PluginProbe ʕ •ᴥ•ʔ
Meta Tag Manager / 3.3
Meta Tag Manager v3.3
trunk 0.2 0.3 0.4 0.5 1.0 1.1 1.2 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.3 3.0 3.0.2 3.1 3.2 3.3
meta-tag-manager / classes / schema-admin.php
meta-tag-manager / classes Last commit date
open-graph-admin.php 4 years ago open-graph.php 4 years ago schema-admin.php 4 years ago schema.php 4 years ago verify-sites-admin.php 4 years ago verify-sites.php 4 years ago
schema-admin.php
54 lines
1 <?php
2 namespace Meta_Tag_Manager;
3
4 class Schema_Admin {
5 public static function get_post(){
6 $schema = Schema::get_options(true);
7 $schema['enabled'] = !empty($_REQUEST['mtm_schema_enabled']);
8 if( !$schema['enabled'] ) return $schema;
9 if( !empty($_REQUEST['mtm_schema_site_type']) ) $schema['type'] = sanitize_text_field($_REQUEST['mtm_schema_site_type']);
10 if( empty($schema['type']) ){
11 global $MTM_Notices; /* @var \Meta_Tag_Manager\Notices $MTM_Notices */
12 $MTM_Notices->add( sprintf(esc_html__('You must select a value in the %s field in the %s tab in order for schema markup to show up on your homepage.', 'meta-tag-manager'), '<code>'.esc_html__('This website represents a', 'meta-tag-manager').'</code>', '<code>'.esc_html__('Structured Data (Schema)', 'meta-tag-manager').'</code>'), 'errors', true );
13 }
14 if( !empty($_REQUEST['mtm_schema_site_logo']) ) $schema['logo'] = absint($_REQUEST['mtm_schema_site_logo']);
15 if( $schema['type'] == 'Person' ){
16 if( !empty($_REQUEST['mtm_schema_person_name']) ) $schema['name'] = sanitize_text_field($_REQUEST['mtm_schema_person_name']);
17 }elseif( $schema['type'] == 'Organization' ) {
18 if( !empty($_REQUEST['mtm_schema_organization_name']) ) $schema['name'] = sanitize_text_field($_REQUEST['mtm_schema_organization_name']);
19 if( !empty($_REQUEST['mtm_schema_site_type_organization']) ) $schema['Organization']['type'] = sanitize_text_field($_REQUEST['mtm_schema_site_type_organization']);
20 if( !empty($_REQUEST['mtm_schema_site_type_organization_specific_'. $schema['Organization']['type']]) ) {
21 $schema['Organization']['subtype'] = sanitize_text_field($_REQUEST['mtm_schema_site_type_organization_specific_' . $schema['Organization']['type']]);
22 }else {
23 $schema['Organization']['subtype'] = $schema['Organization']['type'];
24 }
25 }
26 $schema['Contact']['enabled'] = !empty($_REQUEST['mtm_schema_contact']);
27 if( $schema['Contact']['enabled'] ) {
28 if( !empty($_REQUEST['mtm_schema_contact_name']) ) $schema['Contact']['name'] = sanitize_text_field($_REQUEST['mtm_schema_contact_name']);
29 if( !empty($_REQUEST['mtm_schema_contact_page']) ) {
30 $schema['Contact']['url'] = absint($_REQUEST['mtm_schema_contact_page']);
31 }elseif( !empty($_REQUEST['mtm_schema_contact_url']) ) {
32 $schema['Contact']['url'] = esc_url_raw($_REQUEST['mtm_schema_contact_url']);
33 }
34 if( !empty($_REQUEST['mtm_schema_contact_telephone']) ) $schema['Contact']['telephone'] = sanitize_text_field($_REQUEST['mtm_schema_contact_telephone']);
35 if( !empty($_REQUEST['mtm_schema_contact_email']) ) $schema['Contact']['email'] = sanitize_email($_REQUEST['mtm_schema_contact_email']);
36 }
37 if( isset($_REQUEST['mtm_schema_sitelinks_menu']) ) $schema['sitelinks']['menu'] = absint($_REQUEST['mtm_schema_sitelinks_menu']);
38 if( !empty($_REQUEST['mtm_schema_sitelinks_search']) ) $schema['sitelinks']['search'] = absint($_REQUEST['mtm_schema_sitelinks_search']);
39 if( !empty($_REQUEST['mtm_schema_profiles']) && is_array($_REQUEST['mtm_schema_profiles']) ){
40 $schema['profiles'] = array();
41 foreach( $_REQUEST['mtm_schema_profiles'] as $k => $profile ){
42 if( !empty($profile) && !in_array($profile, $schema['profiles']) ){
43 if( is_numeric($k) ){
44 $schema['profiles'][] = esc_url_raw($profile);
45 }else{
46 $k = sanitize_key($k);
47 $schema['profiles'][$k] = esc_url_raw($profile);
48 }
49 }
50 }
51 }
52 return $schema;
53 }
54 }