PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 19.0
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v19.0
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 / schema-presenter.php

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

63 lines 1.4 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_Utils;
6
7 /**
8 * Presenter class for the schema object.
9 */
10 class Schema_Presenter extends Abstract_Indexable_Presenter {
11
12 /**
13 * The tag key name.
14 *
15 * @var string
16 */
17 protected $key = 'schema';
18
19 /**
20 * Returns the schema output.
21 *
22 * @return string The schema tag.
23 */
24 public function present() {
25 $deprecated_data = [
26 '_deprecated' => 'Please use the "wpseo_schema_*" filters to extend the Yoast SEO schema data - see the WPSEO_Schema class.',
27 ];
28
29 /**
30 * Filter: 'wpseo_json_ld_output' - Allows disabling Yoast's schema output entirely.
31 *
32 * @api mixed If false or an empty array is returned, disable our output.
33 */
34 $return = \apply_filters( 'wpseo_json_ld_output', $deprecated_data, '' );
35 if ( $return === [] || $return === false ) {
36 return '';
37 }
38
39 /**
40 * Action: 'wpseo_json_ld' - Output Schema before the main schema from Yoast SEO is output.
41 */
42 \do_action( 'wpseo_json_ld' );
43
44 $schema = $this->get();
45 if ( \is_array( $schema ) ) {
46 $output = WPSEO_Utils::format_json_encode( $schema );
47 $output = \str_replace( "\n", \PHP_EOL . "\t", $output );
48 return '<script type="application/ld+json" class="yoast-schema-graph">' . $output . '</script>';
49 }
50
51 return '';
52 }
53
54 /**
55 * Gets the raw value of a presentation.
56 *
57 * @return array The raw value.
58 */
59 public function get() {
60 return $this->presentation->schema;
61 }
62 }
63