当前位置: 首页>>代码示例>>PHP>>正文


PHP is_preview函数代码示例

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


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

示例1: tally_term_counts

 public static function tally_term_counts(&$terms, $taxonomy, $args = array())
 {
     global $wpdb, $pp_current_user;
     if (!$terms) {
         return;
     }
     $defaults = array('pad_counts' => true, 'post_type' => '', 'required_operation' => '');
     $args = array_merge($defaults, (array) $args);
     extract($args);
     $term_items = array();
     if ($terms) {
         if (!is_object(reset($terms))) {
             return $terms;
         }
         foreach ((array) $terms as $key => $term) {
             $terms_by_id[$term->term_id] =& $terms[$key];
             $term_ids[$term->term_taxonomy_id] = $term->term_id;
         }
     }
     // Get the object and term ids and stick them in a lookup table
     $tax_obj = get_taxonomy($taxonomy);
     $object_types = $post_type ? (array) $post_type : (array) esc_sql($tax_obj->object_type);
     if (pp_unfiltered()) {
         $stati = get_post_stati(array('public' => true, 'private' => true), 'names', 'or');
         $type_status_clause = "AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status IN ('" . implode("', '", $stati) . "')";
     } else {
         global $query_interceptor;
         $type_status_clause = $query_interceptor->get_posts_where(array('post_types' => $object_types, 'required_operation' => $required_operation));
         // need to apply term restrictions in case post is restricted by another taxonomy
     }
     if (!$required_operation) {
         $required_operation = pp_is_front() && !is_preview() ? 'read' : 'edit';
     }
     $results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM {$wpdb->term_relationships} INNER JOIN {$wpdb->posts} ON object_id = ID WHERE term_taxonomy_id IN ('" . implode("','", array_keys($term_ids)) . "') {$type_status_clause}");
     foreach ($results as $row) {
         $id = $term_ids[$row->term_taxonomy_id];
         $term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1;
     }
     // Touch every ancestor's lookup row for each post in each term
     foreach ($term_ids as $term_id) {
         $child = $term_id;
         while (!empty($terms_by_id[$child]) && ($parent = $terms_by_id[$child]->parent)) {
             if (!empty($term_items[$term_id])) {
                 foreach ($term_items[$term_id] as $item_id => $touches) {
                     $term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id] : 1;
                 }
             }
             $child = $parent;
         }
     }
     foreach (array_keys($terms_by_id) as $key) {
         $terms_by_id[$key]->count = 0;
     }
     // Transfer the touched cells
     foreach ((array) $term_items as $id => $items) {
         if (isset($terms_by_id[$id])) {
             $terms_by_id[$id]->count = count($items);
         }
     }
 }
开发者ID:estrategasdigitales,项目名称:glummer,代码行数:60,代码来源:terms-query-lib_pp.php

示例2: getShortlink

 /**
  * Return a shortlink for a post, page, attachment, or blog.
  * 
  * @since 1.0.0
  */
 public function getShortlink($shortlink, $id, $context, $allow_slugs)
 {
     if (ot_get_option('bitly_service_active') == 'no') {
         return false;
     }
     if (is_singular() && is_preview()) {
         return false;
     }
     global $wp_query;
     $post_id = '';
     if ('query' == $context && is_singular()) {
         $post_id = $wp_query->get_queried_object_id();
     } else {
         if ('post' == $context) {
             $post = get_post($id);
             $post_id = $post->ID;
         }
     }
     if ($shortlink = get_metadata('post', $post_id, '_bitly_shortlink', true)) {
         return $shortlink;
     }
     if (is_front_page() && !is_paged()) {
         return apply_filters('bitly_front_page', false);
     }
     $url = get_permalink($post_id);
     $domain = ot_get_option('bitly_domain');
     $this->login(ot_get_option('bitly_login'));
     $this->apiKey(ot_get_option('bitly_api_key'));
     $shortlink = $this->shorten($url, $domain);
     if (!empty($shortlink)) {
         update_metadata('post', $post_id, '_bitly_shortlink', $shortlink);
         return $shortlink;
     }
     return false;
 }
开发者ID:dayax,项目名称:doyo,代码行数:40,代码来源:BitlyService.php

示例3: cached_result

function cached_result($cache_key, $cache_group, $fn = null)
{
    if (is_null($fn)) {
        $fn = $cache_group;
        $cache_group = '';
        $namespaced = [];
    }
    if ($cache_group) {
        $namespaced = wp_cache_get($cache_group, 'cache_namespaces');
        if ($namespaced === false) {
            wp_cache_set($cache_group, $namespaced = [], CACHE_NAMESPACES);
        }
    }
    if (!is_preview() && in_array($cache_key, $namespaced) && ($result = wp_cache_get($cache_key, $cache_group))) {
        return $result;
    }
    $result = call_user_func($fn);
    if (!is_preview()) {
        wp_cache_set($cache_key, $result, $cache_group);
        if ($cache_group) {
            wp_cache_set($cache_group, $namespaced + [$cache_key], CACHE_NAMESPACES);
        }
    }
    return $result;
}
开发者ID:edygar,项目名称:wp-extensions,代码行数:25,代码来源:cache.php

