Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
pum_theme_migration_2( PUM_Model_Theme $theme )

Upgrade popup data to model v3.


Description Description


Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808

Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813

Parameters Parameters

$theme

(Required)


Top ↑

Source Source

File: includes/functions/themes/migrations.php

function pum_theme_migration_2( &$theme ) {

	$changed     = false;
	$delete_meta = array();

	$settings = $theme->get_settings();

	$old_meta_elements = array(
		'overlay',
		'container',
		'title',
		'content',
		'close',
	);

	foreach ( $old_meta_elements as $element ) {
		$meta_key = 'popup_theme_' . $element;

		/**
		 * Migrate popup_theme_overlay meta data.
		 */
		$element_data = $theme->get_meta( $meta_key );
		if ( ! empty( $element_data ) && is_array( $element_data ) ) {
			$keys = $theme->remapped_meta_settings_keys( $element );

			// Foreach old key, save the value under popup settings for the new key.
			foreach ( $keys as $old_key => $new_key ) {
				if ( isset( $element_data[ $old_key ] ) ) {
					$settings[ $new_key ] = $element_data[ $old_key ];
					$changed              = true;
					unset( $element_data[ $old_key ] );
				}
			}

			if ( empty( $element_data ) ) {
				$delete_meta[] = $meta_key;
			} else {
				// Update the saved popup display data with any remaining keys from extensions.
				$theme->update_meta( $meta_key, $element_data );
			}
		}

	}

	/**
	 * Save only if something changed.
	 */
	if ( $changed ) {
		$theme->update_meta( 'popup_theme_settings', $settings );
	}

	/**
	 * Clean up automatically.
	 */
	pum_cleanup_post_meta_keys( $theme->ID, $delete_meta );
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.8.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.