Re-add text underline and justify - Version 0.4

Version Description

  • 2022/10/24 =
  • Tested on WP 6.0.3 with success!
  • Update readme
Download this release

Release Info

Developer briKou
Plugin Icon Re-add text underline and justify
Version 0.4
Comparing to
See all releases

Code changes from version 0.3 to 0.4

Files changed (2) hide show
  1. re-add-underline-justify.php +78 -79
  2. readme.txt +14 -10
re-add-underline-justify.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: https://www.b-website.com/re-add-text-underline-and-justify
5
  * Description: Re-adds the Editor text underline & justify buttons in the WYSIWYG removed in WordPress 4.7. Works with Classic Editor, ACF and Gutenberg.
6
  * Author: Brice Capobianco
7
- * Version: 0.3
8
  * Author URI: https://www.b-website.com/
9
  * Domain Path: /langs
10
  * Text Domain: re-add-underline-justify
@@ -12,186 +12,185 @@
12
 
13
  /* Copyright 2019 Brice CAPOBIANCO (contact : http:// b-website.com/contact)
14
 
15
- This program is free software; you can redistribute it and/or modify
16
- it under the terms of the GNU General Public License, version 2, as
17
- published by the Free Software Foundation.
18
 
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
 
24
- You should have received a copy of the GNU General Public License
25
- along with this program; if not, write to the Free Software
26
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
 
29
 
30
  /***************************************************************
31
  * SECURITY : Exit if accessed directly
32
  ***************************************************************/
33
- if ( !defined( 'ABSPATH' ) ) {
34
-
35
  die( 'Direct access not allowed!' );
36
-
37
  }
38
 
39
 
40
  /***************************************************************
41
  * Add custom meta link on plugin list page
42
  ***************************************************************/
 
43
  function ratb_meta_links( $links, $file ) {
44
-
45
  if ( $file === 're-add-underline-justify/re-add-underline-justify.php' ) {
46
- $paypalDonate = 'https://www.paypal.me/BriceCapobianco';
47
- $links[] = '<a href="https://www.b-website.com/category/plugins" target="_blank" title="' . __( 'More b*web Plugins', 'simple-revisions-delete' ) . '">'. __( 'More b*web Plugins', 'simple-revisions-delete' ) .'</a>';
48
- $links[] = '<a href="' . $paypalDonate . '" target="_blank" title="' . __( 'Donate to this plugin &#187;' ) . '"><strong>' . __( 'Donate to this plugin &#187;' ) . '</strong></a>';
49
  }
50
  return $links;
51
-
52
  }
53
- add_filter( 'plugin_row_meta', 'ratb_meta_links', 10, 2 );
54
 
55
 
56
  /***************************************************************
57
  * Load plugin textdomain
58
  ***************************************************************/
 
59
  function ratb_load_textdomain() {
60
-
61
  $path = dirname( plugin_basename( __FILE__ ) ) . '/langs/';
62
- load_plugin_textdomain( 're-add-underline-justify', FALSE, $path );
63
-
64
  }
65
- add_action( 'init', 'ratb_load_textdomain' );
66
 
67
 
68
  /***************************************************************
69
  * Remove plugin settings from DB on plugin deletion
70
  ***************************************************************/
71
  function ratb_uninstall() {
72
-
73
  // Remove option from DB
74
  delete_option( 'ratb_options' );
75
-
76
  }
77
 
78
 
79
  /***************************************************************
80
  * Hooks for install & uninstall
81
  ***************************************************************/
 
82
  function ratb_activation() {
83
-
84
  register_uninstall_hook( __FILE__, 'ratb_uninstall' );
85
-
86
  }
87
- register_activation_hook( __FILE__, 'ratb_activation' );
88
 
89
 
90
  /***************************************************************
91
  * Register the new setting on the Wrinting screen
92
  ***************************************************************/
