plugin updates
This commit is contained in:
@@ -131,6 +131,12 @@ class Block_Styles_Handler {
|
||||
/* Global CSS API: Control - File */
|
||||
'gf-ctrl-file-btn-bg-color-hover' => GFCommon::darken_color( $color_palette['inside-control']['color-darker'], 2 ),
|
||||
|
||||
/* Global CSS API: Field - Choice (Checkbox, Radio, Image, & Consent) */
|
||||
'gf-field-img-choice-size' => 'var(--gf-field-img-choice-size-' . $applied_settings['inputImageChoiceSize'] . ')',
|
||||
'gf-field-img-choice-card-space' => 'var(--gf-field-img-choice-card-space-' . $applied_settings['inputImageChoiceSize'] . ')',
|
||||
'gf-field-img-choice-check-ind-size' => 'var(--gf-field-img-choice-check-ind-size-' . $applied_settings['inputImageChoiceSize'] . ')',
|
||||
'gf-field-img-choice-check-ind-icon-size' => 'var(--gf-field-img-choice-check-ind-icon-size-' . $applied_settings['inputImageChoiceSize'] . ')',
|
||||
|
||||
/* Global CSS API: Field - Page */
|
||||
'gf-field-pg-steps-number-color' => 'rgba(' . implode( ', ', GFCommon::darken_color( $applied_settings['labelColor'], 0, 'rgb' ) ) . ', 0.8)',
|
||||
);
|
||||
@@ -144,7 +150,44 @@ class Block_Styles_Handler {
|
||||
}
|
||||
|
||||
public function styles( $form, $ajax, $settings, $block_settings ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$themes = \GFFormDisplay::get_themes_to_enqueue( $form );
|
||||
$styles = array( 'theme' => array() );
|
||||
|
||||
if ( in_array( 'orbital', $themes ) ) {
|
||||
$styles['theme'] = array( array( 'gravity_forms_orbital_theme' ) );
|
||||
$styles['foundation'] = array( array( 'gravity_forms_theme_foundation' ) );
|
||||
$styles['framework'] = array( array( 'gravity_forms_theme_framework' ) );
|
||||
$styles['reset'] = array( array( 'gravity_forms_theme_reset' ) );
|
||||
|
||||
if ( GFCommon::is_form_editor() ) {
|
||||
$styles['framework'][] = array( 'gravity_forms_theme_framework_admin' );
|
||||
$styles['foundation'][] = array( 'gravity_forms_theme_foundation_admin' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( 'gravity-theme', $themes ) ) {
|
||||
|
||||
if ( GFCommon::is_entry_detail() ) {
|
||||
$styles['theme'][] = array( 'gform_theme_admin' );
|
||||
} else {
|
||||
$styles['theme'][] = array( 'gform_basic' );
|
||||
|
||||
/**
|
||||
* Allows users to disable the main theme.css file from being loaded on the Front End.
|
||||
*
|
||||
* @param boolean Whether to disable the theme css.
|
||||
* @since 2.5-beta-3
|
||||
*
|
||||
*/
|
||||
$disable_theme_css = apply_filters( 'gform_disable_form_theme_css', false );
|
||||
if ( ! $disable_theme_css ) {
|
||||
$styles['theme'][] = array( 'gform_theme' );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $styles;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Gravity_Forms\Gravity_Forms\Form_Display;
|
||||
|
||||
use Gravity_Forms\Gravity_Forms\Config\GF_Config_Service_Provider;
|
||||
use Gravity_Forms\Gravity_Forms\Form_Display\Config\GF_Product_Meta_Config;
|
||||
use Gravity_Forms\Gravity_Forms\Form_Display\Config\GF_Pagination_Config;
|
||||
use Gravity_Forms\Gravity_Forms\Form_Display\Full_Screen\Full_Screen_Handler;
|
||||
use Gravity_Forms\Gravity_Forms\Form_Display\Block_Styles\Block_Styles_Handler;
|
||||
use Gravity_Forms\Gravity_Forms\GF_Service_Container;
|
||||
@@ -25,6 +28,8 @@ class GF_Form_Display_Service_Provider extends GF_Service_Provider {
|
||||
const FULL_SCREEN_HANDLER = 'full_screen_handler';
|
||||
const BLOCK_STYLES_HANDLER = 'block_styles_handler';
|
||||
const BLOCK_STYLES_DEFAULTS = 'block_styles_defaults';
|
||||
const PRODUCT_META_CONFIG = 'products_meta_config';
|
||||
const PAGINATION_CONFIG = 'pagination_config';
|
||||
|
||||
/**
|
||||
* Register services to the container.
|
||||
@@ -38,6 +43,8 @@ class GF_Form_Display_Service_Provider extends GF_Service_Provider {
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/block-styles/views/class-form-view.php' );
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/block-styles/views/class-confirmation-view.php' );
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/block-styles/block-styles-handler.php' );
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/config/class-gf-product-meta-config.php' );
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/config/class-gf-pagination-config.php' );
|
||||
|
||||
$container->add( self::FULL_SCREEN_HANDLER, function() use ( $container ) {
|
||||
// Use string handler for now to avoid JSON query issues on old platforms.
|
||||
@@ -63,6 +70,9 @@ class GF_Form_Display_Service_Provider extends GF_Service_Provider {
|
||||
// should be for the theme framework and CSS API. When empty, it defaults to:
|
||||
// buttonPrimaryBackgroundColor
|
||||
'inputPrimaryColor' => rgar( $form_styles, 'inputPrimaryColor' ) ? $form_styles['inputPrimaryColor'] : '', // #204ce5
|
||||
'inputImageChoiceAppearance' => rgar( $form_styles, 'inputImageChoiceAppearance' ) ? $form_styles['inputImageChoiceAppearance'] : 'card',
|
||||
'inputImageChoiceStyle' => rgar( $form_styles, 'inputImageChoiceStyle' ) ? $form_styles['inputImageChoiceStyle'] : 'square',
|
||||
'inputImageChoiceSize' => rgar( $form_styles, 'inputImageChoiceSize' ) ? $form_styles['inputImageChoiceSize'] : 'md',
|
||||
'labelFontSize' => rgar( $form_styles, 'labelFontSize' ) ? $form_styles['labelFontSize'] : 14,
|
||||
'labelColor' => rgar( $form_styles, 'labelColor' ) ? $form_styles['labelColor'] : '#112337',
|
||||
'descriptionFontSize' => rgar( $form_styles, 'descriptionFontSize' ) ? $form_styles['descriptionFontSize'] : 13,
|
||||
@@ -76,6 +86,19 @@ class GF_Form_Display_Service_Provider extends GF_Service_Provider {
|
||||
$container->add( self::BLOCK_STYLES_HANDLER, function() use ( $container ) {
|
||||
return new Block_Styles_Handler( $container->get( self::BLOCK_STYLES_DEFAULTS ) );
|
||||
});
|
||||
|
||||
// Product meta config.
|
||||
$container->add( self::PRODUCT_META_CONFIG, function () use ( $container ) {
|
||||
return new GF_Product_Meta_Config( $container->get( GF_Config_Service_Provider::DATA_PARSER ) );
|
||||
});
|
||||
$container->get( GF_Config_Service_Provider::CONFIG_COLLECTION )->add_config( $container->get( self::PRODUCT_META_CONFIG ) );
|
||||
|
||||
// Pagination config.
|
||||
$container->add( self::PAGINATION_CONFIG, function () use ( $container ) {
|
||||
return new GF_Pagination_Config( $container->get( GF_Config_Service_Provider::DATA_PARSER ) );
|
||||
});
|
||||
$container->get( GF_Config_Service_Provider::CONFIG_COLLECTION )->add_config( $container->get( self::PAGINATION_CONFIG ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,6 +121,7 @@ class GF_Form_Display_Service_Provider extends GF_Service_Provider {
|
||||
|
||||
add_action( 'gform_enqueue_scripts', array( $this, 'register_theme_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'register_theme_styles' ) );
|
||||
add_action( 'enqueue_block_editor_assets', array( $this, 'register_theme_styles' ) );
|
||||
}
|
||||
|
||||
public function register_theme_styles() {
|
||||
@@ -114,9 +138,15 @@ class GF_Form_Display_Service_Provider extends GF_Service_Provider {
|
||||
*/
|
||||
$disable_css = apply_filters( 'gform_disable_css', get_option( 'rg_gforms_disable_css' ) );
|
||||
|
||||
if ( ! $disable_css ) {
|
||||
if ( GFCommon::is_form_editor() || GFCommon::is_block_editor_page() || ! $disable_css ) {
|
||||
wp_register_style( 'gravity_forms_theme_reset', "{$base_url}/assets/css/dist/gravity-forms-theme-reset{$dev_min}.css", array(), $version );
|
||||
wp_register_style( 'gravity_forms_theme_foundation', "{$base_url}/assets/css/dist/gravity-forms-theme-foundation{$dev_min}.css", array(), $version );
|
||||
wp_register_style(
|
||||
'gravity_forms_theme_foundation_admin',
|
||||
"{$base_url}/assets/css/dist/gravity-forms-theme-foundation-admin{$dev_min}.css",
|
||||
array( 'gravity_forms_theme_foundation' ),
|
||||
$version
|
||||
);
|
||||
wp_register_style(
|
||||
'gravity_forms_theme_framework',
|
||||
"{$base_url}/assets/css/dist/gravity-forms-theme-framework{$dev_min}.css",
|
||||
@@ -126,9 +156,14 @@ class GF_Form_Display_Service_Provider extends GF_Service_Provider {
|
||||
),
|
||||
$version
|
||||
);
|
||||
wp_register_style(
|
||||
'gravity_forms_theme_framework_admin',
|
||||
"{$base_url}/assets/css/dist/gravity-forms-theme-framework-admin{$dev_min}.css",
|
||||
array( 'gravity_forms_theme_framework' ),
|
||||
$version
|
||||
);
|
||||
wp_register_style( 'gravity_forms_orbital_theme', "{$base_url}/assets/css/dist/gravity-forms-orbital-theme{$dev_min}.css", array( 'gravity_forms_theme_framework' ), $version );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Gravity_Forms\Gravity_Forms\Form_Display\Config;
|
||||
|
||||
use Gravity_Forms\Gravity_Forms\Config\GF_Config;
|
||||
|
||||
/**
|
||||
* Form specific product meta config.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
class GF_Pagination_Config extends GF_Config {
|
||||
|
||||
protected $name = 'gform_theme_config';
|
||||
protected $script_to_localize = 'gform_gravityforms_theme';
|
||||
|
||||
/**
|
||||
* Config data.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function data() {
|
||||
|
||||
if ( ! rgar( $this->args, 'form_ids' ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$pagination = array();
|
||||
foreach ( $this->args['form_ids'] as $form_id ) {
|
||||
$form = \GFFormDisplay::gform_pre_render( \GFAPI::get_form( $form_id ), 'form_config' );
|
||||
$pagination[ $form_id ] = rgar( $form, 'pagination' );
|
||||
}
|
||||
|
||||
return array(
|
||||
'common' => array(
|
||||
'form' => array(
|
||||
'pagination' => $pagination,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable ajax loading for the "gform_theme_config/common/form/pagination" config path.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param string $config_path The full path to the config item when stored in the browser's window object, for example: "gform_theme_config/common/form/product_meta"
|
||||
* @param array $args The args used to load the config data. This will be empty for generic config items. For form specific items will be in the format: array( 'form_ids' => array(123,222) ).
|
||||
*
|
||||
* @return bool Return true if the provided $config_path is the product_meta path. Return false otherwise.
|
||||
*/
|
||||
public function enable_ajax( $config_path, $args ) {
|
||||
if ( str_starts_with( $config_path, 'gform_theme_config/common/form/pagination' ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Gravity_Forms\Gravity_Forms\Form_Display\Config;
|
||||
|
||||
use Gravity_Forms\Gravity_Forms\Config\GF_Config;
|
||||
|
||||
/**
|
||||
* Form specific product meta config.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*/
|
||||
class GF_Product_Meta_Config extends GF_Config {
|
||||
|
||||
protected $name = 'gform_theme_config';
|
||||
protected $script_to_localize = 'gform_gravityforms_theme';
|
||||
|
||||
/**
|
||||
* Config data.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function data() {
|
||||
|
||||
if ( ! rgar( $this->args, 'form_ids' ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$product_metas = array();
|
||||
foreach ( $this->args['form_ids'] as $form_id ) {
|
||||
$product_metas[ $form_id ] = $this->get_product_meta( $form_id );
|
||||
}
|
||||
|
||||
return array(
|
||||
'common' => array(
|
||||
'form' => array(
|
||||
'product_meta' => $product_metas,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable ajax loading for the "gform_theme_config/common/form/product_meta" config path.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param string $config_path The full path to the config item when stored in the browser's window object, for example: "gform_theme_config/common/form/product_meta"
|
||||
* @param array $args The args used to load the config data. This will be empty for generic config items. For form specific items will be in the format: array( 'form_ids' => array(123,222) ).
|
||||
*
|
||||
* @return bool Return true if the provided $config_path is the product_meta path. Return false otherwise.
|
||||
*/
|
||||
public function enable_ajax( $config_path, $args ) {
|
||||
if ( str_starts_with( $config_path, 'gform_theme_config/common/form/product_meta' ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product meta for a form.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param int $form_id The form ID.
|
||||
*
|
||||
* @return array|null Returns the product meta for the form. Returns null if the form does not contain any product fields.
|
||||
*/
|
||||
private function get_product_meta( $form_id ) {
|
||||
|
||||
$product_meta = array();
|
||||
$products = array();
|
||||
$form = \GFFormDisplay::gform_pre_render( \GFAPI::get_form( $form_id ), 'form_config' );
|
||||
$product_fields = \GFAPI::get_fields_by_type( $form, array( 'product' ) );
|
||||
if ( empty( $product_fields ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ( $product_fields as $field ) {
|
||||
$products[ $field->id ] = $this->clean_meta( $field );
|
||||
|
||||
$options = array();
|
||||
$option_fields = \GFCommon::get_product_fields_by_type( $form, array( 'option' ), $field->id );
|
||||
if ( empty( $option_fields ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( $option_fields as $option_field ) {
|
||||
$options[ $option_field->id ] = $this->clean_meta( $option_field );
|
||||
}
|
||||
|
||||
$products[ $field->id ]['options'] = $options;
|
||||
}
|
||||
|
||||
if ( !empty( $products ) ) {
|
||||
$product_meta['products'] = $products;
|
||||
}
|
||||
|
||||
$shipping_fields = \GFAPI::get_fields_by_type( $form, array( 'shipping' ) );
|
||||
if ( !empty( $shipping_fields ) ) {
|
||||
$product_meta['shipping'] = $this->clean_meta( $shipping_fields[0] );
|
||||
}
|
||||
|
||||
$product_meta['hash'] = self::hash( $product_meta );
|
||||
|
||||
return $product_meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the field metadata so that it only contains a set of whitelisted properties.
|
||||
*
|
||||
* @param array $data Metadata to be cleaned.
|
||||
*
|
||||
* @return array Returns the clean metadata, only containing a set of whitelisted keys.
|
||||
* @since 2.9.0
|
||||
*
|
||||
*/
|
||||
private function clean_meta( $data )
|
||||
{
|
||||
$whitelisted = array( 'id', 'label', 'choices', 'inputs', 'type', 'inputType', 'basePrice', 'disableQuantity' );
|
||||
|
||||
// Convert to an associative array
|
||||
$data = (array) $data;
|
||||
|
||||
// Filter the array to only include whitelisted properties
|
||||
return array_intersect_key( $data, array_flip( $whitelisted ) );
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,6 @@ class Full_Screen_Handler {
|
||||
* @return string
|
||||
*/
|
||||
public function load_full_screen_template( $template ) {
|
||||
$form_for_display = $this->get_form_for_display();
|
||||
|
||||
/**
|
||||
* External filter usable by third-party code to modify/return the form ID for display. Useful for
|
||||
|
||||
Reference in New Issue
Block a user