• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_transient函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_transient函数的典型用法代码示例。如果您正苦于以下问题:PHP get_transient函数的具体用法?PHP get_transient怎么用?PHP get_transient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_transient函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * Prevent caching on dynamic pages.
  *
  * @access public
  * @return void
  */
 public function init()
 {
     if (false === ($wc_page_uris = get_transient('woocommerce_cache_excluded_uris'))) {
         if (woocommerce_get_page_id('cart') < 1 || woocommerce_get_page_id('checkout') < 1 || woocommerce_get_page_id('myaccount') < 1) {
             return;
         }
         $wc_page_uris = array();
         $cart_page = get_post(woocommerce_get_page_id('cart'));
         $checkout_page = get_post(woocommerce_get_page_id('checkout'));
         $account_page = get_post(woocommerce_get_page_id('myaccount'));
         $wc_page_uris[] = '/' . $cart_page->post_name;
         $wc_page_uris[] = '/' . $checkout_page->post_name;
         $wc_page_uris[] = '/' . $account_page->post_name;
         $wc_page_uris[] = 'p=' . $cart_page->ID;
         $wc_page_uris[] = 'p=' . $checkout_page->ID;
         $wc_page_uris[] = 'p=' . $account_page->ID;
         set_transient('woocommerce_cache_excluded_uris', $wc_page_uris);
     }
     if (is_array($wc_page_uris)) {
         foreach ($wc_page_uris as $uri) {
             if (strstr($_SERVER['REQUEST_URI'], $uri)) {
                 $this->nocache();
                 break;
             }
         }
     }
 }
开发者ID:rongandat,项目名称:sallumeh,代码行数:33,代码来源:class-wc-cache-helper.php


示例2: genesis_update_check

/**
 * Pings http://api.genesistheme.com/ asking if a new version of this theme is
 * available.
 *
 * If not, it returns false.
 *
 * If so, the external server passes serialized data back to this function,
 * which gets unserialized and returned for use.
 *
 * @since 1.1.0
 *
 * @uses genesis_get_option()
 * @uses PARENT_THEME_VERSION Genesis version string
 *
 * @global string $wp_version WordPress version string
 * @return mixed Unserialized data, or false on failure
 */
function genesis_update_check()
{
    global $wp_version;
    /**	If updates are disabled */
    if (!genesis_get_option('update') || !current_theme_supports('genesis-auto-updates')) {
        return false;
    }
    /** Get time of last update check */
    $genesis_update = get_transient('genesis-update');
    /** If it has expired, do an update check */
    if (!$genesis_update) {
        $url = 'http://api.genesistheme.com/update-themes/';
        $options = apply_filters('genesis_update_remote_post_options', array('body' => array('genesis_version' => PARENT_THEME_VERSION, 'wp_version' => $wp_version, 'php_version' => phpversion(), 'uri' => home_url(), 'user-agent' => "WordPress/{$wp_version};")));
        $response = wp_remote_post($url, $options);
        $genesis_update = wp_remote_retrieve_body($response);
        /** If an error occurred, return FALSE, store for 1 hour */
        if ('error' == $genesis_update || is_wp_error($genesis_update) || !is_serialized($genesis_update)) {
            set_transient('genesis-update', array('new_version' => PARENT_THEME_VERSION), 60 * 60);
            return false;
        }
        /** Else, unserialize */
        $genesis_update = maybe_unserialize($genesis_update);
        /** And store in transient for 24 hours */
        set_transient('genesis-update', $genesis_update, 60 * 60 * 24);
    }
    /** If we're already using the latest version, return false */
    if (version_compare(PARENT_THEME_VERSION, $genesis_update['new_version'], '>=')) {
        return false;
    }
    return $genesis_update;
}
开发者ID:hscale,项目名称:webento,代码行数:48,代码来源:upgrade.php


