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
← All changes | lib/integ/data/seoframework-meta.php +132 -0 22.2.022.7.0 View file →
@@ -1,0 +1,132 @@
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 The SEO Framework metadata.
25 + */
26 +if ( ! class_exists( 'WpssoIntegDataSeoframeworkMeta' ) ) {
27 +
28 + class WpssoIntegDataSeoframeworkMeta extends WpssoIntegDataAbstractSeoMeta {
29 +
30 + protected $plugin_avail_key = 'seoframework';
31 +
32 + protected $opt_meta_keys = array(
33 + 'post' => array(
34 + 'primary_term_id' => '_primary_term_category',
35 + 'seo_title' => '_genesis_title',
36 + 'seo_desc' => '_genesis_description',
37 + 'og_title' => '_open_graph_title',
38 + 'og_desc' => '_open_graph_description',
39 + 'og_img_id' => '_social_image_id',
40 + 'og_img_url' => '_social_image_url',
41 + 'schema_title' => '_genesis_title',
42 + 'schema_desc' => '_genesis_description',
43 + 'tc_title' => '_twitter_title',
44 + 'tc_desc' => '_twitter_description',
45 + 'canonical_url' => '_genesis_canonical_uri',
46 + 'redirect_url' => 'redirect',
47 + 'robots_noarchive' => '_genesis_noarchive',
48 + 'robots_nofollow' => '_genesis_nofollow',
49 + 'robots_noindex' => '_genesis_noindex',
50 + ),
51 + 'term' => array(
52 + 'seo_title' => 'doctitle',
53 + 'seo_desc' => 'description',
54 + 'og_title' => 'og_title',
55 + 'og_desc' => 'og_description',
56 + 'og_img_id' => 'social_image_id',
57 + 'og_img_url' => 'social_image_url',
58 + 'schema_title' => 'doctitle',
59 + 'schema_desc' => 'description',
60 + 'tc_title' => 'tw_title',
61 + 'tc_desc' => 'tw_description',
62 + 'canonical_url' => 'canonical',
63 + 'redirect_url' => 'redirect',
64 + 'robots_noarchive' => 'noarchive',
65 + 'robots_nofollow' => 'nofollow',
66 + 'robots_noindex' => 'noindex',
67 + ),
68 + 'user' => array(),
69 + );
70 +
71 + public function filter_save_term_options( array $md_opts, $term_id, array $mod ) {
72 +
73 + $this->cache_imported_meta[ 'term' ] = array();
74 +
75 + $md_opts = $this->filter_get_term_options( $md_opts, $term_id, $mod );
76 +
77 + if ( ! empty( $this->cache_imported_meta[ 'term' ] ) ) {
78 +
79 + $term_opts = get_metadata( 'term', $term_id, 'autodescription-term-settings', $single = true );
80 +
81 + foreach( $this->cache_imported_meta[ 'term' ] as $meta_key => $bool ) {
82 +
83 + unset( $term_opts[ $meta_key ] );
84 + }
85 +
86 + update_metadata( 'term', $term_id, 'autodescription-term-settings', $term_opts );
87 + }
88 +
89 + return $md_opts;
90 + }
91 +
92 + public function filter_get_term_options( array $md_opts, $term_id, array $mod ) {
93 +
94 + if ( $this->p->debug->enabled ) {
95 +
96 + $this->p->debug->mark();
97 + }
98 +
99 + $term_opts = get_metadata( 'term', $term_id, 'autodescription-term-settings', $single = true );
100 +
101 + if ( empty( $term_opts ) ) {
102 +
103 + if ( $this->p->debug->enabled ) {
104 +
105 + $this->p->debug->log( 'exiting early: autodescription term meta is empty' );
106 + }
107 +
108 + return $md_opts;
109 + }
110 +
111 + foreach ( $this->import_opt_keys as $opt_key => $bool ) {
112 +
113 + if ( ! empty( $this->opt_meta_keys[ 'term' ][ $opt_key ] ) ) {
114 +
115 + $meta_key = $this->opt_meta_keys[ 'term' ][ $opt_key ];
116 +
117 + // Skip options that have a custom value. An empty string and 'none' are not custom values.
118 + if ( isset( $md_opts[ $opt_key ] ) && '' !== $md_opts[ $opt_key ] && 'none' !== $md_opts[ $opt_key ] ) {
119 +
120 + continue;
121 +
122 + } elseif ( $this->add_mod_term_meta( $mod, $md_opts, $opt_key, $meta_key, $term_opts ) ) {
123 +
124 + $this->cache_imported_meta[ 'term' ][ $meta_key ] = true;
125 + }
126 + }
127 + }
128 +
129 + return $md_opts;
130 + }
131 + }
132 +}