function verify_theme_step1() { $_username = esc_attr($_REQUEST['envato_username']); $_code = esc_attr($_REQUEST['envato_item_code']); $_api_key = esc_attr($_REQUEST['envato_api_key']); $error = false; // Check for error if (empty($_username) || empty($_code)) { add_error_section(__('Enter envato marketplace username and item purchase code to verify.', 'spyropress')); $error = true; } if (empty($_username)) { add_error_message(__('Enter envato marketplace username to verify.', 'spyropress')); $error = true; } if (empty($_code)) { add_error_message(__('Enter item purchase code to verify.', 'spyropress')); $error = true; } if ($error) { return; } update_option('_spyropress_site_key_' . get_internal_name(), md5(home_url() . $_code)); update_option('_spyropress_envato_verification_' . get_internal_name(), $_code); update_option('_spyropress_envato_username_' . get_internal_name(), $_username); update_option('_spyropress_envato_api_key_' . get_internal_name(), $_api_key); add_notice_message(__('Redirecting...', 'spyropress') . '<script type="text/javascript"> //<![CDATA[ window.location.replace("' . admin_url('admin.php?page=spyropress&step=4') . '"); //]]> </script>'); }
/** * Presstrends API call */ function set_trends() { // NO NEED TO EDIT BELOW $data = get_transient('_spyropress_api_trends_data'); if (!$data || empty($data)) { $code = get_option('_spyropress_envato_verification_' . get_internal_name()); $username = get_option('_spyropress_envato_username_' . get_internal_name()); $json = $this->verify_purchase($code, $username); set_transient('_spyropress_api_trends_data', 1, spyropress_get_seconds(10)); } }
/** * Check if theme if activated first time */ function install() { global $pagenow; $is_theme_activated = 'themes.php' == $pagenow && isset($_GET['activated']); $installed = get_option('spyropress_installed_' . get_internal_name(), false); if ($is_theme_activated && !$installed) { include_once 'spyropress-theme-activation.php'; } elseif ($is_theme_activated && $installed) { wp_redirect(admin_url('admin.php?installed=true&page=spyropress')); } }
/** * Install Spyropress */ function do_install_spyropress() { global $spyropress; // init custom taxonomies $spyropress->init_taxonomy(); // flush rules flush_rewrite_rules(); // Set already installed add_option('spyropress_installed_' . get_internal_name(), true); // Do developers hook there activation fucntions do_action('spyropress_theme_activated'); // Redirect wp_redirect(admin_url('admin.php?installed=true&page=spyropress')); }
function update_theme() { if (isset($_REQUEST['page'])) { // Sanitize page being requested. $_page = esc_attr($_REQUEST['page']); if ('spyropress-update' == $_page) { //Setup Filesystem $method = get_filesystem_method(); if (isset($_POST['spyropress_ftp_cred'])) { $cred = spyropress_decode($_POST['spyropress_ftp_cred']); $filesystem = WP_Filesystem($cred); } else { $filesystem = WP_Filesystem(); } if (false == $filesystem && 'Proceed' != $_POST['upgrade']) { add_error_message(sprintf(__('Failed: Filesystem preventing downloads. (%s)', 'spyropress'), $method)); return; } if (isset($_REQUEST['spyropress_updater'])) { // Sanitize action being requested. $_action = esc_attr($_REQUEST['spyropress_updater']); if ('framework' == $_action) { locate_template('framework/utilities/envato/class-envato-wordpress-theme-upgrader.php', true); $envato_api_key = get_option('_spyropress_envato_api_key_' . get_internal_name()); $envato_username = get_option('_spyropress_envato_username_' . get_internal_name()); $upgrader = new Envato_WordPress_Theme_Upgrader($envato_username, $envato_api_key); $result = $upgrader->upgrade_theme(); // Successfully Updated if ($result->success) { $message = __('New version successfully downloaded, extracted and updated.', 'spyropress'); $message .= '<script type="text/javascript"> //<![CDATA[ window.location.replace("' . admin_url('admin.php?page=spyropress-update') . '"); //]]> </script>'; add_success_message($message); } else { add_error_message($result->errors[0]); } } } } // END UPDATE HERE } }
/** Loads the framework files **/ function includes() { do_action('before_spyropress_core_includes'); /** Core **************************************************************/ // Functions require_once 'spyropress-core-functions.php'; // Contains core functions for the front/back end require_once 'spyropress-context.php'; // Contains core functions for the front/back end require_once 'spyropress-template-hierarchy.php'; // Extending template hierarchy making it smarter and more flexible. Inspired by hybrid core. if (is_admin()) { $this->admin_includes(); } if (defined('DOING_AJAX')) { $this->ajax_includes(); } if (!is_admin() || defined('DOING_AJAX')) { $this->frontend_includes(); } /** WP Components *****************************************************/ require_once 'widgets/spyropress-widget-init.php'; /** Components ********************************************************/ // SpyroBuilder $builder_file = $this->framework_path . 'builder/spyropress-builder-init.php'; // envato verification && site_key $is_site_key = false; $code = get_option('_spyropress_envato_verification_' . get_internal_name()); $cur_site_key = md5(home_url() . $code); if ($site_key = get_option('_spyropress_site_key_' . get_internal_name())) { if ($site_key == $cur_site_key) { $is_site_key = true; } } $this->is_builder_verified = (bool) $code && $is_site_key; require_once $builder_file; // Allow developers to include files before framework initialize do_action('spyropress_core_includes'); }
$values = wp_parse_args($_REQUEST, array('step' => '', 'envato_username' => '', 'envato_api_key' => '', 'envato_item_code' => '')); extract($values); $step = $step ? $step : 1; if ($spyropress->is_builder_verified) { if (!isset($_GET['step']) && !isset($_GET['force'])) { return; } } if (!isset($_GET['force']) && $spyropress->is_builder_verified) { $step = 2; } if (isset($_GET['force']) && 'reset' == $_GET['force']) { delete_option('_spyropress_site_key_' . get_internal_name()); delete_option('_spyropress_envato_verification_' . get_internal_name()); delete_option('_spyropress_envato_username_' . get_internal_name()); delete_option('_spyropress_envato_api_key_' . get_internal_name()); } /** Step 1 **/ if (1 == $step) { ?> <div id="welcome-panel" class="welcome-panel"> <div class="welcome-panel-content"> <h3> <?php _e('Welcome to SpyroPress! Update your Theme from the WordPress Dashboard', 'spyropress'); ?> </h3> <p class="about-description"> <?php