uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}
uthor_meta( $user_id, $key ) {
$value = \get_the_author_meta( $key, $user_id );
if ( \is_string( $value ) && $value === '' ) {
return null;
}
return $value;
}
/**
* Finds an alternative image for the social image.
*
* @param Indexable $indexable The indexable.
*
* @return array|bool False when not found, array with data when found.
*/
protected function find_alternative_image( Indexable $indexable ) {
$gravatar_image = \get_avatar_url(
$indexable->object_id,
[
'size' => 500,
'scheme' => 'https',
]
);
if ( $gravatar_image ) {
return [
'image' => $gravatar_image,
'source' => 'gravatar-image',
];
}
return false;
}
/**
* Returns the timestamps for a given author.
*
* @param int $author_id The author ID.
*
* @return object An object with last_modified and published_at timestamps.
*/
protected function get_object_timestamps( $author_id ) {
global $wpdb;
$post_statuses = $this->post_helper->get_public_post_statuses();
$replacements = [];
$replacements[] = 'post_modified_gmt';
$replacements[] = 'post_date_gmt';
$replacements[] = $wpdb->posts;
$replacements[] = 'post_status';
$replacements = \array_merge( $replacements, $post_statuses );
$replacements[] = 'post_password';
$replacements[] = 'post_author';
$replacements[] = $author_id;
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
return $wpdb->get_row(
$wpdb->prepare(
'
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
FROM %i AS p
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
AND p.%i = ''
AND p.%i = %d
",
$replacements
)
);
//phpcs:enable
}
/**
* Checks if the user should be indexed.
* Returns an exception with an appropriate message if not.
*
* @param string $user_id The user id.
*
* @return Author_Not_Built_Exception|null The exception if it should not be indexed, or `null` if it should.
*/
protected function check_if_user_should_be_indexed( $user_id ) {
$exception = null;
if ( $this->author_archive->are_disabled() ) {
$exception = Author_Not_Built_Exception::author_archives_are_disabled( $user_id );
}
// We will check if the author has public posts the WP way, instead of the indexable way, to make sure we get proper results even if SEO optimization is not run.
// In case the user has no public posts, we check if the user should be indexed anyway.
if ( $this->options_helper->get( 'noindex-author-noposts-wpseo', false ) === true && $this->author_archive->author_has_public_posts_wp( $user_id ) === false ) {
$exception = Author_Not_Built_Exception::author_archives_are_not_indexed_for_users_without_posts( $user_id );
}
/**
* Filter: Include or exclude a user from being build and saved as an indexable.
* Return an `Author_Not_Built_Exception` when the indexable should not be build, with an appropriate message telling why it should not be built.
* Return `null` if the indexable should be build.
*
* @param Author_Not_Built_Exception|null $exception An exception if the indexable is not being built, `null` if the indexable should be built.
* @param string $user_id The ID of the user that should or should not be excluded.
*/
return \apply_filters( 'wpseo_should_build_and_save_user_indexable', $exception, $user_id );
}
}