updated plugin GP Premium
version 1.11.2
This commit is contained in:
@ -281,10 +281,7 @@
|
||||
}
|
||||
|
||||
.lazyload{
|
||||
-webkit-transition: opacity 500ms ease-in-out;
|
||||
-moz-transition: opacity 500ms ease-in-out;
|
||||
-o-transition: opacity 500ms ease-in-out;
|
||||
transition: opacity 500ms ease-in-out;
|
||||
transition: opacity 500ms ease-in-out;
|
||||
max-width: 100%;
|
||||
opacity: 0;
|
||||
}
|
||||
|
@ -1,4 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles Beaver Builder functionality during import.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Beaver Builder content for images to download.
|
||||
*
|
||||
@ -47,9 +57,7 @@ class GeneratePress_Sites_Process_Beaver_Builder {
|
||||
$data = get_post_meta( $post_id, '_fl_builder_data', true );
|
||||
|
||||
if ( ! empty( $data ) ) {
|
||||
|
||||
foreach ( $data as $key => $el ) {
|
||||
|
||||
// Import background images.
|
||||
if ( 'row' === $el->type || 'column' === $el->type ) {
|
||||
$data[ $key ]->settings = $this->import_background_images( $el->settings );
|
||||
@ -59,7 +67,6 @@ class GeneratePress_Sites_Process_Beaver_Builder {
|
||||
if ( 'module' === $el->type ) {
|
||||
$data[ $key ]->settings = $this->import_module_images( $el->settings );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Update page builder data.
|
||||
|
@ -1,5 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* This file extends the Content Importer.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Extend the Importer.
|
||||
*/
|
||||
class GeneratePress_Sites_Content_Importer extends GeneratePress\WPContentImporter2\WXRImporter {
|
||||
/**
|
||||
* Constructor method.
|
||||
@ -20,7 +32,7 @@ class GeneratePress_Sites_Content_Importer extends GeneratePress\WPContentImport
|
||||
*/
|
||||
public function get_importer_data() {
|
||||
return array(
|
||||
'mapping' => $this->mapping
|
||||
'mapping' => $this->mapping,
|
||||
);
|
||||
}
|
||||
|
||||
@ -30,7 +42,8 @@ class GeneratePress_Sites_Content_Importer extends GeneratePress\WPContentImport
|
||||
* @param array $data with set variables.
|
||||
*/
|
||||
public function set_importer_data( $data ) {
|
||||
//$this->mapping = empty( $data['mapping'] ) ? array() : $data['mapping'];
|
||||
//$this->requires_remapping = empty( $data['requires_remapping'] ) ? array() : $data['requires_remapping'];
|
||||
// phpcs:ignore -- Commented out code for now.
|
||||
// $this->mapping = empty( $data['mapping'] ) ? array() : $data['mapping'];
|
||||
// $this->requires_remapping = empty( $data['requires_remapping'] ) ? array() : $data['requires_remapping'];
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,17 @@
|
||||
<?php
|
||||
defined( 'WPINC' ) or die;
|
||||
/**
|
||||
* This file has helper functions for the Site Library.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Site Library helper class.
|
||||
*/
|
||||
class GeneratePress_Sites_Helper {
|
||||
|
||||
/**
|
||||
@ -29,12 +40,15 @@ class GeneratePress_Sites_Helper {
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self;
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get it going.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'upload_mimes', array( $this, 'mime_types' ) );
|
||||
add_filter( 'wp_check_filetype_and_ext', array( $this, 'check_real_mime_type' ), 10, 4 );
|
||||
@ -62,7 +76,7 @@ class GeneratePress_Sites_Helper {
|
||||
*/
|
||||
public static function includes() {
|
||||
|
||||
// Content Importer
|
||||
// Content Importer.
|
||||
if ( ! class_exists( 'WP_Importer' ) ) {
|
||||
require ABSPATH . '/wp-admin/includes/class-wp-importer.php';
|
||||
}
|
||||
@ -74,12 +88,20 @@ class GeneratePress_Sites_Helper {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mapped term IDs.
|
||||
*/
|
||||
public static function get_mapped_term_ids() {
|
||||
return ( array ) get_transient( 'generatepress_sites_mapped_term_ids' );
|
||||
return (array) get_transient( 'generatepress_sites_mapped_term_ids' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mapped post IDs.
|
||||
*
|
||||
* @param string $slug The slug of the post.
|
||||
*/
|
||||
public static function get_mapped_post_ids( $slug ) {
|
||||
return ( array ) get_option( "generatepress_sites_mapped_ids_{$slug}", array() );
|
||||
return (array) get_option( "generatepress_sites_mapped_ids_{$slug}", array() );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,12 +153,12 @@ class GeneratePress_Sites_Helper {
|
||||
|
||||
$has_data = array(
|
||||
'mods' => array(),
|
||||
'options' => array()
|
||||
'options' => array(),
|
||||
);
|
||||
|
||||
foreach ( $theme_mods as $theme_mod ) {
|
||||
if ( get_theme_mod( $theme_mod ) ) {
|
||||
$has_data['mods'][$theme_mod] = get_theme_mod( $theme_mod );
|
||||
$has_data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +182,7 @@ class GeneratePress_Sites_Helper {
|
||||
}
|
||||
}
|
||||
|
||||
$has_data['options'][$setting] = get_option( $setting );
|
||||
$has_data['options'][ $setting ] = get_option( $setting );
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,11 +197,11 @@ class GeneratePress_Sites_Helper {
|
||||
* Imports our content and custom CSS.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $path Path to the file.
|
||||
* @param string $slug File slug.
|
||||
*/
|
||||
public static function import_xml( $path, $slug ) {
|
||||
$options = array(
|
||||
$options = array(
|
||||
'fetch_attachments' => true,
|
||||
'default_author' => 0,
|
||||
);
|
||||
@ -211,9 +233,6 @@ class GeneratePress_Sites_Helper {
|
||||
|
||||
// Page builders need so much extra work.
|
||||
self::update_page_builder_content();
|
||||
|
||||
// Log our content
|
||||
//self::log( $logger );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,11 +246,14 @@ class GeneratePress_Sites_Helper {
|
||||
* @return array
|
||||
*/
|
||||
public static function check_for_pro_plugins() {
|
||||
return apply_filters( 'generate_sites_pro_plugins', array(
|
||||
'beaver-builder-lite-version/fl-builder.php' => 'bb-plugin/fl-builder.php',
|
||||
'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
||||
'powerpack-addon-for-beaver-builder/bb-powerpack-lite.php' => 'bbpowerpack/bb-powerpack.php',
|
||||
) );
|
||||
return apply_filters(
|
||||
'generate_sites_pro_plugins',
|
||||
array(
|
||||
'beaver-builder-lite-version/fl-builder.php' => 'bb-plugin/fl-builder.php',
|
||||
'ultimate-addons-for-beaver-builder-lite/bb-ultimate-addon.php' => 'bb-ultimate-addon/bb-ultimate-addon.php',
|
||||
'powerpack-addon-for-beaver-builder/bb-powerpack-lite.php' => 'bbpowerpack/bb-powerpack.php',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,14 +261,14 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param string $plugin
|
||||
* @param string $plugin The plugin to check for.
|
||||
*/
|
||||
public static function is_plugin_installed( $plugin ) {
|
||||
$pro_plugins = self::check_for_pro_plugins();
|
||||
|
||||
// Check to see if this plugin has a pro version.
|
||||
if ( array_key_exists( $plugin, $pro_plugins ) ) {
|
||||
if ( file_exists( WP_PLUGIN_DIR . '/' . $pro_plugins[$plugin] ) ) {
|
||||
if ( file_exists( WP_PLUGIN_DIR . '/' . $pro_plugins[ $plugin ] ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -264,9 +286,9 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param array $response Attachment response.
|
||||
* @param array $response Attachment response.
|
||||
* @param object $attachment Attachment object.
|
||||
* @param array $meta Attachment meta data.
|
||||
* @param array $meta Attachment meta data.
|
||||
*/
|
||||
public static function add_svg_image_support( $response, $attachment, $meta ) {
|
||||
if ( ! function_exists( 'simplexml_load_file' ) ) {
|
||||
@ -337,9 +359,9 @@ class GeneratePress_Sites_Helper {
|
||||
$data = new stdClass();
|
||||
|
||||
if ( ! function_exists( 'media_handle_sideload' ) ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/media.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
||||
require_once ABSPATH . 'wp-admin/includes/media.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/image.php';
|
||||
}
|
||||
|
||||
if ( ! empty( $file ) ) {
|
||||
@ -362,22 +384,22 @@ class GeneratePress_Sites_Helper {
|
||||
|
||||
// If error storing permanently, unlink.
|
||||
if ( is_wp_error( $id ) ) {
|
||||
@unlink( $file_array['tmp_name'] );
|
||||
@unlink( $file_array['tmp_name'] ); // phpcs:ignore
|
||||
return $id;
|
||||
}
|
||||
|
||||
// Build the object to return.
|
||||
$meta = wp_get_attachment_metadata( $id );
|
||||
$data->attachment_id = $id;
|
||||
$data->url = wp_get_attachment_url( $id );
|
||||
$data->thumbnail_url = wp_get_attachment_thumb_url( $id );
|
||||
$meta = wp_get_attachment_metadata( $id );
|
||||
$data->attachment_id = $id;
|
||||
$data->url = wp_get_attachment_url( $id );
|
||||
$data->thumbnail_url = wp_get_attachment_thumb_url( $id );
|
||||
|
||||
if ( isset( $meta['height'] ) ) {
|
||||
$data->height = $meta['height'];
|
||||
$data->height = $meta['height'];
|
||||
}
|
||||
|
||||
if ( isset( $meta['width'] ) ) {
|
||||
$data->width = $meta['width'];
|
||||
$data->width = $meta['width'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,7 +412,7 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param array Incoming locations.
|
||||
* @param array $locations Incoming locations.
|
||||
*/
|
||||
public static function set_nav_menu_locations( $locations = array() ) {
|
||||
$menu_locations = array();
|
||||
@ -405,8 +427,8 @@ class GeneratePress_Sites_Helper {
|
||||
continue;
|
||||
}
|
||||
|
||||
$menu_locations[$menu] = $term_ids[$value];
|
||||
self::log( $value . ' -> ' . $term_ids[$value] );
|
||||
$menu_locations[ $menu ] = $term_ids[ $value ];
|
||||
self::log( $value . ' -> ' . $term_ids[ $value ] );
|
||||
}
|
||||
|
||||
set_theme_mod( 'nav_menu_locations', $menu_locations );
|
||||
@ -418,7 +440,8 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param array Incoming locations.
|
||||
* @param array $locations Incoming locations.
|
||||
* @param string $slug Page Header slug.
|
||||
*/
|
||||
public static function set_global_page_header_locations( $locations = array(), $slug ) {
|
||||
$new_locations = array();
|
||||
@ -428,13 +451,13 @@ class GeneratePress_Sites_Helper {
|
||||
if ( isset( $locations ) && ! empty( $locations ) ) {
|
||||
self::log( '== Start mapping global page headers ==' );
|
||||
|
||||
foreach( $locations as $key => $value ) {
|
||||
foreach ( $locations as $key => $value ) {
|
||||
if ( empty( $value ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$new_locations[$key] = $post_ids[$value];
|
||||
self::log( $value . ' -> ' . $post_ids[$value] );
|
||||
$new_locations[ $key ] = $post_ids[ $value ];
|
||||
self::log( $value . ' -> ' . $post_ids[ $value ] );
|
||||
}
|
||||
|
||||
update_option( 'generate_page_header_global_locations', $new_locations );
|
||||
@ -446,7 +469,8 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param array Incoming locations.
|
||||
* @param array $headers Incoming locations.
|
||||
* @param string $slug Post slug.
|
||||
*/
|
||||
public static function set_page_headers( $headers = array(), $slug ) {
|
||||
$new_headers = array();
|
||||
@ -457,8 +481,8 @@ class GeneratePress_Sites_Helper {
|
||||
self::log( '== Start mapping individual page headers ==' );
|
||||
|
||||
foreach ( $headers as $post_id => $header_id ) {
|
||||
update_post_meta( $post_ids[$post_id], '_generate-select-page-header', $post_ids[$header_id] );
|
||||
self::log( $header_id . ' -> ' . $post_ids[$header_id] );
|
||||
update_post_meta( $post_ids[ $post_id ], '_generate-select-page-header', $post_ids[ $header_id ] );
|
||||
self::log( $header_id . ' -> ' . $post_ids[ $header_id ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -468,8 +492,9 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param string Name of the option to update.
|
||||
* @param string Title of the page.
|
||||
* @param string $name Name of the option to update.
|
||||
* @param string $value Title of the page.
|
||||
* @param string $slug Slug of the page.
|
||||
*/
|
||||
public static function set_reading_pages( $name, $value, $slug ) {
|
||||
if ( empty( $value ) ) {
|
||||
@ -481,8 +506,8 @@ class GeneratePress_Sites_Helper {
|
||||
// Get import data, with new menu IDs.
|
||||
$post_ids = self::get_mapped_post_ids( $slug );
|
||||
|
||||
update_option( $name, $post_ids[$value] );
|
||||
self::log( $value . ' -> ' . $post_ids[$value] );
|
||||
update_option( $name, $post_ids[ $value ] );
|
||||
self::log( $value . ' -> ' . $post_ids[ $value ] );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -490,8 +515,9 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param string Name of the option to update.
|
||||
* @param string Title of the page.
|
||||
* @param string $name Name of the option to update.
|
||||
* @param string $value Title of the page.
|
||||
* @param string $slug Slug of the page.
|
||||
*/
|
||||
public static function set_woocommerce_pages( $name, $value, $slug ) {
|
||||
if ( empty( $value ) ) {
|
||||
@ -502,8 +528,8 @@ class GeneratePress_Sites_Helper {
|
||||
|
||||
$post_ids = self::get_mapped_post_ids( $slug );
|
||||
|
||||
update_option( $name, $post_ids[$value] );
|
||||
self::log( $value . ' -> ' . $post_ids[$value] );
|
||||
update_option( $name, $post_ids[ $value ] );
|
||||
self::log( $value . ' -> ' . $post_ids[ $value ] );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -540,7 +566,8 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array Incoming locations.
|
||||
* @param array $locations Incoming locations.
|
||||
* @param string $slug Element slug.
|
||||
*/
|
||||
public static function set_element_locations( $locations = array(), $slug ) {
|
||||
$post_ids = self::get_mapped_post_ids( $slug );
|
||||
@ -548,22 +575,22 @@ class GeneratePress_Sites_Helper {
|
||||
if ( isset( $locations ) && ! empty( $locations ) ) {
|
||||
self::log( '== Start mapping element locations ==' );
|
||||
|
||||
foreach( $locations as $key => $value ) {
|
||||
foreach ( $locations as $key => $value ) {
|
||||
$new_locations = array();
|
||||
if ( empty( $value ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( ( array ) $value as $data ) {
|
||||
foreach ( (array) $value as $data ) {
|
||||
if ( $data['object'] ) {
|
||||
self::log( $data['object'] . ' -> ' . $post_ids[$data['object']] );
|
||||
$data['object'] = $post_ids[$data['object']];
|
||||
self::log( $data['object'] . ' -> ' . $post_ids[ $data['object'] ] );
|
||||
$data['object'] = $post_ids[ $data['object'] ];
|
||||
}
|
||||
|
||||
$new_locations[] = $data;
|
||||
}
|
||||
|
||||
update_post_meta( $post_ids[$key], '_generate_element_display_conditions', $new_locations );
|
||||
update_post_meta( $post_ids[ $key ], '_generate_element_display_conditions', $new_locations );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -573,7 +600,8 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array Incoming locations.
|
||||
* @param array $locations Incoming locations.
|
||||
* @param string $slug Element slug.
|
||||
*/
|
||||
public static function set_element_exclusions( $locations = array(), $slug ) {
|
||||
$post_ids = self::get_mapped_post_ids( $slug );
|
||||
@ -581,22 +609,22 @@ class GeneratePress_Sites_Helper {
|
||||
if ( isset( $locations ) && ! empty( $locations ) ) {
|
||||
self::log( '== Start mapping element exclusions ==' );
|
||||
|
||||
foreach( $locations as $key => $value ) {
|
||||
foreach ( $locations as $key => $value ) {
|
||||
$new_locations = array();
|
||||
if ( empty( $value ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ( ( array ) $value as $data ) {
|
||||
foreach ( (array) $value as $data ) {
|
||||
if ( $data['object'] ) {
|
||||
self::log( $data['object'] . ' -> ' . $post_ids[$data['object']] );
|
||||
$data['object'] = $post_ids[$data['object']];
|
||||
self::log( $data['object'] . ' -> ' . $post_ids[ $data['object'] ] );
|
||||
$data['object'] = $post_ids[ $data['object'] ];
|
||||
}
|
||||
|
||||
$new_locations[] = $data;
|
||||
}
|
||||
|
||||
update_post_meta( $post_ids[$key], '_generate_element_exclude_conditions', $new_locations );
|
||||
update_post_meta( $post_ids[ $key ], '_generate_element_exclude_conditions', $new_locations );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -605,16 +633,15 @@ class GeneratePress_Sites_Helper {
|
||||
* Update menu URLs.
|
||||
*
|
||||
* @since 1.7.3
|
||||
*
|
||||
* @param string Preview URL
|
||||
* @param string $url Preview URL.
|
||||
*/
|
||||
public static function update_menu_urls( $url ) {
|
||||
$args = array (
|
||||
'post_type' => 'nav_menu_item',
|
||||
'fields' => 'ids',
|
||||
$args = array(
|
||||
'post_type' => 'nav_menu_item',
|
||||
'fields' => 'ids',
|
||||
'no_found_rows' => true,
|
||||
'post_status' => 'any',
|
||||
'numberposts' => 50,
|
||||
'post_status' => 'any',
|
||||
'numberposts' => 50,
|
||||
);
|
||||
|
||||
$items = get_posts( $args );
|
||||
@ -639,16 +666,17 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param array Existing types.
|
||||
* @param array $mimes Existing types.
|
||||
* @return array Merged types.
|
||||
*/
|
||||
public static function mime_types( $mimes ) {
|
||||
$mimes = array_merge(
|
||||
$mimes, array(
|
||||
$mimes,
|
||||
array(
|
||||
'xml' => 'text/xml',
|
||||
'wie' => 'text/plain',
|
||||
'svg' => 'image/svg+xml',
|
||||
'svgz' => 'image/svg+xml'
|
||||
'svgz' => 'image/svg+xml',
|
||||
)
|
||||
);
|
||||
|
||||
@ -662,12 +690,10 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.8
|
||||
*
|
||||
* @param array $wp_check_filetype_and_ext File data array containing 'ext', 'type', and
|
||||
* 'proper_filename' keys.
|
||||
* @param string $file Full path to the file.
|
||||
* @param string $filename The name of the file (may differ from $file due to
|
||||
* $file being in a tmp directory).
|
||||
* @param array $mimes Key is the file extension with value as the mime type.
|
||||
* @param array $defaults Default file types.
|
||||
* @param string $file Full path to the file.
|
||||
* @param string $filename The name of the file (may differ from $file due to $file being in a tmp directory).
|
||||
* @param array $mimes Key is the file extension with value as the mime type.
|
||||
*/
|
||||
public static function check_real_mime_type( $defaults, $file, $filename, $mimes ) {
|
||||
if ( 'content.xml' === $filename ) {
|
||||
@ -688,30 +714,30 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param string URL of the file.
|
||||
* @param string $file URL of the file.
|
||||
* @return array
|
||||
*/
|
||||
public static function download_file( $file ) {
|
||||
// Gives us access to the download_url() and wp_handle_sideload() functions
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
// Gives us access to the download_url() and wp_handle_sideload() functions.
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
// URL to the WordPress logo
|
||||
// URL to the WordPress logo.
|
||||
$url = $file;
|
||||
$timeout_seconds = 10;
|
||||
|
||||
// Download file to temp dir
|
||||
// Download file to temp dir.
|
||||
$temp_file = download_url( $url, $timeout_seconds );
|
||||
|
||||
if ( is_wp_error( $temp_file ) ) {
|
||||
|
||||
return array(
|
||||
'success' => false,
|
||||
'data' => $temp_file->get_error_message()
|
||||
'data' => $temp_file->get_error_message(),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Array based on $_FILE as seen in PHP file uploads
|
||||
// Array based on $_FILE as seen in PHP file uploads.
|
||||
$file = array(
|
||||
'name' => basename( $url ),
|
||||
'tmp_name' => $temp_file,
|
||||
@ -724,7 +750,7 @@ class GeneratePress_Sites_Helper {
|
||||
'test_size' => true,
|
||||
);
|
||||
|
||||
// Move the temporary file into the uploads directory
|
||||
// Move the temporary file into the uploads directory.
|
||||
$results = wp_handle_sideload( $file, $overrides );
|
||||
|
||||
if ( empty( $results['error'] ) ) {
|
||||
@ -750,7 +776,7 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param string URL of the file.
|
||||
* @param string $url URL of the file.
|
||||
* @return array
|
||||
*/
|
||||
public static function get_options( $url ) {
|
||||
@ -768,7 +794,7 @@ class GeneratePress_Sites_Helper {
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param string URL of the file.
|
||||
* @param string $url URL of the file.
|
||||
* @return bool
|
||||
*/
|
||||
public static function file_exists( $url ) {
|
||||
@ -779,7 +805,7 @@ class GeneratePress_Sites_Helper {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strlen( $response['body'] ) > 100 && ( '200' == $response['response']['code'] || '301' == $response['response']['code'] ) ? true : false;
|
||||
return strlen( $response['body'] ) > 100 && ( '200' === (string) $response['response']['code'] || '301' === (string) $response['response']['code'] ) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -795,9 +821,9 @@ class GeneratePress_Sites_Helper {
|
||||
}
|
||||
|
||||
if ( is_array( $log ) || is_object( $log ) ) {
|
||||
error_log( print_r( $log, true ) );
|
||||
error_log( print_r( $log, true ) ); // phpcs:ignore -- Needed to log events.
|
||||
} else {
|
||||
error_log( $log );
|
||||
error_log( $log ); // phpcs:ignore -- Needed to log events.
|
||||
}
|
||||
}
|
||||
|
||||
@ -814,18 +840,18 @@ class GeneratePress_Sites_Helper {
|
||||
'fields' => 'ids',
|
||||
'no_found_rows' => true,
|
||||
'post_status' => 'publish',
|
||||
'numberposts' => -1,
|
||||
'numberposts' => -1,
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => '_fl_builder_data',
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => '_elementor_data',
|
||||
'compare' => 'EXISTS',
|
||||
)
|
||||
)
|
||||
'key' => '_fl_builder_data',
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
array(
|
||||
'key' => '_elementor_data',
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$posts = get_posts( $args );
|
||||
@ -948,40 +974,16 @@ class GeneratePress_Sites_Helper {
|
||||
public static function loading_icon() {
|
||||
?>
|
||||
<svg width="44" height="44" viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg" stroke="#000">
|
||||
<g fill="none" fill-rule="evenodd" stroke-width="2">
|
||||
<circle cx="22" cy="22" r="1">
|
||||
<animate attributeName="r"
|
||||
begin="0s" dur="1.8s"
|
||||
values="1; 20"
|
||||
calcMode="spline"
|
||||
keyTimes="0; 1"
|
||||
keySplines="0.165, 0.84, 0.44, 1"
|
||||
repeatCount="indefinite" />
|
||||
<animate attributeName="stroke-opacity"
|
||||
begin="0s" dur="1.8s"
|
||||
values="1; 0"
|
||||
calcMode="spline"
|
||||
keyTimes="0; 1"
|
||||
keySplines="0.3, 0.61, 0.355, 1"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
<circle cx="22" cy="22" r="1">
|
||||
<animate attributeName="r"
|
||||
begin="-0.9s" dur="1.8s"
|
||||
values="1; 20"
|
||||
calcMode="spline"
|
||||
keyTimes="0; 1"
|
||||
keySplines="0.165, 0.84, 0.44, 1"
|
||||
repeatCount="indefinite" />
|
||||
<animate attributeName="stroke-opacity"
|
||||
begin="-0.9s" dur="1.8s"
|
||||
values="1; 0"
|
||||
calcMode="spline"
|
||||
keyTimes="0; 1"
|
||||
keySplines="0.3, 0.61, 0.355, 1"
|
||||
repeatCount="indefinite" />
|
||||
</circle>
|
||||
</g>
|
||||
<g fill="none" fill-rule="evenodd" stroke-width="2">
|
||||
<circle cx="22" cy="22" r="1">
|
||||
<animate attributeName="r" begin="0s" dur="1.8s" values="1; 20" calcMode="spline" keyTimes="0; 1" keySplines="0.165, 0.84, 0.44, 1" repeatCount="indefinite" />
|
||||
<animate attributeName="stroke-opacity" begin="0s" dur="1.8s" values="1; 0" calcMode="spline" keyTimes="0; 1" keySplines="0.3, 0.61, 0.355, 1" repeatCount="indefinite" />
|
||||
</circle>
|
||||
<circle cx="22" cy="22" r="1">
|
||||
<animate attributeName="r" begin="-0.9s" dur="1.8s" values="1; 20" calcMode="spline" keyTimes="0; 1" keySplines="0.165, 0.84, 0.44, 1" repeatCount="indefinite" />
|
||||
<animate attributeName="stroke-opacity" begin="-0.9s" dur="1.8s" values="1; 0" calcMode="spline" keyTimes="0; 1" keySplines="0.3, 0.61, 0.355, 1" repeatCount="indefinite" />
|
||||
</circle>
|
||||
</g>
|
||||
</svg>
|
||||
<?php
|
||||
}
|
||||
|
@ -1,5 +1,13 @@
|
||||
<?php
|
||||
defined( 'WPINC' ) or die;
|
||||
/**
|
||||
* This file handles image imports in the Site Library.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads and updates images.
|
||||
|
@ -1,6 +1,17 @@
|
||||
<?php
|
||||
defined( 'WPINC' ) or die;
|
||||
/**
|
||||
* This file handles the site restore functionality.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore previous site.
|
||||
*/
|
||||
class GeneratePress_Sites_Restore {
|
||||
/**
|
||||
* Instance.
|
||||
@ -19,22 +30,28 @@ class GeneratePress_Sites_Restore {
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self;
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get it going.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_ajax_generate_restore_theme_options', array( $this, 'theme_options' ) );
|
||||
add_action( 'wp_ajax_generate_restore_site_options', array( $this, 'site_options' ) );
|
||||
add_action( 'wp_ajax_generate_restore_content', array( $this, 'content' ) );
|
||||
add_action( 'wp_ajax_generate_restore_plugins', array( $this, 'plugins' ) );
|
||||
add_action( 'wp_ajax_generate_restore_widgets', array( $this, 'widgets' ) );
|
||||
add_action( 'wp_ajax_generate_restore_css', array( $this, 'css' ) );
|
||||
add_action( 'wp_ajax_generate_restore_site_clean_up', array( $this, 'clean_up' ) );
|
||||
add_action( 'wp_ajax_generate_restore_theme_options', array( $this, 'theme_options' ) );
|
||||
add_action( 'wp_ajax_generate_restore_site_options', array( $this, 'site_options' ) );
|
||||
add_action( 'wp_ajax_generate_restore_content', array( $this, 'content' ) );
|
||||
add_action( 'wp_ajax_generate_restore_plugins', array( $this, 'plugins' ) );
|
||||
add_action( 'wp_ajax_generate_restore_widgets', array( $this, 'widgets' ) );
|
||||
add_action( 'wp_ajax_generate_restore_css', array( $this, 'css' ) );
|
||||
add_action( 'wp_ajax_generate_restore_site_clean_up', array( $this, 'clean_up' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore theme options.
|
||||
*/
|
||||
public function theme_options() {
|
||||
check_ajax_referer( 'generate_sites_nonce', 'nonce' );
|
||||
|
||||
@ -108,6 +125,9 @@ class GeneratePress_Sites_Restore {
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore site options.
|
||||
*/
|
||||
public function site_options() {
|
||||
check_ajax_referer( 'generate_sites_nonce', 'nonce' );
|
||||
|
||||
@ -120,7 +140,7 @@ class GeneratePress_Sites_Restore {
|
||||
|
||||
if ( ! empty( $backup_data ) ) {
|
||||
foreach ( $backup_data['site_options'] as $key => $val ) {
|
||||
if ( in_array( $key, ( array ) generatepress_sites_disallowed_options() ) ) {
|
||||
if ( in_array( $key, (array) generatepress_sites_disallowed_options() ) ) {
|
||||
GeneratePress_Sites_Helper::log( 'Disallowed option: ' . $key );
|
||||
continue;
|
||||
}
|
||||
@ -138,6 +158,9 @@ class GeneratePress_Sites_Restore {
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore content.
|
||||
*/
|
||||
public function content() {
|
||||
check_ajax_referer( 'generate_sites_nonce', 'nonce' );
|
||||
|
||||
@ -163,6 +186,9 @@ class GeneratePress_Sites_Restore {
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore plugins.
|
||||
*/
|
||||
public function plugins() {
|
||||
check_ajax_referer( 'generate_sites_nonce', 'nonce' );
|
||||
|
||||
@ -182,6 +208,9 @@ class GeneratePress_Sites_Restore {
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore widgets.
|
||||
*/
|
||||
public function widgets() {
|
||||
check_ajax_referer( 'generate_sites_nonce', 'nonce' );
|
||||
|
||||
@ -201,6 +230,9 @@ class GeneratePress_Sites_Restore {
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore CSS.
|
||||
*/
|
||||
public function css() {
|
||||
check_ajax_referer( 'generate_sites_nonce', 'nonce' );
|
||||
|
||||
@ -232,6 +264,9 @@ class GeneratePress_Sites_Restore {
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* General cleanup.
|
||||
*/
|
||||
public function clean_up() {
|
||||
check_ajax_referer( 'generate_sites_nonce', 'nonce' );
|
||||
|
||||
|
@ -1,16 +1,32 @@
|
||||
<?php
|
||||
defined( 'WPINC' ) or die;
|
||||
/**
|
||||
* This file handles the widget imports.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Widget importer class.
|
||||
*/
|
||||
class GeneratePress_Sites_Widget_Importer {
|
||||
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @var $_instance
|
||||
*/
|
||||
private static $_instance = null;
|
||||
private static $_instance = null; // phpcs:ignore -- Want the underscore.
|
||||
|
||||
/**
|
||||
* Get our instance.
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( ! isset( self::$_instance ) ) {
|
||||
self::$_instance = new self;
|
||||
self::$_instance = new self();
|
||||
}
|
||||
return self::$_instance;
|
||||
}
|
||||
@ -25,7 +41,7 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
* @global array $wp_registered_widget_updates
|
||||
* @return array Widget information
|
||||
*/
|
||||
function wie_available_widgets() {
|
||||
public function wie_available_widgets() {
|
||||
global $wp_registered_widget_controls;
|
||||
|
||||
$widget_controls = $wp_registered_widget_controls;
|
||||
@ -39,7 +55,7 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wie_available_widgets', $available_widgets );
|
||||
return apply_filters( 'wie_available_widgets', $available_widgets ); // phpcs:ignore -- Keep the plugin prefix.
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,7 +66,7 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
* @param object $data JSON widget data from .wie file.
|
||||
* @return array Results array
|
||||
*/
|
||||
function wie_import_data( $data ) {
|
||||
public function wie_import_data( $data ) {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
// Have valid data?
|
||||
@ -66,9 +82,9 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
}
|
||||
|
||||
// Hook before import.
|
||||
do_action( 'wie_before_import' );
|
||||
do_action( 'wie_before_import' ); // phpcs:ignore -- Keep the plugin prefix.
|
||||
|
||||
$data = apply_filters( 'wie_import_data', $data );
|
||||
$data = apply_filters( 'wie_import_data', $data ); // phpcs:ignore -- Keep the plugin prefix.
|
||||
|
||||
// Get all available widgets site supports.
|
||||
$available_widgets = $this->wie_available_widgets();
|
||||
@ -129,7 +145,7 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
// Filter to modify settings object before conversion to array and import
|
||||
// Leave this filter here for backwards compatibility with manipulating objects (before conversion to array below)
|
||||
// Ideally the newer wie_widget_settings_array below will be used instead of this.
|
||||
$widget = apply_filters( 'wie_widget_settings', $widget );
|
||||
$widget = apply_filters( 'wie_widget_settings', $widget ); // phpcs:ignore -- Keep the plugin prefix.
|
||||
|
||||
// Convert multidimensional objects to multidimensional arrays
|
||||
// Some plugins like Jetpack Widget Visibility store settings as multidimensional arrays
|
||||
@ -141,7 +157,7 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
// Filter to modify settings array
|
||||
// This is preferred over the older wie_widget_settings filter above
|
||||
// Do before identical check because changes may make it identical to end result (such as URL replacements).
|
||||
$widget = apply_filters( 'wie_widget_settings_array', $widget );
|
||||
$widget = apply_filters( 'wie_widget_settings_array', $widget ); // phpcs:ignore -- Keep the plugin prefix.
|
||||
|
||||
// Does widget with identical settings already exist in same sidebar?
|
||||
if ( ! $fail && isset( $widget_instances[ $id_base ] ) ) {
|
||||
@ -166,7 +182,7 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
|
||||
// No failure.
|
||||
if ( ! $fail ) {
|
||||
// Add widget instance
|
||||
// Add widget instance.
|
||||
$single_widget_instances = get_option( 'widget_' . $id_base ); // All instances for that widget ID base, get fresh every time.
|
||||
|
||||
$single_widget_instances = ! empty( $single_widget_instances ) ? $single_widget_instances : array(
|
||||
@ -230,7 +246,7 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
'widget_id_num_old' => $instance_id_number,
|
||||
);
|
||||
|
||||
do_action( 'wie_after_widget_import', $after_widget_import );
|
||||
do_action( 'wie_after_widget_import', $after_widget_import ); // phpcs:ignore -- Keep the plugin prefix.
|
||||
|
||||
// Success message.
|
||||
if ( $sidebar_available ) {
|
||||
@ -242,7 +258,7 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
}
|
||||
}
|
||||
|
||||
// Result for widget instance
|
||||
// Result for widget instance.
|
||||
$results[ $sidebar_id ]['widgets'][ $widget_instance_id ]['name'] = isset( $available_widgets[ $id_base ]['name'] ) ? $available_widgets[ $id_base ]['name'] : $id_base; // Widget name or ID if name not available (not supported by site).
|
||||
$results[ $sidebar_id ]['widgets'][ $widget_instance_id ]['title'] = ! empty( $widget['title'] ) ? $widget['title'] : esc_html__( 'No Title', 'widget-importer-exporter' ); // Show "No Title" if widget instance is untitled.
|
||||
$results[ $sidebar_id ]['widgets'][ $widget_instance_id ]['message_type'] = $widget_message_type;
|
||||
@ -251,9 +267,9 @@ class GeneratePress_Sites_Widget_Importer {
|
||||
}
|
||||
|
||||
// Hook after import.
|
||||
do_action( 'wie_after_import' );
|
||||
do_action( 'wie_after_import' ); // phpcs:ignore -- Keep the plugin prefix.
|
||||
|
||||
// Return results.
|
||||
return apply_filters( 'wie_import_results', $results );
|
||||
return apply_filters( 'wie_import_results', $results ); // phpcs:ignore -- Keep the plugin prefix.
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,17 @@
|
||||
<?php
|
||||
defined( 'WPINC' ) or die;
|
||||
/**
|
||||
* This file builds the sites to be imported.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build each site UI.
|
||||
*/
|
||||
class GeneratePress_Site {
|
||||
|
||||
/**
|
||||
@ -88,10 +99,10 @@ class GeneratePress_Site {
|
||||
protected $documentation;
|
||||
|
||||
/**
|
||||
* Get the uploads URL.
|
||||
*
|
||||
* @var int|string
|
||||
*/
|
||||
* Get the uploads URL.
|
||||
*
|
||||
* @var int|string
|
||||
*/
|
||||
protected $uploads_url;
|
||||
|
||||
/**
|
||||
@ -104,53 +115,56 @@ class GeneratePress_Site {
|
||||
/**
|
||||
* Get it rockin'
|
||||
*
|
||||
* @param array $config
|
||||
* @param array $config The site configuration.
|
||||
*/
|
||||
public function __construct( $config = array() ) {
|
||||
|
||||
$config = wp_parse_args( $config, array(
|
||||
'directory' => '',
|
||||
'name' => '',
|
||||
'preview_url' => '',
|
||||
'author_name' => '',
|
||||
'author_url' => '',
|
||||
'icon' => 'icon.png',
|
||||
'screenshot' => 'screenshot.png',
|
||||
'page_builder' => array(),
|
||||
'uploads_url' => array(),
|
||||
'min_version' => GP_PREMIUM_VERSION,
|
||||
'plugins' => '',
|
||||
'documentation' => '',
|
||||
) );
|
||||
$config = wp_parse_args(
|
||||
$config,
|
||||
array(
|
||||
'directory' => '',
|
||||
'name' => '',
|
||||
'preview_url' => '',
|
||||
'author_name' => '',
|
||||
'author_url' => '',
|
||||
'icon' => 'icon.png',
|
||||
'screenshot' => 'screenshot.png',
|
||||
'page_builder' => array(),
|
||||
'uploads_url' => array(),
|
||||
'min_version' => GP_PREMIUM_VERSION,
|
||||
'plugins' => '',
|
||||
'documentation' => '',
|
||||
)
|
||||
);
|
||||
|
||||
$this->helpers = new GeneratePress_Sites_Helper();
|
||||
|
||||
$this->directory = trailingslashit( $config['directory'] );
|
||||
$this->directory = trailingslashit( $config['directory'] );
|
||||
|
||||
$provider = parse_url( $this->directory );
|
||||
$provider = parse_url( $this->directory ); // phpcs:ignore -- Prefer parse_url().
|
||||
|
||||
if ( ! isset( $provider['host'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! in_array( $provider['host'], ( array ) get_transient( 'generatepress_sites_trusted_providers' ) ) ) {
|
||||
if ( ! in_array( $provider['host'], (array) get_transient( 'generatepress_sites_trusted_providers' ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->name = $config['name'];
|
||||
$this->slug = str_replace( ' ', '_', strtolower( $this->name ) );
|
||||
$this->preview_url = $config['preview_url'];
|
||||
$this->author_name = $config['author_name'];
|
||||
$this->author_url = $config['author_url'];
|
||||
$this->description = $config['description'];
|
||||
$this->icon = $config['icon'];
|
||||
$this->screenshot = $config['screenshot'];
|
||||
$this->page_builder = $config['page_builder'];
|
||||
$this->min_version = $config['min_version'];
|
||||
$this->uploads_url = $config['uploads_url'];
|
||||
$this->plugins = $config['plugins'];
|
||||
$this->documentation = $config['documentation'];
|
||||
$this->installable = true;
|
||||
$this->name = $config['name'];
|
||||
$this->slug = str_replace( ' ', '_', strtolower( $this->name ) );
|
||||
$this->preview_url = $config['preview_url'];
|
||||
$this->author_name = $config['author_name'];
|
||||
$this->author_url = $config['author_url'];
|
||||
$this->description = $config['description'];
|
||||
$this->icon = $config['icon'];
|
||||
$this->screenshot = $config['screenshot'];
|
||||
$this->page_builder = $config['page_builder'];
|
||||
$this->min_version = $config['min_version'];
|
||||
$this->uploads_url = $config['uploads_url'];
|
||||
$this->plugins = $config['plugins'];
|
||||
$this->documentation = $config['documentation'];
|
||||
$this->installable = true;
|
||||
|
||||
if ( empty( $this->min_version ) ) {
|
||||
$this->min_version = GP_PREMIUM_VERSION;
|
||||
@ -160,16 +174,16 @@ class GeneratePress_Site {
|
||||
$this->installable = false;
|
||||
}
|
||||
|
||||
add_action( 'generate_inside_sites_container', array( $this, 'build_box' ) );
|
||||
add_action( "wp_ajax_generate_setup_demo_content_{$this->slug}", array( $this, 'setup_demo_content' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_check_plugins_{$this->slug}", array( $this, 'check_plugins' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_backup_options_{$this->slug}", array( $this, 'backup_options' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_import_options_{$this->slug}", array( $this, 'import_options' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_activate_plugins_{$this->slug}", array( $this, 'activate_plugins' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_import_site_options_{$this->slug}", array( $this, 'import_site_options' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_download_content_{$this->slug}", array( $this, 'download_content' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_import_content_{$this->slug}", array( $this, 'import_content' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_import_widgets_{$this->slug}", array( $this, 'import_widgets' ), 10, 0 );
|
||||
add_action( 'generate_inside_sites_container', array( $this, 'build_box' ) );
|
||||
add_action( "wp_ajax_generate_setup_demo_content_{$this->slug}", array( $this, 'setup_demo_content' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_check_plugins_{$this->slug}", array( $this, 'check_plugins' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_backup_options_{$this->slug}", array( $this, 'backup_options' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_import_options_{$this->slug}", array( $this, 'import_options' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_activate_plugins_{$this->slug}", array( $this, 'activate_plugins' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_import_site_options_{$this->slug}", array( $this, 'import_site_options' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_download_content_{$this->slug}", array( $this, 'download_content' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_import_content_{$this->slug}", array( $this, 'import_content' ), 10, 0 );
|
||||
add_action( "wp_ajax_generate_import_widgets_{$this->slug}", array( $this, 'import_widgets' ), 10, 0 );
|
||||
|
||||
// Don't do the WC setup. This wouldn't be necessary if they used an activation hook.
|
||||
add_filter( 'woocommerce_prevent_automatic_wizard_redirect', '__return_true' );
|
||||
@ -183,10 +197,11 @@ class GeneratePress_Site {
|
||||
*/
|
||||
public function site_details() {
|
||||
|
||||
printf( '<div class="site-screenshot site-overview-screenshot">
|
||||
<img src="" alt="%s" />
|
||||
</div>',
|
||||
esc_attr( $this->name )
|
||||
printf(
|
||||
'<div class="site-screenshot site-overview-screenshot">
|
||||
<img src="" alt="%s" />
|
||||
</div>',
|
||||
esc_attr( $this->name )
|
||||
);
|
||||
|
||||
?>
|
||||
@ -217,11 +232,12 @@ class GeneratePress_Site {
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: Site name */
|
||||
__( '%s is brought to you by ', 'gp-premium' ),
|
||||
$this->name
|
||||
esc_html( $this->name )
|
||||
);
|
||||
?>
|
||||
<a href="<?php echo esc_url( $this->author_url ); ?>" target="_blank" rel="noopener"><?php echo $this->author_name; ?></a>.
|
||||
<a href="<?php echo esc_url( $this->author_url ); ?>" target="_blank" rel="noopener"><?php echo esc_html( $this->author_name ); ?></a>.
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@ -253,7 +269,7 @@ class GeneratePress_Site {
|
||||
* @since 1.6
|
||||
*/
|
||||
public function loading_icon() {
|
||||
// Deprecated since 1.9
|
||||
// Deprecated since 1.9.
|
||||
}
|
||||
|
||||
/**
|
||||
@ -264,31 +280,31 @@ class GeneratePress_Site {
|
||||
public function build_box() {
|
||||
|
||||
$site_data = array(
|
||||
'slug' => $this->slug,
|
||||
'preview_url' => $this->preview_url,
|
||||
'plugins' => $this->plugins,
|
||||
'slug' => $this->slug,
|
||||
'preview_url' => $this->preview_url,
|
||||
'plugins' => $this->plugins,
|
||||
);
|
||||
|
||||
$page_builders = array();
|
||||
foreach ( ( array ) $this->page_builder as $builder ) {
|
||||
foreach ( (array) $this->page_builder as $builder ) {
|
||||
$page_builders = str_replace( ' ', '-', strtolower( $builder ) );
|
||||
}
|
||||
|
||||
$site_classes = array(
|
||||
'site-box',
|
||||
$page_builders,
|
||||
! $this->installable ? 'disabled-site' : ''
|
||||
! $this->installable ? 'disabled-site' : '',
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="<?php echo implode( ' ', $site_classes ); ?>" data-site-data="<?php echo htmlspecialchars( json_encode( $site_data ), ENT_QUOTES, 'UTF-8' ); ?>">
|
||||
<div class="<?php echo implode( ' ', $site_classes ); // phpcs:ignore -- Escaping not needed. ?>" data-site-data="<?php echo htmlspecialchars( json_encode( $site_data ), ENT_QUOTES, 'UTF-8' ); ?>">
|
||||
<div class="steps step-one">
|
||||
<div class="site-info">
|
||||
<div class="site-description">
|
||||
<h3><a class="site-details" href="#"><?php echo $this->name; ?></a></h3>
|
||||
<h3><a class="site-details" href="#"><?php echo esc_html( $this->name ); ?></a></h3>
|
||||
<?php
|
||||
if ( $this->description ) {
|
||||
echo '<a class="site-details" href="#"> ' . wpautop( $this->description ) . '</a>';
|
||||
echo '<a class="site-details" href="#"> ' . wpautop( $this->description ) . '</a>'; // phpcs:ignore -- No escaping necessary.
|
||||
}
|
||||
?>
|
||||
|
||||
@ -299,36 +315,45 @@ class GeneratePress_Site {
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<span class="version-required-message">
|
||||
<?php printf( _x( 'Requires GP Premium %s', 'required version number', 'gp-premium' ), $this->min_version ); ?>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: GP Premium version */
|
||||
_x( 'Requires GP Premium %s', 'required version number', 'gp-premium' ),
|
||||
esc_html( $this->min_version )
|
||||
);
|
||||
?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="site-screenshot site-card-screenshot">
|
||||
<img class="lazyload" src="<?php echo GENERATE_SITES_URL; ?>/assets/images/screenshot.png" data-src="<?php echo esc_url( $this->directory . $this->screenshot ); ?>" alt="" />
|
||||
<img class="lazyload" src="<?php echo esc_url( GENERATE_SITES_URL ); ?>/assets/images/screenshot.png" data-src="<?php echo esc_url( $this->directory . $this->screenshot ); ?>" alt="" />
|
||||
</div>
|
||||
|
||||
<div class="site-title">
|
||||
<span class="author-name"><?php echo $this->author_name; ?></span>
|
||||
<h3><?php echo $this->name; ?></h3>
|
||||
<span class="author-name"><?php echo esc_html( $this->author_name ); ?></span>
|
||||
<h3><?php echo esc_html( $this->name ); ?></h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="steps step-overview" style="display: none;">
|
||||
<div class="step-information">
|
||||
<h1 style="margin-bottom: 0;">
|
||||
<?php printf(
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: Site name. */
|
||||
__( 'Welcome to %s.', 'gp-premium' ),
|
||||
$this->name
|
||||
); ?>
|
||||
esc_html( $this->name )
|
||||
);
|
||||
?>
|
||||
</h1>
|
||||
|
||||
<p><?php echo $this->description; ?></p>
|
||||
<p><?php echo $this->description; // phpcs:ignore -- Escaping not needed. ?></p>
|
||||
|
||||
<div class="action-area">
|
||||
<div class="action-buttons">
|
||||
<?php echo $this->action_button(); ?>
|
||||
<?php echo $this->action_button(); // phpcs:ignore -- Escaping not needed. ?>
|
||||
|
||||
<div class="loading" style="display: none;">
|
||||
<span class="site-message"></span>
|
||||
@ -373,7 +398,8 @@ class GeneratePress_Site {
|
||||
<?php _e( 'Things like pages, menus, widgets and plugins.', 'gp-premium' ); ?>
|
||||
</p>
|
||||
|
||||
<?php if ( $this->plugins ) :
|
||||
<?php
|
||||
if ( $this->plugins ) :
|
||||
$plugins = json_decode( $this->plugins, true );
|
||||
|
||||
if ( ! empty( $plugins ) ) :
|
||||
@ -381,17 +407,20 @@ class GeneratePress_Site {
|
||||
<div class="site-plugins">
|
||||
<p><?php _e( 'This site uses the following plugins.', 'gp-premium' ); ?></p>
|
||||
<ul>
|
||||
<?php foreach( $plugins as $name => $id ) {
|
||||
<?php
|
||||
foreach ( $plugins as $name => $id ) {
|
||||
printf(
|
||||
'<li>%s</li>',
|
||||
$name
|
||||
esc_html( $name )
|
||||
);
|
||||
} ?>
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
endif; ?>
|
||||
endif;
|
||||
?>
|
||||
|
||||
<div class="plugin-area">
|
||||
<div class="no-plugins" style="display: none;">
|
||||
@ -433,27 +462,31 @@ class GeneratePress_Site {
|
||||
|
||||
$uploads_url = $uploads_url['baseurl'];
|
||||
|
||||
if ( $this->uploads_url ) : ?>
|
||||
if ( $this->uploads_url ) :
|
||||
?>
|
||||
<div class="replace-elementor-urls" style="display: none;">
|
||||
<h4><?php _e( 'Additional Cleanup', 'gp-premium' ); ?></h4>
|
||||
<p><?php _e( 'This site is using Elementor which means you will want to replace the imported image URLs.', 'gp-premium' ); ?> <a title="<?php _e( 'Learn more', 'gp-premium' ); ?>" href="https://docs.generatepress.com/article/replacing-urls-in-elementor/" target="_blank" rel="noopener">[?]</a></p>
|
||||
|
||||
<p>
|
||||
<?php printf(
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: Elementor link */
|
||||
__( 'Go to %s, enter the below URLs and click the "Replace URL" button.', 'gp-premium' ),
|
||||
'<a href="' . admin_url( 'admin.php?page=elementor-tools#tab-replace_url' ) . '" target="_blank" rel="noopener">Elementor > Tools > Replace URLs</a>'
|
||||
) ?>
|
||||
'<a href="' . esc_url( admin_url( 'admin.php?page=elementor-tools#tab-replace_url' ) ) . '" target="_blank" rel="noopener">Elementor > Tools > Replace URLs</a>'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<div class="elementor-urls">
|
||||
<label for="old-url"><?php _e( 'Old URL', 'gp-premium' ); ?></label>
|
||||
<input id="old-url" type="text" value="<?php echo $this->uploads_url; ?>" />
|
||||
<input id="old-url" type="text" value="<?php echo esc_url( $this->uploads_url ); ?>" />
|
||||
|
||||
<label for="new-url"><?php _e( 'New URL', 'gp-premium' ); ?></label>
|
||||
<input id="new-url" type="text" value="<?php echo $uploads_url; ?>" />
|
||||
<input id="new-url" type="text" value="<?php echo esc_url( $uploads_url ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
@ -484,10 +517,13 @@ class GeneratePress_Site {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the action buttons.
|
||||
*/
|
||||
public function action_button() {
|
||||
|
||||
$options = GeneratePress_Sites_Helper::do_options_exist();
|
||||
@ -558,18 +594,18 @@ class GeneratePress_Site {
|
||||
|
||||
$data = array(
|
||||
'mods' => array(),
|
||||
'options' => array()
|
||||
'options' => array(),
|
||||
);
|
||||
|
||||
foreach ( $theme_mods as $theme_mod ) {
|
||||
$data['mods'][$theme_mod] = get_theme_mod( $theme_mod );
|
||||
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
|
||||
}
|
||||
|
||||
foreach ( $settings as $setting ) {
|
||||
$data['options'][$setting] = get_option( $setting );
|
||||
$data['options'][ $setting ] = get_option( $setting );
|
||||
}
|
||||
|
||||
echo json_encode( $data );
|
||||
echo wp_json_encode( $data );
|
||||
|
||||
die();
|
||||
|
||||
@ -645,15 +681,15 @@ class GeneratePress_Site {
|
||||
|
||||
$data = array(
|
||||
'mods' => array(),
|
||||
'options' => array()
|
||||
'options' => array(),
|
||||
);
|
||||
|
||||
foreach ( $theme_mods as $theme_mod ) {
|
||||
$data['mods'][$theme_mod] = get_theme_mod( $theme_mod );
|
||||
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
|
||||
}
|
||||
|
||||
foreach ( $settings as $setting ) {
|
||||
$data['options'][$setting] = get_option( $setting );
|
||||
$data['options'][ $setting ] = get_option( $setting );
|
||||
}
|
||||
|
||||
$backup_data['theme_options'] = $data;
|
||||
@ -662,7 +698,7 @@ class GeneratePress_Site {
|
||||
|
||||
$active_modules = array();
|
||||
foreach ( $modules as $name => $key ) {
|
||||
if ( 'activated' == get_option( $key ) ) {
|
||||
if ( 'activated' === get_option( $key ) ) {
|
||||
$active_modules[ $name ] = $key;
|
||||
}
|
||||
}
|
||||
@ -732,17 +768,15 @@ class GeneratePress_Site {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Import any images
|
||||
// Import any images.
|
||||
if ( is_array( $val ) || is_object( $val ) ) {
|
||||
foreach ( $val as $option_name => $option_value ) {
|
||||
if ( is_string( $option_value ) && preg_match( '/\.(jpg|jpeg|png|gif)/i', $option_value ) ) {
|
||||
|
||||
$data = GeneratePress_Sites_Helper::sideload_image( $option_value );
|
||||
|
||||
if ( ! is_wp_error( $data ) ) {
|
||||
$val[$option_name] = $data->url;
|
||||
$val[ $option_name ] = $data->url;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -754,6 +788,14 @@ class GeneratePress_Site {
|
||||
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 );
|
||||
|
||||
// Custom CSS.
|
||||
$css = $settings['custom_css'];
|
||||
$css = '/* GeneratePress Site CSS */ ' . $css . ' /* End GeneratePress Site CSS */';
|
||||
@ -779,8 +821,10 @@ class GeneratePress_Site {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Download the content from the .xml file.
|
||||
*/
|
||||
public function download_content() {
|
||||
|
||||
check_ajax_referer( 'generate_sites_nonce', 'nonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
@ -835,7 +879,7 @@ class GeneratePress_Site {
|
||||
$backup_data['content'] = true;
|
||||
update_option( '_generatepress_site_library_backup', $backup_data );
|
||||
|
||||
// Import content
|
||||
// Import content.
|
||||
$content = get_transient( 'generatepress_sites_content_file' );
|
||||
|
||||
if ( $content ) {
|
||||
@ -898,15 +942,13 @@ class GeneratePress_Site {
|
||||
|
||||
delete_option( 'generate_page_header_global_locations' );
|
||||
|
||||
foreach( $settings['site_options'] as $key => $val ) {
|
||||
|
||||
switch( $key ) {
|
||||
|
||||
foreach ( $settings['site_options'] as $key => $val ) {
|
||||
switch ( $key ) {
|
||||
case 'page_for_posts':
|
||||
case 'page_on_front':
|
||||
$backup_data['site_options'][ $key ] = get_option( $key );
|
||||
GeneratePress_Sites_Helper::set_reading_pages( $key, $val, $this->slug );
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'woocommerce_shop_page_id':
|
||||
case 'woocommerce_cart_page_id':
|
||||
@ -914,27 +956,27 @@ class GeneratePress_Site {
|
||||
case 'woocommerce_myaccount_page_id':
|
||||
$backup_data['site_options'][ $key ] = get_option( $key );
|
||||
GeneratePress_Sites_Helper::set_woocommerce_pages( $key, $val, $this->slug );
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'nav_menu_locations':
|
||||
GeneratePress_Sites_Helper::set_nav_menu_locations( $val );
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'page_header_global_locations':
|
||||
GeneratePress_Sites_Helper::set_global_page_header_locations( $val, $this->slug );
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'page_headers':
|
||||
GeneratePress_Sites_Helper::set_page_headers( $val, $this->slug );
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'element_locations':
|
||||
GeneratePress_Sites_Helper::set_element_locations( $val, $this->slug );
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'element_exclusions':
|
||||
GeneratePress_Sites_Helper::set_element_exclusions( $val, $this->slug );
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'custom_logo':
|
||||
$data = GeneratePress_Sites_Helper::sideload_image( $val );
|
||||
@ -946,20 +988,18 @@ class GeneratePress_Site {
|
||||
remove_theme_mod( 'custom_logo' );
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
if ( in_array( $key, ( array ) generatepress_sites_disallowed_options() ) ) {
|
||||
if ( in_array( $key, (array) generatepress_sites_disallowed_options() ) ) {
|
||||
GeneratePress_Sites_Helper::log( 'Disallowed option: ' . $key );
|
||||
} else {
|
||||
$backup_data['site_options'][ $key ] = get_option( $key );
|
||||
delete_option( $key );
|
||||
update_option( $key, $val );
|
||||
}
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Set our backed up options.
|
||||
@ -998,11 +1038,11 @@ class GeneratePress_Site {
|
||||
|
||||
$pro_plugins = GeneratePress_Sites_Helper::check_for_pro_plugins();
|
||||
|
||||
foreach( $plugins as $plugin ) {
|
||||
foreach ( $plugins as $plugin ) {
|
||||
// If the plugin has a pro version and it exists, activate it instead.
|
||||
if ( array_key_exists( $plugin, $pro_plugins ) ) {
|
||||
if ( file_exists( WP_PLUGIN_DIR . '/' . $pro_plugins[$plugin] ) ) {
|
||||
$plugin = $pro_plugins[$plugin];
|
||||
if ( file_exists( WP_PLUGIN_DIR . '/' . $pro_plugins[ $plugin ] ) ) {
|
||||
$plugin = $pro_plugins[ $plugin ];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1053,9 +1093,9 @@ class GeneratePress_Site {
|
||||
}
|
||||
|
||||
$plugin_data = array();
|
||||
foreach( $data['plugins'] as $name => $slug ) {
|
||||
foreach ( $data['plugins'] as $name => $slug ) {
|
||||
$basename = strtok( $slug, '/' );
|
||||
$plugin_data[$name] = array(
|
||||
$plugin_data[ $name ] = array(
|
||||
'name' => $name,
|
||||
'slug' => $slug,
|
||||
'installed' => GeneratePress_Sites_Helper::is_plugin_installed( $slug ) ? true : false,
|
||||
@ -1067,10 +1107,12 @@ class GeneratePress_Site {
|
||||
$data['plugin_data'] = $plugin_data;
|
||||
}
|
||||
|
||||
wp_send_json( array(
|
||||
'plugins' => $data['plugins'],
|
||||
'plugin_data' => $data['plugin_data'],
|
||||
) );
|
||||
wp_send_json(
|
||||
array(
|
||||
'plugins' => $data['plugins'],
|
||||
'plugin_data' => $data['plugin_data'],
|
||||
)
|
||||
);
|
||||
|
||||
die();
|
||||
|
||||
@ -1082,7 +1124,7 @@ class GeneratePress_Site {
|
||||
* @param int $post_id Post ID.
|
||||
* @return void
|
||||
*/
|
||||
function track_post( $post_id ) {
|
||||
public function track_post( $post_id ) {
|
||||
update_post_meta( $post_id, '_generatepress_sites_imported_post', true );
|
||||
}
|
||||
|
||||
@ -1092,7 +1134,7 @@ class GeneratePress_Site {
|
||||
* @param int $term_id Term ID.
|
||||
* @return void
|
||||
*/
|
||||
function track_term( $term_id ) {
|
||||
public function track_term( $term_id ) {
|
||||
$term = get_term( $term_id );
|
||||
|
||||
update_term_meta( $term_id, '_generatepress_sites_imported_term', true );
|
||||
|
@ -1,8 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Image Background Process
|
||||
* This file handles background processes.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
if ( class_exists( 'WP_Background_Process' ) ) {
|
||||
|
||||
/**
|
||||
@ -12,8 +18,18 @@ if ( class_exists( 'WP_Background_Process' ) ) {
|
||||
*/
|
||||
class GeneratePress_Site_Background_Process extends WP_Background_Process {
|
||||
|
||||
/**
|
||||
* What we're doing.
|
||||
*
|
||||
* @var $action
|
||||
*/
|
||||
protected $action = 'image_process';
|
||||
|
||||
/**
|
||||
* Do the task.
|
||||
*
|
||||
* @param class $process The process.
|
||||
*/
|
||||
protected function task( $process ) {
|
||||
|
||||
if ( method_exists( $process, 'import' ) ) {
|
||||
@ -23,6 +39,9 @@ if ( class_exists( 'WP_Background_Process' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete the task.
|
||||
*/
|
||||
protected function complete() {
|
||||
|
||||
parent::complete();
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user