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


PHP clean_page_cache函数代码示例

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


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

示例1: checkFormMassEdit

 /**
  * Control POST data for mass edit tags
  *
  * @param string $type
  */
 function checkFormMassEdit()
 {
     if (!current_user_can('simple_tags')) {
         return false;
     }
     // Get GET data
     if (isset($_GET['post_type'])) {
         $type = stripslashes($_GET['post_type']);
     }
     if (isset($_POST['update_mass'])) {
         // origination and intention
         if (!wp_verify_nonce($_POST['secure_mass'], 'st_mass_terms')) {
             $this->message = __('Security problem. Try again. If this problem persist, contact <a href="mailto:amaury@wordpress-fr.net">plugin author</a>.', 'simpletags');
             $this->status = 'error';
             return false;
         }
         if (isset($_POST['tags'])) {
             $counter = 0;
             foreach ((array) $_POST['tags'] as $object_id => $tag_list) {
                 // Trim data
                 $tag_list = trim(stripslashes($tag_list));
                 // String to array
                 $tags = explode(',', $tag_list);
                 // Remove empty and trim tag
                 $tags = array_filter($tags, '_delete_empty_element');
                 // Add new tag (no append ! replace !)
                 wp_set_object_terms($object_id, $tags, $this->taxonomy);
                 $counter++;
                 // Clean cache
                 if ($this->post_type == 'page') {
                     clean_page_cache($object_id);
                 } else {
                     clean_post_cache($object_id);
                 }
             }
             $this->message = sprintf(__('%1$s %2$s(s) terms updated with success !', 'simpletags'), (int) $counter, strtolower($this->post_type_name));
             return true;
         }
     }
     return false;
 }
开发者ID:rubyerme,项目名称:rubyerme.github.com,代码行数:46,代码来源:class.admin.mass.php

示例2: wp_update_comment_count_now

/**
 * Updates the comment count for the post.
 *
 * @since 2.5.0
 * @uses $wpdb
 * @uses do_action() Calls 'wp_update_comment_count' hook on $post_id, $new, and $old
 * @uses do_action() Calls 'edit_posts' hook on $post_id and $post
 *
 * @param int $post_id Post ID
 * @return bool False on '0' $post_id or if post with ID does not exist. True on success.
 */
function wp_update_comment_count_now($post_id)
{
    global $wpdb;
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    if (!($post = get_post($post_id))) {
        return false;
    }
    $old = (int) $post->comment_count;
    $new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id));
    $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET comment_count = %d WHERE ID = %d", $new, $post_id));
    if ('page' == $post->post_type) {
        clean_page_cache($post_id);
    } else {
        clean_post_cache($post_id);
    }
    do_action('wp_update_comment_count', $post_id, $new, $old);
    do_action('edit_post', $post_id, $post);
    return true;
}
开发者ID:SymbiSoft,项目名称:litprojects,代码行数:33,代码来源:comment.php

示例3: _save_post_hook

