MCE Table Buttons - Version 3.3.1

Version Description

Note that this release replaces references of master with trunk so please plan to update any references you have from master to trunk to ensure you continue to receive the latest updates on this plugin.

  • Changed: Bump WordPress version tested up to 5.8 (props David Chabbi, @jeffpaul, @ciprianimike).
  • Changed: Updated documentation including new GitHub Actions (props @jeffpaul, @dinhtungdu).
  • Fixed: Issues reported by PHPCS WPCS v2.3.0 (props @ciprianimike, @dinhtungdu).
Download this release

Release Info

Developer 10up
Plugin Icon 128x128 MCE Table Buttons
Version 3.3.1
Comparing to
See all releases

Code changes from version 3.3 to 3.3.1

mce_table_buttons.php → class-mce-table-buttons.php RENAMED
@@ -1,124 +1,137 @@
1
- <?php
2
- /**
3
- * Plugin Name: MCE Table Buttons
4
- * Plugin URI: http://10up.com/plugins-modules/wordpress-mce-table-buttons/
5
- * Description: Add <strong>controls for table editing</strong> to the visual content editor with this <strong>light weight</strong> plug-in.
6
- * Version: 3.3
7
- * Author: Jake Goldman, 10up, Oomph
8
- * Author URI: http://10up.com
9
- * License: GPLv2 or later
10
- */
11
-
12
- class MCE_Table_Buttons {
13
-
14
- /**
15
- * Handles initializing this class and returning the singleton instance after it's been cached.
16
- *
17
- * @return null|MCE_Table_Buttons
18
- */
19
- public static function get_instance() {
20
- // Store the instance locally to avoid private static replication
21
- static $instance = null;
22
-
23
- if ( null === $instance ) {
24
- $instance = new self();
25
- self::_setup_plugin();
26
- }
27
-
28
- return $instance;
29
- }
30
-
31
- /**
32
- * An empty constructor
33
- */
34
- public function __construct() { /* Purposely do nothing here */ }
35
-
36
- /**
37
- * Handles registering hooks that initialize this plugin.
38
- */
39
- public static function _setup_plugin() {
40
- add_filter( 'mce_external_plugins', array( __CLASS__, 'mce_external_plugins' ) );
41
- add_filter( 'mce_buttons_2', array( __CLASS__, 'mce_buttons_2' ) );
42
- add_filter( 'content_save_pre', array( __CLASS__, 'content_save_pre' ), 20 );
43
- add_filter( 'tiny_mce_before_init', array( __CLASS__, 'tiny_mce_before_init' ), 10, 2 );
44
- }
45
-
46
- /**
47
- * Initialize TinyMCE table plugin and custom TinyMCE plugin
48
- *
49
- * @param array $plugin_array Array of TinyMCE plugins
50
- * @return array Array of TinyMCE plugins
51
- */
52
- public static function mce_external_plugins( $plugin_array ) {
53
- global $tinymce_version;
54
- $variant = ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ? '' : '.min';
55
-
56
- if ( version_compare( $tinymce_version, '4700', '<' ) ) {
57
-
58
- $plugin_array['table'] = plugin_dir_url( __FILE__ ) . 'tinymce41-table/plugin' . $variant . '.js';
59
-
60
- } else {
61
-
62
- $plugin_array['table'] = plugin_dir_url( __FILE__ ) . 'tinymce47-table/plugin' . $variant . '.js';
63
-
64
- }
65
-
66
- return $plugin_array;
67
- }
68
-
69
- /**
70
- * Add TinyMCE table control buttons
71
- *
72
- * @param array $buttons Buttons for the second row
73
- * @return array Buttons for the second row
74
- */
75
- public static function mce_buttons_2( $buttons ) {
76
- // in case someone is manipulating other buttons, drop table controls at the end of the row
77
- if ( ! $pos = array_search( 'undo', $buttons ) ) {
78
- array_push( $buttons, 'table' );
79
- return $buttons;
80
- }
81
-
82
- $buttons = array_merge( array_slice( $buttons, 0, $pos ), array( 'table' ), array_slice( $buttons, $pos ) );
83
-
84
- return $buttons;
85
- }
86
-
87
- /**
88
- * Fixes weirdness resulting from wpautop and formatting clean up not built for tables
89
- *
90
- * @param string $content Editor content before WordPress massaging
91
- * @return string Editor content before WordPress massaging
92
- */
93
- public static function content_save_pre( $content ) {
94
- if ( false !== strpos( $content, '<table' ) ) {
95
- // paragraphed content inside of a td requires first paragraph to have extra line breaks (or else autop breaks)
96
- $content = preg_replace( "/<td([^>]*)>(.+\r?\n\r?\n)/m", "<td$1>\n\n$2", $content );
97
-
98
- // make sure there's space around the table
99
- if ( substr( $content, -8 ) == '</table>' ) {
100
- $content .= "\n<br />";
101
- }
102
- }
103
-
104
- return $content;
105
- }
106
-
107
- /**
108
- * Remove the table toolbar introduced in TinyMCE 4.3.0.
109
- *
110
- * Its positioning does not work correctly inside WordPress and blocks editing.
111
- *
112
- * @param array $mceInit An array with TinyMCE config.
113
- * @param string $editor_id Unique editor identifier, e.g. 'content'.
114
- *
115
- * @return array TinyMCE config array
116
- */
117
- public static function tiny_mce_before_init ( $mceInit, $editor_id ) {
118
- $mceInit['table_toolbar'] = '';
119
-
120
- return $mceInit;
121
- }
122
- }
123
-
124
- MCE_Table_Buttons::get_instance();
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MCE Table Buttons
4
+ *
5
+ * @package MCETableButtons
6
+ *
7
+ * @wordpress-plugin
8
+ * Plugin Name: MCE Table Buttons
9
+ * Plugin URI: http://10up.com/plugins-modules/wordpress-mce-table-buttons/
10
+ * Description: Add <strong>controls for table editing</strong> to the visual content editor with this <strong>light weight</strong> plug-in.
11
+ * Version: 3.3.1
12
+ * Requires at least: 4.0
13
+ * Requires PHP:
14
+ * Author: Jake Goldman, 10up, Oomph
15
+ * Author URI: https://10up.com
16
+ * License: GPL v2 or later
17
+ * License URI: https://www.gnu.org/licenses/gpl-2.0.html
18
+ */
19
+
20
+ /**
21
+ * MCE Table Buttons main class.
22
+ */
23
+ class MCE_Table_Buttons {
24
+ /**
25
+ * Handles initializing this class and returning the singleton instance after it's been cached.
26
+ *
27
+ * @return null|MCE_Table_Buttons
28
+ */
29
+ public static function get_instance() {
30
+ // Store the instance locally to avoid private static replication.
31
+ static $instance = null;
32
+
33
+ if ( null === $instance ) {
34
+ $instance = new self();
35
+ self::setup_plugin();
36
+ }
37
+
38
+ return $instance;
39
+ }
40
+
41
+ /**
42
+ * An empty constructor
43
+ */
44
+ public function __construct() {
45
+ /* Purposely do nothing here. */
46
+ }
47
+
48
+ /**
49
+ * Handles registering hooks that initialize this plugin.
50
+ */
51
+ public static function setup_plugin() {
52
+ add_filter( 'mce_external_plugins', array( __CLASS__, 'mce_external_plugins' ) );
53
+ add_filter( 'mce_buttons_2', array( __CLASS__, 'mce_buttons_2' ) );
54
+ add_filter( 'content_save_pre', array( __CLASS__, 'content_save_pre' ), 20 );
55
+ add_filter( 'tiny_mce_before_init', array( __CLASS__, 'tiny_mce_before_init' ), 10, 2 );
56
+ }
57
+
58
+ /**
59
+ * Initialize TinyMCE table plugin and custom TinyMCE plugin
60
+ *
61
+ * @param array $plugin_array Array of TinyMCE plugins.
62
+ * @return array Array of TinyMCE plugins
63
+ */
64
+ public static function mce_external_plugins( $plugin_array ) {
65
+ global $tinymce_version;
66
+ $variant = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
67
+
68
+ if ( version_compare( $tinymce_version, '4700', '<' ) ) {
69
+
70
+ $plugin_array['table'] = plugin_dir_url( __FILE__ ) . 'tinymce41-table/plugin' . $variant . '.js';
71
+
72
+ } else {
73
+
74
+ $plugin_array['table'] = plugin_dir_url( __FILE__ ) . 'tinymce47-table/plugin' . $variant . '.js';
75
+
76
+ }
77
+
78
+ return $plugin_array;
79
+ }
80
+
81
+ /**
82
+ * Add TinyMCE table control buttons
83
+ *
84
+ * @param array $buttons Buttons for the second row.
85
+ * @return array Buttons for the second row
86
+ */
87
+ public static function mce_buttons_2( $buttons ) {
88
+ // in case someone is manipulating other buttons, drop table controls at the end of the row.
89
+ $pos = array_search( 'undo', $buttons, true );
90
+ if ( ! $pos ) {
91
+ array_push( $buttons, 'table' );
92
+ return $buttons;
93
+ }
94
+
95
+ $buttons = array_merge( array_slice( $buttons, 0, $pos ), array( 'table' ), array_slice( $buttons, $pos ) );
96
+
97
+ return $buttons;
98
+ }
99
+
100
+ /**
101
+ * Fixes weirdness resulting from wpautop and formatting clean up not built for tables
102
+ *
103
+ * @param string $content Editor content before WordPress massaging.
104
+ * @return string Editor content before WordPress massaging
105
+ */
106
+ public static function content_save_pre( $content ) {
107
+ if ( false !== strpos( $content, '<table' ) ) {
108
+ // paragraphed content inside of a td requires first paragraph to have extra line breaks (or else autop breaks).
109
+ $content = preg_replace( "/<td([^>]*)>(.+\r?\n\r?\n)/m", "<td$1>\n\n$2", $content );
110
+
111
+ // make sure there's space around the table.
112
+ if ( '</table>' === substr( $content, -8 ) ) {
113
+ $content .= "\n<br />";
114
+ }
115
+ }
116
+
117
+ return $content;
118
+ }
119
+
120
+ /**
121
+ * Remove the table toolbar introduced in TinyMCE 4.3.0.
122
+ *
123
+ * Its positioning does not work correctly inside WordPress and blocks editing.
124
+ *
125
+ * @param array $mce_init An array with TinyMCE config.
126
+ * @param string $editor_id Unique editor identifier, e.g. 'content'.
127
+ *
128
+ * @return array TinyMCE config array
129
+ */
130
+ public static function tiny_mce_before_init( $mce_init, $editor_id ) {
131
+ $mce_init['table_toolbar'] = '';
132
+
133
+ return $mce_init;
134
+ }
135
+ }
136
+
137
+ MCE_Table_Buttons::get_instance();
readme.txt CHANGED
@@ -1,10 +1,13 @@
1
  === MCE Table Buttons ===
