updated plugin GP Premium
version 1.12.2
This commit is contained in:
@ -830,3 +830,24 @@
|
||||
pointer-events: none;
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
.refresh-sites a:first-child:before {
|
||||
font: normal 20px/.5 dashicons;
|
||||
speak: none;
|
||||
display: inline-block;
|
||||
padding: 0;
|
||||
top: 9px;
|
||||
left: -4px;
|
||||
position: relative;
|
||||
vertical-align: top;
|
||||
content: "\f463";
|
||||
}
|
||||
|
||||
.refresh-sites a:first-child.loading:before {
|
||||
animation: rotation 1s infinite linear;
|
||||
}
|
||||
|
||||
.refresh-sites a:first-child.success:before {
|
||||
content: "\f147";
|
||||
color: #46b450;
|
||||
}
|
||||
|
@ -910,4 +910,20 @@ jQuery( document ).ready( function($) {
|
||||
$( 'body' ).removeClass( 'site-import-content-exists' );
|
||||
$( 'body' ).removeClass( 'site-import-data-exists' );
|
||||
} );
|
||||
|
||||
$( '.refresh-sites a:first-child' ).on( 'click', function( e ) {
|
||||
var $thisButton = $( this ); // eslint-disable-line no-var
|
||||
e.preventDefault();
|
||||
|
||||
$thisButton.removeClass( 'success' ).addClass( 'loading' );
|
||||
|
||||
$.post( ajaxurl, {
|
||||
action: 'generate_sites_refresh_sites',
|
||||
_nonce: $thisButton.data( 'nonce' ),
|
||||
} ).done( function() {
|
||||
$thisButton.removeClass( 'loading' ).addClass( 'success' );
|
||||
$thisButton.hide();
|
||||
$thisButton.next( '.button' ).show();
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
@ -118,6 +118,15 @@ class GeneratePress_Sites_Restore {
|
||||
|
||||
update_option( $key, $val );
|
||||
}
|
||||
|
||||
// Re-add non-theme option related theme mods.
|
||||
if ( isset( $backup_data['site_options']['nav_menu_locations'] ) ) {
|
||||
set_theme_mod( 'nav_menu_locations', $backup_data['site_options']['nav_menu_locations'] );
|
||||
}
|
||||
|
||||
if ( isset( $backup_data['site_options']['custom_logo'] ) ) {
|
||||
set_theme_mod( 'custom_logo', $backup_data['site_options']['custom_logo'] );
|
||||
}
|
||||
}
|
||||
|
||||
wp_send_json( __( 'Theme options restored.', 'gp-premium' ) );
|
||||
@ -148,7 +157,11 @@ class GeneratePress_Sites_Restore {
|
||||
if ( 'nav_menu_locations' === $key || 'custom_logo' === $key ) {
|
||||
set_theme_mod( $key, $val );
|
||||
} else {
|
||||
update_option( $key, $val );
|
||||
if ( ! $val && ! is_numeric( $val ) ) {
|
||||
delete_option( $key );
|
||||
} else {
|
||||
update_option( $key, $val );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -768,9 +768,9 @@ class GeneratePress_Site {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Import any images.
|
||||
if ( is_array( $val ) || is_object( $val ) ) {
|
||||
foreach ( $val as $option_name => $option_value ) {
|
||||
// Import any images.
|
||||
if ( is_string( $option_value ) && preg_match( '/\.(jpg|jpeg|png|gif)/i', $option_value ) ) {
|
||||
$data = GeneratePress_Sites_Helper::sideload_image( $option_value );
|
||||
|
||||
@ -778,12 +778,28 @@ class GeneratePress_Site {
|
||||
$val[ $option_name ] = $data->url;
|
||||
}
|
||||
}
|
||||
|
||||
// Set these options if we import content.
|
||||
unset( $val['hide_title'] );
|
||||
unset( $val['hide_tagline'] );
|
||||
unset( $val['logo_width'] );
|
||||
}
|
||||
}
|
||||
|
||||
update_option( $key, $val );
|
||||
}
|
||||
|
||||
// Re-add non-theme option related theme mods.
|
||||
set_theme_mod( 'nav_menu_locations', $backup_data['site_options']['nav_menu_locations'] );
|
||||
set_theme_mod( 'custom_logo', $backup_data['site_options']['custom_logo'] );
|
||||
|
||||
$existing_settings = get_option( 'generate_settings', array() );
|
||||
$existing_settings['hide_title'] = $backup_data['theme_options']['options']['generate_settings']['hide_title'];
|
||||
$existing_settings['hide_tagline'] = $backup_data['theme_options']['options']['generate_settings']['hide_tagline'];
|
||||
$existing_settings['logo_width'] = $backup_data['theme_options']['options']['generate_settings']['logo_width'];
|
||||
|
||||
update_option( 'generate_settings', $existing_settings );
|
||||
|
||||
// Remove dynamic CSS cache.
|
||||
delete_option( 'generate_dynamic_css_output' );
|
||||
delete_option( 'generate_dynamic_css_cached_version' );
|
||||
@ -1002,6 +1018,51 @@ class GeneratePress_Site {
|
||||
}
|
||||
}
|
||||
|
||||
// Set theme options.
|
||||
$theme_settings = get_option( 'generate_settings', array() );
|
||||
$update_theme_settings = false;
|
||||
|
||||
foreach ( $settings['options'] as $key => $val ) {
|
||||
if ( 'generate_settings' !== $key ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_array( $val ) || is_object( $val ) ) {
|
||||
foreach ( $val as $option_name => $option_value ) {
|
||||
if ( 'hide_title' === $option_name ) {
|
||||
$theme_settings['hide_title'] = $option_value;
|
||||
$update_theme_settings = true;
|
||||
}
|
||||
|
||||
if ( 'hide_tagline' === $option_name ) {
|
||||
$theme_settings['hide_tagline'] = $option_value;
|
||||
$update_theme_settings = true;
|
||||
}
|
||||
|
||||
if ( 'logo_width' === $option_name ) {
|
||||
$theme_settings['logo_width'] = $option_value;
|
||||
$update_theme_settings = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $update_theme_settings ) {
|
||||
update_option( 'generate_settings', $theme_settings );
|
||||
|
||||
// Remove dynamic CSS cache.
|
||||
delete_option( 'generate_dynamic_css_output' );
|
||||
delete_option( 'generate_dynamic_css_cached_version' );
|
||||
|
||||
$dynamic_css_data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
|
||||
if ( isset( $dynamic_css_data['updated_time'] ) ) {
|
||||
unset( $dynamic_css_data['updated_time'] );
|
||||
}
|
||||
|
||||
update_option( 'generatepress_dynamic_css_data', $dynamic_css_data );
|
||||
}
|
||||
|
||||
// Set our backed up options.
|
||||
update_option( '_generatepress_site_library_backup', $backup_data );
|
||||
|
||||
|
@ -323,6 +323,17 @@ class WXRImporter extends \WP_Importer {
|
||||
add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) );
|
||||
add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) );
|
||||
|
||||
/*
|
||||
* Elementor fix for excessive use of `wp_slash` after our update v3.0.2.
|
||||
* Method in Elementor: \Elementor\Compatibility::register_actions
|
||||
* https://wordpress.org/support/topic/version-2-6-0-breaks-every-elementor-theme/
|
||||
*
|
||||
* This can be removed after Elementor skips the functionality in above method if our plugin is in use.
|
||||
*/
|
||||
if ( method_exists( '\Elementor\Compatibility', 'on_wxr_importer_pre_process_post_meta' ) ) {
|
||||
remove_action( 'wxr_importer.pre_process.post_meta', array( 'Elementor\Compatibility', 'on_wxr_importer_pre_process_post_meta' ) );
|
||||
}
|
||||
|
||||
$result = $this->import_start( $file );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
return $result;
|
||||
@ -843,7 +854,7 @@ class WXRImporter extends \WP_Importer {
|
||||
$postdata[ $key ] = $data[ $key ];
|
||||
}
|
||||
|
||||
$postdata = apply_filters( 'wp_import_post_data_processed', $postdata, $data );
|
||||
$postdata = apply_filters( 'wp_import_post_data_processed', wp_slash( $postdata ), $data );
|
||||
|
||||
if ( 'attachment' === $postdata['post_type'] ) {
|
||||
if ( ! $this->options['fetch_attachments'] ) {
|
||||
@ -1170,7 +1181,12 @@ class WXRImporter extends \WP_Importer {
|
||||
$value = maybe_unserialize( $meta_item['value'] );
|
||||
}
|
||||
|
||||
add_post_meta( $post_id, $key, $value );
|
||||
if ( function_exists( 'wp_slash_strings_only' ) ) {
|
||||
add_post_meta( $post_id, wp_slash( $key ), wp_slash_strings_only( $value ) );
|
||||
} else {
|
||||
add_post_meta( $post_id, $key, $value );
|
||||
}
|
||||
|
||||
do_action( 'import_post_meta', $post_id, $key, $value );
|
||||
|
||||
// if the post has a featured image, take note of this in case of remap
|
||||
|
@ -261,18 +261,9 @@ function generate_sites_container() {
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<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>
|
||||
<option value="beaver-builder"><?php _e( 'Beaver Builder', 'gp-premium' ); ?></option>
|
||||
<option value="elementor"><?php _e( 'Elementor', 'gp-premium' ); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
@ -314,10 +305,13 @@ function generate_sites_container() {
|
||||
<?php
|
||||
printf(
|
||||
'<div class="refresh-sites">
|
||||
<a class="button" href="%1$s">%2$s</a>
|
||||
<a data-nonce="%1$s" class="button" href="#">%2$s</a>
|
||||
<a class="button button-primary" href="%3$s" style="display: none;">%4$s</a>
|
||||
</div>',
|
||||
esc_url( wp_nonce_url( admin_url( 'themes.php?page=generatepress-site-library' ), 'refresh_sites', 'refresh_sites_nonce' ) ),
|
||||
__( 'Refresh Sites', 'gp-premium' )
|
||||
esc_html( wp_create_nonce( 'refresh_sites_nonce' ) ),
|
||||
__( 'Refresh Sites', 'gp-premium' ),
|
||||
esc_url( admin_url( 'themes.php?page=generatepress-site-library' ) ),
|
||||
__( 'Reload Page', 'gp-premium' )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
@ -325,18 +319,21 @@ function generate_sites_container() {
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'generate_sites_refresh_list', 2 );
|
||||
add_action( 'wp_ajax_generate_sites_refresh_sites', 'generate_sites_do_refresh_list' );
|
||||
/**
|
||||
* Delete our sites transient if the Refresh sites link is clicked.
|
||||
*
|
||||
* @since 1.6
|
||||
* Refresh our list of sites.
|
||||
*/
|
||||
function generate_sites_refresh_list() {
|
||||
if ( ! isset( $_GET['refresh_sites_nonce'] ) || ! wp_verify_nonce( $_GET['refresh_sites_nonce'], 'refresh_sites' ) ) {
|
||||
return;
|
||||
function generate_sites_do_refresh_list() {
|
||||
check_ajax_referer( 'refresh_sites_nonce', '_nonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'Security check failed.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
delete_transient( 'generatepress_sites' );
|
||||
generate_get_sites_from_library();
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -487,6 +484,9 @@ add_action( 'generate_export_items', 'generatepress_sites_add_export_checkbox' )
|
||||
* @since 1.7
|
||||
*/
|
||||
function generatepress_sites_add_export_checkbox() {
|
||||
if ( ! apply_filters( 'generate_show_generatepress_site_export_option', false ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<hr style="margin:10px 0;border-bottom:0;" />
|
||||
|
||||
@ -573,6 +573,8 @@ function generatepress_sites_do_site_options_export( $data ) {
|
||||
$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_load_fa4_shim'] = get_option( 'elementor_load_fa4_shim' );
|
||||
$data['site_options']['elementor_active_kit'] = get_option( 'elementor_active_kit' );
|
||||
}
|
||||
|
||||
// Beaver Builder.
|
||||
@ -647,6 +649,72 @@ function generatepress_sites_do_site_options_export( $data ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our sites from the site server.
|
||||
*
|
||||
* @since 1.12.0
|
||||
*/
|
||||
function generate_get_sites_from_library() {
|
||||
$remote_sites = get_transient( 'generatepress_sites' );
|
||||
$trusted_authors = get_transient( 'generatepress_sites_trusted_providers' );
|
||||
|
||||
if ( empty( $remote_sites ) ) {
|
||||
$sites = array();
|
||||
|
||||
$data = wp_safe_remote_get( 'https://gpsites.co/wp-json/wp/v2/sites?per_page=100' );
|
||||
|
||||
if ( is_wp_error( $data ) ) {
|
||||
set_transient( 'generatepress_sites', 'no results', 5 * MINUTE_IN_SECONDS );
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_decode( wp_remote_retrieve_body( $data ), true );
|
||||
|
||||
if ( ! is_array( $data ) ) {
|
||||
set_transient( 'generatepress_sites', 'no results', 5 * MINUTE_IN_SECONDS );
|
||||
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'],
|
||||
);
|
||||
}
|
||||
|
||||
$sites = apply_filters( 'generate_add_sites', $sites );
|
||||
|
||||
set_transient( 'generatepress_sites', $sites, 24 * HOUR_IN_SECONDS );
|
||||
}
|
||||
|
||||
if ( empty( $trusted_authors ) ) {
|
||||
$trusted_authors = wp_safe_remote_get( 'https://gpsites.co/wp-json/sites/site' );
|
||||
|
||||
if ( is_wp_error( $trusted_authors ) || empty( $trusted_authors ) ) {
|
||||
set_transient( 'generatepress_sites_trusted_providers', 'no results', 5 * MINUTE_IN_SECONDS );
|
||||
return;
|
||||
}
|
||||
|
||||
$trusted_authors = json_decode( wp_remote_retrieve_body( $trusted_authors ), true );
|
||||
|
||||
$authors = array();
|
||||
foreach ( (array) $trusted_authors['trusted_author'] as $author ) {
|
||||
$authors[] = $author;
|
||||
}
|
||||
|
||||
set_transient( 'generatepress_sites_trusted_providers', $authors, 24 * HOUR_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'current_screen', 'generatepress_sites_init', 5 );
|
||||
/**
|
||||
* Fetch our sites and trusted authors. Stores them in their own transients.
|
||||
@ -658,64 +726,7 @@ function generatepress_sites_init() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( 'appearance_page_generate-options' === $screen->id || 'appearance_page_generatepress-site-library' === $screen->id ) {
|
||||
$remote_sites = get_transient( 'generatepress_sites' );
|
||||
$trusted_authors = get_transient( 'generatepress_sites_trusted_providers' );
|
||||
|
||||
if ( empty( $remote_sites ) ) {
|
||||
$sites = array();
|
||||
|
||||
$data = wp_safe_remote_get( 'https://gpsites.co/wp-json/wp/v2/sites?per_page=100' );
|
||||
|
||||
if ( is_wp_error( $data ) ) {
|
||||
set_transient( 'generatepress_sites', 'no results', 5 * MINUTE_IN_SECONDS );
|
||||
return;
|
||||
}
|
||||
|
||||
$data = json_decode( wp_remote_retrieve_body( $data ), true );
|
||||
|
||||
if ( ! is_array( $data ) ) {
|
||||
set_transient( 'generatepress_sites', 'no results', 5 * MINUTE_IN_SECONDS );
|
||||
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'],
|
||||
);
|
||||
}
|
||||
|
||||
$sites = apply_filters( 'generate_add_sites', $sites );
|
||||
|
||||
set_transient( 'generatepress_sites', $sites, 24 * HOUR_IN_SECONDS );
|
||||
}
|
||||
|
||||
if ( empty( $trusted_authors ) ) {
|
||||
$trusted_authors = wp_safe_remote_get( 'https://gpsites.co/wp-json/sites/site' );
|
||||
|
||||
if ( is_wp_error( $trusted_authors ) || empty( $trusted_authors ) ) {
|
||||
set_transient( 'generatepress_sites_trusted_providers', 'no results', 5 * MINUTE_IN_SECONDS );
|
||||
return;
|
||||
}
|
||||
|
||||
$trusted_authors = json_decode( wp_remote_retrieve_body( $trusted_authors ), true );
|
||||
|
||||
$authors = array();
|
||||
foreach ( (array) $trusted_authors['trusted_author'] as $author ) {
|
||||
$authors[] = $author;
|
||||
}
|
||||
|
||||
set_transient( 'generatepress_sites_trusted_providers', $authors, 24 * HOUR_IN_SECONDS );
|
||||
}
|
||||
generate_get_sites_from_library();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user