Black Studio TinyMCE Widget - Version 2.5.0

Version Description

(2017-10-01) = * Fixed compatibility issue with Elementor Page Builder plugin (auto-disabled when editing a page with Elementor) * Fixed compatibility issue with WP Page Widget and WPML (widgets added in a page will not be translated) * Added checks on user meta usage (not allowed on VIP)

Download this release

Release Info

Developer marcochiesi
Plugin Icon 128x128 Black Studio TinyMCE Widget
Version 2.5.0
Comparing to
See all releases

Code changes from version 2.4.2 to 2.5.0

black-studio-tinymce-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Black Studio TinyMCE Widget
4
  Plugin URI: https://wordpress.org/plugins/black-studio-tinymce-widget/
5
  Description: Adds a new "Visual Editor" widget type based on the native WordPress TinyMCE editor.
6
- Version: 2.4.2
7
  Author: Black Studio
8
  Author URI: http://www.blackstudio.it
9
  Requires at least: 3.1
@@ -35,7 +35,7 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Plugin' ) ) {
35
  * @var string
36
  * @since 2.0.0
37
  */
38
- public static $version = '2.4.2';
39
 
40
  /**
41
  * The single instance of the plugin class
@@ -225,7 +225,9 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Plugin' ) ) {
225
  if ( ! is_blog_installed() ) {
226
  return;
227
  }
228
- register_widget( 'WP_Widget_Black_Studio_TinyMCE' );
 
 
229
  }
230
 
231
  /**
3
  Plugin Name: Black Studio TinyMCE Widget
4
  Plugin URI: https://wordpress.org/plugins/black-studio-tinymce-widget/
5
  Description: Adds a new "Visual Editor" widget type based on the native WordPress TinyMCE editor.
6
+ Version: 2.5.0
7
  Author: Black Studio
8
  Author URI: http://www.blackstudio.it
9
  Requires at least: 3.1
35
  * @var string
36
  * @since 2.0.0
37
  */
38
+ public static $version = '2.5.0';
39
 
40
  /**
41
  * The single instance of the plugin class
225
  if ( ! is_blog_installed() ) {
226
  return;
227
  }
228
+ if ( ! is_admin() || self::$admin->enabled() ) {
229
+ register_widget( 'WP_Widget_Black_Studio_TinyMCE' );
230
+ }
231
  }
232
 
233
  /**
includes/class-admin-pointer.php CHANGED
@@ -137,7 +137,7 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Admin_Pointer' ) ) {
137
  */
