PluginProbe
Parse.ly / 3.8.1
Parse.ly v3.8.1
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-date-builder.php

class-date-builder.php in Parse.ly 3.8.1, at src/Metadata/class-date-builder.php

63 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Date 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 function Parsely\Utils\get_date_format;
14 use function Parsely\Utils\get_time_format;
15
16 /**
17 * Implements abstract Metadata Builder class to generate the metadata array
18 * for a date page.
19 *
20 * @since 3.4.0
21 */
22 class Date_Builder extends Metadata_Builder {
23 /**
24 * Generates the metadata object by calling the build_* methods and
25 * returns the value.
26 *
27 * @since 3.4.0
28 *
29 * @return array<string, mixed>
30 */
31 public function get_metadata(): array {
32 $this->build_basic();
33 $this->build_headline();
34 $this->build_url();
35
36 return $this->metadata;
37 }
38
39 /**
40 * Populates the `headline` field in the metadata object.
41 *
42 * @since 3.4.0
43 */
44 private function build_headline(): void {
45 $site_date_format = get_date_format();
46
47 if ( is_year() ) {
48 /* translators: %s: Archive year */
49 $this->metadata['headline'] = sprintf( __( 'Yearly Archive - %s', 'wp-parsely' ), get_the_time( 'Y' ) );
50 } elseif ( is_month() ) {
51 /* translators: %s: Archive month, formatted as F, Y */
52 $this->metadata['headline'] = sprintf( __( 'Monthly Archive - %s', 'wp-parsely' ), get_the_time( 'F, Y' ) );
53 } elseif ( is_day() ) {
54 /* translators: %s: Archive day, formatted as F jS, Y */
55 $this->metadata['headline'] = sprintf( __( 'Daily Archive - %s', 'wp-parsely' ), get_the_time( $site_date_format ) );
56 } elseif ( is_time() ) {
57 $site_time_format = get_time_format();
58 /* translators: %s: Archive time, formatted as F jS g:i:s A */
59 $this->metadata['headline'] = sprintf( __( 'Hourly, Minutely, or Secondly Archive - %s', 'wp-parsely' ), get_the_time( "{$site_date_format} {$site_time_format}" ) );
60 }
61 }
62 }
63