-/**
- * 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.
- *
- * @since 2.3.0
- * @access private
- * @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);
- // Avoid flushing rules for every post during import.
- if ( !defined('WP_IMPORTING') ) {
- global $wp_rewrite;
- $wp_rewrite->flush_rules(false);
- }
- } else {
- clean_post_cache($post_id);
- }
-}
-
-/**
- * Retrieve post ancestors and append to post ancestors property.
- *
- * Will only retrieve ancestors once, if property is already set, then nothing
- * will be done. If there is not a parent post, or post ID and post parent ID
- * are the same then nothing will be done.
- *
- * The parameter is passed by reference, so nothing needs to be returned. The
- * property will be updated and can be referenced after the function is
- * complete. The post parent will be an ancestor and the parent of the post
- * parent will be an ancestor. There will only be two ancestors at the most.
- *
- * @since 2.5.0
- * @access private
- * @uses $wpdb
- *
- * @param object $_post Post data.
- * @return null When nothing needs to be done.
- */
-function _get_post_ancestors(&$_post) {
- global $wpdb;
-
- if ( isset($_post->ancestors) )
- return;
-
- $_post->ancestors = array();
-
- if ( empty($_post->post_parent) || $_post->ID == $_post->post_parent )
- return;
-
- $id = $_post->ancestors[] = $_post->post_parent;
- while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) ) ) {
- // Loop detection: If the ancestor has been seen before, break.
- if ( ( $ancestor == $_post->ID ) || in_array($ancestor, $_post->ancestors) )
- break;
- $id = $_post->ancestors[] = $ancestor;
- }
-}
-