138
  public function filter_dismissed( $pointers ) {
139
  $valid_pointers = array();
140
- if ( is_array( $pointers ) ) {
141
  $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
142
  foreach ( $pointers as $pointer_id => $pointer ) {
143
  if ( ! in_array( $pointer_id, $dismissed ) ) {
137
  */
138
  public function filter_dismissed( $pointers ) {
139
  $valid_pointers = array();
140
+ if ( is_array( $pointers ) && function_exists( 'get_user_meta' ) ) {
141
  $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
142
  foreach ( $pointers as $pointer_id => $pointer ) {
143
  if ( ! in_array( $pointer_id, $dismissed ) ) {
includes/class-admin.php CHANGED
@@ -442,12 +442,18 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Admin' ) ) {
442
  /**
443
  * Show admin notice when visual editor is disabled in current user's profile settings
444
  *
 
 
 
445
  * @return void
446
  * @since 2.4.0
447
  */
448
  public function visual_editor_disabled_notice() {
449
  global $pagenow;
450
- $dismissed = get_user_meta( get_current_user_id(), '_bstw_visual_editor_disabled_notice_dismissed', true );
 
 
 
451
  if ( 'widgets.php' == $pagenow && empty( $dismissed ) ) {
452
  echo '<div class="bstw-visual-editor-disabled-notice notice notice-warning is-dismissible">';
453
  /* translators: warning message shown when when visual editor is disabled in current user's profile settings */
@@ -459,11 +465,16 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Admin' ) ) {
459
  /**
460
  * Store dismission of the "Visual Editor disabled" notice for the current user
461
  *
 
 
 
462
  * @return void
463
  * @since 2.4.0
464
  */
465
  public function visual_editor_disabled_dismiss_notice() {
466
- add_user_meta( get_current_user_id(), '_bstw_visual_editor_disabled_notice_dismissed', true );
 
 
467
  }
468
 
469
  } // END class Black_Studio_TinyMCE_Admin
442
  /**
443
  * Show admin notice when visual editor is disabled in current user's profile settings
444
  *
445
+ * @uses get_user_meta()
446
+ * @uses get_current_user_id()
447
+ *
448
  * @return void
449
  * @since 2.4.0
450
  */
451
  public function visual_editor_disabled_notice() {
452
  global $pagenow;
453
+ $dismissed = false;
454
+ if ( function_exists( 'get_user_meta' ) ) {
455
+ $dismissed = get_user_meta( get_current_user_id(), '_bstw_visual_editor_disabled_notice_dismissed', true );
456
+ }
457
  if ( 'widgets.php' == $pagenow && empty( $dismissed ) ) {
458
  echo '<div class="bstw-visual-editor-disabled-notice notice notice-warning is-dismissible">';
459
  /* translators: warning message shown when when visual editor is disabled in current user's profile settings */
465
  /**
466
  * Store dismission of the "Visual Editor disabled" notice for the current user
467
  *
468
+ * @uses add_user_meta()
469
+ * @uses get_current_user_id()
470
+ *
471
  * @return void
472
  * @since 2.4.0
473
  */
474
  public function visual_editor_disabled_dismiss_notice() {
475
+ if ( function_exists( 'add_user_meta' ) ) {
476
+ add_user_meta( get_current_user_id(), '_bstw_visual_editor_disabled_notice_dismissed', true );
477
+ }
478
  }
479
 
480
  } // END class Black_Studio_TinyMCE_Admin
includes/class-compatibility-plugins.php CHANGED
@@ -110,11 +110,11 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
110
  * @since 2.3.0
111
  */
112
  public function wpml_widget_before( $args, $instance ) {
113
- if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
114
  // Avoid native WPML string translation of widget titles
115
  // For widgets inserted in pages built with Page Builder (SiteOrigin panels) and also when WPML Widgets is active
116
  if ( false !== has_filter( 'widget_title', 'icl_sw_filters_widget_title' ) ) {
117
- if ( isset( $instance['panels_info'] ) || is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
118
  remove_filter( 'widget_title', 'icl_sw_filters_widget_title', 0 );
119
  }
120
  }
@@ -138,9 +138,9 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
138
  * @since 2.3.0
139
  */
140
  public function wpml_widget_after( $args, $instance ) {
141
- if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
142
  if ( false === has_filter( 'widget_title', 'icl_sw_filters_widget_title' ) && function_exists( 'icl_sw_filters_widget_title' ) ) {
143
- if ( isset( $instance['panels_info'] ) || is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
144
  add_filter( 'widget_title', 'icl_sw_filters_widget_title', 0 );
145
  }
146
  }
@@ -162,9 +162,10 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
162
  * @since 2.0.0
163
  */
164
  public function wpml_widget_update( $instance, $widget ) {
165
- if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && ! is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
166
  if ( function_exists( 'icl_register_string' ) && ! empty( $widget->number ) ) {
167
- if ( ! isset( $instance['panels_info'] ) ) { // Avoid translation of Page Builder (SiteOrigin panels) widgets
 
168
  icl_register_string( 'Widgets', 'widget body - ' . $widget->id_base . '-' . $widget->number, $instance['text'] );
169
  }
170
  }
@@ -185,11 +186,11 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
185
  * @since 2.0.0
186
  */
187
  public function wpml_widget_text( $text, $instance = null, $widget = null ) {
188
- if( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && ! is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
189
  if ( bstw()->check_widget( $widget ) && ! empty( $instance ) ) {
190
  if ( function_exists( 'icl_t' ) ) {
191
- // Avoid translation of Page Builder (SiteOrigin panels) widgets
192
- if ( ! isset( $instance['panels_info'] ) ) {
193
  $text = icl_t( 'Widgets', 'widget body - ' . $widget->id_base . '-' . $widget->number, $text );
194
  }
195
  }
@@ -207,7 +208,7 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
207
  * @since 2.0.0
208
  */
209
  public function wp_page_widget() {
210
- add_action( 'admin_init', array( $this, 'wp_page_widget_admin_init' ) );
211
  }
212
 
213
  /**
@@ -221,10 +222,11 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
221
  * @return void
222
  * @since 2.0.0
223
  */
224
- public function wp_page_widget_admin_init() {
225
  if ( is_admin() && is_plugin_active( 'wp-page-widget/wp-page-widgets.php' ) && version_compare( get_bloginfo( 'version' ), '3.3', '>=' ) ) {
226
  add_filter( 'black_studio_tinymce_enable_pages', array( $this, 'wp_page_widget_enable_pages' ) );
227
  add_action( 'admin_print_scripts', array( $this, 'wp_page_widget_enqueue_script' ) );
 
228
  }
229
  }
230
 
@@ -247,6 +249,23 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
247
  return $pages;
248
  }
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  /**
251
  * Enqueue script for WP Page Widget plugin
252
  *
@@ -310,15 +329,15 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
310
  /**
311
  * Remove widget number to prevent translation when using Page Builder (SiteOrigin Panels) + WPML String Translation
312
  *
313
- * @param object $the_widget
314
  * @return object
315
  * @since 2.0.0
316
  */
317
- public function siteorigin_panels_widget_object( $the_widget ) {
318
- if ( isset( $the_widget->id_base ) && 'black-studio-tinymce' == $the_widget->id_base ) {
319
- $the_widget->number = '';
320
  }
321
- return $the_widget;
322
  }
323
 
324
  /**
@@ -408,6 +427,20 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility_Plugins' ) ) {
408
  add_filter( 'atd_load_scripts', '__return_true' );
409
  }
410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  } // END class Black_Studio_TinyMCE_Compatibility_Plugins
412
 
413
  } // END class_exists check
110
  * @since 2.3.0
111
  */
112
  public function wpml_widget_before( $args, $instance ) {
113
+ if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
114
  // Avoid native WPML string translation of widget titles
115
  // For widgets inserted in pages built with Page Builder (SiteOrigin panels) and also when WPML Widgets is active
116
  if ( false !== has_filter( 'widget_title', 'icl_sw_filters_widget_title' ) ) {
117
+ if ( isset( $instance['panels_info'] ) || isset( $instance['wp_page_widget'] ) || is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
118
  remove_filter( 'widget_title', 'icl_sw_filters_widget_title', 0 );
119
  }
120
  }
138
  * @since 2.3.0
139
  */
140
  public function wpml_widget_after( $args, $instance ) {
141
+ if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) {
142
  if ( false === has_filter( 'widget_title', 'icl_sw_filters_widget_title' ) && function_exists( 'icl_sw_filters_widget_title' ) ) {
143
+ if ( isset( $instance['panels_info'] ) || isset( $instance['wp_page_widget'] ) || is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
144
  add_filter( 'widget_title', 'icl_sw_filters_widget_title', 0 );
145
  }
146
  }
162
  * @since 2.0.0
163
  */
164
  public function wpml_widget_update( $instance, $widget ) {
165
+ if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && ! is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
166
  if ( function_exists( 'icl_register_string' ) && ! empty( $widget->number ) ) {
167
+ // Avoid translation of Page Builder (SiteOrigin panels) and WP Page Widget widgets
168
+ if ( ! isset( $instance['panels_info'] ) && ! isset( $instance['wp_page_widget'] ) ) {
169
  icl_register_string( 'Widgets', 'widget body - ' . $widget->id_base . '-' . $widget->number, $instance['text'] );
170
  }
171
  }
186
  * @since 2.0.0
187
  */
188
  public function wpml_widget_text( $text, $instance = null, $widget = null ) {
189
+ if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) && ! is_plugin_active( 'wpml-widgets/wpml-widgets.php' ) ) {
190
  if ( bstw()->check_widget( $widget ) && ! empty( $instance ) ) {
191
  if ( function_exists( 'icl_t' ) ) {
192
+ // Avoid translation of Page Builder (SiteOrigin panels) and WP Page Widget widgets
193
+ if ( ! isset( $instance['panels_info'] ) && ! isset( $instance['wp_page_widget'] ) ) {
194
  $text = icl_t( 'Widgets', 'widget body - ' . $widget->id_base . '-' . $widget->number, $text );
195
  }
196
  }
208
  * @since 2.0.0
209
  */
210
  public function wp_page_widget() {
211
+ add_action( 'init', array( $this, 'wp_page_widget_init' ), 0 );
212
  }
213
 
214
  /**
222
  * @return void
223
  * @since 2.0.0
224
  */
225
+ public function wp_page_widget_init() {
226
  if ( is_admin() && is_plugin_active( 'wp-page-widget/wp-page-widgets.php' ) && version_compare( get_bloginfo( 'version' ), '3.3', '>=' ) ) {
227
  add_filter( 'black_studio_tinymce_enable_pages', array( $this, 'wp_page_widget_enable_pages' ) );
228
  add_action( 'admin_print_scripts', array( $this, 'wp_page_widget_enqueue_script' ) );
229
+ add_filter( 'black_studio_tinymce_widget_update', array( $this, 'wp_page_widget_add_data' ), 10, 2 );
230
  }
231
  }
232
 
249
  return $pages;
250
  }
251
 
252
+ /**
253
+ * Add WP Page Widget marker
254
+ *
255
+ * @param mixed[] $instance
256
+ * @param object $widget
257
+ * @return mixed[]
258
+ * @since 2.5.0
259
+ */
260
+ public function wp_page_widget_add_data( $instance, $widget ) {
261
+ if ( bstw()->check_widget( $widget ) && ! empty( $instance ) ) {
262
+ if ( isset( $_POST['action'] ) && 'pw-save-widget' == $_POST['action'] ) {
263
+ $instance['wp_page_widget'] = true;
264
+ }
265
+ }
266
+ return $instance;
267
+ }
268
+
269
  /**
270
  * Enqueue script for WP Page Widget plugin
271
  *
329
  /**
330
  * Remove widget number to prevent translation when using Page Builder (SiteOrigin Panels) + WPML String Translation
331
  *
332
+ * @param object $widget
333
  * @return object
334
  * @since 2.0.0
335
  */
336
+ public function siteorigin_panels_widget_object( $widget ) {
337
+ if ( isset( $widget->id_base ) && 'black-studio-tinymce' == $widget->id_base ) {
338
+ $widget->number = '';
339
  }
340
+ return $widget;
341
  }
342
 
343
  /**
427
  add_filter( 'atd_load_scripts', '__return_true' );
428
  }
429
 
430
+ /**
431
+ * Compatibility for Elementor plugin
432
+ *
433
+ * @uses add_filter()
434
+ *
435
+ * @return void
436
+ * @since 2.5.0
437
+ */
438
+ public function elementor() {
439
+ if ( is_admin() && isset( $_GET['action'] ) && 'elementor' == $_GET['action'] ) {
440
+ add_filter( 'black_studio_tinymce_enable', '__return_false', 100 );
441
+ }
442
+ }
443
+
444
  } // END class Black_Studio_TinyMCE_Compatibility_Plugins
445
 
446
  } // END class_exists check
includes/class-compatibility.php CHANGED
@@ -121,7 +121,7 @@ if ( ! class_exists( 'Black_Studio_TinyMCE_Compatibility' ) ) {
121
  * @since 2.0.0
122
  */
123
  public function load_plugins() {
124
- $load_compatibility_plugins = apply_filters( 'black_studio_tinymce_load_compatibility_plugins', array( 'siteorigin_panels', 'wpml', 'jetpack_after_the_deadline', 'wp_page_widget' ) );
125
  if ( ! empty( $load_compatibility_plugins ) ) {
126
  include_once( plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-compatibility-plugins.php' );
127
  self::$plugins = Black_Studio_TinyMCE_Compatibility_Plugins::instance( $load_compatibility_plugins );
121
  * @since 2.0.0
122
  */
123
  public function load_plugins() {
124
+ $load_compatibility_plugins = apply_filters( 'black_studio_tinymce_load_compatibility_plugins', array( 'siteorigin_panels', 'wpml', 'jetpack_after_the_deadline', 'wp_page_widget', 'elementor' ) );
125
  if ( ! empty( $load_compatibility_plugins ) ) {
126
  include_once( plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-compatibility-plugins.php' );
127
  self::$plugins = Black_Studio_TinyMCE_Compatibility_Plugins::instance( $load_compatibility_plugins );
languages/black-studio-tinymce-widget.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the GPLv3.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Black Studio TinyMCE Widget 2.3.2\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://github.com/black-studio/black-studio-tinymce-widget/issues\n"
8
- "POT-Creation-Date: 2017-08-03 22:04:31+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -25,7 +25,7 @@ msgstr ""
25
  "X-Poedit-SearchPath-0: .\n"
26
  "X-Textdomain-Support: yes\n"
27
 
28
- #: black-studio-tinymce-widget.php:279
29
  #. translators: error message shown when multiple instance of the plugin are
30
  #. detected
31
  msgid ""
@@ -82,7 +82,7 @@ msgstr ""
82
  msgid "About Black Studio TinyMCE Widget plugin"
83
  msgstr ""
84
 
85
- #: includes/class-admin.php:454
86
  #. translators: warning message shown when when visual editor is disabled in
87
  #. current user's profile settings
88
  msgid ""
2
  # This file is distributed under the GPLv3.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Black Studio TinyMCE Widget 2.5.0\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://github.com/black-studio/black-studio-tinymce-widget/issues\n"
8
+ "POT-Creation-Date: 2017-09-30 22:53:41+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
25
  "X-Poedit-SearchPath-0: .\n"
26
  "X-Textdomain-Support: yes\n"
27
 
28
+ #: black-studio-tinymce-widget.php:281
29
  #. translators: error message shown when multiple instance of the plugin are
30
  #. detected
31
  msgid ""
82
  msgid "About Black Studio TinyMCE Widget plugin"
83
  msgstr ""
84
 
85
+ #: includes/class-admin.php:460
86
  #. translators: warning message shown when when visual editor is disabled in
87
  #. current user's profile settings
88
  msgid ""
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.blackstudio.it/en/wordpress-plugins/black-studio-tinymce
4
  Tags: wysiwyg, widget, tinymce, editor, image, media, rich text, rich text editor, visual editor, wysiwyg editor, tinymce editor, widget editor, html editor, wysiwyg widget, html widget, editor widget, text widget, rich text widget, enhanced text widget, tinymce widget, visual widget, image widget, media widget
5
  Requires at least: 3.1
6
  Tested up to: 4.8
7
- Stable tag: 2.4.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
@@ -189,6 +189,11 @@ DELETE FROM wp_usermeta WHERE meta_key LIKE '_bstw%';
189
 
190
  == Changelog ==
191
 
 
 
 
 
 
192
  = 2.4.2 (2017-08-04) =
193
  * Fixed other additional z-index issues on TinyMCE panels
194
 
@@ -480,5 +485,5 @@ DELETE FROM wp_usermeta WHERE meta_key LIKE '_bstw%';
480
 
481
  == Upgrade Notice ==
482
 
483
- = 2.4.2 =
484
  Version 2.x is a major update. If you are upgrading from version 1.x please ensure to backup your database before upgrading.
4
  Tags: wysiwyg, widget, tinymce, editor, image, media, rich text, rich text editor, visual editor, wysiwyg editor, tinymce editor, widget editor, html editor, wysiwyg widget, html widget, editor widget, text widget, rich text widget, enhanced text widget, tinymce widget, visual widget, image widget, media widget
5
  Requires at least: 3.1
6
  Tested up to: 4.8
7
+ Stable tag: 2.5.0
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl.html
10
 
189
 
190
  == Changelog ==
191
 
192
+ = 2.5.0 (2017-10-01) =
193
+ * Fixed compatibility issue with Elementor Page Builder plugin (auto-disabled when editing a page with Elementor)
194
+ * Fixed compatibility issue with WP Page Widget and WPML (widgets added in a page will not be translated)
195
+ * Added checks on user meta usage (not allowed on VIP)
196
+
197
  = 2.4.2 (2017-08-04) =
198
  * Fixed other additional z-index issues on TinyMCE panels
199
 
485
 
486
  == Upgrade Notice ==
487
 
488
+ = 2.5.0 =
489
  Version 2.x is a major update. If you are upgrading from version 1.x please ensure to backup your database before upgrading.