Initial commit

This commit is contained in:
2020-04-07 13:03:04 +00:00
committed by Gitium
commit 00f842d9bf
1673 changed files with 471161 additions and 0 deletions

View File

@ -0,0 +1,597 @@
<?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';
}
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
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' );?>"/>
</div>
</div>
<?php } else {
if ( 'Page Header' === $k || 'Hooks' === $k ) {
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' );?>"/>
<?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 ) ) {
$message = $license_response->get_error_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 '&nbsp;<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;
}

View File

@ -0,0 +1,204 @@
.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;
}
.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;
-moz-box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
-webkit-box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
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;
-moz-box-shadow: 0 0 0 transparent;
-webkit-box-shadow: 0 0 0 transparent;
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;
-moz-box-shadow: 0 0 0 transparent;
-webkit-box-shadow: 0 0 0 transparent;
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;
}

View File

@ -0,0 +1,37 @@
jQuery( document ).ready(function( $ ) {
$( '#generate-select-all' ).on( 'click', function( event ) {
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() {
var check = confirm( dashboard.deprecated_module );
if ( ! check ) {
return false;
}
} );
$( 'input[name="generate_package_page_header_deactivate_package"]' ).on( 'click', function() {
var check = confirm( dashboard.deprecated_module );
if ( ! check ) {
return false;
}
} );
});

View File

@ -0,0 +1,42 @@
<?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 );
/**
* Adds our tabs to the GeneratePress dashboard.
*
* @since 1.6
*/
function generate_do_dashboard_tabs() {
$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
}

View File

@ -0,0 +1,663 @@
<?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;
}
}
/**
* 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 );
}
}
}
/**
* 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' )
);
}
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.
}

View File

@ -0,0 +1,25 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
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 ];
}

View File

@ -0,0 +1,247 @@
<?php
defined( 'WPINC' ) or die;
add_action( 'generate_admin_right_panel', 'generate_premium_reset_metabox', 25 );
function generate_premium_reset_metabox() {
?>
<div class="postbox generate-metabox" id="generate-reset">
<h3 class="hndle"><?php _e( 'Reset Settings', 'gp-premium' );?></h3>
<div class="inside">
<form method="post">
<span class="show-advanced"><?php _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' );
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_option( 'generate_dynamic_css_output' );
delete_option( 'generate_dynamic_css_cached_version' );
// 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 );
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 );
function generate_reset_options_scripts() {
$screen = get_current_screen();
if ( ! is_object( $screen ) ) {
return;
}
if ( 'appearance_page_generate-options' !== $screen->base ) {
return;
}
?>
<script>
jQuery( document ).ready( function($) {
$( '.show-advanced' ).on( 'click', function() {
$( this ).toggleClass( 'active' );
$( this ).next( '.advanced-choices' ).toggleClass( 'show' );
} );
} );
</script>
<?php
}