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


PHP wp_cache_post_change函数代码示例

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


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

示例1: comment_edited

 public static function comment_edited($commentID = 0, $postID = 0)
 {
     //Clear the comment cache
     if (function_exists('clean_comment_cache')) {
         clean_comment_cache($commentID);
     }
     //For WP Cache and WP Super Cache
     if (function_exists('wp_cache_post_change')) {
         @wp_cache_post_change($postID);
     }
     //Get out if user is admin or post owner
     if (AECCore::is_comment_owner($postID)) {
         return;
     }
     //Increment the number of edited comments
     AECCore::increment_edit_count();
 }
开发者ID:EfncoPlugins,项目名称:ajax-edit-comments,代码行数:17,代码来源:class.actions.php

示例2: flush

 /**
  * Clear something from the cache.
  *
  * @synopsis [--post_id=<post-id>] [--permalink=<permalink>]
  */
 function flush($args = array(), $assoc_args = array())
 {
     if (isset($assoc_args['post_id'])) {
         if (is_numeric($assoc_args['post_id'])) {
             wp_cache_post_change($assoc_args['post_id']);
         } else {
             WP_CLI::error('This is not a valid post id.');
         }
         wp_cache_post_change($assoc_args['post_id']);
     } elseif (isset($assoc_args['permalink'])) {
         $id = url_to_postid($assoc_args['permalink']);
         if (is_numeric($id)) {
             wp_cache_post_change($id);
         } else {
             WP_CLI::error('There is no post with this permalink.');
         }
     } else {
         global $file_prefix;
         wp_cache_clean_cache($file_prefix, true);
         WP_CLI::success('Cache cleared.');
     }
 }
开发者ID:joelw,项目名称:wp-super-cache-cli,代码行数:27,代码来源:cli.php

示例3: flush

 /**
  * Clear something from the cache
  *
  * @param array $args
  * @param array $vars
  */
 function flush($args = array(), $vars = array())
 {
     if (function_exists('wp_cache_clear_cache')) {
         if (isset($vars['post_id'])) {
             if (is_numeric($vars['post_id'])) {
                 wp_cache_post_change($vars['post_id']);
             } else {
                 WP_CLI::error('This is not a valid post id.');
             }
             wp_cache_post_change($vars['post_id']);
         } elseif (isset($vars['permalink'])) {
             $id = url_to_postid($vars['permalink']);
             if (is_numeric($id)) {
                 wp_cache_post_change($id);
             } else {
                 WP_CLI::error('There is no post with this permalink.');
             }
         } else {
             wp_cache_clear_cache();
         }
     } else {
         WP_CLI::error('The WP Super Cache could not be found, is it installed?');
     }
 }
开发者ID:bytewang,项目名称:wp-cli,代码行数:30,代码来源:wp-super-cache.php

示例4: clear_post_cache

 /**
  * Tell caching plugins to clear their caches related to a post
  *
  * @static
  * @param int $post_id
  */
 public static function clear_post_cache($post_id)
 {
     if (function_exists('wp_cache_post_change')) {
         // WP Super Cache
         $GLOBALS['super_cache_enabled'] = 1;
         wp_cache_post_change($post_id);
     } elseif (function_exists('w3tc_pgcache_flush_post')) {
         // W3 Total Cache
         w3tc_pgcache_flush_post($post_id);
     }
 }
开发者ID:EfncoPlugins,项目名称:sprout-invoices,代码行数:17,代码来源:_Controller.php

示例5: dslc_ajax_save_draft_composer

/**
 * Save composer code
 *
 * @since 1.2.4
 */
