| 1 |
<?php |
| 2 |
/* |
| 3 |
* License: GPLv3 |
| 4 |
* License URI: https://www.gnu.org/licenses/gpl.txt |
| 5 |
* Copyright 2016-2026 Jean-Sebastien Morisset (https://wpsso.com/) |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
|
| 10 |
die( 'These aren\'t the droids you\'re looking for.' ); |
| 11 |
} |
| 12 |
|
| 13 |
if ( ! class_exists( 'WpssoJsonTypePlace' ) ) { |
| 14 |
|
| 15 |
class WpssoJsonTypePlace { |
| 16 |
|
| 17 |
private $p; // Wpsso class object. |
| 18 |
|
| 19 |
/* |
| 20 |
* Instantiated by Wpsso->init_json_filters(). |
| 21 |
*/ |
| 22 |
public function __construct( &$plugin ) { |
| 23 |
|
| 24 |
$this->p =& $plugin; |
| 25 |
|
| 26 |
if ( $this->p->debug->enabled ) { |
| 27 |
|
| 28 |
$this->p->debug->mark(); |
| 29 |
} |
| 30 |
|
| 31 |
$this->p->util->add_plugin_filters( $this, array( |
| 32 |
'json_data_https_schema_org_place' => 5, |
| 33 |
) ); |
| 34 |
} |
| 35 |
|
| 36 |
public function filter_json_data_https_schema_org_place( $json_data, $mod, $mt_og, $page_type_id, $is_main ) { |
| 37 |
|
| 38 |
if ( $this->p->debug->enabled ) { |
| 39 |
|
| 40 |
$this->p->debug->mark(); |
| 41 |
} |
| 42 |
|
| 43 |
/* |
| 44 |
* Possibly inherit the schema type. |
| 45 |
*/ |
| 46 |
if ( $this->p->debug->enabled ) { |
| 47 |
|
| 48 |
if ( ! empty( $json_data ) ) { |
| 49 |
|
| 50 |
$this->p->debug->log( 'possibly inherit the schema type' ); |
| 51 |
|
| 52 |
$this->p->debug->log_arr( 'json_data', $json_data ); |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
$json_ret = WpssoSchema::get_data_context( $json_data ); // Returns array() if no schema type found. |
| 57 |
|
| 58 |
if ( $this->p->debug->enabled ) { |
| 59 |
|
| 60 |
$this->p->debug->log_arr( 'json_ret', $json_ret ); |
| 61 |
} |
| 62 |
|
| 63 |
/* |
| 64 |
* Add the Place. |
| 65 |
*/ |
| 66 |
WpssoSchemaSingle::add_place_data( $json_ret, $mod, $place_id = null, $list_el = 'merge' ); |
| 67 |
|
| 68 |
/* |
| 69 |
* Add media. |
| 70 |
* |
| 71 |
* See https://schema.org/image as https://schema.org/ImageObject. |
| 72 |
* See https://schema.org/subjectOf as https://schema.org/VideoObject. |
| 73 |
*/ |
| 74 |
if ( $this->p->debug->enabled ) { |
| 75 |
|
| 76 |
$this->p->debug->log( 'adding image and subjectOf properties for place' ); |
| 77 |
} |
| 78 |
|
| 79 |
WpssoSchema::add_media_data( $json_ret, $mod, $mt_og, $size_names = 'schema', $add_video = 'subjectOf' ); |
| 80 |
|
| 81 |
if ( $this->p->debug->enabled ) { |
| 82 |
|
| 83 |
$this->p->debug->log( 'merging json_data and json_ret arrays' ); |
| 84 |
|
| 85 |
$this->p->debug->log_arr( 'json_data', $json_data ); |
| 86 |
$this->p->debug->log_arr( 'json_ret', $json_ret ); |
| 87 |
} |
| 88 |
|
| 89 |
return WpssoSchema::return_data_from_filter( $json_data, $json_ret, $is_main ); |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
|