diff options
Diffstat (limited to 'plugins/jetpack/modules/sitemaps/sitemap-librarian.php')
-rw-r--r-- | plugins/jetpack/modules/sitemaps/sitemap-librarian.php | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-librarian.php b/plugins/jetpack/modules/sitemaps/sitemap-librarian.php index 4c41d095..c923c952 100644 --- a/plugins/jetpack/modules/sitemaps/sitemap-librarian.php +++ b/plugins/jetpack/modules/sitemaps/sitemap-librarian.php @@ -10,6 +10,7 @@ * @package Jetpack */ +/* Ensure sitemap constants are available. */ require_once dirname( __FILE__ ) . '/sitemap-constants.php'; /** @@ -39,12 +40,14 @@ class Jetpack_Sitemap_Librarian { * } */ public function read_sitemap_data( $name, $type ) { - $post_array = get_posts( array( - 'numberposts' => 1, - 'title' => $name, - 'post_type' => $type, - 'post_status' => 'draft' - ) ); + $post_array = get_posts( + array( + 'numberposts' => 1, + 'title' => $name, + 'post_type' => $type, + 'post_status' => 'draft', + ) + ); $the_post = array_shift( $post_array ); @@ -83,21 +86,25 @@ class Jetpack_Sitemap_Librarian { if ( null === $the_post ) { // Post does not exist. - wp_insert_post(array( - 'post_title' => $name, - 'post_content' => base64_encode( $contents ), - 'post_type' => $type, - 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ), - )); + wp_insert_post( + array( + 'post_title' => $name, + 'post_content' => base64_encode( $contents ), + 'post_type' => $type, + 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ), + ) + ); } else { // Post does exist. - wp_insert_post(array( - 'ID' => $the_post['id'], - 'post_title' => $name, - 'post_content' => base64_encode( $contents ), - 'post_type' => $type, - 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ), - )); + wp_insert_post( + array( + 'ID' => $the_post['id'], + 'post_title' => $name, + 'post_content' => base64_encode( $contents ), + 'post_type' => $type, + 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ), + ) + ); } } @@ -160,8 +167,8 @@ class Jetpack_Sitemap_Librarian { $any_left = true; while ( true === $any_left ) { - $position += 1; - $name = jp_sitemap_filename( $type, $position ); + $position++; + $name = jp_sitemap_filename( $type, $position ); $any_left = $this->delete_sitemap_data( $name, $type ); } } @@ -188,16 +195,18 @@ class Jetpack_Sitemap_Librarian { * @access protected * @since 5.3.0 * - * @param String $type + * @param String $type Type of sitemap. */ protected function delete_sitemap_type_data( $type ) { - $ids = get_posts( array( - 'post_type' => $type, - 'post_status' => 'draft', - 'fields' => 'ids' - ) ); + $ids = get_posts( + array( + 'post_type' => $type, + 'post_status' => 'draft', + 'fields' => 'ids', + ) + ); - foreach( $ids as $id ) { + foreach ( $ids as $id ) { wp_trash_post( $id ); } } |