WPSEO_Author_Sitemap_Provider::update_user_meta()protectedYoast 1.0

Update any users that don't have last profile update timestamp.

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

Хуков нет.

Возвращает

int. Count of users updated.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->update_user_meta();

Код WPSEO_Author_Sitemap_Provider::update_user_meta() Yoast 18.8

protected function update_user_meta() {

	$user_criteria = [
		'capability' => [ 'edit_posts' ],
		'meta_query' => [
			[
				'key'     => '_yoast_wpseo_profile_updated',
				'compare' => 'NOT EXISTS',
			],
		],
	];

	$wordpress_helper  = new Wordpress_Helper();
	$wordpress_version = $wordpress_helper->get_wordpress_version();

	// Capability queries were only introduced in WP 5.9.
	if ( version_compare( $wordpress_version, '5.8.99', '<' ) ) {
		$user_criteria['who'] = 'authors';
		unset( $user_criteria['capability'] );
	}

	$users = get_users( $user_criteria );

	$time = time();

	foreach ( $users as $user ) {
		update_user_meta( $user->ID, '_yoast_wpseo_profile_updated', $time );
	}

	return count( $users );
}