93
- function ratb_admin_init(){
94
-
 
95
  register_setting(
96
- 'writing', // settings page
97
- 'ratb_options' // option name
98
- );
99
  add_settings_field(
100
- 'ratb_mce_style', // id
101
- __( 'Editor style', 're-add-underline-justify' ), // setting title
102
- 'ratb_setting_input', // display callback
103
- 'writing', // settings page
104
- 'default' // settings section
105
  );
106
-
107
  }
108
- add_action('admin_init', 'ratb_admin_init');
109
 
110
 
111
  /***************************************************************
112
  * Display the select on the Wrinting screen
113
  ***************************************************************/
114
  function ratb_setting_input() {
115
-
116
  //Retrieve the option value
117
  $options = get_option( 'ratb_options' );
118
-
119
  //Default value
120
- if( empty( $options ) ){
121
- $options[ 'ratb_mce_style' ] = 2;
122
  }
123
-
124
  // The option "Re-add underline & justify + rearrange" has been deprecated in 0.2
125
  // So we replace option 3 with 2 if the former was selected.
126
- if( !empty( $options ) && $options[ 'ratb_mce_style' ] == 3 ){
127
- $options[ 'ratb_mce_style' ] = 2;
128
  }
129
 
130
-
131
  // Output the field
132
  echo '
133
  <select id="ratb_mce_style" name="ratb_options[ratb_mce_style]">
134
- <option value="1"' . selected( $options[ 'ratb_mce_style' ], 1, false ) . '>' . __( 'Without underline & justify buttons', 're-add-underline-justify' ) . '</option>
135
- <option value="2"' . selected( $options[ 'ratb_mce_style' ], 2, false ) . '>' . __( 'Default - Re-add underline & justify buttons', 're-add-underline-justify' ) . '</option>
136
- <option value="4"' . selected( $options[ 'ratb_mce_style' ], 4, false ) . '>' . __( 'Re-add justify only', 're-add-underline-justify' ) . '</option>
137
  </select>';
138
-
139
  }
140
 
141
 
142
  /***************************************************************
143
  * Update tinyMCE buttons lines
144
  ***************************************************************/
145
- function ratb_buttons_lines_tiny_mce(){
146
-
 
147
  //Retrieve the option value
148
  $options = get_option( 'ratb_options' );
149
-
150
  // Conditionnal MCE display
151
- if ( !isset( $options[ 'ratb_mce_style' ] ) || isset( $options[ 'ratb_mce_style' ] ) && ( $options[ 'ratb_mce_style' ] == 2 || $options[ 'ratb_mce_style' ] == 3 ) ) {
152
-
153
  // The option "Re-add underline & justify + rearrange" has been deprecated in 0.2
154
  // So we replace option 3 with 2 if the former was selected.
155
  add_filter( 'mce_buttons', 'ratb_tiny_mce_buttons_justify', 5 );
156
- add_filter( 'mce_buttons_2', 'ratb_tiny_mce_buttons_underline', 5 );
157
-
158
- } else if ( isset( $options[ 'ratb_mce_style' ] ) && $options[ 'ratb_mce_style' ] == 4 ) {
159
-
160
  add_filter( 'mce_buttons', 'ratb_tiny_mce_buttons_justify', 5 );
161
-
162
- }
163
  //Else, do nothing... use the default editor style
164
 
165
- }
166
- add_action( 'admin_init', 'ratb_buttons_lines_tiny_mce' );
167
 
168
-
169
  /***************************************************************
170
  * First editor row buttons - Re-add underline
171
  ***************************************************************/
172
- function ratb_tiny_mce_buttons_underline( $buttons_array ){
173
-
174
- if ( !in_array( 'underline', $buttons_array ) ){
175
  $inserted = array( 'underline' );
176
  // We add the button at the begining of the second line
177
  array_splice( $buttons_array, 0, 0, $inserted );
178
  }
179
-
180
  return $buttons_array;
181
-
182
  }
183
 
184
  /***************************************************************
185
  * First editor row buttons - Re-add justify
186
  ***************************************************************/
