WPGlobus – Multilingual Everything! - Version 2.1.4

Version Description

  • FIXED:
    • Builders: prevent to filter disabled post types.
Download this release

Release Info

Developer tivnet
Plugin Icon 128x128 WPGlobus – Multilingual Everything!
Version 2.1.4
Comparing to
See all releases

Code changes from version 2.1.3 to 2.1.4

includes/builders/elementor/class-wpglobus-elementor-update-post.php CHANGED
@@ -41,6 +41,15 @@ if ( ! class_exists( 'WPGlobus_elementor_Update_Post' ) ) :
41
  */
42
  public function filter__wp_insert_post_data( $data, $postarr ) {
43
 
 
 
 
 
 
 
 
 
 
44
  global $wpdb;
45
  $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d AND post_type = %s LIMIT 1", $postarr['ID'], $postarr['post_type'] ) );
46
 
41
  */
42
  public function filter__wp_insert_post_data( $data, $postarr ) {
43
 
44
+ /**
45
+ * Prevent to filter disabled post type.
46
+ *
47
+ * @since 2.1.4
48
+ */
49
+ if ( in_array( $data['post_type'], WPGlobus::Config()->disabled_entities, true ) ) {
50
+ return $data;
51
+ }
52
+
53
  global $wpdb;
54
  $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d AND post_type = %s LIMIT 1", $postarr['ID'], $postarr['post_type'] ) );
55
 
includes/builders/js_composer/class-wpglobus-js_composer-update-post.php CHANGED
@@ -42,6 +42,15 @@ if ( ! class_exists( 'WPGlobus_js_composer_Update_Post' ) ) :
42
  */
43
  public function filter__wp_insert_post_data( $data, $postarr ) {
44
 
 
 
 
 
 
 
 
 
 
45
  global $wpdb;
46
  $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d AND post_type = %s LIMIT 1", $postarr['ID'], $postarr['post_type'] ) );
47
 
42
  */
43
  public function filter__wp_insert_post_data( $data, $postarr ) {
44
 
45
+ /**
46
+ * Prevent to filter disabled post type.
47
+ *
48
+ * @since 2.1.4
49
+ */
50
+ if ( in_array( $data['post_type'], WPGlobus::Config()->disabled_entities, true ) ) {
51
+ return $data;
52
+ }
53
+
54
  global $wpdb;
55
  $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d AND post_type = %s LIMIT 1", $postarr['ID'], $postarr['post_type'] ) );
56
 
includes/builders/yoast_seo/class-wpglobus-yoast_seo-update-post.php CHANGED
@@ -19,27 +19,26 @@ if ( ! class_exists( 'WPGlobus_yoast_seo_Update_Post' ) ) :
19
  * Current taxonomy.
20
  */
21
  protected $taxonomy = '';
22
-
23
  /**
24
  * WP_Term object.
25
  */
26
  protected $tag;
27
-
28
  /**
29
  * Constructor.
30
  */
31
  public function __construct() {
32
 
33
-
34
  global $pagenow;
35
-
36
- if ( 'edit-tags.php' == $pagenow && $_POST['action'] == 'editedtag' ) {
37
  /**
38
  * Update button was clicked.
39
  */
40
- $this->build_ml_description();
41
  }
42
-
43
  /**
44
  * @see_file wpglobus\includes\class-wpglobus.php
45
  */
@@ -49,73 +48,70 @@ if ( ! class_exists( 'WPGlobus_yoast_seo_Update_Post' ) ) :
49
  * @todo incorrect the saving post in extra languages with priority = 10
50
  */
51
  add_filter( 'wp_insert_post_data', array( $this, 'filter__wp_insert_post_data' ), 100, 2 );
52
-
53
- $this->taxonomy = WPGlobus::Config()->builder->get('taxonomy');
54
-
55
- if ( $this->taxonomy ) {
56
-
57
  add_filter( 'wp_update_term_data', array( $this, 'filter__update_term_data' ), 10, 4 );
58
 
59
  }
60
  }
61
-
62
  /**
63
  * Build multilingual description.
64
  * We don't have filter for description like filter for name @see 'wp_update_term_data' in wp-includes\taxonomy.php
65
  */
66
  public function build_ml_description() {
67
-
68
  global $wpdb;
69
-
70
  $current_language = WPGlobus::Config()->builder->get_language();
71
-
72
- $tag_ID = (int) $_POST['tag_ID'];
73
- $taxonomy = $_POST['taxonomy'];
74
-
75
  $this->tag = get_term( $tag_ID, $taxonomy );
76
 
77
- if ( is_wp_error($this->tag) ) {
78
-
79
- $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id = %d", $tag_ID) );
80
- if ( ! empty($terms[0]) && is_object($terms[0]) ) {
81
- $this->tag = $terms[0];
82
- }
83
 
 
 
 
 
84
  }
85
-
86
- if ( is_wp_error($this->tag) ) {
87
  /**
88
  * @todo Investigate.
89
  */
90
  return;
91
  }
92
-
93
  $new_desc = array();
94
-
95
  foreach ( WPGlobus::Config()->enabled_languages as $lang ) :
96
 
97
  if ( $lang === $current_language ) {
98
 
99
- $text = trim( $_POST['description'] );
100
  if ( ! empty( $text ) ) {
101
  $new_desc[ $lang ] = $text;
102
  }
103
-
104
  } else {
105
 
106
  $text = WPGlobus_Core::text_filter( $this->tag->description, $lang, WPGlobus::RETURN_EMPTY );
107
  if ( ! empty( $text ) ) {
108
  $new_desc[ $lang ] = $text;
109
  }
110
-
111
  }
112
 
113
- endforeach;
114
 
115
  $_POST['description'] = WPGlobus_Utils::build_multilingual_string( $new_desc );
116
 
117
  }
118
-
119
  /**
120
  * Filters term data before it is updated in the database.
121
  *
@@ -123,25 +119,35 @@ if ( ! class_exists( 'WPGlobus_yoast_seo_Update_Post' ) ) :
123
  * @param int $term_id Term ID.
124
  * @param string $taxonomy Taxonomy slug.
125
  * @param array $args Arguments passed to wp_update_term().
 
 
126
  */
127
- public function filter__update_term_data( $data, $term_id, $taxonomy, $args ) {
128
-
129
- if ( is_wp_error($this->tag) ) {
 
 
 
 
 
 
 
 
130
  /**
131
  * @todo Investigate.
132
  * may be to use $args.
133
  */
134
  return $data;
135
  }
136
-
137
  if ( WPGlobus::Config()->builder && ! WPGlobus::Config()->builder->is_builder_page() ) {
138
  return $data;
139
  }
140
-
141
  $current_language = WPGlobus::Config()->builder->get_language();
142
-
143
  $new_name = array();
144
-
145
  foreach ( WPGlobus::Config()->enabled_languages as $lang ) :
146
 
147
  if ( $lang === $current_language ) {
@@ -150,24 +156,22 @@ if ( ! class_exists( 'WPGlobus_yoast_seo_Update_Post' ) ) :
150
  if ( ! empty( $text ) ) {
151
  $new_name[ $lang ] = $text;
152
  }
153
-
154
  } else {
155
 
156
  $text = WPGlobus_Core::text_filter( $this->tag->name, $lang, WPGlobus::RETURN_EMPTY );
157
  if ( ! empty( $text ) ) {
158
  $new_name[ $lang ] = $text;
159
  }
160
-
161
  }
162
 
163
- endforeach;
 
 
164
 
165
- $data['name'] = WPGlobus_Utils::build_multilingual_string( $new_name );
166
-
167
  return $data;
168
-
169
  }
170
-
171
  /**
172
  * Callback for 'wp_insert_post_data'.
173
  *
@@ -178,6 +182,15 @@ if ( ! class_exists( 'WPGlobus_yoast_seo_Update_Post' ) ) :
178
  */
179
  public function filter__wp_insert_post_data( $data, $postarr ) {
180
 
 
 
 
 
 
 
 
 
 
181
  global $wpdb;
182
  $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d AND post_type = %s LIMIT 1", $postarr['ID'], $postarr['post_type'] ) );
183
 
19
  * Current taxonomy.
20
  */
21
  protected $taxonomy = '';
22
+
23
  /**
24
  * WP_Term object.
25
  */
26
  protected $tag;
27
+
28
  /**
29
  * Constructor.
30
  */
31
  public function __construct() {
32
 
 
33
  global $pagenow;
34
+
35
+ if ( 'edit-tags.php' === $pagenow && 'editedtag' === $_POST['action'] ) { // phpcs:ignore WordPress.CSRF.NonceVerification
36
  /**
37
  * Update button was clicked.
38
  */
39
+ $this->build_ml_description();
40
  }
41
+
42
  /**
43
  * @see_file wpglobus\includes\class-wpglobus.php
44
  */
48
  * @todo incorrect the saving post in extra languages with priority = 10
49
  */
50
  add_filter( 'wp_insert_post_data', array( $this, 'filter__wp_insert_post_data' ), 100, 2 );
51
+
52
+ $this->taxonomy = WPGlobus::Config()->builder->get( 'taxonomy' );
53
+
54
+ if ( $this->taxonomy ) {
55
+
56
  add_filter( 'wp_update_term_data', array( $this, 'filter__update_term_data' ), 10, 4 );
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
64
  */
65
  public function build_ml_description() {
66
+
67
  global $wpdb;
68
+
69
  $current_language = WPGlobus::Config()->builder->get_language();
70
+
71
+ $tag_ID = (int) $_POST['tag_ID'];
72
+ $taxonomy = $_POST['taxonomy']; // phpcs:ignore WordPress.CSRF.NonceVerification
73
+
74
  $this->tag = get_term( $tag_ID, $taxonomy );
75
 
76
+ if ( is_wp_error( $this->tag ) ) {
 
 
 
 
 
77
 
78
+ $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id = %d", $tag_ID ) );
79
+ if ( ! empty( $terms[0] ) && is_object( $terms[0] ) ) {
80
+ $this->tag = $terms[0];
81
+ }
82
  }
83
+
84
+ if ( is_wp_error( $this->tag ) ) {
85
  /**
86
  * @todo Investigate.
87
  */
88
  return;
89
  }
90
+
91
  $new_desc = array();
92
+
93
  foreach ( WPGlobus::Config()->enabled_languages as $lang ) :
94
 
95
  if ( $lang === $current_language ) {
96
 
97
+ $text = trim( $_POST['description'] ); // phpcs:ignore WordPress.CSRF.NonceVerification
98
  if ( ! empty( $text ) ) {
99
  $new_desc[ $lang ] = $text;
100
  }
 
101
  } else {
102
 
103
  $text = WPGlobus_Core::text_filter( $this->tag->description, $lang, WPGlobus::RETURN_EMPTY );
104
  if ( ! empty( $text ) ) {
105
  $new_desc[ $lang ] = $text;
106
  }
 
107
  }
108
 
109
+ endforeach;
110
 
111
  $_POST['description'] = WPGlobus_Utils::build_multilingual_string( $new_desc );
112
 
113
  }
114
+
115
  /**
116
  * Filters term data before it is updated in the database.
117
  *
119
  * @param int $term_id Term ID.
120
  * @param string $taxonomy Taxonomy slug.
121
  * @param array $args Arguments passed to wp_update_term().
122
+ *
123
+ * @return array
124
  */
125
+ public function filter__update_term_data(
126
+ $data,
127
+ /** @noinspection PhpUnusedParameterInspection */
128
+ $term_id,
129
+ /** @noinspection PhpUnusedParameterInspection */
130
+ $taxonomy,
131
+ /** @noinspection PhpUnusedParameterInspection */
132
+ $args
133
+ ) {
134
+
135
+ if ( is_wp_error( $this->tag ) ) {
136
  /**
137
  * @todo Investigate.
138
  * may be to use $args.
139
  */
140
  return $data;
141
  }
142
+
143
  if ( WPGlobus::Config()->builder && ! WPGlobus::Config()->builder->is_builder_page() ) {
144
  return $data;
145
  }
146
+
147
  $current_language = WPGlobus::Config()->builder->get_language();
148
+
149
  $new_name = array();
150
+
151
  foreach ( WPGlobus::Config()->enabled_languages as $lang ) :
152
 
153
  if ( $lang === $current_language ) {
156
  if ( ! empty( $text ) ) {
157
  $new_name[ $lang ] = $text;
158
  }
 
159
  } else {
160
 
161
  $text = WPGlobus_Core::text_filter( $this->tag->name, $lang, WPGlobus::RETURN_EMPTY );
162
  if ( ! empty( $text ) ) {
163
  $new_name[ $lang ] = $text;
164
  }
 
165
  }
166
 
167
+ endforeach;
168
+
169
+ $data['name'] = WPGlobus_Utils::build_multilingual_string( $new_name );
170
 
 
 
171
  return $data;
172
+
173
  }
174
+
175
  /**
176
  * Callback for 'wp_insert_post_data'.
177
  *
182
  */
183
  public function filter__wp_insert_post_data( $data, $postarr ) {
184
 
185
+ /**
186
+ * Prevent to filter disabled post type.
187
+ *
188
+ * @since 2.1.4
189
+ */
190
+ if ( in_array( $data['post_type'], WPGlobus::Config()->disabled_entities, true ) ) {
191
+ return $data;
192
+ }
193
+
194
  global $wpdb;
195
  $_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d AND post_type = %s LIMIT 1", $postarr['ID'], $postarr['post_type'] ) );
196
 
readme.txt CHANGED
@@ -216,6 +216,11 @@ WPGlobus Version 2 supports WordPress 5.x, with Gutenberg.
216
 
217
  == Changelog ==
218
 
 
 
 
 
 
219
  = 2.1.3 =
220
 
221
  * ADDED:
@@ -228,34 +233,6 @@ WPGlobus Version 2 supports WordPress 5.x, with Gutenberg.
228
  * FIXED:
229
  * Builders/Gutenberg: the CPT support when the `Classic Editor` plugin is not active.
230
 
231
- = 2.1.1 =
232
-
233
- * FIXED:
234
- * Builders/Core: use the default language when creating a new post (on the `post-new.php` admin page).
235
- * TWEAK:
236
- * Builders/Core: update admin bar label for WordPress 5.
237
- * Helpdesk: prevent duplicate clicks on the `Send` button.
238
-
239
- = 2.1.0 =
240
-
241
- * ADDED:
242
- * Builders/Core: added Yoast SEO Premium to the list of supported add-ons.
243
- * Builders/Gutenberg: added the Custom Post Type support.
244
- * TWEAK:
245
- * Builders/Gutenberg: visual improvements.
246
-
247
- = 2.0.1 =
248
-
249
- * FIXED:
250
- * Builders/Gutenberg: saving posts correctly in the WordPress 5 'classic-editor' mode.
251
-
252
- = 2.0.0 =
253
-
254
- * COMPATIBILITY:
255
- * WordPress 5.0 (with Gutenberg in the WP Core)
256
- * ADDED:
257
- * Vendor/Yoast SEO: multilingual taxonomy support (`term.php` page).
258
-
259
  = Earlier versions and Add-ons =
260
 
261
  * [See the complete changelog here](https://github.com/WPGlobus/WPGlobus/blob/master/CHANGELOG.md)
216
 
217
  == Changelog ==
218
 
219
+ = 2.1.4 =
220
+
221
+ * FIXED:
222
+ * Builders: prevent to filter disabled post types.
223
+
224
  = 2.1.3 =
225
 
226
  * ADDED:
233
  * FIXED:
234
  * Builders/Gutenberg: the CPT support when the `Classic Editor` plugin is not active.
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  = Earlier versions and Add-ons =
237
 
238
  * [See the complete changelog here](https://github.com/WPGlobus/WPGlobus/blob/master/CHANGELOG.md)
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.1.3
19
  * Author: WPGlobus
20
  * Author URI: https://wpglobus.com/
21
  * Network: false
@@ -42,7 +42,7 @@ if ( ! defined( 'ABSPATH' ) ) {
42
  exit;
43
  }
44
 
45
- define( 'WPGLOBUS_VERSION', '2.1.3' );
46
  define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
47
 
48
  /**
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.1.4
19
  * Author: WPGlobus
20
  * Author URI: https://wpglobus.com/
21
  * Network: false
42
  exit;
43
  }
44
 
45
+ define( 'WPGLOBUS_VERSION', '2.1.4' );
46
  define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
47
 
48
  /**