function _save_post_hook($post_id, $post)
{
    if ($post->post_type == 'page') {
        if (!empty($post->page_template)) {
            if (!update_post_meta($post_id, '_wp_page_template', $post->page_template)) {
                add_post_meta($post_id, '_wp_page_template', $post->page_template, true);
            }
        }
        clean_page_cache($post_id);
        global $wp_rewrite;
        $wp_rewrite->flush_rules();
    } else {
        clean_post_cache($post_id);
    }
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:15,代码来源:post.php

示例4: _save_post_hook

/**
 * Hook used to prevent page/post cache from staying dirty when a post is saved.
 *
 * @since 2.3.0
 * @access private
 *
 * @param int $post_id The ID in the database table for the $post
 * @param object $post Object type containing the post information
 */
function _save_post_hook($post_id, $post)
{
    if ($post->post_type == 'page') {
        clean_page_cache($post_id);
    } else {
        clean_post_cache($post_id);
    }
}
开发者ID:netconstructor,项目名称:WordPress-1,代码行数:17,代码来源:post.php

示例5: page_rows

function page_rows( $pages ) {
	if ( ! $pages )
		$pages = get_pages( 'sort_column=menu_order' );

	if ( ! $pages )
		return false;

	// splice pages into two parts: those without parent and those with parent

	$top_level_pages = array();
	$children_pages  = array();

	foreach ( $pages as $page ) {

		// catch and repair bad pages
		if ( $page->post_parent == $page->ID ) {
			$page->post_parent = 0;
			$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
			clean_page_cache( $page->ID );
		}

		if ( 0 == $page->post_parent )
			$top_level_pages[] = $page;
		else
			$children_pages[] = $page;
	}

	foreach ( $top_level_pages as $page )
		display_page_row($page, $children_pages, 0);

	/*
	 * display the remaining children_pages which are orphans
	 * having orphan requires parental attention
	 */
	 if ( count($children_pages) > 0 ) {
	 	$empty_array = array();
	 	foreach ( $children_pages as $orphan_page ) {
			clean_page_cache( $orphan_page->ID);
			display_page_row( $orphan_page, $empty_array, 0 );
		}
	 }
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:42,代码来源:template.php

示例6: nxt_update_comment_count_now

/**
 * Updates the comment count for the post.
 *
 * @since 2.5.0
 * @uses $nxtdb
 * @uses do_action() Calls 'nxt_update_comment_count' hook on $post_id, $new, and $old
 * @uses do_action() Calls 'edit_posts' hook on $post_id and $post
 *
 * @param int $post_id Post ID
 * @return bool False on '0' $post_id or if post with ID does not exist. True on success.
 */
function nxt_update_comment_count_now($post_id)
{
    global $nxtdb;
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    if (!($post = get_post($post_id))) {
        return false;
    }
    $old = (int) $post->comment_count;
    $new = (int) $nxtdb->get_var($nxtdb->prepare("SELECT COUNT(*) FROM {$nxtdb->comments} WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id));
    $nxtdb->update($nxtdb->posts, array('comment_count' => $new), array('ID' => $post_id));
    if ('page' == $post->post_type) {
        clean_page_cache($post_id);
    } else {
        clean_post_cache($post_id);
    }
    do_action('nxt_update_comment_count', $post_id, $new, $old);
    do_action('edit_post', $post_id, $post);
    return true;
}
开发者ID:nxtclass,项目名称:NXTClass,代码行数:33,代码来源:comment.php

示例7: autoTermsPost

 /**
  * Automatically tag a post/page from the database terms for the taxonomy specified
  *
  * @param object $object 
  * @param string $taxonomy 
  * @param array $options 
  * @param boolean $counter 
  * @return boolean
  * @author Amaury Balmer
  */
 function autoTermsPost($object, $taxonomy = 'post_tag', $options = array(), $counter = false)
 {
     global $wpdb;
     // Option exists ?
     if ($options == false || empty($options)) {
         return false;
     }
     if (get_the_terms($object->ID, $taxonomy) != false && $options['at_empty'] == 1) {
         return false;
         // Skip post with terms, if term only empty post option is checked
     }
     $terms_to_add = array();
     // Merge title + content + excerpt to compare with terms
     $content = $object->post_content . ' ' . $object->post_title;
     if (isset($object->post_excerpt)) {
         $content .= ' ' . $object->post_excerpt;
     }
     $content = trim(strip_tags($content));
     if (empty($content)) {
         return false;
     }
     // Auto term with specific auto terms list
     if (isset($options['auto_list'])) {
         $terms = (array) maybe_unserialize($options['auto_list']);
         foreach ($terms as $term) {
             if (!is_string($term) && empty($term)) {
                 continue;
             }
             $term = trim($term);
             // Whole word ?
             if ((int) $options['only_full_word'] == 1) {
                 if (preg_match("/\\b" . $term . "\\b/i", $content)) {
                     $terms_to_add[] = $term;
                 }
             } elseif (stristr($content, $term)) {
                 $terms_to_add[] = $term;
             }
         }
         unset($terms, $term);
     }
     // Auto terms with all terms
     if (isset($options['at_all']) && $options['at_all'] == 1) {
         // Get all terms
         $terms = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT name\n\t\t\t\tFROM {$wpdb->terms} AS t\n\t\t\t\tINNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id\n\t\t\t\tWHERE tt.taxonomy = %s", $taxonomy));
         $terms = array_unique($terms);
         foreach ($terms as $term) {
             $term = stripslashes($term);
             if (!is_string($term) && empty($term)) {
                 continue;
             }
             // Whole word ?
             if ((int) $options['only_full_word'] == 1) {
                 $term = ' ' . $term . ' ';
                 // Add space before and after !
             }
             if (stristr($content, $term)) {
                 $terms_to_add[] = $term;
             }
         }
         // Clean memory
         $terms = array();
         unset($terms, $term);
     }
     // Append terms if terms to add
     if (!empty($terms_to_add)) {
         // Remove empty and duplicate elements
         $terms_to_add = array_filter($terms_to_add, '_delete_empty_element');
         $terms_to_add = array_unique($terms_to_add);
         if ($counter == true) {
             // Increment counter
             $counter = (int) get_option('tmp_auto_terms_st') + count($terms_to_add);
             update_option('tmp_auto_terms_st', $counter);
         }
         // Add terms to posts
         wp_set_object_terms($object->ID, $terms_to_add, $taxonomy, true);
         // Clean cache
         if (isset($object->post_type) && ($object->post_type = 'page')) {
             clean_page_cache($object->ID);
         } else {
             clean_post_cache($object->ID);
         }
         return true;
     }
     return false;
 }
开发者ID:rubyerme,项目名称:rubyerme.github.com,代码行数:95,代码来源:class.client.autoterms.php

示例8: wp_insert_post


//.........这里部分代码省略.........
				$alt_post_name = $post_name . "-$suffix";
				$post_name_check = ('publish' == $post_status)
					? $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'publish' AND ID != '$post_ID' LIMIT 1")
					: $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$alt_post_name' AND post_status = 'static' AND ID != '$post_ID' AND post_parent = '$post_parent' LIMIT 1");
				$suffix++;
			}
			$post_name = $alt_post_name;
		}
	}

	if ($update) {
		$wpdb->query(
			"UPDATE IGNORE $wpdb->posts SET
			post_author = '$post_author',
			post_date = '$post_date',
			post_date_gmt = '$post_date_gmt',
			post_content = '$post_content',
			post_content_filtered = '$post_content_filtered',
			post_title = '$post_title',
			post_excerpt = '$post_excerpt',
			post_status = '$post_status',
			comment_status = '$comment_status',
			ping_status = '$ping_status',
			post_password = '$post_password',
			post_name = '$post_name',
			to_ping = '$to_ping',
			pinged = '$pinged',
			post_modified = '".current_time('mysql')."',
			post_modified_gmt = '".current_time('mysql',1)."',
			post_parent = '$post_parent',
			menu_order = '$menu_order'
			WHERE ID = $post_ID");
	} else {
		$wpdb->query(
			"INSERT IGNORE INTO $wpdb->posts
			(post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
			VALUES
			('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type')");
			$post_ID = $wpdb->insert_id;			
	}

	if ( empty($post_name) && 'draft' != $post_status ) {
		$post_name = sanitize_title($post_title, $post_ID);
		$wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" );
	}

	wp_set_post_cats('', $post_ID, $post_category);

	if ( 'static' == $post_status ) {
		clean_page_cache($post_ID);
		wp_cache_delete($post_ID, 'pages');
	} else {
		clean_post_cache($post_ID);
	}

	// Set GUID
	if ( ! $update )
		$wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'");

	if ( $update) {
		if ($previous_status != 'publish' && $post_status == 'publish') {
			// Reset GUID if transitioning to publish.
			$wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'");
			do_action('private_to_published', $post_ID);
		}
		
		do_action('edit_post', $post_ID);
	}

	if ($post_status == 'publish') {
		do_action('publish_post', $post_ID);

		if ( !defined('WP_IMPORTING') ) {
			if ( $post_pingback )
				$result = $wpdb->query("
					INSERT INTO $wpdb->postmeta 
					(post_id,meta_key,meta_value) 
					VALUES ('$post_ID','_pingme','1')
				");
			$result = $wpdb->query("
				INSERT INTO $wpdb->postmeta 
				(post_id,meta_key,meta_value) 
				VALUES ('$post_ID','_encloseme','1')
			");
			spawn_pinger();
		}
	} else if ($post_status == 'static') {
		wp_cache_delete('all_page_ids', 'pages');
		$wp_rewrite->flush_rules();

		if ( !empty($page_template) )
			if ( ! update_post_meta($post_ID, '_wp_page_template',  $page_template))
				add_post_meta($post_ID, '_wp_page_template',  $page_template, true);
	}

	do_action('save_post', $post_ID);
	do_action('wp_insert_post', $post_ID);

	return $post_ID;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:functions-post.php

示例9: saveAdvancedTagsInput

 /**
  * Save tags input for old field
  *
  * @param string $post_id 
  * @param object $object 
  * @return boolean
  * @author Amaury Balmer
  */
 function saveAdvancedTagsInput($post_id = 0, $object = null)
 {
     if (isset($_POST['adv-tags-input'])) {
         // Trim/format data
         $tags = preg_replace("/[\n\r]/", ', ', stripslashes($_POST['adv-tags-input']));
         $tags = trim($tags);
         // String to array
         $tags = explode(',', $tags);
         // Remove empty and trim tag
         $tags = array_filter($tags, '_delete_empty_element');
         // Add new tag (no append ! replace !)
         wp_set_object_terms($post_id, $tags, 'post_tag');
         // Clean cache
         if ('page' == $object->post_type) {
             clean_page_cache($post_id);
         } else {
             clean_post_cache($post_id);
         }
         return true;
     }
     return false;
 }
开发者ID:rubyerme,项目名称:rubyerme.github.com,代码行数:30,代码来源:class.admin.autocomplete.php

示例10: wp_insert_post


//.........这里部分代码省略.........
    }
    if (isset($to_ping)) {
        $to_ping = preg_replace('|\\s+|', "\n", $to_ping);
    } else {
        $to_ping = '';
    }
    if (!isset($pinged)) {
        $pinged = '';
    }
    if (isset($post_parent)) {
        $post_parent = (int) $post_parent;
    } else {
        $post_parent = 0;
    }
    if (isset($menu_order)) {
        $menu_order = (int) $menu_order;
    } else {
        $menu_order = 0;
    }
    if (!isset($post_password)) {
        $post_password = '';
    }
    if ('draft' != $post_status) {
        $post_name_check = $wpdb->get_var("SELECT post_name FROM {$wpdb->posts} WHERE post_name = '{$post_name}' AND post_type = '{$post_type}' AND ID != '{$post_ID}' AND post_parent = '{$post_parent}' LIMIT 1");
        if ($post_name_check || in_array($post_name, $wp_rewrite->feeds)) {
            $suffix = 2;
            do {
                $alt_post_name = $post_name . "-{$suffix}";
                $post_name_check = $wpdb->get_var("SELECT post_name FROM {$wpdb->posts} WHERE post_name = '{$alt_post_name}' AND post_type = '{$post_type}' AND ID != '{$post_ID}' AND post_parent = '{$post_parent}' LIMIT 1");
                $suffix++;
            } while ($post_name_check);
            $post_name = $alt_post_name;
        }
    }
    if ($update) {
        $wpdb->query("UPDATE IGNORE {$wpdb->posts} SET\n\t\t\tpost_author = '{$post_author}',\n\t\t\tpost_date = '{$post_date}',\n\t\t\tpost_date_gmt = '{$post_date_gmt}',\n\t\t\tpost_content = '{$post_content}',\n\t\t\tpost_content_filtered = '{$post_content_filtered}',\n\t\t\tpost_title = '{$post_title}',\n\t\t\tpost_excerpt = '{$post_excerpt}',\n\t\t\tpost_status = '{$post_status}',\n\t\t\tpost_type = '{$post_type}',\n\t\t\tcomment_status = '{$comment_status}',\n\t\t\tping_status = '{$ping_status}',\n\t\t\tpost_password = '{$post_password}',\n\t\t\tpost_name = '{$post_name}',\n\t\t\tto_ping = '{$to_ping}',\n\t\t\tpinged = '{$pinged}',\n\t\t\tpost_modified = '" . current_time('mysql') . "',\n\t\t\tpost_modified_gmt = '" . current_time('mysql', 1) . "',\n\t\t\tpost_parent = '{$post_parent}',\n\t\t\tmenu_order = '{$menu_order}'\n\t\t\tWHERE ID = {$post_ID}");
    } else {
        $wpdb->query("INSERT IGNORE INTO {$wpdb->posts}\n\t\t\t(post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)\n\t\t\tVALUES\n\t\t\t('{$post_author}', '{$post_date}', '{$post_date_gmt}', '{$post_content}', '{$post_content_filtered}', '{$post_title}', '{$post_excerpt}', '{$post_status}', '{$post_type}', '{$comment_status}', '{$ping_status}', '{$post_password}', '{$post_name}', '{$to_ping}', '{$pinged}', '{$post_date}', '{$post_date_gmt}', '{$post_parent}', '{$menu_order}', '{$post_mime_type}')");
        $post_ID = (int) $wpdb->insert_id;
    }
    if (empty($post_name) && 'draft' != $post_status) {
        $post_name = sanitize_title($post_title, $post_ID);
        $wpdb->query("UPDATE {$wpdb->posts} SET post_name = '{$post_name}' WHERE ID = '{$post_ID}'");
    }
    wp_set_post_categories($post_ID, $post_category);
    if ('page' == $post_type) {
        clean_page_cache($post_ID);
        $wp_rewrite->flush_rules();
    } else {
        clean_post_cache($post_ID);
    }
    // Set GUID
    if (!$update) {
        $wpdb->query("UPDATE {$wpdb->posts} SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '{$post_ID}'");
    }
    if ($update) {
        if ($previous_status != 'publish' && $post_status == 'publish') {
            // Reset GUID if transitioning to publish.
            $wpdb->query("UPDATE {$wpdb->posts} SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '{$post_ID}'");
            do_action('private_to_published', $post_ID);
        }
        do_action('edit_post', $post_ID);
    }
    if ($post_status == 'publish' && $post_type == 'post') {
        do_action('publish_post', $post_ID);
        if (defined('XMLRPC_REQUEST')) {
            do_action('xmlrpc_publish_post', $post_ID);
        }
        if (defined('APP_REQUEST')) {
            do_action('app_publish_post', $post_ID);
        }
        if (!defined('WP_IMPORTING')) {
            if ($post_pingback) {
                $result = $wpdb->query("\n\t\t\t\t\tINSERT INTO {$wpdb->postmeta}\n\t\t\t\t\t(post_id,meta_key,meta_value)\n\t\t\t\t\tVALUES ('{$post_ID}','_pingme','1')\n\t\t\t\t");
            }
            $result = $wpdb->query("\n\t\t\t\tINSERT INTO {$wpdb->postmeta}\n\t\t\t\t(post_id,meta_key,meta_value)\n\t\t\t\tVALUES ('{$post_ID}','_encloseme','1')\n\t\t\t");
            wp_schedule_single_event(time(), 'do_pings');
        }
    } else {
        if ($post_type == 'page') {
            if (!empty($page_template)) {
                if (!update_post_meta($post_ID, '_wp_page_template', $page_template)) {
                    add_post_meta($post_ID, '_wp_page_template', $page_template, true);
                }
            }
            if ($post_status == 'publish') {
                do_action('publish_page', $post_ID);
            }
        }
    }
    // Always clears the hook in case the post status bounced from future to draft.
    wp_clear_scheduled_hook('publish_future_post', $post_ID);
    // Schedule publication.
    if ('future' == $post_status) {
        wp_schedule_single_event(strtotime($post_date_gmt . ' GMT'), 'publish_future_post', array($post_ID));
    }
    do_action('save_post', $post_ID);
    do_action('wp_insert_post', $post_ID);
    return $post_ID;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:post.php

示例11: page_rows

    private function page_rows($pagenum = 1, $per_page = 15)
    {
        global $wpdb, $wp_query;
        $level = 0;
        $pages =& $wp_query->posts;
        if (!$pages) {
            return false;
        }
        /*
         * arrange pages into two parts: top level pages and children_pages
         * children_pages is two dimensional array, eg.
         * children_pages[10][] contains all sub-pages whose parent is 10.
         * It only takes O(N) to arrange this and it takes O(1) for subsequent lookup operations
         * If searching, ignore hierarchy and treat everything as top level
         */
        if (empty($this->search)) {
            $top_level_pages = array();
            $children_pages = array();
            foreach ($pages as $page) {
                // catch and repair bad pages
                if ($page->post_parent == $page->ID) {
                    $page->post_parent = 0;
                    $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_parent = '0' WHERE ID = %d", $page->ID));
                    clean_page_cache($page->ID);
                }
                if (0 == $page->post_parent) {
                    $top_level_pages[] = $page;
                } else {
                    $children_pages[$page->post_parent][] = $page;
                }
            }
            $pages =& $top_level_pages;
        }
        $count = 0;
        $start = ($pagenum - 1) * $per_page;
        $end = $start + $per_page;
        ?>
<dl><?php 
        foreach ($pages as $page) {
            if ($count >= $end) {
                break;
            }
            if ($count >= $start) {
                echo $this->display_page_row($page, $level);
            }
            $count++;
            if (isset($children_pages)) {
                $this->_page_rows($children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page);
            }
        }
        // if it is the last pagenum and there are orphaned pages, display them with paging as well
        if (isset($children_pages) && $count < $end) {
            foreach ($children_pages as $orphans) {
                foreach ($orphans as $op) {
                    if ($count >= $end) {
                        break;
                    }
                    if ($count >= $start) {
                        echo $this->display_page_row($op, 0);
                    }
                    $count++;
                }
            }
        }
        ?>
</dl><?php 
    }
开发者ID:masayukiando,项目名称:wordpress-event-search,代码行数:67,代码来源:edit-pages.php

示例12: wp_update_comment_count

function wp_update_comment_count($post_id)
{
    global $wpdb, $comment_count_cache;
    $post_id = (int) $post_id;
    if (!$post_id) {
        return false;
    }
    $count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_post_ID = '{$post_id}' AND comment_approved = '1'");
    $wpdb->query("UPDATE {$wpdb->posts} SET comment_count = {$count} WHERE ID = '{$post_id}'");
    $comment_count_cache[$post_id] = $count;
    $post = get_post($post_id);
    if ('page' == $post->post_type) {
        clean_page_cache($post_id);
    } else {
        clean_post_cache($post_id);
    }
    do_action('edit_post', $post_id);
    return true;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:19,代码来源:comment.php

示例13: wp_update_comment_count_now

/**
 * Updates the comment count for the post.
 *
 * @since 2.5.0
 * @uses $wpdb
 * @uses do_action() Calls 'wp_update_comment_count' hook on $post_id, $new, and $old
 * @uses do_action() Calls 'edit_posts' hook on $post_id and $post
 *
 * @param int $post_id Post ID
 * @return bool False on '0' $post_id or if post with ID does not exist. True on success.
 */
function wp_update_comment_count_now($post_id) {
	global $wpdb;
	$post_id = (int) $post_id;
	if ( !$post_id )
		return false;
	if ( !$post = get_post($post_id) )
		return false;

	$old = (int) $post->comment_count;
	$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) );
	$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );

	if ( 'page' == $post->post_type )
		clean_page_cache( $post_id );
	else
		clean_post_cache( $post_id );

	do_action('wp_update_comment_count', $post_id, $new, $old);
	do_action('edit_post', $post_id, $post);

	return true;
}
开发者ID:realfluid,项目名称:umbaugh,代码行数:33,代码来源:comment.php

示例14: process_bulk_action

 function process_bulk_action()
 {
     global $wp_rewrite, $wpdb;
     if ('convert' === $this->current_action()) {
         $output = "<div id=\"viceversa-status\" class=\"updated\">\n            <input type=\"button\" class=\"viceversa-close-icon button-secondary\" title=\"Close\" value=\"x\" />";
         if (VICEVERSA_DEBUG) {
             $output .= "<strong>" . __('Debug Mode', 'vice-versa') . "</strong>\n";
         }
         switch ($_POST['p_type']) {
             case 'page':
                 $categories = array('ids' => array(), 'titles' => array());
                 $do_bulk = false;
                 foreach ($_POST['parents'] as $category) {
                     if ($category != "") {
                         $data = explode("|", $category);
                         $categories[$data[3]]['ids'] = array();
                         $categories[$data[3]]['titles'] = array();
                         if ($data[3] == 0) {
                             $do_bulk = true;
                         }
                     }
                 }
                 foreach ($_POST['parents'] as $category) {
                     if ($category != "") {
                         $data = explode("|", $category);
                         array_push($categories[$data[3]]['ids'], $data[0]);
                         array_push($categories[$data[3]]['titles'], $data[2]);
                     }
                 }
                 $output .= "<p>\n";
                 foreach ($_POST['post'] as $viceversa_page) {
                     $viceversa_data = explode("|", $viceversa_page);
                     $viceversa_url = site_url() . "/?p=" . $viceversa_data[0];
                     if ($do_bulk) {
                         $ids = $categories[0]['ids'];
                         $titles = $categories[0]['titles'];
                     } else {
                         $ids = $categories[$viceversa_data[0]]['ids'];
                         $titles = $categories[$viceversa_data[0]]['titles'];
                     }
                     $catlist = "";
                     if ($titles) {
                         foreach ($titles as $cat) {
                             $catlist .= $cat . ", ";
                         }
                     }
                     $catlist = trim($catlist, ', ') == "" ? get_cat_name(1) : trim($catlist, ', ');
                     $cat_array = count($ids) < 1 ? array(1) : $ids;
                     if (!VICEVERSA_DEBUG) {
                         $wpdb->update($wpdb->posts, array('guid' => $viceversa_url, 'post_parent' => $cat_array[0]), array('ID' => intval($viceversa_data[0])), array('%s', '%d'), array('%d'));
                         clean_page_cache(intval($viceversa_data[0]));
                         set_post_type(intval($viceversa_data[0]), 'post');
                         wp_set_post_categories(intval($viceversa_data[0]), $cat_array);
                     }
                     $new_permalink = get_permalink(intval($viceversa_data[0]));
                     $output .= sprintf(__('<strong>' . __('Page', 'vice-versa') . '</strong> #%s <code><a href="%s" target="_blank" title="' . __('New Permalink', 'vice-versa') . '">%s</a></code> ' . __('was successfully converted to a <strong>Post</strong> and assigned to category(s)', 'vice-versa') . ' <code>%s</code>. <a href="%s" target="_blank" title="' . __('New Permalink', 'vice-versa') . '">' . __('New Permalink', 'vice-versa') . '</a>', 'vice-versa'), $viceversa_data[0], $new_permalink, $viceversa_data[2], $catlist, $new_permalink) . "<br />\n";
                 }
                 if (!VICEVERSA_DEBUG) {
                     $wp_rewrite->flush_rules();
                 }
                 break;
             default:
                 $parents = array();
                 $do_bulk = false;
                 foreach ($_POST['parents'] as $parent) {
                     if ($parent != "") {
                         $data = explode("|", $parent);
                         if ($data[3] == 0) {
                             $do_bulk = true;
                         }
                         $parents[intval($data[3])] = $data[0] . "|" . $data[2];
                     }
                 }
                 $output .= "<p>\n";
                 if (!$_POST['post']) {
                     $output .= __('No items were selected. Please select items using the checkboxes.', 'vice-versa');
                 } else {
                     foreach ($_POST['post'] as $viceversa_post) {
                         $viceversa_data = explode("|", $viceversa_post);
                         $viceversa_url = site_url() . "/?page_id=" . $viceversa_data[0];
                         if ($do_bulk) {
                             $p = $parents[0];
                         } else {
                             $p = $parents[$viceversa_data[0]];
                         }
                         $parent = $p == "" ? "0|" . __('No Parent', 'vice-versa') . "" : $p;
                         $parent = explode("|", $parent);
                         if (!VICEVERSA_DEBUG) {
                             $wpdb->update($wpdb->posts, array('guid' => $viceversa_url, 'post_parent' => intval($parent[0])), array('ID' => intval($viceversa_data[0])), array('%s', '%d'), array('%d'));
                             clean_post_cache(intval($viceversa_data[0]));
                             set_post_type(intval($viceversa_data[0]), 'page');
                             wp_set_post_categories(intval($viceversa_data[0]), array(intval($parent[0])));
                         }
                         $permalink = get_permalink(intval($viceversa_data[0]));
                         $output .= sprintf(__('<strong>' . __('Post', 'vice-versa') . '</strong> #%s <code><a href="%s" target="_blank" title="' . __('New Permalink', 'vice-versa') . '">%s</a></code> ' . __('was successfully converted to a <strong>Page</strong> and assigned to parent', 'vice-versa') . ' #%s <code>%s</code>. <a href="%s" target="_blank" title="' . __('New Permalink', 'vice-versa') . '">' . __('New Permalink', 'vice-versa') . '</a>', 'vice-versa'), $viceversa_data[0], $permalink, $viceversa_data[2], $parent[0], $parent[1], $permalink) . "<br />\n";
                     }
                     if (!VICEVERSA_DEBUG) {
                         $wp_rewrite->flush_rules();
                     }
                 }
//.........这里部分代码省略.........
开发者ID:jasonlau,项目名称:Wordpress-Vice-Versa,代码行数:101,代码来源:vice-versa.php

示例15: _save_post_hook

/**
 * _save_post_hook() - Hook used to prevent page/post cache and rewrite rules from staying dirty
 *
 * Does two things. If the post is a page and has a template then it will update/add that
 * template to the meta. For both pages and posts, it will clean the post cache to make sure
 * that the cache updates to the changes done recently. For pages, the rewrite rules of
 * WordPress are flushed to allow for any changes.
 *
 * The $post parameter, only uses 'post_type' property and 'page_template' property.
 *
 * @package WordPress
 * @subpackage Post
 * @since 2.3
 *
 * @uses $wp_rewrite Flushes Rewrite Rules.
 *
 * @param int $post_id The ID in the database table for the $post
 * @param object $post Object type containing the post information
 */
function _save_post_hook($post_id, $post)
{
    if ($post->post_type == 'page') {
        clean_page_cache($post_id);
        global $wp_rewrite;
        $wp_rewrite->flush_rules();
    } else {
        clean_post_cache($post_id);
    }
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:29,代码来源:post.php


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