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 : ''; ?>

$v ) : $key = get_option( $v ); if( $key == 'activated' ) { ?>
type="checkbox" class="addon-checkbox" name="generate_addon_checkbox[]" value="" />
'; endforeach; ?>
'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( '%s', __( 'Receiving updates', 'gp-premium' ) ); } else { $message = sprintf( '%s', __( 'Not receiving updates', 'gp-premium' ) ); } ?>

[?]

> />

'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 ' ' . __( 'Enter valid license key for automatic updates.', 'gp-premium' ) . ''; } } } 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; }