/home/techb158/public_html/wp-content/plugins/kirki/includes/Manager
Edit: /home/techb158/public_html/wp-content/plugins/kirki/includes/Manager/PluginLoadedEvents.php (4110B)
$block ) {
// Check if the block has a 'name' key
if ( isset( $block['name'] ) ) {
// If block name is one of the wrapper types, change it to 'items'
if (
$block['name'] === 'collection-wrapper' ||
$block['name'] === 'terms' ||
$block['name'] === 'users' ||
$block['name'] === 'comments' ||
$block['name'] === 'menus'
) {
$blocks[ $id ]['name'] = 'items';
}
// If block name is one of the item types, change it to 'item'
if (
$block['name'] === 'collection-item' ||
$block['name'] === 'term-item' ||
$block['name'] === 'user-item' ||
$block['name'] === 'comment-item' ||
$block['name'] === 'menu-item'
) {
$blocks[ $id ]['name'] = 'item';
}
}
}
// Return the updated blocks
return $blocks;
}
// This function goes through all stored page meta data and updates block names
public function alter_collection_names() {
// Get all meta data where key is matched (kirki meta key)
$data = Page::get_all_data_by_kirki_meta_key();
foreach ( $data as $key => $value ) {
$post_id = $value['post_id']; // ID of the post
$meta_key = $value['meta_key']; // Meta key name
$meta_value = $value['meta_value']; // Serialized meta value
$meta_value = unserialize( $meta_value, ['allowed_classes' => false] ); // Convert serialized data to array
// If the meta value has a 'blocks' key, handle it as a full page data
if ( isset( $meta_value['blocks'] ) ) {
$blocks = $meta_value['blocks']; // Get the blocks array
$updated_blocks = $this->update_block( $blocks ); // Update block names
$meta_value['blocks'] = $updated_blocks; // Set updated blocks back
update_post_meta( $post_id, $meta_key, $meta_value ); // Save back to DB
} else {
// If no 'blocks' key, treat entire value as blocks array
$blocks = $meta_value;
$updated_blocks = $this->update_block( $blocks ); // Update block names
$meta_value = $updated_blocks;
update_post_meta( $post_id, $meta_key, $meta_value ); // Save updated value
}
}
}
/**
* Check version whether db needs update or not
*
* @return void
*/
public function do_migration_related_task() {
$version_in_db = HelperFunctions::get_kirki_version_from_db();
$needs_rewrite_flush = empty( $version_in_db ) || version_compare( $version_in_db, KIRKI_VERSION, '<' );
PluginActiveEvents::update_rbac();
$db_altered_in3 = '2.1.0';
if ( empty( $version_in_db ) || version_compare( $version_in_db, $db_altered_in3, '<' ) ) {
$this->alter_collection_names();
}
$db_altered_in6 = '2.3.0';
if ( empty( $version_in_db ) || version_compare( $version_in_db, $db_altered_in6, '<' ) ) {
PluginActiveEvents::create_custom_tables();
}
$db_altered_in6 = '2.4.0';
if ( empty( $version_in_db ) || version_compare( $version_in_db, $db_altered_in6, '<' ) ) {
PluginActiveEvents::add_post_field_in_collaboaration_connected_table();
}
HelperFunctions::set_kirki_version_in_db();
if ( $needs_rewrite_flush ) {
flush_rewrite_rules( false );
}
}
}