/** * Retrieve the appropriate EP_HOST * * Looks at the defined EP_HOST or a backup global should the defined host failed. * Priority is given to the EP_HOST constand with the backups only used when needed. * * @since 1.6 * * @global array $ep_backup_host array of backup hosts * * @param bool $force Whether to force a new lookup or not * @param bool $use_only_backups Forces the use of only the backup array, no others * * @return string|WP_Error the host to use or an error */ public function get_ep_host($force = false, $use_only_backups = false) { global $ep_backup_host; // Delete the transient if we want to force a new good host lookup if (true === $force) { delete_site_transient('ep_last_good_host'); } $last_good_host = get_site_transient('ep_last_good_host'); if ($last_good_host) { return $last_good_host; } // If nothing is defined just return an error if (!defined('EP_HOST') && !$ep_backup_host) { return new WP_Error('elasticpress', __('No running host available.', 'elasticpress')); } $hosts = array(); if (defined('EP_HOST') && false === $use_only_backups) { $hosts[] = EP_HOST; } // If no backups are defined just return the host if ($ep_backup_host && is_array($ep_backup_host)) { $hosts = array_merge($hosts, $ep_backup_host); } foreach ($hosts as $host) { if (true === ep_elasticsearch_alive($host)) { set_site_transient('ep_last_good_host', $host, apply_filters('ep_last_good_host_timeout', 3600)); return $host; } } return new WP_Error('elasticpress', __('No running host available.', 'elasticpress')); }
/** * Get/Set transient. * * @param string $key Transient name. Should be 172 (40 on site) characters or less since WordPress will prefix the name. * @param mixed $value Transient value. Expected to not be SQL-escaped. Can be callable value. Optional. * @param int $expiration Time until expiration in seconds from now, or 0 for never expires. Default 0. * @param bool $site Set to true if site transient. Default false. * * @return mixed */ function xu_get_transient($key, $value = null, $expiration = 0, $site = false) { if (!is_string($key)) { return false; } $transient_value = $site ? get_site_transient($key) : get_transient($key); // Return transient value if it exists or the return value if given value is null. if ($transient_value || is_null($value)) { return $transient_value; } // Support callable values. if (is_callable($value)) { $value = call_user_func($value); // Return false if null value. if (is_null($value)) { return false; } } if ($site) { set_site_transient($key, $value, $expiration); } else { set_transient($key, $value, $expiration); } return $value; }
public function instapageApiCall($service, $data = null, $endpoint = '') { if ($service === null) { $service_parts = parse_url($_SERVER['REQUEST_URI']); parse_str($url_parts['query'], $service_parts); if (isset($service_parts['url'])) { $service = $service_parts['url']; } } $url = self::endpoint . '/ajax/services/' . $endpoint . $service; $current_ver = self::getInstance()->includes['service']->pluginGet('Version'); $response = wp_remote_post($url, array('method' => 'POST', 'timeout' => 70, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => array('service-type' => 'Wordpress', 'service' => $_SERVER['SERVER_NAME'], 'version' => $current_ver, 'user_id' => get_option('instapage.user_id'), 'data' => $data), 'cookies' => array())); if (is_wp_error($response)) { $error_message = $response->get_error_message(); if (!empty($error_message)) { throw new InstapageApiCallException($error_message); } else { throw new InstapageApiCallException('500 Internal Server Error'); } } $res = json_decode($response['body'], true); if (!is_array($res) && !is_object($res)) { throw new InstapageApiCallException('Instapage Services returned empty response.'); } $data = new stdClass(); foreach ($res as $key => $val) { $data->{$key} = $val; } if ($service == 'update-check') { set_site_transient('instapage_latest_version', $data, 60 * 60 * 12); } return $data; }
function prli_get_main_message($message = '', $expiration = 1800) { global $prli_update; // Set the default message if (empty($message)) { $message = __("Get started by <a href=\"?page=pretty-link&action=new\">" . "adding a URL</a> that you want to turn into a pretty link.<br/>" . "Come back to see how many times it was clicked.", 'pretty-link'); } $messages = get_site_transient('_prli_messages'); // if the messages array has expired go back to the mothership if (!$messages) { $remote_controller = $prli_update->pro_is_installed_and_authorized() ? 'prlipro' : 'prli'; $message_mothership = "http://prettylinkpro.com/index.php?controller={$remote_controller}&action=json_messages"; if (!class_exists('WP_Http')) { include_once ABSPATH . WPINC . '/class-http.php'; } $http = new WP_Http(); $response = $http->request($message_mothership); if (isset($response) and is_array($response) and isset($response['body']) and !empty($response['body'])) { $messages = json_decode($response['body']); } else { $messages = array($message); } set_site_transient("_prli_messages", $messages, $expiration); } if (empty($messages) or !$messages or !is_array($messages)) { return $message; } else { return $messages[array_rand($messages)]; } }
/** * @param array $args * @param array $instance */ function widget($args, $instance) { extract($args); $user = esc_attr($instance['user']); $title = esc_attr($instance['title']); $number = (int) esc_attr($instance['number']) > 0 ? esc_attr($instance['number']) : 5; $before_widget = str_replace('class="', 'class="widget_twitter_tweets ', $before_widget); $title = str_replace('class="', 'class="widget_twitter_tweets ', $before_title) . $title . $after_title; $title = $before_title . $title . $after_title; // wp_enqueue_script( // 'fw-theme-twitter-widget', // get_template_directory_uri() . '/inc/widgets/twitter/static/js/scripts.js', // array( 'jquery' ), // '1.0' // ); $tweets = get_site_transient('scratch_tweets_' . $user . '_' . $number); if (empty($tweets)) { /* @var $connection TwitterOAuth */ $connection = fw_ext_social_twitter_get_connection(); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $user . "&count=" . $number); set_site_transient('scratch_tweets_' . $user . '_' . $number, $tweets, 12 * HOUR_IN_SECONDS); } $view_path = dirname(__FILE__) . '/views/widget.php'; echo fw_render_view($view_path, compact('before_widget', 'title', 'tweets', 'number', 'after_widget')); }
public function recheck() { $time_key = $this->slug . '-plugin_updater_api_request_last_checked'; $entity = new WPFront_User_Role_Editor_Entity_Options(); $entity->update_option($time_key, 0); set_site_transient('update_plugins', null); }
function queue_old_update($transient, $force = false) { if (method_exists('FrmUpdate', 'queue_addon_update')) { global $frm_update; $plugin = $this; return $frm_update->queue_addon_update($transient, $plugin, $force); } if (!is_object($transient) or empty($transient->checked)) { return $transient; } global $frmpro_is_installed; if ($frmpro_is_installed) { $expired = true; if (!$force) { $update = get_site_transient($this->pro_last_checked_store); if ($update) { $expired = false; } } if (!$update) { $update = $this->get_current_info($transient->checked[$this->plugin_name], $force, $this->plugin_nicename); } if ($update and !empty($update)) { $update = (object) $update; $transient->response[$this->plugin_name] = $update; //only check periodically if ($expired) { set_site_transient($this->pro_last_checked_store, $update, $this->pro_check_interval); } } } return $transient; }
function rocket_check_update() { if (defined('WP_INSTALLING')) { return false; } $plugin_folder = plugin_basename(dirname(WP_ROCKET_FILE)); $plugin_file = basename(WP_ROCKET_FILE); $version = true; $plugin_transient = null; $response = wp_remote_get(WP_ROCKET_WEB_CHECK, array('timeout' => 30)); set_site_transient('update_wprocket', time()); if (!is_a($response, 'WP_Error') && strlen($response['body']) > 32) { list($version, $url) = explode('|', $response['body']); if (version_compare($version, WP_ROCKET_VERSION, '<=')) { return false; } $plugin_transient = get_site_transient('update_plugins'); $temp_array = array('slug' => $plugin_folder, 'plugin' => $plugin_folder . '/wp-rocket.php', 'new_version' => $version, 'url' => 'http://wp-rocket.me', 'package' => $url); } else { $temp_array = array(); } if ($plugin_transient) { $temp_object = (object) $temp_array; $plugin_transient->response[$plugin_folder . '/' . $plugin_file] = $temp_object; set_site_transient('update_plugins', $plugin_transient); } else { return false; } }
public function checkForUpdates() { // This errors out when creating Shortcake UIs if (!is_array($this->extensions)) { return; } foreach ($this->extensions as $extension) { // Only check for updates every 3 hours if (!is_multisite()) { $updateChecker = get_transient(self::UPDATE_CHECKER_TRANSIENT . $extension['slug']); } else { $updateChecker = get_site_transient(self::UPDATE_CHECKER_TRANSIENT . $extension['slug']); } if (false !== $updateChecker && !self::DEBUG) { continue; } // retrieve our license key from the DB $licenseKey = get_site_option('sandwich_license_' . $extension['slug']); if (empty($licenseKey)) { continue; } // setup the updater $eddUpdater = new PBS_EDD_SL_Plugin_Updater($extension['store_url'], $extension['file'], array('version' => $extension['version'], 'license' => $licenseKey, 'item_name' => $extension['name'], 'author' => $extension['author'])); if (!is_multisite()) { set_transient(self::UPDATE_CHECKER_TRANSIENT . $extension['slug'], '1', 3 * HOUR_IN_SECONDS); } else { set_site_transient(self::UPDATE_CHECKER_TRANSIENT . $extension['slug'], '1', 3 * HOUR_IN_SECONDS); } } }
/** * Retrieve product data from Beans REST API. * * Data are cached in a 24 hours transients and will be returned if found to avoid long loading time. * * @ignore */ function beans_updater($value) { $data = get_site_transient('beans_updater'); $theme = wp_get_theme('tm-beans'); if (!$theme->exists()) { return $value; } $current_version = $theme->get('Version'); // Query Beans REST API if the transient is expired. if (empty($data)) { $args = array('timeout' => 15, 'sslverify' => false); $response = wp_remote_get('http://www.getbeans.io/rest-api/', $args); if (is_wp_error($response)) { return $value; } // Retrieve data from the body and decode json format. $data = json_decode(wp_remote_retrieve_body($response), true); // Stop here if the is an error. if (isset($data['error'])) { // Set temporary transient. set_site_transient('beans_updater', array('version' => $current_version), 30 * MINUTE_IN_SECONDS); return $value; } set_site_transient('beans_updater', $data, 24 * HOUR_IN_SECONDS); } // Return data if Beans is not up to date. if (version_compare($current_version, beans_get('version', $data), '<')) { $value->response[$data['path']] = array('slug' => $data['slug'], 'name' => $data['name'], 'url' => $data['changelog_url'], 'package' => $data['download_url'], 'new_version' => $data['version'], 'tested' => $data['tested'], 'requires' => $data['requires']); return $value; } return $value; }
/** * Provided a URL, will return an array representing the feed item for that * URL. A feed item contains the content, url, simplepie object, and failure * status for the URL passed. Handles caching of content requests. * * @return array * @author Jared Lang * */ protected static function __new_feed($url) { require_once ABSPATH . '/wp-includes/class-simplepie.php'; $simplepie = null; $failed = False; $cache_key = 'feedmanager-' . md5($url); $content = get_site_transient($cache_key); if ($content === False) { $content = @file_get_contents($url); if ($content === False) { $failed = True; $content = null; error_log('FeedManager failed to fetch data using url of ' . $url); } else { set_site_transient($cache_key, $content, self::$cache_length); } } if ($content) { $simplepie = new SimplePie(); $simplepie->set_raw_data($content); $simplepie->init(); $simplepie->handle_content_type(); if ($simplepie->error) { error_log($simplepie->error); $simplepie = null; $failed = True; } } else { $failed = True; } return array('content' => $content, 'url' => $url, 'simplepie' => $simplepie, 'failed' => $failed); }
function generate_maths_question() { global $aio_wp_security; //For now we will only do plus, minus, multiplication $equation_string = ''; $operator_type = array('+', '−', '×'); $operand_display = array('word', 'number'); //let's now generate an equation $operator = $operator_type[rand(0, 2)]; if ($operator === '×') { //Don't make the question too hard if multiplication $first_digit = rand(1, 5); $second_digit = rand(1, 5); } else { $first_digit = rand(1, 20); $second_digit = rand(1, 20); } if ($operand_display[rand(0, 1)] == 'word') { $first_operand = $this->number_word_mapping($first_digit); } else { $first_operand = $first_digit; } if ($operand_display[rand(0, 1)] == 'word') { $second_operand = $this->number_word_mapping($second_digit); } else { $second_operand = $second_digit; } //Let's caluclate the result and construct the equation string if ($operator === '+') { //Addition $result = $first_digit + $second_digit; $equation_string .= $first_operand . ' ' . $operator . ' ' . $second_operand . ' = '; } else { if ($operator === '−') { //Subtraction //If we are going to be negative let's swap operands around if ($first_digit < $second_digit) { $equation_string .= $second_operand . ' ' . $operator . ' ' . $first_operand . ' = '; $result = $second_digit - $first_digit; } else { $equation_string .= $first_operand . ' ' . $operator . ' ' . $second_operand . ' = '; $result = $first_digit - $second_digit; } } elseif ($operator === '×') { //Multiplication $equation_string .= $first_operand . ' ' . $operator . ' ' . $second_operand . ' = '; $result = $first_digit * $second_digit; } } //Let's encode correct answer $captcha_secret_string = $aio_wp_security->configs->get_value('aiowps_captcha_secret_key'); $current_time = time(); $enc_result = base64_encode($current_time . $captcha_secret_string . $result); $random_str = AIOWPSecurity_Utility::generate_alpha_numeric_random_string(10); AIOWPSecurity_Utility::is_multisite_install() ? set_site_transient('aiowps_captcha_string_info_' . $random_str, $enc_result, 30 * 60) : set_transient('aiowps_captcha_string_info_' . $random_str, $enc_result, 30 * 60); $equation_string .= '<input type="hidden" name="aiowps-captcha-string-info" id="aiowps-captcha-string-info" value="' . $random_str . '" />'; $equation_string .= '<input type="hidden" name="aiowps-captcha-temp-string" id="aiowps-captcha-temp-string" value="' . $current_time . '" />'; $equation_string .= '<input type="text" size="2" id="aiowps-captcha-answer" name="aiowps-captcha-answer" value="" />'; return $equation_string; }
/** * Put changelog in plugins_api, return WP.org data as appropriate * * @since 2.0.0 */ public function plugins_api($false, $action, $response) { if (!('plugin_information' === $action)) { return $false; } $wp_repo_data = get_site_transient('ghu-' . md5($response->slug . 'php')); if (!$wp_repo_data) { $wp_repo_data = wp_remote_get('http://api.wordpress.org/plugins/info/1.0/' . $response->slug . '.php'); set_site_transient('ghu-' . md5($response->slug . 'php'), $wp_repo_data, 12 * HOUR_IN_SECONDS); } if (!empty($wp_repo_data['body'])) { $wp_repo_body = unserialize($wp_repo_data['body']); if (is_object($wp_repo_body)) { $response = $wp_repo_body; } } foreach ((array) $this->config as $plugin) { if ($response->slug === $plugin->repo) { $response->slug = $plugin->slug; $response->plugin_name = $plugin->name; $response->author = $plugin->author; $response->homepage = $plugin->uri; $response->version = $plugin->remote_version; $response->sections = $plugin->sections; $response->requires = $plugin->requires; $response->tested = $plugin->tested; $response->downloaded = $plugin->downloaded; $response->last_updated = $plugin->last_updated; $response->rating = $plugin->rating; $response->num_ratings = $plugin->num_ratings; //$response->download_link = $plugin->download_link; } } return $response; }
/** * Retrieve the contributor credits. * * @global string $wp_version The current WordPress version. * * @since 3.2.0 * * @return array|false A list of all of the contributors, or false on error. */ function wp_credits() { global $wp_version; $locale = get_locale(); $results = get_site_transient( 'wordpress_credits_' . $locale ); if ( ! is_array( $results ) || false !== strpos( $wp_version, '-' ) || ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 ) ) { $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale" ); if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) return false; $results = json_decode( wp_remote_retrieve_body( $response ), true ); if ( ! is_array( $results ) ) return false; set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS ); } return $results; }
/** * {@inheritdoc} * @internal */ public function _get_framework_latest_version($force_check) { $user_slash_repo = fw()->manifest->get($this->manifest_key); if (empty($user_slash_repo)) { return false; } if (!preg_match($this->manifest_key_regex, $user_slash_repo)) { return new WP_Error('fw_ext_update_github_framework_manifest_invalid', __('Framework manifest has invalid "github_update" parameter. Please use "user/repo" format.', 'fw')); } $theme_id = preg_replace('[^a-z0-9_]', '_', fw()->theme->manifest->get_id()); $transient_id = 'fw_ext_update_gh_' . $theme_id . '_fw'; // this should be 45 characters or less if ($force_check) { delete_site_transient($transient_id); } else { $cache = get_site_transient($transient_id); if ($cache !== false && isset($cache[$user_slash_repo])) { return $cache[$user_slash_repo]; } } $latest_version = $this->fetch_latest_version($user_slash_repo); if (empty($latest_version)) { return new WP_Error(sprintf(__('Failed to fetch framework latest version from github "%s".', 'fw'), $user_slash_repo)); } if (is_wp_error($latest_version)) { return $latest_version; } set_site_transient($transient_id, array($user_slash_repo => $latest_version), $this->transient_expiration); return $latest_version; }
/** * Provided a URL, will return an array representing the feed item for that * URL. A feed item contains the content, url, simplepie object, and failure * status for the URL passed. Handles caching of content requests. * * @return array * @author Jared Lang **/ protected static function __new_feed($url) { $timer = Timer::start(); require_once THEME_DIR . '/third-party/simplepie.php'; $simplepie = null; $failed = False; $cache_key = 'feedmanager-' . md5($url); $content = get_site_transient($cache_key); if ($content === False) { $content = @file_get_contents($url); if ($content === False) { $failed = True; $content = null; error_log('FeedManager failed to fetch data using url of ' . $url); } else { set_site_transient($cache_key, $content, self::$cache_length); } } if ($content) { $simplepie = new SimplePie(); $simplepie->set_raw_data($content); $simplepie->init(); $simplepie->handle_content_type(); if ($simplepie->error) { error_log($simplepie->error); $simplepie = null; $failed = True; } } else { $failed = True; } $elapsed = round($timer->elapsed() * 1000); debug("__new_feed: {$elapsed} milliseconds"); return array('content' => $content, 'url' => $url, 'simplepie' => $simplepie, 'failed' => $failed); }
function mu_loader_plugins_files() { if (defined('WP_INSTALLING') && WP_INSTALLING === true) { // Do nothing during installation return array(); } // Cache plugins $plugins = get_site_transient('mu_loader_plugins'); if ($plugins !== false) { // Validate plugins still exist // If not, invalidate cache foreach ($plugins as $plugin_file) { if (!is_readable(WPMU_PLUGIN_DIR . '/' . $plugin_file)) { $plugins = false; break; } } } if ($plugins === false) { if (!function_exists('get_plugins')) { // get_plugins is not included by default require ABSPATH . 'wp-admin/includes/plugin.php'; } // Invalid cache $plugins = array(); foreach (get_plugins('/../mu-plugins') as $plugin_file => $data) { if (dirname($plugin_file) != '.' && dirname($plugin_file) != 'mu-loader') { // skip files directly at root $plugins[] = $plugin_file; } } set_site_transient('mu_loader_plugins', $plugins); } return $plugins; }
function contact_form_7_modules_get_remote_message() { // The ad is stored locally for 30 days as a transient. See if it exists. $cache = function_exists('get_site_transient') ? get_site_transient('contact_form_7_modules_remote_ad') : get_transient('contact_form_7_modules_remote_ad'); // If it exists, use that (so we save some request time), unless ?cache is set. if (!empty($cache) && !isset($_REQUEST['cache'])) { return $cache; } // Get the advertisement remotely. An encrypted site identifier, the language of the site, and the version of the cf7 plugin will be sent to katz.co $response = wp_remote_post('http://katz.co/ads/', array('timeout' => 45, 'body' => array('siteid' => sha1(site_url()), 'language' => get_bloginfo('language'), 'plugin' => 'cf7_modules', 'version' => WPCF7_VERSION))); // If it was a successful request, process it. if (!is_wp_error($response) && !empty($response)) { // Basically, remove <script>, <iframe> and <object> tags for security reasons $body = strip_tags(trim(rtrim($response['body'])), '<b><strong><em><i><span><u><ul><li><ol><div><attr><cite><a><style><blockquote><q><p><form><br><meta><option><textarea><input><select><pre><code><s><del><small><table><tbody><tr><th><td><tfoot><thead><u><dl><dd><dt><col><colgroup><fieldset><address><button><aside><article><legend><label><source><kbd><tbody><hr><noscript><link><h1><h2><h3><h4><h5><h6><img>'); // If the result is empty, cache it for 8 hours. Otherwise, cache it for 30 days. $cache_time = empty($response['body']) ? floatval(60 * 60 * 8) : floatval(60 * 60 * 30); if (function_exists('set_site_transient')) { set_site_transient('contact_form_7_modules_remote_ad', $body, $cache_time); } else { set_transient('contact_form_7_modules_remote_ad', $body, $cache_time); } // Print the results. return $body; } }
/** * Constructor. */ public function __construct() { // This MUST come before we get details about the themes so the headers are correctly retrieved GitHub_Updater_GitHub_API::add_headers(); GitHub_Updater_BitBucket_API::add_headers(); // Get details of GitHub-sourced themes $this->config = $this->get_theme_meta(); if (empty($this->config)) { return false; } if (isset($_GET['force-check']) && '1' === $_GET['force-check']) { $this->delete_all_transients('themes'); } foreach ((array) $this->config as $theme) { switch ($theme->type) { case 'github_theme': $repo_api = new GitHub_Updater_GitHub_API($theme); break; case 'bitbucket_theme': $repo_api = new GitHub_Updater_BitBucket_API($theme); break; } $this->{$theme->type} = $theme; $this->set_defaults($theme->type); if ($repo_api->get_remote_info('style.css')) { $repo_api->get_repo_meta(); $repo_api->get_remote_tag(); $repo_api->get_remote_changes('CHANGES.md'); $theme->download_link = $repo_api->construct_download_link(); } // Update theme transient with rollback data if (!empty($_GET['rollback']) && $_GET['theme'] === $theme->repo) { $this->tag = $_GET['rollback']; $updates_transient = get_site_transient('update_themes'); $rollback = array('new_version' => $this->tag, 'url' => $theme->uri, 'package' => $repo_api->construct_download_link($this->tag)); $updates_transient->response[$theme->repo] = $rollback; set_site_transient('update_themes', $updates_transient); } // Remove WordPress update row in theme row, only in multisite // Add update row to theme row, only in multisite for WP < 3.8 if (is_multisite() || get_bloginfo('version') < 3.8) { add_action('after_theme_row', array($this, 'remove_after_theme_row'), 10, 2); if (!$this->tag) { add_action("after_theme_row_{$theme->repo}", array($this, 'wp_theme_update_row'), 10, 2); } } } $this->make_force_check_transient('themes'); $update = array('do-core-reinstall', 'do-core-upgrade'); if (empty($_GET['action']) || !in_array($_GET['action'], $update, true)) { add_filter('pre_set_site_transient_update_themes', array($this, 'pre_set_site_transient_update_themes')); } add_filter('themes_api', array($this, 'themes_api'), 99, 3); add_filter('upgrader_source_selection', array($this, 'upgrader_source_selection'), 10, 3); add_filter('http_request_args', array($this, 'no_ssl_http_request_args'), 10, 2); if (!is_multisite()) { add_filter('wp_prepare_themes_for_js', array($this, 'customize_theme_update_html')); } }
function force_check_for_updates() { $current_transient = get_site_transient('update_plugins'); $new_transient = apply_filters('site_transient_update_plugins', $current_transient, true); set_site_transient('update_plugins', $new_transient, $this->check_update_timeout); echo json_encode('checked'); exit; }
public static function set_version_info($version_info) { if (function_exists('set_site_transient')) { set_site_transient("gforms_campaignmonitor_version", $version_info, 60 * 60 * 12); } else { set_transient("gforms_campaignmonitor_version", $version_info, 60 * 60 * 12); } }
/** * Activate the license key * * @since 1.9 * * @param string $license_key activation key * @return object updated $this */ public function activate_license($license_key) { $this->license_key = $license_key; $this->api_request('activate_license'); // Tell WordPress to look for updates set_site_transient('update_plugins', null); return $this; }
public static function set_version_info($version_info) { if (function_exists('set_site_transient')) { set_site_transient("gforms_userregistration_version", $version_info, 60 * 60 * 12); } else { set_transient("gforms_userregistration_version", $version_info, 60 * 60 * 12); } }
function __construct($api_url, $theme_id, $theme_slug) { $this->api_url = $api_url; $this->theme_id = $theme_id; $this->theme_slug = $theme_slug; add_filter('pre_set_site_transient_update_themes', array(&$this, 'check_for_update')); // This is for testing only! set_site_transient('update_themes', null); }
public static function setTransient($sTransientKey, $vValue, $iExpiration = 0) { global $_wp_using_ext_object_cache; $_bWpUsingExtObjectCacheTemp = $_wp_using_ext_object_cache; $_wp_using_ext_object_cache = false; self::$_bIsNetworkAdmin = isset(self::$_bIsNetworkAdmin) ? self::$_bIsNetworkAdmin : is_network_admin(); $_bIsSet = self::$_bIsNetworkAdmin ? set_site_transient($sTransientKey, $vValue, $iExpiration) : set_transient($sTransientKey, $vValue, $iExpiration); $_wp_using_ext_object_cache = $_bWpUsingExtObjectCacheTemp; return $_bIsSet; }
function attempt_request_lock($blog_id, $expiry = self::BLOG_LOCK_TRANSIENT_EXPIRY) { $transient_name = $this->get_concurrent_request_transient_name($blog_id); $locked_time = get_site_transient($transient_name); if ($locked_time) { return false; } set_site_transient($transient_name, microtime(true), $expiry); return true; }
/** * @ticket 22846 */ public function test_set_site_transient_is_not_stored_as_autoload_option() { $key = 'not_autoloaded'; if (is_multisite()) { $this->markTestSkipped('Does not apply when used in multisite.'); } set_site_transient($key, 'Not an autoload option'); $options = wp_load_alloptions(); $this->assertFalse(isset($options['_site_transient_' . $key])); }
protected static function get_scan_results() { $response = get_site_transient(self::$transient_name); $cached = true; if (defined('ITSEC_TEST_MALWARE_SCAN_SKIP_CACHE') && ITSEC_TEST_MALWARE_SCAN_SKIP_CACHE) { $cached = false; $response = false; } if (false === $response) { $cached = false; $scanner_url = 'http://sitecheck.sucuri.net/'; $site_url = apply_filters('itsec_test_malware_scan_site_url', get_site_url()); if (defined('ITSEC_TEST_MALWARE_SCAN_SITE_URL')) { $site_url = ITSEC_TEST_MALWARE_SCAN_SITE_URL; } $site_url = preg_replace('|^https?://|i', '', $site_url); $query_args = array('scan' => $site_url, 'p' => 'ithemes', 'clear' => 1, 'json' => 1, 'time' => time()); $key = apply_filters('itsec_sucuri_key', ''); if (defined('ITSEC_SUCURI_KEY')) { $key = ITSEC_SUCURI_KEY; } if (!empty($key)) { $query_args['k'] = $key; } $scan_url = "{$scanner_url}?" . http_build_query($query_args); $req_args = array('timeout' => 300); if (defined('ITSEC_TEST_MALWARE_SCAN_DISABLE_SSLVERIFY') && ITSEC_TEST_MALWARE_SCAN_DISABLE_SSLVERIFY) { $req_args['sslverify'] = false; } $response = wp_remote_get($scan_url, $req_args); if (is_wp_error($response)) { return $response; } } if (!is_array($response) || !array_key_exists('body', $response) || !array_key_exists('headers', $response) || !array_key_exists('response', $response) || !isset($response['headers']['content-type'])) { return new WP_Error('itsec-malware-scanner-malformed-wp-remote-get-response', __('The response from the wp_remote_get function was malformed. This could indicate an issue with WordPress.', 'better-wp-security')); } if ('application/json' !== $response['headers']['content-type']) { return new WP_Error('itsec-malware-scanner-invalid-content-type-in-scan-response', sprintf(__('The Sucuri server returned an invalid content type. A content type of <code>%s</code> was received when a content type of <code>application/json</code> was expected. This could indicate a temporary issue with the Sucuri servers.', 'better-wp-security'), esc_html($response['headers']['content-type']))); } $body = @json_decode($response['body'], true); if (!is_array($body)) { if ('ERROR' === substr($response['body'], 0, 5)) { return new WP_Error('itsec-malware-scanner-error-received', sprintf(__('The scan did not complete successfully. Sucuri sent the following error: %s', 'better-wp-security'), $response['body'])); } return new WP_Error('itsec-malware-scanner-unknown-scan-error', sprintf(__('An unknown error prevented the scan from completing successfully. The Sucuri server responded with a <code>%s</code> error code.', 'better-wp-security'), $response['response']['code'])); } if (!$cached) { set_site_transient(self::$transient_name, $response, 10 * MINUTE_IN_SECONDS); } if (is_array($body)) { $body['cached'] = $cached; } return $body; }
function test_serialized_data() { $key = rand_str(); $value = array('foo' => true, 'bar' => true); $this->assertTrue(set_site_transient($key, $value)); $this->assertEquals($value, get_site_transient($key)); $value = (object) $value; $this->assertTrue(set_site_transient($key, $value)); $this->assertEquals($value, get_site_transient($key)); $this->assertTrue(delete_site_transient($key)); }
/** * TODO Document! */ function pagelines_theme_update_push($value) { $pagelines_update = (array) maybe_unserialize($this->pagelines_theme_update_check()); if ($pagelines_update && isset($pagelines_update['package']) && $pagelines_update['package'] !== 'bad') { $value->response['pagelines'] = $pagelines_update; $this->site_tran->response['pagelines'] = $pagelines_update; set_site_transient('update_themes', $this->site_tran); return $this->site_tran; } return $value; }