function vw_envato_toolkit_check() { if (!class_exists('Envato_WordPress_Theme_Upgrader')) { return; } // Use credentials used in toolkit plugin so that we don't have to show our own forms anymore $credentials = get_option('envato-wordpress-toolkit'); if (empty($credentials['user_name']) || empty($credentials['api_key'])) { add_action('admin_notices', 'vw_envato_toolkit_credentials_admin_notices'); return; } // Check updates only after a while $lastCheck = get_option('vw-last-toolkit-check'); if (false === $lastCheck) { update_option('vw-last-toolkit-check', time()); return; } // Check for an update every ... if (VW_CONST_THEME_UPDATE_CHECKING_PERIOD < time() - $lastCheck) { return; } // Update the time we last checked update_option('vw-last-toolkit-check', time()); // Check for updates $upgrader = new Envato_WordPress_Theme_Upgrader($credentials['user_name'], $credentials['api_key']); $updates = $upgrader->check_for_theme_update(); // If $updates->updated_themes_count == true then we have an update! // Add update alert, to update the theme if ($updates->updated_themes_count) { add_action('admin_notices', 'vw_envato_toolkit_admin_notices'); } }
static function check_for_updates($credentials) { # include the library include_once BW_FRAME_LIB . 'envato-wtl/class-envato-wordpress-theme-upgrader.php'; # Check for updates $upgrader = new Envato_WordPress_Theme_Upgrader($credentials['user_name'], $credentials['api_key']); $updates = $upgrader->check_for_theme_update(); if ($updates->updated_themes_count) { add_action('admin_notices', array('Bw_updater', 'admin_notices_download_update')); } }
/** * Envato Upgrader Theme Update */ function grve_envato_toolkit_update() { if (isset($_GET['grve-theme-update']) && 'update' == $_GET['grve-theme-update']) { if (is_super_admin() && 1 == grve_option('update_enabled')) { $envato_username = grve_option('update_user_name'); $envato_api_key = grve_option('update_api_key'); if (empty($envato_username) || empty($envato_api_key)) { return; } else { $upgrader = new Envato_WordPress_Theme_Upgrader($envato_username, $envato_api_key); $update_response = $upgrader->upgrade_theme(GRVE_THEME_NAME); } wp_safe_redirect(esc_url(remove_query_arg('grve-theme-update'))); } } }
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 } }
/** * Load the Envato WordPress Toolkit Library check for updates * and direct the user to the Toolkit Plugin if there is one */ function envato_toolkit_admin_init() { // Include the Toolkit Library include_once IRON_PARENT_DIR . '/includes/envato-wordpress-toolkit-library/class-envato-wordpress-theme-upgrader.php'; // Use credentials used in toolkit plugin so that we don't have to show our own forms anymore $credentials = get_option('envato-wordpress-toolkit'); if (empty($credentials['user_name']) || empty($credentials['api_key'])) { add_action('admin_notices', 'envato_toolkit_credentials_admin_notices'); return; } // Check updates only after a while $lastCheck = get_option('toolkit-last-toolkit-check'); if (false === $lastCheck) { update_option('toolkit-last-toolkit-check', time()); return; } if (!(time() - $lastCheck > 10800)) { // 3 HOURS = 10800 SECONDS return; } // Update the time we last checked update_option('toolkit-last-toolkit-check', time()); // Check for updates $upgrader = new Envato_WordPress_Theme_Upgrader($credentials['user_name'], $credentials['api_key']); $updates = $upgrader->check_for_theme_update(); // If $updates->updated_themes_count == true then we have an update! // Add update alert, to update the theme if ($updates->updated_themes_count) { add_action('admin_notices', 'envato_toolkit_admin_notices'); } }
function ct_check_for_update($theme) { $envato_username = ot_get_option('envato_username', ''); $envato_api = ot_get_option('envato_api', ''); // if user has entered username and api if ($envato_username != '' && $envato_api != '') { // include the library require_once locate_template('/inc/plugins/envato-wordpress-toolkit/class-envato-wordpress-theme-upgrader.php'); $upgrader = new Envato_WordPress_Theme_Upgrader($envato_username, $envato_api); $update = $upgrader->check_for_theme_update($theme); // we enter theme name here to make sure if users are using child theme // found an update return $update->updated_themes_count; } }
function sf_envato_toolkit_admin_init() { // Include the Toolkit Library include_once SF_INCLUDES_PATH . '/envato-wordpress-toolkit-library/class-envato-wordpress-theme-upgrader.php'; // Display a notice in the admin to remind the user to enter their credentials function sf_envato_toolkit_credentials_admin_notices() { $message = sprintf(__("To enable Dante update notifications, please enter your Envato Marketplace credentials in the %s", "swift-framework-admin"), "<a href='" . admin_url() . "admin.php?page=envato-wordpress-toolkit'>Envato WordPress Toolkit Plugin</a>"); echo "<div id='message' class='updated below-h2'><p>{$message}</p></div>"; } // Use credentials used in toolkit plugin so that we don't have to show our own forms anymore $credentials = get_option('envato-wordpress-toolkit'); if (empty($credentials['user_name']) || empty($credentials['api_key'])) { add_action('admin_notices', 'sf_envato_toolkit_credentials_admin_notices'); return; } // Check updates only after a while $lastCheck = get_option('toolkit-last-toolkit-check'); if (false === $lastCheck) { update_option('toolkit-last-toolkit-check', time()); return; } // Check for an update every 3 hours if (time() - $lastCheck < 10800) { return; } // Update the time we last checked update_option('toolkit-last-toolkit-check', time()); // Check for updates $upgrader = new Envato_WordPress_Theme_Upgrader($credentials['user_name'], $credentials['api_key']); $updates = $upgrader->check_for_theme_update(); // Add update alert, to update the theme if ($updates->updated_themes_count) { add_action('admin_notices', 'sf_envato_toolkit_admin_notices'); } // Display a notice in the admin that an update is available function sf_envato_toolkit_admin_notices() { $message = sprintf(__("An update to Dante is available! Head over to %s to update it now.", "swift-framework-admin"), "<a href='" . admin_url() . "admin.php?page=envato-wordpress-toolkit'>Envato WordPress Toolkit Plugin</a>"); echo "<div id='message' class='updated below-h2'><p>{$message}</p></div>"; } }
function themeva_theme_update() { // Check AJAX Referer check_ajax_referer('_theme_options', '_ajax_nonce'); ob_start(); include_once NV_FILES . '/adm/inc/theme-updates/class-envato-wordpress-theme-upgrader.php'; $upgrader = new Envato_WordPress_Theme_Upgrader(of_get_option('tf_username'), of_get_option('tf_apikey')); $upgrader->upgrade_theme(wp_get_theme()->Name); ob_end_clean(); _e('<strong>Update Complete.</strong> You\'re now using the latest version of the theme. Please wait whilst the page reloads.', 'themeva-admin'); die; }
/** * Update theme. * */ function presscore_theme_update() { if (isset($_GET['theme-updater']) && 'update' == $_GET['theme-updater']) { // global timestamp global $dt_lang_backup_dir_timestamp; $user = of_get_option('theme_update-user_name', ''); $api_key = of_get_option('theme_update-api_key', ''); $dt_lang_backup_dir_timestamp = time(); // backup lang files add_filter('upgrader_pre_install', 'presscore_before_theme_update', 10, 2); // restore lang files add_filter('upgrader_post_install', 'presscore_after_theme_update', 10, 3); $upgrader = new Envato_WordPress_Theme_Upgrader($user, $api_key); $responce = $upgrader->upgrade_theme(); remove_filter('upgrader_pre_install', 'presscore_before_theme_update', 10, 2); remove_filter('upgrader_post_install', 'presscore_after_theme_update', 10, 3); unset($dt_lang_backup_dir_timestamp); set_transient('presscore_update_result', $responce, 10); if ($responce) { wp_safe_redirect(add_query_arg('theme-updater', 'updated', remove_query_arg('theme-updater'))); } else { wp_safe_redirect(remove_query_arg('theme-updater')); } // regenrate stylesheets after succesful update } else { if (isset($_GET['theme-updater']) && 'updated' == $_GET['theme-updater'] && get_transient('presscore_update_result')) { add_settings_error('options-framework', 'theme_updated', _x('Stylesheets regenerated.', 'backend', LANGUAGE_ZONE), 'updated fade'); } } }
function rockthemes_to_them_update_start_update($data) { // include the library include_once OPTIONS_DIR . '/envato-wordpress-toolkit-library/class-envato-wordpress-theme-upgrader.php'; $upgrader = new Envato_WordPress_Theme_Upgrader($data['username'], $data['user_api_key']); /* * Uncomment to check if the current theme has been updated */ //return $upgrader->check_for_theme_update(); /* * Uncomment to update the current theme */ $is_updated = $upgrader->upgrade_theme(); //var_dump($is_updated); //echo $is_updated; return $is_updated; }
function wpGrade_set_update_functionality() { global $wpGrade_Options, $wpGrade_data; if ($wpGrade_Options->get('themeforest_upgrade') && isset($_GET['wpGrade_update']) && $_GET['wpGrade_update'] == 'true') { $theme_data = wp_get_theme(); $theme_name = $theme_data->Name; $allow_cache = true; // include the library include_once 'vendor/envato-wtl/class-envato-wordpress-theme-upgrader.php'; $marketplace_username = $wpGrade_Options->get('marketplace_username'); $marketplace_api_key = $wpGrade_Options->get('marketplace_api_key'); if (!empty($marketplace_username) && !empty($marketplace_api_key)) { if (in_array('curl', get_loaded_extensions())) { //cURL is enabled, the Envato Toolkit uses cURL, so the update can be performed $upgrader = new Envato_WordPress_Theme_Upgrader($marketplace_username, $marketplace_api_key); $upgrader->check_for_theme_update($theme_name, $allow_cache); $res = $upgrader->upgrade_theme($theme_name, $allow_cache); $success = $res->success; $wpGrade_data->theme_updated = $success; } else { $wpGrade_data->curl_disabled = true; } } } }
function pp_update_theme() { if (is_admin()) { include_once get_template_directory() . '/modules/envato-wordpress-toolkit-library/class-envato-wordpress-theme-upgrader.php'; $pp_envato_username = get_option('pp_envato_username'); $pp_envato_api_key = get_option('pp_envato_api_key'); if (!empty($pp_envato_username) && !empty($pp_envato_api_key)) { $upgrader = new Envato_WordPress_Theme_Upgrader($pp_envato_username, $pp_envato_api_key); $upgrader_obj = $upgrader->check_for_theme_update(); if ($upgrader_obj->updated_themes_count > 0) { $result = $upgrader->upgrade_theme(); echo $result->installation_feedback; } else { echo 'There is no theme update available'; } } else { echo 'Please enter Envato username and API Key'; } } }
echo "<div id='message' class='updated below-h2'><p>{$message}</p></div>"; } // Check updates only after a while $lastCheck = get_option('toolkit-last-toolkit-check'); if (false === $lastCheck) { update_option('toolkit-last-toolkit-check', time()); return; } // Check for an update every 3 hours if (10800 < time() - $lastCheck) { return; } // Update the time we last checked update_option('toolkit-last-toolkit-check', time()); // Check for updates $upgrader = new Envato_WordPress_Theme_Upgrader($credentials['user_name'], $credentials['api_key']); $updates = $upgrader->check_for_theme_update(); // If $updates->updated_themes_count == true then we have an update! // Add update alert, to update the theme if ($updates->updated_themes_count) { add_action('admin_notices', 'envato_toolkit_admin_notices'); } /** * Display a notice in the admin that an update is available */ function envato_toolkit_admin_notices() { $message = sprintf(__("An update to the theme is available! Head over to %s to update it now.", "default"), "<a href='" . admin_url() . "admin.php?page=envato-wordpress-toolkit'>Envato WordPress Toolkit Plugin</a>"); echo "<div id='message' class='updated below-h2'><p>{$message}</p></div>"; } }
/** * Description here. * */ function presscore_theme_update() { if (isset($_GET['theme-updater']) && 'update' == $_GET['theme-updater']) { $user = of_get_option('theme_update-user_name', ''); $api_key = of_get_option('theme_update-api_key', ''); $upgrader = new Envato_WordPress_Theme_Upgrader($user, $api_key); $responce = $upgrader->upgrade_theme(); set_transient('presscore_update_result', $responce, 10); wp_safe_redirect(remove_query_arg('theme-updater')); } }
</li> <li data-demo="3"> <img src="' . get_template_directory_uri() . '/cache/demos/vega_demo3.jpg" alt=""/> </li> <li data-demo="4"> <img src="' . get_template_directory_uri() . '/cache/demos/vega_demo4.jpg" alt=""/> </li> </ul> <input id="pp_import_default_button" name="pp_import_default_button" type="submit" value="Import Selected Settings" class="upload_btn button-primary"/> <input type="hidden" id="pp_import_demo" name="pp_import_demo" value="1"/> <input type="hidden" id="pp_import_default" name="pp_import_default" value=""/> '), array("type" => "close"), array("name" => "Backup", "type" => "section", "icon" => "drive_disk.png"), array("type" => "open"), array("name" => "<h2>Import Settings</h2>", "desc" => "Choose theme export file (.json) from your computer and click \"Import\" button", "id" => SHORTNAME . "_import_current", "type" => "html", "html" => '<input type="file" id="' . SHORTNAME . '_import_current" name="' . SHORTNAME . '_import_current"/><input type="submit" id="' . SHORTNAME . '_import_current_button" class="button" value="Import"/>'), array("name" => "<h2>Export Settings</h2>", "desc" => "You can click below button to save current backup into .json file so you can import it back any time using restore form below.", "id" => SHORTNAME . "_export_current", "type" => "html", "html" => '<input type="submit" id="' . SHORTNAME . '_export_current_button" class="button" value="Export Current Theme Settings"/><input type="hidden" id="' . SHORTNAME . '_export_current" name="' . SHORTNAME . '_export_current" value="0"/>'), array("type" => "close"), array("name" => "Auto-update", "type" => "section", "icon" => "arrow_refresh.png"), array("type" => "open"), array("name" => "<h2>Envato API Settings</h2>Envato Username", "desc" => "Enter you Envato username", "id" => SHORTNAME . "_envato_username", "type" => "text", "std" => ""), array("name" => "Envato API Key", "desc" => "Enter account API key. You can get it from Your account > Settings > API Keys", "id" => SHORTNAME . "_envato_api_key", "type" => "text", "std" => "")); //Check if has new update include_once get_template_directory() . '/modules/envato-wordpress-toolkit-library/class-envato-wordpress-theme-upgrader.php'; $pp_envato_username = get_option('pp_envato_username'); $pp_envato_api_key = get_option('pp_envato_api_key'); $upgrader = array(); if (!empty($pp_envato_username) && !empty($pp_envato_api_key)) { $upgrader = new Envato_WordPress_Theme_Upgrader($pp_envato_username, $pp_envato_api_key); $upgrader_obj = $upgrader->check_for_theme_update(); if ($upgrader_obj->updated_themes_count > 0) { $options[] = array("name" => "Update Theme<br/>", "desc" => "", "id" => SHORTNAME . "_theme_go_update", "type" => "html", "html" => ' Click to update ' . THEMENAME . ' theme to the latest version. If you made changes on any them code, please backup your changes first otherwise they will be overwritten by the update.<br/><br/> <a id="' . SHORTNAME . '_theme_go_update_bth" href="' . $api_url . '" class="button button-primary">Click here to update theme</a> <div class="update_message"><img src="' . get_template_directory_uri() . '/functions/images/ajax-loader.gif" alt="" style="vertical-align: middle;"/><br/><br/>*Theme is being updated please be patient, don\'t navigate away from this page</div>'); } } $options[] = array("type" => "close"); /*print '<pre>'; print_r($options); print '</pre>';*/
function on_admin_init() { // include the library include_once 'library/class-envato-wordpress-theme-upgrader.php'; $upgrader = new Envato_WordPress_Theme_Upgrader(ot_get_option('tf_user'), ot_get_option('tf_api')); $upgrader->check_for_theme_update(); $upgrader->upgrade_theme(); }