187
- function ratb_tiny_mce_buttons_justify( $buttons_array ){
188
-
189
- if ( !in_array( 'alignjustify', $buttons_array ) && in_array( 'alignright', $buttons_array ) ){
190
- $key = array_search( 'alignright', $buttons_array );
191
  $inserted = array( 'alignjustify' );
192
  array_splice( $buttons_array, $key + 1, 0, $inserted );
193
  }
194
-
195
  return $buttons_array;
196
-
197
- }
4
  * Plugin URI: https://www.b-website.com/re-add-text-underline-and-justify
5
  * Description: Re-adds the Editor text underline & justify buttons in the WYSIWYG removed in WordPress 4.7. Works with Classic Editor, ACF and Gutenberg.
6
  * Author: Brice Capobianco
7
+ * Version: 0.4
8
  * Author URI: https://www.b-website.com/
9
  * Domain Path: /langs
10
  * Text Domain: re-add-underline-justify
12
 
13
  /* Copyright 2019 Brice CAPOBIANCO (contact : http:// b-website.com/contact)
14
 
15
+ This program is free software; you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License, version 2, as
17
+ published by the Free Software Foundation.
18
 
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
 
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
 
29
 
30
  /***************************************************************
31
  * SECURITY : Exit if accessed directly
32
  ***************************************************************/
33
+ if ( ! defined( 'ABSPATH' ) ) {
34
+
35
  die( 'Direct access not allowed!' );
36
+
37
  }
38
 
39
 
40
  /***************************************************************
41
  * Add custom meta link on plugin list page
42
  ***************************************************************/
43
+ add_filter( 'plugin_row_meta', 'ratb_meta_links', 10, 2 );
44
  function ratb_meta_links( $links, $file ) {
45
+
46
  if ( $file === 're-add-underline-justify/re-add-underline-justify.php' ) {
47
+ $paypal_donate = 'https://www.paypal.me/BriceCapobianco';
48
+ $links[] = '<a href="https://www.b-website.com/category/plugins" target="_blank" title="' . __( 'More b*web Plugins', 'simple-revisions-delete' ) . '">' . __( 'More b*web Plugins', 'simple-revisions-delete' ) . '</a>';
49
+ $links[] = '<a href="' . $paypal_donate . '" target="_blank" title="' . __( 'Donate to this plugin &#187;' ) . '"><strong>' . __( 'Donate to this plugin &#187;' ) . '</strong></a>';
50
  }
51
  return $links;
52
+
53
  }
 
54
 
55
 
56
  /***************************************************************
57
  * Load plugin textdomain
58
  ***************************************************************/
59
+ add_action( 'init', 'ratb_load_textdomain' );
60
  function ratb_load_textdomain() {
61
+
62
  $path = dirname( plugin_basename( __FILE__ ) ) . '/langs/';
63
+ load_plugin_textdomain( 're-add-underline-justify', false, $path );
64
+
65
  }
 
66
 
67
 
68
  /***************************************************************
69
  * Remove plugin settings from DB on plugin deletion
70
  ***************************************************************/
71
  function ratb_uninstall() {
72
+
73
  // Remove option from DB
74
  delete_option( 'ratb_options' );
75
+
76
  }
77
 
78
 
79
  /***************************************************************
80
  * Hooks for install & uninstall
81
  ***************************************************************/
82
+ register_activation_hook( __FILE__, 'ratb_activation' );
83
  function ratb_activation() {
84
+
85
  register_uninstall_hook( __FILE__, 'ratb_uninstall' );
86
+
87
  }
 
88
 
89
 
90
  /***************************************************************
91
  * Register the new setting on the Wrinting screen
92
  ***************************************************************/
93
+ add_action( 'admin_init', 'ratb_admin_init' );
94
+ function ratb_admin_init() {
95
+
96
  register_setting(
97
+ 'writing', // settings page
98
+ 'ratb_options' // option name
99
+ );
100
  add_settings_field(
101
+ 'ratb_mce_style', // id
102
+ __( 'Editor style', 're-add-underline-justify' ), // setting title
103
+ 'ratb_setting_input', // display callback
104
+ 'writing', // settings page
105
+ 'default' // settings section
106
  );
107
+
108
  }
 
109
 
110
 
