version 4.13.0
This commit is contained in:
393
includes/builder/module/settings/Migration.php
Normal file
393
includes/builder/module/settings/Migration.php
Normal file
@ -0,0 +1,393 @@
|
||||
<?php
|
||||
/**
|
||||
* Main migartion class.
|
||||
*
|
||||
* @package Divi
|
||||
* @subpackage Builder
|
||||
* @since ?
|
||||
*/
|
||||
|
||||
/**
|
||||
* Depending on the case (field name) determines the necessary migration scripts and launches it.
|
||||
*
|
||||
* @since ?
|
||||
*/
|
||||
abstract class ET_Builder_Module_Settings_Migration {
|
||||
|
||||
/**
|
||||
* Used to exclude names in case of BB.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $_bb_excluded_name_changes = array();
|
||||
|
||||
/**
|
||||
* Used for migrations where we want to separate the logic for
|
||||
* migrating post attributes and global migrating preset attributes.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $_maybe_global_presets_migration = false;
|
||||
|
||||
/**
|
||||
* Used to migrate field names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $field_name_migrations = array();
|
||||
|
||||
/**
|
||||
* Array of hooks.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $hooks = array(
|
||||
'the_content',
|
||||
'admin_enqueue_scripts',
|
||||
'et_pb_get_backbone_templates',
|
||||
'wp_ajax_et_pb_execute_content_shortcodes',
|
||||
'wp_ajax_et_fb_get_saved_layouts',
|
||||
'wp_ajax_et_fb_retrieve_builder_data',
|
||||
);
|
||||
|
||||
/**
|
||||
* The last checked hook.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $last_hook_checked;
|
||||
/**
|
||||
* Last hook check decision .
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $last_hook_check_decision;
|
||||
|
||||
/**
|
||||
* The largest version of the migrations defined in the migrations array.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $max_version = '4.13.0';
|
||||
|
||||
/**
|
||||
* Array of already migrated data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $migrated = array();
|
||||
|
||||
/**
|
||||
* Array of migrations in format( [ 'version' => 'name of migration script' ] ).
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $migrations = array(
|
||||
'3.0.48' => 'BackgroundUI',
|
||||
'3.0.72' => 'Animation',
|
||||
'3.0.74' => 'OptionsHarmony',
|
||||
'3.0.84' => 'FullwidthHeader',
|
||||
'3.0.87' => 'BorderOptions',
|
||||
'3.0.91' => 'FilterOptions',
|
||||
'3.0.92' => 'ShopModuleSlugs',
|
||||
'3.0.94' => 'DropShadowToBoxShadow',
|
||||
'3.0.99' => 'InnerShadowToBoxShadow',
|
||||
'3.0.102' => 'FullwidthHeader2',
|
||||
'3.2' => 'UIImprovements',
|
||||
'3.4' => 'EmailOptinContent',
|
||||
'3.6' => 'ContactFormItemOptionsSerialization',
|
||||
'3.12.3' => 'TeamMemberIconHover',
|
||||
'3.16' => 'HoverOptions',
|
||||
'3.17.3' => 'DiscontinueHtmlEncoding',
|
||||
'3.22' => 'RowCustomWidthToSizing',
|
||||
'3.22.3' => 'RowZeroGutter',
|
||||
'3.23' => 'OptionsHarmony2',
|
||||
'3.23.4' => 'DividerHeight',
|
||||
'3.25' => 'ColumnOptions',
|
||||
'3.25.3' => 'ShopOrderByDefault',
|
||||
'3.27.4' => 'TextAlignment',
|
||||
'4.13.0' => 'IconManager',
|
||||
);
|
||||
|
||||
/**
|
||||
* Migrations by version.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $migrations_by_version = array();
|
||||
|
||||
/**
|
||||
* Fields.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $fields;
|
||||
|
||||
/**
|
||||
* Modules.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $modules;
|
||||
|
||||
/**
|
||||
* Version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $version;
|
||||
|
||||
/**
|
||||
* Add or not missing fields.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $add_missing_fields = false;
|
||||
|
||||
public function __construct() {
|
||||
$this->fields = $this->get_fields();
|
||||
$this->modules = $this->get_modules();
|
||||
}
|
||||
|
||||
protected static function _migrate_field_names( $fields, $module_slug, $version ) {
|
||||
foreach ( self::$field_name_migrations[ $module_slug ] as $new_name => $old_names ) {
|
||||
foreach ( $old_names as $old_name ) {
|
||||
if ( ! isset( $fields[ $old_name ] ) ) {
|
||||
// Add old to-be-migrated attribute as skipped field if it doesn't exist so its value can be used.
|
||||
$fields[ $old_name ] = array( 'type' => 'skip' );
|
||||
}
|
||||
|
||||
// For the BB...
|
||||
if ( ! in_array( $old_name, self::$_bb_excluded_name_changes ) ) {
|
||||
self::$migrated['field_name_changes'][ $module_slug ][ $old_name ] = array(
|
||||
'new_name' => $new_name,
|
||||
'version' => $version,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
abstract public function get_fields();
|
||||
|
||||
public static function get_migrations( $module_version ) {
|
||||
if ( isset( self::$migrations_by_version[ $module_version ] ) ) {
|
||||
return self::$migrations_by_version[ $module_version ];
|
||||
}
|
||||
|
||||
self::$migrations_by_version[ $module_version ] = array();
|
||||
|
||||
if ( 'all' !== $module_version && version_compare( $module_version, self::$max_version, '>=' ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
foreach ( self::$migrations as $version => $migration ) {
|
||||
if ( 'all' !== $module_version && version_compare( $module_version, $version, '>=' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_string( $migration ) ) {
|
||||
self::$migrations[ $version ] = $migration = require_once "migration/{$migration}.php";
|
||||
}
|
||||
|
||||
self::$migrations_by_version[ $module_version ][] = $migration;
|
||||
}
|
||||
|
||||
return self::$migrations_by_version[ $module_version ];
|
||||
}
|
||||
|
||||
abstract public function get_modules();
|
||||
|
||||
public function get_content_migration_modules() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function handle_field_name_migrations( $fields, $module_slug ) {
|
||||
if ( ! in_array( $module_slug, $this->modules ) ) {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
foreach ( $this->fields as $field_name => $field_info ) {
|
||||
foreach ( $field_info['affected_fields'] as $affected_field => $affected_modules ) {
|
||||
|
||||
if ( $affected_field === $field_name || ! in_array( $module_slug, $affected_modules ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( $affected_modules as $affected_module ) {
|
||||
if ( ! isset( self::$field_name_migrations[ $affected_module ][ $field_name ] ) ) {
|
||||
self::$field_name_migrations[ $affected_module ][ $field_name ] = array();
|
||||
}
|
||||
|
||||
self::$field_name_migrations[ $affected_module ][ $field_name ][] = $affected_field;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isset( self::$field_name_migrations[ $module_slug ] )
|
||||
? self::_migrate_field_names( $fields, $module_slug, $this->version )
|
||||
: $fields;
|
||||
}
|
||||
|
||||
public static function init() {
|
||||
$class = 'ET_Builder_Module_Settings_Migration';
|
||||
|
||||
add_filter( 'et_pb_module_processed_fields', array( $class, 'maybe_override_processed_fields' ), 10, 2 );
|
||||
add_filter( 'et_pb_module_shortcode_attributes', array( $class, 'maybe_override_shortcode_attributes' ), 10, 6 );
|
||||
add_filter( 'et_pb_module_content', array( $class, 'maybe_override_content' ), 10, 6 );
|
||||
}
|
||||
|
||||
public static function maybe_override_processed_fields( $fields, $module_slug ) {
|
||||
if ( ! $fields ) {
|
||||
return $fields;
|
||||
}
|
||||
|
||||
$migrations = self::get_migrations( 'all' );
|
||||
|
||||
foreach ( $migrations as $migration ) {
|
||||
if ( in_array( $module_slug, $migration->modules ) ) {
|
||||
$fields = $migration->handle_field_name_migrations( $fields, $module_slug );
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public static function maybe_override_shortcode_attributes( $attrs, $unprocessed_attrs, $module_slug, $module_address, $content = '', $maybe_global_presets_migration = false ) {
|
||||
if ( empty( $attrs['_builder_version'] ) ) {
|
||||
$attrs['_builder_version'] = '3.0.47';
|
||||
}
|
||||
|
||||
if ( ! self::_should_handle_render( $module_slug ) ) {
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
if ( ! is_array( $unprocessed_attrs ) ) {
|
||||
$unprocessed_attrs = array();
|
||||
}
|
||||
|
||||
self::$_maybe_global_presets_migration = $maybe_global_presets_migration;
|
||||
$migrations = self::get_migrations( $attrs['_builder_version'] );
|
||||
|
||||
// Register address-based name module's field name change
|
||||
if ( isset( self::$migrated['field_name_changes'] ) && isset( self::$migrated['field_name_changes'][ $module_slug ] ) ) {
|
||||
foreach ( self::$migrated['field_name_changes'][ $module_slug ] as $old_name => $name_change ) {
|
||||
if ( version_compare( $attrs['_builder_version'], $name_change['version'], '<' ) ) {
|
||||
self::$migrated['name_changes'][ $module_address ][ $old_name ] = $name_change['new_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $migrations as $migration ) {
|
||||
$migrated_attrs_count = 0;
|
||||
|
||||
if ( ! in_array( $module_slug, $migration->modules ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// It needs for IconManager's wpunit tests when it is necessary to test the migration of module posts attributes
|
||||
// and migration of global presets within the same test session
|
||||
// ( because migration fields array is depending on self::$_maybe_global_presets_migration variable ).
|
||||
$migration_fields = ( 'ET_Builder_Module_Settings_Migration_IconManager' === get_class( $migration ) ) ? $migration->get_fields() : $migration->fields;
|
||||
|
||||
foreach ( $migration_fields as $field_name => $field_info ) {
|
||||
foreach ( $field_info['affected_fields'] as $affected_field => $affected_modules ) {
|
||||
|
||||
if ( ( ! $migration->add_missing_fields && ! isset( $attrs[ $affected_field ] ) ) || ! in_array( $module_slug, $affected_modules ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $affected_field !== $field_name ) {
|
||||
// Field name changed
|
||||
$unprocessed_attrs[ $field_name ] = $attrs[ $affected_field ];
|
||||
}
|
||||
|
||||
$current_value = isset( $unprocessed_attrs[ $field_name ] ) ? $unprocessed_attrs[ $field_name ] : '';
|
||||
|
||||
$saved_value = isset( $attrs[ $field_name ] ) ? $attrs[ $field_name ] : '';
|
||||
|
||||
$new_value = $migration->migrate( $field_name, $current_value, $module_slug, $saved_value, $affected_field, $attrs, $content, $module_address );
|
||||
|
||||
if ( $new_value !== $saved_value || ( $affected_field !== $field_name && $new_value !== $current_value ) ) {
|
||||
$attrs[ $field_name ] = self::$migrated['value_changes'][ $module_address ][ $field_name ] = $new_value;
|
||||
$migrated_attrs_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $migrated_attrs_count > 0 ) {
|
||||
$attrs['_builder_version'] = $migration->version;
|
||||
}
|
||||
}
|
||||
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
public static function maybe_override_content( $content, $attrs, $unprocessed_attrs, $module_slug, $module_address, $global_content ) {
|
||||
if ( empty( $attrs['_builder_version'] ) ) {
|
||||
$attrs['_builder_version'] = '3.0.47';
|
||||
}
|
||||
|
||||
if ( ! self::_should_handle_render( $module_slug ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$migrations = self::get_migrations( $attrs['_builder_version'] );
|
||||
|
||||
foreach ( $migrations as $migration ) {
|
||||
$migrated_content = false;
|
||||
|
||||
if ( ! in_array( $module_slug, $migration->get_content_migration_modules() ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( $migration->get_content_migration_modules() as $module ) {
|
||||
$new_content = $migration->migrate_content( $module_slug, $attrs, $content );
|
||||
|
||||
if ( $new_content !== $content ) {
|
||||
$migrated_content = true;
|
||||
}
|
||||
|
||||
$content = $new_content;
|
||||
}
|
||||
|
||||
if ( $migrated_content ) {
|
||||
$attrs['_builder_version'] = $migration->version;
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
abstract public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address );
|
||||
|
||||
// this could have been written as abstract, but its not as common so as to be expected to be implemented by every migration
|
||||
public function migrate_content( $module_slug, $attrs, $content ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
public static function _should_handle_render( $slug ) {
|
||||
if ( false === strpos( $slug, 'et_pb' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
global $wp_current_filter;
|
||||
$current_hook = $wp_current_filter[0];
|
||||
|
||||
if ( $current_hook === self::$last_hook_checked ) {
|
||||
return self::$last_hook_check_decision;
|
||||
}
|
||||
|
||||
self::$last_hook_checked = $current_hook;
|
||||
|
||||
foreach ( self::$hooks as $hook ) {
|
||||
if ( $hook === $current_hook && did_action( $hook ) > 1 ) {
|
||||
return self::$last_hook_check_decision = false;
|
||||
}
|
||||
}
|
||||
|
||||
return self::$last_hook_check_decision = true;
|
||||
}
|
||||
}
|
101
includes/builder/module/settings/migration/Animation.php
Normal file
101
includes/builder/module/settings/migration/Animation.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_Animation extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.0.72';
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'animation_style' => array(
|
||||
'affected_fields' => array(
|
||||
'animation' => $this->get_modules( 'image' ),
|
||||
),
|
||||
'map' => array(
|
||||
'off' => 'none',
|
||||
'fade_in' => 'fade',
|
||||
),
|
||||
),
|
||||
'animation_duration' => array(
|
||||
'affected_fields' => array(
|
||||
'animation' => $this->get_modules( 'image' ),
|
||||
),
|
||||
),
|
||||
'animation_intensity_slide' => array(
|
||||
'affected_fields' => array(
|
||||
'animation' => $this->get_modules( 'image' ),
|
||||
),
|
||||
),
|
||||
'animation_direction' => array(
|
||||
'affected_fields' => array(
|
||||
'animation' => $this->get_modules( 'image' ),
|
||||
),
|
||||
'map' => array(
|
||||
'off' => '',
|
||||
'fade_in' => 'center',
|
||||
'' => 'left',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_modules( $group = '' ) {
|
||||
$modules = array();
|
||||
|
||||
if ( in_array( $group, array( '', 'image' ) ) ) {
|
||||
$modules[] = 'et_pb_image';
|
||||
$modules[] = 'et_pb_fullwidth_image';
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
// Image & Fullwidth Image modules migration setting
|
||||
if ( in_array( $module_slug, $this->get_modules( 'image' ) ) ) {
|
||||
|
||||
// Migrate 'animation' attribute value to new animation UI attributes.
|
||||
// The following migration setting is basically default value for image module's legacy animation setting
|
||||
if ( 'animation' === $saved_field_name ) {
|
||||
|
||||
// Image module specific override
|
||||
if ( 'et_pb_image' === $module_slug ) {
|
||||
// Overwrite default animation if global setting is modified via customizer
|
||||
$global_animation_direction = ET_Global_Settings::get_value( 'et_pb_image-animation' );
|
||||
$default_animation = $global_animation_direction && '' !== $global_animation_direction ? $global_animation_direction : 'left';
|
||||
|
||||
if ( '' === $current_value ) {
|
||||
$current_value = $default_animation;
|
||||
}
|
||||
}
|
||||
|
||||
// Animation is set to off on legacy animation setting
|
||||
$is_animation_off = 'off' === $current_value;
|
||||
|
||||
// Set animation duration to 500ms
|
||||
if ( 'animation_duration' === $field_name && ! $is_animation_off ) {
|
||||
return '500ms';
|
||||
}
|
||||
|
||||
// Set animation intensity to 10%
|
||||
if ( 'animation_intensity_slide' === $field_name && ! $is_animation_off ) {
|
||||
return '10%';
|
||||
}
|
||||
|
||||
// Map animation style to provided configuration, otherwise it is 'slide' style
|
||||
if ( 'animation_style' === $field_name ) {
|
||||
return isset( $this->fields['animation_style']['map'][ $current_value ] ) ? $this->fields['animation_style']['map'][ $current_value ] : 'slide';
|
||||
}
|
||||
|
||||
// Map animation direction to provided configuration, otherwise keep current value
|
||||
if ( 'animation_direction' === $field_name ) {
|
||||
return isset( $this->fields['animation_direction']['map'][ $current_value ] ) ? $this->fields['animation_direction']['map'][ $current_value ] : $current_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_Animation();
|
80
includes/builder/module/settings/migration/BackgroundUI.php
Normal file
80
includes/builder/module/settings/migration/BackgroundUI.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_BackgroundUI extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.0.48';
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'background_image' => array(
|
||||
'affected_fields' => array(
|
||||
'background_url' => array( 'et_pb_fullwidth_header' ),
|
||||
),
|
||||
),
|
||||
'background_position' => array(
|
||||
'affected_fields' => array(
|
||||
'background_position' => $this->get_modules( true ),
|
||||
),
|
||||
'defaults' => array(
|
||||
'new' => 'center', // just fyi
|
||||
'old' => 'top_left',
|
||||
),
|
||||
),
|
||||
'background_repeat' => array(
|
||||
'affected_fields' => array(
|
||||
'background_repeat' => $this->get_modules( true ),
|
||||
),
|
||||
'defaults' => array(
|
||||
'new' => 'no-repeat', // just fyi
|
||||
'old' => 'repeat',
|
||||
),
|
||||
),
|
||||
'background_size' => array(
|
||||
'affected_fields' => array(
|
||||
'background_size' => $this->get_modules( true ),
|
||||
),
|
||||
'defaults' => array(
|
||||
'new' => 'cover', // just fyi
|
||||
'old' => 'initial',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_modules( $for_affected_fields = false ) {
|
||||
$modules = array(
|
||||
'et_pb_audio',
|
||||
'et_pb_blurb',
|
||||
'et_pb_countdown_timer',
|
||||
'et_pb_cta',
|
||||
'et_pb_filterable_portfolio',
|
||||
'et_pb_fullwidth_portfolio',
|
||||
'et_pb_number_counter',
|
||||
'et_pb_team_member',
|
||||
'et_pb_portfolio',
|
||||
'et_pb_row',
|
||||
'et_pb_tab',
|
||||
'et_pb_tabs',
|
||||
'et_pb_testimonial',
|
||||
'et_pb_text',
|
||||
'et_pb_toggle',
|
||||
);
|
||||
|
||||
if ( ! $for_affected_fields ) {
|
||||
$modules[] = 'et_pb_fullwidth_header';
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
if ( '' !== $current_value || 'background_image' === $field_name ) {
|
||||
return $current_value;
|
||||
}
|
||||
|
||||
return $this->fields[ $field_name ]['defaults']['old'];
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_BackgroundUI();
|
304
includes/builder/module/settings/migration/BorderOptions.php
Normal file
304
includes/builder/module/settings/migration/BorderOptions.php
Normal file
@ -0,0 +1,304 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_BorderOptions extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.0.87';
|
||||
public $defaults = array(
|
||||
'all_modules' => array(
|
||||
'width' => '0px',
|
||||
'color' => '#ffffff',
|
||||
'style' => 'solid',
|
||||
),
|
||||
'post_based' => array(
|
||||
'width' => '1px',
|
||||
),
|
||||
'toggles_and_tabs' => array(
|
||||
'width' => '1px',
|
||||
'color' => '#d9d9d9',
|
||||
'style' => 'solid',
|
||||
),
|
||||
'et_pb_contact_form' => array(
|
||||
'width' => '1px',
|
||||
),
|
||||
'et_pb_contact_field' => array(
|
||||
'width' => '14px',
|
||||
'color' => '#bbb',
|
||||
),
|
||||
'et_pb_blog' => array(
|
||||
'width' => '1px',
|
||||
'color' => '#d8d8d8',
|
||||
'style' => 'solid',
|
||||
),
|
||||
'et_pb_signup' => array(
|
||||
'width' => '1px',
|
||||
),
|
||||
);
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
self::$_bb_excluded_name_changes[] = 'use_border_color';
|
||||
self::$_bb_excluded_name_changes[] = 'use_focus_border_color';
|
||||
}
|
||||
|
||||
public function _get_border_style_default( $module_slug, $field_name ) {
|
||||
$field_name = str_replace( 'border_', '', $field_name );
|
||||
$default_key = 'all_modules';
|
||||
$toggles_and_tabs = array( 'et_pb_toggle', 'et_pb_accordion', 'et_pb_accordion_item', 'et_pb_tabs' );
|
||||
$post_based = array( 'et_pb_portfolio', 'et_pb_filterable_portfolio', 'et_pb_gallery' );
|
||||
|
||||
if ( in_array( $module_slug, $toggles_and_tabs ) ) {
|
||||
$default_key = 'toggles_and_tabs';
|
||||
} elseif ( in_array( $module_slug, $post_based ) ) {
|
||||
$default_key = 'post_based';
|
||||
} elseif ( isset( $this->defaults[ $module_slug ][ $field_name ] ) ) {
|
||||
$default_key = $module_slug;
|
||||
}
|
||||
|
||||
if ( isset( $this->defaults[ $default_key ][ $field_name ] ) ) {
|
||||
$default = $this->defaults[ $default_key ][ $field_name ];
|
||||
} else {
|
||||
$default = $this->defaults['all_modules'][ $field_name ];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function get_modules( $group = '' ) {
|
||||
$modules = array();
|
||||
|
||||
if ( in_array( $group, array( '', 'border' ) ) ) {
|
||||
$modules[] = 'et_pb_accordion';
|
||||
$modules[] = 'et_pb_audio';
|
||||
$modules[] = 'et_pb_counters';
|
||||
$modules[] = 'et_pb_blog';
|
||||
$modules[] = 'et_pb_blurb';
|
||||
$modules[] = 'et_pb_cta';
|
||||
$modules[] = 'et_pb_comments';
|
||||
$modules[] = 'et_pb_contact_form';
|
||||
$modules[] = 'et_pb_contact_field';
|
||||
$modules[] = 'et_pb_signup';
|
||||
$modules[] = 'et_pb_image';
|
||||
$modules[] = 'et_pb_login';
|
||||
$modules[] = 'et_pb_number_counter';
|
||||
$modules[] = 'et_pb_team_member';
|
||||
$modules[] = 'et_pb_post_nav';
|
||||
$modules[] = 'et_pb_post_title';
|
||||
$modules[] = 'et_pb_pricing_tables';
|
||||
$modules[] = 'et_pb_tabs';
|
||||
$modules[] = 'et_pb_testimonial';
|
||||
$modules[] = 'et_pb_text';
|
||||
$modules[] = 'et_pb_toggle';
|
||||
$modules[] = 'et_pb_fullwidth_image';
|
||||
$modules[] = 'et_pb_fullwidth_post_title';
|
||||
$modules[] = 'et_pb_filterable_portfolio';
|
||||
$modules[] = 'et_pb_gallery';
|
||||
$modules[] = 'et_pb_portfolio';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'border_fullwidth' ) ) ) {
|
||||
$modules[] = 'et_pb_blog';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'image_border' ) ) ) {
|
||||
$modules[] = 'et_pb_fullwidth_portfolio';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'border_radius' ) ) ) {
|
||||
$modules[] = 'et_pb_counters';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'input_border_radius' ) ) ) {
|
||||
$modules[] = 'et_pb_contact_form';
|
||||
$modules[] = 'et_pb_contact_field';
|
||||
$modules[] = 'et_pb_comments';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'portrait_border_radius' ) ) ) {
|
||||
$modules[] = 'et_pb_testimonial';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'use_focus_border_color' ) ) ) {
|
||||
$modules[] = 'et_pb_login';
|
||||
$modules[] = 'et_pb_signup';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'link_shape' ) ) ) {
|
||||
$modules[] = 'et_pb_social_media_follow';
|
||||
}
|
||||
|
||||
return array_unique( $modules );
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'border_color_all' => array(
|
||||
'affected_fields' => array(
|
||||
'use_border_color' => $this->get_modules( 'border' ),
|
||||
'border_color' => $this->get_modules( 'border' ),
|
||||
),
|
||||
),
|
||||
'border_width_all' => array(
|
||||
'affected_fields' => array(
|
||||
'border_width' => $this->get_modules( 'border' ),
|
||||
),
|
||||
),
|
||||
'border_style_all' => array(
|
||||
'affected_fields' => array(
|
||||
'border_style' => $this->get_modules( 'border' ),
|
||||
),
|
||||
),
|
||||
|
||||
'border_color_all_fullwidth' => array(
|
||||
'affected_fields' => array(
|
||||
'use_border_color' => $this->get_modules( 'border_fullwidth' ),
|
||||
'border_color' => $this->get_modules( 'border_fullwidth' ),
|
||||
),
|
||||
),
|
||||
'border_width_all_fullwidth' => array(
|
||||
'affected_fields' => array(
|
||||
'border_width' => $this->get_modules( 'border_fullwidth' ),
|
||||
),
|
||||
),
|
||||
'border_style_all_fullwidth' => array(
|
||||
'affected_fields' => array(
|
||||
'border_style' => $this->get_modules( 'border_fullwidth' ),
|
||||
),
|
||||
),
|
||||
// migrate module image borders
|
||||
'border_color_all_image' => array(
|
||||
'affected_fields' => array(
|
||||
'use_border_color' => $this->get_modules( 'image_border' ),
|
||||
'border_color' => $this->get_modules( 'image_border' ),
|
||||
),
|
||||
),
|
||||
'border_width_all_image' => array(
|
||||
'affected_fields' => array(
|
||||
'border_width' => $this->get_modules( 'image_border' ),
|
||||
),
|
||||
),
|
||||
'border_style_all_image' => array(
|
||||
'affected_fields' => array(
|
||||
'border_style' => $this->get_modules( 'image_border' ),
|
||||
),
|
||||
),
|
||||
|
||||
// migrate focus border color
|
||||
'border_color_all_fields_focus' => array(
|
||||
'affected_fields' => array(
|
||||
'use_focus_border_color' => $this->get_modules( 'use_focus_border_color' ),
|
||||
'use_border_color' => $this->get_modules( 'use_focus_border_color' ),
|
||||
'focus_border_color' => $this->get_modules( 'use_focus_border_color' ),
|
||||
),
|
||||
),
|
||||
'border_width_all_fields_focus' => array(
|
||||
'affected_fields' => array(
|
||||
'use_focus_border_color' => $this->get_modules( 'use_focus_border_color' ),
|
||||
),
|
||||
),
|
||||
'border_style_all_fields_focus' => array(
|
||||
'affected_fields' => array(
|
||||
'use_focus_border_color' => $this->get_modules( 'use_focus_border_color' ),
|
||||
),
|
||||
),
|
||||
|
||||
'border_radii' => array(
|
||||
'affected_fields' => array(
|
||||
'border_radius' => $this->get_modules( 'border_radius' ),
|
||||
'input_border_radius' => $this->get_modules( 'input_border_radius' ),
|
||||
'link_shape' => $this->get_modules( 'link_shape' ),
|
||||
),
|
||||
),
|
||||
|
||||
'border_radii_portrait' => array(
|
||||
'affected_fields' => array(
|
||||
'portrait_border_radius' => $this->get_modules( 'portrait_border_radius' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
// Border Radius setting migration setting
|
||||
if ( in_array( $module_slug, $this->get_modules( 'border_radius' ) ) ) {
|
||||
if ( 'border_radius' === $saved_field_name ) {
|
||||
return $this->migrate_border_radius( $current_value );
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( $module_slug, $this->get_modules( 'input_border_radius' ) ) ) {
|
||||
if ( 'input_border_radius' === $saved_field_name ) {
|
||||
return $this->migrate_border_radius( $current_value );
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( $module_slug, $this->get_modules( 'portrait_border_radius' ) ) ) {
|
||||
if ( 'portrait_border_radius' === $saved_field_name ) {
|
||||
if ( ! empty( $current_value ) ) {
|
||||
return $this->migrate_border_radius( $current_value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( $module_slug, $this->get_modules( 'link_shape' ) ) ) {
|
||||
if ( ( 'link_shape' === $saved_field_name ) ) {
|
||||
if ( $current_value === 'circle' ) {
|
||||
return 'on|100%|100%|100%|100%';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$focus_fields = array( 'border_width_all_fields_focus', 'border_style_all_fields_focus', 'border_color_all_fields_focus' );
|
||||
|
||||
if ( in_array( $field_name, $focus_fields ) && in_array( $module_slug, $this->get_modules( 'use_focus_border_color' ) ) ) {
|
||||
if ( 'use_focus_border_color' !== $saved_field_name ) {
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
if ( 'on' === $attrs['use_focus_border_color'] ) {
|
||||
switch ( $field_name ) {
|
||||
case 'border_width_all_fields_focus':
|
||||
$current_value = '1px';
|
||||
break;
|
||||
case 'border_style_all_fields_focus':
|
||||
$current_value = 'solid';
|
||||
break;
|
||||
case 'border_color_all_fields_focus':
|
||||
$color = '#ffffff';
|
||||
if ( isset( $attrs['focus_border_color'] ) ) {
|
||||
$color = $attrs['focus_border_color'];
|
||||
}
|
||||
$current_value = $color;
|
||||
break;
|
||||
default:
|
||||
$current_value = '';
|
||||
}
|
||||
|
||||
return $current_value;
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( $saved_field_name, array( 'border_width', 'border_style', 'border_color' ) ) ) {
|
||||
if ( isset( $attrs['use_border_color'] ) && 'on' === $attrs['use_border_color'] ) {
|
||||
if ( '' === $current_value || 'default' === $current_value ) {
|
||||
$current_value = $this->_get_border_style_default( $module_slug, $saved_field_name );
|
||||
}
|
||||
|
||||
return $current_value;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
private function migrate_border_radius( $radius_value ) {
|
||||
$value = is_numeric( $radius_value ) ? $radius_value . 'px' : $radius_value;
|
||||
$value_array = array_fill( 0, 4, $value );
|
||||
|
||||
return 'on|' . implode( '|', $value_array );
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_BorderOptions();
|
221
includes/builder/module/settings/migration/ColumnOptions.php
Normal file
221
includes/builder/module/settings/migration/ColumnOptions.php
Normal file
@ -0,0 +1,221 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_ColumnOptions extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.25';
|
||||
|
||||
public $add_missing_fields = true;
|
||||
|
||||
public $columnSettingsFromRow = array();
|
||||
|
||||
public $fieldsWithSuffix = array(
|
||||
'padding' => array( 'tablet', 'phone', 'last_edited', '_hover', '_hover_enabled' ),
|
||||
'padding_top' => array( '_hover', '_hover_enabled' ),
|
||||
'padding_right' => array( '_hover', '_hover_enabled' ),
|
||||
'padding_bottom' => array( '_hover', '_hover_enabled' ),
|
||||
'padding_left' => array( '_hover', '_hover_enabled' ),
|
||||
'background_color' => array( '_hover', '_hover_enabled' ),
|
||||
'custom_css_before' => array( '_hover', '_hover_enabled' ),
|
||||
'custom_css_main' => array( '_hover', '_hover_enabled' ),
|
||||
'custom_css_after' => array( '_hover', '_hover_enabled' ),
|
||||
);
|
||||
|
||||
public $fieldsWithSuffixAppended = array(
|
||||
'custom_padding' => '__no_suffix__',
|
||||
'custom_padding_tablet' => 'custom_padding',
|
||||
'custom_padding_phone' => 'custom_padding',
|
||||
'custom_padding_last_edited' => 'custom_padding',
|
||||
'custom_padding__hover' => '__no_suffix__',
|
||||
'custom_padding__hover_enabled' => 'custom_padding',
|
||||
'background_color__hover' => 'background_color',
|
||||
'background_color__hover_enabled' => 'background_color',
|
||||
'custom_css_before' => '__no_suffix__',
|
||||
'custom_css_main_element' => '__no_suffix__',
|
||||
'custom_css_after' => '__no_suffix__',
|
||||
'custom_css_before__hover' => 'custom_css_before',
|
||||
'custom_css_main_element__hover' => 'custom_css_main_element',
|
||||
'custom_css_after__hover' => 'custom_css_after',
|
||||
'custom_css_before__hover_enabled' => 'custom_css_before',
|
||||
'custom_css_main_element__hover_enabled' => 'custom_css_main_element',
|
||||
'custom_css_after__hover_enabled' => 'custom_css_after',
|
||||
);
|
||||
|
||||
public function get_modules() {
|
||||
return array( 'et_pb_row', 'et_pb_column', 'et_pb_row_inner', 'et_pb_column_inner' );
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$fields = array();
|
||||
$fields_to_migrate = array(
|
||||
'module_id',
|
||||
'module_class',
|
||||
'background_color',
|
||||
'bg_img',
|
||||
'background_size',
|
||||
'background_position',
|
||||
'background_repeat',
|
||||
'background_blend',
|
||||
'padding_top',
|
||||
'padding_right',
|
||||
'padding_bottom',
|
||||
'padding_left',
|
||||
'padding',
|
||||
'parallax',
|
||||
'parallax_method',
|
||||
'custom_css_before',
|
||||
'custom_css_main',
|
||||
'custom_css_after',
|
||||
'use_background_color_gradient',
|
||||
'background_color_gradient_type',
|
||||
'background_color_gradient_direction',
|
||||
'background_color_gradient_direction_radial',
|
||||
'background_color_gradient_start',
|
||||
'background_color_gradient_end',
|
||||
'background_color_gradient_start_position',
|
||||
'background_color_gradient_end_position',
|
||||
'background_color_gradient_overlays_image',
|
||||
'background_video_mp4',
|
||||
'background_video_webm',
|
||||
'background_video_width',
|
||||
'background_video_height',
|
||||
'allow_player_pause',
|
||||
'background_video_pause_outside_viewport',
|
||||
);
|
||||
|
||||
foreach ( $this->get_modules() as $module ) {
|
||||
foreach ( $fields_to_migrate as $field_name_raw ) {
|
||||
$field_name = $field_name_raw;
|
||||
|
||||
if ( in_array( $module, array( 'et_pb_row', 'et_pb_row_inner' ) ) ) {
|
||||
$max_columns_number = 'et_pb_row_inner' === $module ? 4 : 6;
|
||||
for ( $i = 1; $i <= $max_columns_number; $i++ ) {
|
||||
if ( array_key_exists( $field_name_raw, $this->fieldsWithSuffix ) ) {
|
||||
foreach ( $this->fieldsWithSuffix[ $field_name_raw ] as $suffix ) {
|
||||
$fields[ "${field_name}_${i}_$suffix" ] = array(
|
||||
'affected_fields' => array(
|
||||
"${field_name}_${i}_$suffix" => array( 'et_pb_row', 'et_pb_row_inner' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$fields[ "${field_name}_${i}" ] = array(
|
||||
'affected_fields' => array(
|
||||
"${field_name}_${i}" => array( 'et_pb_row', 'et_pb_row_inner' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( $module, array( 'et_pb_column', 'et_pb_column_inner' ) ) ) {
|
||||
if ( in_array( $field_name, array( 'padding_top', 'padding_right', 'padding_bottom', 'padding_left' ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ( $field_name ) {
|
||||
case 'bg_img':
|
||||
$field_name = 'background_image';
|
||||
break;
|
||||
case 'padding':
|
||||
$field_name = 'custom_padding';
|
||||
break;
|
||||
case 'custom_css_main':
|
||||
$field_name = 'custom_css_main_element';
|
||||
break;
|
||||
}
|
||||
|
||||
if ( array_key_exists( $field_name_raw, $this->fieldsWithSuffix ) ) {
|
||||
foreach ( $this->fieldsWithSuffix[ $field_name_raw ] as $suffix ) {
|
||||
$fields[ "${field_name}_${suffix}" ] = array(
|
||||
'affected_fields' => array(
|
||||
"${field_name}_${suffix}" => array( 'et_pb_column', 'et_pb_column_inner' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$fields[ $field_name ] = array(
|
||||
'affected_fields' => array(
|
||||
$field_name => array( 'et_pb_column', 'et_pb_column_inner' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function migrate_padding( $row_address, $column_index, $field_name, $saved_value ) {
|
||||
$padding_sides = array( 'padding_top', 'padding_right', 'padding_bottom', 'padding_left' );
|
||||
$padding_combined = array();
|
||||
$suffix = str_replace( 'padding', '', $field_name );
|
||||
|
||||
// If padding was migrated already, no need to process it again.
|
||||
if ( ! empty( $saved_value ) ) {
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
foreach ( $padding_sides as $side ) {
|
||||
if ( isset( $this->columnSettingsFromRow[ $row_address ], $this->columnSettingsFromRow[ $row_address ][ "${side}_${column_index}${suffix}" ] ) ) {
|
||||
$padding_combined[] = $this->columnSettingsFromRow[ $row_address ][ "${side}_${column_index}${suffix}" ];
|
||||
} else {
|
||||
$padding_combined[] = '';
|
||||
}
|
||||
}
|
||||
|
||||
return implode( '|', $padding_combined );
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
if ( in_array( $module_slug, array( 'et_pb_row', 'et_pb_row_inner' ) ) ) {
|
||||
$this->columnSettingsFromRow[ $module_address ][ $field_name ] = $saved_value;
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( in_array( $module_slug, array( 'et_pb_column', 'et_pb_column_inner' ) ) ) {
|
||||
$row_level = 'et_pb_column_inner' === $module_slug ? 3 : 2;
|
||||
$address_array = explode( '.', $module_address );
|
||||
$parent_row = implode( '.', array_slice( $address_array, 0, $row_level ) );
|
||||
$column_index = (int) implode( '', array_slice( $address_array, $row_level, 1 ) ) + 1;
|
||||
|
||||
if ( in_array( $field_name, array_keys( $this->fieldsWithSuffixAppended ) ) ) {
|
||||
$field_name_without_suffix = $this->fieldsWithSuffixAppended[ $field_name ];
|
||||
$field_name_replacement = $field_name_without_suffix;
|
||||
|
||||
if ( in_array( $field_name, array( 'custom_padding', 'custom_padding__hover' ) ) ) {
|
||||
$field_name = str_replace( 'custom_', '', $field_name );
|
||||
}
|
||||
|
||||
if ( 'custom_css_main_element' === $field_name ) {
|
||||
$field_name = 'custom_css_main';
|
||||
}
|
||||
|
||||
if ( in_array( $field_name, array( 'custom_padding_phone', 'custom_padding_tablet', 'custom_padding_last_edited', 'custom_padding__hover', 'custom_padding__hover_enabled' ) ) ) {
|
||||
$field_name_replacement = 'padding';
|
||||
}
|
||||
|
||||
if ( in_array( $field_name, array( 'custom_css_main_element__hover', 'custom_css_main_element__hover_enabled' ) ) ) {
|
||||
$field_name_replacement = 'custom_css_main';
|
||||
}
|
||||
|
||||
// Insert the column index in the middle of field name right before suffix.
|
||||
$row_field_name = '__no_suffix__' === $field_name_without_suffix ? "${field_name}_${column_index}" : str_replace( $field_name_without_suffix, "${field_name_replacement}_${column_index}", $field_name );
|
||||
} else {
|
||||
$row_field_name = 'background_image' === $field_name ? "bg_img_${column_index}" : "${field_name}_${column_index}";
|
||||
}
|
||||
|
||||
if ( in_array( $field_name, array( 'padding', 'padding__hover' ) ) ) {
|
||||
return $this->migrate_padding( $parent_row, $column_index, $field_name, $saved_value );
|
||||
}
|
||||
|
||||
if ( isset( $this->columnSettingsFromRow[ $parent_row ], $this->columnSettingsFromRow[ $parent_row ][ $row_field_name ] ) && ! empty( $this->columnSettingsFromRow[ $parent_row ][ $row_field_name ] ) ) {
|
||||
return $this->columnSettingsFromRow[ $parent_row ][ $row_field_name ];
|
||||
}
|
||||
}
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_ColumnOptions();
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Migration for the ContactFormItem module which fixes quote serialization for checkbox, radio and select field options.
|
||||
*
|
||||
* @since 3.10
|
||||
*/
|
||||
class ET_Builder_Module_Settings_Migration_ContactFormItemOptionsSerialization extends ET_Builder_Module_Settings_Migration {
|
||||
public function get_modules() {
|
||||
return array( 'et_pb_contact_field' );
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'checkbox_options' => array(
|
||||
'affected_fields' => array(
|
||||
'checkbox_options' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'radio_options' => array(
|
||||
'affected_fields' => array(
|
||||
'radio_options' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'select_options' => array(
|
||||
'affected_fields' => array(
|
||||
'select_options' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
if ( json_decode( $saved_value ) ) {
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
$pattern = '/
|
||||
\{
|
||||
("value":")(.*?)(",)
|
||||
(
|
||||
"checked":.,?
|
||||
.*?
|
||||
)
|
||||
\}
|
||||
/ix';
|
||||
|
||||
$saved_value = preg_replace_callback( $pattern, array( $this, 'escape_quotes' ), $saved_value );
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
public function escape_quotes( $matches ) {
|
||||
return '{' . $matches[1] . preg_replace( '/(?<!\\\\)"/', '\\"', $matches[2] ) . $matches[3] . $matches[4] . '}';
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_ContactFormItemOptionsSerialization();
|
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* Migration for the Code Module and Signup Module that had values html encoded.
|
||||
*
|
||||
* @since 3.15.1
|
||||
*/
|
||||
class ET_Builder_Module_Settings_Migration_DiscontinueHtmlEncoding extends ET_Builder_Module_Settings_Migration {
|
||||
public function get_modules( $group = '' ) {
|
||||
$modules = array();
|
||||
|
||||
if ( in_array( $group, array( '', 'signup' ) ) ) {
|
||||
$modules[] = 'et_pb_signup';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'code' ) ) ) {
|
||||
$modules[] = 'et_pb_code';
|
||||
$modules[] = 'et_pb_fullwidth_code';
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'raw_content' => array(
|
||||
'affected_fields' => array(
|
||||
'raw_content' => $this->get_modules( 'code' ),
|
||||
),
|
||||
),
|
||||
'description' => array(
|
||||
'affected_fields' => array(
|
||||
'description' => $this->get_modules( 'signup' ),
|
||||
),
|
||||
),
|
||||
'footer_content' => array(
|
||||
'affected_fields' => array(
|
||||
'footer_content' => $this->get_modules( 'signup' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
private function decode_code_module_raw_content( $content ) {
|
||||
// convert previously escaped/encoded content back to normal
|
||||
$content = et_builder_replace_code_content_entities( $content );
|
||||
$content = ET_Builder_Element::convert_smart_quotes_and_amp( $content );
|
||||
|
||||
// TODO, not sure about this, but single quotes were encoded so this seemed to be needed
|
||||
$content = str_replace( ''', "'", $content );
|
||||
|
||||
$author_id = get_post_field( 'post_author', get_the_ID() ) || get_current_user_id();
|
||||
|
||||
if ( ! user_can( $author_id, 'unfiltered_html' ) ) {
|
||||
$content = $this->_post_content_capability_check( $content );
|
||||
}
|
||||
|
||||
$content = html_entity_decode( $content, ENT_QUOTES );
|
||||
|
||||
// Only apply this aspect of the migration on FE, its not needed to run in VB or BB,
|
||||
// thats the purpose ! is_admin() check is serving in this case.
|
||||
if ( ! is_admin() ) {
|
||||
// convert <br /> tags into placeholder so wpautop will leave them alone.
|
||||
$content = preg_replace( '|<br[\s]?[\/]?>|', '<!–- [et_pb_br_holder] -–>', $content );
|
||||
|
||||
// convert <p> tag to <pee> tag, so wpautop will leave them alone,
|
||||
// *and* so that we can clearly spot the <p> tags that wpautop adds
|
||||
// so we can quickly remove them.
|
||||
$content = preg_replace( '|<p |', '<pee ', $content );
|
||||
$content = preg_replace( '|<p>|', '<pee>', $content );
|
||||
$content = preg_replace( '|<\/p>|', '</pee>', $content );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
|
||||
// code module migration for BB
|
||||
if ( in_array( $module_slug, $this->get_modules( 'code' ) ) && 'raw_content' === $saved_field_name ) {
|
||||
return $this->decode_code_module_raw_content( $content );
|
||||
}
|
||||
|
||||
$signup_fields = array( 'description', 'footer_content' );
|
||||
|
||||
if ( in_array( $module_slug, $this->get_modules( 'signup' ) ) && in_array( $saved_field_name, $signup_fields ) ) {
|
||||
return html_entity_decode( $saved_value, ENT_COMPAT, 'UTF-8' );
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
public function get_content_migration_modules( $group = '' ) {
|
||||
$modules = array();
|
||||
|
||||
if ( in_array( $group, array( '', 'code' ) ) ) {
|
||||
$modules[] = 'et_pb_code';
|
||||
$modules[] = 'et_pb_fullwidth_code';
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate_content( $module_slug, $attrs, $content ) {
|
||||
if ( in_array( $module_slug, $this->get_content_migration_modules( 'code' ) ) ) {
|
||||
return $this->decode_code_module_raw_content( $content );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function _post_content_capability_check( $content ) {
|
||||
$content = preg_replace_callback( '/\[et_pb_code.*?\](.*)\[\/et_pb_code\]/mis', array( $this, '_sanitize_code_module_content_regex' ), $content );
|
||||
$content = preg_replace_callback( '/\[et_pb_fullwidth_code.*?\](.*)\[\/et_pb_fullwidth_code\]/mis', array( $this, '_sanitize_code_module_content_regex' ), $content );
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function _sanitize_code_module_content_regex( $matches ) {
|
||||
$sanitized_content = wp_kses_post( $matches[1] );
|
||||
$sanitized_shortcode = str_replace( $matches[1], $sanitized_content, $matches[0] );
|
||||
|
||||
return $sanitized_shortcode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_DiscontinueHtmlEncoding();
|
36
includes/builder/module/settings/migration/DividerHeight.php
Normal file
36
includes/builder/module/settings/migration/DividerHeight.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_DividerHeight extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.23.4';
|
||||
|
||||
public function get_modules() {
|
||||
return array( 'et_pb_divider' );
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'height' => array(
|
||||
'affected_fields' => array(
|
||||
'height' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function migrate(
|
||||
$field_name,
|
||||
$current_value,
|
||||
$module_slug,
|
||||
$saved_value,
|
||||
$saved_field_name,
|
||||
$attrs,
|
||||
$content,
|
||||
$module_address
|
||||
) {
|
||||
// We need to sanitize only numeric values
|
||||
return is_numeric( $saved_value ) ? et_sanitize_input_unit( $saved_value, false, 'px' ) : $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_DividerHeight();
|
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_DropShadowToBoxShadow extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.0.94';
|
||||
|
||||
public function get_modules() {
|
||||
return array(
|
||||
'et_pb_blog',
|
||||
);
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'box_shadow_horizontal' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_vertical' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_blur' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_spread' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_color' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_style' => array(
|
||||
'affected_fields' => array(
|
||||
'use_dropshadow' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
if (
|
||||
'on' !== ET_Core_Data_Utils::instance()->array_get( $attrs, 'use_dropshadow' )
|
||||
||
|
||||
'off' !== ET_Core_Data_Utils::instance()->array_get( $attrs, 'fullwidth' )
|
||||
) {
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
switch ( $field_name ) {
|
||||
case 'box_shadow_style':
|
||||
return 'none' !== $saved_value ? $saved_value : 'preset1';
|
||||
case 'box_shadow_blur':
|
||||
return 'none' === $current_value ? '5px' : $saved_value;
|
||||
case 'box_shadow_horizontal':
|
||||
return 'none' === $current_value ? '0px' : $saved_value;
|
||||
case 'box_shadow_vertical':
|
||||
return 'none' === $current_value ? '1px' : $saved_value;
|
||||
case 'box_shadow_spread':
|
||||
return 'none' === $current_value ? '0px' : $saved_value;
|
||||
case 'box_shadow_color':
|
||||
return 'none' === $current_value ? 'rgba(0,0,0,.1)' : $saved_value;
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_DropShadowToBoxShadow();
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_EmailOptinContent extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.4';
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'description' => array(
|
||||
'affected_fields' => array(
|
||||
'content' => array( 'et_pb_signup' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_modules( $for_affected_fields = false ) {
|
||||
return array( 'et_pb_signup' );
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
if ( '' === $current_value && '' === $saved_value && '' !== $content ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
if ( '' === $current_value && '' !== $saved_value ) {
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
return $current_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_EmailOptinContent();
|
37
includes/builder/module/settings/migration/FilterOptions.php
Normal file
37
includes/builder/module/settings/migration/FilterOptions.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_FilterOptions extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.0.91';
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'child_filter_saturate' => array(
|
||||
'affected_fields' => array(
|
||||
'grayscale_filter_amount' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_modules() {
|
||||
$modules = array(
|
||||
'et_pb_map',
|
||||
'et_pb_fullwidth_map',
|
||||
);
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
// Convert saved Google Maps JS API `stylers->saturation` values to CSS `filter: saturate()` format
|
||||
if ( 0 !== intval( $current_value ) ) {
|
||||
return 100 - intval( $current_value ) . '%';
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_FilterOptions();
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_Fullwidth_Header extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.0.84';
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'title_text_color' => array(
|
||||
'affected_fields' => array(
|
||||
'title_font_color' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'content_text_color' => array(
|
||||
'affected_fields' => array(
|
||||
'content_font_color' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'subhead_text_color' => array(
|
||||
'affected_fields' => array(
|
||||
'subhead_font_color' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_modules() {
|
||||
$modules = array( 'et_pb_fullwidth_header' );
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
if ( '' !== $current_value ) {
|
||||
return $current_value;
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_Fullwidth_Header();
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
class ET_Builder_Module_Settings_Migration_Fullwidth_Header2 extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.0.102';
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'text_orientation' => array(
|
||||
'affected_fields' => array(
|
||||
'text_orientation' => $this->get_modules(),
|
||||
),
|
||||
'map' => array(
|
||||
'justified' => 'center',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_modules() {
|
||||
$modules = array( 'et_pb_fullwidth_header' );
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
// Migrate Fullwidth Header's text orientation justified to center
|
||||
if ( 'et_pb_fullwidth_header' === $module_slug && 'text_orientation' === $field_name && isset( $this->fields['text_orientation']['map'][ $current_value ] ) ) {
|
||||
return $this->fields['text_orientation']['map'][ $current_value ];
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_Fullwidth_Header2();
|
95
includes/builder/module/settings/migration/HoverOptions.php
Normal file
95
includes/builder/module/settings/migration/HoverOptions.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_HoverOptions extends ET_Builder_Module_Settings_Migration {
|
||||
public $version = '3.16';
|
||||
|
||||
public function get_modules( $group = '' ) {
|
||||
$button = array(
|
||||
'et_pb_button',
|
||||
'et_pb_comments',
|
||||
'et_pb_contact_field',
|
||||
'et_pb_cta',
|
||||
'et_pb_fullwidth_post_slider',
|
||||
'et_pb_fullwidth_slider',
|
||||
'et_pb_login',
|
||||
'et_pb_post_slider',
|
||||
'et_pb_pricing_tables',
|
||||
'et_pb_pricing_table',
|
||||
'et_pb_search',
|
||||
'et_pb_signup',
|
||||
'et_pb_slider',
|
||||
'et_pb_slide',
|
||||
);
|
||||
|
||||
$buttons = array( 'et_pb_fullwidth_header' );
|
||||
switch ( $group ) {
|
||||
case 'button':
|
||||
return $button;
|
||||
case $buttons:
|
||||
return $buttons;
|
||||
default:
|
||||
return array_merge( $buttons, $button );
|
||||
}
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'text_size',
|
||||
'text_color',
|
||||
'text_color',
|
||||
'border_width',
|
||||
'border_color',
|
||||
'border_radius',
|
||||
'letter_spacing',
|
||||
'bg_color',
|
||||
);
|
||||
|
||||
$return = array();
|
||||
$hover = et_pb_hover_options();
|
||||
|
||||
foreach ( $fields as $field ) {
|
||||
$return[ $hover->get_hover_enabled_field( "button_{$field}" ) ] = array(
|
||||
'affected_fields' => array(
|
||||
"button_{$field}_hover" => $this->get_modules( 'button' ),
|
||||
),
|
||||
);
|
||||
$return[ $hover->get_hover_field( "button_{$field}" ) ] = array(
|
||||
'affected_fields' => array(
|
||||
"button_{$field}_hover" => $this->get_modules( 'button' ),
|
||||
),
|
||||
);
|
||||
$return[ $hover->get_hover_enabled_field( "button_one_{$field}" ) ] = array(
|
||||
'affected_fields' => array(
|
||||
"button_one_{$field}_hover" => $this->get_modules( 'buttons' ),
|
||||
),
|
||||
);
|
||||
$return[ $hover->get_hover_field( "button_one_{$field}" ) ] = array(
|
||||
'affected_fields' => array(
|
||||
"button_one_{$field}_hover" => $this->get_modules( 'buttons' ),
|
||||
),
|
||||
);
|
||||
$return[ $hover->get_hover_enabled_field( "button_two_{$field}" ) ] = array(
|
||||
'affected_fields' => array(
|
||||
"button_two_{$field}_hover" => $this->get_modules( 'buttons' ),
|
||||
),
|
||||
);
|
||||
$return[ $hover->get_hover_field( "button_two_{$field}" ) ] = array(
|
||||
'affected_fields' => array(
|
||||
"button_two_{$field}_hover" => $this->get_modules( 'buttons' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
if ( $field_name == et_pb_hover_options()->get_hover_field( $field_name ) ) {
|
||||
return strlen( $current_value ) ? $current_value : null;
|
||||
}
|
||||
|
||||
return strlen( $current_value ) ? 'on' : 'off';
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_HoverOptions();
|
690
includes/builder/module/settings/migration/IconManager.php
Normal file
690
includes/builder/module/settings/migration/IconManager.php
Normal file
@ -0,0 +1,690 @@
|
||||
<?php
|
||||
/**
|
||||
* Icon manager migartion class.
|
||||
*
|
||||
* @package Divi
|
||||
* @subpackage Builder
|
||||
* @since ?
|
||||
*/
|
||||
|
||||
/**
|
||||
* Migration process to handle all the changes done in Icon Manager QF.
|
||||
*
|
||||
* @since ?
|
||||
*/
|
||||
class ET_Builder_Module_Settings_Migration_IconManager extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
/**
|
||||
* Migration Version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $version = '4.13.0';
|
||||
|
||||
/**
|
||||
* Proccessing field name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_field_name;
|
||||
|
||||
/**
|
||||
* Current field value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_current_value;
|
||||
|
||||
/**
|
||||
* Saved field value.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_saved_value;
|
||||
|
||||
/**
|
||||
* Current field name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_saved_field_name;
|
||||
|
||||
/**
|
||||
* Array of attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_attrs;
|
||||
|
||||
/**
|
||||
* All responsive modes suffixes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_responsive_modes_suffixes = array( '', '_tablet', '_phone', '__hover', '__hover_enabled', '_last_edited' );
|
||||
|
||||
/**
|
||||
* Responsive modes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_responsive_modes = array( '', '_tablet', '_phone' );
|
||||
|
||||
/**
|
||||
* Default values for the fields related to icon placement migration.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_icon_placement_migration_values = array(
|
||||
'image_icon_width' => array(
|
||||
'left' => '16px',
|
||||
'top' => '48px',
|
||||
),
|
||||
'image_icon_custom_padding' => array(
|
||||
'left' => '8px|8px|8px|8px|false|false',
|
||||
'top' => '25px|25px|25px|25px|false|false',
|
||||
),
|
||||
'border_width_all_image' => array(
|
||||
'left' => '2px',
|
||||
'top' => '3px',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Border radii value for the circle icon attr migration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_circle_border_radii_value = 'on|100%|100%|100%|100%';
|
||||
|
||||
/**
|
||||
* Attrs sticky suffixes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_sticky_suffixes = array( '__sticky_enabled', '__sticky' );
|
||||
|
||||
/**
|
||||
* Get array with Blurb module slug.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_blurb_modules() {
|
||||
return et_pb_get_font_icon_modules( 'blurb' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of Divi modules with buttons that have a custom icons.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_button_modules() {
|
||||
return et_pb_get_font_icon_modules( 'button' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array with slugs for modules that supported Hover Overlay functionality.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_overlay_modules() {
|
||||
return et_pb_get_font_icon_modules( 'overlay' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array with slugs for modules that supported Toggle Icon functionality.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_toggle_modules() {
|
||||
return et_pb_get_font_icon_modules( 'toggle' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Blurb fields.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_blurb_fields() {
|
||||
|
||||
// The order of the array keys and the order of the field names in the values is important when
|
||||
// executing the migration logic, since it uses the "return early" principle.
|
||||
if ( parent::$_maybe_global_presets_migration ) {
|
||||
// Migrations rules for the Global Presets migrations case.
|
||||
$migration_options = array(
|
||||
'icon_font_size' => array( 'image_icon_width' ),
|
||||
'border_color_all_image' => array( 'border_color_all_image' ),
|
||||
'border_width_all_image' => array( 'border_width_all_image' ),
|
||||
'font_icon' => array( 'font_icon' ),
|
||||
'image_max_width' => array( 'image_icon_width' ),
|
||||
'circle_border_color' => array( 'border_color_all_image' ),
|
||||
'circle_color' => array( 'image_icon_background_color' ),
|
||||
'use_circle_border' => array( 'border_color_all_image' ),
|
||||
'use_circle' => array( 'image_icon_custom_padding', 'border_color_all_image', 'border_radii_image', 'image_icon_background_color', 'border_width_all_image' ),
|
||||
'icon_placement' => array( 'image_icon_width', 'border_width_all_image' ),
|
||||
);
|
||||
} else {
|
||||
$migration_options = array(
|
||||
'icon_font_size' => array( 'image_icon_width' ),
|
||||
'border_color_all_image' => array( 'border_color_all_image' ),
|
||||
'border_width_all_image' => array( 'border_width_all_image' ),
|
||||
'font_icon' => array( 'font_icon' ),
|
||||
'image_max_width' => array( 'image_icon_width' ),
|
||||
'circle_border_color' => array( 'border_color_all_image' ),
|
||||
'circle_color' => array( 'image_icon_background_color' ),
|
||||
'use_circle_border' => array( 'border_color_all_image' ),
|
||||
'use_circle' => array( 'border_color_all_image', 'border_radii_image', 'image_icon_background_color', 'border_width_all_image' ),
|
||||
'icon_placement' => array( 'image_icon_width', 'image_icon_custom_padding', 'border_width_all_image' ),
|
||||
);
|
||||
}
|
||||
|
||||
$sticky_options = array( 'circle_color', 'circle_border_color', 'image_max_width', 'icon_font_size' );
|
||||
|
||||
$result_fields_keys = array();
|
||||
|
||||
$modes_with_sticky = array_merge( $this->_responsive_modes_suffixes, $this->_sticky_suffixes );
|
||||
|
||||
foreach ( $migration_options as $saved_field_name => $field_names ) {
|
||||
foreach ( $modes_with_sticky as $mode_suffix ) {
|
||||
|
||||
$maybe_border_width_all_image_saved_field = 'border_width_all_image' === $saved_field_name && in_array( $mode_suffix, array( '__hover', '__hover_enabled' ), true );
|
||||
$maybe_use_circle_border_saved_field = 'use_circle_border' === $saved_field_name && in_array( $mode_suffix, array( '_tablet', '_phone', '__hover', '__hover_enabled', '_last_edited' ), true );
|
||||
$maybe_use_circle_responsive = 'use_circle' === $saved_field_name && '' !== $mode_suffix;
|
||||
$maybe_icon_placement_in_hover = 'icon_placement' === $saved_field_name && in_array( $mode_suffix, array( '__hover', '__hover_enabled' ), true );
|
||||
$maybe_not_sticky_option_when_sticky_mode = in_array( $mode_suffix, $this->_sticky_suffixes, true ) && ! in_array( $saved_field_name, $sticky_options, true );
|
||||
|
||||
if ( $maybe_icon_placement_in_hover || $maybe_border_width_all_image_saved_field || $maybe_use_circle_border_saved_field || $maybe_use_circle_responsive || $maybe_not_sticky_option_when_sticky_mode ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $field_names as $field_name ) {
|
||||
$affected_fields = 'use_circle' === $saved_field_name ? array( $saved_field_name => $this->_get_blurb_modules() ) : array( $saved_field_name . $mode_suffix => $this->_get_blurb_modules() );
|
||||
if ( ! empty( $result_fields_keys[ $field_name . $mode_suffix ]['affected_fields'] ) ) {
|
||||
$affected_fields += $result_fields_keys[ $field_name . $mode_suffix ]['affected_fields'];
|
||||
};
|
||||
|
||||
$result_fields_keys[ $field_name . $mode_suffix ] = array(
|
||||
'affected_fields' => $affected_fields,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result_fields_keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fields for modules with Button support.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_button_fields() {
|
||||
$result_button_fields = array();
|
||||
$button_field_names_for_module = array(
|
||||
'et_pb_fullwidth_header' => array( 'button_one_icon', 'button_two_icon' ),
|
||||
'one_button_modules' => array( 'button_icon' ),
|
||||
);
|
||||
foreach ( $button_field_names_for_module as $field_module => $field_names ) {
|
||||
foreach ( $field_names as $field_name ) {
|
||||
foreach ( $this->_responsive_modes as $mode_suffix ) {
|
||||
$modules = 'et_pb_fullwidth_header' === $field_module ? array( 'et_pb_fullwidth_header' ) : array_diff( $this->_get_button_modules(), array( 'et_pb_fullwidth_header' ) );
|
||||
$full_field_name = $field_name . $mode_suffix;
|
||||
$result_button_fields[ $full_field_name ] = array(
|
||||
'affected_fields' => array( $full_field_name => $modules ),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result_button_fields;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get modules which are using overlay functionality by responsive suffix.
|
||||
*
|
||||
* @since ?
|
||||
* @param string $suffix responsive suffix.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_overlay_modules_by_suffix( $suffix ) {
|
||||
return '' === $suffix ? $this->_get_overlay_modules() : array_filter(
|
||||
$this->_get_overlay_modules(),
|
||||
function( $module ) {
|
||||
return 'et_pb_filterable_portfolio' !== $module;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fields for modules with Hover Overlay functionality.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_overlay_fields() {
|
||||
$result_overlay_fields = array();
|
||||
foreach ( $this->_responsive_modes as $mode_suffix ) {
|
||||
$full_field_name = 'hover_icon' . $mode_suffix;
|
||||
$modules = $this->_get_overlay_modules_by_suffix( $mode_suffix );
|
||||
$result_overlay_fields[ $full_field_name ] = array(
|
||||
'affected_fields' => array( $full_field_name => $modules ),
|
||||
);
|
||||
}
|
||||
return $result_overlay_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fields for modules with Toggle icon functionality.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _get_toggle_fields() {
|
||||
$result_overlay_fields = array();
|
||||
$toggle_icon_fields = array( 'use_icon_font_size', 'icon_color', 'icon_font_size' );
|
||||
foreach ( $toggle_icon_fields as $toggle_icon_field ) {
|
||||
foreach ( $this->_responsive_modes_suffixes as $mode_suffix ) {
|
||||
if ( 'use_icon_font_size' === $toggle_icon_field && '' !== $mode_suffix ) {
|
||||
continue;
|
||||
}
|
||||
$full_field_name = $toggle_icon_field . $mode_suffix;
|
||||
$modules = $this->_get_toggle_modules();
|
||||
$result_overlay_fields[ 'open_' . $full_field_name ] = array(
|
||||
'affected_fields' => array( $full_field_name => $modules ),
|
||||
);
|
||||
}
|
||||
}
|
||||
return $result_overlay_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all affected fields.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_fields() {
|
||||
return array_merge( $this->_get_blurb_fields(), $this->_get_button_fields(), $this->_get_overlay_fields(), $this->_get_toggle_fields() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all affected modules.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_modules() {
|
||||
return array_merge( $this->_get_blurb_modules(), $this->_get_overlay_modules(), $this->_get_button_modules(), $this->_get_toggle_modules() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Base migrate method, which launching during migration.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @param string $field_name field name.
|
||||
* @param string $current_value current value.
|
||||
* @param string $module_slug module slug.
|
||||
* @param string $saved_value saved value.
|
||||
* @param string $saved_field_name saved field name.
|
||||
* @param array $attrs attrs array.
|
||||
* @param string $content content.
|
||||
* @param string $module_address module_address.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
// Initialize migration params from received args.
|
||||
$this->_init_params( $field_name, $current_value, $saved_value, $saved_field_name, $attrs );
|
||||
|
||||
// For the non Blurb modules we only migarte `font_icon` option.
|
||||
if ( ! in_array( $module_slug, $this->_get_blurb_modules(), true ) ) {
|
||||
// Simple migrate filed names for toggle icons.
|
||||
if ( in_array( $module_slug, $this->_get_toggle_modules(), true ) ) {
|
||||
return $current_value;
|
||||
}
|
||||
return $this->_migrate_font_icon();
|
||||
}
|
||||
|
||||
// Run different scripts depending on the type of migration.
|
||||
return ( parent::$_maybe_global_presets_migration ) ? $this->_blurb_global_presets_attrs_migration() : $this->_blurb_post_attrs_migration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize migration params from received args.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @param string $field_name field_name.
|
||||
* @param string $current_value current_value.
|
||||
* @param string $saved_value saved_value.
|
||||
* @param string $saved_field_name saved_field_name.
|
||||
* @param string $attrs attrs.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _init_params( $field_name, $current_value, $saved_value, $saved_field_name, $attrs ) {
|
||||
$this->_field_name = $field_name;
|
||||
$this->_current_value = $current_value;
|
||||
$this->_saved_value = $saved_value;
|
||||
$this->_saved_field_name = $saved_field_name;
|
||||
$this->_attrs = $attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an passed attribute is an on\off type via its name.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @param string $attr_name attribute name.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function _maybe_on( $attr_name ) {
|
||||
return ! empty( $this->_attrs[ $attr_name ] ) && 'on' === ( $this->_attrs[ $attr_name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current migrated `field_name` contains passed attribute name.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @param string $attr_name attribute name.
|
||||
* @return bool
|
||||
*/
|
||||
private function _field_name_contains( $attr_name ) {
|
||||
return false !== strpos( $this->_field_name, $attr_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current migrated `saved_name` contains passed attribute name.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @param string $attr_name attr_name.
|
||||
* @return bool
|
||||
*/
|
||||
private function _saved_name_contains( $attr_name ) {
|
||||
return false !== strpos( $this->_saved_field_name, $attr_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current migrated field name suffix.
|
||||
*
|
||||
* @param bool $use_sticky_suffixes use or not sticky_suffixes.
|
||||
* @since ?
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _get_field_suffix( $use_sticky_suffixes = false ) {
|
||||
$suffixes = $use_sticky_suffixes ? array_merge( $this->_sticky_suffixes, array_reverse( $this->_responsive_modes_suffixes ) ) : array_reverse( $this->_responsive_modes_suffixes );
|
||||
array_pop( $suffixes );
|
||||
foreach ( $suffixes as $suffix ) {
|
||||
if ( $this->_field_name_contains( $suffix ) ) {
|
||||
return $suffix;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current migrated field name without suffix.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _get_field_name_without_suffix() {
|
||||
return str_replace( $this->_get_field_suffix(), '', $this->_field_name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate fields value "as is" if the current field is one of the
|
||||
* service fields ( fields with suffix '__hover_enabled' or '_last_edited' ) or sticky fields.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function _maybe_service_or_sticky_field() {
|
||||
$service_suffixes = array_merge( $this->_sticky_suffixes, array( '__hover_enabled', '_last_edited' ) );
|
||||
return in_array( $this->_get_field_suffix( true ), $service_suffixes, true ) && ! empty( $this->_current_value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an attribute value from by attribute's name.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @param string $attr_name attribute name.
|
||||
* @return bool
|
||||
*/
|
||||
private function _get_attr( $attr_name ) {
|
||||
return ! empty( $this->_attrs[ $attr_name ] ) ? $this->_attrs[ $attr_name ] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate fields which depends on the icon placement option.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @param string $for_empty_current_value setting returned value for empty icon_placement.
|
||||
* @return string
|
||||
*/
|
||||
private function _migrate_icon_placement( $for_empty_current_value = '' ) {
|
||||
$result_values = $this->_icon_placement_migration_values[ $this->_get_field_name_without_suffix() ];
|
||||
$result_values[''] = $for_empty_current_value;
|
||||
$current_icon_placement_value = $this->_get_attr( 'icon_placement' . $this->_get_field_suffix() );
|
||||
if ( '' === $this->_get_field_suffix() || ! empty( $current_icon_placement_value ) ) {
|
||||
return $result_values[ $current_icon_placement_value ];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate background color with circle color.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _migrate_background_color_with_circle_color() {
|
||||
|
||||
if ( empty( $this->_current_value ) && '' === $this->_get_field_suffix() ) {
|
||||
return et_builder_accent_color();
|
||||
}
|
||||
|
||||
return $this->_current_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate font icon.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _migrate_font_icon() {
|
||||
if ( empty( $this->_current_value ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return et_pb_process_font_icon( $this->_current_value ) . '||divi||' . et_pb_get_normal_font_weight_value();
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Blurb's attributes migration when post's shortcodes attributes migrating.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _blurb_post_attrs_migration() {
|
||||
// Determine the conditions for the migration of various options.
|
||||
$is_icon_mode = $this->_maybe_on( 'use_icon' );
|
||||
$maybe_set_border_color_all_image_as_is = ! $is_icon_mode && $this->_field_name_contains( 'border_color_all_image' ) && ! empty( $this->_attrs[ $this->_field_name ] );
|
||||
$_migrate_font_icon = $is_icon_mode && $this->_field_name_contains( 'font_icon' ) && ! $this->_field_name_contains( '__hover_enabled' ) && ! $this->_field_name_contains( '_last_edited' );
|
||||
$migrate_border_radii_image = $is_icon_mode && $this->_field_name_contains( 'border_radii_image' ) && $this->_maybe_on( 'use_circle' );
|
||||
$migrate_image_icon_custom_padding = $is_icon_mode && $this->_field_name_contains( 'image_icon_custom_padding' ) && $this->_maybe_on( 'use_circle' );
|
||||
$migrate_border_width_all_image_as_is = $this->_field_name_contains( 'border_width_all_image' ) && $this->_saved_name_contains( 'border_width_all_image' );
|
||||
$migrate_border_width_all_image_with_circle_border = $is_icon_mode && $this->_field_name_contains( 'border_width_all_image' ) && $this->_maybe_on( 'use_circle' ) && $this->_maybe_on( 'use_circle_border' );
|
||||
$migrate_border_color_all_image = ! $maybe_set_border_color_all_image_as_is && $is_icon_mode && $this->_field_name_contains( 'border_color_all_image' ) && $this->_maybe_on( 'use_circle' ) && $this->_maybe_on( 'use_circle_border' );
|
||||
$migrate_image_icon_width_with_circle = $is_icon_mode && $this->_field_name_contains( 'image_icon_width' ) && $this->_saved_name_contains( 'icon_placement' ) && $this->_maybe_on( 'use_circle' );
|
||||
$migrate_icon_font_size_as_is = $is_icon_mode && $this->_field_name_contains( 'image_icon_width' ) && $this->_saved_name_contains( 'icon_font_size' ) && ! empty( $this->_current_value );
|
||||
$_migrate_background_color_with_circle_color = $is_icon_mode && $this->_field_name_contains( 'image_icon_background_color' ) && $this->_saved_name_contains( 'circle_color' ) && $this->_maybe_on( 'use_circle' );
|
||||
$maybe_return_default_accent_color_for_default_border = empty( $this->_get_attr( 'circle_border_color' ) ) && empty( $this->_get_attr( 'circle_border_color' . $this->_get_field_suffix() ) ) && empty( $this->_get_attr( 'border_color_all_image' ) ) && empty( $this->_get_attr( 'border_color_all_image' . $this->_get_field_suffix() ) );
|
||||
$migrate_image_max_width_as_is = ! $is_icon_mode && $this->_field_name_contains( 'image_icon_width' ) && $this->_saved_name_contains( 'image_max_width' );
|
||||
|
||||
if ( $this->_maybe_service_or_sticky_field() ) {
|
||||
return $this->_current_value;
|
||||
}
|
||||
|
||||
if ( $maybe_set_border_color_all_image_as_is && ! empty( $this->_saved_value ) ) {
|
||||
return $this->_saved_value;
|
||||
}
|
||||
|
||||
if ( $migrate_icon_font_size_as_is ) {
|
||||
return $this->_current_value;
|
||||
}
|
||||
|
||||
if ( $_migrate_background_color_with_circle_color ) {
|
||||
return $this->_migrate_background_color_with_circle_color();
|
||||
}
|
||||
|
||||
if ( $migrate_image_icon_width_with_circle ) {
|
||||
return $this->_migrate_icon_placement();
|
||||
}
|
||||
|
||||
if ( $migrate_border_color_all_image && $maybe_return_default_accent_color_for_default_border ) {
|
||||
return et_builder_accent_color();
|
||||
}
|
||||
|
||||
if ( $_migrate_font_icon ) {
|
||||
return $this->_migrate_font_icon();
|
||||
}
|
||||
|
||||
if ( $migrate_border_radii_image ) {
|
||||
return $this->_circle_border_radii_value;
|
||||
}
|
||||
|
||||
if ( $migrate_image_icon_custom_padding ) {
|
||||
return $this->_migrate_icon_placement();
|
||||
}
|
||||
|
||||
if ( $migrate_border_width_all_image_with_circle_border ) {
|
||||
return $this->_migrate_icon_placement( $this->_icon_placement_migration_values['border_width_all_image']['top'] );
|
||||
}
|
||||
|
||||
if ( $migrate_border_width_all_image_as_is && $is_icon_mode ) {
|
||||
return in_array( $this->_saved_value, $this->_icon_placement_migration_values['border_width_all_image'], true ) ? $this->_saved_value : '';
|
||||
}
|
||||
|
||||
if ( $migrate_border_color_all_image ) {
|
||||
return $this->_current_value;
|
||||
}
|
||||
|
||||
if ( $migrate_image_max_width_as_is ) {
|
||||
return $this->_current_value;
|
||||
}
|
||||
|
||||
return $this->_saved_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Blurb's attributes migration when Global Presets attributes migrating.
|
||||
*
|
||||
* @since ?
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _blurb_global_presets_attrs_migration() {
|
||||
// Determine the conditions for the migration of various options.
|
||||
$_migrate_font_icon = $this->_field_name_contains( 'font_icon' ) && ! $this->_field_name_contains( '__hover_enabled' ) && ! $this->_field_name_contains( '_last_edited' );
|
||||
$migrate_border_radii_image = $this->_field_name_contains( 'border_radii_image' ) && $this->_maybe_on( 'use_circle' );
|
||||
$migrate_image_icon_custom_padding = $this->_field_name_contains( 'image_icon_custom_padding' ) && $this->_maybe_on( 'use_circle' );
|
||||
$migrate_border_width_all_image_as_is = $this->_field_name_contains( 'border_width_all_image' ) && $this->_saved_name_contains( 'border_width_all_image' );
|
||||
$migrate_border_width_all_image_with_circle_border = ! $migrate_border_width_all_image_as_is && $this->_field_name_contains( 'border_width_all_image' ) && $this->_maybe_on( 'use_circle' ) && $this->_maybe_on( 'use_circle_border' );
|
||||
$migrate_no_border_width_all_image_field = ! $migrate_border_width_all_image_with_circle_border && $this->_field_name_contains( 'border_width_all_image' ) && $this->_maybe_on( 'use_circle' );
|
||||
$migrate_border_color_all_image = $this->_field_name_contains( 'border_color_all_image' ) && $this->_maybe_on( 'use_circle' ) && $this->_maybe_on( 'use_circle_border' );
|
||||
$migrate_image_icon_width_with_circle = $this->_field_name_contains( 'image_icon_width' ) && $this->_saved_name_contains( 'icon_placement' ) && $this->_maybe_on( 'use_circle' );
|
||||
$migrate_icon_font_size_as_is = $this->_field_name_contains( 'image_icon_width' ) && $this->_saved_name_contains( 'icon_font_size' ) && ! empty( $this->_current_value );
|
||||
$_migrate_background_color_with_circle_color = $this->_field_name_contains( 'image_icon_background_color' ) && $this->_saved_name_contains( 'circle_color' ) && $this->_maybe_on( 'use_circle' );
|
||||
$migrate_default_background_color = ! $_migrate_background_color_with_circle_color && $this->_field_name_contains( 'image_icon_background_color' ) && $this->_maybe_on( 'use_circle' );
|
||||
$maybe_return_accent_color_for_default_border = empty( $this->_attrs[ 'circle_border_color' . $this->_get_field_suffix() ] ) && in_array( $this->_get_field_suffix(), array( '', '_tablet', '_phone', '__hover' ), true );
|
||||
$migrate_circle_border_color_as_is = $this->_field_name_contains( 'border_color_all_image' ) && $this->_saved_name_contains( 'circle_border_color' ) && ! empty( $this->_current_value );
|
||||
$migrate_image_max_width_as_is = $this->_field_name_contains( 'image_icon_width' ) && $this->_saved_name_contains( 'image_max_width' );
|
||||
|
||||
if ( $this->_maybe_service_or_sticky_field() ) {
|
||||
return $this->_current_value;
|
||||
}
|
||||
|
||||
if ( $migrate_icon_font_size_as_is ) {
|
||||
return $this->_current_value;
|
||||
}
|
||||
|
||||
if ( $migrate_default_background_color ) {
|
||||
return et_builder_accent_color();
|
||||
}
|
||||
|
||||
if ( $_migrate_background_color_with_circle_color ) {
|
||||
return $this->_migrate_background_color_with_circle_color();
|
||||
}
|
||||
|
||||
if ( $migrate_image_icon_width_with_circle ) {
|
||||
return $this->_migrate_icon_placement();
|
||||
}
|
||||
|
||||
if ( $migrate_border_color_all_image && $maybe_return_accent_color_for_default_border ) {
|
||||
return et_builder_accent_color();
|
||||
}
|
||||
|
||||
if ( $_migrate_font_icon ) {
|
||||
return $this->_migrate_font_icon();
|
||||
}
|
||||
|
||||
if ( $migrate_border_radii_image ) {
|
||||
return $this->_circle_border_radii_value;
|
||||
}
|
||||
|
||||
if ( $migrate_image_icon_custom_padding ) {
|
||||
return $this->_migrate_icon_placement( $this->_icon_placement_migration_values['image_icon_custom_padding']['top'] );
|
||||
}
|
||||
|
||||
if ( $migrate_border_width_all_image_with_circle_border ) {
|
||||
return $this->_migrate_icon_placement( $this->_icon_placement_migration_values['border_width_all_image']['top'] );
|
||||
}
|
||||
|
||||
if ( $migrate_no_border_width_all_image_field ) {
|
||||
return in_array( $this->_saved_value, $this->_icon_placement_migration_values['border_width_all_image'], true ) ? $this->_saved_value : '';
|
||||
}
|
||||
|
||||
if ( $migrate_border_color_all_image || $migrate_circle_border_color_as_is ) {
|
||||
return $this->_current_value;
|
||||
}
|
||||
|
||||
if ( $migrate_image_max_width_as_is ) {
|
||||
return $this->_current_value;
|
||||
}
|
||||
|
||||
return $this->_saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_IconManager();
|
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_InnerShadowToBoxShadow extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.0.99';
|
||||
|
||||
public function get_modules( $group = '' ) {
|
||||
return array(
|
||||
'et_pb_slider',
|
||||
'et_pb_fullwidth_slider',
|
||||
'et_pb_post_slider',
|
||||
'et_pb_fullwidth_post_slider',
|
||||
);
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'box_shadow_horizontal' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_vertical' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_blur' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_spread' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_position' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_color' => array(
|
||||
'affected_fields' => array(
|
||||
'box_shadow_style' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'box_shadow_style' => array(
|
||||
'affected_fields' => array(
|
||||
'show_inner_shadow' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
|
||||
switch ( $field_name ) {
|
||||
case 'box_shadow_style':
|
||||
return ( 'none' !== $saved_value || 'off' === $current_value ) ? $saved_value : 'preset6';
|
||||
case 'box_shadow_blur':
|
||||
return 'none' === $current_value ? '10px' : $saved_value;
|
||||
case 'box_shadow_position':
|
||||
return 'none' === $current_value ? 'inner' : $saved_value;
|
||||
case 'box_shadow_color':
|
||||
return 'none' === $current_value ? 'rgba(0,0,0,0.1)' : $saved_value;
|
||||
case 'box_shadow_horizontal':
|
||||
case 'box_shadow_vertical':
|
||||
case 'box_shadow_spread':
|
||||
return 'none' === $current_value ? '0px' : $saved_value;
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_InnerShadowToBoxShadow();
|
511
includes/builder/module/settings/migration/OptionsHarmony.php
Normal file
511
includes/builder/module/settings/migration/OptionsHarmony.php
Normal file
@ -0,0 +1,511 @@
|
||||
<?php
|
||||
class ET_Builder_Module_Settings_Migration_OptionsHarmony extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.0.74';
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
self::$_bb_excluded_name_changes[] = 'text_orientation';
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'parallax' => array(
|
||||
'affected_fields' => array(
|
||||
'parallax_effect' => $this->get_modules( 'post_title' ),
|
||||
),
|
||||
),
|
||||
'parallax_method' => array(
|
||||
'affected_fields' => array(
|
||||
'parallax_effect' => $this->get_modules( 'post_title' ),
|
||||
'parallax_method' => $this->get_modules( 'slide' ),
|
||||
),
|
||||
'values' => array(
|
||||
'off' => 'on',
|
||||
'on' => 'off',
|
||||
),
|
||||
),
|
||||
'background_color' => array(
|
||||
'affected_fields' => array(
|
||||
'module_bg_color' => $this->get_modules( 'post_title' ),
|
||||
'field_bg' => $this->get_modules( 'search' ),
|
||||
'bg_color' => $this->get_modules( 'social_media_follow_network' ),
|
||||
'transparent_background' => $this->get_modules( 'section' ),
|
||||
'transparent_background_fb' => $this->get_modules( 'section' ),
|
||||
),
|
||||
),
|
||||
'custom_padding' => array(
|
||||
'affected_fields' => array(
|
||||
'bar_top_padding' => $this->get_modules( 'bar_counters' ),
|
||||
'bar_bottom_padding' => $this->get_modules( 'bar_counters' ),
|
||||
'top_padding' => $this->get_modules( 'slider' ),
|
||||
'bottom_padding' => $this->get_modules( 'slider' ),
|
||||
'custom_padding' => $this->get_modules( 'section' ),
|
||||
),
|
||||
),
|
||||
'custom_padding_tablet' => array(
|
||||
'affected_fields' => array(
|
||||
'bar_top_padding_tablet' => $this->get_modules( 'bar_counters' ),
|
||||
'bar_bottom_padding_tablet' => $this->get_modules( 'bar_counters' ),
|
||||
'top_padding_tablet' => $this->get_modules( 'slider' ),
|
||||
'bottom_padding_tablet' => $this->get_modules( 'slider' ),
|
||||
'padding_mobile' => $this->get_modules( 'section' ),
|
||||
),
|
||||
),
|
||||
'custom_padding_phone' => array(
|
||||
'affected_fields' => array(
|
||||
'bar_top_padding_phone' => $this->get_modules( 'bar_counters' ),
|
||||
'bar_bottom_padding_phone' => $this->get_modules( 'bar_counters' ),
|
||||
'top_padding_phone' => $this->get_modules( 'slider' ),
|
||||
'bottom_padding_phone' => $this->get_modules( 'slider' ),
|
||||
),
|
||||
),
|
||||
'custom_padding_last_edited' => array(
|
||||
'affected_fields' => array(
|
||||
'bar_top_padding_last_edited' => $this->get_modules( 'bar_counters' ),
|
||||
'bar_bottom_padding_last_edited' => $this->get_modules( 'bar_counters' ),
|
||||
'top_padding_last_edited' => $this->get_modules( 'slider' ),
|
||||
'bottom_padding_last_edited' => $this->get_modules( 'slider' ),
|
||||
'padding_mobile' => $this->get_modules( 'section' ),
|
||||
),
|
||||
),
|
||||
'background_video_mp4' => array(
|
||||
'affected_fields' => array(
|
||||
'video_bg_mp4' => $this->get_modules( 'slide' ),
|
||||
),
|
||||
),
|
||||
'background_video_webm' => array(
|
||||
'affected_fields' => array(
|
||||
'video_bg_webm' => $this->get_modules( 'slide' ),
|
||||
),
|
||||
),
|
||||
'background_video_width' => array(
|
||||
'affected_fields' => array(
|
||||
'video_bg_width' => $this->get_modules( 'slide' ),
|
||||
),
|
||||
),
|
||||
'background_video_height' => array(
|
||||
'affected_fields' => array(
|
||||
'video_bg_height' => $this->get_modules( 'slide' ),
|
||||
),
|
||||
),
|
||||
'disabled_on' => array(
|
||||
'affected_fields' => array(
|
||||
'hide_on_mobile' => $this->get_modules( 'divider' ),
|
||||
),
|
||||
),
|
||||
'show_prev' => array(
|
||||
'affected_fields' => array(
|
||||
'hide_prev' => $this->get_modules( 'post_nav' ),
|
||||
),
|
||||
),
|
||||
'show_next' => array(
|
||||
'affected_fields' => array(
|
||||
'hide_next' => $this->get_modules( 'post_nav' ),
|
||||
),
|
||||
),
|
||||
'show_inner_shadow' => array(
|
||||
'affected_fields' => array(
|
||||
'remove_inner_shadow' => $this->get_modules( 'slider' ),
|
||||
),
|
||||
),
|
||||
'show_featured_drop_shadow' => array(
|
||||
'affected_fields' => array(
|
||||
'remove_featured_drop_shadow' => $this->get_modules( 'pricing_table' ),
|
||||
),
|
||||
),
|
||||
'show_button' => array(
|
||||
'affected_fields' => array(
|
||||
'hide_button' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'show_border' => array(
|
||||
'affected_fields' => array(
|
||||
'remove_border' => $this->get_modules( 'sidebar' ),
|
||||
),
|
||||
),
|
||||
'show_image_overlay' => array(
|
||||
'affected_fields' => array(
|
||||
'show_image_overlay' => $this->get_modules( 'video_slider' ),
|
||||
),
|
||||
),
|
||||
'show_content_on_mobile' => array(
|
||||
'affected_fields' => array(
|
||||
'hide_content_on_mobile' => $this->get_modules( 'slider' ),
|
||||
),
|
||||
),
|
||||
'show_cta_on_mobile' => array(
|
||||
'affected_fields' => array(
|
||||
'hide_cta_on_mobile' => $this->get_modules( 'slider' ),
|
||||
),
|
||||
),
|
||||
'show_bottom_space' => array(
|
||||
'affected_fields' => array(
|
||||
'sticky' => $this->get_modules( 'image' ),
|
||||
),
|
||||
),
|
||||
'image_max_width' => array(
|
||||
'affected_fields' => array(
|
||||
'max_width' => $this->get_modules( 'blurb' ),
|
||||
),
|
||||
),
|
||||
'content_max_width' => array(
|
||||
'affected_fields' => array(
|
||||
'max_width' => $this->get_modules( 'fullwidth_header' ),
|
||||
),
|
||||
),
|
||||
'max_width' => array(
|
||||
'affected_fields' => array(
|
||||
'max_width' => $this->get_modules( 'reset_max_width' ),
|
||||
),
|
||||
),
|
||||
'title_text_color' => array(
|
||||
'affected_fields' => array(
|
||||
'label_color' => $this->get_modules( 'bar_counter' ),
|
||||
),
|
||||
),
|
||||
'percent_text_color' => array(
|
||||
'affected_fields' => array(
|
||||
'percentage_color' => $this->get_modules( 'bar_counter' ),
|
||||
),
|
||||
),
|
||||
'module_alignment' => array(
|
||||
'affected_fields' => array(
|
||||
'text_orientation' => $this->get_modules( 'text_orientation' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_modules( $attr = '' ) {
|
||||
$modules = array();
|
||||
// Section
|
||||
if ( in_array( $attr, array( '', 'section' ) ) ) {
|
||||
$modules[] = 'et_pb_section';
|
||||
}
|
||||
|
||||
// Post title & Fullwidth post title migration settings
|
||||
if ( in_array( $attr, array( '', 'post_title' ) ) ) {
|
||||
$modules[] = 'et_pb_post_title';
|
||||
$modules[] = 'et_pb_fullwidth_post_title';
|
||||
}
|
||||
|
||||
// Blurb migration setting
|
||||
if ( in_array( $attr, array( '', 'blurb' ) ) ) {
|
||||
$modules[] = 'et_pb_blurb';
|
||||
}
|
||||
|
||||
// Fullwidth Header
|
||||
if ( in_array( $attr, array( '', 'fullwidth_header' ) ) ) {
|
||||
$modules[] = 'et_pb_fullwidth_header';
|
||||
}
|
||||
|
||||
if ( 'reset_max_width' === $attr ) {
|
||||
$modules[] = 'et_pb_blurb';
|
||||
$modules[] = 'et_pb_fullwidth_header';
|
||||
}
|
||||
|
||||
if ( in_array( $attr, array( '', 'text_orientation' ) ) ) {
|
||||
$modules[] = 'et_pb_text';
|
||||
$modules[] = 'et_pb_search';
|
||||
}
|
||||
|
||||
// Social media follow item migration settings
|
||||
if ( in_array( $attr, array( '', 'social_media_follow_network' ) ) ) {
|
||||
$modules[] = 'et_pb_social_media_follow_network';
|
||||
}
|
||||
|
||||
// Bar Counters
|
||||
if ( in_array( $attr, array( '', 'bar_counters' ) ) ) {
|
||||
$modules[] = 'et_pb_counters';
|
||||
}
|
||||
|
||||
// Bar Counter Item
|
||||
if ( in_array( $attr, array( '', 'bar_counter' ) ) ) {
|
||||
$modules[] = 'et_pb_counter';
|
||||
}
|
||||
|
||||
// Slider
|
||||
if ( in_array( $attr, array( '', 'slider' ) ) ) {
|
||||
$modules[] = 'et_pb_post_slider';
|
||||
$modules[] = 'et_pb_fullwidth_post_slider';
|
||||
$modules[] = 'et_pb_slider';
|
||||
$modules[] = 'et_pb_fullwidth_slider';
|
||||
}
|
||||
|
||||
// Slide Item
|
||||
if ( in_array( $attr, array( '', 'slide' ) ) ) {
|
||||
$modules[] = 'et_pb_slide';
|
||||
}
|
||||
|
||||
// Divider
|
||||
if ( in_array( $attr, array( '', 'divider' ) ) ) {
|
||||
$modules[] = 'et_pb_divider';
|
||||
}
|
||||
|
||||
// Post Nav
|
||||
if ( in_array( $attr, array( '', 'post_nav' ) ) ) {
|
||||
$modules[] = 'et_pb_post_nav';
|
||||
}
|
||||
|
||||
// Pricing Tables
|
||||
if ( in_array( $attr, array( '', 'pricing_table' ) ) ) {
|
||||
$modules[] = 'et_pb_pricing_tables';
|
||||
}
|
||||
|
||||
// Search
|
||||
if ( in_array( $attr, array( '', 'search' ) ) ) {
|
||||
$modules[] = 'et_pb_search';
|
||||
}
|
||||
|
||||
// Sidebar
|
||||
if ( in_array( $attr, array( '', 'sidebar' ) ) ) {
|
||||
$modules[] = 'et_pb_sidebar';
|
||||
}
|
||||
|
||||
// Video Slider
|
||||
if ( in_array( $attr, array( '', 'video_slider' ) ) ) {
|
||||
$modules[] = 'et_pb_video_slider';
|
||||
}
|
||||
|
||||
// Image
|
||||
if ( in_array( $attr, array( '', 'image' ) ) ) {
|
||||
$modules[] = 'et_pb_image';
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate_spacing( $current_value, $saved_value, $location, $saved_field_name = '', $module_slug = '' ) {
|
||||
$locations = array( 'top', 'right', 'bottom', 'left' );
|
||||
$location_index = array_search( $location, $locations );
|
||||
$spacings = array( '', '', '', '' );
|
||||
|
||||
if ( -1 === $location_index ) {
|
||||
return $current_value;
|
||||
}
|
||||
|
||||
if ( '' !== $saved_value ) {
|
||||
$spacings = explode( '|', $saved_value );
|
||||
$spacings[ $location_index ] = $saved_value;
|
||||
}
|
||||
|
||||
$spacings[ $location_index ] = $current_value;
|
||||
|
||||
// Automatically add zero pixel to padding-right & padding-left of slider & post slider if custom top/bottom padding exist
|
||||
if ( '' !== $current_value && in_array( $saved_field_name, array( 'top_padding', 'bottom_padding' ) ) && in_array( $module_slug, array( 'et_pb_slider', 'et_pb_post_slider' ) ) ) {
|
||||
$spacings[1] = '0px';
|
||||
$spacings[3] = '0px';
|
||||
}
|
||||
|
||||
return implode( '|', $spacings );
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-map value to new value. Originally add to reverse yes/no button value due to option migration
|
||||
*
|
||||
* @param string saved value
|
||||
* @param array map of value, expected mapped value in key-value relationship
|
||||
* @param string default value
|
||||
* @return string mapped value
|
||||
*/
|
||||
public function migrate_remap_value( $value, $map = array(), $default = 'on' ) {
|
||||
$map = wp_parse_args(
|
||||
$map,
|
||||
array(
|
||||
'' => 'on',
|
||||
'off' => 'on',
|
||||
'on' => 'off',
|
||||
)
|
||||
);
|
||||
|
||||
return isset( $map[ $value ] ) ? $map[ $value ] : $default;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
// Padding top & bottom migration to full paddings
|
||||
if ( in_array( $module_slug, array( 'et_pb_counters', 'et_pb_post_slider', 'et_pb_fullwidth_post_slider', 'et_pb_slider', 'et_pb_fullwidth_slider' ) ) ) {
|
||||
|
||||
$top_padding_selectors = array(
|
||||
'bar_top_padding',
|
||||
'bar_top_padding_tablet',
|
||||
'bar_top_padding_phone',
|
||||
'top_padding',
|
||||
'top_padding_tablet',
|
||||
'top_padding_phone',
|
||||
);
|
||||
|
||||
if ( in_array( $saved_field_name, $top_padding_selectors ) ) {
|
||||
return $this->migrate_spacing( $current_value, $saved_value, 'top', $saved_field_name, $module_slug );
|
||||
}
|
||||
|
||||
$bottom_padding_selectors = array(
|
||||
'bar_bottom_padding',
|
||||
'bar_bottom_padding_tablet',
|
||||
'bar_bottom_padding_phone',
|
||||
'bottom_padding',
|
||||
'bottom_padding_tablet',
|
||||
'bottom_padding_phone',
|
||||
);
|
||||
|
||||
if ( in_array( $saved_field_name, $bottom_padding_selectors ) ) {
|
||||
return $this->migrate_spacing( $current_value, $saved_value, 'bottom', $saved_field_name, $module_slug );
|
||||
}
|
||||
|
||||
if ( in_array( $saved_field_name, array( 'bar_top_padding_last_edited', 'bar_bottom_padding_last_edited' ) ) ) {
|
||||
$last_edited_current_value = '' === $current_value ? array( '', '' ) : explode( '|', $current_value );
|
||||
$last_edited_saved_value = '' === $saved_value ? array( '', '' ) : explode( '|', $saved_value );
|
||||
$last_edited_responsive = in_array( 'on', array( $last_edited_current_value[0], $last_edited_saved_value[0] ) ) ? 'on' : 'off';
|
||||
$last_edited_tabs = array_filter( array( $last_edited_current_value[1], $last_edited_saved_value[1] ) );
|
||||
$last_edited_tab = empty( $last_edited_tabs ) ? 'desktop' : end( $last_edited_tabs );
|
||||
|
||||
return "{$last_edited_responsive}|{$last_edited_tab}";
|
||||
}
|
||||
}
|
||||
|
||||
// Section's padding related migration
|
||||
if ( 'et_pb_section' === $module_slug ) {
|
||||
|
||||
// Migrating two side paddings (prior to Divi v2.4) into full paddings
|
||||
if ( 'custom_padding' === $field_name && 'custom_padding' === $saved_field_name ) {
|
||||
$padding_sides = explode( '|', $current_value );
|
||||
|
||||
if ( 2 === count( $padding_sides ) ) {
|
||||
$full_padding_sides = array(
|
||||
$padding_sides[0],
|
||||
'',
|
||||
$padding_sides[1],
|
||||
'',
|
||||
);
|
||||
|
||||
return implode( '|', $full_padding_sides );
|
||||
}
|
||||
}
|
||||
|
||||
// Translating "Keep padding on mobile" options into *_last_edited value
|
||||
if ( 'custom_padding_last_edited' === $field_name && 'padding_mobile' === $saved_field_name ) {
|
||||
|
||||
if ( 'off' === $current_value && '' === $saved_value ) {
|
||||
return 'on|desktop';
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
// Translating "Keep padding on mobile" options into custom_padding_tablet value
|
||||
if ( 'custom_padding_tablet' === $field_name && 'padding_mobile' === $saved_field_name ) {
|
||||
// Keep padding on mobile is disabled
|
||||
if ( '' === $saved_value && 'off' === $current_value ) {
|
||||
return '50px|0|50px|0';
|
||||
}
|
||||
|
||||
// Keep padding on mobile is enabled and custom padding is defined. If no custom_padding value is defined,
|
||||
// the value is expected to be empty string, which makes letting $saved_value to be returned is ok
|
||||
if ( '' === $saved_value && 'on' === $current_value && isset( $attrs['custom_padding'] ) ) {
|
||||
return $attrs['custom_padding'];
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
// Translating transparent_background into background_color
|
||||
if ( 'background_color' === $field_name && in_array( $saved_field_name, array( 'transparent_background', 'transparent_background_fb' ) ) ) {
|
||||
// Transparent is default for Builder Plugin, but not for theme
|
||||
if ( 'on' === $current_value || ( et_is_builder_plugin_active() && 'default' === $current_value ) ) {
|
||||
return 'rgba(255,255,255,0)';
|
||||
} else {
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Divider's hide_on_mobile migration
|
||||
if ( 'et_pb_divider' === $module_slug && 'disabled_on' === $field_name ) {
|
||||
// Set disabled_on if it is previously empty and hide_on_mobile is empty / on (its default value is on)
|
||||
if ( in_array( $current_value, array( '', 'on' ) ) && '' === $saved_value ) {
|
||||
return 'on|on|off';
|
||||
}
|
||||
|
||||
// Translate hide_on_mobile into disabled_on if hide_on_mobile is empty / on and saved_value isn't empty
|
||||
if ( in_array( $current_value, array( '', 'on' ) ) && '' !== $saved_value ) {
|
||||
$disabled_on_array = explode( '|', $saved_value );
|
||||
$disabled_on_array[0] = 'on';
|
||||
$disabled_on_array[1] = 'on';
|
||||
|
||||
return implode( '|', $disabled_on_array );
|
||||
}
|
||||
|
||||
// Otherwise, return saved value
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
if ( 'parallax_method' === $field_name ) {
|
||||
// Reverse post title and fullwidth post title's parallax_method value because its previous select option values (on = CSS, off = True)
|
||||
// were reversed compared to background UI's parallax_method select options values (on = True, off = CSS)
|
||||
if ( in_array( $module_slug, $this->get_modules( 'post_title' ) ) && isset( $this->fields[ $field_name ] ) && isset( $this->fields[ $field_name ]['values'][ $saved_value ] ) ) {
|
||||
return $this->fields[ $field_name ]['values'][ $saved_value ];
|
||||
}
|
||||
|
||||
// Previous version of slide item has parallax_method options order reversed which causing CSS Parallax can't be rendered.
|
||||
// If the attribute has been saved, it will be rendered just fine
|
||||
// $saved_value reflects the correct value, now it inherits value from Slider / Fullwidth Slider module
|
||||
if ( in_array( $module_slug, $this->get_modules( 'slide' ) ) && '' === $current_value ) {
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Normalizing video slider's display image overlay's hide/show & select-based field into yes_no_button + on/off-based option
|
||||
if ( 'et_pb_video_slider' === $module_slug && 'show_image_overlay' === $field_name ) {
|
||||
return $this->migrate_remap_value(
|
||||
$current_value,
|
||||
array(
|
||||
'hide' => 'off',
|
||||
'show' => 'on',
|
||||
'' => 'off',
|
||||
),
|
||||
'off'
|
||||
);
|
||||
}
|
||||
|
||||
// Search's input background migration
|
||||
if ( 'et_pb_search' === $module_slug && 'background_color' === $field_name ) {
|
||||
if ( '' !== $saved_value && '' === $current_value ) {
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Only Text & Search module's text_orientation = center that is being migrated to each module's module_alignment attribute
|
||||
// If module's text_orientation has different value, let it be. This is needed because on previous version, .et_pb_text_align_center class
|
||||
// set text-align: center; AND margin: 0 auto; margin: 0 auto; belongs to module alignment now, hence the migration
|
||||
if ( in_array( $module_slug, $this->get_modules( 'text_orientation' ) ) && 'text_orientation' === $saved_field_name && 'module_alignment' === $field_name ) {
|
||||
if ( 'center' === $current_value && '' === $saved_value ) {
|
||||
return $current_value;
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
// Normalizing "remove_*" & "hide_*" option, to ensure that "Yes" === "Show".
|
||||
// saved value needs to be reversed / remapped, off == on, vice versa
|
||||
$is_slider_remove = in_array( $module_slug, $this->get_modules( 'slider' ) ) && in_array( $saved_field_name, array( 'remove_inner_shadow', 'hide_content_on_mobile', 'hide_cta_on_mobile' ) );
|
||||
$is_post_nav_hides = 'et_pb_post_nav' === $module_slug && in_array( $saved_field_name, array( 'hide_prev', 'hide_next' ) );
|
||||
$is_pricing_tables_remove = 'et_pb_pricing_tables' === $module_slug && in_array( $saved_field_name, array( 'remove_featured_drop_shadow' ) );
|
||||
$is_search_hide = 'et_pb_search' === $module_slug && in_array( $saved_field_name, array( 'hide_button' ) );
|
||||
$is_sidebar_remove = 'et_pb_sidebar' === $module_slug && in_array( $saved_field_name, array( 'remove_border' ) );
|
||||
$is_image_sticky = 'et_pb_image' === $module_slug && in_array( $saved_field_name, array( 'sticky' ) );
|
||||
|
||||
if ( $is_slider_remove || $is_post_nav_hides || $is_pricing_tables_remove || $is_search_hide || $is_sidebar_remove || $is_image_sticky ) {
|
||||
return $this->migrate_remap_value( $current_value );
|
||||
}
|
||||
|
||||
// Blurb's max_width needs to be removed, since older max_width is new image_max_width
|
||||
if ( in_array( $module_slug, $this->get_modules( 'reset_max_width' ) ) && 'max_width' === $field_name && 'max_width' === $saved_field_name ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $current_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_OptionsHarmony();
|
489
includes/builder/module/settings/migration/OptionsHarmony2.php
Normal file
489
includes/builder/module/settings/migration/OptionsHarmony2.php
Normal file
@ -0,0 +1,489 @@
|
||||
<?php
|
||||
/**
|
||||
* Migration process to handle all the changes done in Options Harmony v2's QF.
|
||||
*
|
||||
* @since 3.23
|
||||
*/
|
||||
class ET_Builder_Module_Settings_Migration_OptionsHarmony2 extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
/**
|
||||
* Migration Version
|
||||
*
|
||||
* @since 3.23
|
||||
* @todo Should be replaced with the correct release version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $version = '3.23';
|
||||
|
||||
/**
|
||||
* Get all fields need to be migrated.
|
||||
*
|
||||
* Contains array with:
|
||||
* - key as new field
|
||||
* - value consists affected fields as old field and module location
|
||||
*
|
||||
* @since 3.23
|
||||
*
|
||||
* @return array New and old fields need to be migrated.
|
||||
*/
|
||||
public function get_fields() {
|
||||
return array(
|
||||
// Form Field BG Color.
|
||||
'form_field_background_color' => array(
|
||||
'affected_fields' => array(
|
||||
'form_background_color' => $this->get_modules( 'form_bg_color' ),
|
||||
'field_background_color' => $this->get_modules( 'field_bg_color' ),
|
||||
),
|
||||
),
|
||||
'form_field_background_color__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'form_background_color__hover_enabled' => $this->get_modules( 'contact_form' ),
|
||||
'field_background_color__hover_enabled' => $this->get_modules( 'contact_form_field' ),
|
||||
),
|
||||
),
|
||||
'form_field_background_color__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'form_background_color__hover' => $this->get_modules( 'contact_form' ),
|
||||
'field_background_color__hover' => $this->get_modules( 'contact_form_field' ),
|
||||
),
|
||||
),
|
||||
// Form Field Focus BG Color.
|
||||
'form_field_focus_background_color' => array(
|
||||
'affected_fields' => array(
|
||||
'focus_background_color' => $this->get_modules( 'focus_bg_color' ),
|
||||
),
|
||||
),
|
||||
'form_field_focus_background_color__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'focus_background_color__hover_enabled' => $this->get_modules( 'login' ),
|
||||
),
|
||||
),
|
||||
'form_field_focus_background_color__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'focus_background_color__hover' => $this->get_modules( 'login' ),
|
||||
),
|
||||
),
|
||||
// Form Field Focus Text Color.
|
||||
'form_field_focus_text_color' => array(
|
||||
'affected_fields' => array(
|
||||
'focus_text_color' => $this->get_modules( 'focus_bg_color' ),
|
||||
),
|
||||
),
|
||||
'form_field_focus_text_color__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'focus_text_color__hover_enabled' => $this->get_modules( 'login' ),
|
||||
),
|
||||
),
|
||||
'form_field_focus_text_color__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'focus_text_color__hover' => $this->get_modules( 'login' ),
|
||||
),
|
||||
),
|
||||
// Form Field Font.
|
||||
'form_field_text_color' => array(
|
||||
'affected_fields' => array(
|
||||
'input_text_color' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_color__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'input_text_color__hover_enabled' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_color__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'input_text_color__hover' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_font' => array(
|
||||
'affected_fields' => array(
|
||||
'input_font' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_align' => array(
|
||||
'affected_fields' => array(
|
||||
'input_text_align' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_font_size' => array(
|
||||
'affected_fields' => array(
|
||||
'input_font_size' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_font_size_last_edited' => array(
|
||||
'affected_fields' => array(
|
||||
'input_font_size_last_edited' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_font_size_tablet' => array(
|
||||
'affected_fields' => array(
|
||||
'input_font_size_tablet' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_font_size_phone' => array(
|
||||
'affected_fields' => array(
|
||||
'input_font_size_phone' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_font_size__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'input_font_size__hover_enabled' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_font_size__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'input_font_size__hover' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_letter_spacing' => array(
|
||||
'affected_fields' => array(
|
||||
'input_letter_spacing' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_letter_spacing_last_edited' => array(
|
||||
'affected_fields' => array(
|
||||
'input_letter_spacing_last_edited' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_letter_spacing_tablet' => array(
|
||||
'affected_fields' => array(
|
||||
'input_letter_spacing_tablet' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_letter_spacing_phone' => array(
|
||||
'affected_fields' => array(
|
||||
'input_letter_spacing_phone' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_letter_spacing__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'input_letter_spacing__hover_enabled' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_letter_spacing__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'input_letter_spacing__hover' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_line_height' => array(
|
||||
'affected_fields' => array(
|
||||
'input_line_height' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_line_height_last_edited' => array(
|
||||
'affected_fields' => array(
|
||||
'input_line_height_last_edited' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_line_height_tablet' => array(
|
||||
'affected_fields' => array(
|
||||
'input_line_height_tablet' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_line_height_phone' => array(
|
||||
'affected_fields' => array(
|
||||
'input_line_height_phone' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_line_height__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'input_line_height__hover_enabled' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_line_height__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'input_line_height__hover' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
// Form Field Text Shadow.
|
||||
'form_field_text_shadow_horizontal_length' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_horizontal_length' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_horizontal_length' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_horizontal_length__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_horizontal_length__hover_enabled' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_horizontal_length__hover_enabled' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_horizontal_length__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_horizontal_length__hover' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_horizontal_length__hover' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_vertical_length' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_vertical_length' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_vertical_length' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_vertical_length__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_vertical_length__hover_enabled' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_vertical_length__hover_enabled' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_vertical_length__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_vertical_length__hover' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_vertical_length__hover' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_blur_strength' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_blur_strength' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_blur_strength' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_blur_strength__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_blur_strength__hover_enabled' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_blur_strength__hover_enabled' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_blur_strength__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_blur_strength__hover' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_blur_strength__hover' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_color' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_color' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_color' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_color__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_color__hover_enabled' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_color__hover_enabled' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_color__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_color__hover' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_color__hover' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
'form_field_text_shadow_style' => array(
|
||||
'affected_fields' => array(
|
||||
'fields_text_shadow_style' => $this->get_modules( 'text_shadow' ),
|
||||
'input_text_shadow_style' => $this->get_modules( 'search' ),
|
||||
),
|
||||
),
|
||||
// Image.
|
||||
'align_last_edited' => array(
|
||||
'affected_fields' => array(
|
||||
'always_center_on_mobile' => $this->get_modules( 'image' ),
|
||||
),
|
||||
),
|
||||
'align_tablet' => array(
|
||||
'affected_fields' => array(
|
||||
'always_center_on_mobile' => $this->get_modules( 'image' ),
|
||||
),
|
||||
),
|
||||
// Price Excluded Color.
|
||||
'excluded_text_color' => array(
|
||||
'affected_fields' => array(
|
||||
'pricing_item_excluded_color' => $this->get_modules( 'pricing_table' ),
|
||||
),
|
||||
),
|
||||
'excluded_text_color__hover_enabled' => array(
|
||||
'affected_fields' => array(
|
||||
'pricing_item_excluded_color__hover_enabled' => $this->get_modules( 'pricing_table' ),
|
||||
),
|
||||
),
|
||||
'excluded_text_color__hover' => array(
|
||||
'affected_fields' => array(
|
||||
'pricing_item_excluded_color__hover' => $this->get_modules( 'pricing_table' ),
|
||||
),
|
||||
),
|
||||
// Price Excluded Color.
|
||||
'body_text_align' => array(
|
||||
'affected_fields' => array(
|
||||
'center_list_items' => $this->get_modules( 'pricing_tables' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all modules affected.
|
||||
*
|
||||
* Pass attribute and it will return selected modules only. Default return all affected modules.
|
||||
*
|
||||
* @since 3.23
|
||||
*
|
||||
* @param string $attr Attribute name.
|
||||
*
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function get_modules( $attr = '' ) {
|
||||
$modules = array();
|
||||
|
||||
// Comments.
|
||||
if ( in_array( $attr, array( '', 'comments' ) ) ) {
|
||||
$modules[] = 'et_pb_comments';
|
||||
}
|
||||
|
||||
// Contact Form.
|
||||
if ( in_array( $attr, array( '', 'contact_form' ) ) ) {
|
||||
$modules[] = 'et_pb_contact_form';
|
||||
}
|
||||
|
||||
// Contact Form Field.
|
||||
if ( in_array( $attr, array( '', 'contact_form_field' ) ) ) {
|
||||
$modules[] = 'et_pb_contact_field';
|
||||
}
|
||||
|
||||
// Email Optin.
|
||||
if ( in_array( $attr, array( '', 'email_optin' ) ) ) {
|
||||
$modules[] = 'et_pb_signup';
|
||||
}
|
||||
|
||||
// Email Optin Custom Field.
|
||||
if ( in_array( $attr, array( '', 'email_optin_field' ) ) ) {
|
||||
$modules[] = 'et_pb_signup_custom_field';
|
||||
}
|
||||
|
||||
// Image.
|
||||
if ( in_array( $attr, array( '', 'image' ) ) ) {
|
||||
$modules[] = 'et_pb_image';
|
||||
}
|
||||
|
||||
// Login.
|
||||
if ( in_array( $attr, array( '', 'login' ) ) ) {
|
||||
$modules[] = 'et_pb_login';
|
||||
}
|
||||
|
||||
// Search.
|
||||
if ( in_array( $attr, array( '', 'search' ) ) ) {
|
||||
$modules[] = 'et_pb_search';
|
||||
}
|
||||
|
||||
// Pricing Table.
|
||||
if ( in_array( $attr, array( '', 'pricing_tables' ) ) ) {
|
||||
$modules[] = 'et_pb_pricing_tables';
|
||||
}
|
||||
|
||||
if ( in_array( $attr, array( '', 'pricing_table' ) ) ) {
|
||||
$modules[] = 'et_pb_pricing_table';
|
||||
}
|
||||
|
||||
// Form BG Color options group.
|
||||
if ( 'form_bg_color' === $attr ) {
|
||||
$modules[] = 'et_pb_comments';
|
||||
$modules[] = 'et_pb_contact_form';
|
||||
}
|
||||
|
||||
// Form BG Color options group.
|
||||
if ( 'field_bg_color' === $attr ) {
|
||||
$modules[] = 'et_pb_signup_custom_field';
|
||||
$modules[] = 'et_pb_contact_field';
|
||||
}
|
||||
|
||||
// Form BG Color options group.
|
||||
if ( in_array( $attr, array( 'focus_bg_color', 'text_shadow' ) ) ) {
|
||||
$modules[] = 'et_pb_signup';
|
||||
$modules[] = 'et_pb_login';
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
|
||||
// Migrate Email Optin fields text shadow. There is a conflict on Fields & Email Optin. There
|
||||
// are two different Text Shadow settings. The first one under Fields settings, the second one
|
||||
// under Field Text. In the process, the second one has higher priority than the first one. And
|
||||
// it has the same prefix with current form field. So, we need to check if saved value (2nd) is
|
||||
// exist and not empty, return it and no need to migrate.
|
||||
if ( 'et_pb_signup' === $module_slug ) {
|
||||
$text_shadow_property_name = $this->get_form_field_text_shadow( $field_name );
|
||||
if ( '' !== $text_shadow_property_name ) {
|
||||
// If form_field_text_shadow_style value is not 'none', we need to return current saved
|
||||
// value or 2nd text shadow settings value (Field Text).
|
||||
$form_field_text_shadow_style = isset( $attrs['form_field_text_shadow_style'] ) ? $attrs['form_field_text_shadow_style'] : '';
|
||||
if ( '' !== $form_field_text_shadow_style && 'none' !== $form_field_text_shadow_style ) {
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
return $current_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate Always Center Image on Mobile field as Image Alignment. If current value is
|
||||
// 'off', there is nothing we need to do here. But, if it's 'on', we need to set value
|
||||
// for align_tablet and align_last_edited.
|
||||
if ( 'et_pb_image' === $module_slug ) {
|
||||
if ( 'align_last_edited' === $field_name && 'off' !== $current_value ) {
|
||||
// If always_center_on_mobile is on (the current value is ''), we need to set last
|
||||
// edited value as 'on|desktop'.
|
||||
return 'on|desktop';
|
||||
} elseif ( 'align_tablet' === $field_name && 'off' !== $current_value ) {
|
||||
// If always_center_on_mobile is on (the current value is ''), we need to set align
|
||||
// tablet value as center.
|
||||
return 'center';
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
// Migrate Center List Items as Body Tetx Alignment. If current value is 'off', there is
|
||||
// nothing we need to do here. But, if it's 'on', we need to set value for body_text_align
|
||||
// as 'center'.
|
||||
if ( 'et_pb_pricing_tables' === $module_slug ) {
|
||||
if ( 'body_text_align' === $field_name && 'on' === $current_value && empty( $saved_value ) ) {
|
||||
// If center_list_items is on (the current value is 'on'), we need to set body text
|
||||
// align value as 'center'. However, only do this if current $saved_value is empty
|
||||
// because body_text_align has higher priority than center_list_items.
|
||||
return 'center';
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
// Don't migrate empty value.
|
||||
if ( ! empty( $current_value ) ) {
|
||||
return $current_value;
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Text shadow properties need to be migrated.
|
||||
*
|
||||
* It's only used to check if current text shadow property is the correct field to migrate.
|
||||
*
|
||||
* @since 3.23
|
||||
*
|
||||
* @param string $field_name New field name.
|
||||
* @return string Old field name.
|
||||
*/
|
||||
public function get_form_field_text_shadow( $field_name = '' ) {
|
||||
$text_shadow_properties = array(
|
||||
'form_field_text_shadow_style' => 'fields_text_shadow_style',
|
||||
'form_field_text_shadow_horizontal_length' => 'fields_text_shadow_horizontal_length',
|
||||
'form_field_text_shadow_horizontal_length__hover_enabled' => 'fields_text_shadow_horizontal_length__hover_enabled',
|
||||
'form_field_text_shadow_horizontal_length__hover' => 'fields_text_shadow_horizontal_length__hover',
|
||||
'form_field_text_shadow_vertical_length' => 'fields_text_shadow_vertical_length',
|
||||
'form_field_text_shadow_vertical_length__hover_enabled' => 'fields_text_shadow_vertical_length__hover_enabled',
|
||||
'form_field_text_shadow_vertical_length__hover' => 'fields_text_shadow_vertical_length__hover',
|
||||
'form_field_text_shadow_blur_strength' => 'fields_text_shadow_blur_strength',
|
||||
'form_field_text_shadow_blur_strength__hover' => 'fields_text_shadow_blur_strength__hover',
|
||||
'form_field_text_shadow_blur_strength__hover_enabled' => 'fields_text_shadow_blur_strength__hover_enabled',
|
||||
'form_field_text_shadow_color' => 'fields_text_shadow_color',
|
||||
'form_field_text_shadow_color__hover_enabled' => 'fields_text_shadow_color__hover_enabled',
|
||||
'form_field_text_shadow_color__hover' => 'fields_text_shadow_color__hover',
|
||||
);
|
||||
|
||||
return isset( $text_shadow_properties[ $field_name ] ) ? $text_shadow_properties[ $field_name ] : '';
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_OptionsHarmony2();
|
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_RowCustomWidthToSizing extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.22';
|
||||
|
||||
public function get_modules() {
|
||||
return array( 'et_pb_row', 'et_pb_section' );
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'module_class' => array(
|
||||
'affected_fields' => array(
|
||||
'make_fullwidth' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( $this->get_modules() as $module ) {
|
||||
foreach ( $this->get_keys() as $key ) {
|
||||
$field = $module === 'et_pb_section' ? "inner_$key" : $key;
|
||||
$fields[ $field ] = array(
|
||||
'affected_fields' => array(
|
||||
'make_fullwidth' => array( $module ),
|
||||
'use_custom_width' => array( $module ),
|
||||
'width_unit' => array( $module ),
|
||||
'custom_width_px' => array( $module ),
|
||||
'custom_width_px__hover' => array( $module ),
|
||||
'custom_width_px__hover_enabled' => array( $module ),
|
||||
'custom_width_percent' => array( $module ),
|
||||
'custom_width_percent__hover' => array( $module ),
|
||||
'custom_width_percent__hover_enabled' => array( $module ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function migrate(
|
||||
$field_name,
|
||||
$current_value,
|
||||
$module_slug,
|
||||
$saved_value,
|
||||
$saved_field_name,
|
||||
$attrs,
|
||||
$content,
|
||||
$module_address
|
||||
) {
|
||||
$raw_field = str_replace( 'inner_', '', $field_name );
|
||||
|
||||
if ( et_builder_module_prop( 'use_custom_width', $attrs, '' ) === 'on' ) {
|
||||
$percent = et_builder_module_prop( 'width_unit', $attrs, '' ) === 'off';
|
||||
$field = $percent ? 'custom_width_percent' : 'custom_width_px';
|
||||
|
||||
switch ( $raw_field ) {
|
||||
// If the field is set to % only the max-width is defined
|
||||
case 'width':
|
||||
return ! $percent ? $saved_value : et_builder_module_prop( $field, $attrs, '' );
|
||||
case 'width__hover':
|
||||
return ! $percent ? $saved_value : et_builder_module_prop( "{$field}__hover", $attrs, '' );
|
||||
case 'width__hover_enabled':
|
||||
return ! $percent ? $saved_value : et_builder_module_prop( "{$field}__hover_enabled", $attrs, '' );
|
||||
|
||||
case 'max_width':
|
||||
return et_builder_module_prop( $field, $attrs, $percent ? '80%' : '' );
|
||||
case 'max_width__hover':
|
||||
return et_builder_module_prop( "{$field}__hover", $attrs, '' );
|
||||
case 'max_width__hover_enabled':
|
||||
return et_builder_module_prop( "{$field}__hover_enabled", $attrs, '' );
|
||||
default:
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
if ( et_builder_module_prop( 'make_fullwidth', $attrs, '' ) === 'on' ) {
|
||||
$gutter = (int) et_builder_module_prop( 'gutter_width', $attrs, '' );
|
||||
|
||||
switch ( $raw_field ) {
|
||||
case 'module_class':
|
||||
return $saved_value . ' ' . $this->class_name( $module_slug );
|
||||
case 'width_last_edited':
|
||||
case 'max_width_last_edited':
|
||||
return 'on|desktop';
|
||||
case 'width_tablet':
|
||||
case 'max_width_tablet':
|
||||
return 1 === $gutter ? '100%' : '80%';
|
||||
case 'width':
|
||||
case 'max_width':
|
||||
return $this->get_width( $gutter );
|
||||
}
|
||||
|
||||
if ( et_builder_module_prop( 'gutter_width__hover_enabled', $attrs, '' ) === 'on' ) {
|
||||
$gutter = (int) et_builder_module_prop( 'gutter_width__hover', $attrs, '' );
|
||||
|
||||
switch ( $raw_field ) {
|
||||
case 'width__hover_enabled':
|
||||
case 'max_width__hover_enabled':
|
||||
return 'on';
|
||||
case 'width__hover':
|
||||
case 'max_width__hover':
|
||||
return $this->get_width( $gutter );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
private function get_keys() {
|
||||
return array_merge( $this->to_fields( 'width' ), $this->to_fields( 'max_width' ) );
|
||||
}
|
||||
|
||||
private function to_fields( $field ) {
|
||||
return array(
|
||||
$field,
|
||||
"{$field}_tablet",
|
||||
"{$field}_phone",
|
||||
"{$field}_last_edited",
|
||||
"{$field}__hover",
|
||||
"{$field}__hover_enabled",
|
||||
);
|
||||
}
|
||||
|
||||
private function get_width( $gutter ) {
|
||||
switch ( $gutter ) {
|
||||
case 1:
|
||||
return '100%';
|
||||
case 2:
|
||||
return '94%';
|
||||
case 3:
|
||||
return '89%';
|
||||
case 4:
|
||||
return '86%';
|
||||
default:
|
||||
return '89%';
|
||||
}
|
||||
}
|
||||
|
||||
private function class_name( $module ) {
|
||||
switch ( $module ) {
|
||||
case 'et_pb_row':
|
||||
return 'et_pb_row_fullwidth';
|
||||
case 'et_pb_section':
|
||||
return 'et_pb_specialty_fullwidth';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_RowCustomWidthToSizing();
|
70
includes/builder/module/settings/migration/RowZeroGutter.php
Normal file
70
includes/builder/module/settings/migration/RowZeroGutter.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_RowZeroGutter extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.22.3';
|
||||
|
||||
public function get_modules() {
|
||||
return array( 'et_pb_row', 'et_pb_section' );
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$fields = array();
|
||||
|
||||
foreach ( $this->get_modules() as $module ) {
|
||||
foreach ( $this->get_keys() as $key ) {
|
||||
$field = $module === 'et_pb_section' ? "inner_$key" : $key;
|
||||
$fields[ $field ] = array(
|
||||
'affected_fields' => array(
|
||||
$field => array( $module ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function migrate(
|
||||
$field_name,
|
||||
$current_value,
|
||||
$module_slug,
|
||||
$saved_value,
|
||||
$saved_field_name,
|
||||
$attrs,
|
||||
$content,
|
||||
$module_address
|
||||
) {
|
||||
$raw_field = str_replace( 'inner_', '', $field_name );
|
||||
$gutter = et_builder_module_prop( 'gutter_width', $attrs, '' );
|
||||
$classes = array_map( 'trim', explode( ' ', et_builder_module_prop( 'module_class', $attrs, '' ) ) );
|
||||
$is_fw = in_array( 'et_pb_row_fullwidth', $classes ) || in_array( 'et_pb_specialty_fullwidth', $classes );
|
||||
|
||||
if ( '0' === $gutter && $is_fw ) {
|
||||
switch ( $raw_field ) {
|
||||
case 'width_tablet':
|
||||
case 'max_width_tablet':
|
||||
return '80%' === $saved_value ? '100%' : $saved_value;
|
||||
case 'width':
|
||||
case 'max_width':
|
||||
return '89%' === $saved_value ? '100%' : $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
protected function get_keys() {
|
||||
return array_merge( $this->to_fields( 'width' ), $this->to_fields( 'max_width' ) );
|
||||
}
|
||||
|
||||
protected function to_fields( $field ) {
|
||||
return array(
|
||||
$field,
|
||||
"{$field}_tablet",
|
||||
"{$field}_phone",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_RowZeroGutter();
|
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_ShopModuleSlugs extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public function get_modules() {
|
||||
$modules = array(
|
||||
'et_pb_shop',
|
||||
);
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
if ( ! class_exists( 'WooCommerce' ) ) {
|
||||
return $current_value;
|
||||
}
|
||||
|
||||
switch ( $field_name ) {
|
||||
case 'include_categories':
|
||||
$old_categories = explode( ',', $current_value );
|
||||
$new_categories = array();
|
||||
$product_categories = et_builder_get_shop_categories();
|
||||
if ( is_array( $product_categories ) && ! empty( $product_categories ) ) {
|
||||
foreach ( $product_categories as $category ) {
|
||||
if ( is_object( $category ) && is_a( $category, 'WP_Term' ) ) {
|
||||
if ( in_array( $category->slug, $old_categories ) ) {
|
||||
array_push( $new_categories, $category->term_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode( ',', $new_categories );
|
||||
case '_builder_version':
|
||||
return ET_BUILDER_PRODUCT_VERSION;
|
||||
default:
|
||||
return $current_value;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'include_categories' => array(
|
||||
'affected_fields' => array(
|
||||
'include_categories' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
'_builder_version' => array(
|
||||
'affected_fields' => array(
|
||||
'_builder_version' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_ShopModuleSlugs();
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_ShopOrderByDefault extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.25.3';
|
||||
|
||||
public function get_modules() {
|
||||
return array( 'et_pb_shop' );
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
$fields = array(
|
||||
'orderby' => array(
|
||||
'affected_fields' => array(
|
||||
'orderby' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function migrate(
|
||||
$field_name,
|
||||
$current_value,
|
||||
$module_slug,
|
||||
$saved_value,
|
||||
$saved_field_name,
|
||||
$attrs,
|
||||
$content,
|
||||
$module_address
|
||||
) {
|
||||
return '' === $current_value ? 'menu_order' : $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_ShopOrderByDefault();
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class ET_Builder_Module_Settings_Migration_TeamMemberIconHover extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
public $version = '3.12.3';
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
et_pb_hover_options()->get_hover_field( 'icon_color' ) => array(
|
||||
'affected_fields' => array(
|
||||
'icon_hover_color' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
et_pb_hover_options()->get_hover_enabled_field( 'icon_color' ) => array(
|
||||
'affected_fields' => array(
|
||||
'icon_hover_color' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function get_modules() {
|
||||
$modules = array(
|
||||
'et_pb_team_member',
|
||||
);
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
|
||||
if ( empty( $current_value ) ) {
|
||||
return $saved_value;
|
||||
}
|
||||
|
||||
switch ( $field_name ) {
|
||||
case et_pb_hover_options()->get_hover_field( 'icon_color' ):
|
||||
return $current_value;
|
||||
case et_pb_hover_options()->get_hover_enabled_field( 'icon_color' ):
|
||||
return 'on';
|
||||
}
|
||||
|
||||
return $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_TeamMemberIconHover();
|
66
includes/builder/module/settings/migration/TextAlignment.php
Normal file
66
includes/builder/module/settings/migration/TextAlignment.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Migration process to migrate Text Text Alignment into Text Orientation of Text module.
|
||||
*
|
||||
* @since 3.27.4
|
||||
*/
|
||||
class ET_Builder_Module_Settings_Migration_TextAlignment extends ET_Builder_Module_Settings_Migration {
|
||||
|
||||
/**
|
||||
* Migration Version
|
||||
*
|
||||
* @since 3.27.4
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $version = '3.27.4';
|
||||
|
||||
/**
|
||||
* Get all fields need to be migrated.
|
||||
*
|
||||
* Contains array with:
|
||||
* - key as new field
|
||||
* - value consists affected fields as old field and module location
|
||||
*
|
||||
* @since 3.27.4
|
||||
*
|
||||
* @return array New and old fields need to be migrated.
|
||||
*/
|
||||
public function get_fields() {
|
||||
return array(
|
||||
// Text Alignment of Text module.
|
||||
'text_orientation' => array(
|
||||
'affected_fields' => array(
|
||||
'text_text_align' => $this->get_modules(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all modules affected.
|
||||
*
|
||||
* @since 3.27.4
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_modules() {
|
||||
return array( 'et_pb_text' );
|
||||
}
|
||||
|
||||
public function migrate(
|
||||
$field_name,
|
||||
$current_value,
|
||||
$module_slug,
|
||||
$saved_value,
|
||||
$saved_field_name,
|
||||
$attrs,
|
||||
$content,
|
||||
$module_address
|
||||
) {
|
||||
// Don't migrate empty value.
|
||||
return ! empty( $current_value ) ? $current_value : $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_TextAlignment();
|
142
includes/builder/module/settings/migration/UIImprovements.php
Normal file
142
includes/builder/module/settings/migration/UIImprovements.php
Normal file
@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
* Migration for modules fields prior to UI Improvement Release. Some defaults are changes for better UI, these
|
||||
* migrations makes affected modules made prior UI Improvement to keep its current UI output
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
class ET_Builder_Module_Settings_Migration_UIImprovement extends ET_Builder_Module_Settings_Migration {
|
||||
public $version = '3.2';
|
||||
|
||||
public function get_modules( $group = '' ) {
|
||||
$modules = array();
|
||||
|
||||
if ( in_array( $group, array( '', 'testimonial', 'background_layout', 'version' ) ) ) {
|
||||
$modules[] = 'et_pb_testimonial';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'slide', 'background_color' ) ) ) {
|
||||
$modules[] = 'et_pb_slide';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'post_slider', 'background_color' ) ) ) {
|
||||
$modules[] = 'et_pb_post_slider';
|
||||
$modules[] = 'et_pb_fullwidth_post_slider';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'fullwidth_header', 'background_layout', 'background_color', 'version' ) ) ) {
|
||||
$modules[] = 'et_pb_fullwidth_header';
|
||||
}
|
||||
|
||||
if ( in_array( $group, array( '', 'divider', 'version' ) ) ) {
|
||||
$modules[] = 'et_pb_divider';
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public function get_fields() {
|
||||
return array(
|
||||
'background_layout' => array(
|
||||
'affected_fields' => array(
|
||||
'background_layout' => $this->get_modules( 'background_layout' ),
|
||||
),
|
||||
),
|
||||
'background_color' => array(
|
||||
'affected_fields' => array(
|
||||
'background_color' => $this->get_modules( 'background_color' ),
|
||||
),
|
||||
),
|
||||
'color' => array(
|
||||
'affected_fields' => array(
|
||||
'color' => $this->get_modules( 'divider' ),
|
||||
),
|
||||
),
|
||||
'show_divider' => array(
|
||||
'affected_fields' => array(
|
||||
'show_divider' => $this->get_modules( 'divider' ),
|
||||
),
|
||||
),
|
||||
'_builder_version' => array(
|
||||
'affected_fields' => array(
|
||||
'_builder_version' => $this->get_modules( 'version' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
|
||||
$is_current_value_empty = '' === $current_value;
|
||||
|
||||
if ( $is_current_value_empty ) {
|
||||
// Background Layout
|
||||
if ( 'background_layout' === $field_name ) {
|
||||
// Testimonial
|
||||
if ( 'et_pb_testimonial' === $module_slug ) {
|
||||
$current_value = 'dark';
|
||||
}
|
||||
|
||||
if ( 'et_pb_fullwidth_header' === $module_slug ) {
|
||||
$current_value = 'light';
|
||||
}
|
||||
}
|
||||
|
||||
// Background Color
|
||||
if ( 'background_color' === $field_name ) {
|
||||
if ( in_array( $module_slug, $this->get_modules( 'slide' ) ) ) {
|
||||
$current_value = '#ffffff';
|
||||
|
||||
if ( et_builder_accent_color() === $saved_value ) {
|
||||
$current_value = '#ffffff';
|
||||
} else {
|
||||
$current_value = $saved_value;
|
||||
}
|
||||
}
|
||||
|
||||
if ( in_array( $module_slug, $this->get_modules( 'post_slider' ) ) ) {
|
||||
if ( isset( $attrs['background_layout'] ) && 'light' === $attrs['background_layout'] ) {
|
||||
$current_value = '#f5f5f5';
|
||||
} else {
|
||||
$current_value = '#2ea3f2';
|
||||
}
|
||||
}
|
||||
|
||||
// Migrated value cannot be empty string because it'll be filled by default on visual builder.
|
||||
// Thus for empty value, use rgba-based transparent white color
|
||||
if ( in_array( $module_slug, $this->get_modules( 'fullwidth_header' ) ) ) {
|
||||
$current_value = 'rgba(255, 255, 255, 0)';
|
||||
}
|
||||
}
|
||||
|
||||
// Divider
|
||||
if ( in_array( $module_slug, $this->get_modules( 'divider' ) ) ) {
|
||||
if ( 'color' === $field_name ) {
|
||||
$current_value = '#ffffff';
|
||||
}
|
||||
|
||||
// Divider visibility was automatically set to visible when module customizer for divider visibility is turned on in theme
|
||||
// Thus the migration only took effect on theme when module customizer for divider visibility isn't turn on
|
||||
$is_theme_module_customizer_unmodified = ! et_is_builder_plugin_active() && true === et_get_option( 'et_pb_divider-show_divider', false );
|
||||
|
||||
if ( 'show_divider' === $field_name && ! $is_theme_module_customizer_unmodified ) {
|
||||
$current_value = 'off';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bump _builder_version if migrate() is called for visual builder data retrieval. This needs to be done
|
||||
// due to shortcode trimming. Migration originally added with migrating attribute value from a field_name to
|
||||
// different field_name in mind. When data is migrated to the same field_name and the value gets trimmed
|
||||
// due to it being identical to default value, what ends up happening is unexpected layout change when
|
||||
// layout is saved in VB because the builder version remains but the data changed and gets trimmed
|
||||
// because it is migrated to default value and it gets migrated again on the next round (due to builder
|
||||
// version remains to its original value)
|
||||
if ( $field_name === '_builder_version' && is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
||||
$current_value = $this->version;
|
||||
}
|
||||
|
||||
return $current_value;
|
||||
}
|
||||
}
|
||||
|
||||
return new ET_Builder_Module_Settings_Migration_UIImprovement();
|
Reference in New Issue
Block a user