updated plugin GP Premium version 1.11.2

This commit is contained in:
2020-08-13 14:53:39 +00:00
committed by Gitium
parent 3f0f8d3ac9
commit 885bbdd113
151 changed files with 11329 additions and 6954 deletions

View File

@ -1,5 +1,15 @@
<?php
defined( 'WPINC' ) or die;
/**
* This file handles the Site Library.
*
* @since 1.6.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
define( 'GENERATE_SITES_PATH', plugin_dir_path( __FILE__ ) );
define( 'GENERATE_SITES_URL', plugin_dir_url( __FILE__ ) );
@ -76,8 +86,8 @@ function generate_site_library_fix_menu() {
global $parent_file, $submenu_file, $post_type;
if ( generate_is_sites_dashboard() ) {
$parent_file = 'themes.php';
$submenu_file = 'generate-options';
$parent_file = 'themes.php'; // phpcs:ignore -- Override necessary.
$submenu_file = 'generate-options'; // phpcs:ignore -- Override necessary.
}
remove_submenu_page( 'themes.php', 'generatepress-site-library' );
@ -124,29 +134,29 @@ function generate_sites_do_enqueue_scripts() {
'generate-sites-admin',
'generate_sites_params',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'generate_sites_nonce' ),
'importing_options' => __( 'Importing options', 'gp-premium' ),
'backing_up_options' => __( 'Backing up options', 'gp-premium' ),
'checking_demo_content' => __( 'Checking demo content', 'gp-premium' ),
'downloading_content' => __( 'Downloading content', 'gp-premium' ),
'importing_content' => __( 'Importing content', 'gp-premium' ),
'importing_site_options' => __( 'Importing site options', 'gp-premium' ),
'importing_widgets' => __( 'Importing widgets', 'gp-premium' ),
'activating_plugins' => __( 'Activating plugins', 'gp-premium' ),
'installing_plugins' => __( 'Installing plugins', 'gp-premium' ),
'automatic_plugins' => __( 'Automatic', 'gp-premium' ),
'manual_plugins' => __( 'Manual', 'gp-premium' ),
'home_url' => home_url(),
'restoreThemeOptions' => __( 'Restoring theme options', 'gp-premium' ),
'restoreSiteOptions' => __( 'Restoring site options', 'gp-premium' ),
'restoreContent' => __( 'Removing imported content', 'gp-premium' ),
'restorePlugins' => __( 'Deactivating imported plugins', 'gp-premium' ),
'restoreWidgets' => __( 'Restoring widgets', 'gp-premium' ),
'restoreCSS' => __( 'Restoring CSS', 'gp-premium' ),
'cleanUp' => __( 'Cleaning up', 'gp-premium' ),
'hasContentBackup' => ! empty( $backup_data['content'] ),
'confirmRemoval' => __( 'This process makes changes to your database. If you have existing data, be sure to create a backup as a precaution.', 'gp-premium' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'generate_sites_nonce' ),
'importing_options' => __( 'Importing options', 'gp-premium' ),
'backing_up_options' => __( 'Backing up options', 'gp-premium' ),
'checking_demo_content' => __( 'Checking demo content', 'gp-premium' ),
'downloading_content' => __( 'Downloading content', 'gp-premium' ),
'importing_content' => __( 'Importing content', 'gp-premium' ),
'importing_site_options' => __( 'Importing site options', 'gp-premium' ),
'importing_widgets' => __( 'Importing widgets', 'gp-premium' ),
'activating_plugins' => __( 'Activating plugins', 'gp-premium' ),
'installing_plugins' => __( 'Installing plugins', 'gp-premium' ),
'automatic_plugins' => __( 'Automatic', 'gp-premium' ),
'manual_plugins' => __( 'Manual', 'gp-premium' ),
'home_url' => home_url(),
'restoreThemeOptions' => __( 'Restoring theme options', 'gp-premium' ),
'restoreSiteOptions' => __( 'Restoring site options', 'gp-premium' ),
'restoreContent' => __( 'Removing imported content', 'gp-premium' ),
'restorePlugins' => __( 'Deactivating imported plugins', 'gp-premium' ),
'restoreWidgets' => __( 'Restoring widgets', 'gp-premium' ),
'restoreCSS' => __( 'Restoring CSS', 'gp-premium' ),
'cleanUp' => __( 'Cleaning up', 'gp-premium' ),
'hasContentBackup' => ! empty( $backup_data['content'] ),
'confirmRemoval' => __( 'This process makes changes to your database. If you have existing data, be sure to create a backup as a precaution.', 'gp-premium' ),
)
);
@ -159,7 +169,7 @@ function generate_sites_do_enqueue_scripts() {
wp_enqueue_style(
'generate-premium-dashboard',
plugin_dir_url( dirname(__FILE__) ) . 'inc/assets/dashboard.css',
plugin_dir_url( dirname( __FILE__ ) ) . 'inc/assets/dashboard.css',
array(),
GP_PREMIUM_VERSION
);
@ -171,7 +181,7 @@ add_filter( 'admin_body_class', 'generate_sites_do_admin_body_classes' );
*
* @since 1.8
*
* @param array Current body classes.
* @param array $classes Current body classes.
* @return array Existing and our new body classes
*/
function generate_sites_do_admin_body_classes( $classes ) {
@ -232,18 +242,19 @@ function generate_sites_container() {
echo '<div class="library-filters">';
if ( ! empty( $page_builders ) ) : ?>
if ( ! empty( $page_builders ) ) :
?>
<div class="page-builder-filter">
<label for="page-builder" class="page-builder-label"><?php _e( 'Page Builder:', 'gp-premium' ); ?></label>
<div class="filter-select">
<select id="page-builder" class="page-builder-group" data-filter-group="page-builder" data-page-builder=".no-page-builder">
<option value="no-page-builder"><?php _e( 'None', 'gp-premium' ); ?></option>
<?php
foreach( $page_builders as $id => $name ) {
foreach ( $page_builders as $id => $name ) {
printf(
'<option value="%1$s">%2$s</option>',
$id,
$name
esc_attr( $id ),
esc_html( $name )
);
}
?>
@ -266,15 +277,15 @@ function generate_sites_container() {
</div>
</div> <!-- .site-library-tabs-wrapper -->
<?php // The opening wrapper for this is in generate_sites_add_tabs_wrapper_open() ?>
<?php // The opening wrapper for this is in generate_sites_add_tabs_wrapper_open(). ?>
<?php
$backup_data = get_option( '_generatepress_site_library_backup', array() );
$show_remove_site = false;
$backup_data = get_option( '_generatepress_site_library_backup', array() );
$show_remove_site = false;
if ( ! empty( $backup_data ) ) {
$show_remove_site = true;
}
if ( ! empty( $backup_data ) ) {
$show_remove_site = true;
}
?>
<div class="remove-site" style="<?php echo ! $show_remove_site ? 'display: none' : ''; ?>">
@ -305,7 +316,7 @@ function generate_sites_container() {
'<div class="refresh-sites">
<a class="button" href="%1$s">%2$s</a>
</div>',
wp_nonce_url( admin_url( 'themes.php?page=generatepress-site-library' ), 'refresh_sites', 'refresh_sites_nonce' ),
esc_url( wp_nonce_url( admin_url( 'themes.php?page=generatepress-site-library' ), 'refresh_sites', 'refresh_sites_nonce' ) ),
__( 'Refresh Sites', 'gp-premium' )
);
?>
@ -340,11 +351,11 @@ function generate_sites_export_page_headers() {
'post_type' => get_post_types( array( 'public' => true ) ),
'showposts' => -1,
'meta_query' => array(
array(
'key' => '_generate-select-page-header',
'compare' => 'EXISTS',
)
)
array(
'key' => '_generate-select-page-header',
'compare' => 'EXISTS',
),
),
);
$posts = get_posts( $args );
@ -354,7 +365,7 @@ function generate_sites_export_page_headers() {
$page_header_id = get_post_meta( $post->ID, '_generate-select-page-header', true );
if ( $page_header_id ) {
$new_values[$post->ID] = $page_header_id;
$new_values[ $post->ID ] = $page_header_id;
}
}
@ -381,7 +392,7 @@ function generate_sites_export_elements_location() {
$display_conditions = get_post_meta( $post->ID, '_generate_element_display_conditions', true );
if ( $display_conditions ) {
$new_values[$post->ID] = $display_conditions;
$new_values[ $post->ID ] = $display_conditions;
}
}
@ -408,7 +419,7 @@ function generate_sites_export_elements_exclusion() {
$display_conditions = get_post_meta( $post->ID, '_generate_element_exclude_conditions', true );
if ( $display_conditions ) {
$new_values[$post->ID] = $display_conditions;
$new_values[ $post->ID ] = $display_conditions;
}
}
@ -497,32 +508,32 @@ add_filter( 'generate_export_data', 'generatepress_sites_do_site_options_export'
*/
function generatepress_sites_do_site_options_export( $data ) {
// Bail if we haven't chosen to export the Site.
if ( ! in_array( 'generatepress-site', $_POST['module_group'] ) ) {
if ( ! in_array( 'generatepress-site', $_POST['module_group'] ) ) { // phpcs:ignore -- No processing happening here.
return $data;
}
// Modules
// Modules.
$modules = generatepress_get_site_premium_modules();
$data['modules'] = array();
foreach ( $modules as $name => $key ) {
if ( 'activated' == get_option( $key ) ) {
if ( 'activated' === get_option( $key ) ) {
$data['modules'][ $name ] = $key;
}
}
// Site options
// Site options.
$data['site_options']['nav_menu_locations'] = get_theme_mod( 'nav_menu_locations' );
$data['site_options']['custom_logo'] = wp_get_attachment_url( get_theme_mod( 'custom_logo' ) );
$data['site_options']['show_on_front'] = get_option( 'show_on_front' );
$data['site_options']['page_on_front'] = get_option( 'page_on_front' );
$data['site_options']['page_for_posts'] = get_option( 'page_for_posts' );
$data['site_options']['custom_logo'] = wp_get_attachment_url( get_theme_mod( 'custom_logo' ) );
$data['site_options']['show_on_front'] = get_option( 'show_on_front' );
$data['site_options']['page_on_front'] = get_option( 'page_on_front' );
$data['site_options']['page_for_posts'] = get_option( 'page_for_posts' );
// Page header
// Page header.
$data['site_options']['page_header_global_locations'] = get_option( 'generate_page_header_global_locations' );
$data['site_options']['page_headers'] = generate_sites_export_page_headers();
// Elements
// Elements.
$data['site_options']['element_locations'] = generate_sites_export_elements_location();
$data['site_options']['element_exclusions'] = generate_sites_export_elements_exclusion();
@ -533,87 +544,90 @@ function generatepress_sites_do_site_options_export( $data ) {
// WooCommerce.
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
$data['site_options']['woocommerce_shop_page_id'] = get_option( 'woocommerce_shop_page_id' );
$data['site_options']['woocommerce_cart_page_id'] = get_option( 'woocommerce_cart_page_id' );
$data['site_options']['woocommerce_checkout_page_id'] = get_option( 'woocommerce_checkout_page_id' );
$data['site_options']['woocommerce_myaccount_page_id'] = get_option( 'woocommerce_myaccount_page_id' );
$data['site_options']['woocommerce_single_image_width'] = get_option( 'woocommerce_single_image_width' );
$data['site_options']['woocommerce_thumbnail_image_width'] = get_option( 'woocommerce_thumbnail_image_width' );
$data['site_options']['woocommerce_thumbnail_cropping'] = get_option( 'woocommerce_thumbnail_cropping' );
$data['site_options']['woocommerce_shop_page_display'] = get_option( 'woocommerce_shop_page_display' );
$data['site_options']['woocommerce_category_archive_display'] = get_option( 'woocommerce_category_archive_display' );
$data['site_options']['woocommerce_default_catalog_orderby'] = get_option( 'woocommerce_default_catalog_orderby' );
$data['site_options']['woocommerce_shop_page_id'] = get_option( 'woocommerce_shop_page_id' );
$data['site_options']['woocommerce_cart_page_id'] = get_option( 'woocommerce_cart_page_id' );
$data['site_options']['woocommerce_checkout_page_id'] = get_option( 'woocommerce_checkout_page_id' );
$data['site_options']['woocommerce_myaccount_page_id'] = get_option( 'woocommerce_myaccount_page_id' );
$data['site_options']['woocommerce_single_image_width'] = get_option( 'woocommerce_single_image_width' );
$data['site_options']['woocommerce_thumbnail_image_width'] = get_option( 'woocommerce_thumbnail_image_width' );
$data['site_options']['woocommerce_thumbnail_cropping'] = get_option( 'woocommerce_thumbnail_cropping' );
$data['site_options']['woocommerce_shop_page_display'] = get_option( 'woocommerce_shop_page_display' );
$data['site_options']['woocommerce_category_archive_display'] = get_option( 'woocommerce_category_archive_display' );
$data['site_options']['woocommerce_default_catalog_orderby'] = get_option( 'woocommerce_default_catalog_orderby' );
}
// Elementor
// Elementor.
if ( is_plugin_active( 'elementor/elementor.php' ) ) {
$data['site_options']['elementor_container_width'] = get_option( 'elementor_container_width' );
$data['site_options']['elementor_cpt_support'] = get_option( 'elementor_cpt_support' );
$data['site_options']['elementor_css_print_method'] = get_option( 'elementor_css_print_method' );
$data['site_options']['elementor_default_generic_fonts'] = get_option( 'elementor_default_generic_fonts' );
$data['site_options']['elementor_disable_color_schemes'] = get_option( 'elementor_disable_color_schemes' );
$data['site_options']['elementor_disable_typography_schemes'] = get_option( 'elementor_disable_typography_schemes' );
$data['site_options']['elementor_editor_break_lines'] = get_option( 'elementor_editor_break_lines' );
$data['site_options']['elementor_exclude_user_roles'] = get_option( 'elementor_exclude_user_roles' );
$data['site_options']['elementor_global_image_lightbox'] = get_option( 'elementor_global_image_lightbox' );
$data['site_options']['elementor_page_title_selector'] = get_option( 'elementor_page_title_selector' );
$data['site_options']['elementor_scheme_color'] = get_option( 'elementor_scheme_color' );
$data['site_options']['elementor_scheme_color-picker'] = get_option( 'elementor_scheme_color-picker' );
$data['site_options']['elementor_scheme_typography'] = get_option( 'elementor_scheme_typography' );
$data['site_options']['elementor_space_between_widgets'] = get_option( 'elementor_space_between_widgets' );
$data['site_options']['elementor_stretched_section_container'] = get_option( 'elementor_stretched_section_container' );
$data['site_options']['elementor_container_width'] = get_option( 'elementor_container_width' );
$data['site_options']['elementor_cpt_support'] = get_option( 'elementor_cpt_support' );
$data['site_options']['elementor_css_print_method'] = get_option( 'elementor_css_print_method' );
$data['site_options']['elementor_default_generic_fonts'] = get_option( 'elementor_default_generic_fonts' );
$data['site_options']['elementor_disable_color_schemes'] = get_option( 'elementor_disable_color_schemes' );
$data['site_options']['elementor_disable_typography_schemes'] = get_option( 'elementor_disable_typography_schemes' );
$data['site_options']['elementor_editor_break_lines'] = get_option( 'elementor_editor_break_lines' );
$data['site_options']['elementor_exclude_user_roles'] = get_option( 'elementor_exclude_user_roles' );
$data['site_options']['elementor_global_image_lightbox'] = get_option( 'elementor_global_image_lightbox' );
$data['site_options']['elementor_page_title_selector'] = get_option( 'elementor_page_title_selector' );
$data['site_options']['elementor_scheme_color'] = get_option( 'elementor_scheme_color' );
$data['site_options']['elementor_scheme_color-picker'] = get_option( 'elementor_scheme_color-picker' );
$data['site_options']['elementor_scheme_typography'] = get_option( 'elementor_scheme_typography' );
$data['site_options']['elementor_space_between_widgets'] = get_option( 'elementor_space_between_widgets' );
$data['site_options']['elementor_stretched_section_container'] = get_option( 'elementor_stretched_section_container' );
}
// Beaver Builder
// Beaver Builder.
if ( is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) || is_plugin_active( 'bb-plugin/fl-builder.php' ) ) {
$data['site_options']['_fl_builder_enabled_icons'] = get_option( '_fl_builder_enabled_icons' );
$data['site_options']['_fl_builder_enabled_modules'] = get_option( '_fl_builder_enabled_modules' );
$data['site_options']['_fl_builder_post_types'] = get_option( '_fl_builder_post_types' );
$data['site_options']['_fl_builder_color_presets'] = get_option( '_fl_builder_color_presets' );
$data['site_options']['_fl_builder_services'] = get_option( '_fl_builder_services' );
$data['site_options']['_fl_builder_settings'] = get_option( '_fl_builder_settings' );
$data['site_options']['_fl_builder_user_access'] = get_option( '_fl_builder_user_access' );
$data['site_options']['_fl_builder_enabled_templates'] = get_option( '_fl_builder_enabled_templates' );
$data['site_options']['_fl_builder_enabled_icons'] = get_option( '_fl_builder_enabled_icons' );
$data['site_options']['_fl_builder_enabled_modules'] = get_option( '_fl_builder_enabled_modules' );
$data['site_options']['_fl_builder_post_types'] = get_option( '_fl_builder_post_types' );
$data['site_options']['_fl_builder_color_presets'] = get_option( '_fl_builder_color_presets' );
$data['site_options']['_fl_builder_services'] = get_option( '_fl_builder_services' );
$data['site_options']['_fl_builder_settings'] = get_option( '_fl_builder_settings' );
$data['site_options']['_fl_builder_user_access'] = get_option( '_fl_builder_user_access' );
$data['site_options']['_fl_builder_enabled_templates'] = get_option( '_fl_builder_enabled_templates' );
}
// Menu Icons
// Menu Icons.
if ( is_plugin_active( 'menu-icons/menu-icons.php' ) ) {
$data['site_options']['menu-icons'] = get_option( 'menu-icons' );
}
// Ninja Forms
// Ninja Forms.
if ( is_plugin_active( 'ninja-forms/ninja-forms.php' ) ) {
$data['site_options']['ninja_forms_settings'] = get_option( 'ninja_forms_settings' );
}
// Social Warfare
// Social Warfare.
if ( is_plugin_active( 'social-warfare/social-warfare.php' ) ) {
$data['site_options']['socialWarfareOptions'] = get_option( 'socialWarfareOptions' );
}
// Elements Plus
// Elements Plus.
if ( is_plugin_active( 'elements-plus/elements-plus.php' ) ) {
$data['site_options']['elements_plus_settings'] = get_option( 'elements_plus_settings' );
}
// Ank Google Map
// Ank Google Map.
if ( is_plugin_active( 'ank-google-map/ank-google-map.php' ) ) {
$data['site_options']['ank_google_map'] = get_option( 'ank_google_map' );
}
// GP Social Share
// GP Social Share.
if ( is_plugin_active( 'gp-social-share-svg/gp-social-share.php' ) ) {
$data['site_options']['gp_social_settings'] = get_option( 'gp_social_settings' );
}
// Active plugins
// Active plugins.
$active_plugins = get_option( 'active_plugins' );
$all_plugins = get_plugins();
$ignore = apply_filters( 'generate_sites_ignore_plugins', array(
'gp-premium/gp-premium.php',
'widget-importer-exporter/widget-importer-exporter.php'
) );
$ignore = apply_filters(
'generate_sites_ignore_plugins',
array(
'gp-premium/gp-premium.php',
'widget-importer-exporter/widget-importer-exporter.php',
)
);
foreach ( $ignore as $plugin ) {
unset( $all_plugins[ $plugin ] );
@ -622,8 +636,8 @@ function generatepress_sites_do_site_options_export( $data ) {
$activated_plugins = array();
foreach ( $active_plugins as $p ) {
if ( isset( $all_plugins[$p] ) ) {
$activated_plugins[$all_plugins[$p]['Name']] = $p;
if ( isset( $all_plugins[ $p ] ) ) {
$activated_plugins[ $all_plugins[ $p ]['Name'] ] = $p;
}
}
@ -664,19 +678,19 @@ function generatepress_sites_init() {
return;
}
foreach( ( array ) $data as $site ) {
$sites[$site['name']] = array(
'name' => $site['name'],
'directory' => $site['directory'],
'preview_url' => $site['preview_url'],
'author_name' => $site['author_name'],
'author_url' => $site['author_url'],
'description' => $site['description'],
'page_builder' => $site['page_builder'],
'min_version' => $site['min_version'],
'uploads_url' => $site['uploads_url'],
'plugins' => $site['plugins'],
'documentation' => $site['documentation'],
foreach ( (array) $data as $site ) {
$sites[ $site['name'] ] = array(
'name' => $site['name'],
'directory' => $site['directory'],
'preview_url' => $site['preview_url'],
'author_name' => $site['author_name'],
'author_url' => $site['author_url'],
'description' => $site['description'],
'page_builder' => $site['page_builder'],
'min_version' => $site['min_version'],
'uploads_url' => $site['uploads_url'],
'plugins' => $site['plugins'],
'documentation' => $site['documentation'],
);
}
@ -696,7 +710,7 @@ function generatepress_sites_init() {
$trusted_authors = json_decode( wp_remote_retrieve_body( $trusted_authors ), true );
$authors = array();
foreach ( ( array ) $trusted_authors['trusted_author'] as $author ) {
foreach ( (array) $trusted_authors['trusted_author'] as $author ) {
$authors[] = $author;
}
@ -724,11 +738,11 @@ function generatepress_sites_output() {
return;
}
if ( apply_filters( 'generate_sites_randomize', true ) ) {
if ( apply_filters( 'generate_sites_randomize', false ) ) {
shuffle( $sites );
}
foreach( $sites as $site ) {
foreach ( $sites as $site ) {
new GeneratePress_Site( $site );
}
}