111
  /***************************************************************
112
  * Display the select on the Wrinting screen
113
  ***************************************************************/
114
  function ratb_setting_input() {
115
+
116
  //Retrieve the option value
117
  $options = get_option( 'ratb_options' );
118
+
119
  //Default value
120
+ if ( empty( $options ) ) {
121
+ $options['ratb_mce_style'] = 2;
122
  }
123
+
124
  // The option "Re-add underline & justify + rearrange" has been deprecated in 0.2
125
  // So we replace option 3 with 2 if the former was selected.
126
+ if ( ! empty( $options ) && $options['ratb_mce_style'] == 3 ) {
127
+ $options['ratb_mce_style'] = 2;
128
  }
129
 
 
130
  // Output the field
131
  echo '
132
  <select id="ratb_mce_style" name="ratb_options[ratb_mce_style]">
133
+ <option value="1"' . selected( $options['ratb_mce_style'], 1, false ) . '>' . __( 'Without underline & justify buttons', 're-add-underline-justify' ) . '</option>
134
+ <option value="2"' . selected( $options['ratb_mce_style'], 2, false ) . '>' . __( 'Default - Re-add underline & justify buttons', 're-add-underline-justify' ) . '</option>
135
+ <option value="4"' . selected( $options['ratb_mce_style'], 4, false ) . '>' . __( 'Re-add justify only', 're-add-underline-justify' ) . '</option>
136
  </select>';
137
+
138
  }
139
 
140
 
141
  /***************************************************************
142
  * Update tinyMCE buttons lines
143
  ***************************************************************/
144
+ add_action( 'admin_init', 'ratb_buttons_lines_tiny_mce' );
145
+ function ratb_buttons_lines_tiny_mce() {
146
+
147
  //Retrieve the option value
148
  $options = get_option( 'ratb_options' );
149
+
150
  // Conditionnal MCE display
151
+ if ( ! isset( $options['ratb_mce_style'] ) || isset( $options['ratb_mce_style'] ) && ( $options['ratb_mce_style'] == 2 || $options['ratb_mce_style'] == 3 ) ) {
152
+
153
  // The option "Re-add underline & justify + rearrange" has been deprecated in 0.2
154
  // So we replace option 3 with 2 if the former was selected.
155
  add_filter( 'mce_buttons', 'ratb_tiny_mce_buttons_justify', 5 );
156
+ add_filter( 'mce_buttons_2', 'ratb_tiny_mce_buttons_underline', 5 );
157
+
158
+ } elseif ( isset( $options['ratb_mce_style'] ) && $options['ratb_mce_style'] == 4 ) {
159
+
160
  add_filter( 'mce_buttons', 'ratb_tiny_mce_buttons_justify', 5 );
161
+
162
+ }
163
  //Else, do nothing... use the default editor style
164
 
165
+ }
166
+
167
 
 
168
  /***************************************************************
169
  * First editor row buttons - Re-add underline
170
  ***************************************************************/
171
+ function ratb_tiny_mce_buttons_underline( $buttons_array ) {
172
+
173
+ if ( ! in_array( 'underline', $buttons_array ) ) {
174
  $inserted = array( 'underline' );
175
  // We add the button at the begining of the second line
176
  array_splice( $buttons_array, 0, 0, $inserted );
177
  }
178
+
179
  return $buttons_array;
180
+
181
  }
182
 
183
  /***************************************************************
184
  * First editor row buttons - Re-add justify
185
  ***************************************************************/
186
+ function ratb_tiny_mce_buttons_justify( $buttons_array ) {
187
+
188
+ if ( ! in_array( 'alignjustify', $buttons_array ) && in_array( 'alignright', $buttons_array ) ) {
189
+ $key = array_search( 'alignright', $buttons_array );
190
  $inserted = array( 'alignjustify' );
191
  array_splice( $buttons_array, $key + 1, 0, $inserted );
192
  }
193
+
194
  return $buttons_array;
195
+
196
+ }
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: briKou
3
  Donate link: https://www.paypal.me/BriceCapobianco
4
  Tags: editor, underline, justify, wysiwyg, gutenberg, ACF
