PluginProbe
WPSSO Core – Complete Schema Markup and Meta Tags / 22.7.0
WPSSO Core – Complete Schema Markup and Meta Tags v22.7.0
22.7.0 22.6.1 22.6.0 22.5.3 22.5.2 22.5.1 22.4.0 22.3.0 22.2.1 22.2.0 22.1.3 22.1.2 22.1.1 22.1.0 22.0.0 21.13.3 21.13.2 trunk 21.13.1
wpsso / lib / json / type / softwareapplication.php

softwareapplication.php in WPSSO Core – Complete Schema Markup and Meta Tags 22.7.0, at lib/json/type/softwareapplication.php

118 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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( 'WpssoJsonTypeSoftwareApplication' ) ) {
14
15 class WpssoJsonTypeSoftwareApplication {
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_softwareapplication' => 5,
33 ) );
34 }
35
36 /*
37 * Note that SoftwareApplication is a sub-type of CreativeWork, which includes image and video properties.
38 */
39 public function filter_json_data_https_schema_org_softwareapplication( $json_data, $mod, $mt_og, $page_type_id, $is_main ) {
40
41 if ( $this->p->debug->enabled ) {
42
43 $this->p->debug->mark();
44 }
45
46 /*
47 * Maybe remove values related to the WordPress post object.
48 */
49 unset( $json_data[ 'author' ] );
50 unset( $json_data[ 'contributor' ] );
51 unset( $json_data[ 'dateCreated' ] );
52 unset( $json_data[ 'datePublished' ] );
53 unset( $json_data[ 'dateModified' ] );
54
55 $json_ret = array();
56 $md_opts = array();
57
58 WpssoSchema::add_type_opts_md_pad( $md_opts, $mod );
59
60 /*
61 * See https://schema.org/applicationCategory.
62 */
63 if ( ! empty( $md_opts[ 'schema_software_app_cat' ] ) ) {
64
65 $json_ret[ 'applicationCategory' ] = (string) $md_opts[ 'schema_software_app_cat' ];
66 }
67
68 /*
69 * See https://schema.org/operatingSystem.
70 */
71 if ( ! empty( $md_opts[ 'schema_software_app_os' ] ) ) {
72
73 $json_ret[ 'operatingSystem' ] = (string) $md_opts[ 'schema_software_app_os' ];
74 }
75
76 /*
77 * See https://schema.org/downloadUrl.
78 */
79 if ( ! empty( $md_opts[ 'schema_software_app_dl_url' ] ) ) {
80
81 $json_ret[ 'downloadUrl' ] = (string) $md_opts[ 'schema_software_app_dl_url' ];
82 }
83
84 /*
85 * Prevent recursion for an itemOffered within a Schema Offer.
86 */
87 static $local_recursion = false;
88
89 if ( ! $local_recursion ) {
90
91 $local_recursion = true;
92
93 if ( empty( $mt_og[ 'product:offers' ] ) ) {
94
95 $json_ret[ 'offers' ] = WpssoSchemaSingle::get_offer_data_mt( $mod, $mt_og, $def_type_id = 'offer' );
96
97 } elseif ( is_array( $mt_og[ 'product:offers' ] ) ) {
98
99 if ( empty( $this->p->options[ 'schema_def_product_aggr_offers' ] ) ) {
100
101 WpssoSchema::add_offers_data_mt( $json_ret, $mt_og[ 'product:offers' ] );
102
103 } else WpssoSchema::add_offers_aggregate_data_mt( $json_ret, $mt_og[ 'product:offers' ] );
104 }
105
106 $local_recursion = false;
107 }
108
109 if ( $this->p->debug->enabled ) {
110
111 $this->p->debug->log( 'merging json_data and json_ret arrays' );
112 }
113
114 return WpssoSchema::return_data_from_filter( $json_data, $json_ret, $is_main );
115 }
116 }
117 }
118