function dslc_ajax_save_draft_composer($atts)
{
    // Allowed to do this?
    if (is_user_logged_in() && current_user_can(DS_LIVE_COMPOSER_CAPABILITY_SAVE)) {
        // The array we'll pass back to the AJAX call
        $response = array();
        // The composer code
        $composer_code = $_POST['dslc_code'];
        // The ID of the post/page
        $post_id = $_POST['dslc_post_id'];
        // Add/update the post/page with the composer code
        if (update_post_meta($post_id, 'dslc_code_draft', $composer_code)) {
            $response['status'] = 'success';
        } else {
            $response['status'] = 'failed';
        }
        // Encode response
        $response_json = json_encode($response);
        // Send the response
        header("Content-Type: application/json");
        echo $response_json;
        // Refresh cache
        if (function_exists('wp_cache_post_change')) {
            $GLOBALS['super_cache_enabled'] = 1;
            wp_cache_post_change($post_id);
        }
        // Au revoir
        exit;
    }
}
开发者ID:bibiangel1989,项目名称:vespatour,代码行数:35,代码来源:ajax.php

示例6: Discourse

<?php

// this script can be used to synchronize posts to Discourse
// there appears to be bugs in publish_future_post
// see: http://wordpress.org/support/topic/is-publish_future_post-hook-still-present-working
require_once "../wp-load.php";
$discourse = new Discourse();
$args = array('numberposts' => '3', 'orderby' => 'date', 'post_type' => array('post'));
$last_posts = get_posts($args);
foreach ($last_posts as $post) {
    setup_postdata($post);
    $link = get_post_meta($post->ID, 'discourse_permalink', true);
    if (!$link) {
        $pub = get_post_meta($post->ID, 'publish_to_discourse', true);
        if ($pub) {
            $discourse::sync_to_discourse($post->ID, $post->post_title, $post->post_content);
            wp_cache_post_change($post->ID);
        }
    }
}
开发者ID:ZerGabriel,项目名称:wp-discourse,代码行数:20,代码来源:sync.php

示例7: wp_cache_get_postid_from_comment

function wp_cache_get_postid_from_comment($comment_id)
{
    $comment = get_commentdata($comment_id, 1, true);
    $postid = $comment['comment_post_ID'];
    // We must check it up again due to WP bugs calling two different actions
    // for delete, for example both wp_set_comment_status and delete_comment
    // are called whene deleting a comment
    if ($postid > 0) {
        return wp_cache_post_change($postid);
    } else {
        return wp_cache_post_change(wp_cache_post_id());
    }
}
开发者ID:sajidsan,项目名称:sajidsan.github.io,代码行数:13,代码来源:wp-cache-phase2.php

示例8: ajax

    function ajax()
    {
        $award_id = intval($_POST['award_id']);
        $award = get_post($award_id);
        if (is_null($award) || $award->post_type != $this->get_post_type_name()) {
            die;
        }
        $admin_email = get_settings('admin_email');
        header('Content-Type: text/html');
        # Only actions are valid on awards that haven't been accepted or
        # rejected yet
        $award_status = get_post_meta($award_id, 'wpbadger-award-status', true);
        if ($award_status != 'Awarded') {
            ?>
            <div class="wpbadger-award-error">
                <p>This award has already been claimed.</p>
                <p>If you believe this was done in error, please contact the 
                <a href="mailto:<?php 
            esc_attr_e($admin_email);
            ?>
">site administrator</a>.</p>
            </div>
            <?php 
            die;
        }
        switch ($_POST['award_action']) {
            case 'accept':
                update_post_meta($award_id, 'wpbadger-award-status', 'Accepted');
                // If WP Super Cache Plugin installed, delete cache files for award post
                if (function_exists('wp_cache_post_change')) {
                    wp_cache_post_change($award_id);
                }
                ?>
            <div class="wpbadger-award-updated">
                <p>You have successfully accepted to add your award to your backpack.</p>
            </div>
            <?php 
                break;
            case 'reject':
                update_post_meta($award_id, 'wpbadger-award-status', 'Rejected');
                // If WP Super Cache Plugin installed, delete cache files for award post
                if (function_exists('wp_cache_post_change')) {
                    wp_cache_post_change($award_id);
                }
                ?>
            <div class="wpbadger-award-updated">
                <p>You have successfully declined to add your award to your backpack.</p>
            </div>
            <?php 
                break;
        }
        die;
    }
开发者ID:R4N3,项目名称:WPBadger,代码行数:53,代码来源:awards.php

