PluginProbe
Parse.ly / 3.23.5
Parse.ly v3.23.5
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
wp-parsely / src / Metadata / class-front-page-builder.php

class-front-page-builder.php in Parse.ly 3.23.5, at src/Metadata/class-front-page-builder.php

90 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Front Page Metadata Builder class
4 *
5 * @package Parsely
6 * @since 3.4.0
7 */
8
9 declare(strict_types=1);
10
11 namespace Parsely\Metadata;
12
13 use Parsely\Parsely;
14 use WP_Post;
15
16 /**
17 * Implements abstract Metadata Builder class to generate the metadata array
18 * for a front page.
19 *
20 * @since 3.4.0
21 */
22 class Front_Page_Builder extends Metadata_Builder {
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 /**
46 * Generates the metadata object by calling the build_* methods and
47 * returns the value.
48 *
49 * @since 3.4.0
50 *
51 * @return array<string, mixed>
52 */
53 public function get_metadata(): array {
54 $this->build_basic();
55 $this->build_headline();
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 }
68
69 return $this->metadata;
70 }
71
72 /**
73 * Populates the `headline` field in the metadata object.
74 *
75 * @since 3.4.0
76 */
77 private function build_headline(): void {
78 $this->metadata['headline'] = $this->clean_value( get_bloginfo( 'name', 'raw' ) );
79 }
80
81 /**
82 * Populates the `url` field in the metadata object by getting the home URL.
83 *
84 * @since 3.4.0
85 */
86 protected function build_url(): void {
87 $this->metadata['url'] = home_url();
88 }
89 }
90