: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
public static function keyword_usage( $keyword, $post_id ) {
if ( empty( $keyword ) ) {
* The indexable repository.
* @var Indexable_Repository
$repository = YoastSEO()->classes->get( Indexable_Repository::class );
$post_ids = $repository->query()
->where( 'primary_focus_keyword', $keyword )
->where( 'object_type', 'post' )
->where_not_equal( 'object_id', $post_id )
->where_not_equal( 'post_status', 'trash' )
->limit( 2 ) // Limit to 2 results to save time and resources.
// Get object_id from each subarray in $post_ids.
$post_ids = ( is_array( $post_ids ) ) ? array_column( $post_ids, 'object_id' ) : [];
* If Premium is installed, get the additional keywords as well.
* We only check for the additional keywords if we've not already found two.
* In that case there's no use for an additional query as we already know
* that the keyword has been used multiple times before.
if ( count( $post_ids ) < 2 ) {
* Allows enhancing the array of posts' that share their focus keywords with the post's focus keywords.
* @param array $post_ids The array of posts' ids that share their related keywords with the post.
* @param string $keyword The keyword to search for.
* @param int $post_id The id of the post the keyword is associated to.
$post_ids = apply_filters( 'wpseo_posts_for_focus_keyword', $post_ids, $keyword, $post_id );
* Returns the post types for the given post ids.
* @param array $post_ids The post ids to get the post types for.
* @return array The post types.
public static function post_types_for_ids( $post_ids ) {
* The indexable repository.
* @var Indexable_Repository
$repository = YoastSEO()->classes->get( Indexable_Repository::class );
// Check if post ids is not empty.
if ( ! empty( $post_ids ) ) {
// Get the post subtypes for the posts that share the keyword.
$post_types = $repository->query()
->select( 'object_sub_type' )
->where_in( 'object_id', $post_ids )
// Get object_sub_type from each subarray in $post_ids.
$post_types = array_column( $post_types, 'object_sub_type' );
* Filter the schema article types.
public static function filter_schema_article_types() {
/** This filter is documented in inc/options/class-wpseo-option-titles.php */
self::$meta_fields['schema']['schema_article_type']['options'] = apply_filters( 'wpseo_schema_article_types', self::$meta_fields['schema']['schema_article_type']['options'] );