TinyMCE Advanced - Version 4.3.10

Version Description

  • Updated for WordPress 4.5.1 and TinyMCE 4.3.10.
  • Fixed support for adding editor-style.css to themes that don't have it.
Download this release

Release Info

Developer azaozz
Plugin Icon 128x128 TinyMCE Advanced
Version 4.3.10
Comparing to
See all releases

Code changes from version 4.3.8 to 4.3.10

Files changed (4) hide show
  1. css/tadv-styles.css +5 -0
  2. readme.txt +4 -0
  3. tadv_admin.php +38 -16
  4. tinymce-advanced.php +29 -7
css/tadv-styles.css CHANGED
@@ -276,3 +276,8 @@ div.tadv-error {
276
  .tadvdropzone .tadv-placeholder {
277
  height: 28px;
278
  }
 
 
 
 
 
276
  .tadvdropzone .tadv-placeholder {
277
  height: 28px;
278
  }
279
+
280
+ .tadv-error {
281
+ color: #d54e21;
282
+ font-weight: bold;
283
+ }
readme.txt CHANGED
@@ -30,6 +30,10 @@ Best is to install directly from WordPress. If manual installation is required,
30
 
31
  == Changelog ==
32
 
 
 
 
 
33
  = 4.3.8 =
34
  * Updated for WordPress 4.5 and TinyMCE 4.3.8.
35
  * Separated standard options and admin options.
30
 
31
  == Changelog ==
32
 
33
+ = 4.3.10 =
34
+ * Updated for WordPress 4.5.1 and TinyMCE 4.3.10.
35
+ * Fixed support for adding editor-style.css to themes that don't have it.
36
+
37
  = 4.3.8 =
38
  * Updated for WordPress 4.5 and TinyMCE 4.3.8.
39
  * Separated standard options and admin options.
tadv_admin.php CHANGED
@@ -52,7 +52,7 @@ if ( isset( $_POST['tadv-save'] ) ) {
52
  $plugins_array = array( 'anchor', 'code', 'insertdatetime', 'nonbreaking', 'print', 'searchreplace',
53
  'table', 'visualblocks', 'visualchars' );
54
  }
55
-
56
  if ( ! empty( $_POST['fontsize_formats'] ) ) {
57
  $options_array[] = 'fontsize_formats';
58
  }
@@ -70,10 +70,6 @@ if ( isset( $_POST['tadv-save'] ) ) {
70
  $admin_settings_array[] = 'paste_images';
71
  }
72
 
73
- if ( ! empty( $_POST['editorstyle'] ) ) {
74
- $admin_settings_array[] = 'editorstyle';
75
- }
76
-
77
  if ( ! empty( $_POST['disabled_plugins'] ) && is_array( $_POST['disabled_plugins'] ) ) {
78
  foreach( $_POST['disabled_plugins'] as $plugin ) {
79
  if ( in_array( $this->all_plugins, $plugin, true ) ) {
@@ -467,22 +463,48 @@ if ( ! is_multisite() || current_user_can( 'manage_sites' ) ) {
467
  <h3><?php _e( 'Advanced Options', 'tinymce-advanced' ); ?></h3>
468
  <?php
469
 
470
- // The 'editorstyle' option for (very) old themes was deprecated. Still supported if present.
 
471
 
472
- if ( current_theme_supports( 'editor-style' ) ) {
473
- ?>
474
- <div>
475
- <label><input type="checkbox" name="importcss" id="importcss" <?php if ( $this->check_admin_setting( 'importcss' ) ) echo ' checked="checked"'; ?> />
476
- <?php _e( 'Create CSS classes menu', 'tinymce-advanced' ); ?></label>
477
- <p>
478
- <?php _e( 'Load the CSS classes used in editor-style.css and replace the Formats button and sub-menu.', 'tinymce-advanced' ); ?>
479
- </p>
480
- </div>
481
- <?php
482
  }
483
 
484
  ?>
 
 
 
 
 
 
 
485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  <div>
487
  <label><input type="checkbox" name="no_autop" id="no_autop" <?php if ( $this->check_admin_setting( 'no_autop' ) ) echo ' checked="checked"'; ?> />
488
  <?php _e( 'Keep paragraph tags', 'tinymce-advanced' ); ?></label>
52
  $plugins_array = array( 'anchor', 'code', 'insertdatetime', 'nonbreaking', 'print', 'searchreplace',
53
  'table', 'visualblocks', 'visualchars' );
54
  }
55
+
56
  if ( ! empty( $_POST['fontsize_formats'] ) ) {
57
  $options_array[] = 'fontsize_formats';
58
  }
70
  $admin_settings_array[] = 'paste_images';
71
  }
72
 
 
 
 
 
73
  if ( ! empty( $_POST['disabled_plugins'] ) && is_array( $_POST['disabled_plugins'] ) ) {
74
  foreach( $_POST['disabled_plugins'] as $plugin ) {
75
  if ( in_array( $this->all_plugins, $plugin, true ) ) {
463
  <h3><?php _e( 'Advanced Options', 'tinymce-advanced' ); ?></h3>
464
  <?php
465
 
466
+ $has_editor_style = $this->has_editor_style();
467
+ $disabled = ' disabled';
468
 
469
+ if ( $has_editor_style === 'not-supporetd' || $has_editor_style === 'not-present' ) {
470
+ add_editor_style();
471
+ }
472
+
473
+ if ( $this->has_editor_style() === 'present' ) {
474
+ $disabled = '';
475
+ $has_editor_style = 'present';
 
 
 
476
  }
477
 
478
  ?>
479
+ <div>
480
+ <label><input type="checkbox" name="importcss" id="importcss" <?php if ( ! $disabled && $this->check_admin_setting( 'importcss' ) ) echo ' checked="checked"'; echo $disabled; ?> />
481
+ <?php _e( 'Create CSS classes menu', 'tinymce-advanced' ); ?></label>
482
+ <p>
483
+ <?php
484
+
485
+ _e( 'Load the CSS classes used in editor-style.css and replace the Formats menu.', 'tinymce-advanced' );
486
 
487
+ if ( $has_editor_style === 'not-supporetd' ) {
488
+ ?>
489
+ <br>
490
+ <span class="tadv-error"><?php _e( 'ERROR:', 'tinymce-advanced' ); ?></span>
491
+ <?php _e( 'Your theme does not support editor-style.css.', 'tinymce-advanced' ); ?>
492
+ <?php
493
+ } elseif ( $disabled ) {
494
+ ?>
495
+ <br>
496
+ <span class="tadv-error"><?php _e( 'ERROR:', 'tinymce-advanced' ); ?></span>
497
+ <?php _e( 'A stylesheet file named editor-style.css was not added by your theme.', 'tinymce-advanced' ); ?>
498
+ <?php
499
+ }
500
+
501
+ if ( $has_editor_style === 'not-supporetd' || $disabled ) {
502
+ _e( 'To use this option, add editor-style.css to your theme or a child theme. Enabling this option will also load that stylesheet in the editor.', 'tinymce-advanced' );
503
+ }
504
+
505
+ ?>
506
+ </p>
507
+ </div>
508
  <div>
509
  <label><input type="checkbox" name="no_autop" id="no_autop" <?php if ( $this->check_admin_setting( 'no_autop' ) ) echo ' checked="checked"'; ?> />
510
  <?php _e( 'Keep paragraph tags', 'tinymce-advanced' ); ?></label>
tinymce-advanced.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: TinyMCE Advanced
4
  Plugin URI: http://www.laptoptips.ca/projects/tinymce-advanced/
5
  Description: Enables advanced features and plugins in TinyMCE, the visual editor in WordPress.
6
- Version: 4.3.8
7
  Author: Andrew Ozz
8
  Author URI: http://www.laptoptips.ca/
9
  License: GPL2
@@ -107,6 +107,8 @@ class Tinymce_Advanced {
107
  }
108
 
109
  public function disable_for_editor( $settings, $editor_id ) {
 
 
110
  if ( empty( $this->admin_settings ) ) {
111
  $this->load_settings();
112
  }
@@ -131,6 +133,14 @@ class Tinymce_Advanced {
131
  }
132
  }
133
 
 
 
 
 
 
 
 
 
134
  return $settings;
135
  }
136
 
@@ -138,6 +148,24 @@ class Tinymce_Advanced {
138
  return $this->disabled_for_editor;
139
  }
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  // When using a plugin that changes the paths dinamically, set these earlier than 'plugins_loaded' 50.
142
  public function set_paths() {
143
  if ( ! defined( 'TADV_URL' ) )
@@ -598,12 +626,6 @@ class Tinymce_Advanced {
598
  return $mce_plugins;
599
  }
600
 
601
- // import user created editor-style.css
602
- // Deprecated since
603
- if ( $this->check_admin_setting( 'editorstyle' ) && ! current_theme_supports( 'editor-style' ) ) {
604
- add_editor_style();
605
- }
606
-
607
  if ( ! is_array( $this->plugins ) ) {
608
  $this->plugins = array();
609
  }
3
  Plugin Name: TinyMCE Advanced
4
  Plugin URI: http://www.laptoptips.ca/projects/tinymce-advanced/
5
  Description: Enables advanced features and plugins in TinyMCE, the visual editor in WordPress.
6
+ Version: 4.3.10
7
  Author: Andrew Ozz
8
  Author URI: http://www.laptoptips.ca/
9
  License: GPL2
107
  }
108
 
109
  public function disable_for_editor( $settings, $editor_id ) {
110
+ static $editor_style_added = false;
111
+
112
  if ( empty( $this->admin_settings ) ) {
113
  $this->load_settings();
114
  }
133
  }
134
  }
135
 
136
+ if ( ! $this->disabled_for_editor && ! $editor_style_added ) {
137
+ if ( $this->check_admin_setting( 'importcss' ) && $this->has_editor_style() !== 'present' ) {
138
+ add_editor_style();
139
+ }
140
+
141
+ $editor_style_added = true;
142
+ }
143
+
144
  return $settings;
145
  }
146
 
148
  return $this->disabled_for_editor;
149
  }
150
 
151
+ private function has_editor_style() {
152
+ if ( ! current_theme_supports( 'editor-style' ) ) {
153
+ return 'not-supporetd';
154
+ }
155
+
156
+ $editor_stylesheets = get_editor_stylesheets();
157
+
158
+ if ( is_array( $editor_stylesheets ) ) {
159
+ foreach ( $editor_stylesheets as $url ) {
160
+ if ( strpos( $url, 'editor-style.css' ) !== false ) {
161
+ return 'present';
162
+ }
163
+ }
164
+ }
165
+
166
+ return 'not-present';
167
+ }
168
+
169
  // When using a plugin that changes the paths dinamically, set these earlier than 'plugins_loaded' 50.
170
  public function set_paths() {
171
  if ( ! defined( 'TADV_URL' ) )
626
  return $mce_plugins;
627
  }
628
 
 
 
 
 
 
 
629
  if ( ! is_array( $this->plugins ) ) {
630
  $this->plugins = array();
631
  }