=> 'title', 'metadesc' => 'description', 'bctitle' => 'breadcrumb_title', 'opengraph-title' => 'open_graph_title', 'opengraph-image' => 'open_graph_image', 'opengraph-image-id' => 'open_graph_image_id', 'opengraph-description' => 'open_graph_description', 'twitter-title' => 'twitter_title', 'twitter-image' => 'twitter_image', 'twitter-image-id' => 'twitter_image_id', 'twitter-description' => 'twitter_description', 'estimated-reading-time-minutes' => 'estimated_reading_time_minutes', ]; } /** * Retrieves the current value for the meta field. * * @param int $post_id The post ID to use. * @param string $meta_key Meta key to fetch. * * @return mixed The value of the indexable entry to use. */ protected function get_meta_value( $post_id, $meta_key ) { $value = WPSEO_Meta::get_value( $meta_key, $post_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 ) { if ( $indexable->object_sub_type === 'attachment' && $this->image->is_valid_attachment( $indexable->object_id ) ) { return [ 'image_id' => $indexable->object_id, 'source' => 'attachment-image', ]; } $featured_image_id = $this->image->get_featured_image_id( $indexable->object_id ); if ( $featured_image_id ) { return [ 'image_id' => $featured_image_id, 'source' => 'featured-image', ]; } $gallery_image = $this->image->get_gallery_image( $indexable->object_id ); if ( $gallery_image ) { return [ 'image' => $gallery_image, 'source' => 'gallery-image', ]; } $content_image = $this->image->get_post_content_image( $indexable->object_id ); if ( $content_image ) { return [ 'image' => $content_image, 'source' => 'first-content-image', ]; } return false; } /** * Gets the number of pages for a post. * * @param object $post The post object. * * @return int|null The number of pages or null if the post isn't paginated. */ protected function get_number_of_pages_for_post( $post ) { $number_of_pages = ( \substr_count( $post->post_content, '' ) + 1 ); if ( $number_of_pages <= 1 ) { return null; } return $number_of_pages; } /** * Checks whether an indexable should be built for this post. * * @param \WP_Post $post The post for which an indexable should be built. * * @return bool `true` if the post should be excluded from building, `false` if not. */ protected function should_exclude_post( $post ) { return $this->post_type_helper->is_excluded( $post->post_type ); } }