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

PHP set_transient函数代码示例

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

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



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

示例1: 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


示例2: 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


示例3: smart_coupon_activate

/**
 * Database changes required for Smart Coupons
 *
 * Add option 'smart_coupon_email_subject' if not exists
 * Enable 'Auto Generation' for Store Credit (discount_type: 'smart_coupon') not having any customer_email
 * Disable 'apply_before_tax' for all Store Credit (discount_type: 'smart_coupon')
 */
function smart_coupon_activate()
{
    global $wpdb, $blog_id;
    if (is_multisite()) {
        $blog_ids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}", 0);
    } else {
        $blog_ids = array($blog_id);
    }
    if (!get_option('smart_coupon_email_subject')) {
        add_option('smart_coupon_email_subject');
    }
    foreach ($blog_ids as $blog_id) {
        if (file_exists(WP_PLUGIN_DIR . '/woocommerce/woocommerce.php') && is_plugin_active('woocommerce/woocommerce.php')) {
            $wpdb_obj = clone $wpdb;
            $wpdb->blogid = $blog_id;
            $wpdb->set_prefix($wpdb->base_prefix);
            $query = "SELECT postmeta.post_id FROM {$wpdb->prefix}postmeta as postmeta WHERE postmeta.meta_key = 'discount_type' AND postmeta.meta_value = 'smart_coupon' AND postmeta.post_id IN\n\t\t\t\t\t(SELECT p.post_id FROM {$wpdb->prefix}postmeta AS p WHERE p.meta_key = 'customer_email' AND p.meta_value = 'a:0:{}') ";
            $results = $wpdb->get_col($query);
            foreach ($results as $result) {
                update_post_meta($result, 'auto_generate_coupon', 'yes');
            }
            // To disable apply_before_tax option for Gift Certificates / Store Credit.
            $post_id_tax_query = "SELECT post_id FROM {$wpdb->prefix}postmeta WHERE meta_key = 'discount_type' AND meta_value = 'smart_coupon'";
            $tax_post_ids = $wpdb->get_col($post_id_tax_query);
            foreach ($tax_post_ids as $tax_post_id) {
                update_post_meta($tax_post_id, 'apply_before_tax', 'no');
            }
            $wpdb = clone $wpdb_obj;
        }
    }
    if (!is_network_admin() && !isset($_GET['activate-multi'])) {
        set_transient('_smart_coupons_activation_redirect', 1, 30);
    }
}
开发者ID:NerdyDillinger,项目名称:ovrride,代码行数:41,代码来源:woocommerce-smart-coupons.php


示例4: mm_ab_test_inclusion_none

function mm_ab_test_inclusion_none()
{
    if (is_admin() && false === get_transient('mm_test', false)) {
        $duration = WEEK_IN_SECONDS * 4;
        set_transient('mm_test', array('key' => 'none'), $duration);
    }
}
开发者ID:rmalina,项目名称:creativedisturbance,代码行数:7,代码来源:tests.php


示例5: edd_create_protection_files

/**
 * Creates blank index.php and .htaccess files
 *
 * This function runs approximately once per month in order to ensure all folders
 * have their necessary protection files
 *
 * @since 1.1.5
 *
 * @param bool $force
 * @param bool $method
 */
function edd_create_protection_files($force = false, $method = false)
{
    if (false === get_transient('edd_check_protection_files') || $force) {
        $upload_path = edd_get_upload_dir();
        // Make sure the /edd folder is created
        wp_mkdir_p($upload_path);
        // Top level .htaccess file
        $rules = edd_get_htaccess_rules($method);
        if (edd_htaccess_exists()) {
            $contents = @file_get_contents($upload_path . '/.htaccess');
            if ($contents !== $rules || !$contents) {
                // Update the .htaccess rules if they don't match
                @file_put_contents($upload_path . '/.htaccess', $rules);
            }
        } elseif (wp_is_writable($upload_path)) {
            // Create the file if it doesn't exist
            @file_put_contents($upload_path . '/.htaccess', $rules);
        }
        // Top level blank index.php
        if (!file_exists($upload_path . '/index.php') && wp_is_writable($upload_path)) {
            @file_put_contents($upload_path . '/index.php', '<?php' . PHP_EOL . '// Silence is golden.');
        }
        // Now place index.php files in all sub folders
        $folders = edd_scan_folders($upload_path);
        foreach ($folders as $folder) {
            // Create index.php, if it doesn't exist
            if (!file_exists($folder . 'index.php') && wp_is_writable($folder)) {
                @file_put_contents($folder . 'index.php', '<?php' . PHP_EOL . '// Silence is golden.');
            }
        }
        // Check for the files once per day
        set_transient('edd_check_protection_files', true, 3600 * 24);
    }
}
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:45,代码来源:upload-functions.php


示例6: mashsb_install

/**
 * Install
 *
 * Runs on plugin install to populates the settings fields for those plugin
 * pages. After successful install, the user is redirected to the MASHSB Welcome
 * screen.
 *
 * @since 2.0
 * @global $wpdb
 * @global $mashsb_options
 * @global $wp_version
 * @return void
 */