示例3: get_photos

 function get_photos($id, $count = 8)
 {
     if (empty($id)) {
         return false;
     }
     $transient_key = md5('favethemes_flickr_cache_' . $id . $count);
     $cached = get_transient($transient_key);
     if (!empty($cached)) {
         return $cached;
     }
     $output = array();
     $rss = 'http://api.flickr.com/services/feeds/photos_public.gne?id=' . $id . '&lang=en-us&format=rss_200';
     $rss = fetch_feed($rss);
     if (is_wp_error($rss)) {
         //check for group feed
         $rss = 'http://api.flickr.com/services/feeds/groups_pool.gne?id=' . $id . '&lang=en-us&format=rss_200';
         $rss = fetch_feed($rss);
     }
     if (!is_wp_error($rss)) {
         $maxitems = $rss->get_item_quantity($count);
         $rss_items = $rss->get_items(0, $maxitems);
         foreach ($rss_items as $item) {
             $temp = array();
             $temp['img_url'] = esc_url($item->get_permalink());
             $temp['title'] = esc_html($item->get_title());
             $content = $item->get_content();
             preg_match_all("/<IMG.+?SRC=[\"']([^\"']+)/si", $content, $sub, PREG_SET_ORDER);
             $photo_url = str_replace("_m.jpg", "_t.jpg", $sub[0][1]);
             $temp['img_src'] = esc_url($photo_url);
             $output[] = $temp;
         }
         set_transient($transient_key, $output, 60 * 60 * 24);
     }
     return $output;
 }
开发者ID:phuthuytinhoc,项目名称:Demo1,代码行数:35,代码来源:magazilla-flickr-photos.php


示例4: check_update

 public static function check_update($plugin_path, $plugin_slug, $plugin_url, $offering, $key, $version, $option)
 {
     $version_info = function_exists('get_site_transient') ? get_site_transient("gforms_userregistration_version") : get_transient("gforms_userregistration_version");
     //making the remote request for version information
     if (!$version_info) {
         //Getting version number
         $version_info = self::get_version_info($offering, $key, $version);
         self::set_version_info($version_info);
     }
     if ($version_info == -1) {
         return $option;
     }
     if (empty($option->response[$plugin_path])) {
         $option->response[$plugin_path] = new stdClass();
     }
     //Empty response means that the key is invalid. Do not queue for upgrade
     if (!$version_info["is_valid_key"] || version_compare($version, $version_info["version"], '>=')) {
         unset($option->response[$plugin_path]);
     } else {
         $option->response[$plugin_path]->url = $plugin_url;
         $option->response[$plugin_path]->slug = $plugin_slug;
         $option->response[$plugin_path]->package = str_replace("{KEY}", $key, $version_info["url"]);
         $option->response[$plugin_path]->new_version = $version_info["version"];
         $option->response[$plugin_path]->id = "0";
     }
     return $option;
 }
开发者ID:vinvinh315,项目名称:maintainwebsolutions.com,代码行数:27,代码来源:plugin-upgrade.php


示例5: moxie_press_endpoint_data

function moxie_press_endpoint_data()
{
    global $wp_query;
    // get query vars
    $json = $wp_query->get('json');
    $name = $wp_query->get('name');
    // use this template redirect only if json is requested
    if ($json != 'true') {
        return;
    }
    // build the query
    $movie_data = array();
    // default args
    $args = array('post_type' => 'movie', 'posts_per_page' => 100);
    if ($name != '') {
        $args['name'] = $name;
    }
    // add name if provided in query
    // check if this particular request is cached, if not, perform the query
    if (false === ($moxie_cached_request = get_transient('moxie_cached_request_' . json_encode($args)))) {
        $moxie_cached_request = new WP_Query($args);
        set_transient('moxie_cached_request_' . json_encode($args), $moxie_cached_request);
    }
    // prepare the object we want to send as response
    if ($moxie_cached_request->have_posts()) {
        while ($moxie_cached_request->have_posts()) {
            $moxie_cached_request->the_post();
            $id = get_the_ID();
            $movie_data[] = array('id' => $id, 'title' => get_the_title(), 'poster_url' => get_post_meta($id, 'moxie_press_poster_url', true), 'rating' => get_post_meta($id, 'moxie_press_rating', true), 'year' => get_post_meta($id, 'moxie_press_year', true), 'short_description' => get_post_meta($id, 'moxie_press_description', true), 'mdbid' => get_post_meta($id, 'moxie_press_mdbid', true));
        }
        wp_reset_postdata();
    }
    // send json data using built-in WP function
    wp_send_json(array('data' => $movie_data));
}
开发者ID:camilodelvasto,项目名称:MoxiePress,代码行数:35,代码来源:json-api.php


