WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WPSEO_Sitemaps::get_last_modified_gmt() public Yoast 3.2

Get the GMT modification date for the last modified post in the post type.

{} Это метод класса: WPSEO_Sitemaps{}

Хуков нет.

Возвращает

Строку|Массив|false.

Использование

$result = WPSEO_Sitemaps::get_last_modified_gmt( $post_types, $return_all );
$post_types(строка|массив) (обязательный)
Post type or array of types.
$return_all(true|false)
Flag to return array of values.
По умолчанию: false

Список изменений

С версии 3.2 Введена.

Код WPSEO_Sitemaps::get_last_modified_gmt() Yoast 17.1

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;
}