示例4: rocket_cdn_enqueue

function rocket_cdn_enqueue($src)
{
    // Don't use CDN if in admin, in login page, in register page or in a post preview
    if (is_admin() || is_preview() || in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) {
        return $src;
    }
    $src = set_url_scheme($src);
    $zone = array('all', 'css_and_js');
    // Add only CSS zone
    if (current_filter() == 'style_loader_src') {
        $zone[] = 'css';
    }
    // Add only JS zone
    if (current_filter() == 'script_loader_src') {
        $zone[] = 'js';
    }
    if ($cnames = get_rocket_cdn_cnames($zone)) {
        list($src_host, $src_path) = get_rocket_parse_url($src);
        // Check if the link isn't external
        if ($src_host == parse_url(home_url(), PHP_URL_HOST) && trim($src_path, '/') != '') {
            $src = get_rocket_cdn_url($src, $zone);
        }
    }
    return $src;
}
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:25,代码来源:cdn.php

示例5: fw_get_db_post_option

/**
 * Get post option value from the database
 *
 * @param null|int $post_id
 * @param string|null $option_id Specific option id (accepts multikey). null - all options
 * @param null|mixed $default_value If no option found in the database, this value will be returned
 * @param null|bool $get_original_value Original value is that with no translations and other changes
 *
 * @return mixed|null
 */
function fw_get_db_post_option($post_id = null, $option_id = null, $default_value = null, $get_original_value = null)
{
    if (!$post_id) {
        /** @var WP_Post $post */
        global $post;
        if (!$post) {
            return $default_value;
        } else {
            $post_id = $post->ID;
        }
        /**
         * Check if is Preview and use the preview post_id instead of real/current post id
         *
         * Note: WordPress changes the global $post content on preview:
         * 1. https://github.com/WordPress/WordPress/blob/2096b451c704715db3c4faf699a1184260deade9/wp-includes/query.php#L3573-L3583
         * 2. https://github.com/WordPress/WordPress/blob/4a31dd6fe8b774d56f901a29e72dcf9523e9ce85/wp-includes/revision.php#L485-L528
         */
        if (is_preview()) {
            $preview = wp_get_post_autosave($post->ID);
            if (is_object($preview)) {
                $post_id = $preview->ID;
            }
        }
    }
    $option_id = 'fw_options' . ($option_id !== null ? '/' . $option_id : '');
    return FW_WP_Meta::get('post', $post_id, $option_id, $default_value, $get_original_value);
}
开发者ID:vonsuu,项目名称:Unyson,代码行数:37,代码来源:database.php

示例6: storikaze_tag_at

 function storikaze_tag_at($atts, $content = null)
 {
     $timecode = strtotime($GLOBALS["storikaze_time_now"]);
     // Of course, if the page is being displayed in preview mode,
     // we want anything to show up. (This part of code may change
     // if there is a way to have a preview with a particular
     // point in time specified.)
     if (is_preview()) {
         return do_shortcode($content);
     }
     foreach ($atts as $thenom => $theval) {
         if ($thenom == "from") {
             if ($timecode < strtotime($theval)) {
                 return "";
             }
         }
         // The "to" attribute specifies a time at which the text
         // disappears (such as the "story still in progress" note
         // at the end of the TOC -- but only once you know at what
         // time the very last installation of the story will be
         // added).
         if ($thenom == "to") {
             if ($timecode > strtotime($theval)) {
                 return "";
             }
         }
     }
     return do_shortcode($content);
 }
开发者ID:sophiaphillyqueen,项目名称:storikaze-wp-plugin-postmortem,代码行数:29,代码来源:meatofit.php

示例7: kill_frame

/**
 * kill_frame()
 *
 * @return void
 **/
