modified file bootstrap-buttons.css
This commit is contained in:
@ -1,623 +0,0 @@
|
||||
<?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;
|
||||
}
|
@ -1,199 +0,0 @@
|
||||
.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;
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
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;
|
||||
}
|
||||
} );
|
||||
} );
|
@ -1,47 +0,0 @@
|
||||
<?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
|
||||
}
|
@ -1,371 +0,0 @@
|
||||
<?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();
|
@ -1,273 +0,0 @@
|
||||
<?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