2
- Contributors: 10up, jakemgold, helen, thinkoomph
3
- Donate link: http://10up.com/plugins-modules/wordpress-mce-table-buttons/
4
- Tags: tables, table, editor, WYSIWYG, buttons, tinymce
5
  Requires at least: 4.0
6
- Tested up to: 4.9.6
7
- Stable tag: 3.3
 
 
 
8
 
9
  Adds table editing controls to the visual content editor (TinyMCE).
10
 
@@ -29,6 +32,13 @@ Note that the table controls are contained in the “kitchen sink” toolbar, to
29
 
30
  == Changelog ==
31
 
 
 
 
 
 
 
 
32
  = 3.3 =
33
  * Significantly update TinyMCE plugin from 4.1.x to 4.7.11
34
  * Drop support for WordPress 3.x, which means dropping TinyMCE 3.x and 4.0.x
@@ -72,5 +82,8 @@ Note that the table controls are contained in the “kitchen sink” toolbar, to
72
 
73
  == Upgrade Notice ==
74
 
 
 
 
75
  = 1.5 =
76
  REQUIRES WordPress 3.3 or higher. Finally links table buttons row to kitchen sink!
1
  === MCE Table Buttons ===
2
+ Contributors: 10up, jakemgold, helen, thinkoomph
3
+ Donate link: http://10up.com/plugins-modules/wordpress-mce-table-buttons/
4
+ Tags: tables, table, editor, WYSIWYG, buttons, tinymce, classic editor
5
  Requires at least: 4.0
