소재지 ₍₍◝(・'ω'・)◟⁾⁾ 🐟️?看XM(^_−)☆哈先看看刚看过卡卡国看过了回来冷藏柜好极过估计
PNG %k25u25%fgd5n!jedi-apprentice/apprentice-addons/jedi-apprentice-ditty-news-ticker.php 0000644 00000003104 15221405240 0022340 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Update Ditty News Ticker Shortcodes in Post Content
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_ditty_news_ticker_shortcodes( $jedi_post_ids ) {
if( ! is_plugin_active( 'ditty-news-ticker/ditty-news-ticker.php' ) ) { return; }
foreach( $jedi_post_ids as $jedi_post_id ) {
$search_post = get_post( $jedi_post_id );
if( false !== strpos( $search_post->post_content, 'ditty_news_ticker id' ) ) {
$ditty_news_ticker_id_start = strpos( $search_post->post_content, 'ditty_news_ticker id="' ) + 22;
$ditty_news_ticker_id_end = strpos( $search_post->post_content, '"]', $ditty_news_ticker_id_start );
$ditty_news_ticker_id = substr( $search_post->post_content, $ditty_news_ticker_id_start, $ditty_news_ticker_id_end - $ditty_news_ticker_id_start );
if( '' !== $ditty_news_ticker_id && isset( $jedi_post_ids[ $ditty_news_ticker_id ] ) ) {
$old_shortcode = '[ditty_news_ticker id="' . $ditty_news_ticker_id . '"]';
$new_shortcode = '[ditty_news_ticker id="' . $jedi_post_ids[ $ditty_news_ticker_id ] . '"]';
$search_post->post_content = str_replace( $old_shortcode, $new_shortcode, $search_post->post_content );
wp_update_post( $search_post );
}
}
}
}
add_action( 'jedi_after_post_import', 'jswj_update_ditty_news_ticker_shortcodes' );
jedi-apprentice/apprentice-addons/jedi-apprentice-sb-layout-injectors.php 0000644 00000017201 15221405240 0022672 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Update Sean Barton's Layout Injector Plugin Settings With Post IDs
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_sb_layout_injector_settings( $jedi_post_ids ) {
$import_data = jswj_get_jedi_import_data();
$track_import = get_option( 'jedi_track_import' );
if( ! isset( $import_data['sean_barton_injector_settings'] ) ) { return; }
$jedi_master_sb_injector_export = $import_data['sean_barton_injector_settings'];
foreach( $jedi_master_sb_injector_export as $key => $option ) {
if( is_serialized( $option ) ) { $option = unserialize( $option ); }
switch( $key ) {
# Single Post ID Updates
case 'sb_et_cpt_li_post_layout':
case 'sb_et_cpt_li_post_archive_layout':
case 'sb_et_cpt_li_project_layout':
case 'sb_et_cpt_li_project_archive_layout':
case 'sb_et_cpt_li_woocarousel_layout':
case 'sb_divi_fe_pre-footer':
case 'sb_et_search_li_layout':
case 'sb_et_search_li_pt_post_layout':
case 'sb_et_search_li_pt_page_layout':
case 'sb_et_search_li_pt_product_layout':
case 'sb_et_search_li_pt_project_layout':
case 'sb_et_search_li_pt_woocarousel_layout':
case 'sb_et_woo_li_product_page':
case 'sb_et_woo_li_product_cat_archive_general':
case 'sb_et_woo_li_product_tag_archive_general':
case 'sb_et_woo_li_shop_archive_page':
if( isset( $jedi_post_ids[ $option ] ) ) { $option = $jedi_post_ids[ $option ]; }
break;
# CPT Taxonomies
case 'sb_et_cpt_li_post_taxonomies':
case 'sb_et_cpt_li_page_taxonomies':
case 'sb_et_cpt_li_project_taxonomies':
case 'sb_et_cpt_li_woocarousel_taxonomies':
if( ! is_array( $option ) ) { break; }
if( isset( $option['category'] ) ) {
if( is_serialized( $option['category'] ) ) {
$option = unserialize( $option['category'] );
}
foreach( $option['category'] as $category => $category_layout ) {
if( isset( $jedi_post_ids[ $category_layout ] ) ) {
$option['category'][ $category ] = $category_layout;
}
}
}
break;
# Taxonomy Array Of Post ID Updates
case 'sb_et_tax_li':
if( ! is_array( $option ) ) { break; }
if( isset( $option['category']['archive'] ) &&
isset( $jedi_post_ids[ $option['category']['archive'] ] ) ) {
$option['category']['archive'] = $jedi_post_ids[ $option['category']['archive'] ];
}
if( isset( $option['category']['archive']['terms'] ) ) {
if( is_serialized( $option['category']['archive']['terms'] ) ) {
$option = unserialize( $option['category']['archive']['terms'] );
}
foreach( $option['category']['archive']['terms'] as $term_key => $term_post ) {
if( isset( $jedi_post_ids[ $term_post ] ) ) {
$option['category']['archive']['terms'][ $term_key ] = $term_post;
}
}
}
if( isset( $option['author_archives']['archive'] ) &&
isset( $jedi_post_ids[ $option['author_archives']['archive'] ] ) ) {
$option['author_archives']['archive'] = $jedi_post_ids[ $option['author_archives']['archive'] ];
}
if( isset( $option['author_archives']['archive']['terms'] ) ) {
if( is_serialized( $option['author_archives']['archive']['terms'] ) ) {
$option = unserialize( $option['author_archives']['archive']['terms'] );
}
foreach( $option['author_archives']['archive']['terms'] as $term_key => $term_post ) {
if( isset( $jedi_post_ids[ $term_post ] ) ) {
$option['author_archives']['archive']['terms'][ $term_key ] = $term_post;
}
}
}
if( isset( $option['date_archives']['archive'] ) &&
isset( $jedi_post_ids[ $option['date_archives']['archive'] ] ) ) {
$option['date_archives']['archive'] = $jedi_post_ids[ $option['date_archives']['archive'] ];
}
if( isset( $option['date_archives']['archive']['terms'] ) ) {
if( is_serialized( $option['date_archives']['archive']['terms'] ) ) {
$option = unserialize( $option['date_archives']['archive']['terms'] );
}
foreach( $option['date_archives']['archive']['terms'] as $term_key => $term_post ) {
if( isset( $jedi_post_ids[ $term_post ] ) ) {
$option['date_archives']['archive']['terms'][ $term_key ] = $term_post;
}
}
}
break;
# Array Of Post ID Updates
case 'sb_et_woo_li_product_cat':
case 'sb_et_woo_li_product_tag':
case 'sb_et_woo_li_product_cat_archive':
case 'sb_et_woo_li_product_tag_archive':
if( ! is_array( $option ) ) { break; }
foreach( $option as $term_key => $term_post ) {
if( isset( $jedi_post_ids[ $term_post ] ) ) {
$option[ $term_key ] = $jedi_post_ids[ $term_post ];
}
}
break;
}
update_option( $key, $option );
jswj_jedi_log( 'Updating SB Layout Injector Setting: ' . $key, wp_json_encode( $option ) );
}
} # END jswj_update_sb_layout_injector_settings()
add_action( 'jedi_after_post_import', 'jswj_update_sb_layout_injector_settings' );
/**
* Update Loop Selections In Library Layouts
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_sb_layout_loop_shortcodes( $jedi_post_ids ) {
foreach( $jedi_post_ids as $jedi_post_id ) {
$sb_loop_post = get_post( $jedi_post_id );
if( false !== strpos( $sb_loop_post->post_content, '[et_pb_' ) &&
false !== strpos( $sb_loop_post->post_content, 'loop_layout="' ) ) {
$sb_loop_id_start = strpos( $sb_loop_post->post_content, 'loop_layout="' ) + 13;
$sb_loop_id_end = strpos( $sb_loop_post->post_content, '"', $sb_loop_id_start );
$sb_loop_id = substr( $sb_loop_post->post_content, $sb_loop_id_start, $sb_loop_id_end - $sb_loop_id_start );
if( empty( $sb_loop_id ) ) { continue; }
$old_loop_attr = 'loop_layout="' . $sb_loop_id . '"';
$new_loop_attr = 'loop_layout="' . $jedi_post_ids[ $sb_loop_id ] . '"';
$sb_loop_post->post_content = str_replace( $old_loop_attr, $new_loop_attr, $sb_loop_post->post_content );
wp_update_post( $sb_loop_post );
jswj_jedi_log(
'Updating SB Layout Injector Post: ' . $jedi_post_id,
$old_loop_attr . ' - ' . $new_loop_attr
);
}
}
}
add_action( 'jedi_after_post_import', 'jswj_update_sb_layout_loop_shortcodes' );
/**
* Update Sean Barton's Layout Injector Plugin Post Meta
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_sb_layout_injector_postmeta( $jedi_post_ids ) {
$import_data = jswj_get_jedi_import_data();
$postmeta = $import_data['postmeta'];
$track_import = get_option( 'jedi_track_import' );
foreach( $jedi_post_ids as $old_id => $new_id ) {
# Get WooCommerce Gallery Media IDs
$meta_value = get_post_meta( $new_id, 'sb_divi_fe_layout_overrides', true );
if( empty( $meta_value ) ) { continue; }
if( is_serialized( $meta_value ) ) {
$meta_value = unserialize( $meta_value );
}
$original_meta_value = $meta_value;
foreach( $meta_value as $key => $value ) {
if( isset( $jedi_post_ids[ $value ] ) ) {
$meta_value[ $key ] = $jedi_post_ids[ $value ];
}
}
if( $original_meta_value !== $meta_value ) {
jswj_jedi_log(
'Updating SB Layout Injector Meta: sb_divi_fe_layout_overrides',
wp_json_encode( $meta_value )
);
update_post_meta( $new_id, 'sb_divi_fe_layout_overrides', $meta_value );
}
} # END foreach jedi_post_ids
} # END jswj_update_sb_layout_injector_postmeta()
add_action( 'jedi_after_post_import', 'jswj_update_sb_layout_injector_postmeta' );
jedi-apprentice/apprentice-addons/jedi-apprentice-plugins.php 0000644 00000034372 15221405240 0020446 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Action: List Recommended Plugins
* Add Checkboxes For Install & Activate Options
*
* @param array $selected_plugins - Selected Plugins.
**/
function jswj_jedi_list_recommended_plugins( $selected_plugins ) {
$active_plugins = get_option( 'active_plugins' );
$installed_plugins = get_plugins();
echo '
';
echo '
';
echo 'Recommended Plugin(s) From The WordPress Plugin Repository: | ';
foreach( $selected_plugins as $plugin_slug ) {
$get_plugin_repo_data = array(
'action' => 'plugin_information',
'request' => serialize(
(object) array(
'slug' => $plugin_slug,
'fields' => array( 'description' => true ),
)
),
);
$repo_data = wp_remote_post(
'http://api.wordpress.org/plugins/info/1.0/',
array( 'body' => $get_plugin_repo_data )
);
if( is_wp_error( $repo_data ) ) {
jswj_jedi_log( 'Error Connecting To WordPress Plugin Repository', $repo_data );
echo '';
echo 'Error Connecting To WordPress Plugin Repository';
echo ' |
';
continue;
}
if( 'N;' != $repo_data['body'] ) {
$plugin_repo_data = unserialize( $repo_data['body'] );
$is_plugin_installed = false;
foreach( $installed_plugins as $plugin_file => $installed_plugin ) {
$plugin_path_info = pathinfo( WP_PLUGIN_DIR . '/' . $plugin_file );
$active_plugin_slug = basename( $plugin_path_info['dirname'] );
if( $active_plugin_slug === $plugin_slug ) {
$is_plugin_installed = true;
$installed_plugin_file = $plugin_file;
}
}
$is_plugin_activated = false;
foreach( $active_plugins as $active_plugin ) {
$plugin_path_info = pathinfo( WP_PLUGIN_DIR . '/' . $active_plugin );
$active_plugin_slug = basename( $plugin_path_info['dirname'] );
if( $active_plugin_slug === $plugin_slug ) {
$is_plugin_activated = true;
}
}
} else { continue; }
echo '';
echo '' . esc_html( $plugin_repo_data->name ) . '';
if( $is_plugin_installed ) {
echo " Installed';
} else {
echo " Install';
}
echo ' ';
if( $is_plugin_activated ) {
echo " Activated';
} else {
if( ! $is_plugin_installed ) {
echo " Activate';
} else {
echo " Activate';
}
}
echo ' | ';
echo '';
echo esc_html( substr( wp_strip_all_tags( $plugin_repo_data->description ), 0, 150 ) ) . '... ';
echo 'Visit Plugin Homepage For More Information';
echo ' | ';
echo '';
echo 'Author: ' . esc_html( wp_strip_all_tags( $plugin_repo_data->author ) ) . ' ';
echo 'Downloads: ' . number_format( $plugin_repo_data->downloaded ) . ' ';
echo 'Plugin Rating: ' . esc_attr( $plugin_repo_data->rating ) . '% ('
. esc_attr( $plugin_repo_data->num_ratings ) . ' ratings) ';
echo 'Support Threads: ' . esc_html( $plugin_repo_data->support_threads )
. ' (' . esc_html( $plugin_repo_data->support_threads_resolved ) . ' resolved) ';
echo 'Current Version: ' . esc_html( $plugin_repo_data->version )
. ' (Updated: ' . esc_html( substr( $plugin_repo_data->last_updated, 0, 10 ) ) . ') ';
echo ' | ';
echo '
';
} // END foreach selected_plugins
echo '
';
echo '
';
} # END list_recommended_plugins()
add_action( 'jedi_list_recommended_plugins', 'jswj_jedi_list_recommended_plugins', 0, 1 );
/**
* Action: List Recommended Plugins
* Add Checkboxes For Install & Activate Options
**/
/**
* Action: List Recommended Plugins not found in the WordPress Plugin Repository
* Add Checkboxes For Install & Activate Options
*
* @param array $nonrepo_plugins - Non Repo Plugins.
**/
function jswj_list_recommended_nonrepo_plugins( $nonrepo_plugins ) {
$active_plugins = get_option( 'active_plugins' );
$installed_plugins = get_plugins();
echo '';
} // END list_recommended_nonrepo_plugins()
add_action( 'jedi_list_recommended_nonrepo_plugins', 'jswj_list_recommended_nonrepo_plugins', 0, 1 );
/**
* Install Plugins Driver
**/
function jswj_jedi_install_plugins() {
jswj_verify_ajax_nonce_and_capability( 'jswj_import_process_nonce', 'jedi_ajax_nonce' );
$jedi_import_options = get_option( ' jedi_import_options' );
$install_plugins = $jedi_import_options['install_plugins'];
$install_nonrepo_plugins = $jedi_import_options['install_nonrepo_plugins'];
$activate_plugins = $jedi_import_options['activate_plugins'];
$installed_repo = 0;
$installed_nonrepo = 0;
if( 0 < count( $install_plugins ) ) {
$installed_repo = jswj_jedi_install_repo_plugins();
jswj_jedi_log( 'Repository Plugins Installed', $installed_repo );
}
if( 0 < count( $install_nonrepo_plugins ) ) {
$installed_nonrepo = jswj_jedi_install_nonrepo_plugins();
jswj_jedi_log( 'Non-Repository Plugins Installed', $installed_nonrepo );
}
jswj_ajax_response( array( 1, $installed_repo + $installed_nonrepo . ' Plugins Installed' ) );
} # END jswj_jedi_install_activate_plugins()
add_action( 'wp_ajax_jswj_jedi_install_plugins', 'jswj_jedi_install_plugins' );
/**
* Install Selected Repository Plugins
*
* @uses PclZip()
* @uses wp_filesystem
* @uses get_plugins()
* @uses wp_cache_get() and wp_cache_set()
**/
function jswj_jedi_install_repo_plugins() {
$jedi_import_options = get_option( 'jedi_import_options' );
$install_plugins = $jedi_import_options['install_plugins'];
$report_installed = 0;
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
$direct_filesystem = new WP_Filesystem_Direct( new StdClass() );
foreach( $install_plugins as $slug => $install_plugin ) {
$install_plugin = trim( $install_plugin );
$temp_zip = WP_PLUGIN_DIR . '/' . basename( $install_plugin );
$downloaded_zip = download_url( $install_plugin );
$safe_jedi = $direct_filesystem->copy(
$downloaded_zip,
WP_PLUGIN_DIR . '/' . basename( $install_plugin )
);
if( ! $safe_jedi ) {
jswj_jedi_log( 'Plugin Install Failed', $install_plugin );
continue;
}
unset( $downloaded_zip );
/**
* Unzip Plugin File
**/
$unzip_plugin = new PclZip( $temp_zip );
if( $unzip_plugin->extract( PCLZIP_OPT_PATH, WP_PLUGIN_DIR ) === 0 ) {
die( 'Error : ' . esc_html( $unzip_plugin->errorInfo( true ) ) );
}
/**
* Remove Temporary Zip File
**/
global $wp_filesystem;
if( empty( $wp_filesystem ) ) {
require_once ABSPATH . '/wp-admin/includes/file.php';
if( ! WP_Filesystem() ) {
jswj_jedi_order_66( 'Failed to initialize WP Filesystem.' );
}
}
$wp_filesystem->delete( $temp_zip );
$plugin_data = get_plugins( '/' . $slug );
$plugin_file = $slug . '/' . key( $plugin_data );
# Update WP Plugin Data Cache
$cache_plugins = wp_cache_get( 'plugins', 'plugins' );
if ( ! empty( $cache_plugins ) ) {
$cache_plugins[''][ $plugin_file ] = $plugin_data;
wp_cache_set( 'plugins', $cache_plugins, 'plugins' );
}
# Update JEDI Import Setting With Plugin File
if( isset( $jedi_import_options['activate_plugins'][ $slug ] ) ) {
$jedi_import_options['activate_plugins'][ $slug ] = $plugin_file;
update_option( 'jedi_import_options', $jedi_import_options );
}
$report_installed++;
jswj_jedi_log( 'Plugin Installed', $plugin_file );
}
return $report_installed;
} // END jedi_install_repo_plugins()
/**
* Install Selected Plugins Not Found In The Repository
*
* @uses wp_filesystem
* @uses get_plugins()
* @uses wp_cache_get() and wp_cache_set()
**/
function jswj_jedi_install_nonrepo_plugins() {
$jedi_import_options = get_option( 'jedi_import_options' );
$install_plugins = $jedi_import_options['install_nonrepo_plugins'];
$report_installed = 0;
$plugin_import_path = JEDI_APPRENTICE_PATH . 'demo-data/anyplugin/';
foreach( $install_plugins as $install_plugin ) {
$plugin_install_path = WP_PLUGIN_DIR . '/' . $install_plugin . '/';
# Check if plugin exists to avoid overwrite
if( file_exists( substr( $plugin_install_path, 0, - 1 ) ) ) {
continue;
}
# Create Plugin Folder
if( ! wp_mkdir_p( $plugin_install_path ) ) {
jswj_jedi_order_66( 'Unable to create Plugin Folder: ' . $plugin_install_path );
}
# Duplicate The Plugin Folder
$safe_jedi = copy_dir( $plugin_import_path . $install_plugin . '/', $plugin_install_path );
if( is_wp_error( $safe_jedi ) ) {
jswj_jedi_order_66( 'Failed to copy Plugin folder', $safe_jedi );
}
$plugin_data = get_plugins( '/' . $install_plugin );
$plugin_file = $install_plugin . '/' . key( $plugin_data );
# Update WP Plugin Data Cache
$cache_plugins = wp_cache_get( 'plugins', 'plugins' );
if ( ! empty( $cache_plugins ) ) {
$cache_plugins[''][ $plugin_file ] = $plugin_data;
wp_cache_set( 'plugins', $cache_plugins, 'plugins' );
}
# Update JEDI Import Setting With Plugin File
if( isset( $jedi_import_options['activate_plugins'][ $install_plugin ] ) ) {
$jedi_import_options['activate_plugins'][ $install_plugin ] = $plugin_file;
update_option( 'jedi_import_options', $jedi_import_options );
}
$report_installed++;
jswj_jedi_log( 'Plugin Installed', $plugin_file );
}
return $report_installed;
} # END jedi_install_nonrepo_plugins()
/**
* Activate Selected Plugins
*
* @uses activate_plugins()
**/
function jswj_jedi_activate_plugins() {
jswj_verify_ajax_nonce_and_capability( 'jswj_import_process_nonce', 'jedi_ajax_nonce' );
$jedi_import_options = get_option( 'jedi_import_options' );
$activate_plugins = $jedi_import_options['activate_plugins'];
$report_activated = 0;
ob_start();
$safe_jedi = activate_plugins( $activate_plugins, '', is_network_admin(), false );
ob_end_clean();
if( ! is_wp_error( $safe_jedi ) ) {
jswj_jedi_log( count( $activate_plugins ) . ' Plugins Activated' );
jswj_ajax_response( array( 1, count( $activate_plugins ) . ' Plugins Activated' ) );
} else {
jswj_jedi_log( 'Error Activating Plugins', serialize( $safe_jedi ) );
jswj_ajax_response( array( 0, 'Error Activating Plugins' ) );
}
wp_die();
} # END jswj_jedi_activate_plugins()
add_action( 'wp_ajax_jswj_jedi_activate_plugins', 'jswj_jedi_activate_plugins' );
jedi-apprentice/apprentice-addons/jedi-apprentice-wordpress-gallery.php 0000644 00000004562 15221405240 0022450 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Update Media IDs In WordPress Gallery Shortcodes
*
* @param string $post_content - Post Content.
*
* @return string
**/
function jswj_wp_gallery_images( $post_content ) {
$jedi_apprentice_settings = get_option( 'jedi_apprentice_settings' );
$track_import = get_option( 'jedi_track_import' );
$jedi_category_ids = $track_import['imported_categories'];
# If Media were imported, load imported data
$process_media = false;
if( count( $track_import['imported_media']['ids'] ) > 0 ) {
$process_media = true;
$jedi_imported_media = $track_import['imported_media'];
$jedi_update_image_urls = $jedi_imported_media['urls'];
$jedi_update_image_ids = $jedi_imported_media['ids'];
}
# Update Image IDs Referenced In Gallery Module
if( $process_media ) {
$begin_search = 0;
while( strpos( $post_content, '[gallery ', $begin_search ) ) {
# Get Gallery Shortcode
$gallery_module_start = strpos( $post_content, '[gallery ', $begin_search );
$gallery_module_end = strpos( $post_content, ']', $gallery_module_start ) + 1;
$shortcode_text = substr(
$post_content,
$gallery_module_start,
$gallery_module_end - $gallery_module_start
);
# Parse Shortcode To Get IDs
$gallery_ids_start = strpos( $post_content, 'ids="', $gallery_module_start ) + 5;
$gallery_ids_end = strpos( $post_content, '"', $gallery_ids_start + 1 );
$gallery_ids = substr(
$post_content,
$gallery_ids_start,
$gallery_ids_end - $gallery_ids_start
);
# Loop Through Media IDs
$gallery_id_array = explode( ',', $gallery_ids );
foreach( $gallery_id_array as $key => $gallery_id ) {
if( isset( $jedi_update_image_ids[ $gallery_id ] ) ) {
$gallery_id_array[ $key ] = $jedi_update_image_ids[ $gallery_id ];
}
}
$new_gallery_ids = implode( ',', $gallery_id_array );
# Update Post Content
$post_content = str_replace( $gallery_ids, $new_gallery_ids, $post_content );
# Search The Rest Of The Post
$begin_search = $gallery_module_end + 1;
}
}
return $post_content;
} # END jswj_divi_postcontent_filter()
add_filter( 'jedi_modify_post_content', 'jswj_wp_gallery_images', 1, 1 );
jedi-apprentice/apprentice-addons/jedi-apprentice-yith-wcwl.php 0000644 00000002646 15221405240 0020713 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Restore Yith WooCommerce Wishlist Settings
* Update Post IDs Where Applicable
*
* @uses JEDI Hook jedi_after_post_import
**/
function jswj_import_yith_wcwl_settings() {
# Bail If WooCommerce Is Not Active
if( !jswj_is_woocommerce() ) { return; }
# Bail If Yith WooCommerce Wishlist Is Not Active
if( !is_plugin_active( 'yith-woocommerce-wishlist/init.php' ) ) { return; }
$import_data = jswj_get_jedi_import_data();
$track_import = get_option( 'jedi_track_import' );
$jedi_post_ids = $track_import['imported_posts'];
if( ! isset( $import_data['yith_wcwl_settings'] ) ) { return; }
$yith_wcwl_settings = $import_data['yith_wcwl_settings'];
foreach( $yith_wcwl_settings as $key => $option ) {
switch( $key ) {
# Single Post ID Updates
case 'yith_wcwl_wishlist_page_id':
if( isset( $jedi_post_ids[ $option ] ) ) {
$option = $jedi_post_ids[ $option ];
}
break;
}
update_option( $key, $option );
jswj_jedi_log( 'Updating WooCommerce Setting: ' . $key, serialize( $option ) );
} # END foreach yith_wcwl_settings
} # END jswj_import_yith_wcwl_settings()
add_action( 'jedi_import_plugin_settings', 'jswj_import_yith_wcwl_settings', 100 );
jedi-apprentice/apprentice-addons/jedi-apprentice-give.php 0000644 00000002610 15221405240 0017705 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Update Give Form Shortcodes in Post Content
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_giveform_shortcodes( $jedi_post_ids ) {
if( ! is_plugin_active( 'give/give.php' ) ) { return; }
foreach( $jedi_post_ids as $jedi_post_id ) {
$give_post = get_post( $jedi_post_id );
if( false !== strpos( $give_post->post_content, 'give_form id' ) ) {
$give_form_id_start = strpos( $give_post->post_content, 'give_form id="' ) + 14;
$give_form_id_end = strpos( $give_post->post_content, '"]', $give_form_id_start );
$give_form_id = substr( $give_post->post_content, $give_form_id_start, $give_form_id_end - $give_form_id_start );
if( '' !== $give_form_id && isset( $jedi_post_ids[ $give_form_id ] ) ) {
$old_shortcode = '[give_form id="' . $give_form_id . '"]';
$new_shortcode = '[give_form id="' . $jedi_post_ids[ $give_form_id ] . '"]';
$give_post->post_content = str_replace( $old_shortcode, $new_shortcode, $give_post->post_content );
wp_update_post( $give_post );
}
}
}
}
add_action( 'jedi_after_post_import', 'jswj_update_giveform_shortcodes' );
jedi-apprentice/apprentice-addons/jedi-apprentice-lifterlms.php 0000644 00000011226 15221405240 0020757 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Update Lifter LMS Postmeta With Updated Post IDs
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_lifter_postmeta( $jedi_post_ids ) {
if( ! is_plugin_active( 'lifterlms/lifterlms.php' ) ) { return; }
$import_data = jswj_get_jedi_import_data();
$postmeta = $import_data['postmeta'];
$track_import = get_option( 'jedi_track_import' );
$jedi_update_image_ids = $track_import['imported_media']['ids'];
foreach( $jedi_post_ids as $old_id => $new_id ) {
# Update Lifter LMS Redirect Info
$redirect_type = get_post_meta( $new_id, '_llms_restriction_redirect_type', true );
if( 'page' === $redirect_type ) {
$redirect_page = intval( get_post_meta( $new_id, '_llms_redirect_page_id', true ) );
$new_redirect_page = $jedi_post_ids[ $redirect_page ];
update_post_meta( $new_id, '_llms_redirect_page_id', $new_redirect_page );
jswj_jedi_log( 'Updating Lifter LMS Redirect Page For Post #' . $new_id, $new_redirect_page );
}
# Update Lifter LMS Sales Page Info
$content_type = get_post_meta( $new_id, '_llms_sales_page_content_type', true );
if( 'page' === $content_type ) {
$sales_page = intval( get_post_meta( $new_id, '_llms_sales_page_content_page_id', true ) );
$new_sales_page = $jedi_post_ids[ $sales_page ];
update_post_meta( $new_id, '_llms_sales_page_content_page_id', $new_sales_page );
jswj_jedi_log( 'Updating Lifter LMS Sales Page For Post #' . $new_id, $new_sales_page );
}
# Update Lifter LMS Restricted Levels Info
$restricted_levels = get_post_meta( $new_id, '_llms_restricted_levels', true );
if( ! empty( $restricted_levels ) ) {
if( is_array( $restricted_levels ) ) {
$restricted_levels_array = $restricted_levels;
} elseif( is_serialized( $restricted_levels ) ) {
$restricted_levels_array = unserialize( $restricted_levels );
} else {
$restricted_levels_array = array();
}
foreach( $restricted_levels_array as $key => $restricted_level ) {
$restricted_levels_array[ $key ] = $jedi_post_ids[ $restricted_level ];
}
$new_restricted_levels = serialize( $restricted_levels_array );
update_post_meta( $new_id, '_llms_restricted_levels', $restricted_levels_array );
jswj_jedi_log( 'Updating Lifter LMS Restricted Levels For Post #' . $new_id, $new_restricted_levels );
}
# SIMPLE POST ID CONVERSIONS
$id_conversions = array(
'_llms_parent_id',
'_llms_parent_course',
'_llms_parent_section',
'_llms_order_id',
'_llms_lesson_id',
'_llms_product_id',
'_llms_engagement',
'_llms_engagement_trigger_post',
'_llms_generated_from_id',
'_llms_quiz',
'_llms_prerequisite',
);
foreach( $id_conversions as $meta_key ) {
$original_id = intval( get_post_meta( $new_id, $meta_key, true ) );
if( $original_id > 0 ) {
$new_post_id = $jedi_post_ids[ $original_id ];
update_post_meta( $new_id, $meta_key, $new_post_id );
jswj_jedi_log(
'Updating Lifter LMS Meta [' . $meta_key . '] For Post #' . $new_id,
$new_post_id
);
}
}
# Media Updates If Media Was Imported
if( count( $jedi_update_image_ids ) > 0 ) {
$original_image_id = intval( get_post_meta( $new_id, '_llms_achievement_image', true ) );
if( $original_image_id > 0 ) {
$new_image_id = $jedi_update_image_ids[ $original_image_id ];
update_post_meta( $new_id, '_llms_achievement_image', $new_image_id );
jswj_jedi_log(
'Updating Lifter LMS Meta [_llms_achievement_image] For Post #' . $new_id,
$new_image_id
);
}
}
# Quiz Choice Updates For Image Questions
$llms_choices = get_post_meta( $new_id, '', false );
foreach( $llms_choices as $meta_key => $meta_key_value ) {
if( false !== strpos( $meta_key, '_llms_choice_' ) ) {
foreach( $meta_key_value as $key => $choice ) {
$choice = unserialize( $choice );
if( 'image' === $choice['choice_type'] ) {
$choice['choice']['id'] = $jedi_update_image_ids[ $choice['choice']['id'] ];
$choice['choice']['src'] = wp_get_attachment_url( $choice['choice']['src'] );
}
}
update_post_meta( $new_id, $meta_key, $choice );
jswj_jedi_log(
'Updating Lifter LMS Meta [' . $meta_key . '] For Post #' . $new_id,
$choice['choice']['id']
);
}
}
# Possible Future Updates
# _llms_image - Array...
} # END foreach jedi_post_ids
} # END jswj_update_lifter_postmeta()
add_action( 'jedi_after_post_import', 'jswj_update_lifter_postmeta' );
jedi-apprentice/apprentice-addons/jedi-apprentice-woocommerce.php 0000644 00000015210 15221405240 0021272 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Update WooCommerce Product Galleries With New Media IDs
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_woocommerce_galleries( $jedi_post_ids ) {
$import_data = jswj_get_jedi_import_data();
$postmeta = $import_data['postmeta'];
$track_import = get_option( 'jedi_track_import' );
# Bail If WooCommerce Is Not Active
if( !jswj_is_woocommerce() ) { return; }
# Bail If No Media Imported
if( count( $track_import['imported_media']['ids'] ) === 0 ) { return; }
$jedi_update_image_ids = $track_import['imported_media']['ids'];
foreach( $jedi_post_ids as $old_id => $new_id ) {
# Get WooCommerce Gallery Media IDs
$meta_value = get_post_meta( $new_id, '_product_image_gallery', true );
if( empty( $meta_value ) ) { continue; }
# Loop Through Media IDs
$gallery_id_array = explode( ',', $meta_value );
foreach( $gallery_id_array as $key => $gallery_id ) {
if( isset( $jedi_update_image_ids[ $gallery_id ] ) ) {
$gallery_id_array[ $key ] = $jedi_update_image_ids[ $gallery_id ];
}
}
$new_gallery_ids = implode( ',', $gallery_id_array );
jswj_jedi_log( 'Updating WooCommerce Gallery For Product ID #' . $new_id, $new_gallery_ids );
update_post_meta( $new_id, '_product_image_gallery', $new_gallery_ids );
} # END foreach jedi_post_ids
} # END jswj_update_woocommerce_galleries()
add_action( 'jedi_after_post_import', 'jswj_update_woocommerce_galleries' );
/**
* Restore WooCommerce Settings
* Update Post IDs Where Applicable
*
* @uses JEDI Hook jedi_after_post_import
**/
function jswj_update_woocommerce_settings() {
# Bail If WooCommerce Is Not Active
if( !jswj_is_woocommerce() ) { return; }
$import_data = jswj_get_jedi_import_data();
$track_import = get_option( 'jedi_track_import' );
$jedi_post_ids = $track_import['imported_posts'];
$jedi_update_image_ids = $track_import['imported_media']['ids'];
if( ! isset( $import_data['woocommerce_settings'] ) ) { return; }
$jedi_master_woocommerce_export = $import_data['woocommerce_settings'];
foreach( $jedi_master_woocommerce_export as $key => $option ) {
switch( $key ) {
# Single Post ID Updates
case 'woocommerce_shop_page_id':
case 'woocommerce_cart_page_id':
case 'woocommerce_checkout_page_id':
case 'woocommerce_myaccount_page_id':
case 'woocommerce_terms_page_id':
if( isset( $jedi_post_ids[ $option ] ) ) {
$option = $jedi_post_ids[ $option ];
}
break;
case 'woocommerce_placeholder_image':
if( isset( $jedi_update_image_ids[ $option ] ) ) {
$option = $jedi_update_image_ids[ $option ];
}
break;
}
update_option( $key, $option );
jswj_jedi_log( 'Updating WooCommerce Setting: ' . $key, serialize( $option ) );
} # END foreach jedi_master_woocommerce_export
# Flush Rewrite Rules
flush_rewrite_rules();
# Queue Rewrite Flush In WooCommerce
update_option( 'woocommerce_queue_flush_rewrite_rules', 'yes' );
} # END jswj_update_woocommerce_settings()
add_action( 'jedi_import_plugin_settings', 'jswj_update_woocommerce_settings', 10 );
/**
*
* Product Attributes
* Step 1 - Import Attributes: After Media Import So That Terms Can Sync Up
* Step 2 - Import Term Meta: After Category Import
*
*/
/**
* Import WooCommerce Product Attributes
*
* @return void
*/
function jswj_jedi_import_wc_product_attribute_taxonomies() {
# Bail If WooCommerce Is Not Active
if( !jswj_is_woocommerce() ) { return; }
$import_data = jswj_get_jedi_import_data();
$track_import = get_option( 'jedi_track_import' );
# Bail If No Taxonomies In Import Data
if( !isset( $import_data['wc_product_attribute_taxonomies'] ) ) { return; }
$import_attributes = $import_data['wc_product_attribute_taxonomies'];
foreach( $import_attributes as $old_attribute_id => $import_attribute ) {
$new_attribute_id = wc_create_attribute(
array(
'name' => $import_attribute->attribute_label,
'slug' => $import_attribute->attribute_name,
'type' => $import_attribute->attribute_type,
'order_by' => $import_attribute->attribute_orderby,
'has_archives' => false,
)
);
if( is_wp_error( $new_attribute_id ) ) {
jswj_jedi_log( 'Error Importing Product Attribute Taxonomy', $new_attribute_id->get_error_message() );
} else {
jswj_jedi_log( 'Product Attribute Taxonomy Imported: ' . $new_attribute_id, $import_attribute->attribute_name );
$track_import['imported_product_attributes'][ $old_attribute_id ] = $new_attribute_id;
}
} # END foreach import_attributes
update_option( 'jedi_track_import', $track_import );
} # END jswj_jedi_import_wc_product_attribute_taxonomies()
add_action( 'jedi_after_media_import', 'jswj_jedi_import_wc_product_attribute_taxonomies' );
/**
* Import WooCommerce Product Attribute Terms & Meta
*
* @return void
*/
function jswj_jedi_import_wc_product_attribute_terms_meta() {
# Bail If WooCommerce Is Not Active
if( !jswj_is_woocommerce() ) { return; }
$import_data = jswj_get_jedi_import_data();
$track_import = get_option( 'jedi_track_import' );
$jedi_update_image_ids = $track_import['imported_media']['ids'];
if( isset( $track_import['imported_product_attributes'] ) ) {
$imported_product_attribute_ids = $track_import['imported_product_attributes'];
} else {
# Bail If No Attributes Were Imported
return;
}
# Bail If No Attributes Were Imported
if( count( $imported_product_attribute_ids ) === 0 ) { return; }
$wc_product_attribute_data = $import_data['wc_product_attribute_data'];
foreach( $wc_product_attribute_data as $slug => $attribute_data ) {
foreach( $attribute_data['terms'] as $terms_index => $term_data ) {
$old_term_id = $term_data->term_id;
$new_term_id = $track_import['imported_categories'][ $old_term_id ];
foreach( $attribute_data['term_meta'][ $terms_index ] as $meta_key => $term_meta_values ) {
foreach( $term_meta_values as $term_meta_value ) {
if( 'product_attribute_image' === $meta_key ) {
if( isset( $jedi_update_image_ids[ intval( $term_meta_value ) ] ) ) {
$term_meta_value = $jedi_update_image_ids[ intval( $term_meta_value ) ];
jswj_jedi_log( 'Updating product_attribute_image', $term_meta_value );
}
}
$update_test = update_term_meta( $new_term_id, $meta_key, $term_meta_value );
}
}
}
}
} # END jswj_jedi_import_wc_product_attribute_terms_meta()
add_action( 'jedi_before_post_import', 'jswj_jedi_import_wc_product_attribute_terms_meta' );
jedi-apprentice/apprentice-addons/jedi-apprentice-elementor-premium-addons.php 0000644 00000011416 15221405240 0023673 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Functions for plugin Premium Addons for Elementor
* Plugin URL: https://wordpress.org/plugins/premium-addons-for-elementor/
**/
/**
* Update Carousel Slider Post IDs In Post Meta
*
* Find & Replace Post IDs
* Add Slashes For JSON Content
*
* @param array $jedi_post_ids - Array of post IDs.
**/
function jswj_jedi_premium_carousel_slider_update_postmeta( $jedi_post_ids ) {
if( ! is_plugin_active( 'premium-addons-for-elementor/premium-addons-for-elementor.php' ) ) { return; }
# Check Each Post For Carousel Slider
# Pattern: "premium_carousel_slider_content":"["8410","8888"]"
foreach( $jedi_post_ids as $jedi_post_id ) {
$post_meta = get_post_meta( $jedi_post_id, '_elementor_data', true );
# Update Slider Content IDs
$search_string = '"premium_carousel_slider_content":';
$search_start_pos = strpos( $post_meta, $search_string );
# Protect against infinite loops
$escape_hatch = 0;
# Keep checking content for search string
while( false !== $search_start_pos ) {
# Get array of post IDs from post meta
$search_start_pos += strlen( $search_string );
$search_end_pos = strpos( $post_meta, ']', $search_start_pos ) + 1;
$slider_id_string = substr( $post_meta, $search_start_pos, $search_end_pos - $search_start_pos );
# Loop through Post IDs, replace with imported Post IDs
$slider_ids = json_decode( $slider_id_string );
foreach( $slider_ids as $key => $old_post_id ) {
$slider_ids[ $key ] = strval( $jedi_post_ids[ $old_post_id ] );
}
$post_meta = str_replace( $slider_id_string, wp_json_encode( $slider_ids ), $post_meta );
# Reset starting search position to search remaining content
$search_start_pos = strpos( $post_meta, $search_string, $search_end_pos );
# Protect against infinite loops
$escape_hatch++;
if( $escape_hatch > 100 ) { break; }
} # END while
# Update Repeater Item IDs
# Pattern: "premium_carousel_repeater_item":"8410"
$search_string = '"premium_carousel_repeater_item":"';
$search_start_pos = strpos( $post_meta, $search_string );
# Protect against infinite loops
$escape_hatch = 0;
# Keep checking content for search string
while( false !== $search_start_pos ) {
# Get array of post IDs from post meta
$search_start_pos += strlen( $search_string );
$search_end_pos = strpos( $post_meta, '"', $search_start_pos );
$old_repeater_item = substr( $post_meta, $search_start_pos, $search_end_pos - $search_start_pos );
$new_repeater_item = $jedi_post_ids[ $old_repeater_item ];
$post_meta = str_replace(
$search_string . $old_repeater_item . '"',
$search_string . $new_repeater_item . '"',
$post_meta
);
# Reset starting search position to search remaining content
$search_start_pos = strpos( $post_meta, $search_string, $search_end_pos );
# Protect against infinite loops
$escape_hatch++;
if( $escape_hatch > 100 ) { break; }
} # END while
# Add Slashes For JSON Content
$post_meta = wp_slash( $post_meta );
update_post_meta( $jedi_post_id, '_elementor_data', $post_meta );
} # END foreach jedi_post_ids
# Check Each Post For Popup Codes
# Pattern: {"popup":"8294"}
# Pattern: %7B%22popup%22%3A%228294%22%7D
foreach( $jedi_post_ids as $jedi_post_id ) {
$post_meta = get_post_meta( $jedi_post_id, '_elementor_data', true );
$search_string = '%7B%22popup%22%3A%22';
$search_start_pos = strpos( $post_meta, $search_string );
# Protect against infinite loops
$escape_hatch = 0;
# Keep checking content for search string
while( false !== $search_start_pos ) {
# Get array of post IDs from post meta
$search_start_pos += strlen( $search_string );
if( $search_start_pos > strlen( $post_meta ) ) { break; }
$search_end_pos = strpos( $post_meta, '%22%7D', $search_start_pos );
$popup_id_string = substr( $post_meta, $search_start_pos, $search_end_pos - $search_start_pos );
if( ! isset( $jedi_post_ids[ $popup_id_string ] ) ) { continue; }
$post_meta = str_replace( $popup_id_string, $jedi_post_ids[ $popup_id_string ], $post_meta );
# Reset starting search position to search remaining content
$search_start_pos = strpos( $post_meta, $search_string, $search_end_pos );
# Protect against infinite loops
$escape_hatch++;
if( $escape_hatch > 100 ) { break; }
} # END while
# Add Slashes For JSON Content
$post_meta = wp_slash( $post_meta );
update_post_meta( $jedi_post_id, '_elementor_data', $post_meta );
} # END foreach $jedi_post_ids
} # END jswj_jedi_premium_carousel_slider_update_postmeta()
add_action( 'jedi_after_post_import', 'jswj_jedi_premium_carousel_slider_update_postmeta' );
jedi-apprentice/apprentice-addons/jedi-apprentice-visual-portfolio.php 0000644 00000003203 15221405240 0022270 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Update Visual Portfolio Shortcodes in Post Content
*
* Example Shortcode: [visual_portfolio id="415"]
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_visual_portfolio_shortcodes( $jedi_post_ids ) {
if( ! is_plugin_active( 'visual-portfolio/class-visual-portfolio.php' ) ) { return; }
foreach( $jedi_post_ids as $jedi_post_id ) {
$the_post = get_post( $jedi_post_id );
if( false !== strpos( $the_post->post_content, '[visual_portfolio id' ) ) {
$vp_form_id_start = strpos( $the_post->post_content, '[visual_portfolio id="' ) + 22;
$vp_form_id_end = strpos( $the_post->post_content, '"', $vp_form_id_start + 1 );
$vp_form_id = substr( $the_post->post_content, $vp_form_id_start, $vp_form_id_end - $vp_form_id_start );
$old_shortcode = '[visual_portfolio id="' . $vp_form_id . '"';
$new_shortcode = '[visual_portfolio id="' . $jedi_post_ids[ $vp_form_id ] . '"';
$the_post->post_content = str_replace( $old_shortcode, $new_shortcode, $the_post->post_content );
wp_update_post( $the_post );
}
} # END foreach $jedi_post_ids
}
add_action( 'jedi_after_post_import', 'jswj_update_visual_portfolio_shortcodes' );
jedi-apprentice/apprentice-addons/jedi-apprentice-acf-fields.php 0000644 00000007676 15221405240 0020771 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Advanced Custom Fields - Update Postmeta To Match New Post & Media IDs
**/
function jswj_update_acf_postmeta() {
# Bail If Advanced Custom Fields Is Not Active
if( !is_plugin_active( 'advanced-custom-fields/acf.php' ) ) { return; }
$jedi_apprentice_settings = get_option( 'jedi_apprentice_settings' );
$track_import = get_option( 'jedi_track_import' );
$jedi_post_ids = $track_import['imported_posts'];
$jedi_category_ids = $track_import['imported_categories'];
$categories_posts = $track_import['categories_posts'];
$import_data = jswj_get_jedi_import_data();
# If Media were imported, load imported data
$process_media = false;
if( count( $track_import['imported_media']['ids'] ) > 0 ) {
$process_media = true;
$jedi_imported_media = $track_import['imported_media'];
$jedi_update_image_urls = $jedi_imported_media['urls'];
$jedi_update_image_ids = $jedi_imported_media['ids'];
}
$acf_image_array = array();
/**
* Work Through Field Groups
*/
foreach( $jedi_post_ids as $old_id => $new_id ) {
$post_type = get_post_type( $new_id );
if( 'acf-field-group' !== $post_type ) {
continue;
}
$acf_post_group = get_post( $new_id );
$posts = get_posts( array('post_parent'=>strval($new_id)));
$args = array(
'posts_per_page' => -1,
'post_parent' => $new_id,
'post_type' => 'acf-field',
);
$children = get_children( $args );
foreach( $children as $child ) {
$child_post_content = unserialize( $child->post_content );
$group_parent_slug = $child->post_excerpt . '_';
if( 'group' === $child_post_content['type'] ) {
$child_args = array(
'posts_per_page' => -1,
'post_parent' => $child->ID,
'post_type' => 'acf-field',
);
$kidskids = get_children( $child_args );
foreach( $kidskids as $kidskid ) {
$kidskid_post_content = unserialize( $kidskid->post_content );
if( 'image' === $kidskid_post_content['type'] ) {
$postmeta_slug = $group_parent_slug;
$postmeta_slug .= $kidskid->post_excerpt;
$acf_image_array[] = $postmeta_slug;
}
}
}
}
} # END foreach jedi_post_ids
/**
* Build Image Array
**/
foreach( $jedi_post_ids as $old_id => $new_id ) {
$post_type = get_post_type( $new_id );
if( 'acf-field' !== $post_type ) {
continue;
}
$acf_post = get_post( $new_id );
$acf_post_content = unserialize( $acf_post->post_content );
$acf_field_slug = $acf_post->post_excerpt;
if( $process_media ) {
if( 'image' === $acf_post_content['type'] ) {
$acf_image_array[] = $acf_field_slug;
} else if( 'group' === $acf_post_content['type'] ) {
}
}
} # END foreach jedi_post_ids
$acf_image_unique_array = array_unique( $acf_image_array );
foreach( $jedi_post_ids as $old_id => $new_id ) {
if( $process_media ) {
$meta_data = get_post_meta( $new_id );
foreach( $meta_data as $meta_slug => $meta_value ) {
foreach( $acf_image_unique_array as $acf_image_slug ) {
if( false !== strpos( $meta_slug, $acf_image_slug ) ) {
if( is_array( $meta_value ) ) {
foreach( $meta_value as $single_meta_value ) {
if( !isset( $jedi_update_image_ids[$single_meta_value] ) ) { continue; }
update_post_meta(
$new_id,
$acf_image_slug,
$jedi_update_image_ids[$single_meta_value],
$single_meta_value
);
}
} else {
if( isset( $jedi_update_image_ids[$meta_value] ) ) {
update_post_meta(
$new_id,
$acf_image_slug,
$jedi_update_image_ids[$meta_value]
);
}
}
}
}
}
}
} # END foreach jedi_post_ids
jswj_jedi_log( 'ACF Field Postmeta Updated' );
} # END jswj_update_acf_postmeta()
add_action( 'jedi_after_post_import', 'jswj_update_acf_postmeta', 101 );
jedi-apprentice/apprentice-addons/jedi-apprentice-elementor-functions.php 0000644 00000047456 15221405240 0022774 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Filter Postmeta Content For Elementor
*
* Find & Replace Image IDs
* Add Slashes For JSON Content
*
* @param string $postmeta - String / Array.
*
* @return String / Array
**/
function jswj_jedi_elementor_filter_postmeta( $postmeta ) {
if( ! jswj_is_elementor() ) { return $postmeta; }
# Find & Replace Image IDs
$track_import = get_option( 'jedi_track_import' );
$jedi_imported_media_ids = $track_import['imported_media']['ids'];
$jedi_imported_media_urls = $track_import['imported_media']['urls'];
foreach( $jedi_imported_media_ids as $old_media_id => $new_media_id ) {
# Patterns
# "image":{"url":"...","id":###}
# "background_image":{"url":"...","id":###}
# "bg_image":{"url":"...","id":###}
# "wp_gallery":[{"id":###,"url":"..."},{"id":###,"url":"..."}]
$postmeta = str_replace(
'"id":' . $old_media_id . '}',
'"id":' . $new_media_id . '}',
$postmeta
);
$postmeta = str_replace(
'"id":' . $old_media_id . ',',
'"id":' . $new_media_id . ',',
$postmeta
);
} # END foreach jedi_imported_media_ids
foreach( $jedi_imported_media_urls as $media_url_array ) {
$old_media_url = $media_url_array['oldURL'];
$new_media_url = $media_url_array['newURL'];
# Patterns
# "image":{"url":"...","id":###}
# "background_image":{"url":"...","id":###}
# "bg_image":{"url":"...","id":###}
# "wp_gallery":[{"id":###,"url":"..."},{"id":###,"url":"..."}]
$postmeta = str_replace(
'"url":' . $old_media_url . '}',
'"url":' . $new_media_url . '}',
$postmeta
);
$postmeta = str_replace(
'"url":' . $old_media_url . ',',
'"url":' . $new_media_url . ',',
$postmeta
);
} # END foreach jedi_imported_media_ids
# Add Slashes For JSON Content
$postmeta = wp_slash( $postmeta );
return $postmeta;
} # END jswj_jedi_elementor_filter_postmeta()
add_filter( 'jedi_filter_postmeta_content', 'jswj_jedi_elementor_filter_postmeta' );
/**
* Import The Elementor Plugin Options
**/
function jswj_jedi_import_elementor_options() {
jswj_verify_ajax_nonce_and_capability( 'jswj_import_process_nonce', 'jedi_ajax_nonce' );
if( ! jswj_is_elementor() ) {
jswj_ajax_response( array( 1, 'Unable To Import Options, Elementor Not Installed' ) );
}
$jedi_import_options = get_option( 'jedi_import_options' );
$jedi_apprentice_settings = get_option( 'jedi_apprentice_settings' );
$track_import = get_option( 'jedi_track_import' );
$jedi_imported_media = $track_import['imported_media'];
$jedi_post_ids = $track_import['imported_posts'];
$import_data = jswj_get_jedi_import_data();
$elementor_options = $import_data['elementor_options'];
/**
* Loops through Elementor Options
**/
foreach( $elementor_options as $option_key => $jedi_import_option ) {
$jedi_import_option = apply_filters( 'jedi_elementor_options_import_filter', $jedi_import_option, $option_key );
update_option( $option_key, $jedi_import_option );
}
# Import Fonts
jswj_jedi_import_elementor_fonts();
# Import CSS Files
jswj_jedi_import_elementor_css();
jswj_jedi_log( 'Elementor Options & Settings Imported' );
jswj_ajax_response( array( 1, 'Elementor Options & Settings Imported' ) );
} # END jswj_jedi_import_elementor_options()
add_action( 'wp_ajax_jswj_jedi_import_elementor_options', 'jswj_jedi_import_elementor_options' );
/**
* Import Elementor CSS Files From Export Folder
*
* Copies CSS Files To Upload Directory
* Rename & Replace CSS Files With Updated Post IDs
**/
function jswj_jedi_import_elementor_css() {
if( ! jswj_is_elementor() ) { return; }
$jedi_apprentice_settings = get_option( 'jedi_apprentice_settings' );
$track_import = get_option( 'jedi_track_import' );
$jedi_post_ids = $track_import['imported_posts'];
$css_import_path = JEDI_APPRENTICE_PATH . 'demo-data/elementor/css';
if( ! file_exists( $css_import_path ) ) { return; }
$upload_dir = wp_get_upload_dir();
$upload_css_dir = $upload_dir['basedir'] . '/elementor/css';
# Initialize the WP filesystem
global $wp_filesystem;
if( empty( $wp_filesystem ) ) {
require_once ABSPATH . '/wp-admin/includes/file.php';
if( ! WP_Filesystem() ) {
jswj_jedi_order_66( 'Failed to initialize WP Filesystem.' );
}
}
# Create Upload CSS Folder If Necessary
if( ! wp_mkdir_p( $upload_css_dir ) ) {
jswj_jedi_order_66( 'Unable to create Plugin Folder: ' . $upload_css_dir );
}
# Duplicate The CSS Folder
$safe_jedi = copy_dir( $css_import_path, $upload_css_dir );
if( is_wp_error( $safe_jedi ) ) {
jswj_jedi_order_66( 'Failed to copy Plugin folder', wp_json_encode( $safe_jedi ) );
}
# Loop Through CSS Files To Find & Update Post IDs
$css_files = glob( $upload_css_dir . '/*.css' );
foreach( $css_files as $css_file ) {
foreach( $jedi_post_ids as $old_id => $new_id ) {
# If File Matches Post ID
if( strpos( $css_file, '-' . strval( $old_id ) . '.css' ) !== false ) {
jswj_jedi_log( 'Importing CSS File', $css_file );
# Create New CSS File Name
$new_css_file = str_replace(
'-' . strval( $old_id ) . '.css',
'-' . strval( $new_id ) . '.css',
$css_file
);
# Create New CSS File Content
$css_file_content = str_replace(
'.elementor-' . strval( $old_id ) . ' ',
'.elementor-' . strval( $new_id ) . ' ',
file_get_contents( $css_file )
);
# Replace Popup IDs In File Content
# Pattern: #elementor-popup-modal-###
$css_file_content = str_replace(
'#elementor-popup-modal-' . strval( $old_id ),
'#elementor-popup-modal-' . strval( $new_id ),
$css_file_content
);
# Save New CSS File
file_put_contents( $new_css_file, $css_file_content );
jswj_jedi_log( 'New CSS File', $new_css_file );
# Delete CSS File With Original ID
unlink( $css_file );
}
}
}
# Loop Through CSS Files To Find & Update Media & Font File URLs
$css_files = glob( $upload_css_dir . '/*.css' );
foreach( $css_files as $css_file ) {
$css_file_content = file_get_contents( $css_file );
# If Media were imported, load imported data
# Update Image URLs In Content
if( count( $track_import['imported_media']['ids'] ) > 0 ) {
$jedi_imported_media = $track_import['imported_media'];
$jedi_update_image_urls = $jedi_imported_media['urls'];
$jedi_update_image_ids = $jedi_imported_media['ids'];
foreach( $jedi_update_image_urls as $jedi_update_image_url ) {
$css_file_content = str_replace(
$jedi_update_image_url['oldURL'],
$jedi_update_image_url['newURL'],
$css_file_content
);
}
}
# If Fonts were imported, load imported data
# Update Image URLs In Content
if( isset( $track_import['imported_fonts'] ) && count( $track_import['imported_fonts'] ) > 0 ) {
foreach( $track_import['imported_fonts'] as $old_font_url => $new_font_url ) {
$css_file_content = str_replace(
$old_font_url,
$new_font_url,
$css_file_content
);
}
}
# Save Modified File
file_put_contents( $css_file, $css_file_content );
} # END foreach $css_files
} # END jswj_jedi_import_elementor_css()
/**
* Import Elementor Font Files From Export Folder
*
* Copies Font Files To Upload Directory
**/
function jswj_jedi_import_elementor_fonts() {
if( ! jswj_is_elementor() ) { return; }
$jedi_apprentice_settings = get_option( 'jedi_apprentice_settings' );
$track_import = get_option( 'jedi_track_import' );
$track_import['imported_fonts'] = array();
$font_import_path = JEDI_APPRENTICE_PATH . 'demo-data/elementor/fonts';
if( ! file_exists( $font_import_path ) ) { return; }
# Get Upload Directory Data
$upload_dir = wp_get_upload_dir();
$upload_font_dir = $upload_dir['path'] . '/';
$upload_font_url = $upload_dir['url'] . '/';
$import_data = jswj_get_jedi_import_data();
$font_files_to_import = $import_data['elementor_options']['fonts'];
# Initialize the WP filesystem
global $wp_filesystem;
if( empty( $wp_filesystem ) ) {
require_once ABSPATH . '/wp-admin/includes/file.php';
if( ! WP_Filesystem() ) {
jswj_jedi_order_66( 'Failed to initialize WP Filesystem.' );
}
}
# Duplicate The Font Folder To Current Upload Folder
$safe_jedi = copy_dir( $font_import_path, $upload_font_dir );
if( is_wp_error( $safe_jedi ) ) {
jswj_jedi_order_66( 'Failed to copy Plugin folder', wp_json_encode( $safe_jedi ) );
}
# Get The Font Database Records
$font_files_args = array(
'post_type' => 'elementor_font',
'posts_per_page' => -1,
);
$font_files_query = new WP_Query( $font_files_args );
$font_records = $font_files_query->posts;
$font_types = array( 'woff', 'woff2', 'ttf', 'svg', 'eot' );
# Loop Through Font Records
# Check each one to see if local file exists
# If local file exists, copy font file to export folder
foreach( $font_records as $font_record ) {
# Get Font Record Metadata
$font_record_metadata = get_post_meta( $font_record->ID, 'elementor_font_face', true );
$font_file_record_metadata = get_post_meta( $font_record->ID, 'elementor_font_files', true );
foreach( $font_files_to_import as $file_url => $font_file_to_import ) {
if( ! file_exists( $upload_font_dir . basename( $file_url ) ) ) { continue; }
# Update Font Face Metadata
$font_record_metadata = str_replace(
$file_url,
$upload_font_url . basename( $file_url ),
$font_record_metadata
);
# Update Font File Metadata
foreach( $font_types as $font_type ) {
if( ! isset( $font_file_record_metadata[0][ $font_type ] ) ) { continue; }
$font_file_record_metadata[0][ $font_type ] = str_replace(
$file_url,
$upload_font_url . basename( $file_url ),
$font_file_record_metadata[0][ $font_type ]
);
}
$track_import['imported_fonts'][ $file_url ] = $upload_font_url . basename( $file_url );
} # END foreach $font_files_to_import
update_post_meta( $font_record->ID, 'elementor_font_face', $font_record_metadata );
update_post_meta( $font_record->ID, 'elementor_font_files', $font_file_record_metadata );
} # END foreach $font_records
update_option( 'jedi_track_import', $track_import );
} # END jswj_jedi_import_elementor_fonts()
/**
* Update Elementor Pro Theme Builder Options With Updated Post IDs
*
* @param string $jedi_import_option - Option Content.
* @param string $option_key - Option Key.
**/
function jswj_elementor_pro_option_filter( $jedi_import_option, $option_key ) {
if( ! jswj_is_elementor() ) { return; }
if( 'elementor_pro_theme_builder_conditions' !== $option_key ) { return $jedi_import_option; }
if( ! is_array( $jedi_import_option ) ) { return $jedi_import_option; }
$track_import = get_option( 'jedi_track_import' );
$jedi_imported_media = $track_import['imported_media'];
$jedi_post_ids = $track_import['imported_posts'];
foreach( $jedi_import_option as $theme_element_slug => $theme_element_items ) {
foreach( $theme_element_items as $element_id => $element_content ) {
if( isset( $jedi_post_ids[ $element_id ] ) ) {
# Create New Element With Updated Post ID
$new_id = $jedi_post_ids[ $element_id ];
foreach( $element_content as $single_key => $single_element ) {
# Single Page
$search_string = 'include/singular/page/';
if( strpos( $single_element, $search_string ) !== false ) {
$old_post_id = substr( $single_element, strlen( $search_string ) );
if( isset( $jedi_post_ids[ $old_post_id ] ) ) {
$single_element = str_replace( $old_post_id, $jedi_post_ids[ $old_post_id ], $single_element );
$element_content[ $single_key ] = $single_element;
}
}
# Single Post
$search_string = 'include/singular/post/';
if( strpos( $single_element, $search_string ) !== false ) {
$old_post_id = substr( $single_element, strlen( $search_string ) );
if( isset( $jedi_post_ids[ $old_post_id ] ) ) {
$single_element = str_replace( $old_post_id, $jedi_post_ids[ $old_post_id ], $single_element );
$element_content[ $single_key ] = $single_element;
}
}
} # END foreach $element_content
$jedi_import_option[ $theme_element_slug ][ $new_id ] = $element_content;
# Delete Old Element
unset( $jedi_import_option[ $theme_element_slug ][ $element_id ] );
}
}
}
return $jedi_import_option;
} # END jswj_elementor_pro_option_filter()
add_filter( 'jedi_elementor_options_import_filter', 'jswj_elementor_pro_option_filter', 10, 2 );
/**
* Update Post Content For Elementor Elements
*
* Style: .elementor-####
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_elementor_postcontent( $jedi_post_ids ) {
if( ! jswj_is_elementor() ) { return; }
jswj_jedi_log( 'Executing jswj_update_elementor_postcontent() ', wp_json_encode( $jedi_post_ids ) );
$search_post_ids = $jedi_post_ids;
$search_within_post_ids = $jedi_post_ids;
foreach( $search_post_ids as $key => $search_post_id ) {
$the_post = get_post( $search_post_id );
$update_count = 0;
foreach( $search_within_post_ids as $old_search_post_id => $new_search_post_id ) {
$old_elementor_string = '.elementor-' . $old_search_post_id . ' ';
$new_elementor_string = '.elementor-' . $new_search_post_id . ' ';
$count = 0;
$the_post->post_content = str_replace(
$old_elementor_string,
$new_elementor_string,
$the_post->post_content,
$count
);
$update_count = $update_count + $count;
}
if( $update_count > 0 ) {
$update_post = wp_update_post( $the_post );
jswj_jedi_log(
'Updating post #' . $search_post_id . ' for elementor content',
'Replacements: ' . $update_count
);
}
} # END foreach $jedi_post_ids
} # END jswj_update_elementor_postcontent()
add_action( 'jedi_after_post_import', 'jswj_update_elementor_postcontent' );
/**
* Update Post Meta
*
* Find & Replace Post IDs
* Add Slashes For JSON Content
*
* @param array $jedi_post_ids - Array of post IDs.
**/
function jswj_jedi_elementor_postmeta( $jedi_post_ids ) {
if( ! jswj_is_elementor() ) { return; }
# Check Each Post For Template IDs
# Pattern: "template_id":"8435"
foreach( $jedi_post_ids as $jedi_post_id ) {
$post_meta = get_post_meta( $jedi_post_id, '_elementor_data', true );
# Update Template Item IDs
# Pattern: "template_id":"8435"
$search_string = '"template_id":"';
$search_start_pos = strpos( $post_meta, $search_string );
# Protect against infinite loops
$escape_hatch = 0;
# Keep checking content for search string
while( false !== $search_start_pos ) {
# Get array of post IDs from post meta
$search_start_pos += strlen( $search_string );
$search_end_pos = strpos( $post_meta, '"', $search_start_pos );
$old_repeater_item = substr( $post_meta, $search_start_pos, $search_end_pos - $search_start_pos );
if( isset( $jedi_post_ids[ $old_repeater_item ] ) ) {
$new_repeater_item = $jedi_post_ids[ $old_repeater_item ];
$post_meta = str_replace(
$search_string . $old_repeater_item . '"',
$search_string . $new_repeater_item . '"',
$post_meta
);
}
# Reset starting search position to search remaining content
$search_start_pos = strpos( $post_meta, $search_string, $search_end_pos );
# Protect against infinite loops
$escape_hatch++;
if( $escape_hatch > 100 ) { break; }
} # END while
# Add Slashes For JSON Content
$post_meta = wp_slash( $post_meta );
update_post_meta( $jedi_post_id, '_elementor_data', $post_meta );
} # END foreach jedi_post_ids
# Check Each Post For Query Post IDs
# Pattern: "posts_posts_ids":["7727","7726","7725"]
foreach( $jedi_post_ids as $jedi_post_id ) {
$post_meta = get_post_meta( $jedi_post_id, '_elementor_data', true );
# Update Post IDs
# Pattern: "posts_posts_ids":["7727","7726","7725"]
$search_string = '"posts_posts_ids":';
$search_start_pos = strpos( $post_meta, $search_string );
# Protect against infinite loops
$escape_hatch = 0;
# Keep checking content for search string
while( false !== $search_start_pos ) {
# Get array of post IDs from post meta
$search_start_pos += strlen( $search_string );
$search_end_pos = strpos( $post_meta, ']', $search_start_pos ) + 1;
$old_post_ids_json = substr( $post_meta, $search_start_pos, $search_end_pos - $search_start_pos );
$post_ids_object = json_decode( $old_post_ids_json );
if( count( $post_ids_object ) > 0 ) {
foreach( $post_ids_object as $key => $this_post_id ) {
if( isset( $jedi_post_ids[ $this_post_id ] ) ) {
$post_ids_object[ $key ] = $jedi_post_ids[ $this_post_id ];
}
}
}
$new_post_ids_json = wp_json_encode( $post_ids_object );
$post_meta = str_replace(
$search_string . $old_post_ids_json,
$search_string . $new_post_ids_json,
$post_meta
);
# Reset starting search position to search remaining content
$search_start_pos = strpos( $post_meta, $search_string, $search_end_pos );
# Protect against infinite loops
$escape_hatch++;
if( $escape_hatch > 100 ) { break; }
} # END while
# Add Slashes For JSON Content
$post_meta = wp_slash( $post_meta );
update_post_meta( $jedi_post_id, '_elementor_data', $post_meta );
} # END foreach jedi_post_ids
} # END jswj_jedi_elementor_postmeta()
add_action( 'jedi_after_post_import', 'jswj_jedi_elementor_postmeta' );
/*** ELEMENTOR SHORTCODES ***/
/**
* Update Elementor Shortcodes in Post Content
*
* Example Shortcode: [elementor-template id="415"]
*
* @uses JEDI Hook jedi_after_post_import
* @param array $jedi_post_ids An array of imported Post IDs.
**/
function jswj_update_elementor_shortcodes( $jedi_post_ids ) {
if( ! jswj_is_elementor() ) { return; }
jswj_jedi_log( 'Executing jswj_update_elementor_shortcodes() ', wp_json_encode( $jedi_post_ids ) );
foreach( $jedi_post_ids as $jedi_post_id ) {
$the_post = get_post( $jedi_post_id );
if( false !== strpos( $the_post->post_content, '[elementor-template id' ) ) {
$the_shortcode_id_start = strpos( $the_post->post_content, '[elementor-template id="' ) + 24;
$the_shortcode_id_end = strpos( $the_post->post_content, '"', $the_shortcode_id_start + 1 );
$the_shortcode_id = substr( $the_post->post_content, $the_shortcode_id_start, $the_shortcode_id_end - $the_shortcode_id_start );
$old_shortcode = '[elementor-template id="' . $the_shortcode_id . '"';
$new_shortcode = '[elementor-template id="' . $jedi_post_ids[ $the_shortcode_id ] . '"';
$the_post->post_content = str_replace( $old_shortcode, $new_shortcode, $the_post->post_content );
jswj_jedi_log(
'Updating Elementor Shortcode: ',
wp_json_encode(
array(
$jedi_post_id,
$the_shortcode_id,
$jedi_post_ids[ $the_shortcode_id ],
)
)
);
wp_update_post( $the_post );
}
} # END foreach $jedi_post_ids
}
add_action( 'jedi_after_post_import', 'jswj_update_elementor_shortcodes' );
/**
* Set Elementor Libary Item Terms
**/
function jswj_import_elementor_library_terms() {
if( ! jswj_is_elementor() ) { return; }
$jedi_apprentice_settings = get_option( 'jedi_apprentice_settings' );
$track_import = get_option( 'jedi_track_import' );
$jedi_post_ids = $track_import['imported_posts'];
$jedi_category_ids = $track_import['imported_categories'];
$categories_posts = $track_import['categories_posts'];
$import_data = jswj_get_jedi_import_data();
# Import and assign the terms for Elementor Library Items
if( isset( $import_data['elementor_options']['elementor_library_terms'] ) ) {
$elementor_library_terms = $import_data['elementor_options']['elementor_library_terms'];
# Loop Through Library Item Posts
foreach( $elementor_library_terms as $old_post_id => $post_terms ) {
# Loop Through Library Item Post Terms
foreach( $post_terms as $post_term_slug => $post_term ) {
wp_set_post_terms( $jedi_post_ids[ $old_post_id ], $post_term_slug, 'elementor_library_type', false );
}
} # END foreach $elementor_library_terms
}
} # END jswj_import_elementor_library_terms()
add_action( 'jedi_after_post_import', 'jswj_import_elementor_library_terms', 100 );
jedi-apprentice/apprentice-addons/jedi-apprentice-divi-theme-builder.php 0000644 00000015556 15221405240 0022447 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Sync Theme Builder Post IDs
**/
function jswj_import_divi_theme_builder_data() {
jswj_verify_ajax_nonce_and_capability( 'jswj_import_process_nonce', 'jedi_ajax_nonce' );
if( ! jswj_is_divi() ) {
echo wp_json_encode( array( 1, 'Divi Not Installed, Skipping Theme Builder Import' ) );
wp_die();
}
$jedi_apprentice_settings = get_option( 'jedi_apprentice_settings' );
$track_import = get_option( 'jedi_track_import' );
$jedi_post_ids = $track_import['imported_posts'];
$jedi_category_ids = $track_import['imported_categories'];
$categories_posts = $track_import['categories_posts'];
$import_data = jswj_get_jedi_import_data();
/**
* Check if Theme Builder Post already exists
* If it does, use that for imported theme builder content
* If it doesn't, use the one from imported content
**/
$theme_builder_post_id = et_theme_builder_get_theme_builder_post_id( 'publish', false );
if( 0 === $theme_builder_post_id ) {
$imported_theme_builder_post_id = $import_data['divi_theme_builder']['theme_builder_post_id'];
if( isset( $jedi_post_ids[ $imported_theme_builder_post_id ] ) ) {
# Use Imported Theme Builder Post
$theme_builder_post_id = $import_data['divi_theme_builder']['theme_builder_post_id'];
} else {
# Catch Error When No Theme Builder Post On Site, Or In Import Content
jswj_jedi_log(
'Error Identifying Theme Builder Post: ',
wp_json_encode(
array(
'theme_builder_post_id' => $theme_builder_post_id,
'imported_theme_builder_post_id' => $imported_theme_builder_post_id,
)
)
);
return false;
}
} # END if theme_builder_post_id
/**
* Add Imported Templates To Theme Builder
**/
$imported_theme_builder_template_ids = $import_data['divi_theme_builder']['theme_builder_template_ids'];
foreach( $imported_theme_builder_template_ids as $template_id ) {
add_post_meta(
$theme_builder_post_id,
'_et_template',
$jedi_post_ids[ $template_id ]
);
}
$theme_builder_post_types = array(
ET_THEME_BUILDER_TEMPLATE_POST_TYPE,
ET_THEME_BUILDER_HEADER_LAYOUT_POST_TYPE,
ET_THEME_BUILDER_BODY_LAYOUT_POST_TYPE,
ET_THEME_BUILDER_FOOTER_LAYOUT_POST_TYPE,
);
$theme_builder_layout_meta_slugs = array(
'_et_header_layout_id',
'_et_body_layout_id',
'_et_footer_layout_id',
);
/**
* Loop Through Imported Posts To Update Theme Builder Meta Data
**/
foreach( $jedi_post_ids as $old_id => $new_id ) {
$post_type = get_post_type( $new_id );
# Update Layout IDs
if( in_array( $post_type, $theme_builder_post_types, true ) ) {
foreach( $theme_builder_layout_meta_slugs as $meta_slug ) {
if( metadata_exists( 'post', $new_id, $meta_slug ) ) {
$meta_value = get_post_meta( $new_id, $meta_slug, true );
if( isset( $jedi_post_ids[ $meta_value ] ) ) {
update_post_meta(
$new_id,
$meta_slug,
$jedi_post_ids[ $meta_value ],
$meta_value
);
}
}
}
/**
* Make Sure Old Post IDs Are Not Attached To Theme Builder Templates
**/
if( 'et_template' === $post_type ) {
delete_post_meta( $theme_builder_post_id, '_et_template', $old_id );
}
}
# Update Meta _et_use_on
if( metadata_exists( 'post', $new_id, '_et_use_on' ) ) {
$use_on = get_post_meta( $new_id, '_et_use_on', false );
$useon_post_ids = $track_import['imported_posts'];
$useon_category_ids = $track_import['imported_categories'];
delete_post_meta( $new_id, '_et_use_on' );
foreach ( $use_on as $condition ) {
foreach( $useon_post_ids as $useon_old_id => $useon_new_id ) {
# Pages
if( strpos( $condition, 'page:id:' . $useon_old_id ) !== false ) {
$condition = str_replace( 'page:id:' . $useon_old_id, 'page:id:' . $useon_new_id, $condition );
}
# Posts
if( strpos( $condition, 'post:id:' . $useon_old_id ) !== false ) {
$condition = str_replace( 'post:id:' . $useon_old_id, 'post:id:' . $useon_new_id, $condition );
}
# Children
if( strpos( $condition, 'children:id:' . $useon_old_id ) !== false ) {
$condition = str_replace( 'children:id:' . $useon_old_id, 'children:id:' . $useon_new_id, $condition );
}
# Single Custom Post Type
if( strpos( $condition, 'singular:post_type' ) !== false
&& strpos( $condition, 'id:' . $useon_old_id ) !== false ) {
$condition = str_replace( 'id:' . $useon_old_id, 'id:' . $useon_new_id, $condition );
}
}
foreach( $useon_category_ids as $useon_old_cat_id => $useon_new_cat_id ) {
if( strpos( $condition, 'term:id:' . $useon_old_cat_id ) !== false ) {
$condition = str_replace( 'term:id:' . $useon_old_cat_id, 'term:id:' . $useon_new_cat_id, $condition );
}
}
add_post_meta( $new_id, '_et_use_on', $condition );
} # END foreach use_on
} # END _et_use_on
# Update Meta _et_exclude_from
if( metadata_exists( 'post', $new_id, '_et_exclude_from' ) ) {
$exclude_from = get_post_meta( $new_id, '_et_exclude_from', false );
$excludefrom_post_ids = $track_import['imported_posts'];
$excludefrom_category_ids = $track_import['imported_categories'];
delete_post_meta( $new_id, '_et_exclude_from' );
foreach ( $exclude_from as $condition ) {
foreach( $excludefrom_post_ids as $excludefrom_old_id => $excludefrom_new_id ) {
# Pages
if( strpos( $condition, 'page:id:' . $excludefrom_old_id ) !== false ) {
$condition = str_replace( 'page:id:' . $excludefrom_old_id, 'page:id:' . $excludefrom_new_id, $condition );
}
# Posts
if( strpos( $condition, 'post:id:' . $excludefrom_old_id ) !== false ) {
$condition = str_replace( 'post:id:' . $excludefrom_old_id, 'post:id:' . $excludefrom_new_id, $condition );
}
# Children
if( strpos( $condition, 'children:id:' . $excludefrom_old_id ) !== false ) {
$condition = str_replace( 'children:id:' . $excludefrom_old_id, 'children:id:' . $excludefrom_new_id, $condition );
}
}
foreach( $excludefrom_category_ids as $excludefrom_old_cat_id => $excludefrom_new_cat_id ) {
if( strpos( $condition, 'term:id:' . $excludefrom_old_cat_id ) !== false ) {
$condition = str_replace( 'term:id:' . $excludefrom_old_cat_id, 'term:id:' . $excludefrom_new_cat_id, $condition );
}
}
add_post_meta( $new_id, '_et_exclude_from', $condition );
}# END foreach exclude_from
} # END _et_exclude_from
} # END foreach jedi_post_ids
# Clean Up
et_theme_builder_trash_draft_and_unused_posts();
jswj_jedi_log( 'Divi Theme Builder Content Imported' );
echo wp_json_encode( array( 1, 'Divi Theme Builder Content Imported' ) );
wp_die();
} # END jswj_import_divi_theme_builder_data()
add_action( 'wp_ajax_jswj_jedi_import_divi_theme_builder_data', 'jswj_import_divi_theme_builder_data', 101 );
jedi-apprentice/apprentice-addons/jedi-apprentice-cartflows.php 0000644 00000012062 15221405240 0020761 0 ustar 00
* @copyright 2021 Jerry Simmons
* @license GPL-2.0+
**/
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Restore Cartflows Settings
* Update Post IDs Where Applicable
*
* @uses JEDI Hook jedi_import_plugin_settings
**/
function jswj_import_cartflows_settings() {
# Bail If WooCommerce Is Not Active
if( !jswj_is_woocommerce() ) { return; }
# Bail If Cartflows Is Not Active
if( !is_plugin_active( 'cartflows/cartflows.php' ) ) { return; }
jswj_jedi_log( 'Importing Cartflows Settings' );
$import_data = jswj_get_jedi_import_data();
$track_import = get_option( 'jedi_track_import' );
$jedi_post_ids = $track_import['imported_posts'];
$jedi_category_ids = $track_import['imported_categories'];
$categories_posts = $track_import['categories_posts'];
# Bail if no Cartflows settings exist in import data
if( ! isset( $import_data['cartflows_settings'] ) ) { return; }
$cartflows_settings = $import_data['cartflows_settings'];
foreach( $cartflows_settings as $key => $option ) {
if( is_serialized( $option ) ) { $option = unserialize( $option ); }
switch( $key ) {
# Single Post ID Updates
case '_cartflows_common':
$old_global_checkout = intval( $option['global_checkout'] );
if( isset( $jedi_post_ids[ $old_global_checkout ] ) ) {
$new_global_checkout = $jedi_post_ids[ $old_global_checkout ];
$option['global_checkout'] = strval( $new_global_checkout );
}
break;
case 'cartflows-divi-flows-and-steps-1':
case 'cartflows-elementor-flows-and-steps-1':
case 'cartflows-beaver-builder-flows-and-steps-1':
case 'cartflows-gutenberg-flows-and-steps-1':
$option = jswj_jedi_update_ids_in_steps( $option );
break;
}
update_option( $key, $option );
jswj_jedi_log( 'Updating Cartflows Setting: ' . $key );
} # END foreach yith_wcwl_settings
# Update Post Meta
foreach( $jedi_post_ids as $old_post_id => $new_post_id ) {
if( 'cartflows_step' === get_post_type( $new_post_id ) ) {
$meta_post_id = get_post_meta( $new_post_id, 'wcf-flow-id', true );
if( isset( $jedi_post_ids[ $meta_post_id ] ) ) {
update_post_meta( $new_post_id, 'wcf-flow-id', $jedi_post_ids[ $meta_post_id ], $meta_post_id );
}
}
if( 'cartflows_flow' === get_post_type( $new_post_id ) ) {
$flow_post_meta = get_post_meta( $new_post_id, 'wcf-steps', true );
foreach( $flow_post_meta as $meta_index => $meta_array ) {
$ref_id = $meta_array['id'];
if( isset( $jedi_post_ids[ $ref_id ] ) ) {
$flow_post_meta[$meta_index]['id'] = $jedi_post_ids[ $ref_id ];
}
}
update_post_meta( $new_post_id, 'wcf-steps', $flow_post_meta );
}
}
} # END jswj_import_cartflows_settings()
add_action( 'jedi_import_plugin_settings', 'jswj_import_cartflows_settings', 100 );
/**
* Update Post & Term IDs In Cartflows Steps
*
* @param array $option
* @param array $jedi_post_ids
* @return array
*/
function jswj_jedi_update_ids_in_steps( $option ) {
$track_import = get_option( 'jedi_track_import' );
$jedi_post_ids = $track_import['imported_posts'];
$jedi_category_ids = $track_import['imported_categories'];
$categories_posts = $track_import['categories_posts'];
foreach( $option as $index => $flow ) {
# Update The Flow ID
if( isset( $jedi_post_ids[ $flow['ID'] ] ) ) {
$new_flow_id = $jedi_post_ids[ $flow['ID'] ];
$option[$index]['ID'] = $new_flow_id;
}
# Loop Through Steps To Update Step IDs (Posts)
foreach( $flow['steps'] as $step_index => $step_array ) {
if( isset( $jedi_post_ids[ $step_array['ID'] ] ) ) {
$new_step_id = $jedi_post_ids[ $step_array['ID'] ];
$option[$index]['steps'][$step_index]['ID'] = $new_step_id;
}
}
# Loop Through Setting To Update Step IDs (Terms)
foreach( $flow['cartflows_flow_page_builder'] as $pb_index => $pb_array ) {
if( isset( $jedi_category_ids[ $pb_array['term_id'] ] ) ) {
$new_pb_id = $jedi_category_ids[ $pb_array['term_id'] ];
$option[$index]['cartflows_flow_page_builder'][$pb_index]['term_id'] = $new_pb_id;
$option[$index]['cartflows_flow_page_builder'][$pb_index]['term_taxonomy_id'] = $new_pb_id;
}
}
# Loop Through Setting To Update Step IDs (Terms)
foreach( $flow['cartflows_flow_category'] as $pb_index => $pb_array ) {
if( isset( $jedi_category_ids[ $pb_array['term_id'] ] ) ) {
$new_pb_id = $jedi_category_ids[ $pb_array['term_id'] ];
$option[$index]['cartflows_flow_category'][$pb_index]['term_id'] = $new_pb_id;
$option[$index]['cartflows_flow_category'][$pb_index]['term_taxonomy_id'] = $new_pb_id;
}
}
# Loop Through Setting To Update Step IDs (Terms)
foreach( $flow['cartflows_flow_type'] as $pb_index => $pb_array ) {
if( isset( $jedi_category_ids[ $pb_array['term_id'] ] ) ) {
$new_pb_id = $jedi_category_ids[ $pb_array['term_id'] ];
$option[$index]['cartflows_flow_type'][$pb_index]['term_id'] = $new_pb_id;
$option[$index]['cartflows_flow_type'][$pb_index]['term_taxonomy_id'] = $new_pb_id;
}
}
}
return $option;
} # END jswj_jedi_update_ids_in_steps() jedi-apprentice/demo-data/media/doors.jpg 0000644 00000112646 15221405240 0014356 0 ustar 00 PNG
IHDR ؑ mIDATxsTW&WHl/]]=5=O`(XmhRʜ4`$r|WgHR{{nn p @(
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t H@ $
t HV= P{{{QNNNh4>22wәtT B Jf677OӜ
ejj*333իW3;;鱩 J5?U l6szzw322$?C~ V+kkkYYYQWkbb"YXX\|t1 RP8F裏i6$~
瑑gllWOMMeddW:::~[-mgzz:SSS~MNNG!?@5(ǿ=rHٻubtt4t355U_|'njeqq1KKK2X(, +: ]l6sxx}P=D333w\\'''NrppLLLdjj*zj\ҳ}C;fw샃466,//+q