| 1 |
<?php |
| 2 |
/** |
| 3 |
* Tag 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 |
/** |
| 14 |
* Implements abstract Metadata Builder class to generate the metadata array |
| 15 |
* for a tag page. |
| 16 |
* |
| 17 |
* @since 3.4.0 |
| 18 |
*/ |
| 19 |
class Tag_Builder extends Metadata_Builder { |
| 20 |
/** |
| 21 |
* Generates the metadata object by calling the build_* methods and |
| 22 |
* returns the value. |
| 23 |
* |
| 24 |
* @since 3.4.0 |
| 25 |
* |
| 26 |
* @return array<string, mixed> |
| 27 |
*/ |
| 28 |
public function get_metadata(): array { |
| 29 |
$this->build_basic(); |
| 30 |
$this->build_headline(); |
| 31 |
$this->build_url(); |
| 32 |
|
| 33 |
return $this->metadata; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Populates the `headline` field in the metadata object. |
| 38 |
* |
| 39 |
* @since 3.4.0 |
| 40 |
*/ |
| 41 |
private function build_headline(): void { |
| 42 |
$tag = single_tag_title( '', false ); |
| 43 |
if ( empty( $tag ) ) { |
| 44 |
$tag = single_term_title( '', false ); |
| 45 |
} |
| 46 |
/* translators: %s: Tag name */ |
| 47 |
$this->metadata['headline'] = $this->clean_value( sprintf( __( 'Tagged - %s', 'wp-parsely' ), $tag ) ); |
| 48 |
} |
| 49 |
} |
| 50 |
|