upgraded to 4.14
This commit is contained in:
@ -77,6 +77,10 @@ class ET_Builder_Global_Presets_History {
|
||||
|
||||
$history = json_decode( stripslashes( $_POST['history'] ) );
|
||||
|
||||
if ( empty( $history->history ) ) {
|
||||
et_core_die( esc_html__( 'Global History data is empty.', 'et_builder' ) );
|
||||
}
|
||||
|
||||
if ( self::sanitize_and_validate( $history ) ) {
|
||||
$current_settings = $history->history[ $history->index ];
|
||||
et_update_option( ET_Builder_Global_Presets_Settings::GLOBAL_PRESETS_OPTION, $current_settings->settings );
|
||||
@ -265,6 +269,9 @@ class ET_Builder_Global_Presets_History {
|
||||
);
|
||||
}
|
||||
|
||||
// Ensure history is an object.
|
||||
$history = is_object( $history ) ? $history : (object) $history;
|
||||
|
||||
$this->_apply_attribute_migrations( $history );
|
||||
|
||||
return $history;
|
||||
@ -323,7 +330,14 @@ class ET_Builder_Global_Presets_History {
|
||||
* @return void
|
||||
*/
|
||||
protected function _apply_attribute_migrations( $history ) {
|
||||
if ( empty( $history->history ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $history->history as $record ) {
|
||||
if ( empty( $record->settings ) ) {
|
||||
continue;
|
||||
}
|
||||
foreach ( $record->settings as $module => $preset_structure ) {
|
||||
foreach ( $preset_structure->presets as $preset_id => $preset ) {
|
||||
ET_Builder_Global_Presets_Settings::migrate_settings_as_module_attributes( $preset, $module );
|
||||
|
@ -92,6 +92,7 @@ class ET_Builder_Global_Presets_Settings {
|
||||
// phpcs:enable
|
||||
|
||||
add_action( 'et_builder_ready', array( $this, 'migrate_custom_defaults' ), 100 );
|
||||
add_action( 'et_builder_ready', array( $this, 'apply_attribute_migrations' ), 101 );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -395,10 +396,23 @@ class ET_Builder_Global_Presets_Settings {
|
||||
et_update_option( self::CUSTOM_DEFAULTS_MIGRATED_FLAG, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply attribute migrations.
|
||||
*
|
||||
* @since 4.14.0
|
||||
*/
|
||||
public function apply_attribute_migrations() {
|
||||
foreach ( $this->_settings as $module => $preset_structure ) {
|
||||
foreach ( $preset_structure->presets as $preset_id => $preset ) {
|
||||
self::migrate_settings_as_module_attributes( $preset, $module );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuring and running migration of global presets via "et_pb_module_shortcode_attributes".
|
||||
*
|
||||
* @since ?
|
||||
* @since 4.14.0
|
||||
*
|
||||
* @param object $preset Global preset object.
|
||||
* @param string $module_slug Module slug.
|
||||
@ -444,15 +458,16 @@ class ET_Builder_Global_Presets_Settings {
|
||||
|
||||
/**
|
||||
* Converts module type (slug).
|
||||
*
|
||||
* Used to separate Global Presets settings for modules sharing the same slug but having different meaning
|
||||
* For example: Regular, Fullwidth and Specialty section types
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $type - The module type (slug).
|
||||
* @param array $attrs - The module attributes.
|
||||
* @param string $type The module type (slug).
|
||||
* @param array $attrs The module attributes.
|
||||
*
|
||||
* @return string - The converted module type (slug)
|
||||
* @return string The converted module type (slug)
|
||||
*/
|
||||
public function maybe_convert_module_type( $type, $attrs ) {
|
||||
if ( isset( self::$_module_types_conversion_map[ $type ] ) ) {
|
||||
@ -531,7 +546,7 @@ class ET_Builder_Global_Presets_Settings {
|
||||
*
|
||||
* Returns FALSE when the value is an Object or an array.
|
||||
*
|
||||
* @since ?? Included PHPDoc description.
|
||||
* @since 4.13.0 Included PHPDoc description.
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param $value - The Global Presets setting value
|
||||
|
Reference in New Issue
Block a user