5
  Requires at least: 4.7
6
- Tested up to: 5.3
7
  Requires PHP: 5.5.12
8
- Stable tag: 0.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -57,35 +57,39 @@ Just go to Settings -> Writing and select the option you want under "Editor styl
57
 
58
  == Changelog ==
59
 
60
- = 0.3 - 14/11/2019 =
 
 
 
 
61
  * Tested on WP 5.3 with success!
62
  * Change default option to "Re-add underline & justify buttons" on plugin activation
63
 
64
- = 0.2 - 09/04/2018 =
65
  * Tested on WP 4.9.8 with success!
66
  * Added support for Gutenberg for its "Classic" bloc only.
67
  * Remove option 3 "Re-add underline & justify + rearrange" (depracated)
68
 
69
- = 0.1.4 - 03/31/2017 =
70
  * Tested on WP 4.7.3 with success!
71
  * Fix broken links in plugins meta
72
 
73
- = 0.1.3 - 01/14/2016 =
74
  * Added the fourth option to only re-add justify button (push methode)
75
  * Push non standard button to the end of the buttons lines for the third option. This prevents from removing extra buttons added by other plugins.
76
  * Fix for ACF (free) on the second option
77
 
78
- = 0.1.2 - 11/14/2016 =
79
  * Changes MCE button hook priority to prevent errors with other plugins adding extra buttons.
80
 
81
- = 0.1.1 - 11/10/2016 =
82
  * Fixes an issue hidding Editor content.
83
 
84
- = 0.1 - 11/06/2016 =
85
  * First release.
86
 
87
  == Upgrade Notice ==
88
- = 0.1 - 11/06/2016 =
89
  * The old option "Re-add underline & justify + rearrange" has been deprecated in 0.2 (sept. 2018) as it cause conflicts with the new Gutenberg editor. This option automatically switches to "Re-add underline & justify buttons" since.
90
 
91
  = 0.1.3 =
3
  Donate link: https://www.paypal.me/BriceCapobianco
4
  Tags: editor, underline, justify, wysiwyg, gutenberg, ACF
5
  Requires at least: 4.7
6
+ Tested up to: 6.0.3
7
  Requires PHP: 5.5.12
8
+ Stable tag: 0.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
57
 
58
  == Changelog ==
59
 
60
+ = 0.4 - 2022/10/24 =
61
+ * Tested on WP 6.0.3 with success!
62
+ * Update readme
63
+
64
+ = 0.3 - 2019/11/14 =
65
  * Tested on WP 5.3 with success!
66
  * Change default option to "Re-add underline & justify buttons" on plugin activation
67
 
68
+ = 0.2 - 2018/04/09 =
69
  * Tested on WP 4.9.8 with success!
70
  * Added support for Gutenberg for its "Classic" bloc only.
71
  * Remove option 3 "Re-add underline & justify + rearrange" (depracated)
72
 
73
+ = 0.1.4 - 2017/31/03 =
74
  * Tested on WP 4.7.3 with success!
75
  * Fix broken links in plugins meta
76
 
77
+ = 0.1.3 - 2016/14/01 =
78
  * Added the fourth option to only re-add justify button (push methode)
79
  * Push non standard button to the end of the buttons lines for the third option. This prevents from removing extra buttons added by other plugins.
80
  * Fix for ACF (free) on the second option
81
 
82
+ = 0.1.2 - 2016/14/11 =
83
  * Changes MCE button hook priority to prevent errors with other plugins adding extra buttons.
84
 
85
+ = 0.1.1 - 2016/10/11 =
86
  * Fixes an issue hidding Editor content.
87
 
88
+ = 0.1 - 2016/06/116 =
89
  * First release.
90
 
91
  == Upgrade Notice ==
92
+ = 0.1 - 2016/06/11 =
93
  * The old option "Re-add underline & justify + rearrange" has been deprecated in 0.2 (sept. 2018) as it cause conflicts with the new Gutenberg editor. This option automatically switches to "Re-add underline & justify buttons" since.
94
 
95
  = 0.1.3 =