WPGlobus – Multilingual Everything! - Version 2.2.24

Version Description

  • Added: (Core/Builders) Check if block editor is used with specific post types.
Download this release

Release Info

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

Code changes from version 2.2.23 to 2.2.24

includes/admin/register-post-types/class-wpglobus-register-post-types.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: class-wpglobus-register-post-types.php
4
+ *
5
+ * @since 2.2.24
6
+ * @package WPGlobus\Admin
7
+ */
8
+
9
+ /**
10
+ * Class WPGlobus_Register_Post_Types.
11
+ */
12
+ if ( ! class_exists( 'WPGlobus_Register_Post_Types' ) ) :
13
+
14
+ class WPGlobus_Register_Post_Types {
15
+
16
+ /**
17
+ * @var array
18
+ */
19
+ protected static $pages = array( 'edit.php', 'post.php' );
20
+
21
+ /**
22
+ * Don't handling with these post types.
23
+ * @var array
24
+ */
25
+ protected static $excluded_post_types = array(
26
+ 'attachment',
27
+ 'attachment:audio',
28
+ 'attachment:video',
29
+ 'revision',
30
+ 'nav_menu_item',
31
+ 'custom_css',
32
+ 'customize_changeset',
33
+ 'oembed_cache',
34
+ 'user_request',
35
+ 'wp_block',
36
+ );
37
+
38
+ /**
39
+ * @var array
40
+ */
41
+ protected static $post_types = array();
42
+
43
+ /**
44
+ * Constructor.
45
+ */
46
+ public static function construct() {
47
+
48
+ if ( ! WPGlobus_WP::is_pagenow(self::$pages) ) {
49
+ return;
50
+ }
51
+
52
+ /**
53
+ * @see wp-includes\post.php
54
+ */
55
+ add_action( 'registered_post_type', array( __CLASS__, 'on__registered' ), 10, 2 );
56
+
57
+ add_action( 'wp_loaded', array( __CLASS__, 'on__wp_loaded' ) );
58
+
59
+ }
60
+
61
+ /**
62
+ * Fires after a post type is registered.
63
+ *
64
+ * @param string $post_type Post type.
65
+ * @param WP_Post_Type $post_type_object Arguments used to register the post type.
66
+ */
67
+ public static function on__registered( $post_type, $post_type_object ) {
68
+
69
+ global $_wp_post_type_features;
70
+
71
+ if ( defined('DOING_AJAX') && DOING_AJAX ) {
72
+ return;
73
+ }
74
+
75
+ static $_init = null;
76
+
77
+ if ( is_null($_init) ) {
78
+
79
+ self::$excluded_post_types = array_merge(self::$excluded_post_types, WPGlobus::Config()->disabled_entities);
80
+
81
+ self::$excluded_post_types = array_unique( self::$excluded_post_types );
82
+
83
+ $_init = true;
84
+
85
+ }
86
+
87
+ if ( self::is_excluded_post_type($post_type) ) {
88
+ return;
89
+ }
90
+
91
+ if ( empty($_wp_post_type_features[$post_type]) ) {
92
+ return;
93
+ }
94
+
95
+ /**
96
+ * @see `use_block_editor_for_post_type()` in wp-admin\includes\post.php
97
+ */
98
+ self::$post_types[$post_type] = array(
99
+ 'show_in_rest' => $post_type_object->show_in_rest,
100
+ 'features' => $_wp_post_type_features[$post_type]
101
+ );
102
+
103
+ }
104
+
105
+ /**
106
+ * Fired to save option.
107
+ */
108
+ public static function on__wp_loaded() {
109
+
110
+ if ( defined('DOING_AJAX') && DOING_AJAX ) {
111
+ return;
112
+ }
113
+ if ( ! empty(self::$post_types) ) {
114
+ update_option( WPGlobus::Config()->option_register_post_types, self::$post_types, false );
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Check for excluded post type.
120
+ *
121
+ * @return bool
122
+ */
123
+ public static function is_excluded_post_type( $post_type = '') {
124
+
125
+ if ( empty($post_type) ) {
126
+ return true;
127
+ }
128
+
129
+ if ( in_array( $post_type, self::get_excluded_post_types() ) ) {
130
+ return true;
131
+ }
132
+
133
+ return false;
134
+ }
135
+
136
+ /**
137
+ * Get excluded post types.
138
+ *
139
+ * @return array
140
+ */
141
+ public static function get_excluded_post_types() {
142
+ return self::$excluded_post_types;
143
+ }
144
+ }
145
+
146
+ endif;
147
+ /* EOF */
includes/admin/wpglobus-admin.php CHANGED
@@ -12,6 +12,12 @@
12
  require_once dirname( __FILE__ ) . '/central/class-wpglobus-admin-central.php';
13
  WPGlobus_Admin_Central::construct();
14
 
 
 
 
 
 
 
15
  if ( ! empty( $_GET['wpglobus-debug'] ) && 'godmode' === $_GET['wpglobus-debug'] ) { // WPCS: input var ok, sanitization ok.
16
  /**
17
  * To load debug info
12
  require_once dirname( __FILE__ ) . '/central/class-wpglobus-admin-central.php';
13
  WPGlobus_Admin_Central::construct();
14
 
15
+ /**
16
+ * @since 2.2.24
17
+ */
18
+ require_once dirname( __FILE__ ) . '/register-post-types/class-wpglobus-register-post-types.php';
19
+ WPGlobus_Register_Post_Types::construct();
20
+
21
  if ( ! empty( $_GET['wpglobus-debug'] ) && 'godmode' === $_GET['wpglobus-debug'] ) { // WPCS: input var ok, sanitization ok.
22
  /**
23
  * To load debug info
includes/builders/class-wpglobus-builders.php CHANGED
@@ -33,6 +33,12 @@ if ( ! class_exists( 'WPGlobus_Builders' ) ) :
33
  * @since 2.2.11
34
  */
35
  protected static $post_type = null;
 
 
 
 
 
 
36
 
37
  /**
38
  * @return array
@@ -174,16 +180,26 @@ if ( ! class_exists( 'WPGlobus_Builders' ) ) :
174
 
175
  /**
176
  * @param bool $init
177
- * @param array $post_types was added @since 2.2.11
178
  *
179
  * @return array|bool
180
  */
181
- public static function get( $init = true, $post_types = array() ) {
182
 
183
  // if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
184
  //return false;
185
  // }
186
-
 
 
 
 
 
 
 
 
 
 
187
  /** @global string $pagenow */
188
  global $pagenow;
189
 
@@ -739,7 +755,18 @@ if ( ! class_exists( 'WPGlobus_Builders' ) ) :
739
  // if ( ! in_array( $post_type, array( 'post', 'page' ), true ) ) {
740
  // $load_gutenberg = false;
741
  // }
742
-
 
 
 
 
 
 
 
 
 
 
 
743
  $load_gutenberg = self::get_3rd_party_status_for_gutenberg( $load_gutenberg, $post_type );
744
 
745
  }
@@ -1324,7 +1351,43 @@ if ( ! class_exists( 'WPGlobus_Builders' ) ) :
1324
 
1325
  return self::$post_type;
1326
  }
 
 
 
 
 
 
 
 
 
 
 
1327
 
1328
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1329
 
1330
  endif;
33
  * @since 2.2.11
34
  */
35
  protected static $post_type = null;
36
+
37
+ /**
38
+ * @var array
39
+ * @since 2.2.24
40
+ */
41
+ protected static $init_attrs = null;
42
 
43
  /**
44
  * @return array
180
 
181
  /**
182
  * @param bool $init
183
+ * @param array $init_attrs added @since 2.2.24
184
  *
185
  * @return array|bool
186
  */
187
+ public static function get( $init = true, $init_attrs = array() ) {
188
 
189
  // if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
190
  //return false;
191
  // }
192
+
193
+ /**
194
+ * @since 2.2.24
195
+ */
196
+ self::$init_attrs = $init_attrs;
197
+
198
+ /**
199
+ * @since 2.2.24
200
+ */
201
+ $post_types = $init_attrs['post_types'];
202
+
203
  /** @global string $pagenow */
204
  global $pagenow;
205
 
755
  // if ( ! in_array( $post_type, array( 'post', 'page' ), true ) ) {
756
  // $load_gutenberg = false;
757
  // }
758
+
759
+ /**
760
+ * @since 2.2.24
761
+ */
762
+ if ( ! self::use_block_editor_for_post_type($post_type) ) {
763
+ /**
764
+ * Don't start Block Editor support.
765
+ */
766
+ return false;
767
+
768
+ }
769
+
770
  $load_gutenberg = self::get_3rd_party_status_for_gutenberg( $load_gutenberg, $post_type );
771
 
772
  }
1351
 
1352
  return self::$post_type;
1353
  }
1354
+
1355
+ /**
1356
+ * Check for post type supports.
1357
+ *
1358
+ * @since 2.2.24
1359
+ *
1360
+ * @return bool
1361
+ */
1362
+ protected static function use_block_editor_for_post_type($post_type) {
1363
+
1364
+ $_opts = get_option(self::$init_attrs['options']['register_post_types']);
1365
 
1366
+ if ( empty($_opts[$post_type]) ) {
1367
+ /**
1368
+ * We don't have info about post type.
1369
+ */
1370
+ return true;
1371
+ }
1372
+
1373
+ if ( empty($_opts[$post_type]['features']['editor']) || (int) $_opts[$post_type]['features']['editor'] == 0 ) {
1374
+ /**
1375
+ * Don't start Block Editor support.
1376
+ * @see `use_block_editor_for_post_type()` in wp-admin\includes\post.php
1377
+ */
1378
+ return false;
1379
+ }
1380
+
1381
+ if ( ! empty($_opts[$post_type]['show_in_rest']) && (int) $_opts[$post_type]['show_in_rest'] == 0 ) {
1382
+ /**
1383
+ * Don't start Block Editor support.
1384
+ * @see `use_block_editor_for_post_type()` in wp-admin\includes\post.php
1385
+ */
1386
+ return false;
1387
+ }
1388
+
1389
+ return true;
1390
+ }
1391
+ }
1392
 
1393
  endif;
includes/builders/class-wpglobus-config-builder.php CHANGED
@@ -66,9 +66,9 @@ if ( ! class_exists( 'WPGlobus_Config_Builder' ) ) :
66
 
67
  require_once dirname( __FILE__ ) . '/class-wpglobus-builders.php';
68
  /**
69
- * @since 2.2.11 was added second parameter.
70
  */
71
- $builder = WPGlobus_Builders::get(true, $this->post_types);
72
 
73
  $this->id = $builder['id'];
74
  unset( $builder['id'] );
66
 
67
  require_once dirname( __FILE__ ) . '/class-wpglobus-builders.php';
68
  /**
69
+ * @since 2.2.24 added $init_attrs.
70
  */
71
+ $builder = WPGlobus_Builders::get(true, $init_attrs);
72
 
73
  $this->id = $builder['id'];
74
  unset( $builder['id'] );
includes/class-wpglobus-config.php CHANGED
@@ -170,6 +170,13 @@ class WPGlobus_Config {
170
  */
171
  public $option_post_meta_settings = 'wpglobus_option_post_meta_settings';
172
 
 
 
 
 
 
 
 
173
  /**
174
  * @var string
175
  */
@@ -872,8 +879,11 @@ class WPGlobus_Config {
872
  $this->builder = new WPGlobus_Config_Builder(
873
  true,
874
  array(
875
- 'default_language' => $this->default_language,
876
- 'post_types' => $builder_post_types
 
 
 
877
  )
878
  );
879
 
170
  */
171
  public $option_post_meta_settings = 'wpglobus_option_post_meta_settings';
172
 
173
+ /**
174
+ * WPGlobus option key for registered post types.
175
+ * @since 2.2.24
176
+ * @var string
177
+ */
178
+ public $option_register_post_types = 'wpglobus_option_register_post_types';
179
+
180
  /**
181
  * @var string
182
  */
879
  $this->builder = new WPGlobus_Config_Builder(
880
  true,
881
  array(
882
+ 'default_language' => $this->default_language,
883
+ 'post_types' => $builder_post_types,
884
+ 'options' => array(
885
+ 'register_post_types' => $this->option_register_post_types, // @since 2.2.24
886
+ )
887
  )
888
  );
889
 
languages/wpglobus.pot CHANGED
@@ -1,8 +1,8 @@
1
- # Copyright (C) 2019 WPGlobus 2.2.23
2
- # This file is distributed under the same license as the WPGlobus 2.2.23 package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WPGlobus 2.2.23\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
1
+ # Copyright (C) 2019 WPGlobus 2.2.24
2
+ # This file is distributed under the same license as the WPGlobus 2.2.24 package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WPGlobus 2.2.24\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
readme.txt CHANGED
@@ -218,6 +218,10 @@ WPGlobus Version 2 supports WordPress 5.x, with Gutenberg.
218
 
219
  == Changelog ==
220
 
 
 
 
 
221
  = 2.2.23 =
222
 
223
  * Internal: (Options) Moved theme info to `Customize` section.
@@ -242,27 +246,6 @@ WPGlobus Version 2 supports WordPress 5.x, with Gutenberg.
242
  * Added: (Vendor/Yoast) Support Yoast SEO Premium from v.12.(Beta stage).
243
  * Added: (Core/WPGlobusDialogApp) `afterSave` callback.
244
 
245
- = 2.2.16 =
246
-
247
- * Added: (Vendor/Yoast) Filters for `SEO Title`, `Meta Desc` on `edit.php` page.
248
-
249
- = 2.2.15 =
250
-
251
- * Fixed: (Builders/Gutenberg) TypeError `Cannot read property 'PluginSidebarMoreMenuItem' of undefined`.
252
-
253
- = 2.2.14 =
254
-
255
- * Added: (Options/Builders) Pinned button type option for builder mode.
256
- * Added: (Flag) `serbska_malka.png`.
257
-
258
- = 2.2.13 =
259
-
260
- * Fixed: `extract_text()` regex to support line breaks in strings.
261
-
262
- = 2.2.12 =
263
-
264
- * Fixed: (Config) PHP warnings for clean install.
265
-
266
  = Earlier versions and Add-ons =
267
 
268
  * [See the complete changelog here](https://github.com/WPGlobus/WPGlobus/blob/master/CHANGELOG.md)
218
 
219
  == Changelog ==
220
 
221
+ = 2.2.24 =
222
+
223
+ * Added: (Core/Builders) Check if block editor is used with specific post types.
224
+
225
  = 2.2.23 =
226
 
227
  * Internal: (Options) Moved theme info to `Customize` section.
246
  * Added: (Vendor/Yoast) Support Yoast SEO Premium from v.12.(Beta stage).
247
  * Added: (Core/WPGlobusDialogApp) `afterSave` callback.
248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  = Earlier versions and Add-ons =
250
 
251
  * [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.2.23
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.2.23' );
46
  define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
47
  define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
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.2.24
19
  * Author: WPGlobus
20
  * Author URI: https://wpglobus.com/
21
  * Network: false
42
  exit;
43
  }
44
 
45
+ define( 'WPGLOBUS_VERSION', '2.2.24' );
46
  define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
47
  define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
48