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 / integ / data / wpseo-meta.php

wpseo-meta.php in WPSSO Core – Complete Schema Markup and Meta Tags 22.7.0, at lib/integ/data/wpseo-meta.php

148 lines 4.6 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 2012-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 ( ! defined( 'WPSSO_PLUGINDIR' ) ) {
14
15 die( 'Do. Or do not. There is no try.' );
16 }
17
18 if ( ! class_exists( 'WpssoIntegDataAbstractSeoMeta' ) ) {
19
20 require_once WPSSO_PLUGINDIR . 'lib/integ/data/abstract/seo-meta.php';
21 }
22
23 /*
24 * Import Yoast SEO metadata.
25 */
26 if ( ! class_exists( 'WpssoIntegDataWpseoMeta' ) ) {
27
28 class WpssoIntegDataWpseoMeta extends WpssoIntegDataAbstractSeoMeta {
29
30 protected $plugin_avail_key = 'wpseo';
31
32 protected $opt_meta_keys = array(
33 'post' => array(
34 'primary_term_id' => '_yoast_wpseo_primary_%%post_primary_tax_slug%%',
35 'og_title' => '_yoast_wpseo_opengraph-title',
36 'og_desc' => '_yoast_wpseo_opengraph-description',
37 'og_img_id' => '_yoast_wpseo_opengraph-image-id',
38 'og_img_url' => '_yoast_wpseo_opengraph-image',
39 'seo_title' => '_yoast_wpseo_title',
40 'seo_desc' => '_yoast_wpseo_metadesc',
41 'tc_title' => '_yoast_wpseo_twitter-title',
42 'tc_desc' => '_yoast_wpseo_twitter-description',
43 'tc_sum_img_id' => '_yoast_wpseo_twitter-image-id',
44 'tc_sum_img_url' => '_yoast_wpseo_twitter-image',
45 'tc_lrg_img_id' => '_yoast_wpseo_twitter-image-id',
46 'tc_lrg_img_url' => '_yoast_wpseo_twitter-image',
47 'schema_title' => '_yoast_wpseo_title',
48 'schema_title_bc' => '_yoast_wpseo_bctitle',
49 'schema_desc' => '_yoast_wpseo_metadesc',
50 'schema_reading_mins' => '_yoast_wpseo_estimated-reading-time-minutes',
51 'canonical_url' => '_yoast_wpseo_canonical',
52 'robots_noindex' => '_yoast_wpseo_meta-robots-noindex',
53 ),
54 'term' => array(
55 'og_title' => 'wpseo_opengraph-title',
56 'og_desc' => 'wpseo_opengraph-description',
57 'og_img_id' => 'wpseo_opengraph-image-id',
58 'og_img_url' => 'wpseo_opengraph-image',
59 'seo_title' => 'wpseo_title',
60 'seo_desc' => 'wpseo_desc',
61 'tc_title' => 'wpseo_twitter-title',
62 'tc_desc' => 'wpseo_twitter-description',
63 'tc_sum_img_id' => 'wpseo_twitter-image-id',
64 'tc_sum_img_url' => 'wpseo_twitter-image',
65 'tc_lrg_img_id' => 'wpseo_twitter-image-id',
66 'tc_lrg_img_url' => 'wpseo_twitter-image',
67 'schema_title' => 'wpseo_title',
68 'schema_title_bc' => 'wpseo_bctitle',
69 'schema_desc' => 'wpseo_desc',
70 'canonical_url' => 'wpseo_canonical',
71 'robots_noindex' => 'wpseo_noindex',
72 ),
73 'user' => array(
74 'og_title' => 'wpseo_title',
75 'og_desc' => 'wpseo_metadesc',
76 'seo_title' => 'wpseo_title',
77 'seo_desc' => 'wpseo_metadesc',
78 'robots_noindex' => 'wpseo_noindex_author',
79 ),
80 );
81
82 public function filter_save_term_options( array $md_opts, $term_id, array $mod ) {
83
84 $this->cache_imported_meta[ 'term' ] = array();
85
86 $md_opts = $this->filter_get_term_options( $md_opts, $term_id, $mod );
87
88 if ( ! empty( $this->cache_imported_meta[ 'term' ] ) ) {
89
90 $tax_slug = $mod[ 'tax_slug' ];
91 $tax_meta = get_option( 'wpseo_taxonomy_meta' );
92
93 foreach( $this->cache_imported_meta[ 'term' ] as $meta_key => $bool ) {
94
95 unset( $tax_meta[ $tax_slug ][ $term_id ][ $meta_key ] );
96 }
97
98 update_option( 'wpseo_taxonomy_meta', $tax_meta );
99 }
100
101 return $md_opts;
102 }
103
104 public function filter_get_term_options( array $md_opts, $term_id, array $mod ) {
105
106 if ( $this->p->debug->enabled ) {
107
108 $this->p->debug->mark();
109 }
110
111 $tax_slug = $mod[ 'tax_slug' ];
112 $tax_meta = get_option( 'wpseo_taxonomy_meta' );
113
114 if ( empty( $tax_meta[ $tax_slug ][ $term_id ] ) ) {
115
116 if ( $this->p->debug->enabled ) {
117
118 $this->p->debug->log( 'exiting early: ' . $tax_slug . ' taxonomy meta for term id ' . $term_id . ' is empty' );
119 }
120
121 return $md_opts;
122 }
123
124 $term_opts = $tax_meta[ $tax_slug ][ $term_id ];
125
126 foreach ( $this->import_opt_keys as $opt_key => $bool ) {
127
128 if ( ! empty( $this->opt_meta_keys[ 'term' ][ $opt_key ] ) ) {
129
130 $meta_key = $this->opt_meta_keys[ 'term' ][ $opt_key ];
131
132 // Skip options that have a custom value. An empty string and 'none' are not custom values.
133 if ( isset( $md_opts[ $opt_key ] ) && '' !== $md_opts[ $opt_key ] && 'none' !== $md_opts[ $opt_key ] ) {
134
135 continue;
136
137 } elseif ( $this->add_mod_term_meta( $mod, $md_opts, $opt_key, $meta_key, $term_opts ) ) {
138
139 $this->cache_imported_meta[ 'term' ][ $meta_key ] = true;
140 }
141 }
142 }
143
144 return $md_opts;
145 }
146 }
147 }
148