示例6: cache_in_progress

 function cache_in_progress($reportid)
 {
     global $tzobj;
     $r = intval(substr($reportid, 5));
     /* *** skip the 'users' and take the rest */
     $inprogress = get_transient('amr_users_cache_' . $r);
     if (!$inprogress) {
         $this->log_cache_event('Cache record, but no transient yet? ' . $reportid);
         return false;
     }
     $status = ausers_get_option('amr-users-cache-status');
     //var_dump($status);
     if (isset($status[$reportid]['start']) and !isset($status[$reportid]['end'])) {
         $now = time();
         $diff = $now - $status[$reportid]['start'];
         if ($diff > 60 * 5) {
             $d = date_create(strftime('%c', $status[$reportid]['start']));
             date_timezone_set($d, $tzobj);
             $text = sprintf(__('Report %s started %s ago', 'amr-users'), $reportid, human_time_diff($status[$reportid]['start'], time()));
             $text .= ' ' . __('Something may be wrong - delete cache status, try again, check server logs and/or memory limit', 'amr-users');
             $this->log_cache_event($text);
             $fun = '<a href="http://upload.wikimedia.org/wikipedia/commons/1/12/Apollo13-wehaveaproblem_edit_1.ogg" >' . __('Houston, we have a problem', 'amr-users') . '</a>';
             $text = $fun . '<br/>' . $text;
             amr_users_message($text);
             return false;
         } else {
             return true;
         }
     } else {
         return false;
     }
 }
开发者ID:rdelr011,项目名称:BOLO-Flier-Creator,代码行数:32,代码来源:ameta-cache.php


示例7: fix_in_wpadmin

 function fix_in_wpadmin($config, $force_all_checks = false)
 {
     $exs = new SelfTestExceptions();
     $fix_on_event = false;
     if (w3_is_multisite() && w3_get_blog_id() != 0) {
         if (get_transient('w3tc_config_changes') != ($md5_string = $config->get_md5())) {
             $fix_on_event = true;
             set_transient('w3tc_config_changes', $md5_string, 3600);
         }
     }
     // call plugin-related handlers
     foreach ($this->get_handlers($config) as $h) {
         try {
             $h->fix_on_wpadmin_request($config, $force_all_checks);
             if ($fix_on_event) {
                 $this->fix_on_event($config, 'admin_request');
             }
         } catch (SelfTestExceptions $ex) {
             $exs->push($ex);
         }
     }
     if (count($exs->exceptions()) > 0) {
         throw $exs;
     }
 }
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:25,代码来源:AdminEnvironment.php


示例8: purge_transients

 function purge_transients($older_than = '7 days', $safemode = true)
 {
     global $wpdb;
     $older_than_time = strtotime('-' . $older_than);
     if ($older_than_time > time() || $older_than_time < 1) {
         return false;
     }
     $transients = $wpdb->get_col($wpdb->prepare("\n\t\t\t\t\tSELECT REPLACE(option_name, '_transient_timeout_', '') AS transient_name \n\t\t\t\t\tFROM {$wpdb->options} \n\t\t\t\t\tWHERE option_name LIKE '\\_transient\\_timeout\\__%%'\n\t\t\t\t\t\tAND option_value < %s\n\t\t\t", $older_than_time));
     if ($safemode) {
         foreach ($transients as $transient) {
             get_transient($transient);
         }
     } else {
         $options_names = array();
         foreach ($transients as $transient) {
             $options_names[] = '_transient_' . $transient;
             $options_names[] = '_transient_timeout_' . $transient;
         }
         if ($options_names) {
             $options_names = array_map(array($wpdb, 'escape'), $options_names);
             $options_names = "'" . implode("','", $options_names) . "'";
             $result = $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name IN ({$options_names})");
             if (!$result) {
                 return false;
             }
         }
     }
     return $transients;
 }
开发者ID:kubens,项目名称:Snippets,代码行数:29,代码来源:purge-transients.php


