本文整理汇总了PHP中Util_Environment::detect_post_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::detect_post_id方法的具体用法?PHP Util_Environment::detect_post_id怎么用?PHP Util_Environment::detect_post_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util_Environment
的用法示例。
在下文中一共展示了Util_Environment::detect_post_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: w3tc_admin_bar_menu
public function w3tc_admin_bar_menu($menu_items)
{
$menu_items['20110.pagecache'] = array('id' => 'w3tc_flush_pgcache', 'parent' => 'w3tc_flush', 'title' => __('Page Cache: All', 'w3-total-cache'), 'href' => wp_nonce_url(network_admin_url('admin.php?page=w3tc_dashboard&w3tc_flush_pgcache'), 'w3tc'));
if (Util_Environment::detect_post_id() && (!defined('DOING_AJAX') || !DOING_AJAX)) {
$menu_items['20120.pagecache'] = array('id' => 'w3tc_pgcache_flush_post', 'parent' => 'w3tc_flush', 'title' => __('Page Cache: Current Page', 'w3-total-cache'), 'href' => wp_nonce_url(network_admin_url('admin.php?page=w3tc_dashboard&w3tc_flush_post&post_id=' . Util_Environment::detect_post_id()), 'w3tc'));
}
return $menu_items;
}
示例2: flush_post
/**
* Flushes varnish post cache
*
* @param integer $post_id
* @return boolean
*/
function flush_post($post_id)
{
if (!$post_id) {
$post_id = Util_Environment::detect_post_id();
}
if ($post_id) {
$full_urls = array();
$post = null;
$terms = array();
$feeds = $this->_config->get_array('pgcache.purge.feed.types');
$limit_post_pages = $this->_config->get_integer('pgcache.purge.postpages_limit');
if ($this->_config->get_boolean('pgcache.purge.terms') || $this->_config->get_boolean('varnish.pgcache.feed.terms')) {
$taxonomies = get_post_taxonomies($post_id);
$terms = wp_get_post_terms($post_id, $taxonomies);
}
switch (true) {
case $this->_config->get_boolean('pgcache.purge.author'):
case $this->_config->get_boolean('pgcache.purge.archive.daily'):
case $this->_config->get_boolean('pgcache.purge.archive.monthly'):
case $this->_config->get_boolean('pgcache.purge.archive.yearly'):
case $this->_config->get_boolean('pgcache.purge.feed.author'):
$post = get_post($post_id);
}
$front_page = get_option('show_on_front');
/**
* Home (Frontpage) URL
*/
if ($this->_config->get_boolean('pgcache.purge.home') && $front_page == 'posts' || $this->_config->get_boolean('pgcache.purge.front_page')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_frontpage_urls($limit_post_pages));
}
/**
* Home (Post page) URL
*/
if ($this->_config->get_boolean('pgcache.purge.home') && $front_page != 'posts') {
$full_urls = array_merge($full_urls, Util_PageUrls::get_postpage_urls($limit_post_pages));
}
/**
* Post URL
*/
if ($this->_config->get_boolean('pgcache.purge.post')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_urls($post_id));
}
/**
* Post comments URLs
*/
if ($this->_config->get_boolean('pgcache.purge.comments') && function_exists('get_comments_pagenum_link')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_comments_urls($post_id));
}
/**
* Post author URLs
*/
if ($this->_config->get_boolean('pgcache.purge.author') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_author_urls($post->post_author, $limit_post_pages));
}
/**
* Post terms URLs
*/
if ($this->_config->get_boolean('pgcache.purge.terms')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_terms_urls($terms, $limit_post_pages));
}
/**
* Daily archive URLs
*/
if ($this->_config->get_boolean('pgcache.purge.archive.daily') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_daily_archive_urls($post, $limit_post_pages));
}
/**
* Monthly archive URLs
*/
if ($this->_config->get_boolean('pgcache.purge.archive.monthly') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_monthly_archive_urls($post, $limit_post_pages));
}
/**
* Yearly archive URLs
*/
if ($this->_config->get_boolean('pgcache.purge.archive.yearly') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_yearly_archive_urls($post, $limit_post_pages));
}
/**
* Feed URLs
*/
if ($this->_config->get_boolean('pgcache.purge.feed.blog')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_urls($feeds));
}
if ($this->_config->get_boolean('pgcache.purge.feed.comments')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_comments_urls($post_id, $feeds));
}
if ($this->_config->get_boolean('pgcache.purge.feed.author') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_author_urls($post->post_author, $feeds));
}
if ($this->_config->get_boolean('pgcache.purge.feed.terms')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_terms_urls($terms, $feeds));
}
/**
//.........这里部分代码省略.........
示例3: w3tc_flush_post
/**
* Purges cdn's post cache
*
* @param integer $post_id
* @return boolean
*/
public static function w3tc_flush_post($post_id)
{
if (!$post_id) {
$post_id = Util_Environment::detect_post_id();
}
if (!$post_id) {
return false;
}
$config = Dispatcher::config();
$full_urls = array();
$post = null;
$terms = array();
$feeds = $config->get_array('pgcache.purge.feed.types');
$limit_post_pages = $config->get_integer('pgcache.purge.postpages_limit');
if ($config->get_boolean('pgcache.purge.terms') || $config->get_boolean('varnish.pgcache.feed.terms')) {
$taxonomies = get_post_taxonomies($post_id);
$terms = wp_get_post_terms($post_id, $taxonomies);
}
switch (true) {
case $config->get_boolean('pgcache.purge.author'):
case $config->get_boolean('pgcache.purge.archive.daily'):
case $config->get_boolean('pgcache.purge.archive.monthly'):
case $config->get_boolean('pgcache.purge.archive.yearly'):
case $config->get_boolean('pgcache.purge.feed.author'):
$post = get_post($post_id);
}
$front_page = get_option('show_on_front');
/**
* Home (Frontpage) URL
*/
if ($config->get_boolean('pgcache.purge.home') && $front_page == 'posts' || $config->get_boolean('pgcache.purge.front_page')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_frontpage_urls($limit_post_pages));
}
/**
* Home (Post page) URL
*/
if ($config->get_boolean('pgcache.purge.home') && $front_page != 'posts') {
$full_urls = array_merge($full_urls, Util_PageUrls::get_postpage_urls($limit_post_pages));
}
/**
* Post URL
*/
if ($config->get_boolean('pgcache.purge.post')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_urls($post_id));
}
/**
* Post comments URLs
*/
if ($config->get_boolean('pgcache.purge.comments') && function_exists('get_comments_pagenum_link')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_comments_urls($post_id));
}
/**
* Post author URLs
*/
if ($config->get_boolean('pgcache.purge.author') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_author_urls($post->post_author, $limit_post_pages));
}
/**
* Post terms URLs
*/
if ($config->get_boolean('pgcache.purge.terms')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_terms_urls($terms, $limit_post_pages));
}
/**
* Daily archive URLs
*/
if ($config->get_boolean('pgcache.purge.archive.daily') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_daily_archive_urls($post, $limit_post_pages));
}
/**
* Monthly archive URLs
*/
if ($config->get_boolean('pgcache.purge.archive.monthly') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_monthly_archive_urls($post, $limit_post_pages));
}
/**
* Yearly archive URLs
*/
if ($config->get_boolean('pgcache.purge.archive.yearly') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_yearly_archive_urls($post, $limit_post_pages));
}
/**
* Feed URLs
*/
if ($config->get_boolean('pgcache.purge.feed.blog')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_urls($feeds));
}
if ($config->get_boolean('pgcache.purge.feed.comments')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_comments_urls($post_id, $feeds));
}
if ($config->get_boolean('pgcache.purge.feed.author') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_author_urls($post->post_author, $feeds));
}
if ($config->get_boolean('pgcache.purge.feed.terms')) {
//.........这里部分代码省略.........
示例4: flush_post
/**
* Flushes post cache
*
* @param integer $post_id
* @return boolean
*/
function flush_post($post_id = null)
{
if (!$post_id) {
$post_id = Util_Environment::detect_post_id();
}
if (!$post_id) {
return false;
}
$full_urls = array();
$post = null;
$terms = array();
$feeds = $this->_config->get_array('pgcache.purge.feed.types');
$limit_post_pages = $this->_config->get_integer('pgcache.purge.postpages_limit');
if ($this->_config->get_boolean('pgcache.purge.terms') || $this->_config->get_boolean('pgcache.purge.feed.terms')) {
$taxonomies = get_post_taxonomies($post_id);
$terms = wp_get_post_terms($post_id, $taxonomies);
$terms = $this->_append_parent_terms($terms, $terms);
}
$post = get_post($post_id);
$post_type = in_array($post->post_type, array('post', 'page', 'attachment', 'revision')) ? null : $post->post_type;
$front_page = get_option('show_on_front');
/**
* Home (Frontpage) URL
*/
if ($this->_config->get_boolean('pgcache.purge.home') && $front_page == 'posts' || $this->_config->get_boolean('pgcache.purge.front_page')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_frontpage_urls($limit_post_pages));
}
/**
* Home (Post page) URL
*/
if ($this->_config->get_boolean('pgcache.purge.home') && $front_page != 'posts') {
$full_urls = array_merge($full_urls, Util_PageUrls::get_postpage_urls($limit_post_pages));
}
/**
* Post URL
*/
if ($this->_config->get_boolean('pgcache.purge.post')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_urls($post_id));
}
/**
* Post comments URLs
*/
if ($this->_config->get_boolean('pgcache.purge.comments') && function_exists('get_comments_pagenum_link')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_comments_urls($post_id));
}
/**
* Post author URLs
*/
if ($this->_config->get_boolean('pgcache.purge.author')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_author_urls($post->post_author, $limit_post_pages));
}
/**
* Post terms URLs
*/
if ($this->_config->get_boolean('pgcache.purge.terms')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_post_terms_urls($terms, $limit_post_pages));
}
/**
* Daily archive URLs
*/
if ($this->_config->get_boolean('pgcache.purge.archive.daily') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_daily_archive_urls($post, $limit_post_pages));
}
/**
* Monthly archive URLs
*/
if ($this->_config->get_boolean('pgcache.purge.archive.monthly') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_monthly_archive_urls($post, $limit_post_pages));
}
/**
* Yearly archive URLs
*/
if ($this->_config->get_boolean('pgcache.purge.archive.yearly') && $post) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_yearly_archive_urls($post, $limit_post_pages));
}
/**
* Feed URLs
*/
if ($this->_config->get_boolean('pgcache.purge.feed.blog')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_urls($feeds, $post_type));
}
if ($this->_config->get_boolean('pgcache.purge.feed.comments')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_comments_urls($post_id, $feeds));
}
if ($this->_config->get_boolean('pgcache.purge.feed.author')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_author_urls($post->post_author, $feeds));
}
if ($this->_config->get_boolean('pgcache.purge.feed.terms')) {
$full_urls = array_merge($full_urls, Util_PageUrls::get_feed_terms_urls($terms, $feeds));
}
/**
* Purge selected pages
*/
if ($this->_config->get_array('pgcache.purge.pages')) {
//.........这里部分代码省略.........