| @@ -9,8 +9,11 @@ | ||
| 9 | 9 | declare(strict_types=1); |
| 10 | 10 | |
| 11 | 11 | namespace Parsely\Metadata; |
| 12 | 12 | |
| 13 | +use Parsely\Parsely; | |
| 14 | +use WP_Post; | |
| 15 | + | |
| 13 | 16 | /** |
| 14 | 17 | * Implements abstract Metadata Builder class to generate the metadata array |
| 15 | 18 | * for a front page. |
| 16 | 19 | * |
| @@ -17,8 +20,30 @@ | ||
| 17 | 20 | * @since 3.4.0 |
| 18 | 21 | */ |
| 19 | 22 | class Front_Page_Builder extends Metadata_Builder { |
| 20 | 23 | /** |
| 24 | + * Post object to generate the metadata for. | |
| 25 | + * | |
| 26 | + * @since 3.20.7 | |
| 27 | + * | |
| 28 | + * @var WP_Post | |
| 29 | + */ | |
| 30 | + private $post; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * Constructor. | |
| 34 | + * | |
| 35 | + * @since 3.20.7 | |
| 36 | + * | |
| 37 | + * @param Parsely $parsely Instance of Parsely class. | |
| 38 | + * @param WP_Post $post Post object to generate the metadata for. | |
| 39 | + */ | |
| 40 | + public function __construct( Parsely $parsely, WP_Post $post ) { | |
| 41 | + parent::__construct( $parsely ); | |
| 42 | + $this->post = $post; | |
| 43 | + } | |
| 44 | + | |
| 45 | + /** | |
| 21 | 46 | * Generates the metadata object by calling the build_* methods and |
| 22 | 47 | * returns the value. |
| 23 | 48 | * |
| 24 | 49 | * @since 3.4.0 |
| @@ -28,8 +53,19 @@ | ||
| 28 | 53 | public function get_metadata(): array { |
| 29 | 54 | $this->build_basic(); |
| 30 | 55 | $this->build_headline(); |
| 31 | 56 | $this->build_url(); |
| 57 | + | |
| 58 | + if ( true === $this->parsely->get_options()['full_metadata_in_non_posts'] ) { | |
| 59 | + $this->build_main_entity( 'non-post' ); | |
| 60 | + $this->build_thumbnail_url( $this->post ); | |
| 61 | + $this->build_image( $this->post ); | |
| 62 | + $this->build_article_section( $this->post ); | |
| 63 | + $this->build_author( $this->post ); | |
| 64 | + $this->build_publisher(); | |
| 65 | + $this->build_keywords( $this->post ); | |
| 66 | + $this->build_metadata_post_times( $this->post ); | |
| 67 | + } | |
| 32 | 68 | |
| 33 | 69 | return $this->metadata; |
| 34 | 70 | } |
| 35 | 71 | |