Version Description
- (Vendors) Updated doc.
- (Configs) Updated
rank-math-seo.json
file. - (Core/WPGlobus) Updated doc.
- (Core/WPGlobus_WP) Added
is_rest_api_request
function. - (Core/Builders) Added: builder attributes.
- (Core/Meta) Added: support term meta data.
- (Core/Config) Added: support REST API requests.
- (Builder/Config) Set builder language for REST API requests.
- (Vendor/Config) Added: handling term meta fields.
- (Vendor/Yoast) Filter taxonomy term name in the
Schema Generator
. - (Vendor/RankMathSEO) Don't check post IDs.
- (Builders/RankMathSEO) Added: support multilingual columns on
edit.php
page. - (Builders/RankMathSEO) Added: support for the REST API requests.
Download this release
Release Info
Developer | tivnet |
Plugin | WPGlobus – Multilingual Everything! |
Version | 2.8.9 |
Comparing to | |
See all releases |
Code changes from version 2.8.8 to 2.8.9
- configs/rank-math-seo.json +12 -5
- data/wpglobus-product-info.json +1 -1
- includes/admin/meta/class-wpglobus-meta.php +235 -5
- includes/builders/class-wpglobus-builders.php +3 -2
- includes/builders/class-wpglobus-config-builder.php +10 -3
- includes/builders/rank_math_seo/class-wpglobus-builder-rank_math_seo.php +54 -3
- includes/builders/rank_math_seo/class-wpglobus-rank_math_seo-functions.php +70 -14
- includes/class-wpglobus-config-vendor.php +123 -21
- includes/class-wpglobus-config.php +7 -4
- includes/class-wpglobus-wp.php +28 -2
- includes/class-wpglobus.php +3 -0
- includes/vendor/rank-math-seo/class-wpglobus-vendor-rank_math_seo.php +105 -103
- includes/vendor/wpglobus-vendors.php +3 -0
- includes/vendor/yoast-seo/class-wpglobus-yoastseo140.php +10 -1
- readme.txt +19 -0
- wpglobus.php +2 -2
configs/rank-math-seo.json
CHANGED
@@ -2,13 +2,20 @@
|
|
2 |
"post_meta_fields": {
|
3 |
"*":{"file":"vendor/rank-math-seo/class-wpglobus-vendor-rank_math_seo.php","class":"WPGlobus_Vendor_RankMathSEO"}
|
4 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
"post_ml_fields": {
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
9 |
},
|
10 |
"wp_options": {
|
11 |
-
|
12 |
-
|
13 |
}
|
14 |
}
|
2 |
"post_meta_fields": {
|
3 |
"*":{"file":"vendor/rank-math-seo/class-wpglobus-vendor-rank_math_seo.php","class":"WPGlobus_Vendor_RankMathSEO"}
|
4 |
},
|
5 |
+
"term_meta_fields": {
|
6 |
+
"rank_math_description": {},
|
7 |
+
"rank_math_seo_score": {},
|
8 |
+
"rank_math_title": {},
|
9 |
+
"rank_math_focus_keyword": {}
|
10 |
+
},
|
11 |
"post_ml_fields": {
|
12 |
+
"rank_math_title": {},
|
13 |
+
"rank_math_description": {},
|
14 |
+
"rank_math_focus_keyword": {},
|
15 |
+
"rank_math_seo_score": {}
|
16 |
},
|
17 |
"wp_options": {
|
18 |
+
"blogname": {},
|
19 |
+
"blogdescription": null
|
20 |
}
|
21 |
}
|
data/wpglobus-product-info.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"multilingual-woocommerce-nets-netaxept":{"title":"{:en}Multilingual WooCommerce Nets Netaxept{:}{:ru}\u041c\u0443\u043b\u044c\u0442\u0438\u044f\u0437\u044b\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce Nets Netaxept{:}","_api_new_version":"1.0.3","_api_tested_up_to":"4.9.8"},"wpglobus-multi-currency":{"title":"{:en}Multi-Currency for WooCommerce{:}{:ru}WPGlobus - \u041c\u0443\u043b\u044c\u0442\u0438\u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce{:}","_api_new_version":"1.1.1","_api_tested_up_to":"4.9.4"},"wpglobus-mobile-menu":{"title":"{:en}WPGlobus Mobile Menu{:}{:ru}WPGlobus Mobile Menu{:}","_api_new_version":"2.2.0","_api_tested_up_to":"5.6"},"wpglobus-for-ultimate-member":{"title":"{:en}WPGlobus for Ultimate Member{:}{:ru}WPGlobus \u0434\u043b\u044f \u043f\u043b\u0430\u0433\u0438\u043d\u0430 Ultimate Member{:}","_api_new_version":"1.1.0","_api_tested_up_to":"5.6"},"wpglobus-menu-visibility":{"title":"WPGlobus Menu Visibility","_api_new_version":"2.0.0","_api_tested_up_to":"5.6"},"wpglobus-for-bridge-theme":{"title":"{:en}WPGlobus for the \"Bridge\" theme{:}{:ru}WPGlobus \u0434\u043b\u044f \u0442\u0435\u043c\u044b Bridge{:}","_api_new_version":"2.4.0","_api_tested_up_to":"5.5"},"wpglobus-language-widgets":{"title":"{:en}WPGlobus Language Widgets{:}{:ru}\u042f\u0437\u044b\u043a\u0438 WPGlobus \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432{:}","_api_new_version":"2.1.0","_api_tested_up_to":"5.7"},"wpglobus-multilingual-popups":{"title":"{:en}WPGlobus Multilingual Popups{:}{:ru}WPGlobus Multilingual Popups{:}","_api_new_version":"1.4.0","_api_tested_up_to":"5.7"},"
|
1 |
+
{"multilingual-woocommerce-nets-netaxept":{"title":"{:en}Multilingual WooCommerce Nets Netaxept{:}{:ru}\u041c\u0443\u043b\u044c\u0442\u0438\u044f\u0437\u044b\u0447\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce Nets Netaxept{:}","_api_new_version":"1.0.3","_api_tested_up_to":"4.9.8"},"wpglobus-multi-currency":{"title":"{:en}Multi-Currency for WooCommerce{:}{:ru}WPGlobus - \u041c\u0443\u043b\u044c\u0442\u0438\u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f WooCommerce{:}","_api_new_version":"1.1.1","_api_tested_up_to":"4.9.4"},"wpglobus-mobile-menu":{"title":"{:en}WPGlobus Mobile Menu{:}{:ru}WPGlobus Mobile Menu{:}","_api_new_version":"2.2.0","_api_tested_up_to":"5.6"},"wpglobus-for-ultimate-member":{"title":"{:en}WPGlobus for Ultimate Member{:}{:ru}WPGlobus \u0434\u043b\u044f \u043f\u043b\u0430\u0433\u0438\u043d\u0430 Ultimate Member{:}","_api_new_version":"1.1.0","_api_tested_up_to":"5.6"},"wpglobus-menu-visibility":{"title":"WPGlobus Menu Visibility","_api_new_version":"2.0.0","_api_tested_up_to":"5.6"},"wpglobus-for-bridge-theme":{"title":"{:en}WPGlobus for the \"Bridge\" theme{:}{:ru}WPGlobus \u0434\u043b\u044f \u0442\u0435\u043c\u044b Bridge{:}","_api_new_version":"2.4.0","_api_tested_up_to":"5.5"},"wpglobus-language-widgets":{"title":"{:en}WPGlobus Language Widgets{:}{:ru}\u042f\u0437\u044b\u043a\u0438 WPGlobus \u0434\u043b\u044f \u0432\u0438\u0434\u0436\u0435\u0442\u043e\u0432{:}","_api_new_version":"2.1.0","_api_tested_up_to":"5.7"},"wpglobus-multilingual-popups":{"title":"{:en}WPGlobus Multilingual Popups{:}{:ru}WPGlobus Multilingual Popups{:}","_api_new_version":"1.4.0","_api_tested_up_to":"5.7"},"wpglobus-multilingual-notices":{"title":"{:en}WPGlobus Multilingual Notices{:}{:ru}WPGlobus - \u043c\u043d\u043e\u0433\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f{:}","_api_new_version":"2.9.2","_api_tested_up_to":"5.8"},"wpglobus-header-images":{"title":"{:en}WPGlobus Header Images{:}{:ru}WPGlobus Header Images{:}","_api_new_version":"2.2.0","_api_tested_up_to":"5.8"},"woocommerce-wpglobus":{"title":"{:en}WPGlobus for WooCommerce{:}{:ru}\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 WooCommerce WPGlobus{:}","_api_new_version":"6.0.0","_api_tested_up_to":"5.8"},"wpglobus-plus":{"title":"{:en}WPGlobus Plus multilingual extension{:}{:ru}WPGlobus \u041f\u043b\u044e\u0441{:}","_api_new_version":"1.8.4","_api_tested_up_to":"5.8"}}
|
includes/admin/meta/class-wpglobus-meta.php
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* @since 1.9.17
|
6 |
* @since 1.9.25 Added build_multilingual_string function.
|
|
|
7 |
*
|
8 |
* @package WPGlobus\Admin\Meta
|
9 |
* @author Alex Gor(alexgff)
|
@@ -47,8 +48,12 @@ if ( ! class_exists( 'WPGlobus_Meta' ) ) :
|
|
47 |
|
48 |
self::$meta_fields = $meta_fields;
|
49 |
self::$builder = $builder;
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
52 |
add_filter( 'get_post_metadata', array( __CLASS__, 'filter__post_metadata' ), 5, 4 );
|
53 |
|
54 |
/**
|
@@ -57,8 +62,23 @@ if ( ! class_exists( 'WPGlobus_Meta' ) ) :
|
|
57 |
add_filter( 'update_post_metadata', array( __CLASS__, 'filter__update_post_metadata' ), 5, 5 );
|
58 |
|
59 |
add_filter( 'delete_post_metadata', array( __CLASS__, 'filter__delete_metadata' ), 5, 5 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
-
|
62 |
}
|
63 |
|
64 |
/**
|
@@ -77,6 +97,215 @@ if ( ! class_exists( 'WPGlobus_Meta' ) ) :
|
|
77 |
return self::$instance;
|
78 |
}
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
/**
|
81 |
* public static function get_post_meta( $post_id = false ) {
|
82 |
* $meta_cache = wp_cache_get($post_id, 'post_meta');
|
@@ -347,7 +576,6 @@ if ( ! class_exists( 'WPGlobus_Meta' ) ) :
|
|
347 |
}
|
348 |
|
349 |
return $result;
|
350 |
-
|
351 |
}
|
352 |
|
353 |
/**
|
@@ -543,3 +771,5 @@ if ( ! class_exists( 'WPGlobus_Meta' ) ) :
|
|
543 |
}
|
544 |
|
545 |
endif;
|
|
|
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-wpglobus-meta.php
|
4 |
*
|
5 |
* @since 1.9.17
|
6 |
* @since 1.9.25 Added build_multilingual_string function.
|
7 |
+
* @since 2.8.9 Added support for term meta.
|
8 |
*
|
9 |
* @package WPGlobus\Admin\Meta
|
10 |
* @author Alex Gor(alexgff)
|
48 |
|
49 |
self::$meta_fields = $meta_fields;
|
50 |
self::$builder = $builder;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @since 2.8.9 Added checking REST API request.
|
54 |
+
*/
|
55 |
+
if ( is_admin() || WPGlobus_WP::is_rest_api_request() ) {
|
56 |
+
|
57 |
add_filter( 'get_post_metadata', array( __CLASS__, 'filter__post_metadata' ), 5, 4 );
|
58 |
|
59 |
/**
|
62 |
add_filter( 'update_post_metadata', array( __CLASS__, 'filter__update_post_metadata' ), 5, 5 );
|
63 |
|
64 |
add_filter( 'delete_post_metadata', array( __CLASS__, 'filter__delete_metadata' ), 5, 5 );
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @since 2.8.9
|
68 |
+
*/
|
69 |
+
add_filter( 'get_term_metadata', array( __CLASS__, 'filter__term_metadata' ), 5, 4 );
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @since 2.8.9
|
73 |
+
*/
|
74 |
+
add_filter( 'update_term_metadata', array( __CLASS__, 'filter__update_term_metadata' ), 5, 5 );
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @todo Test deleting term meta with Yoast and Rank Math(REST query).
|
78 |
+
* @since 2.8.9
|
79 |
+
*/
|
80 |
+
// add_filter( 'delete_term_metadata', array( __CLASS__, 'filter__delete_term_metadata' ), 5, 5 );
|
81 |
}
|
|
|
82 |
}
|
83 |
|
84 |
/**
|
97 |
return self::$instance;
|
98 |
}
|
99 |
|
100 |
+
/**
|
101 |
+
* Update meta data.
|
102 |
+
*
|
103 |
+
* Internal use.
|
104 |
+
* @since 2.8.9
|
105 |
+
*/
|
106 |
+
protected static function _update_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value, $meta_type = '' ) {
|
107 |
+
|
108 |
+
if ( empty( $meta_type ) ) {
|
109 |
+
return $check;
|
110 |
+
}
|
111 |
+
|
112 |
+
/** @global wpdb $wpdb */
|
113 |
+
global $wpdb;
|
114 |
+
|
115 |
+
$table = _get_meta_table( $meta_type );
|
116 |
+
if ( ! $table ) {
|
117 |
+
return false;
|
118 |
+
}
|
119 |
+
|
120 |
+
$column = $meta_type . '_id';
|
121 |
+
$id_column = 'meta_id';
|
122 |
+
|
123 |
+
$raw_meta_key = $meta_key;
|
124 |
+
|
125 |
+
if ( empty( $prev_value ) ) {
|
126 |
+
$old_value = get_metadata_raw( $meta_type, $object_id, $meta_key );
|
127 |
+
if ( is_countable( $old_value ) && count( $old_value ) === 1 ) {
|
128 |
+
if ( $old_value[0] === $meta_value ) {
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
$_meta_value = $meta_value;
|
135 |
+
|
136 |
+
$meta_value = maybe_serialize( $meta_value );
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Don't auto-modify this SQL query.
|
140 |
+
*/
|
141 |
+
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
142 |
+
$prev_meta = $wpdb->get_row( $wpdb->prepare( "SELECT $id_column, meta_value FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) );
|
143 |
+
|
144 |
+
if ( is_null( $prev_meta ) ) {
|
145 |
+
|
146 |
+
$_passed_value = $_meta_value;
|
147 |
+
|
148 |
+
if ( ! empty( $_passed_value ) && WPGlobus::Config()->default_language !== self::$builder->get_language() ) {
|
149 |
+
// phpcs:ignore Generic.CodeAnalysis.EmptyStatement
|
150 |
+
if ( WPGlobus_Core::has_translations( $_passed_value ) ) {
|
151 |
+
/**
|
152 |
+
* We get multilingual $meta_value. Let save it as is.
|
153 |
+
*/
|
154 |
+
} else {
|
155 |
+
$_passed_value = self::build_multilingual_string( array( self::$builder->get_language() => $_passed_value ) );
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
return add_metadata( $meta_type, $object_id, $raw_meta_key, $_passed_value );
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* WPGlobus Core.
|
164 |
+
* We get $meta_value in language that can be retrieved with self::$builder->get_language().
|
165 |
+
*/
|
166 |
+
|
167 |
+
// phpcs:ignore Generic.CodeAnalysis.EmptyStatement
|
168 |
+
if ( WPGlobus_Core::has_translations( $meta_value ) ) {
|
169 |
+
/**
|
170 |
+
* We get multilingual $meta_value. Let save it as is.
|
171 |
+
*/
|
172 |
+
} else {
|
173 |
+
|
174 |
+
$_new_ml_array = array();
|
175 |
+
|
176 |
+
if ( WPGlobus_Core::has_translations($prev_meta->meta_value) ) {
|
177 |
+
|
178 |
+
foreach ( WPGlobus::Config()->enabled_languages as $language ) :
|
179 |
+
|
180 |
+
if ( $language === self::$builder->get_language() ) {
|
181 |
+
|
182 |
+
if ( ! empty( $meta_value ) ) {
|
183 |
+
$_new_ml_array[ $language ] = $meta_value;
|
184 |
+
}
|
185 |
+
} else {
|
186 |
+
|
187 |
+
$_value = WPGlobus_Core::text_filter( $prev_meta->meta_value, $language, WPGlobus::RETURN_EMPTY );
|
188 |
+
|
189 |
+
if ( '' !== $_value ) {
|
190 |
+
$_new_ml_array[ $language ] = $_value;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
endforeach;
|
195 |
+
|
196 |
+
$_new_value = self::build_multilingual_string( $_new_ml_array );
|
197 |
+
|
198 |
+
} else {
|
199 |
+
|
200 |
+
if ( WPGlobus::Config()->default_language === self::$builder->get_language() ) {
|
201 |
+
$_new_ml_array[ WPGlobus::Config()->default_language ] = $meta_value;
|
202 |
+
} else {
|
203 |
+
$_new_ml_array[ WPGlobus::Config()->default_language ] = $prev_meta->meta_value;
|
204 |
+
if ( ! empty( $meta_value ) ) {
|
205 |
+
$_new_ml_array[ self::$builder->get_language() ] = $meta_value;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
$_new_value = self::build_multilingual_string( $_new_ml_array );
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
if ( ! empty( $_new_value ) ) {
|
214 |
+
$meta_value = $_new_value;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
$data = compact( 'meta_value' );
|
219 |
+
$where = array(
|
220 |
+
$column => $object_id,
|
221 |
+
'meta_key' => $meta_key,
|
222 |
+
);
|
223 |
+
|
224 |
+
$result = $wpdb->update( $table, $data, $where );
|
225 |
+
|
226 |
+
if ( ! $result ) {
|
227 |
+
return false;
|
228 |
+
}
|
229 |
+
|
230 |
+
wp_cache_delete( $object_id, $meta_type . '_meta' );
|
231 |
+
|
232 |
+
return true;
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* Filter term meta data.
|
237 |
+
*
|
238 |
+
* @since 2.8.9
|
239 |
+
*/
|
240 |
+
public static function filter__term_metadata( $check, $object_id, $meta_key, $single ) {
|
241 |
+
|
242 |
+
if ( empty( self::$meta_fields ) ) {
|
243 |
+
return $check;
|
244 |
+
}
|
245 |
+
|
246 |
+
if ( ! self::meta_key_exists( $meta_key ) ) {
|
247 |
+
return $check;
|
248 |
+
}
|
249 |
+
|
250 |
+
if ( empty( self::$builder->get_language() ) ) {
|
251 |
+
/**
|
252 |
+
* Prevent update term meta when $builder is not set.
|
253 |
+
*/
|
254 |
+
return $check;
|
255 |
+
}
|
256 |
+
|
257 |
+
$meta_type = 'term';
|
258 |
+
|
259 |
+
$meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' );
|
260 |
+
|
261 |
+
if ( ! $meta_cache ) {
|
262 |
+
$meta_cache = update_meta_cache( $meta_type, array( $object_id ) );
|
263 |
+
$meta_cache = $meta_cache[ $object_id ];
|
264 |
+
}
|
265 |
+
|
266 |
+
if ( ! empty( $meta_cache[$meta_key][0] ) && WPGlobus_Core::has_translations( $meta_cache[$meta_key][0] ) ) {
|
267 |
+
|
268 |
+
$meta_cache[$meta_key][0] = WPGlobus_Core::text_filter(
|
269 |
+
$meta_cache[$meta_key][0],
|
270 |
+
self::$builder->get_language(),
|
271 |
+
WPGlobus::RETURN_EMPTY
|
272 |
+
);
|
273 |
+
|
274 |
+
wp_cache_replace(
|
275 |
+
$object_id,
|
276 |
+
$meta_cache,
|
277 |
+
$meta_type . '_meta'
|
278 |
+
);
|
279 |
+
}
|
280 |
+
|
281 |
+
return $check;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Update term meta data.
|
286 |
+
*
|
287 |
+
* @since 2.8.9
|
288 |
+
*/
|
289 |
+
public static function filter__update_term_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
|
290 |
+
|
291 |
+
if ( empty( self::$meta_fields ) ) {
|
292 |
+
return $check;
|
293 |
+
}
|
294 |
+
|
295 |
+
if ( ! self::meta_key_exists( $meta_key ) ) {
|
296 |
+
return $check;
|
297 |
+
}
|
298 |
+
|
299 |
+
if ( empty( self::$builder->get_language() ) ) {
|
300 |
+
/**
|
301 |
+
* Prevent update term meta when $builder is not set.
|
302 |
+
*/
|
303 |
+
return $check;
|
304 |
+
}
|
305 |
+
|
306 |
+
return self::_update_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value, 'term' );
|
307 |
+
}
|
308 |
+
|
309 |
/**
|
310 |
* public static function get_post_meta( $post_id = false ) {
|
311 |
* $meta_cache = wp_cache_get($post_id, 'post_meta');
|
576 |
}
|
577 |
|
578 |
return $result;
|
|
|
579 |
}
|
580 |
|
581 |
/**
|
771 |
}
|
772 |
|
773 |
endif;
|
774 |
+
|
775 |
+
# --- EOF
|
includes/builders/class-wpglobus-builders.php
CHANGED
@@ -248,6 +248,9 @@ if ( ! class_exists( 'WPGlobus_Builders' ) ) :
|
|
248 |
'message' => '',
|
249 |
'ajax_actions' => '',
|
250 |
'builder_support' => true, // @since 2.4.12
|
|
|
|
|
|
|
251 |
);
|
252 |
|
253 |
self::$admin_attrs = array(
|
@@ -287,8 +290,6 @@ if ( ! class_exists( 'WPGlobus_Builders' ) ) :
|
|
287 |
|
288 |
if ( $init ) {
|
289 |
|
290 |
-
//$builder = false;
|
291 |
-
|
292 |
self::get_addons();
|
293 |
|
294 |
/**
|
248 |
'message' => '',
|
249 |
'ajax_actions' => '',
|
250 |
'builder_support' => true, // @since 2.4.12
|
251 |
+
'taxonomy' => '', // @since 2.8.9
|
252 |
+
'tag_ID' => '', // @since 2.8.9
|
253 |
+
'rest_request' => WPGlobus_WP::is_rest_api_request(), // @since 2.8.9
|
254 |
);
|
255 |
|
256 |
self::$admin_attrs = array(
|
290 |
|
291 |
if ( $init ) {
|
292 |
|
|
|
|
|
293 |
self::get_addons();
|
294 |
|
295 |
/**
|
includes/builders/class-wpglobus-config-builder.php
CHANGED
@@ -81,8 +81,16 @@ if ( ! class_exists( 'WPGlobus_Config_Builder' ) ) :
|
|
81 |
$this->attrs[ $key ] = $value;
|
82 |
}
|
83 |
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
} else {
|
88 |
unset( $this->attrs );
|
@@ -94,7 +102,6 @@ if ( ! class_exists( 'WPGlobus_Config_Builder' ) ) :
|
|
94 |
$builder = WPGlobus_Builders::get( false );
|
95 |
|
96 |
}
|
97 |
-
|
98 |
}
|
99 |
|
100 |
/**
|
81 |
$this->attrs[ $key ] = $value;
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* @since 2.8.9 Get REST API request language.
|
86 |
+
* For example for setting language @see wpglobus\includes\builders\rank_math_seo\class-wpglobus-builder-rank_math_seo.php
|
87 |
+
*/
|
88 |
+
if ( isset($builder['rest_request']) && $builder['rest_request'] && isset($builder['rest_language']) ) {
|
89 |
+
$this->set_language( $builder['rest_language'] );
|
90 |
+
} else {
|
91 |
+
$this->language = $this->get_language();
|
92 |
+
$this->attrs['language'] = $this->language;
|
93 |
+
}
|
94 |
|
95 |
} else {
|
96 |
unset( $this->attrs );
|
102 |
$builder = WPGlobus_Builders::get( false );
|
103 |
|
104 |
}
|
|
|
105 |
}
|
106 |
|
107 |
/**
|
includes/builders/rank_math_seo/class-wpglobus-builder-rank_math_seo.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
* File: class-wpglobus-builder-rank_math_seo.php
|
4 |
*
|
5 |
* @since 2.4.3
|
|
|
6 |
*
|
7 |
* @package WPGlobus\Builders\RankMathSEO.
|
8 |
* @author Alex Gor(alexgff)
|
@@ -46,9 +47,14 @@ if ( ! class_exists( 'WPGlobus_Builder_RankMathSEO' ) ) :
|
|
46 |
|
47 |
return $attrs;
|
48 |
|
49 |
-
}
|
|
|
|
|
|
|
|
|
50 |
|
51 |
$tax = empty( $_GET['taxonomy'] ) ? false : sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) ); // phpcs:ignore WordPress.CSRF.NonceVerification
|
|
|
52 |
|
53 |
if ( $tax ) {
|
54 |
|
@@ -59,11 +65,56 @@ if ( ! class_exists( 'WPGlobus_Builder_RankMathSEO' ) ) :
|
|
59 |
} else {
|
60 |
$attrs['post_type'] = ''; // reset post type.
|
61 |
$attrs['taxonomy'] = $tax;
|
|
|
62 |
$attrs['builder_page'] = true;
|
63 |
}
|
64 |
-
|
65 |
return $attrs;
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
|
69 |
return false;
|
3 |
* File: class-wpglobus-builder-rank_math_seo.php
|
4 |
*
|
5 |
* @since 2.4.3
|
6 |
+
* @since 2.8.9 Added support REST API request.
|
7 |
*
|
8 |
* @package WPGlobus\Builders\RankMathSEO.
|
9 |
* @author Alex Gor(alexgff)
|
47 |
|
48 |
return $attrs;
|
49 |
|
50 |
+
} else if ( 'term.php' === $pagenow ) {
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Current language will be set correctrly from $_REQUEST['language'] @see wpglobus\includes\builders\class-wpglobus-config-builder.php
|
54 |
+
*/
|
55 |
|
56 |
$tax = empty( $_GET['taxonomy'] ) ? false : sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) ); // phpcs:ignore WordPress.CSRF.NonceVerification
|
57 |
+
$tag_ID = empty( $_GET['tag_ID'] ) ? false : sanitize_text_field( wp_unslash( $_GET['tag_ID'] ) ); // phpcs:ignore WordPress.CSRF.NonceVerification
|
58 |
|
59 |
if ( $tax ) {
|
60 |
|
65 |
} else {
|
66 |
$attrs['post_type'] = ''; // reset post type.
|
67 |
$attrs['taxonomy'] = $tax;
|
68 |
+
$attrs['tag_ID'] = $tag_ID;
|
69 |
$attrs['builder_page'] = true;
|
70 |
}
|
71 |
+
|
72 |
return $attrs;
|
73 |
+
}
|
74 |
+
|
75 |
+
} else if ( 'edit.php' === $pagenow ) {
|
76 |
+
|
77 |
+
// return $attrs;
|
78 |
+
|
79 |
+
} else if ( isset( $attrs['rest_request'] ) && $attrs['rest_request'] ) {
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Get post ID, term, term ID, language from REST API request.
|
83 |
+
*
|
84 |
+
* @since 2.8.9
|
85 |
+
*/
|
86 |
+
if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
|
87 |
+
|
88 |
+
preg_match( '/\?post=(?<postID>[^&]+)/', $_SERVER['HTTP_REFERER'], $matches );
|
89 |
+
|
90 |
+
if ( ! empty($matches['postID']) && (int) $matches['postID'] > 0 ) {
|
91 |
+
|
92 |
+
$attrs['post_id'] = $matches['postID'];
|
93 |
+
|
94 |
+
} else {
|
95 |
+
|
96 |
+
preg_match( '/term\.php\?taxonomy=(?<tax>[^&]+)&tag_ID=(?<id>[^&]+)/', $_SERVER['HTTP_REFERER'], $matches );
|
97 |
+
preg_match( '/&language=(?<language>[a-z]{2})/', $_SERVER['HTTP_REFERER'], $lang_matches );
|
98 |
+
|
99 |
+
if ( ! empty($matches['tax']) && ! empty($matches['id']) && (int) $matches['id'] > 0 ) {
|
100 |
+
|
101 |
+
$attrs['taxonomy'] = $matches['tax'];
|
102 |
+
$attrs['tag_ID'] = $matches['id'];
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Get language for REST API request.
|
106 |
+
*/
|
107 |
+
if ( ! empty( $lang_matches['language'] ) ) {
|
108 |
+
$attrs['rest_language'] = $lang_matches['language'];
|
109 |
+
}
|
110 |
+
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
$attrs['builder_page'] = true;
|
116 |
+
|
117 |
+
return $attrs;
|
118 |
}
|
119 |
|
120 |
return false;
|
includes/builders/rank_math_seo/class-wpglobus-rank_math_seo-functions.php
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
* File: class-wpglobus-rank_math_seo-functions.php
|
4 |
*
|
5 |
* @since 2.4.3
|
|
|
6 |
*
|
7 |
* @package WPGlobus\Builders\RankMathSEO.
|
8 |
* @author Alex Gor(alexgff)
|
@@ -34,30 +35,85 @@ if ( ! class_exists( 'WPGlobus_RankMathSEO_Functions' ) ) :
|
|
34 |
* Constructor.
|
35 |
*/
|
36 |
public static function controller() {
|
37 |
-
|
38 |
-
if (
|
|
|
39 |
/**
|
40 |
-
*
|
|
|
|
|
41 |
*/
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
44 |
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
|
|
|
|
|
49 |
}
|
50 |
|
51 |
-
if (
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
|
58 |
-
|
59 |
}
|
60 |
-
|
61 |
/**
|
62 |
* Build multilingual description.
|
63 |
* We don't have filter for description like filter for name @see 'wp_update_term_data' in wp-includes\taxonomy.php
|
3 |
* File: class-wpglobus-rank_math_seo-functions.php
|
4 |
*
|
5 |
* @since 2.4.3
|
6 |
+
* @since 2.8.9 Added support multilingual columns on `edit.php` page.
|
7 |
*
|
8 |
* @package WPGlobus\Builders\RankMathSEO.
|
9 |
* @author Alex Gor(alexgff)
|
35 |
* Constructor.
|
36 |
*/
|
37 |
public static function controller() {
|
38 |
+
|
39 |
+
if ( WPGlobus_WP::is_pagenow( 'edit.php' ) ) {
|
40 |
+
|
41 |
/**
|
42 |
+
* To translate SEO columns on `edit.php` page.
|
43 |
+
*
|
44 |
+
* @since 2.8.9
|
45 |
*/
|
46 |
+
add_filter( 'get_post_metadata', array( __CLASS__, 'filter__post_metadata' ), 2, 4 );
|
47 |
+
}
|
48 |
+
|
49 |
+
if ( is_admin() ) {
|
50 |
+
|
51 |
+
if ( empty( $_POST['nonce_CMB2phprank_math_metabox'] ) || empty( $_POST['action'] ) ) {
|
52 |
+
/**
|
53 |
+
* Not `Rank Math SEO`.
|
54 |
+
*/
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
|
58 |
+
global $pagenow;
|
59 |
+
|
60 |
+
if ( ! empty( $_POST[ WPGlobus::get_language_meta_key() ] ) ) {
|
61 |
+
self::$current_language = sanitize_text_field( $_POST[ WPGlobus::get_language_meta_key() ] );
|
62 |
+
}
|
63 |
+
|
64 |
+
if ( 'edit-tags.php' === $pagenow && 'editedtag' === $_POST['action'] ) { // phpcs:ignore WordPress.CSRF.NonceVerification
|
65 |
+
/**
|
66 |
+
* Update button was clicked.
|
67 |
+
*/
|
68 |
+
self::build_ml_description();
|
69 |
+
}
|
70 |
+
|
71 |
+
add_filter( 'wp_update_term_data', array( __CLASS__, 'filter__update_term_data' ), 5, 4 );
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @since 2.8.9
|
77 |
+
*/
|
78 |
+
public static function filter__post_metadata( $check, $object_id, $meta_key, $single ) {
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @todo Get keys from builder.
|
82 |
+
* @since 2.8.9
|
83 |
+
*/
|
84 |
+
$enabled_keys = array(
|
85 |
+
'rank_math_title',
|
86 |
+
'rank_math_description',
|
87 |
+
'rank_math_focus_keyword',
|
88 |
+
'rank_math_seo_score'
|
89 |
+
);
|
90 |
+
|
91 |
+
if ( ! in_array( $meta_key, $enabled_keys ) ) {
|
92 |
+
return $check;
|
93 |
}
|
94 |
|
95 |
+
$meta_type = 'post';
|
96 |
|
97 |
+
$meta_cache = wp_cache_get( $object_id, $meta_type . '_meta' );
|
98 |
+
|
99 |
+
if ( ! $meta_cache ) {
|
100 |
+
return $check;
|
101 |
}
|
102 |
|
103 |
+
if ( ! empty( $meta_cache[$meta_key][0] ) && WPGlobus_Core::has_translations( $meta_cache[$meta_key][0] ) ) {
|
104 |
+
|
105 |
+
$meta_cache[$meta_key][0] = WPGlobus_Core::text_filter( $meta_cache[$meta_key][0], WPGlobus::Config()->language );
|
106 |
+
|
107 |
+
wp_cache_replace(
|
108 |
+
$object_id,
|
109 |
+
$meta_cache,
|
110 |
+
$meta_type . '_meta'
|
111 |
+
);
|
112 |
}
|
113 |
|
114 |
+
return $check;
|
115 |
}
|
116 |
+
|
117 |
/**
|
118 |
* Build multilingual description.
|
119 |
* We don't have filter for description like filter for name @see 'wp_update_term_data' in wp-includes\taxonomy.php
|
includes/class-wpglobus-config-vendor.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
4 |
*
|
5 |
* @package WPGlobus
|
6 |
* @author Alex Gor(alexgff)
|
@@ -39,6 +39,18 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
39 |
*/
|
40 |
protected static $post_ml_fields = null;
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/**
|
43 |
* @var array|null
|
44 |
*/
|
@@ -69,7 +81,6 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
69 |
|
70 |
self::get_config_files();
|
71 |
self::parse_config();
|
72 |
-
|
73 |
}
|
74 |
|
75 |
/**
|
@@ -90,14 +101,27 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
90 |
/**
|
91 |
* Get meta fields.
|
92 |
*
|
|
|
|
|
93 |
* @return array|false
|
94 |
*/
|
95 |
public static function get_meta_fields() {
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
98 |
}
|
99 |
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
/**
|
@@ -197,11 +221,12 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
197 |
/**
|
198 |
* Rank Math SEO.
|
199 |
* https://wordpress.org/plugins/seo-by-rank-math/
|
200 |
-
* @since 2.4.3
|
|
|
201 |
*/
|
202 |
-
if ( defined( 'RANK_MATH_VERSION' ) ) {
|
203 |
-
self::$vendors[] = 'rank-math-seo.json';
|
204 |
-
}
|
205 |
|
206 |
/**
|
207 |
* Page Builder by SiteOrigin.
|
@@ -216,13 +241,24 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
216 |
if ( self::$builder->get_id() != '' && self::$builder->is_builder_page() ) {
|
217 |
|
218 |
$addons = WPGlobus_Builders::get_addons();
|
219 |
-
|
220 |
if ( ! empty( $addons ) ) {
|
221 |
-
foreach ( $addons as $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
if ( 'add-on' === $addon['role'] ) {
|
223 |
if ( ! empty( $addon['const'] ) && defined( $addon['const'] ) ) {
|
224 |
-
self::$vendors[] = $addon['config_file'];
|
225 |
}
|
|
|
|
|
|
|
|
|
226 |
}
|
227 |
}
|
228 |
}
|
@@ -231,12 +267,12 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
231 |
/**
|
232 |
* Now handle with config files.
|
233 |
*/
|
234 |
-
foreach ( self::$vendors as $file ) {
|
235 |
-
|
236 |
if ( is_readable( $config_plugin_dir . $file ) ) {
|
237 |
-
$
|
238 |
-
|
239 |
-
|
|
|
240 |
}
|
241 |
}
|
242 |
|
@@ -251,7 +287,60 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
251 |
* @return array
|
252 |
*/
|
253 |
self::$config = apply_filters( 'wpglobus_config_vendors', self::$config, self::$builder );
|
|
|
254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
|
257 |
/**
|
@@ -351,12 +440,18 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
351 |
|
352 |
return $_post_meta_fields;
|
353 |
}
|
354 |
-
|
355 |
/**
|
356 |
* Parse config files.
|
357 |
*/
|
358 |
public static function parse_config() {
|
359 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
/**
|
361 |
* Parse post meta fields.
|
362 |
*/
|
@@ -365,7 +460,10 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
365 |
self::$post_meta_fields = array();
|
366 |
self::$post_ml_fields = array();
|
367 |
|
368 |
-
|
|
|
|
|
|
|
369 |
|
370 |
if ( isset( $data['post_meta_fields'] ) && is_array( $data['post_meta_fields'] ) ) :
|
371 |
|
@@ -375,6 +473,7 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
375 |
|
376 |
if ( '*' === $_meta ) {
|
377 |
$_arr = self::get_post_meta_fields( $_meta, $_init );
|
|
|
378 |
if ( ! empty( $_arr ) ) {
|
379 |
self::$post_meta_fields = array_merge( self::$post_meta_fields, $_arr );
|
380 |
}
|
@@ -411,7 +510,10 @@ if ( ! class_exists( 'WPGlobus_Config_Vendor' ) ) :
|
|
411 |
*/
|
412 |
if ( is_null( self::$wp_options ) ) {
|
413 |
|
414 |
-
|
|
|
|
|
|
|
415 |
|
416 |
if ( isset( $data['wp_options'] ) && is_array( $data['wp_options'] ) ) :
|
417 |
foreach ( $data['wp_options'] as $_option => $_init ) {
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-wpglobus-config-vendor.php
|
4 |
*
|
5 |
* @package WPGlobus
|
6 |
* @author Alex Gor(alexgff)
|
39 |
*/
|
40 |
protected static $post_ml_fields = null;
|
41 |
|
42 |
+
/**
|
43 |
+
* @since 2.8.9
|
44 |
+
* @var array|null
|
45 |
+
*/
|
46 |
+
protected static $term_meta_fields = null;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @since 2.8.9
|
50 |
+
* @var array|null
|
51 |
+
*/
|
52 |
+
protected static $term_ml_fields = null;
|
53 |
+
|
54 |
/**
|
55 |
* @var array|null
|
56 |
*/
|
81 |
|
82 |
self::get_config_files();
|
83 |
self::parse_config();
|
|
|
84 |
}
|
85 |
|
86 |
/**
|
101 |
/**
|
102 |
* Get meta fields.
|
103 |
*
|
104 |
+
* @since 2.8.9 Return term and post meta fields.
|
105 |
+
*
|
106 |
* @return array|false
|
107 |
*/
|
108 |
public static function get_meta_fields() {
|
109 |
+
|
110 |
+
$meta_fields = false;
|
111 |
+
|
112 |
+
if ( ! is_null( self::$post_meta_fields ) && ! empty( self::$post_meta_fields ) ) {
|
113 |
+
$meta_fields = self::$post_meta_fields;
|
114 |
}
|
115 |
|
116 |
+
if ( ! is_null( self::$term_meta_fields ) && ! empty( self::$term_meta_fields ) ) {
|
117 |
+
if ( $meta_fields ) {
|
118 |
+
$meta_fields = array_merge( $meta_fields, self::$term_meta_fields );
|
119 |
+
} else {
|
120 |
+
$meta_fields = self::$term_meta_fields;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
return $meta_fields;
|
125 |
}
|
126 |
|
127 |
/**
|
221 |
/**
|
222 |
* Rank Math SEO.
|
223 |
* https://wordpress.org/plugins/seo-by-rank-math/
|
224 |
+
* @since 2.4.3
|
225 |
+
* obsolete @since 2.8.9 Info from self::$add_on['rank_math_seo'] @see `wpglobus\includes\builders\class-wpglobus-builders.php` is enough.
|
226 |
*/
|
227 |
+
// if ( defined( 'RANK_MATH_VERSION' ) ) {
|
228 |
+
// self::$vendors[] = 'rank-math-seo.json';
|
229 |
+
// }
|
230 |
|
231 |
/**
|
232 |
* Page Builder by SiteOrigin.
|
241 |
if ( self::$builder->get_id() != '' && self::$builder->is_builder_page() ) {
|
242 |
|
243 |
$addons = WPGlobus_Builders::get_addons();
|
|
|
244 |
if ( ! empty( $addons ) ) {
|
245 |
+
foreach ( $addons as $key => $addon ) {
|
246 |
+
|
247 |
+
/**
|
248 |
+
* @since 2.8.9
|
249 |
+
*/
|
250 |
+
if ( empty( $addon['config_file'] ) ) {
|
251 |
+
continue;
|
252 |
+
}
|
253 |
+
|
254 |
if ( 'add-on' === $addon['role'] ) {
|
255 |
if ( ! empty( $addon['const'] ) && defined( $addon['const'] ) ) {
|
256 |
+
self::$vendors[$key] = $addon['config_file'];
|
257 |
}
|
258 |
+
} elseif ( 'builder' === $addon['role'] ) {
|
259 |
+
if ( ! empty( $addon['const'] ) && defined( $addon['const'] ) ) {
|
260 |
+
self::$vendors[$key] = $addon['config_file'];
|
261 |
+
}
|
262 |
}
|
263 |
}
|
264 |
}
|
267 |
/**
|
268 |
* Now handle with config files.
|
269 |
*/
|
270 |
+
foreach ( self::$vendors as $id=>$file ) {
|
|
|
271 |
if ( is_readable( $config_plugin_dir . $file ) ) {
|
272 |
+
self::$config[ $id ] = json_decode( file_get_contents( $config_plugin_dir . $file ), true );
|
273 |
+
/**
|
274 |
+
* @todo Add warning if file is incorrect. @since 2.8.9
|
275 |
+
*/
|
276 |
}
|
277 |
}
|
278 |
|
287 |
* @return array
|
288 |
*/
|
289 |
self::$config = apply_filters( 'wpglobus_config_vendors', self::$config, self::$builder );
|
290 |
+
}
|
291 |
|
292 |
+
/**
|
293 |
+
* Get term meta fields.
|
294 |
+
*
|
295 |
+
* @since 2.8.9
|
296 |
+
*/
|
297 |
+
protected static function get_term_meta_fields() {
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Parse term meta fields.
|
301 |
+
*/
|
302 |
+
self::$term_meta_fields = array();
|
303 |
+
self::$term_ml_fields = array();
|
304 |
+
|
305 |
+
foreach ( self::$config as $vendor_key => $data ) {
|
306 |
+
|
307 |
+
if ( isset( $data['term_meta_fields'] ) && is_array( $data['term_meta_fields'] ) ) :
|
308 |
+
|
309 |
+
foreach ( $data['term_meta_fields'] as $_meta => $_init ) {
|
310 |
+
|
311 |
+
if ( isset( $data['term_meta_fields'][ $_meta ] ) ) {
|
312 |
+
|
313 |
+
if ( '*' === $_meta ) {
|
314 |
+
// @todo Add in future version.
|
315 |
+
// $_arr = self::get_term_meta_fields( $_meta, $_init );
|
316 |
+
// if ( ! empty( $_arr ) ) {
|
317 |
+
// self::$term_meta_fields = array_merge( self::$term_meta_fields, $_arr );
|
318 |
+
// }
|
319 |
+
} else {
|
320 |
+
self::$term_meta_fields[] = $_meta;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
|
325 |
+
endif;
|
326 |
+
|
327 |
+
if ( isset( $data['term_ml_fields'] ) && is_array( $data['term_ml_fields'] ) ) :
|
328 |
+
foreach ( $data['term_ml_fields'] as $_meta => $_init ) {
|
329 |
+
if ( isset( $data['term_ml_fields'][ $_meta ] ) ) {
|
330 |
+
|
331 |
+
if ( '*' === $_meta ) {
|
332 |
+
// @todo Add in future version.
|
333 |
+
// $_arr = self::get_term_ml_fields( $_meta, $_init );
|
334 |
+
// if ( ! empty( $_arr ) ) {
|
335 |
+
// self::$term_ml_fields = array_merge( self::$term_ml_fields, $_arr );
|
336 |
+
// }
|
337 |
+
} else {
|
338 |
+
self::$term_ml_fields[] = $_meta;
|
339 |
+
}
|
340 |
+
}
|
341 |
+
}
|
342 |
+
endif;
|
343 |
+
}
|
344 |
}
|
345 |
|
346 |
/**
|
440 |
|
441 |
return $_post_meta_fields;
|
442 |
}
|
443 |
+
|
444 |
/**
|
445 |
* Parse config files.
|
446 |
*/
|
447 |
public static function parse_config() {
|
448 |
+
|
449 |
+
/**
|
450 |
+
* Get term meta fields.
|
451 |
+
* @since 2.8.9
|
452 |
+
*/
|
453 |
+
self::get_term_meta_fields();
|
454 |
+
|
455 |
/**
|
456 |
* Parse post meta fields.
|
457 |
*/
|
460 |
self::$post_meta_fields = array();
|
461 |
self::$post_ml_fields = array();
|
462 |
|
463 |
+
/**
|
464 |
+
* @since 2.8.9 Changed $vendor to $vendor_key.
|
465 |
+
*/
|
466 |
+
foreach ( self::$config as $vendor_key => $data ) {
|
467 |
|
468 |
if ( isset( $data['post_meta_fields'] ) && is_array( $data['post_meta_fields'] ) ) :
|
469 |
|
473 |
|
474 |
if ( '*' === $_meta ) {
|
475 |
$_arr = self::get_post_meta_fields( $_meta, $_init );
|
476 |
+
|
477 |
if ( ! empty( $_arr ) ) {
|
478 |
self::$post_meta_fields = array_merge( self::$post_meta_fields, $_arr );
|
479 |
}
|
510 |
*/
|
511 |
if ( is_null( self::$wp_options ) ) {
|
512 |
|
513 |
+
/**
|
514 |
+
* @since 2.8.9 Changed $vendor to $vendor_key.
|
515 |
+
*/
|
516 |
+
foreach ( self::$config as $vendor_key => $data ) {
|
517 |
|
518 |
if ( isset( $data['wp_options'] ) && is_array( $data['wp_options'] ) ) :
|
519 |
foreach ( $data['wp_options'] as $_option => $_init ) {
|
includes/class-wpglobus-config.php
CHANGED
@@ -935,13 +935,16 @@ class WPGlobus_Config {
|
|
935 |
'default_language' => $this->default_language,
|
936 |
'post_types' => $builder_post_types,
|
937 |
'options' => array(
|
938 |
-
|
939 |
-
|
940 |
)
|
941 |
);
|
|
|
|
|
|
|
|
|
|
|
942 |
|
943 |
-
if ( is_admin() ) {
|
944 |
-
|
945 |
require_once dirname( __FILE__ ) . '/class-wpglobus-config-vendor.php';
|
946 |
$config_vendor = WPGlobus_Config_Vendor::get_instance( $this->builder );
|
947 |
|
935 |
'default_language' => $this->default_language,
|
936 |
'post_types' => $builder_post_types,
|
937 |
'options' => array(
|
938 |
+
'register_post_types' => $this->option_register_post_types, // @since 2.2.24
|
939 |
+
)
|
940 |
)
|
941 |
);
|
942 |
+
|
943 |
+
/**
|
944 |
+
* @since 2.8.9 Added support REST API requests.
|
945 |
+
*/
|
946 |
+
if ( is_admin() || WPGlobus_WP::is_rest_api_request() ) {
|
947 |
|
|
|
|
|
948 |
require_once dirname( __FILE__ ) . '/class-wpglobus-config-vendor.php';
|
949 |
$config_vendor = WPGlobus_Config_Vendor::get_instance( $this->builder );
|
950 |
|
includes/class-wpglobus-wp.php
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
*
|
|
|
|
|
4 |
* @package WPGlobus
|
5 |
*/
|
6 |
|
@@ -262,6 +264,30 @@ class WPGlobus_WP {
|
|
262 |
return ( is_admin() && ! self::is_doing_ajax() );
|
263 |
}
|
264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
265 |
} // class
|
266 |
|
267 |
-
# --- EOF
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: class-wpglobus-wp.php
|
4 |
+
*
|
5 |
+
* WordPress shortcuts.
|
6 |
* @package WPGlobus
|
7 |
*/
|
8 |
|
264 |
return ( is_admin() && ! self::is_doing_ajax() );
|
265 |
}
|
266 |
|
267 |
+
/**
|
268 |
+
* True if doing REST API request.
|
269 |
+
*
|
270 |
+
* @since 2.8.9
|
271 |
+
*
|
272 |
+
* @return bool
|
273 |
+
*/
|
274 |
+
public static function is_rest_api_request() {
|
275 |
+
|
276 |
+
if ( self::is_doing_ajax() ) {
|
277 |
+
return false;
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* @see wp-includes\rest-api.php
|
282 |
+
* @see wp-includes\load.php
|
283 |
+
*/
|
284 |
+
if ( defined( 'REST_REQUEST' ) || wp_is_json_request() ) {
|
285 |
+
return true;
|
286 |
+
}
|
287 |
+
|
288 |
+
return false;
|
289 |
+
}
|
290 |
+
|
291 |
} // class
|
292 |
|
293 |
+
# --- EOF
|
includes/class-wpglobus.php
CHANGED
@@ -462,6 +462,9 @@ class WPGlobus {
|
|
462 |
require_once dirname( __FILE__ ) . '/builders/class-wpglobus-builder.php';
|
463 |
require_once dirname( __FILE__ ) . '/builders/gutenberg/class-wpglobus-gutenberg.php';
|
464 |
$builder = new WPGlobus_Gutenberg();
|
|
|
|
|
|
|
465 |
require_once dirname( __FILE__ ) . '/vendor/wpglobus-vendors.php';
|
466 |
|
467 |
/**
|
462 |
require_once dirname( __FILE__ ) . '/builders/class-wpglobus-builder.php';
|
463 |
require_once dirname( __FILE__ ) . '/builders/gutenberg/class-wpglobus-gutenberg.php';
|
464 |
$builder = new WPGlobus_Gutenberg();
|
465 |
+
/**
|
466 |
+
* Let's load all needed vendors.
|
467 |
+
*/
|
468 |
require_once dirname( __FILE__ ) . '/vendor/wpglobus-vendors.php';
|
469 |
|
470 |
/**
|
includes/vendor/rank-math-seo/class-wpglobus-vendor-rank_math_seo.php
CHANGED
@@ -1,104 +1,106 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* File: class-wpglobus-vendor-rank_math_seo.php
|
4 |
-
*
|
5 |
-
* @since 2.4.3
|
6 |
-
*
|
7 |
-
*
|
8 |
-
* @
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
*
|
37 |
-
*
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
*
|
61 |
-
*
|
62 |
-
*
|
63 |
-
*
|
64 |
-
* @param
|
65 |
-
*
|
66 |
-
*
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
*
|
92 |
-
*
|
93 |
-
* @
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
104 |
# --- EOF
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* File: class-wpglobus-vendor-rank_math_seo.php
|
4 |
+
*
|
5 |
+
* @since 2.4.3
|
6 |
+
* @since 2.8.9 Don't check out post_id.
|
7 |
+
*
|
8 |
+
* @package WPGlobus\Vendors\RankMathSEO.
|
9 |
+
* @author Alex Gor(alexgff)
|
10 |
+
*/
|
11 |
+
/**
|
12 |
+
* Class WPGlobus_Vendor_RankMathSEO.
|
13 |
+
*/
|
14 |
+
if ( ! class_exists( 'WPGlobus_Vendor_RankMathSEO' ) ) :
|
15 |
+
|
16 |
+
class WPGlobus_Vendor_RankMathSEO {
|
17 |
+
|
18 |
+
protected static $post_meta_fields = null;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* List of fields to add `wpglobus-translatable` class.
|
22 |
+
*/
|
23 |
+
protected static $post_multilingual_fields = null;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var object Instance of this class.
|
27 |
+
*/
|
28 |
+
protected static $instance;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Constructor.
|
32 |
+
*/
|
33 |
+
protected function __construct(){}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Get instance of this class.
|
37 |
+
*
|
38 |
+
* @return WPGlobus_Vendor_RankMathSEO
|
39 |
+
*/
|
40 |
+
public static function get_instance() {
|
41 |
+
if ( ! ( self::$instance instanceof WPGlobus_Vendor_RankMathSEO ) ) {
|
42 |
+
self::$instance = new self();
|
43 |
+
}
|
44 |
+
|
45 |
+
return self::$instance;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get multilingual fields.
|
50 |
+
*/
|
51 |
+
public static function get_post_multilingual_fields() {
|
52 |
+
if ( is_null( self::$post_multilingual_fields ) ) {
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
|
56 |
+
return self::$post_multilingual_fields;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Get post meta.
|
61 |
+
*
|
62 |
+
* Don't call WPGlobus::Config() inside function to prevent the resetting of `meta` property.
|
63 |
+
*
|
64 |
+
* @param $post_id
|
65 |
+
* @param string $post_type
|
66 |
+
*
|
67 |
+
* @return array
|
68 |
+
*/
|
69 |
+
public static function get_post_meta_fields( $post_id, $post_type = 'post' ) {
|
70 |
+
|
71 |
+
if ( ! is_null( self::$post_meta_fields ) ) {
|
72 |
+
return self::$post_meta_fields;
|
73 |
+
}
|
74 |
+
|
75 |
+
// @since 2.8.9 Don't check out post_id.
|
76 |
+
// $post_id = (int) $post_id;
|
77 |
+
// if ( $post_id > 0 ) {
|
78 |
+
// }
|
79 |
+
|
80 |
+
self::$post_meta_fields = array(
|
81 |
+
'rank_math_title',
|
82 |
+
'rank_math_description',
|
83 |
+
'rank_math_focus_keyword',
|
84 |
+
'rank_math_seo_score',
|
85 |
+
);
|
86 |
+
|
87 |
+
return self::$post_meta_fields;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Check 3rd party plugin to enable/disable field.
|
92 |
+
*
|
93 |
+
* @param array $field
|
94 |
+
*
|
95 |
+
* @return bool
|
96 |
+
*/
|
97 |
+
protected static function get_3rd_party_field_status( $field ) {
|
98 |
+
// @see wpglobus\includes\vendor\acf\class-wpglobus-acf.php for example.
|
99 |
+
return true;
|
100 |
+
}
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
endif;
|
105 |
+
|
106 |
# --- EOF
|
includes/vendor/wpglobus-vendors.php
CHANGED
@@ -1,9 +1,12 @@
|
|
1 |
<?php
|
2 |
/**
|
|
|
|
|
3 |
* @package WPGlobus\Vendors
|
4 |
*
|
5 |
* We start this file to support the plugins/add-ons in builder mode.
|
6 |
* @since 1.9.17
|
|
|
7 |
*/
|
8 |
|
9 |
/**
|
1 |
<?php
|
2 |
/**
|
3 |
+
* File: wpglobus-vendors.php
|
4 |
+
*
|
5 |
* @package WPGlobus\Vendors
|
6 |
*
|
7 |
* We start this file to support the plugins/add-ons in builder mode.
|
8 |
* @since 1.9.17
|
9 |
+
* @see function maybe_run gutenberg builder in wpglobus\includes\class-wpglobus.php
|
10 |
*/
|
11 |
|
12 |
/**
|
includes/vendor/yoast-seo/class-wpglobus-yoastseo140.php
CHANGED
@@ -1763,8 +1763,9 @@ class WPGlobus_YoastSEO {
|
|
1763 |
*
|
1764 |
* @since 2.4.14
|
1765 |
* @since 2.4.15 Localize description.
|
1766 |
-
* @since 2.5.1
|
1767 |
* @since 2.7.11 Added filter for breadcrumb title.
|
|
|
1768 |
*
|
1769 |
* @scope front
|
1770 |
* @param array $graph_piece Array of graph piece.
|
@@ -1804,6 +1805,14 @@ class WPGlobus_YoastSEO {
|
|
1804 |
if ( WPGlobus_Core::has_translations($context->indexable->breadcrumb_title) ) {
|
1805 |
$context->indexable->breadcrumb_title = WPGlobus_Core::extract_text( $context->indexable->breadcrumb_title, WPGlobus::Config()->language );
|
1806 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1807 |
|
1808 |
} else if ( 'home-page' == $context->indexable->object_type ) {
|
1809 |
|
1763 |
*
|
1764 |
* @since 2.4.14
|
1765 |
* @since 2.4.15 Localize description.
|
1766 |
+
* @since 2.5.1 Added support of taxonomies.
|
1767 |
* @since 2.7.11 Added filter for breadcrumb title.
|
1768 |
+
* @since 2.8.9 Added filter for taxonomy term name.
|
1769 |
*
|
1770 |
* @scope front
|
1771 |
* @param array $graph_piece Array of graph piece.
|
1805 |
if ( WPGlobus_Core::has_translations($context->indexable->breadcrumb_title) ) {
|
1806 |
$context->indexable->breadcrumb_title = WPGlobus_Core::extract_text( $context->indexable->breadcrumb_title, WPGlobus::Config()->language );
|
1807 |
}
|
1808 |
+
|
1809 |
+
/**
|
1810 |
+
* Filter taxonomy term name.
|
1811 |
+
* @since 2.8.9
|
1812 |
+
*/
|
1813 |
+
if ( WPGlobus_Core::has_translations($graph_piece['name']) ) {
|
1814 |
+
$graph_piece['name'] = WPGlobus_Core::extract_text( $graph_piece['name'], WPGlobus::Config()->language );
|
1815 |
+
}
|
1816 |
|
1817 |
} else if ( 'home-page' == $context->indexable->object_type ) {
|
1818 |
|
readme.txt
CHANGED
@@ -220,6 +220,25 @@ WPGlobus Version 2 supports WordPress 5.x, with Gutenberg.
|
|
220 |
|
221 |
== Changelog ==
|
222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
= 2.8.7 =
|
224 |
* (Vendor/Yoast) Fixed: posts having the `Canonical` meta field set were missing in the `sitemap.xml`.
|
225 |
|
220 |
|
221 |
== Changelog ==
|
222 |
|
223 |
+
= 2.8.9 =
|
224 |
+
|
225 |
+
* (Vendors) Updated doc.
|
226 |
+
* (Configs) Updated `rank-math-seo.json` file.
|
227 |
+
* (Core/WPGlobus) Updated doc.
|
228 |
+
* (Core/WPGlobus_WP) Added `is_rest_api_request` function.
|
229 |
+
* (Core/Builders) Added: builder attributes.
|
230 |
+
* (Core/Meta) Added: support term meta data.
|
231 |
+
* (Core/Config) Added: support REST API requests.
|
232 |
+
* (Builder/Config) Set builder language for REST API requests.
|
233 |
+
* (Vendor/Config) Added: handling term meta fields.
|
234 |
+
* (Vendor/Yoast) Filter taxonomy term name in the `Schema Generator`.
|
235 |
+
* (Vendor/RankMathSEO) Don't check post IDs.
|
236 |
+
* (Builders/RankMathSEO) Added: support multilingual columns on `edit.php` page.
|
237 |
+
* (Builders/RankMathSEO) Added: support for the REST API requests.
|
238 |
+
|
239 |
+
= 2.8.8 =
|
240 |
+
* Version 2.8.7 was a broken build. Fixed.
|
241 |
+
|
242 |
= 2.8.7 =
|
243 |
* (Vendor/Yoast) Fixed: posts having the `Canonical` meta field set were missing in the `sitemap.xml`.
|
244 |
|
wpglobus.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
* Description: A WordPress Globalization / Multilingual Plugin. Posts, pages, menus, widgets and even custom fields - in multiple languages!
|
16 |
* Text Domain: wpglobus
|
17 |
* Domain Path: /languages/
|
18 |
-
* Version: 2.8.
|
19 |
* Author: WPGlobus
|
20 |
* Author URI: https://wpglobus.com/
|
21 |
* Network: false
|
@@ -44,7 +44,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
44 |
exit;
|
45 |
}
|
46 |
|
47 |
-
define( 'WPGLOBUS_VERSION', '2.8.
|
48 |
define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
49 |
define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
|
50 |
|
15 |
* Description: A WordPress Globalization / Multilingual Plugin. Posts, pages, menus, widgets and even custom fields - in multiple languages!
|
16 |
* Text Domain: wpglobus
|
17 |
* Domain Path: /languages/
|
18 |
+
* Version: 2.8.9
|
19 |
* Author: WPGlobus
|
20 |
* Author URI: https://wpglobus.com/
|
21 |
* Network: false
|
44 |
exit;
|
45 |
}
|
46 |
|
47 |
+
define( 'WPGLOBUS_VERSION', '2.8.9' );
|
48 |
define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
49 |
define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
|
50 |
|