示例9: wp_cache_get_postid_from_comment

function wp_cache_get_postid_from_comment($comment_id)
{
    $comment = get_commentdata($comment_id, 1, true);
    $postid = $comment['comment_post_ID'];
    // Do nothing if comment is not moderated
    // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world
    if (!preg_match('/wp-admin\\//', $_SERVER['REQUEST_URI']) && $comment['comment_approved'] != 1) {
        return $post_id;
    }
    // We must check it up again due to WP bugs calling two different actions
    // for delete, for example both wp_set_comment_status and delete_comment
    // are called when deleting a comment
    if ($postid > 0) {
        return wp_cache_post_change($postid);
    } else {
        return wp_cache_post_change(wp_cache_post_id());
    }
}
开发者ID:ryan-allen,项目名称:w1000-super-total-mega-shark-cache-on-a-boat-on-a-plane,代码行数:18,代码来源:wp-cache-phase2.php

示例10: widget

 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $items = intval($instance['items']);
     //process expired news
     $tzone = get_option('timezone_string');
     date_default_timezone_set($tzone);
     $tdate = date('Ymd');
     $oldnews = query_posts(array('post_type' => 'news-update', 'meta_query' => array(array('key' => 'news_update_expiry_date', 'value' => $tdate, 'compare' => '<='))));
     if (count($oldnews) > 0) {
         foreach ($oldnews as $old) {
             if ($tdate == date('Ymd', strtotime(get_post_meta($old->ID, 'news_update_expiry_date', true)))) {
                 // if expiry today, check the time
                 if (date('H:i:s', strtotime(get_post_meta($old->ID, 'news_update_expiry_time', true))) > date('H:i:s')) {
                     continue;
                 }
             }
             $expiryaction = get_post_meta($old->ID, 'news_update_expiry_action', true);
             if ($expiryaction == 'Revert to draft status') {
                 $my_post = array();
                 $my_post['ID'] = $old->ID;
                 $my_post['post_status'] = 'draft';
                 wp_update_post($my_post);
                 delete_post_meta($old->ID, 'news_update_expiry_date');
                 delete_post_meta($old->ID, 'news_update_expiry_time');
                 delete_post_meta($old->ID, 'news_update_expiry_action');
                 delete_post_meta($old->ID, 'news_auto_expiry');
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($old->ID);
                 }
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($my_post);
                 }
             }
             if ($expiryaction == 'Move to trash') {
                 $my_post = array();
                 $my_post['ID'] = $old->ID;
                 $my_post['post_status'] = 'trash';
                 delete_post_meta($old->ID, 'news_update_expiry_date');
                 delete_post_meta($old->ID, 'news_update_expiry_time');
                 delete_post_meta($old->ID, 'news_update_expiry_action');
                 delete_post_meta($old->ID, 'news_auto_expiry');
                 wp_update_post($my_post);
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($old->ID);
                 }
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($my_post);
                 }
             }
         }
         wp_reset_query();
     }
     //display need to know stories
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_news_update_widget_include_type";
     $news_update_types = get_option($acf_key);
     if ($icon == '') {
         $icon = get_option('options_need_to_know_icon');
     }
     if ($icon == '') {
         $icon = "flag";
     }
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_news_update_background_colour";
     $background_colour = get_option($acf_key);
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_news_update_text_colour";
     $text_colour = get_option($acf_key);
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_news_update_border_colour";
     $border_colour = get_option($acf_key);
     $border_height = get_option('options_widget_border_height', '5');
     if (!$news_update_types || $news_update_types == "None") {
         $cquery = array('orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'news-update', 'posts_per_page' => $items);
     } else {
         $cquery = array('orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'news-update', 'posts_per_page' => $items, 'tax_query' => array(array('taxonomy' => 'news-update-type', 'field' => 'id', 'terms' => $news_update_types)));
     }
     $news = new WP_Query($cquery);
     if ($news->post_count != 0) {
         echo "<style>";
         if ($border_colour) {
             echo ".need-to-know-container." . sanitize_file_name($title) . " { background-color: " . $background_colour . "; color: " . $text_colour . "; padding: 1em; margin-top: 16px; border-top: " . $border_height . "px solid " . $border_colour . " ; }\n";
         } else {
             echo ".need-to-know-container." . sanitize_file_name($title) . " { background-color: " . $background_colour . "; color: " . $text_colour . "; padding: 1em; margin-top: 16px; border-top: 5px solid rgba(0, 0, 0, 0.45); }\n";
         }
         echo ".need-to-know-container." . sanitize_file_name($title) . " a { color: " . $text_colour . "; }\n";
         echo ".need-to-know-container." . sanitize_file_name($title) . " .category-block { background: " . $background_colour . "; }\n";
         echo ".need-to-know-container." . sanitize_file_name($title) . " .category-block h3 { padding: 0 0 10px 0; margin-top: 0; border: none ; color: " . $text_colour . "; }\n";
         echo ".need-to-know-container." . sanitize_file_name($title) . " .category-block ul li { border-top: 1px solid rgba(255, 255, 255, 0.45); }\n";
         echo ".need-to-know-container." . sanitize_file_name($title) . " .category-block p.more-updates { margin-bottom: 0 !important; margin-top: 10px; font-weight: bold; }\n";
         echo "</style>";
         if ($title) {
             echo "<div class='need-to-know-container " . sanitize_file_name($title) . "'>";
             echo $before_widget;
             echo $before_title . $title . $after_title;
         }
         echo "\n\t\t\t<div class='need-to-know'>\n\t\t\t<ul class='need'>";
     }
     $k = 0;
     $alreadydone = array();
     while ($news->have_posts()) {
         $news->the_post();
//.........这里部分代码省略.........
开发者ID:ryanlfoster,项目名称:govintranet,代码行数:101,代码来源:ht_news_updates.php

示例11: cleanCache

 function cleanCache($posts = array())
 {
     if (!defined('WP_CACHE')) {
         return;
     }
     if (count($posts) > 0) {
         //check wp-cache
         @(include_once ABSPATH . 'wp-content/plugins/wp-cache/wp-cache.php');
         if (function_exists('wp_cache_post_change')) {
             foreach ($posts as $post_id) {
                 wp_cache_post_change($post_id);
             }
         } else {
             //check wp-super-cache
             @(include_once ABSPATH . 'wp-content/plugins/wp-super-cache/wp-cache.php');
             if (function_exists('wp_cache_post_change')) {
                 foreach ($posts as $post_id) {
                     wp_cache_post_change($post_id);
                 }
             }
         }
     }
 }
开发者ID:samuelshih,项目名称:daily-gazette,代码行数:23,代码来源:textlinkads.php

示例12: wp_cache_post_edit

function wp_cache_post_edit($post_id)
{
    global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir, $wp_cache_object_cache;
    static $last_post_edited = -1;
    if ($post_id == $last_post_edited) {
        wp_cache_debug("wp_cache_post_edit: Already processed post {$post_id}.", 4);
        return $post_id;
    }
    $post = get_post($post_id);
    if (is_object($post) == false) {
        return $post_id;
    }
    // Some users are inexplicibly seeing this error on scheduled posts.
    // define this constant to disable the post status check.
    if (false == defined('WPSCFORCEUPDATE') && $post->post_status != 'publish') {
        wp_cache_debug("wp_cache_post_edit: draft post, not deleting any cache files.", 4);
        return $post_id;
    }
    // we want to process the post again just in case it becomes published before the second time this function is called.
    $last_post_edited = $post_id;
    if ($wp_cache_clear_on_post_edit) {
        wp_cache_debug("wp_cache_post_edit: Clearing cache {$blog_cache_dir} and {$cache_path}supercache/ on post edit per config.", 2);
        if ($wp_cache_object_cache) {
            reset_oc_version();
        } else {
            prune_super_cache($blog_cache_dir, true);
            prune_super_cache(get_supercache_dir(), true);
        }
    } else {
        wp_cache_debug("wp_cache_post_edit: Clearing cache for post {$post_id} on post edit.", 2);
        wp_cache_post_change($post_id);
    }
}
开发者ID:KurtMakesWeb,项目名称:CandG,代码行数:33,代码来源:wp-cache-phase2.php

示例13: current_time

 /**
  * 
  * @since 1.4
  * @return string
  */
 public function &rebuildHTML5Sitemap()
 {
     include $this->dirPath . '/core/sitetree-factory.class.php';
     include $this->dirPath . '/core/sitetree-html5-factory.class.php';
     $page_id = (int) $this->db->getOption('page_for_sitemap');
     // We don't use 'wp_update_post' because it would generate a new revision.
     global $wpdb;
     $query_str = $wpdb->prepare("UPDATE {$wpdb->posts} SET `post_modified` = %s, `post_modified_gmt` = %s WHERE `ID` = %d", current_time('mysql'), current_time('mysql', 1), $page_id);
     $wpdb->query($query_str);
     $factory = new SiteTreeHTML5Factory($this->db);
     $sitemap = $factory->getSitemap();
     $this->db->setOption('stats_html5', $factory->getStats());
     $this->db->setCache('html5', $sitemap);
     // Try to force WP Super Cache to flush the cached version of the page where the html5 sitemap is shown
     if (WP_CACHE && function_exists('wp_cache_post_change')) {
         if ($page_id !== 0) {
             global $super_cache_enabled;
             $super_cache_enabled = 1;
             wp_cache_post_change($page_id);
         }
     }
     return $sitemap;
 }
开发者ID:MarkSpencerTan,项目名称:webdev,代码行数:28,代码来源:sitetree.class.php

示例14: clear_post_cache

 public function clear_post_cache($post_id)
 {
     switch (get_post_status($post_id)) {
         case 'draft':
         case 'pending':
         case 'future':
         case 'private':
         case 'publish':
             $lca = $this->p->cf['lca'];
             $lang = SucomUtil::get_locale();
             $permalink = get_permalink($post_id);
             $permalink_no_meta = add_query_arg(array('WPSSO_META_TAGS_DISABLE' => 1), $permalink);
             $sharing_url = $this->p->util->get_sharing_url($post_id);
             $transients = array('SucomCache::get' => array('url:' . $permalink, 'url:' . $permalink_no_meta), 'WpssoHead::get_header_array' => array('lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url, 'lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url . '_crawler:pinterest'), 'WpssoMeta::get_mod_column_content' => array('mod:post_lang:' . $lang . '_id:' . $post_id . '_column:' . $lca . '_og_image'));
             $transients = apply_filters($lca . '_post_cache_transients', $transients, $post_id, $lang, $sharing_url);
             $objects = array('SucomWebpage::get_content' => array('lang:' . $lang . '_post:' . $post_id . '_filtered', 'lang:' . $lang . '_post:' . $post_id . '_unfiltered'), 'SucomWebpage::get_hashtags' => array('lang:' . $lang . '_post:' . $post_id));
             $objects = apply_filters($lca . '_post_cache_objects', $objects, $post_id, $lang, $sharing_url);
             $deleted = $this->clear_cache_objects($transients, $objects);
             if (!empty($this->p->options['plugin_cache_info']) && $deleted > 0) {
                 $this->p->notice->inf($deleted . ' items removed from the WordPress object and transient caches.', true);
             }
             if (function_exists('w3tc_pgcache_flush_post')) {
                 // w3 total cache
                 w3tc_pgcache_flush_post($post_id);
             }
             if (function_exists('wp_cache_post_change')) {
                 // wp super cache
                 wp_cache_post_change($post_id);
             }
             break;
     }
 }
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:32,代码来源:util.php

示例15: wp_cache_post_edit

function wp_cache_post_edit($post_id)
{
    global $wp_cache_clear_on_post_edit, $cache_path;
    if ($wp_cache_clear_on_post_edit) {
        prune_super_cache($cache_path, true);
    } else {
        wp_cache_post_change($post_id);
    }
}
开发者ID:alx,项目名称:barceloneta,代码行数:9,代码来源:wp-cache-phase2.php


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