PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.2
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.2
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / presenters / abstract-indexable-presenter.php

abstract-indexable-presenter.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.2, at src/presenters/abstract-indexable-presenter.php

81 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Presenters;
4
5 use WPSEO_Replace_Vars;
6 use Yoast\WP\SEO\Presentations\Indexable_Presentation;
7 use Yoast\WP\SEO\Surfaces\Helpers_Surface;
8
9 /**
10 * Abstract presenter class for indexable presentations.
11 */
12 abstract class Abstract_Indexable_Presenter extends Abstract_Presenter {
13
14 /**
15 * The WPSEO Replace Vars object.
16 *
17 * @var WPSEO_Replace_Vars
18 */
19 public $replace_vars;
20
21 /**
22 * The indexable presentation.
23 *
24 * @var Indexable_Presentation
25 */
26 public $presentation;
27
28 /**
29 * The helpers surface
30 *
31 * @var Helpers_Surface
32 */
33 public $helpers;
34
35 /**
36 * The tag key name.
37 *
38 * @var string
39 */
40 protected $key = 'NO KEY PROVIDED';
41
42 /**
43 * Gets the raw value of a presentation.
44 *
45 * @return string|array The raw value.
46 */
47 abstract public function get();
48
49 /**
50 * Transforms an indexable presenter's key to a json safe key string.
51 *
52 * @return string|null
53 */
54 public function escape_key() {
55 if ( $this->key === 'NO KEY PROVIDED' ) {
56 return null;
57 }
58 return \str_replace( [ ':', ' ', '-' ], '_', $this->key );
59 }
60
61 /**
62 * Returns the metafield's property key.
63 *
64 * @return string The property key.
65 */
66 public function get_key() {
67 return $this->key;
68 }
69
70 /**
71 * Replace replacement variables in a string.
72 *
73 * @param string $replacevar_string The string with replacement variables.
74 *
75 * @return string The string with replacement variables replaced.
76 */
77 protected function replace_vars( $replacevar_string ) {
78 return $this->replace_vars->replace( $replacevar_string, $this->presentation->source );
79 }
80 }
81