function kill_frame()
{
    if (is_preview()) {
        return;
    }
    $home_url = strtolower(get_option('home'));
    echo <<<EOS

<script type="text/javascript">
<!--
try {
\tvar parent_location = new String(parent.location);
\tvar top_location = new String(top.location);
\tvar cur_location = new String(document.location);
\tparent_location = parent_location.toLowerCase();
\ttop_location = top_location.toLowerCase();
\tcur_location = cur_location.toLowerCase();

\tif ( top_location != cur_location && parent_location.indexOf('{$home_url}') != 0 )
\t\ttop.location.href = document.location.href;
} catch ( err ) {
\ttop.location.href = document.location.href;
}
//-->
</script>

EOS;
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:33,代码来源:sem-frame-buster.php

示例8: is_exit

function is_exit()
{
    if (is_admin() || is_feed() || is_preview() || 1 === intval(get_query_var('print')) || 1 === intval(get_query_var('printpage')) || false !== strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini')) {
        return true;
    }
    return false;
}
开发者ID:vralle,项目名称:VRALLE.lazyload,代码行数:7,代码来源:vr-lazyload.php

示例9: ucc_include_custom_post_types

function ucc_include_custom_post_types($query)
{
    global $wp_query;
    /* Don't break admin or preview pages. This is also a good place to exclude feed with !is_feed() if desired. */
    if (!is_preview() && !is_admin() && !is_singular()) {
        $args = array('public' => true, '_builtin' => false);
        $output = 'names';
        $operator = 'and';
        $post_types = get_post_types($args, $output, $operator);
        /* Add 'link' and/or 'page' to array() if you want these included:
         * array( 'post' , 'link' , 'page' ), etc.
         */
        $post_types = array_merge($post_types, array('post'));
        if ($query->is_feed) {
            /* Do feed processing here if you did not exclude it previously. This if/else
             * is not necessary if you want custom post types included in your feed.
             */
        } else {
            $my_post_type = get_query_var('post_type');
            if (empty($my_post_type)) {
                $query->set('post_type', $post_types);
            }
        }
    }
    return $query;
}
开发者ID:rigelstpierre,项目名称:Everlovin-Press,代码行数:26,代码来源:post_types.php

示例10: tc_parse_imgs

      /**
      * hook : the_content
      * Inspired from Unveil Lazy Load plugin : https://wordpress.org/plugins/unveil-lazy-load/ by @marubon
      *
      * @return string
      * @package Customizr
      * @since Customizr 3.3.0
      */
      function tc_parse_imgs( $_html ) {
        if( is_feed() || is_preview() || ( wp_is_mobile() && apply_filters('tc_disable_img_smart_load_mobiles', false ) ) )
          return $_html;

        if ( strpos( $_html, 'data-src' ) !== false )
          return $_html;

        return preg_replace_callback('#<img([^>]+?)src=[\'"]?([^\'"\s>]+)[\'"]?([^>]*)>#', array( $this , 'tc_regex_callback' ) , $_html);
      }
开发者ID:niamherinoc,项目名称:rctractors,代码行数:17,代码来源:class-fire-utils.php

示例11: tc_parse_imgs

 /**
  * hook : the_content
  * @return string
  * @package Customizr
  * @since Customizr 3.3.0
  */
 function tc_parse_imgs($_html)
 {
     if (is_feed() || is_preview() || wp_is_mobile()) {
         return $_html;
     }
     if (strpos($_html, 'data-src') !== false) {
         return $_html;
     }
     return preg_replace_callback('#<img([^>]+?)src=[\'"]?([^\'"\\s>]+)[\'"]?([^>]*)>#', array($this, 'tc_regex_callback'), $_html);
 }
开发者ID:lokenxo,项目名称:familygenerator,代码行数:16,代码来源:class-fire-utils.php

示例12: add_dummy_image

 function add_dummy_image($content)
 {
     if (is_feed() || is_preview() || $this->is_smartphone()) {
         return $content;
     }
     if (strpos($content, 'data-src') !== false) {
         return $content;
     }
     $content = preg_replace_callback('#<img([^>]+?)src=[\'"]?([^\'"\\s>]+)[\'"]?([^>]*)>#', array($this, 'replace_callback'), $content);
     return $content;
 }
开发者ID:bergvogel,项目名称:stayuplate,代码行数:11,代码来源:unveil-lazy-load.php

示例13: widget

 /**
  * Outputs the content of the widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     if (!is_preview()) {
         echo $args['before_widget'];
         if (!empty($instance['title'])) {
             echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
         }
         echo '<div class="tm-ads-widget">';
         echo $instance['ads_code'];
         echo '</div>';
         echo $args['after_widget'];
     }
 }
开发者ID:kkthemes,项目名称:bench-wordpress-theme,代码行数:19,代码来源:ads.php

示例14: rocket_lazyload_images

function rocket_lazyload_images($html)
{
    // Don't LazyLoad if the thumbnail is in admin, a feed or a post preview
    if (is_admin() || is_feed() || is_preview() || empty($html)) {
        return $html;
    }
    // You can stop the LalyLoad process with a hook
    if (!apply_filters('do_rocket_lazyload', true)) {
        return $html;
    }
    $html = preg_replace_callback('#<img([^>]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', '__rocket_lazyload_replace_callback', $html);
    return $html;
}
开发者ID:StudentLifeMarketingAndDesign,项目名称:krui-wp,代码行数:13,代码来源:rocket-lazy-load.php

示例15: _pp_flt_administrator_pad_term_counts

function _pp_flt_administrator_pad_term_counts($terms, $taxonomies, $args)
{
    if (!defined('XMLRPC_REQUEST') && 'all' == $args['fields'] && empty($args['pp_no_filter'])) {
        global $pagenow;
        if (!is_admin() || !in_array($pagenow, array('post.php', 'post-new.php'))) {
            require_once PPC_ABSPATH . '/terms-query-lib_pp.php';
            // pp_tally_term_counts() is PP equivalent to WP _pad_term_counts()
            $args['required_operation'] = pp_is_front() && !is_preview() ? 'read' : 'edit';
            PP_TermsQueryLib::tally_term_counts($terms, reset($taxonomies), $args);
        }
    }
    return $terms;
}
开发者ID:severnrescue,项目名称:web,代码行数:13,代码来源:terms-interceptor-administrator_pp.php


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