You appear to be a bot. Output may be restricted
Description
Get the GMT modification date for the last modified post in the post type.
Usage
$string|array|false = WPSEO_Sitemaps::get_last_modified_gmt( $post_types, $return_all );
Parameters
- $post_types
- ( string|array ) required – Post type or array of types.
- $return_all
- ( bool ) optional – Flag to return array of values.
Returns
string|array|false
Source
File name: wordpress-seo/inc/sitemaps/class-sitemaps.php
Lines:
1 to 52 of 52
public static function get_last_modified_gmt( $post_types, $return_all = false ) { global $wpdb; static $post_type_dates = null; if ( ! is_array( $post_types ) ) { $post_types = [ $post_types ]; } foreach ( $post_types as $post_type ) { if ( ! isset( $post_type_dates[ $post_type ] ) ) { // If we hadn't seen post type before. R. $post_type_dates = null; break; } } if ( is_null( $post_type_dates ) ) { $post_type_dates = []; $post_type_names = WPSEO_Post_Type::get_accessible_post_types(); if ( ! empty( $post_type_names ) ) { $post_statuses = array_map( 'esc_sql', self::get_post_statuses() ); $sql = " SELECT post_type, MAX(post_modified_gmt) AS date FROM $wpdb->posts WHERE post_status IN ('" . implode( "','", $post_statuses ) . "') AND post_type IN ('" . implode( "','", $post_type_names ) . "') GROUP BY post_type ORDER BY date DESC "; foreach ( $wpdb->get_results( $sql ) as $obj ) { $post_type_dates[ $obj->post_type ] = $obj->date; } } } $dates = array_intersect_key( $post_type_dates, array_flip( $post_types ) ); if ( count( $dates ) > 0 ) { if ( $return_all ) { return $dates; } return max( $dates ); } return false; }