modified file plugins
This commit is contained in:
@ -0,0 +1,401 @@
|
||||
<?php
|
||||
/**
|
||||
* Build our admin dashboard.
|
||||
*
|
||||
* @package GeneratePress Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
/**
|
||||
* This class adds premium sections to our Dashboard.
|
||||
*/
|
||||
class GeneratePress_Pro_Dashboard {
|
||||
/**
|
||||
* Class instance.
|
||||
*
|
||||
* @access private
|
||||
* @var $instance Class instance.
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get started.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'after_setup_theme', array( $this, 'setup' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our actions and require old Dashboard files if we need them.
|
||||
*/
|
||||
public function setup() {
|
||||
// Load our old dashboard if we're using an old version of GeneratePress.
|
||||
if ( ! class_exists( 'GeneratePress_Dashboard' ) ) {
|
||||
if ( is_admin() ) {
|
||||
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/dashboard.php';
|
||||
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/import-export.php';
|
||||
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/reset.php';
|
||||
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/activation.php';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
||||
add_action( 'generate_admin_dashboard', array( $this, 'module_list' ), 8 );
|
||||
add_action( 'generate_admin_dashboard', array( $this, 'license_key' ), 5 );
|
||||
add_action( 'generate_admin_dashboard', array( $this, 'import_export' ), 50 );
|
||||
add_action( 'generate_admin_dashboard', array( $this, 'reset' ), 100 );
|
||||
add_filter( 'generate_premium_beta_tester', array( $this, 'set_beta_tester' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data for all of our pro modules.
|
||||
*/
|
||||
public static function get_modules() {
|
||||
$modules = array(
|
||||
'Backgrounds' => array(
|
||||
'title' => __( 'Backgrounds', 'gp-premium' ),
|
||||
'description' => __( 'Set background images for various HTML elements.', 'gp-premium' ),
|
||||
'key' => 'generate_package_backgrounds',
|
||||
'settings' => 'generate_background_settings',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_backgrounds', false ),
|
||||
'exportable' => true,
|
||||
),
|
||||
'Blog' => array(
|
||||
'title' => __( 'Blog', 'gp-premium' ),
|
||||
'description' => __( 'Set blog options like infinite scroll, masonry layouts and more.', 'gp-premium' ),
|
||||
'key' => 'generate_package_blog',
|
||||
'settings' => 'generate_blog_settings',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_blog', false ),
|
||||
'exportable' => true,
|
||||
),
|
||||
'Colors' => array(
|
||||
'title' => __( 'Colors', 'gp-premium' ),
|
||||
'key' => 'generate_package_colors',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_colors', false ),
|
||||
),
|
||||
'Copyright' => array(
|
||||
'title' => __( 'Copyright', 'gp-premium' ),
|
||||
'description' => __( 'Set a custom copyright message in your footer.', 'gp-premium' ),
|
||||
'key' => 'generate_package_copyright',
|
||||
'settings' => 'copyright',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_copyright', false ),
|
||||
'exportable' => true,
|
||||
),
|
||||
'Disable Elements' => array(
|
||||
'title' => __( 'Disable Elements', 'gp-premium' ),
|
||||
'description' => __( 'Disable default theme elements on specific pages or inside a Layout Element.', 'gp-premium' ),
|
||||
'key' => 'generate_package_disable_elements',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_disable_elements', false ),
|
||||
),
|
||||
'Elements' => array(
|
||||
'title' => __( 'Elements', 'gp-premium' ),
|
||||
'description' => __( 'Use our block editor theme builder, build advanced HTML hooks, and gain more Layout control.', 'gp-premium' ),
|
||||
'key' => 'generate_package_elements',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_elements', false ),
|
||||
),
|
||||
'Hooks' => array(
|
||||
'title' => __( 'Hooks', 'gp-premium' ),
|
||||
'description' => __( 'This module has been deprecated. Please use Elements instead.', 'gp-premium' ),
|
||||
'key' => 'generate_package_hooks',
|
||||
'settings' => 'generate_hooks',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_hooks', false ),
|
||||
'exportable' => true,
|
||||
),
|
||||
'Menu Plus' => array(
|
||||
'title' => __( 'Menu Plus', 'gp-premium' ),
|
||||
'description' => __( 'Set up a mobile header, sticky navigation or off-canvas panel.', 'gp-premium' ),
|
||||
'key' => 'generate_package_menu_plus',
|
||||
'settings' => 'generate_menu_plus_settings',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_menu_plus', false ),
|
||||
'exportable' => true,
|
||||
),
|
||||
'Page Header' => array(
|
||||
'title' => __( 'Page Header', 'gp-premium' ),
|
||||
'description' => __( 'This module has been deprecated. Please use Elements instead.', 'gp-premium' ),
|
||||
'key' => 'generate_package_page_header',
|
||||
'settings' => 'generate_page_header_settings',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_page_header', false ),
|
||||
'exportable' => true,
|
||||
),
|
||||
'Secondary Nav' => array(
|
||||
'title' => __( 'Secondary Nav', 'gp-premium' ),
|
||||
'description' => __( 'Add a fully-featured secondary navigation to your site.', 'gp-premium' ),
|
||||
'key' => 'generate_package_secondary_nav',
|
||||
'settings' => 'generate_secondary_nav_settings',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_secondary_nav', false ),
|
||||
'exportable' => true,
|
||||
),
|
||||
'Sections' => array(
|
||||
'title' => __( 'Sections', 'gp-premium' ),
|
||||
'description' => __( 'This module has been deprecated. Please consider using our GenerateBlocks plugin instead.', 'gp-premium' ),
|
||||
'key' => 'generate_package_sections',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_sections', false ),
|
||||
),
|
||||
'Spacing' => array(
|
||||
'title' => __( 'Spacing', 'gp-premium' ),
|
||||
'description' => __( 'Set the padding and overall spacing of your theme elements.', 'gp-premium' ),
|
||||
'key' => 'generate_package_spacing',
|
||||
'settings' => 'generate_spacing_settings',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_spacing', false ),
|
||||
'exportable' => true,
|
||||
),
|
||||
'Typography' => array(
|
||||
'title' => __( 'Typography', 'gp-premium' ),
|
||||
'description' => __( 'This module has been deprecated. Switch to our dynamic typography system in Customize > General instead.', 'gp-premium' ),
|
||||
'key' => 'generate_package_typography',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_typography', false ),
|
||||
),
|
||||
'WooCommerce' => array(
|
||||
'title' => __( 'WooCommerce', 'gp-premium' ),
|
||||
'description' => __( 'Add colors, typography, and layout options to your WooCommerce store.', 'gp-premium' ),
|
||||
'key' => 'generate_package_woocommerce',
|
||||
'settings' => 'generate_woocommerce_settings',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_woocommerce', false ),
|
||||
'exportable' => true,
|
||||
),
|
||||
);
|
||||
|
||||
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
|
||||
$modules['Site Library'] = array(
|
||||
'title' => __( 'Site Library', 'gp-premium' ),
|
||||
'description' => __( 'Choose from an extensive library of professionally designed starter sites.', 'gp-premium' ),
|
||||
'key' => 'generate_package_site_library',
|
||||
'isActive' => 'activated' === get_option( 'generate_package_site_library', false ),
|
||||
);
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
|
||||
unset( $modules['Typography'] );
|
||||
}
|
||||
|
||||
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '>=' ) ) {
|
||||
unset( $modules['Colors'] );
|
||||
}
|
||||
|
||||
$deprecated_modules = apply_filters(
|
||||
'generate_premium_deprecated_modules',
|
||||
array(
|
||||
'Page Header',
|
||||
'Hooks',
|
||||
'Sections',
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $deprecated_modules as $deprecated_module ) {
|
||||
if ( isset( $modules[ $deprecated_module ] ) ) {
|
||||
$modules[ $deprecated_module ]['deprecated'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
ksort( $modules );
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get modules that can have their settings exported and imported.
|
||||
*/
|
||||
public static function get_exportable_modules() {
|
||||
$modules = array(
|
||||
'Core' => array(
|
||||
'settings' => 'generate_settings',
|
||||
'title' => __( 'Core', 'gp-premium' ),
|
||||
'isActive' => true,
|
||||
),
|
||||
);
|
||||
|
||||
foreach ( self::get_modules() as $key => $data ) {
|
||||
if ( ! empty( $data['exportable'] ) && $data['isActive'] ) {
|
||||
$modules[ $key ] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get options using theme_mods.
|
||||
*/
|
||||
public static function get_theme_mods() {
|
||||
$theme_mods = array(
|
||||
'font_body_variants',
|
||||
'font_body_category',
|
||||
'font_site_title_variants',
|
||||
'font_site_title_category',
|
||||
'font_site_tagline_variants',
|
||||
'font_site_tagline_category',
|
||||
'font_navigation_variants',
|
||||
'font_navigation_category',
|
||||
'font_secondary_navigation_variants',
|
||||
'font_secondary_navigation_category',
|
||||
'font_buttons_variants',
|
||||
'font_buttons_category',
|
||||
'font_heading_1_variants',
|
||||
'font_heading_1_category',
|
||||
'font_heading_2_variants',
|
||||
'font_heading_2_category',
|
||||
'font_heading_3_variants',
|
||||
'font_heading_3_category',
|
||||
'font_heading_4_variants',
|
||||
'font_heading_4_category',
|
||||
'font_heading_5_variants',
|
||||
'font_heading_5_category',
|
||||
'font_heading_6_variants',
|
||||
'font_heading_6_category',
|
||||
'font_widget_title_variants',
|
||||
'font_widget_title_category',
|
||||
'font_footer_variants',
|
||||
'font_footer_category',
|
||||
'generate_copyright',
|
||||
);
|
||||
|
||||
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
|
||||
$theme_mods = array(
|
||||
'generate_copyright',
|
||||
);
|
||||
}
|
||||
|
||||
return $theme_mods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our setting keys.
|
||||
*/
|
||||
public static function get_setting_keys() {
|
||||
return array(
|
||||
'generate_settings',
|
||||
'generate_background_settings',
|
||||
'generate_blog_settings',
|
||||
'generate_hooks',
|
||||
'generate_page_header_settings',
|
||||
'generate_secondary_nav_settings',
|
||||
'generate_spacing_settings',
|
||||
'generate_menu_plus_settings',
|
||||
'generate_woocommerce_settings',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns safely the license key.
|
||||
*/
|
||||
public static function get_license_key() {
|
||||
$license_key = get_option( 'gen_premium_license_key', '' );
|
||||
|
||||
if ( $license_key && strlen( $license_key ) > 4 ) {
|
||||
$hidden_length = strlen( $license_key ) - 4;
|
||||
$safe_part = substr( $license_key, 0, 4 );
|
||||
$hidden_part = implode('', array_fill( 0, $hidden_length, '*' ) );
|
||||
|
||||
return $safe_part . $hidden_part;
|
||||
}
|
||||
|
||||
return $license_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our scripts to the page.
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
if ( ! class_exists( 'GeneratePress_Dashboard' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dashboard_pages = GeneratePress_Dashboard::get_pages();
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( in_array( $current_screen->id, $dashboard_pages ) ) {
|
||||
wp_enqueue_style(
|
||||
'generate-pro-dashboard',
|
||||
GP_PREMIUM_DIR_URL . 'dist/style-dashboard.css',
|
||||
array( 'wp-components' ),
|
||||
GP_PREMIUM_VERSION
|
||||
);
|
||||
|
||||
if ( 'appearance_page_generate-options' === $current_screen->id ) {
|
||||
wp_enqueue_script(
|
||||
'generate-pro-dashboard',
|
||||
GP_PREMIUM_DIR_URL . 'dist/dashboard.js',
|
||||
array(),
|
||||
GP_PREMIUM_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_set_script_translations( 'generate-pro-dashboard', 'gp-premium', GP_PREMIUM_DIR_PATH . 'langs' );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-pro-dashboard',
|
||||
'generateProDashboard',
|
||||
array(
|
||||
'modules' => self::get_modules(),
|
||||
'exportableModules' => self::get_exportable_modules(),
|
||||
'siteLibraryUrl' => admin_url( 'themes.php?page=generatepress-library' ),
|
||||
'elementsUrl' => admin_url( 'edit.php?post_type=gp_elements' ),
|
||||
'hasWooCommerce' => class_exists( 'WooCommerce' ),
|
||||
'licenseKey' => self::get_license_key(),
|
||||
'licenseKeyStatus' => get_option( 'gen_premium_license_key_status', 'deactivated' ),
|
||||
'betaTester' => get_option( 'gp_premium_beta_testing', false ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable beta testing if our option is set.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @param boolean $value Whether beta testing is on or not.
|
||||
*/
|
||||
public function set_beta_tester( $value ) {
|
||||
if ( get_option( 'gp_premium_beta_testing', false ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the container for our start customizing app.
|
||||
*/
|
||||
public function module_list() {
|
||||
echo '<div id="generatepress-module-list"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the container for our start customizing app.
|
||||
*/
|
||||
public function license_key() {
|
||||
echo '<div id="generatepress-license-key"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the container for our start customizing app.
|
||||
*/
|
||||
public function import_export() {
|
||||
echo '<div id="generatepress-import-export-pro"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the container for our reset app.
|
||||
*/
|
||||
public function reset() {
|
||||
echo '<div id="generatepress-reset-pro"></div>';
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Pro_Dashboard::get_instance();
|
@ -0,0 +1,570 @@
|
||||
<?php
|
||||
/**
|
||||
* Rest API functions
|
||||
*
|
||||
* @package GenerateBlocks
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class GenerateBlocks_Rest
|
||||
*/
|
||||
class GeneratePress_Pro_Rest extends WP_REST_Controller {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'generatepress-pro/v';
|
||||
|
||||
/**
|
||||
* Version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $version = '1';
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* GeneratePress_Pro_Rest constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register rest routes.
|
||||
*/
|
||||
public function register_routes() {
|
||||
$namespace = $this->namespace . $this->version;
|
||||
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/modules/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'update_module' ),
|
||||
'permission_callback' => array( $this, 'update_settings_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/license/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'update_licensing' ),
|
||||
'permission_callback' => array( $this, 'update_settings_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/beta/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'update_beta_testing' ),
|
||||
'permission_callback' => array( $this, 'update_settings_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/export/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'export' ),
|
||||
'permission_callback' => array( $this, 'update_settings_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/import/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'import' ),
|
||||
'permission_callback' => array( $this, 'update_settings_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/reset/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'reset' ),
|
||||
'permission_callback' => array( $this, 'update_settings_permission' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit options permissions.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update_settings_permission() {
|
||||
return current_user_can( 'manage_options' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update modules.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_module( WP_REST_Request $request ) {
|
||||
$module_key = $request->get_param( 'key' );
|
||||
$action = $request->get_param( 'action' );
|
||||
$current_setting = get_option( $module_key, false );
|
||||
$modules = GeneratePress_Pro_Dashboard::get_modules();
|
||||
$safe_module_keys = array();
|
||||
|
||||
foreach ( $modules as $key => $data ) {
|
||||
$safe_module_keys[] = $data['key'];
|
||||
}
|
||||
|
||||
if ( ! in_array( $module_key, $safe_module_keys ) ) {
|
||||
return $this->failed( 'Bad module key.' );
|
||||
}
|
||||
|
||||
$message = '';
|
||||
|
||||
if ( 'activate' === $action ) {
|
||||
update_option( $module_key, 'activated' );
|
||||
$message = __( 'Module activated.', 'gp-premium' );
|
||||
}
|
||||
|
||||
if ( 'deactivate' === $action ) {
|
||||
update_option( $module_key, 'deactivated' );
|
||||
$message = __( 'Module deactivated.', 'gp-premium' );
|
||||
}
|
||||
|
||||
return $this->success( $message );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update licensing.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_licensing( WP_REST_Request $request ) {
|
||||
$new_license_key = $request->get_param( 'key' );
|
||||
$old_license = get_option( 'gen_premium_license_key', '' );
|
||||
$old_status = get_option( 'gen_premium_license_key_status', 'deactivated' );
|
||||
$new_license = strpos( $new_license_key, '***' ) !== false
|
||||
? trim( $old_license )
|
||||
: trim( $new_license_key );
|
||||
|
||||
if ( $new_license ) {
|
||||
$api_params = array(
|
||||
'edd_action' => 'activate_license',
|
||||
'license' => sanitize_key( $new_license ),
|
||||
'item_name' => rawurlencode( 'GP Premium' ),
|
||||
'url' => home_url(),
|
||||
);
|
||||
} elseif ( $old_license && 'valid' === $old_status ) {
|
||||
$api_params = array(
|
||||
'edd_action' => 'deactivate_license',
|
||||
'license' => sanitize_key( $old_license ),
|
||||
'item_name' => rawurlencode( 'GP Premium' ),
|
||||
'url' => home_url(),
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $api_params ) ) {
|
||||
$response = wp_remote_post(
|
||||
'https://generatepress.com',
|
||||
array(
|
||||
'timeout' => 30,
|
||||
'sslverify' => false,
|
||||
'body' => $api_params,
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error( $response ) || 200 !== (int) wp_remote_retrieve_response_code( $response ) ) {
|
||||
if ( is_object( $response ) ) {
|
||||
return $this->failed( $response->get_error_message() );
|
||||
} elseif ( is_array( $response ) && isset( $response['response']['message'] ) ) {
|
||||
if ( 'Forbidden' === $response['response']['message'] ) {
|
||||
$message = __( '403 Forbidden. Your server is not able to communicate with generatepress.com in order to activate your license key.', 'gp-premium' );
|
||||
} else {
|
||||
$message = $response['response']['message'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
|
||||
|
||||
if ( false === $license_data->success ) {
|
||||
switch ( $license_data->error ) {
|
||||
case 'expired':
|
||||
$message = sprintf(
|
||||
/* translators: License key expiration date. */
|
||||
__( 'Your license key expired on %s.', 'gp-premium' ),
|
||||
date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) ) // phpcs:ignore
|
||||
);
|
||||
break;
|
||||
|
||||
case 'disabled':
|
||||
case 'revoked':
|
||||
$message = __( 'Your license key has been disabled.', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'missing':
|
||||
$message = __( 'Invalid license.', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'invalid':
|
||||
case 'site_inactive':
|
||||
$message = __( 'Your license is not active for this URL.', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'item_name_mismatch':
|
||||
/* translators: GP Premium */
|
||||
$message = sprintf( __( 'This appears to be an invalid license key for %s.', 'gp-premium' ), __( 'GP Premium', 'gp-premium' ) );
|
||||
break;
|
||||
|
||||
case 'no_activations_left':
|
||||
$message = __( 'Your license key has reached its activation limit.', 'gp-premium' );
|
||||
break;
|
||||
|
||||
default:
|
||||
$message = __( 'An error occurred, please try again.', 'gp-premium' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'gen_premium_license_key_status', esc_attr( $license_data->license ) );
|
||||
}
|
||||
|
||||
update_option( 'gen_premium_license_key', sanitize_key( $new_license ) );
|
||||
|
||||
if ( ! isset( $api_params ) ) {
|
||||
return $this->success( __( 'Settings saved.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $message ) ) {
|
||||
return $this->failed( $message );
|
||||
}
|
||||
|
||||
return $this->success( $license_data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update licensing.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_beta_testing( WP_REST_Request $request ) {
|
||||
$new_beta_tester = $request->get_param( 'beta' );
|
||||
|
||||
if ( ! empty( $new_beta_tester ) ) {
|
||||
update_option( 'gp_premium_beta_testing', true, false );
|
||||
} else {
|
||||
delete_option( 'gp_premium_beta_testing' );
|
||||
}
|
||||
|
||||
if ( ! isset( $api_params ) ) {
|
||||
return $this->success( __( 'Settings saved.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $message ) ) {
|
||||
return $this->failed( $message );
|
||||
}
|
||||
|
||||
return $this->success( $license_data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Export settings.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function export( WP_REST_Request $request ) {
|
||||
$exportable_modules = $request->get_param( 'items' );
|
||||
|
||||
if ( ! $exportable_modules ) {
|
||||
$exportable_modules = GeneratePress_Pro_Dashboard::get_exportable_modules();
|
||||
}
|
||||
|
||||
$export_type = $request->get_param( 'type' );
|
||||
|
||||
if ( 'all' === $export_type ) {
|
||||
$data = array(
|
||||
'modules' => array(),
|
||||
'mods' => array(),
|
||||
'options' => array(),
|
||||
);
|
||||
|
||||
$module_settings = array();
|
||||
|
||||
foreach ( $exportable_modules as $exported_module_key => $exported_module_data ) {
|
||||
if ( isset( $exported_module_data['settings'] ) ) {
|
||||
$module_settings[] = $exported_module_data['settings'];
|
||||
}
|
||||
}
|
||||
|
||||
$modules = GeneratePress_Pro_Dashboard::get_modules();
|
||||
|
||||
// Export module status of the exported options.
|
||||
foreach ( $modules as $module_key => $module_data ) {
|
||||
if ( isset( $module_data['settings'] ) && in_array( $module_data['settings'], $module_settings ) ) {
|
||||
$data['modules'][ $module_key ] = $module_data['key'];
|
||||
}
|
||||
}
|
||||
|
||||
$theme_mods = GeneratePress_Pro_Dashboard::get_theme_mods();
|
||||
|
||||
foreach ( $theme_mods as $theme_mod ) {
|
||||
if ( 'generate_copyright' === $theme_mod ) {
|
||||
if ( in_array( 'copyright', $module_settings ) ) {
|
||||
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
|
||||
}
|
||||
} else {
|
||||
if ( in_array( 'generate_settings', $module_settings ) ) {
|
||||
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$settings = GeneratePress_Pro_Dashboard::get_setting_keys();
|
||||
|
||||
foreach ( $settings as $setting ) {
|
||||
if ( in_array( $setting, $module_settings ) ) {
|
||||
$data['options'][ $setting ] = get_option( $setting );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'global-colors' === $export_type ) {
|
||||
$data['global-colors'] = generate_get_option( 'global_colors' );
|
||||
}
|
||||
|
||||
if ( 'typography' === $export_type ) {
|
||||
$data['font-manager'] = generate_get_option( 'font_manager' );
|
||||
$data['typography'] = generate_get_option( 'typography' );
|
||||
}
|
||||
|
||||
$data = apply_filters( 'generate_export_data', $data, $export_type );
|
||||
|
||||
return $this->success( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Import settings.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function import( WP_REST_Request $request ) {
|
||||
$settings = $request->get_param( 'import' );
|
||||
|
||||
if ( empty( $settings ) ) {
|
||||
$this->failed( __( 'No settings to import.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $settings['typography'] ) ) {
|
||||
$existing_settings = get_option( 'generate_settings', array() );
|
||||
$existing_settings['typography'] = $settings['typography'];
|
||||
|
||||
if ( ! empty( $settings['font-manager'] ) ) {
|
||||
$existing_settings['font_manager'] = $settings['font-manager'];
|
||||
}
|
||||
|
||||
update_option( 'generate_settings', $existing_settings );
|
||||
} elseif ( ! empty( $settings['global-colors'] ) ) {
|
||||
$existing_settings = get_option( 'generate_settings', array() );
|
||||
$existing_settings['global_colors'] = $settings['global-colors'];
|
||||
|
||||
update_option( 'generate_settings', $existing_settings );
|
||||
} else {
|
||||
$modules = GeneratePress_Pro_Dashboard::get_modules();
|
||||
|
||||
foreach ( (array) $settings['modules'] as $key => $val ) {
|
||||
if ( isset( $modules[ $key ] ) && in_array( $val, $modules[ $key ] ) ) {
|
||||
update_option( $val, 'activated' );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( (array) $settings['mods'] as $key => $val ) {
|
||||
if ( in_array( $key, GeneratePress_Pro_Dashboard::get_theme_mods() ) ) {
|
||||
set_theme_mod( $key, $val );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( (array) $settings['options'] as $key => $val ) {
|
||||
if ( in_array( $key, GeneratePress_Pro_Dashboard::get_setting_keys() ) ) {
|
||||
update_option( $key, $val );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete existing 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 );
|
||||
|
||||
return $this->success( __( 'Settings imported.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset settings.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function reset( WP_REST_Request $request ) {
|
||||
$reset_items = $request->get_param( 'items' );
|
||||
|
||||
if ( ! $reset_items ) {
|
||||
$reset_items = GeneratePress_Pro_Dashboard::get_exportable_modules();
|
||||
}
|
||||
|
||||
$module_settings = array();
|
||||
|
||||
foreach ( $reset_items as $reset_module_key => $reset_module_data ) {
|
||||
if ( isset( $reset_module_data['settings'] ) ) {
|
||||
$module_settings[] = $reset_module_data['settings'];
|
||||
}
|
||||
}
|
||||
|
||||
$theme_mods = GeneratePress_Pro_Dashboard::get_theme_mods();
|
||||
|
||||
foreach ( $theme_mods as $theme_mod ) {
|
||||
if ( 'generate_copyright' === $theme_mod ) {
|
||||
if ( in_array( 'copyright', $module_settings ) ) {
|
||||
remove_theme_mod( $theme_mod );
|
||||
}
|
||||
} else {
|
||||
if ( in_array( 'generate_settings', $module_settings ) ) {
|
||||
remove_theme_mod( $theme_mod );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$settings = GeneratePress_Pro_Dashboard::get_setting_keys();
|
||||
|
||||
foreach ( $settings as $setting ) {
|
||||
if ( in_array( $setting, $module_settings ) ) {
|
||||
delete_option( $setting );
|
||||
}
|
||||
}
|
||||
|
||||
// Delete our dynamic CSS option.
|
||||
delete_option( 'generate_dynamic_css_output' );
|
||||
delete_option( 'generate_dynamic_css_cached_version' );
|
||||
|
||||
// Reset our dynamic CSS file updated time so it regenerates.
|
||||
$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 );
|
||||
|
||||
// Delete any GeneratePress Site CSS in Additional CSS.
|
||||
$additional_css = wp_get_custom_css_post();
|
||||
|
||||
if ( ! empty( $additional_css ) ) {
|
||||
$additional_css->post_content = preg_replace( '#(/\\* GeneratePress Site CSS \\*/).*?(/\\* End GeneratePress Site CSS \\*/)#s', '', $additional_css->post_content );
|
||||
wp_update_custom_css_post( $additional_css->post_content );
|
||||
}
|
||||
|
||||
return $this->success( __( 'Settings reset.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Success rest.
|
||||
*
|
||||
* @param mixed $response response data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function success( $response ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
'success' => true,
|
||||
'response' => $response,
|
||||
),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed rest.
|
||||
*
|
||||
* @param mixed $response response data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function failed( $response ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
'success' => false,
|
||||
'response' => $response,
|
||||
),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error rest.
|
||||
*
|
||||
* @param mixed $code error code.
|
||||
* @param mixed $response response data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function error( $code, $response ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
'error' => true,
|
||||
'success' => false,
|
||||
'error_code' => $code,
|
||||
'response' => $response,
|
||||
),
|
||||
401
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Pro_Rest::get_instance();
|
@ -0,0 +1,790 @@
|
||||
<?php
|
||||
/**
|
||||
* Deprecated admin functions.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if we're in the Site dashboard.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function generate_is_sites_dashboard() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( ! is_object( $screen ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'appearance_page_generatepress-site-library' === $screen->id ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the Sites tab to our Dashboard tabs.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @param array $tabs Existing tabs.
|
||||
* @return array New tabs.
|
||||
*/
|
||||
function generate_sites_dashboard_tab( $tabs ) {
|
||||
$tabs['Sites'] = array(
|
||||
'name' => __( 'Site Library', 'gp-premium' ),
|
||||
'url' => admin_url( 'themes.php?page=generatepress-site-library' ),
|
||||
'class' => generate_is_sites_dashboard() ? 'active' : '',
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register our Site Library page.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
function generate_site_library_register() {
|
||||
add_submenu_page(
|
||||
'themes.php',
|
||||
__( 'Site Library', 'gp-premium' ),
|
||||
__( 'Site Library', 'gp-premium' ),
|
||||
'manage_options',
|
||||
'generatepress-site-library',
|
||||
'generate_sites_container'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set our current menu item as the GeneratePress Dashboard.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
function generate_site_library_fix_menu() {
|
||||
global $parent_file, $submenu_file, $post_type;
|
||||
|
||||
if ( generate_is_sites_dashboard() ) {
|
||||
$parent_file = 'themes.php'; // phpcs:ignore -- Override necessary.
|
||||
$submenu_file = 'generate-options'; // phpcs:ignore -- Override necessary.
|
||||
}
|
||||
|
||||
remove_submenu_page( 'themes.php', 'generatepress-site-library' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our scripts for the site library.
|
||||
*
|
||||
* @since 1.8
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
function generate_sites_do_enqueue_scripts() {
|
||||
if ( ! generate_is_sites_dashboard() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$backup_data = get_option( '_generatepress_site_library_backup', array() );
|
||||
|
||||
wp_enqueue_script(
|
||||
'generate-sites-admin',
|
||||
GENERATE_SITES_URL . 'assets/js/admin.js',
|
||||
array( 'jquery', 'wp-util', 'updates', 'generate-sites-blazy' ),
|
||||
GP_PREMIUM_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'generate-sites-download',
|
||||
GENERATE_SITES_URL . 'assets/js/download.js',
|
||||
array( 'jquery', 'generate-sites-admin' ),
|
||||
GP_PREMIUM_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_enqueue_script(
|
||||
'generate-sites-blazy',
|
||||
GENERATE_SITES_URL . 'assets/js/blazy.min.js',
|
||||
array(),
|
||||
GP_PREMIUM_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
'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' ),
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'generate-sites-admin',
|
||||
GENERATE_SITES_URL . 'assets/css/admin.css',
|
||||
array(),
|
||||
GP_PREMIUM_VERSION
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'generate-premium-dashboard',
|
||||
plugin_dir_url( dirname( __FILE__ ) ) . 'inc/assets/dashboard.css',
|
||||
array(),
|
||||
GP_PREMIUM_VERSION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a body class while in the Site Library.
|
||||
*
|
||||
* @since 1.8
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @param array $classes Current body classes.
|
||||
* @return array Existing and our new body classes
|
||||
*/
|
||||
function generate_sites_do_admin_body_classes( $classes ) {
|
||||
if ( generate_is_sites_dashboard() ) {
|
||||
$classes .= ' generate-sites';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an opening wrapper element for our Dashboard tabs and page builder links.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
function generate_sites_add_tabs_wrapper_open() {
|
||||
echo '<div class="site-library-tabs-wrapper">';
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds our Site dashboard container.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
function generate_sites_container() {
|
||||
?>
|
||||
<div class="generate-site-library">
|
||||
<div class="site-library-header">
|
||||
<div class="site-library-container">
|
||||
<div class="library-title">
|
||||
<?php _e( 'GeneratePress Site Library', 'gp-premium' ); ?>
|
||||
</div>
|
||||
|
||||
<div class="library-links">
|
||||
<a href="https://generatepress.com/support" target="_blank"><?php _e( 'Support', 'gp-premium' ); ?></a>
|
||||
<a href="https://docs.generatepress.com" target="_blank"><?php _e( 'Documentation', 'gp-premium' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="site-library-container">
|
||||
<?php
|
||||
do_action( 'generate_inside_site_library_container' );
|
||||
|
||||
$site_data = get_transient( 'generatepress_sites' );
|
||||
$page_builders = array();
|
||||
|
||||
foreach ( (array) $site_data as $data ) {
|
||||
if ( isset( $data['page_builder'][0] ) ) {
|
||||
$page_builder = $data['page_builder'][0];
|
||||
$page_builder_id = str_replace( ' ', '-', strtolower( $page_builder ) );
|
||||
|
||||
if ( 'no-page-builder' !== $page_builder_id ) {
|
||||
$page_builders[ $page_builder_id ] = $page_builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<div class="library-filters">';
|
||||
|
||||
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 ) {
|
||||
printf(
|
||||
'<option value="%1$s">%2$s</option>',
|
||||
esc_attr( $id ),
|
||||
esc_html( $name )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
</div> <!-- .site-library-tabs-wrapper -->
|
||||
<?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;
|
||||
|
||||
if ( ! empty( $backup_data ) ) {
|
||||
$show_remove_site = true;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="remove-site" style="<?php echo ! $show_remove_site ? 'display: none' : ''; ?>">
|
||||
<h2><?php _e( 'Existing Site Import Detected', 'gp-premium' ); ?></h2>
|
||||
|
||||
<div class="remove-site-content">
|
||||
<p><?php _e( 'It is highly recommended that you remove the last site you imported before importing a new one.', 'gp-premium' ); ?></p>
|
||||
<p><?php _e( 'This process restores your previous options, widgets and active plugins. It will also remove your imported content and CSS.', 'gp-premium' ); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="remove-site-actions">
|
||||
<button class="do-remove-site button-primary"><?php _e( 'Remove Imported Site', 'gp-premium' ); ?></button>
|
||||
<a class="skip-remove-site" href="#"><?php _e( 'Skip', 'gp-premium' ); ?></a>
|
||||
|
||||
<div class="loading" style="display: none;">
|
||||
<span class="remove-site-message"></span>
|
||||
<?php GeneratePress_Sites_Helper::loading_icon(); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="generatepress-sites generatepress-admin-block <?php echo $show_remove_site ? 'remove-site-needed' : ''; ?>" id="sites" data-page-builder=".no-page-builder">
|
||||
<?php do_action( 'generate_inside_sites_container' ); ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
printf(
|
||||
'<div class="refresh-sites">
|
||||
<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_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>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh our list of sites.
|
||||
*
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our page header meta slugs.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function generate_sites_export_page_headers() {
|
||||
$args = array(
|
||||
'post_type' => get_post_types( array( 'public' => true ) ),
|
||||
'showposts' => -1,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_generate-select-page-header',
|
||||
'compare' => 'EXISTS',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$posts = get_posts( $args );
|
||||
$new_values = array();
|
||||
|
||||
foreach ( $posts as $post ) {
|
||||
$page_header_id = get_post_meta( $post->ID, '_generate-select-page-header', true );
|
||||
|
||||
if ( $page_header_id ) {
|
||||
$new_values[ $post->ID ] = $page_header_id;
|
||||
}
|
||||
}
|
||||
|
||||
return $new_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our Element display locations.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function generate_sites_export_elements_location() {
|
||||
$args = array(
|
||||
'post_type' => 'gp_elements',
|
||||
'showposts' => -1,
|
||||
);
|
||||
|
||||
$posts = get_posts( $args );
|
||||
$new_values = array();
|
||||
|
||||
foreach ( $posts as $post ) {
|
||||
$display_conditions = get_post_meta( $post->ID, '_generate_element_display_conditions', true );
|
||||
|
||||
if ( $display_conditions ) {
|
||||
$new_values[ $post->ID ] = $display_conditions;
|
||||
}
|
||||
}
|
||||
|
||||
return $new_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our Element display locations.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function generate_sites_export_elements_exclusion() {
|
||||
$args = array(
|
||||
'post_type' => 'gp_elements',
|
||||
'showposts' => -1,
|
||||
);
|
||||
|
||||
$posts = get_posts( $args );
|
||||
$new_values = array();
|
||||
|
||||
foreach ( $posts as $post ) {
|
||||
$display_conditions = get_post_meta( $post->ID, '_generate_element_exclude_conditions', true );
|
||||
|
||||
if ( $display_conditions ) {
|
||||
$new_values[ $post->ID ] = $display_conditions;
|
||||
}
|
||||
}
|
||||
|
||||
return $new_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* List out compatible theme modules Sites can activate.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function generatepress_get_site_premium_modules() {
|
||||
return array(
|
||||
'Backgrounds' => 'generate_package_backgrounds',
|
||||
'Blog' => 'generate_package_blog',
|
||||
'Colors' => 'generate_package_colors',
|
||||
'Copyright' => 'generate_package_copyright',
|
||||
'Elements' => 'generate_package_elements',
|
||||
'Disable Elements' => 'generate_package_disable_elements',
|
||||
'Hooks' => 'generate_package_hooks',
|
||||
'Menu Plus' => 'generate_package_menu_plus',
|
||||
'Page Header' => 'generate_package_page_header',
|
||||
'Secondary Nav' => 'generate_package_secondary_nav',
|
||||
'Sections' => 'generate_package_sections',
|
||||
'Spacing' => 'generate_package_spacing',
|
||||
'Typography' => 'generate_package_typography',
|
||||
'WooCommerce' => 'generate_package_woocommerce',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't allow Sites to modify these options.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function generatepress_sites_disallowed_options() {
|
||||
return array(
|
||||
'admin_email',
|
||||
'siteurl',
|
||||
'home',
|
||||
'blog_charset',
|
||||
'blog_public',
|
||||
'current_theme',
|
||||
'stylesheet',
|
||||
'template',
|
||||
'default_role',
|
||||
'mailserver_login',
|
||||
'mailserver_pass',
|
||||
'mailserver_port',
|
||||
'mailserver_url',
|
||||
'permalink_structure',
|
||||
'rewrite_rules',
|
||||
'users_can_register',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our GeneratePress Site export checkbox to the Export module.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
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;" />
|
||||
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generatepress-site" />
|
||||
<?php _ex( 'GeneratePress Site', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to our export .json file.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 2.0.0
|
||||
*
|
||||
* @param array $data The current data being exported.
|
||||
* @return array Existing and extended data.
|
||||
*/
|
||||
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'] ) ) { // phpcs:ignore -- No processing happening here.
|
||||
return $data;
|
||||
}
|
||||
|
||||
// Modules.
|
||||
$modules = generatepress_get_site_premium_modules();
|
||||
|
||||
$data['modules'] = array();
|
||||
foreach ( $modules as $name => $key ) {
|
||||
if ( 'activated' === get_option( $key ) ) {
|
||||
$data['modules'][ $name ] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
// 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' );
|
||||
|
||||
// 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.
|
||||
$data['site_options']['element_locations'] = generate_sites_export_elements_location();
|
||||
$data['site_options']['element_exclusions'] = generate_sites_export_elements_exclusion();
|
||||
|
||||
// Custom CSS.
|
||||
if ( function_exists( 'wp_get_custom_css_post' ) ) {
|
||||
$data['custom_css'] = wp_get_custom_css_post()->post_content;
|
||||
}
|
||||
|
||||
// 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' );
|
||||
}
|
||||
|
||||
// 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_load_fa4_shim'] = get_option( 'elementor_load_fa4_shim' );
|
||||
$data['site_options']['elementor_active_kit'] = get_option( 'elementor_active_kit' );
|
||||
}
|
||||
|
||||
// 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' );
|
||||
}
|
||||
|
||||
// Menu Icons.
|
||||
if ( is_plugin_active( 'menu-icons/menu-icons.php' ) ) {
|
||||
$data['site_options']['menu-icons'] = get_option( 'menu-icons' );
|
||||
}
|
||||
|
||||
// Ninja Forms.
|
||||
if ( is_plugin_active( 'ninja-forms/ninja-forms.php' ) ) {
|
||||
$data['site_options']['ninja_forms_settings'] = get_option( 'ninja_forms_settings' );
|
||||
}
|
||||
|
||||
// Social Warfare.
|
||||
if ( is_plugin_active( 'social-warfare/social-warfare.php' ) ) {
|
||||
$data['site_options']['socialWarfareOptions'] = get_option( 'socialWarfareOptions' );
|
||||
}
|
||||
|
||||
// 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.
|
||||
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.
|
||||
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 = 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',
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $ignore as $plugin ) {
|
||||
unset( $all_plugins[ $plugin ] );
|
||||
}
|
||||
|
||||
$activated_plugins = array();
|
||||
|
||||
foreach ( $active_plugins as $p ) {
|
||||
if ( isset( $all_plugins[ $p ] ) ) {
|
||||
$activated_plugins[ $all_plugins[ $p ]['Name'] ] = $p;
|
||||
}
|
||||
}
|
||||
|
||||
$data['plugins'] = $activated_plugins;
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our sites from the site server.
|
||||
*
|
||||
* @since 1.12.0'
|
||||
* @deprecated 2.0.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 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch our sites and trusted authors. Stores them in their own transients.
|
||||
* We use current_screen instead of admin_init so we can check what admin page we're on.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
function generatepress_sites_init() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( 'appearance_page_generate-options' === $screen->id || 'appearance_page_generatepress-site-library' === $screen->id ) {
|
||||
generate_get_sites_from_library();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate our Sites once everything has loaded.
|
||||
* We use current_screen instead of admin_init so we can check what admin page we're on.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
function generatepress_sites_output() {
|
||||
if ( ! class_exists( 'GeneratePress_Site' ) ) {
|
||||
return; // Bail if we don't have the needed class.
|
||||
}
|
||||
|
||||
$sites = get_transient( 'generatepress_sites' );
|
||||
|
||||
if ( empty( $sites ) || ! is_array( $sites ) ) {
|
||||
add_action( 'generate_inside_sites_container', 'generatepress_sites_no_results_error' );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( apply_filters( 'generate_sites_randomize', false ) ) {
|
||||
shuffle( $sites );
|
||||
}
|
||||
|
||||
foreach ( $sites as $site ) {
|
||||
new GeneratePress_Site( $site );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an error message when no sites exist.
|
||||
*
|
||||
* @since 1.8.2
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
function generatepress_sites_no_results_error() {
|
||||
printf(
|
||||
'<div class="no-site-library-results">
|
||||
%1$s <a href="%3$s" target="_blank" rel="noopener noreferrer">%2$s</a>
|
||||
</div>',
|
||||
__( 'No sites found.', 'gp-premium' ),
|
||||
__( 'Why?', 'gp-premium' ),
|
||||
'https://docs.generatepress.com/article/site-library-unavailable/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build each site UI.
|
||||
*
|
||||
* @deprecated 2.0.0
|
||||
*/
|
||||
class GeneratePress_Site {
|
||||
/**
|
||||
* Get it rockin'
|
||||
*
|
||||
* @param array $config The site configuration.
|
||||
*/
|
||||
public function __construct( $config = array() ) {
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
@ -0,0 +1,718 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Backgrounds module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_backgrounds_customize_preview_css' ) ) {
|
||||
function generate_backgrounds_customize_preview_css() {
|
||||
// No longer needed.
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_backgrounds_init' ) ) {
|
||||
function generate_backgrounds_init() {
|
||||
load_plugin_textdomain( 'backgrounds', false, 'gp-premium/langs/backgrounds/' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_backgrounds_setup' ) ) {
|
||||
function generate_backgrounds_setup() {
|
||||
// This function is here just in case
|
||||
// It's kept so we can check to see if Backgrounds is active elsewhere
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Blog module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_blog_post_image' ) ) {
|
||||
/**
|
||||
* Build our featured image HTML
|
||||
*
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
function generate_blog_post_image() {
|
||||
// No longer needed
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_get_masonry_post_width' ) ) {
|
||||
/**
|
||||
* Set our masonry post width
|
||||
*
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
function generate_get_masonry_post_width() {
|
||||
// Get our global variables
|
||||
global $post, $wp_query;
|
||||
|
||||
// Figure out which page we're on
|
||||
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
|
||||
|
||||
// Figure out if we're on the most recent post or not
|
||||
$most_recent = ( $wp_query->current_post == 0 && $paged == 1 ) ? true : false;
|
||||
|
||||
// Get our Customizer options
|
||||
$generate_blog_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
$masonry_post_width = $generate_blog_settings['masonry_width'];
|
||||
|
||||
// Get our post meta option
|
||||
$stored_meta = ( isset( $post ) ) ? get_post_meta( $post->ID, '_generate-blog-post-class', true ) : '';
|
||||
|
||||
// If our post meta option is set, use it
|
||||
// Or else, use our Customizer option
|
||||
if ( '' !== $stored_meta ) {
|
||||
if ( 'width4' == $stored_meta && 'width4' == $generate_blog_settings['masonry_width'] ) {
|
||||
$masonry_post_width = 'medium';
|
||||
} else {
|
||||
$masonry_post_width = $stored_meta;
|
||||
}
|
||||
}
|
||||
|
||||
// Return our width class
|
||||
return apply_filters( 'generate_masonry_post_width', $masonry_post_width );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_add_post_class_meta_box' ) ) {
|
||||
/**
|
||||
* Create our masonry meta box
|
||||
*
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
function generate_blog_add_post_class_meta_box() {
|
||||
$generate_blog_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'true' !== $generate_blog_settings['masonry'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_types = apply_filters( 'generate_blog_masonry_metabox', array( 'post' ) );
|
||||
|
||||
add_meta_box
|
||||
(
|
||||
'generate_blog_post_class_meta_box', // $id
|
||||
__('Masonry Post Width','generate-blog'), // $title
|
||||
'generate_blog_show_post_class_metabox', // $callback
|
||||
$post_types, // $page
|
||||
'side', // $context
|
||||
'default' // $priority
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_show_post_class_metabox' ) ) {
|
||||
/**
|
||||
* Outputs the content of the metabox
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
function generate_blog_show_post_class_metabox( $post ) {
|
||||
wp_nonce_field( basename( __FILE__ ), 'generate_blog_post_class_nonce' );
|
||||
$stored_meta = get_post_meta( $post->ID );
|
||||
|
||||
// Set defaults to avoid PHP notices
|
||||
if ( isset($stored_meta['_generate-blog-post-class'][0]) ) {
|
||||
$stored_meta['_generate-blog-post-class'][0] = $stored_meta['_generate-blog-post-class'][0];
|
||||
} else {
|
||||
$stored_meta['_generate-blog-post-class'][0] = '';
|
||||
}
|
||||
?>
|
||||
<p>
|
||||
<label for="_generate-blog-post-class" class="example-row-title"><strong><?php _e( 'Masonry Post Width', 'gp-premium' );?></strong></label><br />
|
||||
<select name="_generate-blog-post-class" id="_generate-blog-post-class">
|
||||
<option value="" <?php selected( $stored_meta['_generate-blog-post-class'][0], '' ); ?>><?php _e( 'Global setting', 'gp-premium' );?></option>
|
||||
<option value="width2" <?php selected( $stored_meta['_generate-blog-post-class'][0], 'width2' ); ?>><?php _e( 'Small', 'gp-premium' );?></option>
|
||||
<option value="width4" <?php selected( $stored_meta['_generate-blog-post-class'][0], 'width4' ); ?>><?php _e( 'Medium', 'gp-premium' );?></option>
|
||||
<option value="width6" <?php selected( $stored_meta['_generate-blog-post-class'][0], 'width6' ); ?>><?php _e( 'Large', 'gp-premium' );?></option>
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_save_post_class_meta' ) ) {
|
||||
/**
|
||||
* Saves post class meta data
|
||||
*
|
||||
* @param int $post_id The post ID being saved
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
function generate_blog_save_post_class_meta( $post_id ) {
|
||||
// Checks save status
|
||||
$is_autosave = wp_is_post_autosave( $post_id );
|
||||
$is_revision = wp_is_post_revision( $post_id );
|
||||
$is_valid_nonce = ( isset( $_POST[ 'generate_blog_post_class_nonce' ] ) && wp_verify_nonce( $_POST[ 'generate_blog_post_class_nonce' ], basename( __FILE__ ) ) ) ? true : false;
|
||||
|
||||
// Exits script depending on save status
|
||||
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Checks for input and saves if needed
|
||||
if ( isset( $_POST[ '_generate-blog-post-class' ] ) ) {
|
||||
update_post_meta( $post_id, '_generate-blog-post-class', sanitize_text_field( $_POST[ '_generate-blog-post-class' ] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_get_next_posts_url' ) ) {
|
||||
/**
|
||||
* Get the URL of the next page
|
||||
* This is for the AJAX load more function
|
||||
*/
|
||||
function generate_blog_get_next_posts_url( $max_page = 0 ) {
|
||||
global $paged, $wp_query;
|
||||
|
||||
if ( ! $max_page ) {
|
||||
$max_page = $wp_query->max_num_pages;
|
||||
}
|
||||
|
||||
if ( ! $paged ) {
|
||||
$paged = 1;
|
||||
}
|
||||
|
||||
$nextpage = intval( $paged ) + 1;
|
||||
|
||||
if ( ! is_single() && ( $nextpage <= $max_page ) ) {
|
||||
return next_posts( $max_page, false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes a bug in Safari where images with srcset won't display when using infinite scroll.
|
||||
*
|
||||
* @since 1.5.5
|
||||
* @deprecated 1.6
|
||||
*/
|
||||
function generate_blog_disable_infinite_scroll_srcset() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! is_singular() && $settings[ 'infinite_scroll' ] ) {
|
||||
add_filter( 'wp_calculate_image_srcset', '__return_empty_array' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_init' ) ) {
|
||||
function generate_blog_init() {
|
||||
load_plugin_textdomain( 'generate-blog', false, 'gp-premium/langs/blog/' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Colors module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_colors_init' ) ) {
|
||||
function generate_colors_init() {
|
||||
load_plugin_textdomain( 'generate-colors', false, 'gp-premium/langs/colors/' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_colors_setup' ) ) {
|
||||
function generate_colors_setup() {
|
||||
// Here so we can check to see if Colors is activated
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_copyright_init' ) ) {
|
||||
function generate_copyright_init() {
|
||||
load_plugin_textdomain( 'generate-copyright', false, 'gp-premium/langs/copyright/' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable Elements module.
|
||||
*/
|
||||
if ( ! function_exists('generate_disable_elements_init') ) {
|
||||
function generate_disable_elements_init() {
|
||||
load_plugin_textdomain( 'disable-elements', false, 'gp-premium/langs/disable-elements/' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_hooks_init' ) ) {
|
||||
function generate_hooks_init() {
|
||||
load_plugin_textdomain( 'generate-hooks', false, 'gp-premium/langs/hooks/' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import/Export module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_ie_init' ) ) {
|
||||
function generate_ie_init() {
|
||||
load_plugin_textdomain( 'generate-ie', false, 'gp-premium/langs/import-export/' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu Plus module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_slideout_navigation_class' ) ) {
|
||||
/**
|
||||
* Display the classes for the slideout navigation.
|
||||
*
|
||||
* @since 0.1
|
||||
* @param string|array $class One or more classes to add to the class list.
|
||||
*/
|
||||
function generate_slideout_navigation_class( $class = '' ) {
|
||||
// Separates classes with a single space, collates classes for post DIV
|
||||
echo 'class="' . join( ' ', generate_get_slideout_navigation_class( $class ) ) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_get_slideout_navigation_class' ) ) {
|
||||
/**
|
||||
* Retrieve the classes for the slideout navigation.
|
||||
*
|
||||
* @since 0.1
|
||||
* @param string|array $class One or more classes to add to the class list.
|
||||
* @return array Array of classes.
|
||||
*/
|
||||
function generate_get_slideout_navigation_class( $class = '' ) {
|
||||
$classes = array();
|
||||
|
||||
if ( !empty($class) ) {
|
||||
if ( !is_array( $class ) )
|
||||
$class = preg_split('#\s+#', $class);
|
||||
$classes = array_merge($classes, $class);
|
||||
}
|
||||
|
||||
$classes = array_map('esc_attr', $classes);
|
||||
|
||||
return apply_filters('generate_slideout_navigation_class', $classes, $class);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_slideout_menu_class' ) ) {
|
||||
/**
|
||||
* Display the classes for the slideout navigation.
|
||||
*
|
||||
* @since 0.1
|
||||
* @param string|array $class One or more classes to add to the class list.
|
||||
*/
|
||||
function generate_slideout_menu_class( $class = '' ) {
|
||||
// Separates classes with a single space, collates classes for post DIV
|
||||
echo 'class="' . join( ' ', generate_get_slideout_menu_class( $class ) ) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_get_slideout_menu_class' ) ) {
|
||||
/**
|
||||
* Retrieve the classes for the slideout navigation.
|
||||
*
|
||||
* @since 0.1
|
||||
* @param string|array $class One or more classes to add to the class list.
|
||||
* @return array Array of classes.
|
||||
*/
|
||||
function generate_get_slideout_menu_class( $class = '' ) {
|
||||
$classes = array();
|
||||
|
||||
if ( !empty($class) ) {
|
||||
if ( !is_array( $class ) )
|
||||
$class = preg_split('#\s+#', $class);
|
||||
$classes = array_merge($classes, $class);
|
||||
}
|
||||
|
||||
$classes = array_map('esc_attr', $classes);
|
||||
|
||||
return apply_filters('generate_slideout_menu_class', $classes, $class);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_slideout_menu_classes' ) ) {
|
||||
/**
|
||||
* Adds custom classes to the menu
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_slideout_menu_classes( $classes ) {
|
||||
$classes[] = 'slideout-menu';
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_slideout_navigation_classes' ) ) {
|
||||
/**
|
||||
* Adds custom classes to the navigation
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_slideout_navigation_classes( $classes ){
|
||||
$slideout_effect = apply_filters( 'generate_menu_slideout_effect','overlay' );
|
||||
$slideout_position = apply_filters( 'generate_menu_slideout_position','left' );
|
||||
|
||||
$classes[] = 'main-navigation';
|
||||
$classes[] = 'slideout-navigation';
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_menu_plus_init' ) ) {
|
||||
function generate_menu_plus_init() {
|
||||
load_plugin_textdomain( 'menu-plus', false, 'gp-premium/langs/menu-plus/' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_slideout_menu_fallback' ) ) {
|
||||
/**
|
||||
* Menu fallback.
|
||||
*
|
||||
* @param array $args
|
||||
* @return string
|
||||
* @since 1.1.4
|
||||
*/
|
||||
function generate_slideout_menu_fallback( $args ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Page header module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_page_header_inside' ) ) {
|
||||
/**
|
||||
* Add page header inside content
|
||||
* @since 0.3
|
||||
*/
|
||||
function generate_page_header_inside() {
|
||||
if ( ! is_page() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'inside-content' == generate_get_page_header_location() ) {
|
||||
generate_page_header_area( 'page-header-image', 'page-header-content' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_single_below_title' ) ) {
|
||||
/**
|
||||
* Add post header below title
|
||||
* @since 0.3
|
||||
*/
|
||||
function generate_page_header_single_below_title() {
|
||||
if ( ! is_single() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'below-title' == generate_get_page_header_location() ) {
|
||||
generate_page_header_area( 'page-header-image-single page-header-below-title', 'page-header-content-single page-header-below-title' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_single_above' ) ) {
|
||||
/**
|
||||
* Add post header above content
|
||||
* @since 0.3
|
||||
*/
|
||||
function generate_page_header_single_above() {
|
||||
if ( ! is_single() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'above-content' == generate_get_page_header_location() ) {
|
||||
generate_page_header_area( 'page-header-image-single', 'page-header-content-single' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_single' ) ) {
|
||||
/**
|
||||
* Add post header inside content
|
||||
* @since 0.3
|
||||
*/
|
||||
function generate_page_header_single() {
|
||||
$image_class = 'page-header-image-single';
|
||||
$content_class = 'page-header-content-single';
|
||||
|
||||
if ( 'below-title' == generate_get_page_header_location() ) {
|
||||
$image_class = 'page-header-image-single page-header-below-title';
|
||||
$content_class = 'page-header-content-single page-header-below-title';
|
||||
}
|
||||
|
||||
if ( 'inside-content' == generate_get_page_header_location() ) {
|
||||
generate_page_header_area( $image_class, $content_class );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_page_header_init' ) ) {
|
||||
function generate_page_header_init() {
|
||||
load_plugin_textdomain( 'page-header', false, 'gp-premium/langs/page-header/' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Secondary Navigation module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_secondary_nav_init' ) ) {
|
||||
function generate_secondary_nav_init() {
|
||||
load_plugin_textdomain( 'secondary-nav', false, 'gp-premium/langs/secondary-nav/' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sections module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_sections_init' ) ) {
|
||||
function generate_sections_init() {
|
||||
load_plugin_textdomain( 'generate-sections', false, 'gp-premium/langs/sections/' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_sections_metabox_init' ) ) {
|
||||
/*
|
||||
* Enqueue styles and scripts specific to metaboxs
|
||||
*/
|
||||
function generate_sections_metabox_init(){
|
||||
|
||||
// I prefer to enqueue the styles only on pages that are using the metaboxes
|
||||
wp_enqueue_style( 'generate-sections-metabox', plugin_dir_url( __FILE__ ) . 'wpalchemy/css/meta.css');
|
||||
wp_enqueue_style( 'generate-style-grid', get_template_directory_uri() . '/css/unsemantic-grid.css', false, GENERATE_VERSION, 'all' );
|
||||
|
||||
//make sure we enqueue some scripts just in case ( only needed for repeating metaboxes )
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'jquery-ui-core' );
|
||||
wp_enqueue_script( 'jquery-ui-widget' );
|
||||
wp_enqueue_script( 'jquery-ui-mouse' );
|
||||
wp_enqueue_script( 'jquery-ui-sortable' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
|
||||
// special script for dealing with repeating textareas- needs to run AFTER all the tinyMCE init scripts, so make 'editor' a requirement
|
||||
wp_enqueue_script( 'generate-sections-metabox', plugin_dir_url( __FILE__ ) . 'wpalchemy/js/sections-metabox.js', array( 'jquery', 'editor', 'media-upload', 'wp-color-picker' ), GENERATE_SECTIONS_VERSION, true );
|
||||
$translation_array = array(
|
||||
'no_content_error' => __( 'Error: Content already detected in default editor.', 'gp-premium' ),
|
||||
'use_visual_editor' => __( 'Please activate the "Visual" tab in your main editor before transferring content.', 'gp-premium' )
|
||||
);
|
||||
wp_localize_script( 'generate-sections-metabox', 'generate_sections', $translation_array );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Spacing module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_spacing_init' ) ) {
|
||||
function generate_spacing_init() {
|
||||
load_plugin_textdomain( 'generate-spacing', false, 'gp-premium/langs/spacing/' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_spacing_setup' ) ) {
|
||||
function generate_spacing_setup() {
|
||||
// Here so we can check to see if Spacing is active
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Typography module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_typography_init' ) ) {
|
||||
function generate_typography_init() {
|
||||
load_plugin_textdomain( 'generate-typography', false, 'gp-premium/langs/typography/' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_fonts_setup' ) ) {
|
||||
function generate_fonts_setup() {
|
||||
// Here to check if Typography is active
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WooCommerce module.
|
||||
*/
|
||||
if ( ! function_exists( 'generate_woocommerce_init' ) ) {
|
||||
function generate_woocommerce_init() {
|
||||
load_plugin_textdomain( 'generate-woocommerce', false, 'gp-premium/langs/woocommerce/' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use text instead of an icon if essentials are in use.
|
||||
*
|
||||
* @since 1.3
|
||||
* @deprecated 1.6
|
||||
*
|
||||
* @param string $icon Existing icon HTML.
|
||||
* @return string New icon HTML.
|
||||
*/
|
||||
function generatepress_wc_essentials_menu_icon( $icon ) {
|
||||
if ( apply_filters( 'generate_fontawesome_essentials', false ) ) {
|
||||
return __( 'Cart', 'gp-premium' );
|
||||
}
|
||||
|
||||
return $icon;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_activation_styles' ) ) {
|
||||
function generate_activation_styles() {
|
||||
// Added to dashboard.css
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_verify_styles' ) ) {
|
||||
function generate_verify_styles() {
|
||||
// Added to dashboard.css
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_add_license_key_field' ) ) {
|
||||
function generate_add_license_key_field() {
|
||||
// Replaced by generatepress_premium_license_key_field()
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_license_key' ) ) {
|
||||
function generate_premium_license_key() {
|
||||
// Replaced by generatepress_premium_license_key_field()
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_save_premium_license_key' ) ) {
|
||||
function generate_save_premium_license_key() {
|
||||
// Replaced by generatepress_premium_process_license_key()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ! function_exists( 'generate_process_license_key' ) ) {
|
||||
function generate_process_license_key() {
|
||||
// Replaced by generatepress_premium_process_license_key()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the Refresh sites link after the list of sites.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 1.7
|
||||
*/
|
||||
function generate_sites_refresh_link() {
|
||||
if ( ! generate_is_sites_dashboard() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div class="refresh-sites">
|
||||
<a class="button" href="%1$s">%2$s</a>
|
||||
</div>',
|
||||
wp_nonce_url( admin_url( 'themes.php?page=generate-options&area=generate-sites' ), 'refresh_sites', 'refresh_sites_nonce' ),
|
||||
__( 'Refresh Sites', 'gp-premium' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete our sites transient if the Refresh sites link is clicked.
|
||||
*
|
||||
* @since 1.6
|
||||
* @deprecated 1.12.0
|
||||
*/
|
||||
function generate_sites_refresh_list() {
|
||||
if ( ! isset( $_GET['refresh_sites_nonce'] ) || ! wp_verify_nonce( $_GET['refresh_sites_nonce'], 'refresh_sites' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete_transient( 'generatepress_sites' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_insert_import_export' ) ) {
|
||||
/**
|
||||
* @deprecated 1.7
|
||||
*/
|
||||
function generate_insert_import_export() {
|
||||
// Replaced by GeneratePress_Import_Export::build_html()
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_ie_import_form' ) ) {
|
||||
/**
|
||||
* @deprecated 1.7
|
||||
*/
|
||||
function generate_ie_import_form() {
|
||||
// Replaced by GeneratePress_Import_Export::build_html()
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_process_settings_export' ) ) {
|
||||
/**
|
||||
* Process a settings export that generates a .json file of the shop settings
|
||||
*
|
||||
* @deprecated 1.7
|
||||
*/
|
||||
function generate_process_settings_export() {
|
||||
// Replaced by GeneratePress_Import_Export::export()
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_process_settings_import' ) ) {
|
||||
/**
|
||||
* Process a settings import from a json file
|
||||
*
|
||||
* @deprecated 1.7
|
||||
*/
|
||||
function generate_process_settings_import() {
|
||||
// Replaced by GeneratePress_Import_Export::import()
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_ie_exportable' ) ) {
|
||||
/**
|
||||
* @deprecated 1.7
|
||||
*/
|
||||
function generate_ie_exportable() {
|
||||
// A check to see if other addons can add their export button
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our dynamic CSS.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generate_menu_plus_make_css() {
|
||||
// Replaced by generate_do_off_canvas_css()
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue our dynamic CSS.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generate_menu_plus_enqueue_dynamic_css() {
|
||||
// No longer needed.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_hidden_secondary_navigation' ) && function_exists( 'is_customize_preview' ) ) {
|
||||
/**
|
||||
* Adds a hidden navigation if no navigation is set
|
||||
* This allows us to use postMessage to position the navigation when it doesn't exist
|
||||
*/
|
||||
function generate_hidden_secondary_navigation() {
|
||||
if ( is_customize_preview() && function_exists( 'generate_secondary_navigation_position' ) ) {
|
||||
?>
|
||||
<div style="display:none;">
|
||||
<?php generate_secondary_navigation_position(); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles general functions in the plugin.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the requested media query.
|
||||
*
|
||||
* @since 1.9.0
|
||||
* @param string $name Name of the media query.
|
||||
*/
|
||||
function generate_premium_get_media_query( $name ) {
|
||||
if ( function_exists( 'generate_get_media_query' ) ) {
|
||||
return generate_get_media_query( $name );
|
||||
}
|
||||
|
||||
// If the theme function doesn't exist, build our own queries.
|
||||
$desktop = apply_filters( 'generate_desktop_media_query', '(min-width:1025px)' );
|
||||
$tablet = apply_filters( 'generate_tablet_media_query', '(min-width: 769px) and (max-width: 1024px)' );
|
||||
$mobile = apply_filters( 'generate_mobile_media_query', '(max-width:768px)' );
|
||||
$mobile_menu = apply_filters( 'generate_mobile_menu_media_query', $mobile );
|
||||
|
||||
$queries = apply_filters(
|
||||
'generate_media_queries',
|
||||
array(
|
||||
'desktop' => $desktop,
|
||||
'tablet' => $tablet,
|
||||
'mobile' => $mobile,
|
||||
'mobile-menu' => $mobile_menu,
|
||||
)
|
||||
);
|
||||
|
||||
return $queries[ $name ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our CSS print method.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*/
|
||||
function generate_get_css_print_method() {
|
||||
$mode = apply_filters( 'generatepress_dynamic_css_print_method', 'inline' );
|
||||
|
||||
if (
|
||||
( function_exists( 'is_customize_preview' ) && is_customize_preview() )
|
||||
||
|
||||
is_preview()
|
||||
||
|
||||
// AMP inlines all CSS, so inlining from the start improves CSS processing performance.
|
||||
( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() )
|
||||
) {
|
||||
return 'inline';
|
||||
}
|
||||
|
||||
if ( ! defined( 'GENERATE_VERSION' ) ) {
|
||||
return 'inline';
|
||||
}
|
||||
|
||||
return $mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if we have a Block Element.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @param string $element The type of element to check.
|
||||
* @param boolean $block_element Whether it's a block element or not.
|
||||
*/
|
||||
function generate_has_active_element( $element, $block_element ) {
|
||||
global $generate_elements;
|
||||
|
||||
if ( ! empty( $generate_elements ) ) {
|
||||
foreach ( (array) $generate_elements as $key => $data ) {
|
||||
if ( $element === $data['type'] && $block_element === $data['is_block_element'] ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check our GeneratePress version.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
function generate_premium_get_theme_version() {
|
||||
return defined( 'GENERATE_VERSION' ) ? GENERATE_VERSION : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the featured-image-active class if needed.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
function generate_premium_remove_featured_image_class( $classes, $remove_class ) {
|
||||
if ( $remove_class && in_array( 'featured-image-active', $classes ) ) {
|
||||
$classes = array_diff( $classes, array( 'featured-image-active' ) );
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the global $wp_filesystem with credentials set.
|
||||
* Returns null in case of any errors.
|
||||
*
|
||||
* @return WP_Filesystem_Base|null
|
||||
*/
|
||||
function generate_premium_get_wp_filesystem() {
|
||||
global $wp_filesystem;
|
||||
|
||||
$success = true;
|
||||
|
||||
// Initialize the file system if it has not been done yet.
|
||||
if ( ! $wp_filesystem ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
|
||||
$constants = array(
|
||||
'hostname' => 'FTP_HOST',
|
||||
'username' => 'FTP_USER',
|
||||
'password' => 'FTP_PASS',
|
||||
'public_key' => 'FTP_PUBKEY',
|
||||
'private_key' => 'FTP_PRIKEY',
|
||||
);
|
||||
|
||||
$credentials = array();
|
||||
|
||||
// We provide credentials based on wp-config.php constants.
|
||||
// Reference https://developer.wordpress.org/apis/wp-config-php/#wordpress-upgrade-constants.
|
||||
foreach ( $constants as $key => $constant ) {
|
||||
if ( defined( $constant ) ) {
|
||||
$credentials[ $key ] = constant( $constant );
|
||||
}
|
||||
}
|
||||
|
||||
$success = WP_Filesystem( $credentials );
|
||||
}
|
||||
|
||||
if ( ! $success || $wp_filesystem->errors->has_errors() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $wp_filesystem;
|
||||
}
|
@ -0,0 +1,623 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
add_action( 'admin_enqueue_scripts', 'generatepress_premium_dashboard_scripts' );
|
||||
/**
|
||||
* Enqueue scripts and styles for the GP Dashboard area.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generatepress_premium_dashboard_scripts() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( 'appearance_page_generate-options' !== $screen->base ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'generate-premium-dashboard', plugin_dir_url( __FILE__ ) . 'assets/dashboard.css', array(), GP_PREMIUM_VERSION );
|
||||
wp_enqueue_script( 'generate-premium-dashboard', plugin_dir_url( __FILE__ ) . 'assets/dashboard.js', array( 'jquery' ), GP_PREMIUM_VERSION, true );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-premium-dashboard',
|
||||
'dashboard',
|
||||
array(
|
||||
'deprecated_module' => esc_attr__( 'This module has been deprecated. Deactivating it will remove it from this list.', 'gp-premium' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_notices' ) ) {
|
||||
add_action( 'admin_notices', 'generate_premium_notices' );
|
||||
/*
|
||||
* Set up errors and messages
|
||||
*/
|
||||
function generate_premium_notices() {
|
||||
if ( isset( $_GET['generate-message'] ) && 'addon_deactivated' == $_GET['generate-message'] ) {
|
||||
add_settings_error( 'generate-premium-notices', 'addon_deactivated', __( 'Module deactivated.', 'gp-premium' ), 'updated' );
|
||||
}
|
||||
|
||||
if ( isset( $_GET['generate-message'] ) && 'addon_activated' == $_GET['generate-message'] ) {
|
||||
add_settings_error( 'generate-premium-notices', 'addon_activated', __( 'Module activated.', 'gp-premium' ), 'updated' );
|
||||
}
|
||||
|
||||
settings_errors( 'generate-premium-notices' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_license_errors' ) ) {
|
||||
add_action( 'admin_notices', 'generate_license_errors' );
|
||||
/*
|
||||
* Set up errors and messages
|
||||
*/
|
||||
function generate_license_errors() {
|
||||
if ( isset( $_GET['generate-message'] ) && 'deactivation_passed' == $_GET['generate-message'] ) {
|
||||
add_settings_error( 'generate-license-notices', 'deactivation_passed', __( 'License deactivated.', 'gp-premium' ), 'updated' );
|
||||
}
|
||||
|
||||
if ( isset( $_GET['generate-message'] ) && 'license_activated' == $_GET['generate-message'] ) {
|
||||
add_settings_error( 'generate-license-notices', 'license_activated', __( 'License activated.', 'gp-premium' ), 'updated' );
|
||||
}
|
||||
|
||||
if ( isset( $_GET['sl_activation'] ) && ! empty( $_GET['message'] ) ) {
|
||||
|
||||
switch ( $_GET['sl_activation'] ) {
|
||||
|
||||
case 'false':
|
||||
$message = urldecode( $_GET['message'] );
|
||||
add_settings_error( 'generate-license-notices', 'license_failed', $message, 'error' );
|
||||
break;
|
||||
|
||||
case 'true':
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
settings_errors( 'generate-license-notices' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_super_package_addons' ) ) {
|
||||
add_action( 'generate_options_items', 'generate_super_package_addons', 5 );
|
||||
/**
|
||||
* Build the area that allows us to activate and deactivate modules.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_super_package_addons() {
|
||||
$addons = array(
|
||||
'Backgrounds' => 'generate_package_backgrounds',
|
||||
'Blog' => 'generate_package_blog',
|
||||
'Colors' => 'generate_package_colors',
|
||||
'Copyright' => 'generate_package_copyright',
|
||||
'Disable Elements' => 'generate_package_disable_elements',
|
||||
'Elements' => 'generate_package_elements',
|
||||
'Hooks' => 'generate_package_hooks',
|
||||
'Menu Plus' => 'generate_package_menu_plus',
|
||||
'Page Header' => 'generate_package_page_header',
|
||||
'Secondary Nav' => 'generate_package_secondary_nav',
|
||||
'Sections' => 'generate_package_sections',
|
||||
'Spacing' => 'generate_package_spacing',
|
||||
'Typography' => 'generate_package_typography',
|
||||
'WooCommerce' => 'generate_package_woocommerce',
|
||||
);
|
||||
|
||||
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
|
||||
$addons['Site Library'] = 'generate_package_site_library';
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
|
||||
unset( $addons['Typography'] );
|
||||
}
|
||||
|
||||
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '>=' ) ) {
|
||||
unset( $addons['Colors'] );
|
||||
}
|
||||
|
||||
ksort( $addons );
|
||||
|
||||
$addon_count = 0;
|
||||
foreach ( $addons as $k => $v ) {
|
||||
if ( 'activated' == get_option( $v ) )
|
||||
$addon_count++;
|
||||
}
|
||||
|
||||
$key = get_option( 'gen_premium_license_key_status', 'deactivated' );
|
||||
$version = ( defined( 'GP_PREMIUM_VERSION' ) ) ? GP_PREMIUM_VERSION : '';
|
||||
|
||||
?>
|
||||
<div class="postbox generate-metabox generatepress-admin-block" id="modules">
|
||||
<h3 class="hndle"><?php _e('GP Premium','gp-premium'); ?> <?php echo $version; ?></h3>
|
||||
<div class="inside" style="margin:0;padding:0;">
|
||||
<div class="premium-addons">
|
||||
<form method="post">
|
||||
<div class="add-on gp-clear addon-container grid-parent" style="background:#EFEFEF;border-left:5px solid #DDD;padding-left:10px !important;">
|
||||
<div class="addon-name column-addon-name">
|
||||
<input type="checkbox" id="generate-select-all" />
|
||||
<select name="generate_mass_activate" class="mass-activate-select">
|
||||
<option value=""><?php _e( 'Bulk Actions', 'gp-premium' ) ;?></option>
|
||||
<option value="activate-selected"><?php _e( 'Activate','gp-premium' ) ;?></option>
|
||||
<option value="deactivate-selected"><?php _e( 'Deactivate','gp-premium' ) ;?></option>
|
||||
</select>
|
||||
<?php wp_nonce_field( 'gp_premium_bulk_action_nonce', 'gp_premium_bulk_action_nonce' ); ?>
|
||||
<input type="submit" name="generate_multi_activate" class="button mass-activate-button" value="<?php _e( 'Apply','gp-premium' ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
$deprecated_modules = apply_filters(
|
||||
'generate_premium_deprecated_modules',
|
||||
array(
|
||||
'Page Header',
|
||||
'Hooks',
|
||||
'Sections',
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $addons as $k => $v ) :
|
||||
|
||||
$key = get_option( $v );
|
||||
|
||||
if( $key == 'activated' ) { ?>
|
||||
<div class="add-on activated gp-clear addon-container grid-parent">
|
||||
<div class="addon-name column-addon-name" style="">
|
||||
<input type="checkbox" class="addon-checkbox" name="generate_addon_checkbox[]" value="<?php echo $v; ?>" />
|
||||
<?php echo $k;?>
|
||||
</div>
|
||||
<div class="addon-action addon-addon-action" style="text-align:right;">
|
||||
<?php wp_nonce_field( $v . '_deactivate_nonce', $v . '_deactivate_nonce' ); ?>
|
||||
<input type="submit" name="<?php echo $v;?>_deactivate_package" value="<?php _e( 'Deactivate', 'gp-premium' );?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<?php } else {
|
||||
// Don't output deprecated modules.
|
||||
if ( in_array( $k, $deprecated_modules ) ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<div class="add-on gp-clear addon-container grid-parent">
|
||||
|
||||
<div class="addon-name column-addon-name">
|
||||
<input <?php if ( 'WooCommerce' == $k && ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { echo 'disabled'; } ?> type="checkbox" class="addon-checkbox" name="generate_addon_checkbox[]" value="<?php echo $v; ?>" />
|
||||
<?php echo $k;?>
|
||||
</div>
|
||||
|
||||
<div class="addon-action addon-addon-action" style="text-align:right;">
|
||||
<?php if ( 'WooCommerce' == $k && ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { ?>
|
||||
<?php _e( 'WooCommerce not activated.','gp-premium' ); ?>
|
||||
<?php } else { ?>
|
||||
<?php wp_nonce_field( $v . '_activate_nonce', $v . '_activate_nonce' ); ?>
|
||||
<input type="submit" name="<?php echo $v;?>_activate_package" value="<?php _e( 'Activate', 'gp-premium' );?>"/>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php }
|
||||
echo '<div class="gp-clear"></div>';
|
||||
endforeach;
|
||||
?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_multi_activate' ) ) {
|
||||
add_action( 'admin_init', 'generate_multi_activate' );
|
||||
|
||||
function generate_multi_activate() {
|
||||
// Deactivate selected
|
||||
if ( isset( $_POST['generate_multi_activate'] ) ) {
|
||||
|
||||
// If we didn't click the button, bail.
|
||||
if ( ! check_admin_referer( 'gp_premium_bulk_action_nonce', 'gp_premium_bulk_action_nonce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're not an administrator, bail.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$name = ( isset( $_POST['generate_addon_checkbox'] ) ) ? $_POST['generate_addon_checkbox'] : '';
|
||||
$option = ( isset( $_POST['generate_addon_checkbox'] ) ) ? $_POST['generate_mass_activate'] : '';
|
||||
$autoload = null;
|
||||
|
||||
if ( isset( $_POST['generate_addon_checkbox'] ) ) {
|
||||
|
||||
if ( 'deactivate-selected' == $option ) {
|
||||
foreach ( $name as $id ) {
|
||||
if ( 'activated' == get_option( $id ) ) {
|
||||
if ( 'generate_package_site_library' === $id ) {
|
||||
$autoload = false;
|
||||
}
|
||||
|
||||
update_option( $id, '', $autoload );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'activate-selected' == $option ) {
|
||||
foreach ( $name as $id ) {
|
||||
if ( 'activated' !== get_option( $id ) ) {
|
||||
if ( 'generate_package_site_library' === $id ) {
|
||||
$autoload = false;
|
||||
}
|
||||
|
||||
update_option( $id, 'activated', $autoload );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp_safe_redirect( admin_url( 'themes.php?page=generate-options' ) );
|
||||
exit;
|
||||
} else {
|
||||
wp_safe_redirect( admin_url( 'themes.php?page=generate-options' ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* Activate the add-on
|
||||
***********************************************/
|
||||
if ( ! function_exists( 'generate_activate_super_package_addons' ) ) {
|
||||
add_action( 'admin_init', 'generate_activate_super_package_addons' );
|
||||
|
||||
function generate_activate_super_package_addons() {
|
||||
$addons = array(
|
||||
'Typography' => 'generate_package_typography',
|
||||
'Colors' => 'generate_package_colors',
|
||||
'Backgrounds' => 'generate_package_backgrounds',
|
||||
'Page Header' => 'generate_package_page_header',
|
||||
'Sections' => 'generate_package_sections',
|
||||
'Copyright' => 'generate_package_copyright',
|
||||
'Disable Elements' => 'generate_package_disable_elements',
|
||||
'Elements' => 'generate_package_elements',
|
||||
'Blog' => 'generate_package_blog',
|
||||
'Hooks' => 'generate_package_hooks',
|
||||
'Spacing' => 'generate_package_spacing',
|
||||
'Secondary Nav' => 'generate_package_secondary_nav',
|
||||
'Menu Plus' => 'generate_package_menu_plus',
|
||||
'WooCommerce' => 'generate_package_woocommerce',
|
||||
);
|
||||
|
||||
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
|
||||
$addons['Site Library'] = 'generate_package_site_library';
|
||||
}
|
||||
|
||||
foreach( $addons as $k => $v ) :
|
||||
|
||||
if ( isset( $_POST[$v . '_activate_package'] ) ) {
|
||||
|
||||
// If we didn't click the button, bail.
|
||||
if ( ! check_admin_referer( $v . '_activate_nonce', $v . '_activate_nonce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're not an administrator, bail.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$autoload = null;
|
||||
|
||||
if ( 'generate_package_site_library' === $v ) {
|
||||
$autoload = false;
|
||||
}
|
||||
|
||||
update_option( $v, 'activated', $autoload );
|
||||
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&generate-message=addon_activated' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
endforeach;
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************
|
||||
* Deactivate the plugin
|
||||
***********************************************/
|
||||
if ( ! function_exists( 'generate_deactivate_super_package_addons' ) ) {
|
||||
add_action( 'admin_init', 'generate_deactivate_super_package_addons' );
|
||||
|
||||
function generate_deactivate_super_package_addons() {
|
||||
$addons = array(
|
||||
'Typography' => 'generate_package_typography',
|
||||
'Colors' => 'generate_package_colors',
|
||||
'Backgrounds' => 'generate_package_backgrounds',
|
||||
'Page Header' => 'generate_package_page_header',
|
||||
'Sections' => 'generate_package_sections',
|
||||
'Copyright' => 'generate_package_copyright',
|
||||
'Disable Elements' => 'generate_package_disable_elements',
|
||||
'Elements' => 'generate_package_elements',
|
||||
'Blog' => 'generate_package_blog',
|
||||
'Hooks' => 'generate_package_hooks',
|
||||
'Spacing' => 'generate_package_spacing',
|
||||
'Secondary Nav' => 'generate_package_secondary_nav',
|
||||
'Menu Plus' => 'generate_package_menu_plus',
|
||||
'WooCommerce' => 'generate_package_woocommerce',
|
||||
);
|
||||
|
||||
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
|
||||
$addons['Site Library'] = 'generate_package_site_library';
|
||||
}
|
||||
|
||||
foreach( $addons as $k => $v ) :
|
||||
|
||||
if ( isset( $_POST[$v . '_deactivate_package'] ) ) {
|
||||
|
||||
// If we didn't click the button, bail.
|
||||
if ( ! check_admin_referer( $v . '_deactivate_nonce', $v . '_deactivate_nonce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're not an administrator, bail.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$autoload = null;
|
||||
|
||||
if ( 'generate_package_site_library' === $v ) {
|
||||
$autoload = false;
|
||||
}
|
||||
|
||||
update_option( $v, 'deactivated', $autoload );
|
||||
wp_safe_redirect( admin_url('themes.php?page=generate-options&generate-message=addon_deactivated' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
endforeach;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_premium_body_class' ) ) {
|
||||
add_filter( 'admin_body_class', 'generate_premium_body_class' );
|
||||
/**
|
||||
* Add a class or many to the body in the dashboard
|
||||
*/
|
||||
function generate_premium_body_class( $classes ) {
|
||||
return "$classes gp_premium";
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_activation_area' ) ) {
|
||||
add_action( 'generate_admin_right_panel', 'generate_activation_area' );
|
||||
|
||||
function generate_activation_area() {
|
||||
$license = get_option( 'gen_premium_license_key', '' );
|
||||
$key = get_option( 'gen_premium_license_key_status', 'deactivated' );
|
||||
|
||||
if ( 'valid' == $key ) {
|
||||
$message = sprintf( '<span class="license-key-message receiving-updates">%s</span>', __( 'Receiving updates', 'gp-premium' ) );
|
||||
} else {
|
||||
$message = sprintf( '<span class="license-key-message not-receiving-updates">%s</span>', __( 'Not receiving updates', 'gp-premium' ) );
|
||||
}
|
||||
?>
|
||||
<form method="post" action="options.php">
|
||||
<div class="postbox generate-metabox" id="generate-license-keys">
|
||||
<h3 class="hndle">
|
||||
<?php _e( 'Updates', 'gp-premium' );?>
|
||||
<span class="license-key-info">
|
||||
<?php echo $message; ?>
|
||||
<a title="<?php esc_attr_e( 'Help', 'gp-premium' ); ?>" href="https://docs.generatepress.com/article/updating-gp-premium/" target="_blank" rel="noopener">[?]</a>
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
<div class="inside" style="margin-bottom:0;">
|
||||
<div class="license-key-container" style="position:relative;">
|
||||
<p>
|
||||
<input spellcheck="false" class="license-key-input" id="generate_license_key_gp_premium" name="generate_license_key_gp_premium" type="<?php echo apply_filters( 'generate_premium_license_key_field', 'password' ); ?>" value="<?php echo $license; ?>" placeholder="<?php _e( 'License Key', 'gp-premium' ); ?>" />
|
||||
</p>
|
||||
|
||||
<p class="beta-testing-container" <?php echo ( empty( $license ) ) ? 'style="display: none;"' : '';?>>
|
||||
<input type="checkbox" id="gp_premium_beta_testing" name="gp_premium_beta_testing" value="true" <?php echo ( get_option( 'gp_premium_beta_testing', false ) ) ? 'checked="checked"' : ''; ?> />
|
||||
<label for="gp_premium_beta_testing"><?php _e( 'Receive beta updates', 'gp-premium' ); ?> <a title="<?php esc_attr_e( 'Help', 'gp-premium' ); ?>" href="https://docs.generatepress.com/article/beta-testing/" target="_blank" rel="noopener">[?]</a></label>
|
||||
</p>
|
||||
|
||||
<?php wp_nonce_field( 'generate_license_key_gp_premium_nonce', 'generate_license_key_gp_premium_nonce' ); ?>
|
||||
<input type="submit" class="button button-primary" name="gp_premium_license_key" value="<?php _e( 'Save', 'gp-premium' );?>" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'generatepress_premium_process_license_key', 5 );
|
||||
/**
|
||||
* Process our saved license key.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generatepress_premium_process_license_key() {
|
||||
// Has our button been clicked?
|
||||
if ( isset( $_POST[ 'gp_premium_license_key' ] ) ) {
|
||||
|
||||
// Get out if we didn't click the button
|
||||
if ( ! check_admin_referer( 'generate_license_key_gp_premium_nonce', 'generate_license_key_gp_premium_nonce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we're not an administrator, bail.
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set our beta testing option if it's checked.
|
||||
if ( ! empty( $_POST['gp_premium_beta_testing'] ) ) {
|
||||
update_option( 'gp_premium_beta_testing', true, false );
|
||||
} else {
|
||||
delete_option( 'gp_premium_beta_testing' );
|
||||
}
|
||||
|
||||
// Grab the value being saved
|
||||
$new = sanitize_key( $_POST['generate_license_key_gp_premium'] );
|
||||
|
||||
// Get the previously saved value
|
||||
$old = get_option( 'gen_premium_license_key' );
|
||||
|
||||
// Still here? Update our option with the new license key
|
||||
update_option( 'gen_premium_license_key', $new );
|
||||
|
||||
// If we have a value, run activation.
|
||||
if ( '' !== $new ) {
|
||||
$api_params = array(
|
||||
'edd_action' => 'activate_license',
|
||||
'license' => $new,
|
||||
'item_name' => urlencode( 'GP Premium' ),
|
||||
'url' => home_url()
|
||||
);
|
||||
}
|
||||
|
||||
// If we don't have a value (it's been cleared), run deactivation.
|
||||
if ( '' == $new && 'valid' == get_option( 'gen_premium_license_key_status' ) ) {
|
||||
$api_params = array(
|
||||
'edd_action' => 'deactivate_license',
|
||||
'license' => $old,
|
||||
'item_name' => urlencode( 'GP Premium' ),
|
||||
'url' => home_url()
|
||||
);
|
||||
}
|
||||
|
||||
// Nothing? Get out of here.
|
||||
if ( ! isset( $api_params ) ) {
|
||||
wp_safe_redirect( admin_url( 'themes.php?page=generate-options' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// Phone home.
|
||||
$license_response = wp_remote_post( 'https://generatepress.com', array(
|
||||
'timeout' => 60,
|
||||
'sslverify' => false,
|
||||
'body' => $api_params
|
||||
) );
|
||||
|
||||
// Make sure the response came back okay.
|
||||
if ( is_wp_error( $license_response ) || 200 !== wp_remote_retrieve_response_code( $license_response ) ) {
|
||||
if ( is_object( $license_response ) ) {
|
||||
$message = $license_response->get_error_message();
|
||||
} elseif ( is_array( $license_response ) && isset( $license_response['response']['message'] ) ) {
|
||||
if ( 'Forbidden' === $license_response['response']['message'] ) {
|
||||
$message = __( '403 Forbidden. Your server is not able to communicate with generatepress.com in order to activate your license key.', 'gp-premium' );
|
||||
} else {
|
||||
$message = $license_response['response']['message'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Still here? Decode our response.
|
||||
$license_data = json_decode( wp_remote_retrieve_body( $license_response ) );
|
||||
|
||||
if ( false === $license_data->success ) {
|
||||
|
||||
switch ( $license_data->error ) {
|
||||
|
||||
case 'expired' :
|
||||
|
||||
$message = sprintf(
|
||||
__( 'Your license key expired on %s.', 'gp-premium' ),
|
||||
date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'revoked' :
|
||||
|
||||
$message = __( 'Your license key has been disabled.', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'missing' :
|
||||
|
||||
$message = __( 'Invalid license.', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'invalid' :
|
||||
case 'site_inactive' :
|
||||
|
||||
$message = __( 'Your license is not active for this URL.', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'item_name_mismatch' :
|
||||
|
||||
$message = __( 'This appears to be an invalid license key for GP Premium.', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'no_activations_left':
|
||||
|
||||
$message = __( 'Your license key has reached its activation limit.', 'gp-premium' );
|
||||
break;
|
||||
|
||||
default :
|
||||
|
||||
$message = __( 'An error occurred, please try again.', 'gp-premium' );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check if anything passed on a message constituting a failure
|
||||
if ( ! empty( $message ) ) {
|
||||
delete_option( 'gen_premium_license_key_status' );
|
||||
$base_url = admin_url( 'themes.php?page=generate-options' );
|
||||
$redirect = add_query_arg( array( 'sl_activation' => 'false', 'message' => urlencode( $message ) ), esc_url( $base_url ) );
|
||||
wp_redirect( $redirect );
|
||||
exit();
|
||||
}
|
||||
|
||||
// Update our license key status
|
||||
update_option( 'gen_premium_license_key_status', $license_data->license );
|
||||
|
||||
if ( 'valid' == $license_data->license ) {
|
||||
// Validated, go tell them
|
||||
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&generate-message=license_activated' ) );
|
||||
exit;
|
||||
} elseif ( 'deactivated' == $license_data->license ) {
|
||||
// Deactivated, go tell them
|
||||
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&generate-message=deactivation_passed' ) );
|
||||
exit;
|
||||
} else {
|
||||
// Failed, go tell them
|
||||
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&generate-message=license_failed' ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_license_missing' ) ) {
|
||||
add_action( 'in_plugin_update_message-gp-premium/gp-premium.php', 'generate_license_missing', 10, 2 );
|
||||
/**
|
||||
* Add a message to the plugin update area if no license key is set
|
||||
*/
|
||||
function generate_license_missing() {
|
||||
$license = get_option( 'gen_premium_license_key_status' );
|
||||
|
||||
if ( 'valid' !== $license ) {
|
||||
echo ' <strong><a href="' . esc_url( admin_url('themes.php?page=generate-options' ) ) . '">' . __( 'Enter valid license key for automatic updates.', 'gp-premium' ) . '</a></strong>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_premium_beta_tester', 'generatepress_premium_beta_tester' );
|
||||
/**
|
||||
* Enable beta testing if our option is set.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generatepress_premium_beta_tester( $value ) {
|
||||
if ( get_option( 'gp_premium_beta_testing', false ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
@ -0,0 +1,199 @@
|
||||
.generatepress-dashboard-tabs {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.generatepress-dashboard-tabs a {
|
||||
background-color: rgba(255,255,255,0.5);
|
||||
border: 1px solid #ddd;
|
||||
padding: 10px 15px;
|
||||
cursor: pointer;
|
||||
color: #222;
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.generatepress-dashboard-tabs a:not(:last-child) {
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
.generatepress-dashboard-tabs a.active {
|
||||
background-color: #ffffff;
|
||||
border-color: #ccc;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
input#generate-select-all,
|
||||
.addon-checkbox {
|
||||
margin-right: 15px !important;
|
||||
}
|
||||
.gp-premium-version,
|
||||
.gp-addon-count {
|
||||
display: block;
|
||||
color:#ccc;
|
||||
}
|
||||
|
||||
.addon-container:before,
|
||||
.addon-container:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.addon-container:after {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.premium-addons .gp-clear {
|
||||
margin: 0 !important;
|
||||
border: 0;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.premium-addons .add-on.gp-clear {
|
||||
padding: 15px !important;
|
||||
margin: 0 !important;
|
||||
box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
|
||||
}
|
||||
|
||||
.premium-addons .add-on:last-child {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
.addon-action {
|
||||
float: right;
|
||||
clear: right;
|
||||
}
|
||||
|
||||
.addon-name {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.premium-addons .add-on.gp-clear.activated {
|
||||
background-color:#F7FCFE !important;
|
||||
border-left: 5px solid #2EA2CC !important;
|
||||
font-weight: bold;
|
||||
padding-left: 10px !important;
|
||||
}
|
||||
|
||||
.premium-addons .addon-action input[type="submit"],
|
||||
.premium-addons .addon-action input[type="submit"]:visited {
|
||||
background: none;
|
||||
border: 0;
|
||||
color: #0d72b2;
|
||||
padding: 0;
|
||||
font-size: inherit;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 0 0 transparent;
|
||||
}
|
||||
|
||||
.premium-addons .addon-action input[type="submit"]:hover,
|
||||
.premium-addons .addon-action input[type="submit"]:focus {
|
||||
background: none;
|
||||
border: 0;
|
||||
color: #0f92e5;
|
||||
padding: 0;
|
||||
font-size: inherit;
|
||||
box-shadow: 0 0 0 transparent;
|
||||
}
|
||||
|
||||
.premium-addons input[type="submit"].hide-customizer-button,
|
||||
.premium-addons input[type="submit"]:visited.hide-customizer-button {
|
||||
color: #a00;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.premium-addons input[type="submit"]:hover.hide-customizer-button,
|
||||
.premium-addons input[type="submit"]:focus.hide-customizer-button {
|
||||
color: red;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.premium-addons input[type="submit"].hide-customizer-button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.premium-addons .add-on.activated:hover input[type="submit"].hide-customizer-button {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.gp_premium input[name="generate_activate_all"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.email-container .addon-name {
|
||||
width: 75%;
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.license-key-container {
|
||||
margin-bottom:15px;
|
||||
}
|
||||
|
||||
.license-key-container:last-child {
|
||||
margin:0;
|
||||
}
|
||||
|
||||
.license-key-info {
|
||||
float: right;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.license-key-container label {
|
||||
font-size: 11px;
|
||||
font-weight: normal;
|
||||
color: #777;
|
||||
display: inline-block;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.status {
|
||||
position: absolute;
|
||||
right:10px;
|
||||
top:-1px;
|
||||
background:rgba(255,255,255,0.9);
|
||||
}
|
||||
|
||||
.license-key-input {
|
||||
width:100%;
|
||||
box-sizing:border-box;
|
||||
padding:10px;
|
||||
}
|
||||
|
||||
.license-key-input::-webkit-credentials-auto-fill-button {
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.license-key-button {
|
||||
position:relative;
|
||||
top:1px;
|
||||
width:100%;
|
||||
box-sizing:border-box;
|
||||
padding: 10px !important;
|
||||
height:auto !important;
|
||||
line-height:normal !important;
|
||||
}
|
||||
|
||||
.license-key-message {
|
||||
font-size: 80%;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.license-key-message.receiving-updates {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.license-key-message.not-receiving-updates {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.mass-activate-select {
|
||||
margin-top: 0;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
jQuery( function( $ ) {
|
||||
$( '#generate-select-all' ).on( 'click', function() {
|
||||
if ( this.checked ) {
|
||||
$( '.addon-checkbox:not(:disabled)' ).each( function() {
|
||||
this.checked = true;
|
||||
} );
|
||||
} else {
|
||||
$( '.addon-checkbox' ).each( function() {
|
||||
this.checked = false;
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#generate_license_key_gp_premium' ).on( 'input', function() {
|
||||
if ( '' !== $.trim( this.value ) ) {
|
||||
$( '.beta-testing-container' ).show();
|
||||
} else {
|
||||
$( '.beta-testing-container' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
$( 'input[name="generate_package_hooks_deactivate_package"]' ).on( 'click', function() {
|
||||
// eslint-disable-next-line no-alert
|
||||
var check = confirm( dashboard.deprecated_module );
|
||||
|
||||
if ( ! check ) {
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
$( 'input[name="generate_package_page_header_deactivate_package"]' ).on( 'click', function() {
|
||||
// eslint-disable-next-line no-alert
|
||||
var check = confirm( dashboard.deprecated_module );
|
||||
|
||||
if ( ! check ) {
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
|
||||
$( 'input[name="generate_package_sections_deactivate_package"]' ).on( 'click', function() {
|
||||
// eslint-disable-next-line no-alert
|
||||
var check = confirm( dashboard.deprecated_module );
|
||||
|
||||
if ( ! check ) {
|
||||
return false;
|
||||
}
|
||||
} );
|
||||
} );
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
add_action( 'generate_dashboard_inside_container', 'generate_do_dashboard_tabs', 5 );
|
||||
add_action( 'generate_inside_site_library_container', 'generate_do_dashboard_tabs', 5 );
|
||||
add_action( 'generate_before_site_library', 'generate_do_dashboard_tabs', 5 );
|
||||
/**
|
||||
* Adds our tabs to the GeneratePress dashboard.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generate_do_dashboard_tabs() {
|
||||
if ( ! defined( 'GENERATE_VERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
$tabs = apply_filters( 'generate_dashboard_tabs', array(
|
||||
'Modules' => array(
|
||||
'name' => __( 'Modules', 'gp-premium' ),
|
||||
'url' => admin_url( 'themes.php?page=generate-options' ),
|
||||
'class' => 'appearance_page_generate-options' === $screen->id ? 'active' : '',
|
||||
),
|
||||
) );
|
||||
|
||||
// Don't print any markup if we only have one tab.
|
||||
if ( count( $tabs ) === 1 ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="generatepress-dashboard-tabs">
|
||||
<?php
|
||||
foreach ( $tabs as $tab ) {
|
||||
printf( '<a href="%1$s" class="%2$s">%3$s</a>',
|
||||
esc_url( $tab['url'] ),
|
||||
esc_attr( $tab['class'] ),
|
||||
esc_html( $tab['name'] )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
@ -0,0 +1,371 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the import/export functionality.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Import/export class.
|
||||
*/
|
||||
class GeneratePress_Import_Export {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
* @since 1.7
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @since 1.7
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add necessary actions.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'generate_admin_right_panel', array( $this, 'build_html' ), 15 );
|
||||
add_action( 'admin_init', array( $this, 'export' ) );
|
||||
add_action( 'admin_init', array( $this, 'import' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our export and import HTML.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function build_html() {
|
||||
?>
|
||||
<div class="postbox generate-metabox" id="generate-ie">
|
||||
<h3 class="hndle"><?php esc_html_e( 'Import/Export', 'gp-premium' ); ?></h3>
|
||||
<div class="inside">
|
||||
<form method="post">
|
||||
<h3 style="font-size: 15px;"><?php esc_html_e( 'Export', 'gp-premium' ); ?></h3>
|
||||
<span class="show-advanced"><?php _e( 'Advanced', 'gp-premium' ); ?></span>
|
||||
<div class="export-choices advanced-choices">
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generate_settings" checked />
|
||||
<?php _ex( 'Core', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generate_background_settings" checked />
|
||||
<?php _ex( 'Backgrounds', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_blog', 'GENERATE_BLOG' ) ) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generate_blog_settings" checked />
|
||||
<?php _ex( 'Blog', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_hooks', 'GENERATE_HOOKS' ) ) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generate_hooks" checked />
|
||||
<?php _ex( 'Hooks', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_page_header', 'GENERATE_PAGE_HEADER' ) ) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generate_page_header_settings" checked />
|
||||
<?php _ex( 'Page Header', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ) ) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generate_secondary_nav_settings" checked />
|
||||
<?php _ex( 'Secondary Navigation', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_spacing', 'GENERATE_SPACING' ) ) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generate_spacing_settings" checked />
|
||||
<?php _ex( 'Spacing', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ) ) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generate_menu_plus_settings" checked />
|
||||
<?php _ex( 'Menu Plus', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_woocommerce', 'GENERATE_WOOCOMMERCE' ) ) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="generate_woocommerce_settings" checked />
|
||||
<?php _ex( 'WooCommerce', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_copyright', 'GENERATE_COPYRIGHT' ) ) : ?>
|
||||
<label>
|
||||
<input type="checkbox" name="module_group[]" value="copyright" checked />
|
||||
<?php _ex( 'Copyright', 'Module name', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php do_action( 'generate_export_items' ); ?>
|
||||
</div>
|
||||
<p><input type="hidden" name="generate_action" value="export_settings" /></p>
|
||||
<p style="margin-bottom:0">
|
||||
<?php wp_nonce_field( 'generate_export_nonce', 'generate_export_nonce' ); ?>
|
||||
<?php submit_button( __( 'Export', 'gp-premium' ), 'button-primary', 'submit', false, array( 'id' => '' ) ); ?>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<h3 style="font-size: 15px;margin-top: 30px;"><?php esc_html_e( 'Import', 'gp-premium' ); ?></h3>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<p>
|
||||
<input type="file" name="import_file"/>
|
||||
</p>
|
||||
<p style="margin-bottom:0">
|
||||
<input type="hidden" name="generate_action" value="import_settings" />
|
||||
<?php wp_nonce_field( 'generate_import_nonce', 'generate_import_nonce' ); ?>
|
||||
<?php submit_button( __( 'Import', 'gp-premium' ), 'button-primary', 'submit', false, array( 'id' => '' ) ); ?>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Export our chosen options.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function export() {
|
||||
if ( empty( $_POST['generate_action'] ) || 'export_settings' !== $_POST['generate_action'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! wp_verify_nonce( $_POST['generate_export_nonce'], 'generate_export_nonce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$modules = self::get_modules();
|
||||
$theme_mods = self::get_theme_mods();
|
||||
$settings = self::get_settings();
|
||||
|
||||
$data = array(
|
||||
'modules' => array(),
|
||||
'mods' => array(),
|
||||
'options' => array(),
|
||||
);
|
||||
|
||||
foreach ( $modules as $name => $value ) {
|
||||
if ( 'activated' === get_option( $value ) ) {
|
||||
$data['modules'][ $name ] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $theme_mods as $theme_mod ) {
|
||||
if ( 'generate_copyright' === $theme_mod ) {
|
||||
if ( in_array( 'copyright', $_POST['module_group'] ) ) {
|
||||
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
|
||||
}
|
||||
} else {
|
||||
if ( in_array( 'generate_settings', $_POST['module_group'] ) ) {
|
||||
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $settings as $setting ) {
|
||||
if ( in_array( $setting, $_POST['module_group'] ) ) {
|
||||
$data['options'][ $setting ] = get_option( $setting );
|
||||
}
|
||||
}
|
||||
|
||||
$data = apply_filters( 'generate_export_data', $data );
|
||||
|
||||
nocache_headers();
|
||||
header( 'Content-Type: application/json; charset=utf-8' );
|
||||
header( 'Content-Disposition: attachment; filename=generate-settings-export-' . date( 'Ymd' ) . '.json' ); // phpcs:ignore -- Prefer date().
|
||||
header( 'Expires: 0' );
|
||||
|
||||
echo wp_json_encode( $data );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import our exported file.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function import() {
|
||||
if ( empty( $_POST['generate_action'] ) || 'import_settings' !== $_POST['generate_action'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! wp_verify_nonce( $_POST['generate_import_nonce'], 'generate_import_nonce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = $_FILES['import_file']['name'];
|
||||
$extension = end( explode( '.', $_FILES['import_file']['name'] ) );
|
||||
|
||||
if ( 'json' !== $extension ) {
|
||||
wp_die( __( 'Please upload a valid .json file', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
$import_file = $_FILES['import_file']['tmp_name'];
|
||||
|
||||
if ( empty( $import_file ) ) {
|
||||
wp_die( __( 'Please upload a file to import', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
// Retrieve the settings from the file and convert the json object to an array.
|
||||
$settings = json_decode( file_get_contents( $import_file ), true ); // phpcs:ignore -- file_get_contents() is fine here.
|
||||
|
||||
foreach ( (array) $settings['modules'] as $key => $val ) {
|
||||
if ( in_array( $val, self::get_modules() ) ) {
|
||||
update_option( $val, 'activated' );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( (array) $settings['mods'] as $key => $val ) {
|
||||
if ( in_array( $key, self::get_theme_mods() ) ) {
|
||||
set_theme_mod( $key, $val );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( (array) $settings['options'] as $key => $val ) {
|
||||
if ( in_array( $key, self::get_settings() ) ) {
|
||||
update_option( $key, $val );
|
||||
}
|
||||
}
|
||||
|
||||
// Delete existing 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 );
|
||||
|
||||
wp_safe_redirect( admin_url( 'admin.php?page=generate-options&status=imported' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* List out our available modules.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function get_modules() {
|
||||
return array(
|
||||
'Backgrounds' => 'generate_package_backgrounds',
|
||||
'Blog' => 'generate_package_blog',
|
||||
'Colors' => 'generate_package_colors',
|
||||
'Copyright' => 'generate_package_copyright',
|
||||
'Elements' => 'generate_package_elements',
|
||||
'Disable Elements' => 'generate_package_disable_elements',
|
||||
'Hooks' => 'generate_package_hooks',
|
||||
'Menu Plus' => 'generate_package_menu_plus',
|
||||
'Page Header' => 'generate_package_page_header',
|
||||
'Secondary Nav' => 'generate_package_secondary_nav',
|
||||
'Sections' => 'generate_package_sections',
|
||||
'Spacing' => 'generate_package_spacing',
|
||||
'Typography' => 'generate_package_typography',
|
||||
'WooCommerce' => 'generate_package_woocommerce',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List our our set theme mods.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function get_theme_mods() {
|
||||
return array(
|
||||
'font_body_variants',
|
||||
'font_body_category',
|
||||
'font_site_title_variants',
|
||||
'font_site_title_category',
|
||||
'font_site_tagline_variants',
|
||||
'font_site_tagline_category',
|
||||
'font_navigation_variants',
|
||||
'font_navigation_category',
|
||||
'font_secondary_navigation_variants',
|
||||
'font_secondary_navigation_category',
|
||||
'font_buttons_variants',
|
||||
'font_buttons_category',
|
||||
'font_heading_1_variants',
|
||||
'font_heading_1_category',
|
||||
'font_heading_2_variants',
|
||||
'font_heading_2_category',
|
||||
'font_heading_3_variants',
|
||||
'font_heading_3_category',
|
||||
'font_heading_4_variants',
|
||||
'font_heading_4_category',
|
||||
'font_heading_5_variants',
|
||||
'font_heading_5_category',
|
||||
'font_heading_6_variants',
|
||||
'font_heading_6_category',
|
||||
'font_widget_title_variants',
|
||||
'font_widget_title_category',
|
||||
'font_footer_variants',
|
||||
'font_footer_category',
|
||||
'generate_copyright',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List out our available settings.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function get_settings() {
|
||||
return array(
|
||||
'generate_settings',
|
||||
'generate_background_settings',
|
||||
'generate_blog_settings',
|
||||
'generate_hooks',
|
||||
'generate_page_header_settings',
|
||||
'generate_secondary_nav_settings',
|
||||
'generate_spacing_settings',
|
||||
'generate_menu_plus_settings',
|
||||
'generate_woocommerce_settings',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Import_Export::get_instance();
|
@ -0,0 +1,273 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles resetting of options.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
add_action( 'generate_admin_right_panel', 'generate_premium_reset_metabox', 25 );
|
||||
/**
|
||||
* Add the reset options to the Dashboard.
|
||||
*/
|
||||
function generate_premium_reset_metabox() {
|
||||
?>
|
||||
<div class="postbox generate-metabox" id="generate-reset">
|
||||
<h3 class="hndle"><?php esc_html_e( 'Reset Settings', 'gp-premium' ); ?></h3>
|
||||
<div class="inside">
|
||||
<form method="post">
|
||||
<span class="show-advanced"><?php esc_html_e( 'Advanced', 'gp-premium' ); ?></span>
|
||||
<div class="reset-choices advanced-choices">
|
||||
<label><input type="checkbox" name="module_group[]" value="generate_settings" checked /><?php _ex( 'Core', 'Module name', 'gp-premium' ); ?></label>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) { ?>
|
||||
<label><input type="checkbox" name="module_group[]" value="generate_background_settings" checked /><?php _ex( 'Backgrounds', 'Module name', 'gp-premium' ); ?></label>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_blog', 'GENERATE_BLOG' ) ) { ?>
|
||||
<label><input type="checkbox" name="module_group[]" value="generate_blog_settings" checked /><?php _ex( 'Blog', 'Module name', 'gp-premium' ); ?></label>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_hooks', 'GENERATE_HOOKS' ) ) { ?>
|
||||
<label><input type="checkbox" name="module_group[]" value="generate_hooks" checked /><?php _ex( 'Hooks', 'Module name', 'gp-premium' ); ?></label>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_page_header', 'GENERATE_PAGE_HEADER' ) ) { ?>
|
||||
<label><input type="checkbox" name="module_group[]" value="generate_page_header_settings" checked /><?php _ex( 'Page Header', 'Module name', 'gp-premium' ); ?></label>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ) ) { ?>
|
||||
<label><input type="checkbox" name="module_group[]" value="generate_secondary_nav_settings" checked /><?php _ex( 'Secondary Navigation', 'Module name', 'gp-premium' ); ?></label>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_spacing', 'GENERATE_SPACING' ) ) { ?>
|
||||
<label><input type="checkbox" name="module_group[]" value="generate_spacing_settings" checked /><?php _ex( 'Spacing', 'Module name', 'gp-premium' ); ?></label>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ) ) { ?>
|
||||
<label><input type="checkbox" name="module_group[]" value="generate_menu_plus_settings" checked /><?php _ex( 'Menu Plus', 'Module name', 'gp-premium' ); ?></label>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_woocommerce', 'GENERATE_WOOCOMMERCE' ) ) { ?>
|
||||
<label><input type="checkbox" name="module_group[]" value="generate_woocommerce_settings" checked /><?php _ex( 'WooCommerce', 'Module name', 'gp-premium' ); ?></label>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( generatepress_is_module_active( 'generate_package_copyright', 'GENERATE_COPYRIGHT' ) ) { ?>
|
||||
<label><input type="checkbox" name="module_group[]" value="copyright" checked /><?php _ex( 'Copyright', 'Module name', 'gp-premium' ); ?></label>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<p><input type="hidden" name="generate_reset_action" value="reset_settings" /></p>
|
||||
<p style="margin-bottom:0">
|
||||
<?php
|
||||
$warning = 'return confirm("' . __( 'Warning: This will delete your settings and can not be undone.', 'gp-premium' ) . '")';
|
||||
wp_nonce_field( 'generate_reset_settings_nonce', 'generate_reset_settings_nonce' );
|
||||
submit_button(
|
||||
__( 'Reset', 'gp-premium' ),
|
||||
'button-primary',
|
||||
'submit',
|
||||
false,
|
||||
array(
|
||||
'onclick' => esc_js( $warning ),
|
||||
'id' => '',
|
||||
)
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'generate_premium_process_reset' );
|
||||
/**
|
||||
* Process the reset functions.
|
||||
*/
|
||||
function generate_premium_process_reset() {
|
||||
if ( empty( $_POST['generate_reset_action'] ) || 'reset_settings' !== $_POST['generate_reset_action'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! wp_verify_nonce( $_POST['generate_reset_settings_nonce'], 'generate_reset_settings_nonce' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$theme_mods = array(
|
||||
'font_body_variants',
|
||||
'font_body_category',
|
||||
'font_site_title_variants',
|
||||
'font_site_title_category',
|
||||
'font_site_tagline_variants',
|
||||
'font_site_tagline_category',
|
||||
'font_navigation_variants',
|
||||
'font_navigation_category',
|
||||
'font_secondary_navigation_variants',
|
||||
'font_secondary_navigation_category',
|
||||
'font_buttons_variants',
|
||||
'font_buttons_category',
|
||||
'font_heading_1_variants',
|
||||
'font_heading_1_category',
|
||||
'font_heading_2_variants',
|
||||
'font_heading_2_category',
|
||||
'font_heading_3_variants',
|
||||
'font_heading_3_category',
|
||||
'font_heading_4_variants',
|
||||
'font_heading_4_category',
|
||||
'font_heading_5_variants',
|
||||
'font_heading_5_category',
|
||||
'font_heading_6_variants',
|
||||
'font_heading_6_category',
|
||||
'font_widget_title_variants',
|
||||
'font_widget_title_category',
|
||||
'font_footer_variants',
|
||||
'font_footer_category',
|
||||
'generate_copyright',
|
||||
);
|
||||
|
||||
$settings = array(
|
||||
'generate_settings',
|
||||
'generate_background_settings',
|
||||
'generate_blog_settings',
|
||||
'generate_hooks',
|
||||
'generate_page_header_settings',
|
||||
'generate_secondary_nav_settings',
|
||||
'generate_spacing_settings',
|
||||
'generate_menu_plus_settings',
|
||||
'generate_woocommerce_settings',
|
||||
);
|
||||
|
||||
$data = array(
|
||||
'mods' => array(),
|
||||
'options' => array(),
|
||||
);
|
||||
|
||||
foreach ( $theme_mods as $theme_mod ) {
|
||||
if ( 'generate_copyright' === $theme_mod ) {
|
||||
if ( in_array( 'copyright', $_POST['module_group'] ) ) {
|
||||
remove_theme_mod( $theme_mod );
|
||||
}
|
||||
} else {
|
||||
if ( in_array( 'generate_settings', $_POST['module_group'] ) ) {
|
||||
remove_theme_mod( $theme_mod );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $settings as $setting ) {
|
||||
if ( in_array( $setting, $_POST['module_group'] ) ) {
|
||||
delete_option( $setting );
|
||||
}
|
||||
}
|
||||
|
||||
// Delete our dynamic CSS option.
|
||||
delete_option( 'generate_dynamic_css_output' );
|
||||
delete_option( 'generate_dynamic_css_cached_version' );
|
||||
|
||||
// Reset our dynamic CSS file updated time so it regenerates.
|
||||
$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 );
|
||||
|
||||
// Delete any GeneratePress Site CSS in Additional CSS.
|
||||
$additional_css = wp_get_custom_css_post();
|
||||
|
||||
if ( ! empty( $additional_css ) ) {
|
||||
$additional_css->post_content = preg_replace( '#(/\\* GeneratePress Site CSS \\*/).*?(/\\* End GeneratePress Site CSS \\*/)#s', '', $additional_css->post_content );
|
||||
wp_update_custom_css_post( $additional_css->post_content );
|
||||
}
|
||||
|
||||
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&status=reset' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
add_action( 'admin_head', 'generate_reset_options_css', 100 );
|
||||
/**
|
||||
* Add CSS to the dashboard.
|
||||
*/
|
||||
function generate_reset_options_css() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( ! is_object( $screen ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'appearance_page_generate-options' !== $screen->base ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<style>
|
||||
#gen-delete {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.advanced-choices {
|
||||
margin-top: 10px;
|
||||
font-size: 95%;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.advanced-choices:not(.show) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.advanced-choices label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.show-advanced {
|
||||
font-size: 13px;
|
||||
opacity: 0.8;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.show-advanced:after {
|
||||
content: "\f347";
|
||||
font-family: dashicons;
|
||||
padding-left: 2px;
|
||||
padding-top: 2px;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.show-advanced.active:after {
|
||||
content: "\f343";
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'admin_footer', 'generate_reset_options_scripts', 100 );
|
||||
/**
|
||||
* Add scripts to the Dashboard.
|
||||
*/
|
||||
function generate_reset_options_scripts() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( ! is_object( $screen ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'appearance_page_generate-options' !== $screen->base ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
jQuery( function( $ ) {
|
||||
$( '.show-advanced' ).on( 'click', function() {
|
||||
$( this ).toggleClass( 'active' );
|
||||
$( this ).next( '.advanced-choices' ).toggleClass( 'show' );
|
||||
} );
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
Reference in New Issue
Block a user