本文整理汇总了PHP中set_site_transient函数的典型用法代码示例。如果您正苦于以下问题:PHP set_site_transient函数的具体用法?PHP set_site_transient怎么用?PHP set_site_transient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_site_transient函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_ep_host
/**
* 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'));
}
开发者ID:cliebler,项目名称:elasticsearch-wp-plugin,代码行数:46,代码来源:class-ep-config.php
示例2: xu_get_transient
/**
* 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;
}
开发者ID:wp-xu,项目名称:framework,代码行数:35,代码来源:transient.php
示例3: instapageApiCall
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;
}
开发者ID:peter-watters,项目名称:yo_WordPressTheme,代码行数:33,代码来源:api.php
示例4: prli_get_main_message
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)];
}
}
开发者ID:phpwomen,项目名称:combell,代码行数:30,代码来源:models.inc.php
示例5: widget
/**
* @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'));
}
开发者ID:Umeeshh,项目名称:Scratch-Theme,代码行数:29,代码来源:class-widget-twitter.php
示例6: recheck
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);
}
开发者ID:JulieKuehl,项目名称:auburn-agency,代码行数:7,代码来源:class-wpfront-user-role-editor-plugin-updater.php
示例7: queue_old_update
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;
}
开发者ID:sedici,项目名称:wpmu-istec,代码行数:33,代码来源:FrmCptUpdate.php
示例8: rocket_check_update
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;
}
}
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:29,代码来源:updater.php
示例9: checkForUpdates
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);
}
}
}
开发者ID:JohnStafford,项目名称:Page-Builder-Sandwich,代码行数:30,代码来源:updater.php
示例10: beans_updater
/**
* 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;
}
开发者ID:JoomPassion,项目名称:Beans,代码行数:39,代码来源:updater.php
示例11: __new_feed
/**
* 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);
}
开发者ID:UCF,项目名称:Students-Theme,代码行数:40,代码来源:feeds.php
示例12: generate_maths_question
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;
}
开发者ID:crazyyy,项目名称:bessarabia,代码行数:60,代码来源:wp-security-captcha.php
示例13: plugins_api
/**
* 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;
}
开发者ID:vondervick,项目名称:veuse-uikit,代码行数:40,代码来源:class-plugin-updater.php
示例14: wp_credits
/**
* 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;
}
开发者ID:ShankarVellal,项目名称:WordPress,代码行数:34,代码来源:credits.php
示例15: _get_framework_latest_version
/**
* {@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;
}
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:34,代码来源:class-fw-extension-github-update.php
示例16: __new_feed
/**
* 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);
}
开发者ID:rolandinsh,项目名称:Pegasus-Theme,代码行数:43,代码来源:feeds.php
示例17: mu_loader_plugins_files
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;
}
开发者ID:UPMediaDesign,项目名称:vidaestudiantilip,代码行数:35,代码来源:mu-loader.php
示例18: contact_form_7_modules_get_remote_message
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;
}
}
开发者ID:Allan019,项目名称:grupometa,代码行数:25,代码来源:functions.php
示例19: __construct
/**
* 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'));
}
}
开发者ID:nino65,项目名称:pasw2015beta,代码行数:62,代码来源:class-theme-updater.php
示例20: force_check_for_updates
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;
}
开发者ID:WP-Panda,项目名称:allergenics,代码行数:8,代码来源:class-storeapps-upgrade.php
注:本文中的set_site_transient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论