Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Returns max ID of the source wp_posts table.
- *
- * @return int
- */
- public function get_source_max_article_id() {
- $in_source_post_statuses = [ 'publish', 'draft', 'pending', 'private', 'trash', 'inherit' ];
- $post_status_placeholders = implode( ', ', array_fill( 0, count( $in_source_post_statuses ), '%s' ) );
- $prepare_values = array_merge( [ $this->post_type ], $in_source_post_statuses );
- $source_db = self::$source_db_handle;
- $sql = $source_db->prepare(
- "SELECT max(ID) FROM {$source_db->prefix}posts
- WHERE post_type=%s AND post_status IN ( {$post_status_placeholders} )",
- $prepare_values
- );
- return (int) $source_db->get_var( $sql );
- }
Add Comment
Please, Sign In to add comment