6
+ Tested up to: 5.9
7
+ Stable tag: 3.3.1
8
+ Requires PHP:
9
+ License: GPLv2 or later
10
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
12
  Adds table editing controls to the visual content editor (TinyMCE).
13
 
32
 
33
  == Changelog ==
34
 
35
+ = 3.3.1 =
36
+ **Note that this release replaces references of `master` with `trunk` so please plan to update any references you have from `master` to `trunk` to ensure you continue to receive the latest updates on this plugin.**
37
+
38
+ * **Changed:** Bump WordPress version “tested up to” 5.8 (props [David Chabbi](https://profiles.wordpress.org/davidchabbi/), [@jeffpaul](https://github.com/jeffpaul), [@ciprianimike](https://github.com/ciprianimike)).
39
+ * **Changed:** Updated documentation including new GitHub Actions (props [@jeffpaul](https://github.com/jeffpaul), [@dinhtungdu](https://github.com/dinhtungdu)).
40
+ * **Fixed:** Issues reported by PHPCS WPCS v2.3.0 (props [@ciprianimike](https://github.com/ciprianimike), [@dinhtungdu](https://github.com/dinhtungdu)).
41
+
42
  = 3.3 =
43
  * Significantly update TinyMCE plugin from 4.1.x to 4.7.11
44
  * Drop support for WordPress 3.x, which means dropping TinyMCE 3.x and 4.0.x
82
 
83
  == Upgrade Notice ==
84
 
85
+ = 3.3.1 =
86
+ This release replaces references of `master` with `trunk` so please plan to update any references you have from `master` to `trunk` to ensure you continue to receive the latest updates on this plugin.
87
+
88
  = 1.5 =
89
  REQUIRES WordPress 3.3 or higher. Finally links table buttons row to kitchen sink!