@@ -21,44 +21,44 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Jsonld_Adapter { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var Wordlift_Jsonld_Service |
|
| 26 | - */ |
|
| 27 | - private $jsonld_service; |
|
| 24 | + /** |
|
| 25 | + * @var Wordlift_Jsonld_Service |
|
| 26 | + */ |
|
| 27 | + private $jsonld_service; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Jsonld_Adapter constructor. |
|
| 31 | - * |
|
| 32 | - * @param \Wordlift_Jsonld_Service $jsonld_service |
|
| 33 | - */ |
|
| 34 | - public function __construct( $jsonld_service ) { |
|
| 29 | + /** |
|
| 30 | + * Jsonld_Adapter constructor. |
|
| 31 | + * |
|
| 32 | + * @param \Wordlift_Jsonld_Service $jsonld_service |
|
| 33 | + */ |
|
| 34 | + public function __construct( $jsonld_service ) { |
|
| 35 | 35 | |
| 36 | - $this->jsonld_service = $jsonld_service; |
|
| 36 | + $this->jsonld_service = $jsonld_service; |
|
| 37 | 37 | |
| 38 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
| 39 | - add_action( 'amp_post_template_head', array( $this, 'wp_head' ) ); |
|
| 38 | + add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
| 39 | + add_action( 'amp_post_template_head', array( $this, 'wp_head' ) ); |
|
| 40 | 40 | |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function wp_head() { |
|
| 43 | + public function wp_head() { |
|
| 44 | 44 | |
| 45 | - // Bail out if `wl_jsonld_enabled` isn't enabled. |
|
| 46 | - if ( ! apply_filters( 'wl_jsonld_enabled', true ) ) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 45 | + // Bail out if `wl_jsonld_enabled` isn't enabled. |
|
| 46 | + if ( ! apply_filters( 'wl_jsonld_enabled', true ) ) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - // Determine whether this is the home page or whether we're displaying a single post. |
|
| 51 | - $is_homepage = is_home() || is_front_page(); |
|
| 52 | - $post_id = is_singular() ? get_the_ID() : null; |
|
| 50 | + // Determine whether this is the home page or whether we're displaying a single post. |
|
| 51 | + $is_homepage = is_home() || is_front_page(); |
|
| 52 | + $post_id = is_singular() ? get_the_ID() : null; |
|
| 53 | 53 | |
| 54 | - // Get the JSON-LD. |
|
| 55 | - $jsonld = wp_json_encode( $this->jsonld_service->get_jsonld( $is_homepage, $post_id, Jsonld_Context_Enum::PAGE ) ); |
|
| 56 | - // Finally print the JSON-LD out. |
|
| 57 | - $jsonld_post_html_output = '<script type="application/ld+json" id="wl-jsonld">' . $jsonld . '</script>'; |
|
| 58 | - $jsonld_post_html_output = apply_filters( 'wl_jsonld_post_html_output', $jsonld_post_html_output, $post_id ); |
|
| 54 | + // Get the JSON-LD. |
|
| 55 | + $jsonld = wp_json_encode( $this->jsonld_service->get_jsonld( $is_homepage, $post_id, Jsonld_Context_Enum::PAGE ) ); |
|
| 56 | + // Finally print the JSON-LD out. |
|
| 57 | + $jsonld_post_html_output = '<script type="application/ld+json" id="wl-jsonld">' . $jsonld . '</script>'; |
|
| 58 | + $jsonld_post_html_output = apply_filters( 'wl_jsonld_post_html_output', $jsonld_post_html_output, $post_id ); |
|
| 59 | 59 | |
| 60 | - echo $jsonld_post_html_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 60 | + echo $jsonld_post_html_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 61 | 61 | |
| 62 | - } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | } |
@@ -31,19 +31,19 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @param \Wordlift_Jsonld_Service $jsonld_service |
| 33 | 33 | */ |
| 34 | - public function __construct( $jsonld_service ) { |
|
| 34 | + public function __construct($jsonld_service) { |
|
| 35 | 35 | |
| 36 | 36 | $this->jsonld_service = $jsonld_service; |
| 37 | 37 | |
| 38 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
| 39 | - add_action( 'amp_post_template_head', array( $this, 'wp_head' ) ); |
|
| 38 | + add_action('wp_head', array($this, 'wp_head')); |
|
| 39 | + add_action('amp_post_template_head', array($this, 'wp_head')); |
|
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | public function wp_head() { |
| 44 | 44 | |
| 45 | 45 | // Bail out if `wl_jsonld_enabled` isn't enabled. |
| 46 | - if ( ! apply_filters( 'wl_jsonld_enabled', true ) ) { |
|
| 46 | + if ( ! apply_filters('wl_jsonld_enabled', true)) { |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | $post_id = is_singular() ? get_the_ID() : null; |
| 53 | 53 | |
| 54 | 54 | // Get the JSON-LD. |
| 55 | - $jsonld = wp_json_encode( $this->jsonld_service->get_jsonld( $is_homepage, $post_id, Jsonld_Context_Enum::PAGE ) ); |
|
| 55 | + $jsonld = wp_json_encode($this->jsonld_service->get_jsonld($is_homepage, $post_id, Jsonld_Context_Enum::PAGE)); |
|
| 56 | 56 | // Finally print the JSON-LD out. |
| 57 | - $jsonld_post_html_output = '<script type="application/ld+json" id="wl-jsonld">' . $jsonld . '</script>'; |
|
| 58 | - $jsonld_post_html_output = apply_filters( 'wl_jsonld_post_html_output', $jsonld_post_html_output, $post_id ); |
|
| 57 | + $jsonld_post_html_output = '<script type="application/ld+json" id="wl-jsonld">'.$jsonld.'</script>'; |
|
| 58 | + $jsonld_post_html_output = apply_filters('wl_jsonld_post_html_output', $jsonld_post_html_output, $post_id); |
|
| 59 | 59 | |
| 60 | 60 | echo $jsonld_post_html_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 61 | 61 | |