function mashsb_install()
{
    global $wpdb, $mashsb_options, $wp_version;
    // Add Upgraded From Option
    $current_version = get_option('mashsb_version');
    if ($current_version) {
        update_option('mashsb_version_upgraded_from', $current_version);
    }
    // Update the current version
    update_option('mashsb_version', MASHSB_VERSION);
    // Add plugin installation date and variable for rating div
    add_option('mashsb_installDate', date('Y-m-d h:i:s'));
    add_option('mashsb_RatingDiv', 'no');
    if (!get_option('mashsb_update_notice')) {
        add_option('mashsb_update_notice', 'no');
    }
    /* Setup some default options
     * Store our initial social networks in separate option row.
     * For easier modification and to prevent some trouble
     */
    $networks = array('Facebook', 'Twitter', 'Subscribe');
    if (is_plugin_inactive('mashshare-networks/mashshare-networks.php')) {
        update_option('mashsb_networks', $networks);
    }
    // Bail if activating from network, or bulk
    if (is_network_admin() || isset($_GET['activate-multi'])) {
        return;
    }
    // Add the transient to redirect / not for multisites
    set_transient('_mashsb_activation_redirect', true, 30);
}
开发者ID:Nguyenkain,项目名称:Elearning,代码行数:44,代码来源:install.php


示例7: 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


示例8: bbconnect_create_search_post

function bbconnect_create_search_post()
{
    // RUN A SECURITY CHECK
    if (!wp_verify_nonce($_POST['bbconnect_report_nonce'], 'bbconnect-report-nonce')) {
        die('terribly sorry.');
    }
    global $current_user;
    if (!empty($_POST)) {
        $post = array('post_content' => serialize($_POST['data']['search']), 'post_title' => $_POST['data']['postTitle'], 'post_status' => 'publish', 'post_type' => 'savedsearch', 'post_author' => $current_user->ID);
        $wp_error = wp_insert_post($post, $wp_error);
        if (!is_array($wp_error)) {
            add_post_meta($wp_error, 'private', $_POST['data']['privateV']);
            add_post_meta($wp_error, 'segment', $_POST['data']['segment']);
            add_post_meta($wp_error, 'category', $_POST['data']['category']);
            if (false === $recently_saved) {
                $recently_saved = array();
            }
            set_transient('bbconnect_' . $current_user->ID . '_last_saved', $wp_error, 3600);
            echo '<div class="updated update-nag"  style="width:95%; border-left: 4px solid #7ad03a;"><p>Search has been saved as <a href="/post.php?post=' . $wp_error . '&action=edit">savedsearch-' . $wp_error . '</a></p></div>' . "\n";
        } else {
            echo '<div class="updated"><p>Search has not been saved' . var_dump($wp_error) . '</a></p></div>' . "\n";
        }
    }
    die;
}
开发者ID:whatthefork,项目名称:bbconnect,代码行数:25,代码来源:bbconnect-savedsearch-modal.php


示例9: 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


示例10: add_notice

 /**
  * @see wm_add_notice
  */
 public static function add_notice($message, $type = 'info', $title = null, $backtrace = false)
 {
     $message = rtrim(ucfirst(trim((string) $message)), '.') . '.';
     $content = wpautop($title ? "<strong class=\"wm-notice-title\">{$title}</strong><br />{$message}" : $message);
     if (false !== $backtrace) {
         if (is_array($backtrace)) {
             $content .= self::get_backtrace($backtrace);
         } else {
             if ($stack = array_slice(debug_backtrace(), 2)) {
                 if (true === $backtrace) {
                     $content .= "<ol start=\"0\" class=\"wm-notice-backtrace\">";
                     foreach ($stack as $i => $backtrace) {
                         $content .= "<li>" . self::get_backtrace($backtrace) . "</li>";
                     }
                     $content .= "</ol>";
                 } else {
                     if (isset($stack[$backtrace])) {
                         $content .= self::get_backtrace($stack[$backtrace]);
                     }
                 }
             }
         }
     }
     self::$notices[] = "<div class=\"wm-notice notice {$type}\">{$content}</div>";
     // Cache alerts until they're shown
     set_transient('wm_notices', self::$notices);
 }
开发者ID:WebMaestroFr,项目名称:wm-notices,代码行数:30,代码来源:plugin.php


示例11: affiliate_wp_install

