plugin install

This commit is contained in:
Tony Volpe
2024-06-18 17:29:05 -04:00
parent e1aaedd1ae
commit 41f50eacc4
5880 changed files with 1057631 additions and 39681 deletions

View File

@@ -0,0 +1,57 @@
<?php
namespace Gravity_Forms\Gravity_Forms\Query\JSON_Handlers;
/**
* Abstract class to provide contract for JSON Handlers used to query against JSON values in the database.
*
* @since 2.7
*/
abstract class GF_JSON_Handler {
const SETTING_NAME = 'form_full_screen_slug';
const SECTION_NAME = 'gf_theme_layers';
/**
* Get the correct setting name to check to enable full screen for a slug.
*
* @since 2.7
*
* @return string
*/
protected function get_setting_name() {
/**
* Filter to allow third-party code to modify the setting name being queried against in the JSON.
*
* @since 2.7
*
* @param string $setting_name The current setting name
*
* @return string
*/
return apply_filters( 'gform_full_screen_display_setting_name', self::SETTING_NAME );
}
protected function get_section_name() {
/**
* Filter to allow third-party code to modify the setting section to query against in the JSON.
*
* @since 2.7
*
* @param string $section_name The current section name
*
* @return string
*/
return apply_filters( 'gform_full_screen_display_setting_group', self::SECTION_NAME );
}
/**
* Perform the DB query to get data.
*
* @param string $slug The slug against which to query.
*
* @return string
*/
abstract public function query( $slug );
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Gravity_Forms\Gravity_Forms\Query\JSON_Handlers;
/**
* GF_JSON_Handler implementation which uses a MySQL JSON query to gather data. More performant that string-based
* queries, but only available in MySQL 5.7+.
*
* @since 2.7
*/
class GF_Query_JSON_Handler extends GF_JSON_Handler {
/**
* Perform the query against the DB.
*
* @param string $slug
*
* @return string
*/
public function query( $slug ) {
global $wpdb;
$setting_name = $this->get_setting_name();
$section = $this->get_section_name();
// JSON Selector is formatted as `{"setting_name": "value"}`
$json_selector = sprintf( '{"%s": "%s"}', $setting_name, $slug );
$query = "SELECT form_id FROM {$wpdb->prefix}gf_form_meta AS meta LEFT JOIN {$wpdb->prefix}gf_form AS form ON form.id = meta.form_id WHERE is_trash = 0 AND is_active = 1 AND JSON_CONTAINS(display_meta, %s, %s)";
// To define a "section" to query against, we pass it as `$.section` as the third argument to JSON_CONTAINS.
$prepared_query = $wpdb->prepare( $query, $json_selector, sprintf( '$.%s', $section ) );
return $wpdb->get_var( $prepared_query );
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Gravity_Forms\Gravity_Forms\Query\JSON_Handlers;
/**
* GF_JSON_Handler implementation which uses a MySQL "LIKE" query. Not as performant as JSON_CONTAINS, but
* available on older (pre-5.7) versions of MySQL.
*
* @since 2.7
*/
class GF_String_JSON_Handler extends GF_JSON_Handler {
public function query( $slug ) {
global $wpdb;
$setting_name = $this->get_setting_name();
$like_statement = sprintf( '%%"%s":"%s"%%', $setting_name, $slug );
$query = "SELECT form_id FROM {$wpdb->prefix}gf_form_meta AS meta LEFT JOIN {$wpdb->prefix}gf_form AS form ON form.id = meta.form_id WHERE is_trash = 0 AND is_active = 1 AND display_meta LIKE %s";
$prepared_query = $wpdb->prepare( $query, $like_statement );
return $wpdb->get_var( $prepared_query );
}
}