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 | 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 +137 -124
- readme.txt +18 -5
mce_table_buttons.php → class-mce-table-buttons.php
RENAMED
@@ -1,124 +1,137 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
*
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
*
|
9 |
-
*
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
*
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
3 |
-
Donate link:
|
4 |
-
Tags:
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to:
|
7 |
-
Stable tag:
|
|
|
|
|
|
|
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!
|