示例9: get_groupings

 /**
  * Retrive the list of groupings associated with a list id
  *
  * @param  string $list_id     List id for which groupings should be returned
  * @return array  $groups_data Data about the groups
  */
 public function get_groupings($list_id = '')
 {
     global $edd_options;
     if (!empty($edd_options['eddmc_api'])) {
         $grouping_data = get_transient('edd_mailchimp_groupings_' . $list_id);
         if (false === $grouping_data) {
             if (!class_exists('EDD_MailChimp_API')) {
                 require_once EDD_MAILCHIMP_PATH . '/includes/MailChimp.class.php';
             }
             $api = new EDD_MailChimp_API(trim($edd_options['eddmc_api']));
             $grouping_data = $api->call('lists/interest-groupings', array('id' => $list_id));
             set_transient('edd_mailchimp_groupings_' . $list_id, $grouping_data, 24 * 24 * 24);
         }
         $groups_data = array();
         if ($grouping_data && !isset($grouping_data->status)) {
             foreach ($grouping_data as $grouping) {
                 $grouping_id = $grouping->id;
                 $grouping_name = $grouping->name;
                 foreach ($grouping->groups as $groups) {
                     $group_name = $groups->name;
                     $groups_data["{$list_id}|{$grouping_id}|{$group_name}"] = $grouping_name . ' - ' . $group_name;
                 }
             }
         }
     }
     return $groups_data;
 }
开发者ID:EngageWP,项目名称:edd-mail-chimp,代码行数:33,代码来源:class-edd-mailchimp.php


示例10: videopress_get_video_details

/**
 * Get details about a specific video by GUID:
 *
 * @param $guid string
 * @return object
 */
function videopress_get_video_details($guid)
{
    if (!videopress_is_valid_guid($guid)) {
        return new WP_Error('bad-guid-format', __('Invalid Video GUID!', 'jetpack'));
    }
    $version = '1.1';
    $endpoint = sprintf('/videos/%1$s', $guid);
    $query_url = sprintf('https://public-api.wordpress.com/rest/v%1$s%2$s', $version, $endpoint);
    // Look for data in our transient. If nothing, let's make a new query.
    $data_from_cache = get_transient('jetpack_videopress_' . $guid);
    if (false === $data_from_cache) {
        $response = wp_remote_get(esc_url_raw($query_url));
        $data = json_decode(wp_remote_retrieve_body($response));
        // Cache the response for an hour.
        set_transient('jetpack_videopress_' . $guid, $data, HOUR_IN_SECONDS);
    } else {
        $data = $data_from_cache;
    }
    /**
     * Allow functions to modify fetched video details.
     *
     * This filter allows third-party code to modify the return data
     * about a given video.  It may involve swapping some data out or
     * adding new parameters.
     *
     * @since 4.0.0
     *
     * @param object $data The data returned by the WPCOM API. See: https://developer.wordpress.com/docs/api/1.1/get/videos/%24guid/
     * @param string $guid The GUID of the VideoPress video in question.
     */
    return apply_filters('videopress_get_video_details', $data, $guid);
}
开发者ID:automattic,项目名称:jetpack,代码行数:38,代码来源:utility-functions.php


示例11: wpl_instagram_response

/**
 * The API call
 */
function wpl_instagram_response($userid = null, $count = 6, $columns = 3)
{
    if (intval($userid) === 0) {
        return '<p>No user ID specified.</p>';
    }
    $transient_var = 'biw_' . $userid . '_' . $count;
    if (false === ($items = get_transient($transient_var))) {
        $response = wp_remote_get('https://api.instagram.com/v1/users/' . $userid . '/media/recent/?client_id=' . BIW_CLIENT_ID . '&count=' . esc_attr($count));
        $response_body = json_decode($response['body']);
        //echo '<pre>'; print_r( $response_body ); echo '</pre>';
        if ($response_body->meta->code !== 200) {
            return '<p>Incorrect user ID specified.</p>';
        }
        $items_as_objects = $response_body->data;
        $items = array();
        foreach ($items_as_objects as $item_object) {
            $item['link'] = $item_object->link;
            $item['src'] = $item_object->images->low_resolution->url;
            $items[] = $item;
        }
        set_transient($transient_var, $items, 60 * 60);
    }
    $output = '<ul class="photo-tiles large-block-grid-3 medium-block-grid-6 small-block-grid-3">';
    foreach ($items as $item) {
        $link = $item['link'];
        $image = $item['src'];
        $output .= '<li class="photo-tile"><a href="' . esc_url($link) . '"><img src="' . esc_url($image) . '" /></a></li>';
    }
    $output .= '</ul>';
    return $output;
}
开发者ID:craighays,项目名称:nsfhp,代码行数:34,代码来源:widget-instagram.php


