Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit a21c081

Browse files
committed
Merge branch 'release/2.1.12'
2 parents d40c044 + 6559d12 commit a21c081

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+443
-350
lines changed

assets/scripts/translator.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var wpm_translator = {
3030
return text;
3131
}
3232

33-
var split_regex = /(<!--:[a-z]{2}-->|<!--:-->|\[:[a-z]{2}\]|\[:\]|\{:[a-z]{2}\}|\{:\})/gi;
33+
var split_regex = /(<!--:[a-z-]+-->|<!--:-->|\[:[a-z-]+\]|\[:\]|\{:[a-z-]+\}|\{:\})/gi;
3434
var blocks = text.xsplit(split_regex);
3535

3636
if (typeof blocks !== 'object' || !Object.keys(blocks).length)
@@ -48,9 +48,9 @@ var wpm_translator = {
4848
results[item] = '';
4949
});
5050

51-
var clang_regex = /<!--:([a-z]{2})-->/gi;
52-
var blang_regex = /\[:([a-z]{2})\]/gi;
53-
var slang_regex = /\{:([a-z]{2})\}/gi; // @since 3.3.6 swirly brackets
51+
var clang_regex = /<!--:([a-z-]+)-->/gi;
52+
var blang_regex = /\[:([a-z-]+)\]/gi;
53+
var slang_regex = /\{:([a-z-]+)\}/gi;
5454
var lang = false;
5555
var matches;
5656
for (var i = 0; i < blocks.length; ++i) {

assets/scripts/translator.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/abstracts/abstract-wpm-object.php

+31-26
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ public function get_meta_field( $value, $object_id, $meta_key ) {
4444
switch ( $this->object_type ) {
4545

4646
case 'post':
47-
if ( is_null( wpm_get_post_config( get_post_type( $object_id ) ) ) ) {
47+
if ( null === wpm_get_post_config( get_post_type( $object_id ) ) ) {
4848
return $value;
4949
}
5050

5151
break;
5252

5353
case 'term':
5454
$term = get_term( $object_id );
55-
if ( ! $term || is_null( wpm_get_taxonomy_config( $term->taxonomy ) ) ) {
55+
if ( ! $term || null === wpm_get_taxonomy_config( $term->taxonomy ) ) {
5656
return $value;
5757
}
5858
}
@@ -76,16 +76,15 @@ public function get_meta_field( $value, $object_id, $meta_key ) {
7676
return $value;
7777
}
7878

79-
$meta_config = apply_filters( "wpm_{$meta_key}_meta_config", $object_fields_config[ $meta_key ], $object_id );
79+
$meta_config = apply_filters( "wpm_{$meta_key}_meta_config", $object_fields_config[ $meta_key ], false, $object_id );
8080
$meta_config = apply_filters( "wpm_{$this->object_type}_meta_{$meta_key}_config", $meta_config, $object_id );
8181

82-
if ( is_null( $meta_config ) ) {
82+
if ( null === $meta_config ) {
8383
return $value;
8484
}
8585

86-
$column = sanitize_key( $this->object_type . '_id' );
87-
$id_column = 'user' === $this->object_type ? 'umeta_id' : 'meta_id';
88-
86+
$column = sanitize_key( $this->object_type . '_id' );
87+
$id_column = 'user' === $this->object_type ? 'umeta_id' : 'meta_id';
8988
$meta_values = wp_cache_get( $object_id, $this->object_type . '_' . $meta_key . '_wpm_meta' );
9089
$values = array();
9190

@@ -119,7 +118,6 @@ public function get_meta_field( $value, $object_id, $meta_key ) {
119118
}
120119

121120
return null;
122-
123121
}
124122

125123
/**
@@ -139,15 +137,15 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
139137
switch ( $this->object_type ) {
140138

141139
case 'post':
142-
if ( is_null( wpm_get_post_config( get_post_type( $object_id ) ) ) ) {
140+
if ( null === wpm_get_post_config( get_post_type( $object_id ) ) ) {
143141
return $check;
144142
}
145143

146144
break;
147145

148146
case 'term':
149147
$term = get_term( $object_id );
150-
if ( ! $term || is_null( wpm_get_taxonomy_config( $term->taxonomy ) ) ) {
148+
if ( ! $term || null === wpm_get_taxonomy_config( $term->taxonomy ) ) {
151149
return $check;
152150
}
153151
}
@@ -162,14 +160,13 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
162160
$meta_config = apply_filters( "wpm_{$meta_key}_meta_config", $object_fields_config[ $meta_key ], $meta_value, $object_id );
163161
$meta_config = apply_filters( "wpm_{$this->object_type}_meta_{$meta_key}_config", $meta_config, $meta_value, $object_id );
164162

165-
if ( is_null( $meta_config ) ) {
163+
if ( null === $meta_config ) {
166164
return $check;
167165
}
168166

169167
$table = $wpdb->{$this->object_table};
170168
$column = sanitize_key( $this->object_type . '_id' );
171169
$id_column = 'user' === $this->object_type ? 'umeta_id' : 'meta_id';
172-
173170
$meta_value = apply_filters( 'wpm_update_meta_value', $meta_value, $meta_key );
174171
$meta_value = apply_filters( "wpm_update_{$meta_key}_meta_value", $meta_value );
175172
$meta_value = apply_filters( "wpm_update_{$this->object_type}_meta_{$meta_key}_value", $meta_value );
@@ -205,6 +202,7 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
205202
$old_value = maybe_unserialize( $old_value );
206203
$old_value = apply_filters( "wpm_filter_old_{$meta_key}_meta_value", $old_value, $meta_value, $meta_config );
207204
$meta_value = wpm_set_new_value( $old_value, $meta_value, $meta_config );
205+
$meta_value = apply_filters( "wpm_filter_new_{$meta_key}_meta_value", $meta_value, $old_value, $meta_config );
208206
}
209207

210208
$meta_value = maybe_serialize( $meta_value );
@@ -215,7 +213,7 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
215213

216214
if ( ! wpm_is_ml_value( $prev_value ) ) {
217215
$like = '%' . $wpdb->esc_like( esc_sql( $prev_value ) ) . '%';
218-
$prev_value = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->{$this->object_table}} WHERE meta_key = %s AND {$column} = %d AND meta_value LIKE '%s' LIMIT 1", $meta_key, $object_id, $like ) );
216+
$prev_value = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->{$this->object_table}} WHERE meta_key = %s AND {$column} = %d AND meta_value LIKE %s LIMIT 1", $meta_key, $object_id, $like ) );
219217
}
220218

221219
$prev_value = maybe_serialize( $prev_value );
@@ -295,7 +293,17 @@ public function update_meta_field( $check, $object_id, $meta_key, $meta_value, $
295293
return true;
296294
}
297295

298-
296+
/**
297+
* Add new meta for translation
298+
*
299+
* @param $check null|mixed
300+
* @param $object_id int
301+
* @param $meta_key
302+
* @param $meta_value mixed
303+
* @param $unique bool
304+
*
305+
* @return mixed
306+
*/
299307
public function add_meta_field( $check, $object_id, $meta_key, $meta_value, $unique ) {
300308
global $wpdb;
301309

@@ -306,14 +314,14 @@ public function add_meta_field( $check, $object_id, $meta_key, $meta_value, $uni
306314
switch ( $this->object_type ) {
307315

308316
case 'post':
309-
if ( is_null( wpm_get_post_config( get_post_type( $object_id ) ) ) ) {
317+
if ( null === wpm_get_post_config( get_post_type( $object_id ) ) ) {
310318
return $check;
311319
}
312320
break;
313321

314322
case 'term':
315323
$term = get_term( $object_id );
316-
if ( ! $term || is_null( wpm_get_taxonomy_config( $term->taxonomy ) ) ) {
324+
if ( ! $term || null === wpm_get_taxonomy_config( $term->taxonomy ) ) {
317325
return $check;
318326
}
319327
}
@@ -328,13 +336,12 @@ public function add_meta_field( $check, $object_id, $meta_key, $meta_value, $uni
328336
$meta_config = apply_filters( "wpm_{$meta_key}_meta_config", $object_fields_config[ $meta_key ], $meta_value, $object_id );
329337
$meta_config = apply_filters( "wpm_{$this->object_type}_meta_{$meta_key}_config", $meta_config, $meta_value, $object_id );
330338

331-
if ( is_null( $meta_config ) ) {
339+
if ( null === $meta_config ) {
332340
return $check;
333341
}
334342

335-
$table = $wpdb->{$this->object_table};
336-
$column = sanitize_key( $this->object_type . '_id' );
337-
343+
$table = $wpdb->{$this->object_table};
344+
$column = sanitize_key( $this->object_type . '_id' );
338345
$meta_value = apply_filters( 'wpm_add_meta_value', $meta_value, $meta_key );
339346
$meta_value = apply_filters( "wpm_add_{$meta_key}_meta_value", $meta_value );
340347
$meta_value = apply_filters( "wpm_add_{$this->object_type}_meta_{$meta_key}_value", $meta_value );
@@ -343,15 +350,13 @@ public function add_meta_field( $check, $object_id, $meta_key, $meta_value, $uni
343350
$meta_value = wpm_set_new_value( array(), $meta_value, $meta_config );
344351
}
345352

346-
347353
if ( $unique && $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) )
348354
) {
349355
return false;
350356
}
351357

352358
$_meta_value = $meta_value;
353-
354-
$meta_value = maybe_serialize( $meta_value );
359+
$meta_value = maybe_serialize( $meta_value );
355360

356361
/**
357362
* Fires immediately before meta of a specific type is added.
@@ -411,22 +416,22 @@ public function delete_meta_field( $meta_ids, $object_id, $meta_key ) {
411416
switch ( $this->object_type ) {
412417

413418
case 'post':
414-
if ( is_null( wpm_get_post_config( get_post_type( $object_id ) ) ) ) {
419+
if ( null === wpm_get_post_config( get_post_type( $object_id ) ) ) {
415420
return;
416421
}
417422
break;
418423

419424
case 'term':
420425
$term = get_term( $object_id );
421-
if ( ! $term || is_null( wpm_get_taxonomy_config( $term->taxonomy ) ) ) {
426+
if ( ! $term || null === wpm_get_taxonomy_config( $term->taxonomy ) ) {
422427
return;
423428
}
424429
}
425430

426431
$config = wpm_get_config();
427432
$object_fields_config = apply_filters( "wpm_{$this->object_type}_fields_config", $config[ "{$this->object_type}_fields" ] );
428433

429-
if ( ! isset( $object_fields_config[ $meta_key ] ) || is_null( $object_fields_config[ $meta_key ] ) ) {
434+
if ( ! isset( $object_fields_config[ $meta_key ] ) || null === $object_fields_config[ $meta_key ] ) {
430435
return;
431436
}
432437

includes/abstracts/abstract-wpm-widget.php

-3
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ public function flush_widget_cache() {
115115
*
116116
* @param array $args
117117
* @param $instance
118-
*
119-
* @return string
120118
*/
121119
public function widget_start( $args, $instance ) {
122120
echo $args['before_widget'];
@@ -130,7 +128,6 @@ public function widget_start( $args, $instance ) {
130128
* Output the html at the end of a widget.
131129
*
132130
* @param array $args
133-
* @return string
134131
*/
135132
public function widget_end( $args ) {
136133
echo $args['after_widget'];

includes/admin/class-wpm-admin-assets.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function admin_scripts() {
7272

7373
wp_register_script( 'wpm_additional_settings', wpm_asset_path( 'scripts/additional-settings' . $suffix . '.js' ), array( 'jquery' ), WPM_VERSION );
7474

75-
if ( is_null( $screen ) ) {
75+
if ( null === $screen ) {
7676
return;
7777
}
7878

@@ -87,11 +87,11 @@ public function admin_scripts() {
8787

8888
$show_switcher = false;
8989

90-
if ( $screen->post_type && ! is_null( wpm_get_post_config( $screen->post_type ) ) && ( ( $screen_id == $screen->post_type ) || ( 'edit-' . $screen->post_type == $screen_id ) ) ) {
90+
if ( ( ( $screen_id === $screen->post_type ) || ( 'edit-' . $screen->post_type === $screen_id ) ) && $screen->post_type && null !== wpm_get_post_config( $screen->post_type ) ) {
9191
$show_switcher = true;
9292
}
9393

94-
if ( $screen->taxonomy && ! is_null( wpm_get_taxonomy_config( $screen->taxonomy ) ) && ( 'edit-' . $screen->taxonomy == $screen_id ) ) {
94+
if ( ( 'edit-' . $screen->taxonomy === $screen_id ) && $screen->taxonomy && null !== wpm_get_taxonomy_config( $screen->taxonomy ) ) {
9595
$show_switcher = true;
9696
}
9797

@@ -107,14 +107,14 @@ public function admin_scripts() {
107107

108108
$admin_html_tags = apply_filters( 'wpm_admin_html_tags', $config['admin_html_tags'] );
109109

110-
if ( isset( $admin_html_tags[ $screen_id ] ) && ! is_null( $admin_html_tags[ $screen_id ] ) ) {
110+
if ( isset( $admin_html_tags[ $screen_id ] ) && null !== $admin_html_tags[ $screen_id ] ) {
111111
wp_enqueue_script( 'wpm_translator' );
112112
$js_code = '';
113113
foreach ( $admin_html_tags[ $screen_id ] as $attr => $selector ) {
114114
$js_code .= '$( "' . implode( ', ', $selector ) . '" ).each( function () {';
115-
if ( 'text' == $attr ) {
115+
if ( 'text' === $attr ) {
116116
$js_code .= '$(this).text(wpm_translator.translate_string($(this).text()));';
117-
} elseif ( 'value' == $attr ) {
117+
} elseif ( 'value' === $attr ) {
118118
$js_code .= '$(this).val(wpm_translator.translate_string($(this).val()));';
119119
} else {
120120
$js_code .= '$(this).attr("' . $attr . '", wpm_translator.translate_string($(this).attr("' . $attr . '")));';
@@ -125,7 +125,7 @@ public function admin_scripts() {
125125
}
126126
}
127127

128-
if ( 'options-general' == $screen_id ) {
128+
if ( 'options-general' === $screen_id ) {
129129
wpm_enqueue_js( "$('#WPLANG').parents('tr').hide();" );
130130
}
131131
}

includes/admin/class-wpm-admin-edit-menus.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function wp_update_nav_menu_item_action( $menu_id, $menu_item_db_i
6868
}
6969

7070
// Update
71-
if ( ! is_null( $value ) ) {
71+
if ( null !== $value ) {
7272
update_post_meta( $menu_item_db_id, '_' . $key, $value );
7373
} else {
7474
delete_post_meta( $menu_item_db_id, '_' . $key );

includes/admin/class-wpm-admin-menus.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public function nav_menu_links() {
199199
*/
200200
public function menu_item_languages_setting( $item_id, $item ) {
201201

202-
if ( '#wpm-languages' != $item->url ) {
202+
if ( '#wpm-languages' !== $item->url ) {
203203
return;
204204
}
205205

@@ -263,7 +263,7 @@ public function update_nav_menu_item( $menu_id, $menu_item_db_id ) {
263263

264264
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
265265

266-
if ( empty( $_POST['menu-item-url'][ $menu_item_db_id ] ) || '#wpm-languages' != $_POST['menu-item-url'][ $menu_item_db_id ] ) {
266+
if ( empty( $_POST['menu-item-url'][ $menu_item_db_id ] ) || '#wpm-languages' !== $_POST['menu-item-url'][ $menu_item_db_id ] ) {
267267
return;
268268
}
269269

includes/admin/class-wpm-admin-meta-boxes.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function add_meta_boxes( $post_type ) {
9797
$screen = get_current_screen();
9898
$screen_id = $screen ? $screen->id : '';
9999

100-
if ( ! is_null( wpm_get_post_config( $post_type ) ) && ( 'attachment' !== $post_type ) ) {
100+
if ( ( 'attachment' !== $post_type ) && null !== wpm_get_post_config( $post_type ) ) {
101101
add_meta_box( "wpm-{$post_type}-languages", __( 'Languages', 'wp-multilang' ), __NAMESPACE__ . '\Meta_Boxes\WPM_Meta_Box_Post_Languages::output', $post_type, 'side' );
102102
}
103103

@@ -115,7 +115,7 @@ public function add_meta_boxes( $post_type ) {
115115
*/
116116
public function save_meta_boxes( $post_id, $post ) {
117117
// $post_id and $post are required
118-
if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
118+
if ( empty( $post_id ) || null === $post || self::$saved_meta_boxes ) {
119119
return;
120120
}
121121

@@ -130,7 +130,7 @@ public function save_meta_boxes( $post_id, $post ) {
130130
}
131131

132132
// Check the post being saved == the $post_id to prevent triggering this call for other save_post events
133-
if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) {
133+
if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] !== $post_id ) {
134134
return;
135135
}
136136

includes/admin/class-wpm-admin-notices.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ public static function remove_notice( $name ) {
9292
* @return boolean
9393
*/
9494
public static function has_notice( $name ) {
95-
return in_array( $name, self::get_notices() );
95+
return in_array( $name, self::get_notices(), true );
9696
}
9797

9898
/**
9999
* Hide a notice if the GET variable is set.
100100
*/
101101
public static function hide_notices() {
102-
if ( isset( $_GET['wpm-hide-notice'] ) && isset( $_GET['_wpm_notice_nonce'] ) ) {
102+
if ( isset( $_GET['wpm-hide-notice'], $_GET['_wpm_notice_nonce'] ) ) {
103103
if ( ! wp_verify_nonce( $_GET['_wpm_notice_nonce'], 'wpm_hide_notices_nonce' ) ) {
104104
wp_die( __( 'Action failed. Please refresh the page and retry.', 'wp-multilang' ) );
105105
}
@@ -163,7 +163,7 @@ public static function output_custom_notices() {
163163
$notice_html = get_option( 'wpm_admin_notice_' . $notice );
164164

165165
if ( $notice_html ) {
166-
include( 'views/html-notice-custom.php' );
166+
include 'views/html-notice-custom.php';
167167
}
168168
}
169169
}
@@ -176,13 +176,13 @@ public static function output_custom_notices() {
176176
public static function update_notice() {
177177
if ( version_compare( get_option( 'wpm_db_version' ), WPM_VERSION, '<' ) ) {
178178
$updater = new WPM_Background_Updater();
179-
if ( $updater->is_updating() || ! empty( $_GET['do_update_wpm'] ) ) {
180-
include( 'views/html-notice-updating.php' );
179+
if ( ! empty( $_GET['do_update_wpm'] ) || $updater->is_updating() ) {
180+
include 'views/html-notice-updating.php';
181181
} else {
182-
include( 'views/html-notice-update.php' );
182+
include 'views/html-notice-update.php';
183183
}
184184
} else {
185-
include( 'views/html-notice-updated.php' );
185+
include 'views/html-notice-updated.php';
186186
}
187187
}
188188
}

0 commit comments

Comments
 (0)