function affiliate_wp_install()
{
    // Create affiliate caps
    $roles = new Affiliate_WP_Capabilities();
    $roles->add_caps();
    $affiliate_wp_install = new stdClass();
    $affiliate_wp_install->affiliates = new Affiliate_WP_DB_Affiliates();
    $affiliate_wp_install->affiliate_meta = new Affiliate_WP_Affiliate_Meta_DB();
    $affiliate_wp_install->referrals = new Affiliate_WP_Referrals_DB();
    $affiliate_wp_install->visits = new Affiliate_WP_Visits_DB();
    $affiliate_wp_install->creatives = new Affiliate_WP_Creatives_DB();
    $affiliate_wp_install->settings = new Affiliate_WP_Settings();
    $affiliate_wp_install->affiliates->create_table();
    $affiliate_wp_install->affiliate_meta->create_table();
    $affiliate_wp_install->referrals->create_table();
    $affiliate_wp_install->visits->create_table();
    $affiliate_wp_install->creatives->create_table();
    if (!get_option('affwp_is_installed')) {
        $affiliate_area = wp_insert_post(array('post_title' => __('Affiliate Area', 'affiliate-wp'), 'post_content' => '[affiliate_area]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed'));
        $options = $affiliate_wp_install->settings->get_all();
        $options['affiliates_page'] = $affiliate_area;
        update_option('affwp_settings', $options);
    }
    update_option('affwp_is_installed', '1');
    update_option('affwp_version', AFFILIATEWP_VERSION);
    // Clear rewrite rules
    flush_rewrite_rules();
    // Bail if activating from network, or bulk
    if (is_network_admin() || isset($_GET['activate-multi'])) {
        return;
    }
    // Add the transient to redirect
    set_transient('_affwp_activation_redirect', true, 30);
}
开发者ID:jwondrusch,项目名称:AffiliateWP,代码行数:34,代码来源:install.php


示例12: 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


示例13: x_demo_content_set_stage_completed

function x_demo_content_set_stage_completed($stage)
{
    $transient = get_transient('x_demo_content_stage');
    $stages = is_array($transient) ? $transient : array();
    $stages[$stage] = true;
    set_transient('x_demo_content_stage', $stages);
}
开发者ID:ju4nr3v0l,项目名称:juandavidmarulanda.com,代码行数:7,代码来源:ajax-handler.php


示例14: 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


示例15: cp

 /**
  * s2Member's PayPal IPN handler (inner processing routine).
  *
  * @package s2Member\PayPal
  * @since 110720
  *
  * @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
  * @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
  */
 public static function cp($vars = array())
 {
     extract($vars, EXTR_OVERWRITE | EXTR_REFS);
     // Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
     if (!empty($paypal["txn_type"]) && preg_match("/^virtual_terminal\$/i", $paypal["txn_type"])) {
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_notify_before_virtual_terminal", get_defined_vars());
         unset($__refs, $__v);
         if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `virtual_terminal` ).";
             $processing = $during = true;
             // Yes, we ARE processing this.
             $paypal["s2member_log"][] = "The `txn_type` does not require any action on the part of s2Member.";
             foreach (array_keys(get_defined_vars()) as $__v) {
                 $__refs[$__v] =& ${$__v};
             }
             do_action("ws_plugin__s2member_during_paypal_notify_during_virtual_terminal", get_defined_vars());
             unset($__refs, $__v);
         } else {
             $paypal["s2member_log"][] = "Not processing. Duplicate IPN.";
             $paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `virtual_terminal` ).";
             $paypal["s2member_log"][] = "Duplicate IPN. Already processed. This IPN will be ignored.";
         }
         foreach (array_keys(get_defined_vars()) as $__v) {
             $__refs[$__v] =& ${$__v};
         }
         do_action("ws_plugin__s2member_during_paypal_notify_after_virtual_terminal", get_defined_vars());
         unset($__refs, $__v);
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_virtual_terminal", $paypal, get_defined_vars());
     } else {
         return apply_filters("c_ws_plugin__s2member_paypal_notify_in_virtual_terminal", false, get_defined_vars());
     }
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:44,代码来源:paypal-notify-in-virtual-terminal.inc.php


示例16: 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


示例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: 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


示例19: __construct

 public function __construct()
 {
     $this->init_settings();
     if (isset($this->settings['storage_type'])) {
         $this->storage_type = $this->settings['storage_type'];
     }
     $this->storage = new WOOF_STORAGE($this->storage_type);
     //+++
     if (!defined('DOING_AJAX')) {
         global $wp_query;
         if (isset($wp_query->query_vars['taxonomy']) and in_array($wp_query->query_vars['taxonomy'], get_object_taxonomies('product'))) {
             //unset($_SESSION['woof_really_current_term']);
             $this->set_really_current_term();
         }
     }
     //+++
     global $wpdb;
     $attribute_taxonomies = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "woocommerce_attribute_taxonomies");
     set_transient('wc_attribute_taxonomies', $attribute_taxonomies);
     if (!empty($attribute_taxonomies) and is_array($attribute_taxonomies)) {
         foreach ($attribute_taxonomies as $att) {
             //fixing for woo >= 2.3.2
             add_filter("woocommerce_taxonomy_args_pa_{$att->attribute_name}", array($this, 'change_woo_att_data'));
         }
     }
     //add_filter("woocommerce_taxonomy_args_pa_color", array($this, 'change_woo_att_data'));
     //add_action('init', array($this, 'price_filter_init'));
     add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
     add_action('widgets_init', array($this, 'widgets_init'));
 }
开发者ID:donpapa26,项目名称:bakancslistad,代码行数:30,代码来源:index.php


示例20: 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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP set_upgrade_progress函数代码示例发布时间:2022-05-15
下一篇:
PHP set_tracked_topics函数代码示例发布时间: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