示例12: wplms_update_message

 /**
  * Show Theme changes. Code adapted from W3 Total Cache.
  *
  * @return void
  */
 function wplms_update_message($args)
 {
     $transient_name = 'wplms_upgrade_notice_' . $args['Version'];
     if (false === ($upgrade_notice = get_transient($transient_name))) {
         $response = wp_remote_get('https://s3.amazonaws.com/WPLMS/readme.txt');
         if (!is_wp_error($response) && !empty($response['body'])) {
             // Output Upgrade Notice
             $matches = null;
             $regexp = '~==\\s*Upgrade Notice\\s*==\\s*=\\s*(.*)\\s*=(.*)(=\\s*' . preg_quote(WC_VERSION) . '\\s*=|$)~Uis';
             $upgrade_notice = '';
             if (preg_match($regexp, $response['body'], $matches)) {
                 $version = trim($matches[1]);
                 $notices = (array) preg_split('~[\\r\\n]+~', trim($matches[2]));
                 if (version_compare(WC_VERSION, $version, '<')) {
                     $upgrade_notice .= '<div class="wplms_plugin_upgrade_notice">';
                     foreach ($notices as $index => $line) {
                         $upgrade_notice .= wp_kses_post(preg_replace('~\\[([^\\]]*)\\]\\(([^\\)]*)\\)~', '<a href="${2}">${1}</a>', $line));
                     }
                     $upgrade_notice .= '</div> ';
                 }
             }
             set_transient($transient_name, $upgrade_notice, DAY_IN_SECONDS);
         }
     }
     echo wp_kses_post($upgrade_notice);
 }
开发者ID:emiisor,项目名称:diffhelper,代码行数:31,代码来源:wplms-install.php


示例13: prepare_items

 function prepare_items()
 {
     //First, lets decide how many records per page to show
     $per_page = 20;
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     //$this->process_bulk_action();
     global $wpdb;
     global $aio_wp_security;
     $logged_in_users = AIOWPSecurity_Utility::is_multisite_install() ? get_site_transient('users_online') : get_transient('users_online');
     if ($logged_in_users !== FALSE) {
         foreach ($logged_in_users as $key => $val) {
             $userdata = get_userdata($val['user_id']);
             $username = $userdata->user_login;
             $val['username'] = $username;
             $logged_in_users[$key] = $val;
         }
     } else {
         $logged_in_users = array();
         //If no transient found set to empty array
     }
     $data = $logged_in_users;
     $current_page = $this->get_pagenum();
     $total_items = count($data);
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     $this->items = $data;
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
开发者ID:bobz0r75,项目名称:budref,代码行数:30,代码来源:wp-security-list-logged-in-users.php


示例14: al_product_adder_admin_notices_styles

/**
 * Plugin compatibility checker
 *
 * Here current theme is checked for compatibility with WP PRODUCT ADDER.
 *
 * @version		1.1.2
 * @package		ecommerce-product-catalog/functions
 * @author 		Norbert Dreszer
 */
function al_product_adder_admin_notices_styles()
{
    if (current_user_can('activate_plugins')) {
        if (!is_advanced_mode_forced()) {
            $template = get_option('template');
            $integration_type = get_integration_type();
            if (!empty($_GET['hide_al_product_adder_support_check'])) {
                update_option('product_adder_theme_support_check', $template);
                return;
            }
            if (get_option('product_adder_theme_support_check') !== $template && current_user_can('delete_others_products')) {
                product_adder_theme_check_notice();
            }
        }
        if (is_ic_catalog_admin_page()) {
            $product_count = ic_products_count();
            if ($product_count > 5) {
                if (false === get_transient('implecode_hide_plugin_review_info')) {
                    implecode_plugin_review_notice();
                    set_transient('implecode_hide_plugin_translation_info', 1, WEEK_IN_SECONDS);
                } else {
                    if (false === get_transient('implecode_hide_plugin_translation_info') && !is_english_catalog_active()) {
                        implecode_plugin_translation_notice();
                    }
                }
            } else {
                if (false === get_transient('implecode_hide_plugin_review_info')) {
                    set_transient('implecode_hide_plugin_review_info', 1, WEEK_IN_SECONDS);
                }
            }
        }
    }
}
开发者ID:nanookYs,项目名称:orientreizen,代码行数:42,代码来源:theme-product_adder_support.php


示例15: fetch_feed

 function fetch_feed($username, $slice = 8)
 {
     $barcelona_remote_url = esc_url('http://instagram.com/' . trim(strtolower($username)));
     $barcelona_transient_key = 'barcelona_instagram_feed_' . sanitize_title_with_dashes($username);
     $slice = absint($slice);
     if (false === ($barcelona_result_data = get_transient($barcelona_transient_key))) {
         $barcelona_remote = wp_remote_get($barcelona_remote_url);
         if (is_wp_error($barcelona_remote) || 200 != wp_remote_retrieve_response_code($barcelona_remote)) {
             return new WP_Error('not-connected', esc_html__('Unable to communicate with Instagram.', 'barcelona'));
         }
         preg_match('#window\\.\\_sharedData\\s\\=\\s(.*?)\\;\\<\\/script\\>#', $barcelona_remote['body'], $barcelona_match);
         if (!empty($barcelona_match)) {
             $barcelona_data = json_decode(end($barcelona_match), true);
             if (is_array($barcelona_data) && isset($barcelona_data['entry_data']['ProfilePage'][0]['user']['media']['nodes'])) {
                 $barcelona_result_data = $barcelona_data['entry_data']['ProfilePage'][0]['user']['media']['nodes'];
             }
         }
         if (is_array($barcelona_result_data)) {
             set_transient($barcelona_transient_key, $barcelona_result_data, 60 * 60 * 2);
         }
     }
     if (empty($barcelona_result_data)) {
         return new WP_Error('no-images', esc_html__('Instagram did not return any images.', 'barcelona'));
     }
     return array_slice($barcelona_result_data, 0, $slice);
 }
开发者ID:yalmaa,项目名称:little-magazine,代码行数:26,代码来源:barcelona-instagram-feed.php


示例16: show_migrate_notice

 /**
  * Give the user options for how to handle their legacy Stream records
  *
  * @action admin_notices
  * @return void
  */
 public static function show_migrate_notice()
 {
     if (!isset($_GET['migrate_action']) && WP_Stream::is_connected() && WP_Stream_Admin::is_stream_screen() && !empty(self::$record_count) && false === get_transient(self::MIGRATE_DELAY_TRANSIENT)) {
         return true;
     }
     return false;
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:13,代码来源:class-wp-stream-migrate.php


示例17: get_photos

 /**
  * Returns an array of photos on a WP_Error.
  */
 private function get_photos($args = array())
 {
     $transient_key = md5('aquick-flickr-cache-' . print_r($args, true));
     $cached = get_transient($transient_key);
     if ($cached) {
         return $cached;
     }
     $username = isset($args['username']) ? $args['username'] : '';
     $tags = isset($args['tags']) ? $args['tags'] : '';
     $count = isset($args['count']) ? absint($args['count']) : 10;
     $query = array('tagmode' => 'any', 'tags' => $tags);
     // If username is an RSS feed
     if (preg_match('#^https?://api\\.flickr\\.com/services/feeds/photos_public\\.gne#', $username)) {
         $url = parse_url($username);
         $url_query = array();
         wp_parse_str($url['query'], $url_query);
         $query = array_merge($query, $url_query);
     } else {
         $user = $this->request('flickr.people.findByUsername', array('username' => $username));
         if (is_wp_error($user)) {
             return $user;
         }
         $user_id = $user->user->id;
         $query['id'] = $user_id;
     }
     $photos = $this->request_feed('photos_public', $query);
     if (!$photos) {
         return new WP_Error('error', __('Could not fetch photos.', AZ_THEME_NAME));
     }
     $photos = array_slice($photos, 0, $count);
     set_transient($transient_key, $photos, apply_filters('quick_flickr_widget_cache_timeout', 3600));
     return $photos;
 }
开发者ID:SIB-Colombia,项目名称:biodiversidad_wp,代码行数:36,代码来源:flickr-widget.php


示例18: ngfb_get_sharing_buttons

 function ngfb_get_sharing_buttons($ids = array(), $atts = array())
 {
     global $ngfb;
     if ($ngfb->is_avail['ssb']) {
         if ($ngfb->is_avail['cache']['transient']) {
             $cache_salt = __METHOD__ . '(lang:' . SucomUtil::get_locale() . '_url:' . $ngfb->util->get_sharing_url() . '_ids:' . implode('_', $ids) . '_atts:' . implode('_', $atts) . ')';
             $cache_id = $ngfb->cf['lca'] . '_' . md5($cache_salt);
             $cache_type = 'object cache';
             $ngfb->debug->log($cache_type . ': transient salt ' . $cache_salt);
             $html = get_transient($cache_id);
             if ($html !== false) {
                 $ngfb->debug->log($cache_type . ': html retrieved from transient ' . $cache_id);
                 return $ngfb->debug->get_html() . $html;
             }
         }
         $html = '<!-- ' . $ngfb->cf['lca'] . ' sharing buttons begin -->' . $ngfb->sharing->get_js('sharing-buttons-header', $ids) . $ngfb->sharing->get_html($ids, $atts) . $ngfb->sharing->get_js('sharing-buttons-footer', $ids) . '<!-- ' . $ngfb->cf['lca'] . ' sharing buttons end -->';
         if ($ngfb->is_avail['cache']['transient']) {
             set_transient($cache_id, $html, $ngfb->cache->object_expire);
             $ngfb->debug->log($cache_type . ': html saved to transient ' . $cache_id . ' (' . $ngfb->cache->object_expire . ' seconds)');
         }
     } else {
         $html = '<!-- ' . $ngfb->cf['lca'] . ' sharing sharing buttons disabled -->';
     }
     return $ngfb->debug->get_html() . $html;
 }
开发者ID:christocmp,项目名称:bingopaws,代码行数:25,代码来源:functions.php


示例19: sendWPRCRequestWithRetries

 /**
  * Send request to the WPRC server only with retries
  * 
  * @param string method
  * @param mixed arguments to send
  */
 public function sendWPRCRequestWithRetries($method, $args, $timeout = 5)
 {
     $url = WPRC_SERVER_URL;
     $send_result = false;
     $failed = 0;
     $timer = get_transient('wprc_report_failed_timer');
     if ($timer != false && $timer != '' && $timer != null) {
         $timer = intval($timer);
     } else {
         $timer = 0;
     }
     $timenow = time();
     if ($timer - $timenow > 0) {
         return false;
     }
     // discard report
     while ($send_result === false && $failed < 2) {
         $send_result = $this->sendRequest($method, $url, $args, $timeout);
         if ($send_result === false) {
             $failed++;
             if ($failed < 2) {
                 usleep(rand(100, 300));
             }
             // wait 1 to 3 seconds
         }
     }
     if ($send_result === false) {
         set_transient('wprc_report_failed_timer', time() + 5 * 60 * 60);
     } else {
         // reset flags
         set_transient('wprc_report_failed_timer', 0);
     }
     return $send_result;
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:40,代码来源:wprc-repository-connector.php


示例20: pre_http_request

 function pre_http_request($content, $r, $url)
 {
     $key = $this->getKey($url, $r);
     $this->r(sprintf('request transient key: %s<br />request url: %s,<br />request args: %s', $key, $url, print_r($r, true)), false, 'Request Details');
     // If caching isn't set, return.
     if (!$this->getCacheTime($r)) {
         $this->r('Not cached because the `cache` parameter is not set or cacheTime() method says no cache');
         return false;
     }
     $response = maybe_unserialize(get_transient($key));
     $this->flushCache($url, $r);
     if (strtoupper($r['method'] !== 'GET') || current_user_can('manage_options') && isset($_REQUEST['cache']) || !$response || is_wp_error($response) || $response && $response['response']['code'] !== 200) {
         if (strtoupper($r['method'] !== 'GET')) {
             // If something's been PUT or POSTed to the same endpoint, let's reset the cache for that.
             $this->r('not cached due to method not GET');
         } elseif (current_user_can('manage_options') && isset($_REQUEST['cache'])) {
             $this->r('not cached due to overrides');
         } elseif (!$response || is_wp_error($response)) {
             $this->r('not cached due to no response (or error response)');
             $this->r($response, false, '$response:');
         } else {
             $this->r(sprintf('not cached due to response code being %s', $response['response']['code']));
         }
         return false;
     }
     if ($this->debug) {
         $this->r($response, false, 'Response (Cached)');
     }
     return $response;
 }
开发者ID:kidaa30,项目名称:Constant-Contact-WordPress-Plugin,代码行数:30,代码来源:cache-http.php



注:本文中的get_transient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_translated_tempcode函数代码示例发布时间:2022-05-15
下一篇:
PHP get_trans_view_str函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap