AddQuicktag - Version 2.4.3

Version Description

(2015-08-21) = * Add czech translation, thanks to https://github.com/MikkCZ * Bugfix: TinyMCE input select was changed in his object, changes on the script for the visual editor to set quicktags.

Download this release

Release Info

Developer Bueltge
Plugin Icon wp plugin AddQuicktag
Version 2.4.3
Comparing to
See all releases

Code changes from version 2.3.0 to 2.4.3

Files changed (43) hide show
  1. addquicktag.php +422 -447
  2. assets/screenshot-1.png +0 -0
  3. assets/screenshot-2.png +0 -0
  4. assets/screenshot-3.png +0 -0
  5. assets/screenshot-4.png +0 -0
  6. inc/class-code-quicktags.php +151 -151
  7. inc/class-imexport.php +238 -238
  8. inc/class-remove-quicktags.php +151 -151
  9. inc/class-settings.php +781 -805
  10. inc/class-tinymce.php +1 -1
  11. inc/tinymce/editor_plugin.dev.js +149 -139
  12. inc/tinymce/editor_plugin.js +10 -10
  13. inc/tinymce/langs/de.js +0 -0
  14. inc/tinymce/langs/en.js +0 -0
  15. js/add-quicktags.dev.js +82 -55
  16. js/add-quicktags.js +2 -2
  17. languages/addquicktag-cs_CZ.mo +0 -0
  18. languages/addquicktag-cs_CZ.po +348 -0
  19. languages/addquicktag-de_DE.mo +0 -0
  20. languages/addquicktag-de_DE.po +87 -97
  21. languages/addquicktag-es_ES.mo +0 -0
  22. languages/addquicktag-es_ES.po +217 -0
  23. languages/addquicktag-fr_FR.mo +0 -0
  24. languages/addquicktag-fr_FR.po +159 -119
  25. languages/addquicktag-lt_LT.mo +0 -0
  26. languages/addquicktag-lt_LT.po +217 -0
  27. languages/addquicktag-pl_PL.mo +0 -0
  28. languages/addquicktag-pl_PL.po +345 -0
  29. languages/addquicktag-pt_BR.po +18 -18
  30. languages/addquicktag-ru_RU.mo +0 -0
  31. languages/addquicktag-ru_RU.po +220 -0
  32. languages/addquicktag-sr_RS.po +18 -18
  33. languages/addquicktag-tr_TR.mo +0 -0
  34. languages/addquicktag-tr_TR.po +176 -139
  35. languages/addquicktag-uk_UA.po +18 -18
  36. languages/addquicktag-xx_XX.pot +316 -231
  37. languages/addquicktag-zh_CN.mo +0 -0
  38. languages/addquicktag-zh_CN.po +245 -0
  39. languages/addquicktag-zh_TW.mo +0 -0
  40. languages/addquicktag-zh_TW.po +242 -0
  41. license.txt +674 -674
  42. readme.md +0 -0
  43. readme.txt +74 -39
addquicktag.php CHANGED
@@ -1,447 +1,422 @@
1
- <?php
2
-
3
- /**
4
- * Plugin Name: AddQuicktag
5
- * Plugin URI: http://bueltge.de/wp-addquicktags-de-plugin/120/
6
- * Text Domain: addquicktag
7
- * Domain Path: /languages
8
- * Description: Allows you to easily add custom Quicktags to the html- and visual-editor.
9
- * Version: 2.3.0
10
- * Author: Frank Bültge
11
- * Author URI: http://bueltge.de
12
- * License: GPLv2+
13
- *
14
- *
15
- *
16
- * License:
17
- * ==============================================================================
18
- * Copyright 2011 - 2014 Frank Bültge (email : frank@bueltge.de)
19
- *
20
- * This program is free software; you can redistribute it and/or modify
21
- * it under the terms of the GNU General Public License as published by
22
- * the Free Software Foundation; either version 2 of the License, or
23
- * (at your option) any later version.
24
- *
25
- * This program is distributed in the hope that it will be useful,
26
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
- * GNU General Public License for more details.
29
- *
30
- * You should have received a copy of the GNU General Public License
31
- * along with this program; if not, write to the Free Software
32
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33
- *
34
- * Requirements:
35
- * ==============================================================================
36
- * This plugin requires WordPress >= 3.9 and tested with PHP Interpreter >= 5.3
37
- *
38
- *
39
- *
40
- * Add Quicktag Plugin class
41
- *
42
- * @since 2.0.0
43
- */
44
- class Add_Quicktag {
45
-
46
- /**
47
- * Option key - String
48
- *
49
- * @var string
50
- */
51
- static private $option_string = 'rmnlQuicktagSettings';
52
-
53
- /**
54
- * Use filter 'addquicktag_pages' for add custom pages
55
- *
56
- * @var array
57
- */
58
- static private $admin_pages_for_js = array(
59
- 'post.php',
60
- 'post-new.php',
61
- 'comment.php',
62
- 'edit-comments.php',
63
- 'widgets.php'
64
- );
65
-
66
- /**
67
- * Use filter 'addquicktag_post_types' for add custom post_types
68
- *
69
- * @var array
70
- */
71
- static private $post_types_for_js = array( 'comment', 'edit-comments', 'widgets' );
72
-
73
- /**
74
- * @var string
75
- */
76
- static private $plugin;
77
-
78
- /**
79
- * Handler for the action 'init'. Instantiates this class.
80
- *
81
- * @since 2.0.0
82
- * @access public
83
- * @return \Add_Quicktag $instance
84
- */
85
- public static function get_object() {
86
-
87
- static $instance;
88
-
89
- if ( NULL === $instance ) {
90
- $instance = new self();
91
- }
92
-
93
- return $instance;
94
- }
95
-
96
- /**
97
- * Constructor, init the functions inside WP
98
- *
99
- * @since 2.0.0
100
- * @return \Add_Quicktag
101
- */
102
- private function __construct() {
103
-
104
- if ( ! is_admin() ) {
105
- return;
106
- }
107
-
108
- // get string of plugin
109
- self::$plugin = plugin_basename( __FILE__ );
110
-
111
- // on uninstall remove capability from roles
112
- register_uninstall_hook( __FILE__, array( 'Add_Quicktag', 'uninstall' ) );
113
- // on deactivate delete all settings in database
114
- // register_deactivation_hook( __FILE__, array('Add_Quicktag', 'uninstall' ) );
115
-
116
- // load translation files
117
- add_action( 'admin_init', array( $this, 'localize_plugin' ) );
118
- // on init register post type for addquicktag and print js
119
- add_action( 'init', array( $this, 'on_admin_init' ) );
120
-
121
- add_filter( 'quicktags_settings', array( $this, 'remove_quicktags' ), 10, 1 );
122
- }
123
-
124
-
125
- /**
126
- * Include other files and print JS
127
- *
128
- * @since 07/16/2012
129
- * @return void
130
- */
131
- public function on_admin_init() {
132
-
133
- if ( ! is_admin() ) {
134
- return NULL;
135
- }
136
-
137
- // Include settings
138
- require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-settings.php';
139
- // Include solution for TinyMCE
140
- require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-tinymce.php';
141
-
142
- foreach ( $this->get_admin_pages_for_js() as $page ) {
143
- add_action( 'admin_print_scripts-' . $page, array( $this, 'get_json' ) );
144
- add_action( 'admin_print_scripts-' . $page, array( $this, 'admin_enqueue_scripts' ) );
145
- }
146
- }
147
-
148
- /**
149
- * Remove quicktags
150
- *
151
- * @since 08/15/2013
152
- *
153
- * @param array $qtags_init the Buttons
154
- *
155
- * @type string id
156
- * @type array buttons, default: 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,fullscreen'
157
- * @return array $qtags_init the Buttons
158
- */
159
- public function remove_quicktags( $qtags_init ) {
160
-
161
- // No core buttons, not necessary to filter
162
- if ( empty( $qtags_init[ 'buttons' ] ) ) {
163
- return $qtags_init;
164
- }
165
-
166
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
167
- $options = get_site_option( self::$option_string );
168
- } else {
169
- $options = get_option( self::$option_string );
170
- }
171
-
172
- // No settings, not necessary to filter
173
- if ( empty( $options[ 'core_buttons' ] ) ) {
174
- return $qtags_init;
175
- }
176
-
177
- // get current screen, post type
178
- $screen = get_current_screen();
179
-
180
- // Convert string to array from default core buttons
181
- $buttons = explode( ',', $qtags_init[ 'buttons' ] );
182
-
183
- // loop about the options to check for each post type
184
- foreach ( $options[ 'core_buttons' ] as $button => $post_type ) {
185
-
186
- // if the post type is inside the settings array active, the remove qtags
187
- if ( array_key_exists( $screen->id, $post_type ) ) {
188
-
189
- // If settings have key inside, then unset this button
190
- if ( FALSE !== ( $key = array_search( $button, $buttons ) ) ) {
191
- unset( $buttons[ $key ] );
192
- }
193
- }
194
- }
195
-
196
- // Convert new buttons array back into a comma-separated string
197
- $qtags_init[ 'buttons' ] = implode( ',', $buttons );
198
- $qtags_init[ 'buttons' ] = apply_filters( 'addquicktag_remove_buttons', $qtags_init[ 'buttons' ] );
199
-
200
- return $qtags_init;
201
- }
202
-
203
- /**
204
- * Uninstall data in options table, if the plugin was uninstall via backend
205
- *
206
- * @since 2.0.0
207
- * @return void
208
- */
209
- public function uninstall() {
210
-
211
- delete_site_option( self::$option_string );
212
- }
213
-
214
- /**
215
- * Print json data in head
216
- *
217
- * @since 2.0.0
218
- * @return void
219
- */
220
- public function get_json() {
221
- global $current_screen;
222
-
223
- if ( ! in_array(
224
- $current_screen->id,
225
- $this->get_post_types_for_js()
226
- ) &&
227
- isset( $current_screen->id )
228
- ) {
229
- return NULL;
230
- }
231
-
232
- if ( is_multisite() && is_plugin_active_for_network( $this ->get_plugin_string() ) ) {
233
- $options = get_site_option( self::$option_string );
234
- } else {
235
- $options = get_option( self::$option_string );
236
- }
237
-
238
- if ( empty( $options[ 'buttons' ] ) ) {
239
- $options[ 'buttons' ] = '';
240
- }
241
-
242
- // allow change or enhance buttons array
243
- $options[ 'buttons' ] = apply_filters( 'addquicktag_buttons', $options[ 'buttons' ] );
244
- // hook for filter options
245
- $options = apply_filters( 'addquicktag_options', $options );
246
-
247
- if ( ! $options ) {
248
- return NULL;
249
- }
250
-
251
- if ( 1 < count( $options[ 'buttons' ] ) ) {
252
- // sort array by order value
253
- $tmp = array();
254
- foreach ( $options[ 'buttons' ] as $order ) {
255
- if ( isset( $order[ 'order' ] ) ) {
256
- $tmp[ ] = $order[ 'order' ];
257
- } else {
258
- $tmp[ ] = 0;
259
- }
260
- }
261
- array_multisort( $tmp, SORT_ASC, $options[ 'buttons' ] );
262
- }
263
-
264
- ?>
265
- <script type="text/javascript">
266
- var addquicktag_tags = <?php echo json_encode( $options ); ?>,
267
- addquicktag_post_type = <?php echo json_encode( $current_screen->id ); ?>,
268
- addquicktag_pt_for_js = <?php echo json_encode( $this->get_post_types_for_js() ); ?>;
269
- </script>
270
- <?php
271
- }
272
-
273
- /**
274
- * Enqueue Scripts for plugin
275
- *
276
- * @internal param string $where
277
- *
278
- * @since 2.0.0
279
- * @access public
280
- * @return void
281
- */
282
- public function admin_enqueue_scripts() {
283
-
284
- global $current_screen;
285
-
286
- if ( ! in_array(
287
- $current_screen->id,
288
- $this->get_post_types_for_js()
289
- ) &&
290
- isset( $current_screen->id )
291
- ) {
292
- return NULL;
293
- }
294
-
295
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
296
-
297
- if ( version_compare( $GLOBALS[ 'wp_version' ], '3.3alpha', '>=' ) ) {
298
- wp_enqueue_script(
299
- self::get_textdomain() . '_script',
300
- plugins_url( '/js/add-quicktags' . $suffix . '.js', __FILE__ ),
301
- array( 'jquery', 'quicktags' ),
302
- '',
303
- TRUE
304
- );
305
- // Load only for WPs, there version is smaller then 3.2
306
- } else {
307
- wp_enqueue_script(
308
- self::get_textdomain() . '_script',
309
- plugins_url( '/js/add-quicktags_32' . $suffix . '.js', __FILE__ ),
310
- array( 'jquery', 'quicktags' ),
311
- '',
312
- TRUE
313
- );
314
- }
315
- // Alternative to JSON function
316
- // wp_localize_script( self :: get_textdomain() . '_script', 'addquicktag_tags', get_option( self :: $option_string ) );
317
- }
318
-
319
- /**
320
- * Localize_plugin function.
321
- *
322
- * @uses load_plugin_textdomain, plugin_basename
323
- * @access public
324
- * @since 2.0.0
325
- * @return void
326
- */
327
- public function localize_plugin() {
328
-
329
- load_plugin_textdomain( $this->get_textdomain(), FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
330
- }
331
-
332
- /**
333
- * return plugin comment data
334
- *
335
- * @since 2.0.0
336
- * @access public
337
- *
338
- * @param $value string, default = 'TextDomain'
339
- * Name, PluginURI, Version, Description, Author, AuthorURI, TextDomain, DomainPath, Network, Title
340
- *
341
- * @return string
342
- */
343
- public function get_plugin_data( $value = 'TextDomain' ) {
344
-
345
- static $plugin_data = array();
346
-
347
- // fetch the data just once.
348
- if ( isset( $plugin_data[ $value ] ) ) {
349
- return $plugin_data[ $value ];
350
- }
351
-
352
- if ( ! function_exists( 'get_plugin_data' ) ) {
353
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
354
- }
355
-
356
- $plugin_data = get_plugin_data( __FILE__ );
357
-
358
- return empty( $plugin_data[ $value ] ) ? '' : $plugin_data[ $value ];
359
- }
360
-
361
- /**
362
- * Return string of plugin
363
- *
364
- * @since 2.0.0
365
- * @return string
366
- */
367
- public function get_plugin_string() {
368
-
369
- return self::$plugin;
370
- }
371
-
372
- /**
373
- * Get Post types with UI to use optional the quicktags
374
- *
375
- * @since 08/1/2013
376
- * @return Array
377
- */
378
- private function get_post_types() {
379
-
380
- // list only post types, there was used in UI
381
- $args = array( 'show_ui' => TRUE );
382
- $post_types = get_post_types( $args, 'names' );
383
- // simplify the array
384
- $post_types = array_values( $post_types );
385
- // merge with strings from var
386
- $post_types = array_merge( $post_types, self::$post_types_for_js );
387
-
388
- return $post_types;
389
- }
390
-
391
- /**
392
- * Return allowed post types for include scripts
393
- *
394
- * @since 2.1.1
395
- * @access public
396
- * @return Array
397
- */
398
- public function get_post_types_for_js() {
399
-
400
- return apply_filters( 'addquicktag_post_types', $this->get_post_types() );
401
- }
402
-
403
- /**
404
- * Return allowed post types for include scripts
405
- *
406
- * @since 2.1.1
407
- * @access public
408
- * @return Array
409
- */
410
- public function get_admin_pages_for_js() {
411
-
412
- return apply_filters( 'addquicktag_pages', self::$admin_pages_for_js );
413
- }
414
-
415
- /**
416
- * Return textdomain string
417
- *
418
- * @since 2.0.0
419
- * @access public
420
- * @return string
421
- */
422
- public function get_textdomain() {
423
-
424
- return self::get_plugin_data( 'TextDomain' );
425
- }
426
-
427
- /**
428
- * Return string for options
429
- *
430
- * @since 2.0.0
431
- * @return string
432
- */
433
- public function get_option_string() {
434
-
435
- return self::$option_string;
436
- }
437
-
438
-
439
- } // end class
440
-
441
- if ( function_exists( 'add_action' ) && class_exists( 'Add_Quicktag' ) ) {
442
- add_action( 'plugins_loaded', array( 'Add_Quicktag', 'get_object' ) );
443
- } else {
444
- header( 'Status: 403 Forbidden' );
445
- header( 'HTTP/1.1 403 Forbidden' );
446
- exit();
447
- }
1
+ <?php
2
+
3
+ /**
4
+ * Plugin Name: AddQuicktag
5
+ * Plugin URI: http://bueltge.de/wp-addquicktags-de-plugin/120/
6
+ * Text Domain: addquicktag
7
+ * Domain Path: /languages
8
+ * Description: Allows you to easily add custom Quicktags to the html- and visual-editor.
9
+ * Version: 2.4.3
10
+ * Author: Frank Bültge
11
+ * Author URI: http://bueltge.de
12
+ * License: GPLv2+
13
+ * License URI: ./license.txt
14
+ *
15
+ * Add Quicktag Plugin class
16
+ *
17
+ * @since 2.0.0
18
+ */
19
+ class Add_Quicktag {
20
+
21
+ /**
22
+ * Option key - String
23
+ *
24
+ * @var string
25
+ */
26
+ static private $option_string = 'rmnlQuicktagSettings';
27
+
28
+ /**
29
+ * Use filter 'addquicktag_pages' for add custom pages
30
+ *
31
+ * @var array
32
+ */
33
+ static private $admin_pages_for_js = array(
34
+ 'post.php',
35
+ 'post-new.php',
36
+ 'comment.php',
37
+ 'edit-comments.php',
38
+ 'widgets.php'
39
+ );
40
+
41
+ /**
42
+ * Use filter 'addquicktag_post_types' for add custom post_types
43
+ *
44
+ * @var array
45
+ */
46
+ static private $post_types_for_js = array( 'comment', 'edit-comments', 'widgets' );
47
+
48
+ /**
49
+ * @var string
50
+ */
51
+ static private $plugin;
52
+
53
+ /**
54
+ * Handler for the action 'init'. Instantiates this class.
55
+ *
56
+ * @since 2.0.0
57
+ * @access public
58
+ * @return \Add_Quicktag $instance
59
+ */
60
+ public static function get_object() {
61
+
62
+ static $instance;
63
+
64
+ if ( NULL === $instance ) {
65
+ $instance = new self();
66
+ }
67
+
68
+ return $instance;
69
+ }
70
+
71
+ /**
72
+ * Constructor, init the functions inside WP
73
+ *
74
+ * @since 2.0.0
75
+ * @return \Add_Quicktag
76
+ */
77
+ private function __construct() {
78
+
79
+ if ( ! is_admin() ) {
80
+ return;
81
+ }
82
+
83
+ // get string of plugin
84
+ self::$plugin = plugin_basename( __FILE__ );
85
+
86
+ // on uninstall remove capability from roles
87
+ register_uninstall_hook( __FILE__, array( 'Add_Quicktag', 'uninstall' ) );
88
+ // on deactivate delete all settings in database
89
+ // register_deactivation_hook( __FILE__, array('Add_Quicktag', 'uninstall' ) );
90
+
91
+ // load translation files
92
+ add_action( 'admin_init', array( $this, 'localize_plugin' ) );
93
+ // on init register post type for addquicktag and print js
94
+ add_action( 'init', array( $this, 'on_admin_init' ) );
95
+
96
+ add_filter( 'quicktags_settings', array( $this, 'remove_quicktags' ), 10, 1 );
97
+ }
98
+
99
+
100
+ /**
101
+ * Include other files and print JS
102
+ *
103
+ * @since 07/16/2012
104
+ * @return void
105
+ */
106
+ public function on_admin_init() {
107
+
108
+ if ( ! is_admin() ) {
109
+ return NULL;
110
+ }
111
+
112
+ // Include settings
113
+ require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-settings.php';
114
+ // Include solution for TinyMCE
115
+ require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-tinymce.php';
116
+
117
+ foreach ( $this->get_admin_pages_for_js() as $page ) {
118
+ add_action( 'admin_print_scripts-' . $page, array( $this, 'get_json' ) );
119
+ add_action( 'admin_print_scripts-' . $page, array( $this, 'admin_enqueue_scripts' ) );
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Remove quicktags
125
+ *
126
+ * @since 08/15/2013
127
+ *
128
+ * @param array $qtags_init the Buttons
129
+ *
130
+ * @type string id
131
+ * @type array buttons, default: 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,fullscreen'
132
+ * @return array $qtags_init the Buttons
133
+ */
134
+ public function remove_quicktags( $qtags_init ) {
135
+
136
+ // No core buttons, not necessary to filter
137
+ if ( empty( $qtags_init[ 'buttons' ] ) ) {
138
+ return $qtags_init;
139
+ }
140
+
141
+ if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
142
+ $options = get_site_option( self::$option_string );
143
+ } else {
144
+ $options = get_option( self::$option_string );
145
+ }
146
+
147
+ // No settings, not necessary to filter
148
+ if ( empty( $options[ 'core_buttons' ] ) ) {
149
+ return $qtags_init;
150
+ }
151
+
152
+ // get current screen, post type
153
+ $screen = get_current_screen();
154
+
155
+ // Convert string to array from default core buttons
156
+ $buttons = explode( ',', $qtags_init[ 'buttons' ] );
157
+
158
+ // loop about the options to check for each post type
159
+ foreach ( $options[ 'core_buttons' ] as $button => $post_type ) {
160
+
161
+ // if the post type is inside the settings array active, the remove qtags
162
+ if ( is_array( $post_type ) && array_key_exists( $screen->id, $post_type ) ) {
163
+
164
+ // If settings have key inside, then unset this button
165
+ if ( FALSE !== ( $key = array_search( $button, $buttons ) ) ) {
166
+ unset( $buttons[ $key ] );
167
+ }
168
+ }
169
+ }
170
+
171
+ // Convert new buttons array back into a comma-separated string
172
+ $qtags_init[ 'buttons' ] = implode( ',', $buttons );
173
+ $qtags_init[ 'buttons' ] = apply_filters( 'addquicktag_remove_buttons', $qtags_init[ 'buttons' ] );
174
+
175
+ return $qtags_init;
176
+ }
177
+
178
+ /**
179
+ * Uninstall data in options table, if the plugin was uninstall via backend
180
+ *
181
+ * @since 2.0.0
182
+ * @return void
183
+ */
184
+ public function uninstall() {
185
+
186
+ delete_site_option( self::$option_string );
187
+ }
188
+
189
+ /**
190
+ * Print json data in head
191
+ *
192
+ * @since 2.0.0
193
+ * @return void
194
+ */
195
+ public function get_json() {
196
+ global $current_screen;
197
+
198
+ if ( ! in_array(
199
+ $current_screen->id,
200
+ $this->get_post_types_for_js()
201
+ ) &&
202
+ isset( $current_screen->id )
203
+ ) {
204
+ return NULL;
205
+ }
206
+
207
+ if ( is_multisite() && is_plugin_active_for_network( $this ->get_plugin_string() ) ) {
208
+ $options = get_site_option( self::$option_string );
209
+ } else {
210
+ $options = get_option( self::$option_string );
211
+ }
212
+
213
+ if ( empty( $options[ 'buttons' ] ) ) {
214
+ $options[ 'buttons' ] = '';
215
+ }
216
+
217
+ // allow change or enhance buttons array
218
+ $options[ 'buttons' ] = apply_filters( 'addquicktag_buttons', $options[ 'buttons' ] );
219
+ // hook for filter options
220
+ $options = apply_filters( 'addquicktag_options', $options );
221
+
222
+ if ( ! $options ) {
223
+ return NULL;
224
+ }
225
+
226
+ if ( 1 < count( $options[ 'buttons' ] ) ) {
227
+ // sort array by order value
228
+ $tmp = array();
229
+ foreach ( $options[ 'buttons' ] as $order ) {
230
+ if ( isset( $order[ 'order' ] ) ) {
231
+ $tmp[ ] = $order[ 'order' ];
232
+ } else {
233
+ $tmp[ ] = 0;
234
+ }
235
+ }
236
+ array_multisort( $tmp, SORT_ASC, $options[ 'buttons' ] );
237
+ }
238
+
239
+ ?>
240
+ <script type="text/javascript">
241
+ var addquicktag_tags = <?php echo json_encode( $options ); ?>,
242
+ addquicktag_post_type = <?php echo json_encode( $current_screen->id ); ?>,
243
+ addquicktag_pt_for_js = <?php echo json_encode( $this->get_post_types_for_js() ); ?>;
244
+ </script>
245
+ <?php
246
+ }
247
+
248
+ /**
249
+ * Enqueue Scripts for plugin
250
+ *
251
+ * @internal param string $where
252
+ *
253
+ * @since 2.0.0
254
+ * @access public
255
+ * @return void
256
+ */
257
+ public function admin_enqueue_scripts() {
258
+
259
+ global $current_screen;
260
+
261
+ if ( ! in_array(
262
+ $current_screen->id,
263
+ $this->get_post_types_for_js()
264
+ ) &&
265
+ isset( $current_screen->id )
266
+ ) {
267
+ return NULL;
268
+ }
269
+
270
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
271
+
272
+ if ( version_compare( $GLOBALS[ 'wp_version' ], '3.3alpha', '>=' ) ) {
273
+ wp_enqueue_script(
274
+ self::get_textdomain() . '_script',
275
+ plugins_url( '/js/add-quicktags' . $suffix . '.js', __FILE__ ),
276
+ array( 'jquery', 'quicktags' ),
277
+ '',
278
+ TRUE
279
+ );
280
+ // Load only for WPs, there version is smaller then 3.2
281
+ } else {
282
+ wp_enqueue_script(
283
+ self::get_textdomain() . '_script',
284
+ plugins_url( '/js/add-quicktags_32' . $suffix . '.js', __FILE__ ),
285
+ array( 'jquery', 'quicktags' ),
286
+ '',
287
+ TRUE
288
+ );
289
+ }
290
+ // Alternative to JSON function
291
+ // wp_localize_script( self :: get_textdomain() . '_script', 'addquicktag_tags', get_option( self :: $option_string ) );
292
+ }
293
+
294
+ /**
295
+ * Localize_plugin function.
296
+ *
297
+ * @uses load_plugin_textdomain, plugin_basename
298
+ * @access public
299
+ * @since 2.0.0
300
+ * @return void
301
+ */
302
+ public function localize_plugin() {
303
+
304
+ load_plugin_textdomain( $this->get_textdomain(), FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
305
+ }
306
+
307
+ /**
308
+ * return plugin comment data
309
+ *
310
+ * @since 2.0.0
311
+ * @access public
312
+ *
313
+ * @param $value string, default = 'TextDomain'
314
+ * Name, PluginURI, Version, Description, Author, AuthorURI, TextDomain, DomainPath, Network, Title
315
+ *
316
+ * @return string
317
+ */
318
+ public function get_plugin_data( $value = 'TextDomain' ) {
319
+
320
+ static $plugin_data = array();
321
+
322
+ // fetch the data just once.
323
+ if ( isset( $plugin_data[ $value ] ) ) {
324
+ return $plugin_data[ $value ];
325
+ }
326
+
327
+ if ( ! function_exists( 'get_plugin_data' ) ) {
328
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
329
+ }
330
+
331
+ $plugin_data = get_plugin_data( __FILE__ );
332
+
333
+ return empty( $plugin_data[ $value ] ) ? '' : $plugin_data[ $value ];
334
+ }
335
+
336
+ /**
337
+ * Return string of plugin
338
+ *
339
+ * @since 2.0.0
340
+ * @return string
341
+ */
342
+ public function get_plugin_string() {
343
+
344
+ return self::$plugin;
345
+ }
346
+
347
+ /**
348
+ * Get Post types with UI to use optional the quicktags
349
+ *
350
+ * @since 08/1/2013
351
+ * @return Array
352
+ */
353
+ private function get_post_types() {
354
+
355
+ // list only post types, there was used in UI
356
+ $args = array( 'show_ui' => TRUE );
357
+ $post_types = get_post_types( $args, 'names' );
358
+ // simplify the array
359
+ $post_types = array_values( $post_types );
360
+ // merge with strings from var
361
+ $post_types = array_merge( $post_types, self::$post_types_for_js );
362
+
363
+ return $post_types;
364
+ }
365
+
366
+ /**
367
+ * Return allowed post types for include scripts
368
+ *
369
+ * @since 2.1.1
370
+ * @access public
371
+ * @return Array
372
+ */
373
+ public function get_post_types_for_js() {
374
+
375
+ return apply_filters( 'addquicktag_post_types', $this->get_post_types() );
376
+ }
377
+
378
+ /**
379
+ * Return allowed post types for include scripts
380
+ *
381
+ * @since 2.1.1
382
+ * @access public
383
+ * @return Array
384
+ */
385
+ public function get_admin_pages_for_js() {
386
+
387
+ return apply_filters( 'addquicktag_pages', self::$admin_pages_for_js );
388
+ }
389
+
390
+ /**
391
+ * Return textdomain string
392
+ *
393
+ * @since 2.0.0
394
+ * @access public
395
+ * @return string
396
+ */
397
+ public function get_textdomain() {
398
+
399
+ return self::get_plugin_data( 'TextDomain' );
400
+ }
401
+
402
+ /**
403
+ * Return string for options
404
+ *
405
+ * @since 2.0.0
406
+ * @return string
407
+ */
408
+ public function get_option_string() {
409
+
410
+ return self::$option_string;
411
+ }
412
+
413
+
414
+ } // end class
415
+
416
+ if ( function_exists( 'add_action' ) && class_exists( 'Add_Quicktag' ) ) {
417
+ add_action( 'plugins_loaded', array( 'Add_Quicktag', 'get_object' ) );
418
+ } else {
419
+ header( 'Status: 403 Forbidden' );
420
+ header( 'HTTP/1.1 403 Forbidden' );
421
+ exit();
422
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/screenshot-1.png DELETED
Binary file
assets/screenshot-2.png DELETED
Binary file
assets/screenshot-3.png DELETED
Binary file
assets/screenshot-4.png DELETED
Binary file
inc/class-code-quicktags.php CHANGED
@@ -1,151 +1,151 @@
1
- <?php
2
- /**
3
- * AddQuicktag - Settings for enhanced code buttons
4
- *
5
- * @license GPLv2
6
- * @package AddQuicktag
7
- * @subpackage AddQuicktag Settings
8
- * @author Frank Bueltge <frank@bueltge.de>
9
- * @since 01/26/2014
10
- * @version 06/19/2014
11
- */
12
-
13
- if ( ! function_exists( 'add_action' ) ) {
14
- echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
15
- exit;
16
- }
17
-
18
- /**
19
- * Class Add_Quicktag_Code_Quicktags
20
- */
21
- class Add_Quicktag_Code_Quicktags extends Add_Quicktag_Settings {
22
-
23
- /**
24
- * Post types for the settings
25
- *
26
- * @var
27
- */
28
- private static $code_quicktags = array( 'enhanced_code' => 'pre', 'en_de_coding' => 'htmlentities' );
29
-
30
- /**
31
- * Static var for textdomain
32
- *
33
- * @var string
34
- */
35
- public static $textdomain = '';
36
-
37
- /**
38
- * Handler for the action 'init'. Instantiates this class.
39
- *
40
- * @access public
41
- * @since 2.0.0
42
- * @return \Add_Quicktag|\Add_Quicktag_Code_Quicktags|\Add_Quicktag_Settings $instance
43
- */
44
- public static function get_object() {
45
-
46
- static $instance;
47
-
48
- if ( NULL === $instance ) {
49
- $instance = new self();
50
- }
51
-
52
- return $instance;
53
- }
54
-
55
- /**
56
- * Constructor, init on defined hooks of WP and include second class
57
- *
58
- * @access public
59
- * @since 0.0.2
60
- * @uses register_activation_hook, register_uninstall_hook, add_action
61
- * @return \Add_Quicktag_Code_Quicktags
62
- */
63
- private function __construct() {
64
-
65
- self::$textdomain = parent::get_textdomain();
66
-
67
- add_action( 'addquicktag_settings_form_page', array( $this, 'get_code_quicktag_area' ) );
68
- }
69
-
70
- /**
71
- * Add settings area
72
- *
73
- * @param $options
74
- */
75
- public function get_code_quicktag_area( $options ) {
76
-
77
- if ( ! isset( $options[ 'code_buttons' ] ) ) {
78
- $options[ 'code_buttons' ] = array();
79
- }
80
- ?>
81
- <h3><?php _e( 'Enhanced Code Quicktag buttons', self::$textdomain ); ?></h3>
82
- <p><?php _e( 'Select the checkbox below to add enhanced code buttons.', $this->get_textdomain() ); ?></p>
83
- <h4><?php _e( 'pre: Enhanced Code buttons', self::$textdomain ); ?></h4>
84
- <p><?php _e( 'Enhanced the default Code buttons. Add a pull down menu for different languages before the default code button and include this as class inside the code tag. Also add a pre button for preformatted text.', self::$textdomain ); ?></p>
85
- <h4><?php _e( 'htmlentities: HTML Entities, HTML Decode', self::$textdomain ); ?></h4>
86
- <p><?php _e( 'Add buttons to do the inconvient HTML encoding/decoding, like &lt; to &amp;lt; and back.', self::$textdomain ); ?></p>
87
-
88
- <?php
89
- // loop about the post types, create html an values for title in table
90
- $pt_title = '';
91
- $pt_colgroup = '';
92
- foreach ( $this->get_post_types_for_js() as $post_type ) {
93
- $pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
94
- $pt_colgroup .= '<colgroup></colgroup>' . "\n";
95
- }
96
- ?>
97
-
98
- <table class="widefat form-table rmnlCodeQuicktagSettings">
99
- <colgroup></colgroup>
100
- <?php echo $pt_colgroup; ?>
101
- <colgroup></colgroup>
102
-
103
- <tr>
104
- <th class="row-title"><?php _e( 'Button', self::$textdomain ); ?></th>
105
- <?php echo $pt_title; ?>
106
- <th class="row-title num" style="width:3%;">&#x2714;</th>
107
- </tr>
108
-
109
- <?php
110
- // Convert string to array
111
- //$code_buttons = explode( ',', self::$code_quicktags );
112
- // Loop over items to remove and unset them from the buttons
113
- $i = 9999;
114
- foreach ( self::$code_quicktags as $key => $value ) {
115
-
116
- echo '<tr id="rmqtb' . $i . '">' . "\n";
117
- echo '<td><input type="button" class="ed_button" title="" value="' . $value . '"></td>';
118
-
119
- // loop about the post types, create html an values
120
- $pt_checkboxes = '';
121
- foreach ( $this->get_post_types_for_js() as $post_type ) {
122
-
123
- $pt_checked = '';
124
- if ( isset( $options[ 'code_buttons' ][ $value ][ $post_type ] ) && 1 == $options[ 'code_buttons' ][ $value ][ $post_type ] ) {
125
- $pt_checked = ' checked="checked"';
126
- }
127
-
128
- $pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
129
- parent :: get_option_string() . '[code_buttons][' .
130
- $value . '][' . $post_type . ']" value="1"' .
131
- $pt_checked . '/></td>' . "\n";
132
- }
133
- echo $pt_checkboxes;
134
-
135
- echo '<td class="num"><input type="checkbox" class="toggle" id="select_all_' . $i . '" value="' . $i . '" /></td>' . "\n";
136
-
137
- echo '</tr>' . "\n";
138
- $i ++;
139
- }
140
-
141
- // Convert new buttons array back into a comma-separated string
142
- //$code_qt = implode( ',', $code_buttons );
143
- ?>
144
-
145
- </table>
146
- <?php
147
- }
148
-
149
- } // end class
150
-
151
- $add_quicktag_code_quicktags = Add_Quicktag_Code_Quicktags::get_object();
1
+ <?php
2
+ /**
3
+ * AddQuicktag - Settings for enhanced code buttons
4
+ *
5
+ * @license GPLv2
6
+ * @package AddQuicktag
7
+ * @subpackage AddQuicktag Settings
8
+ * @author Frank Bueltge <frank@bueltge.de>
9
+ * @since 01/26/2014
10
+ * @version 06/19/2014
11
+ */
12
+
13
+ if ( ! function_exists( 'add_action' ) ) {
14
+ echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
15
+ exit;
16
+ }
17
+
18
+ /**
19
+ * Class Add_Quicktag_Code_Quicktags
20
+ */
21
+ class Add_Quicktag_Code_Quicktags extends Add_Quicktag_Settings {
22
+
23
+ /**
24
+ * Post types for the settings
25
+ *
26
+ * @var
27
+ */
28
+ private static $code_quicktags = array( 'enhanced_code' => 'pre', 'en_de_coding' => 'htmlentities' );
29
+
30
+ /**
31
+ * Static var for textdomain
32
+ *
33
+ * @var string
34
+ */
35
+ public static $textdomain = '';
36
+
37
+ /**
38
+ * Handler for the action 'init'. Instantiates this class.
39
+ *
40
+ * @access public
41
+ * @since 2.0.0
42
+ * @return \Add_Quicktag|\Add_Quicktag_Code_Quicktags|\Add_Quicktag_Settings $instance
43
+ */
44
+ public static function get_object() {
45
+
46
+ static $instance;
47
+
48
+ if ( NULL === $instance ) {
49
+ $instance = new self();
50
+ }
51
+
52
+ return $instance;
53
+ }
54
+
55
+ /**
56
+ * Constructor, init on defined hooks of WP and include second class
57
+ *
58
+ * @access public
59
+ * @since 0.0.2
60
+ * @uses register_activation_hook, register_uninstall_hook, add_action
61
+ * @return \Add_Quicktag_Code_Quicktags
62
+ */
63
+ private function __construct() {
64
+
65
+ self::$textdomain = parent::get_textdomain();
66
+
67
+ add_action( 'addquicktag_settings_form_page', array( $this, 'get_code_quicktag_area' ) );
68
+ }
69
+
70
+ /**
71
+ * Add settings area
72
+ *
73
+ * @param $options
74
+ */
75
+ public function get_code_quicktag_area( $options ) {
76
+
77
+ if ( ! isset( $options[ 'code_buttons' ] ) ) {
78
+ $options[ 'code_buttons' ] = array();
79
+ }
80
+ ?>
81
+ <h3><?php esc_html_e( 'Enhanced Code Quicktag buttons', self::$textdomain ); ?></h3>
82
+ <p><?php esc_html_e( 'Select the checkbox below to add enhanced code buttons.', $this->get_textdomain() ); ?></p>
83
+ <h4><?php esc_html_e( 'pre: Enhanced Code buttons', self::$textdomain ); ?></h4>
84
+ <p><?php esc_html_e( 'Enhanced the default Code buttons. Add a pull down menu for different languages before the default code button and include this as class inside the code tag. Also add a pre button for preformatted text.', self::$textdomain ); ?></p>
85
+ <h4><?php esc_html_e( 'htmlentities: HTML Entities, HTML Decode', self::$textdomain ); ?></h4>
86
+ <p><?php esc_html_e( 'Add buttons to do the inconvient HTML encoding/decoding, like &lt; to &amp;lt; and back.', self::$textdomain ); ?></p>
87
+
88
+ <?php
89
+ // loop about the post types, create html an values for title in table
90
+ $pt_title = '';
91
+ $pt_colgroup = '';
92
+ foreach ( $this->get_post_types_for_js() as $post_type ) {
93
+ $pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
94
+ $pt_colgroup .= '<colgroup></colgroup>' . "\n";
95
+ }
96
+ ?>
97
+
98
+ <table class="widefat form-table rmnlCodeQuicktagSettings">
99
+ <colgroup></colgroup>
100
+ <?php echo $pt_colgroup; ?>
101
+ <colgroup></colgroup>
102
+
103
+ <tr>
104
+ <th class="row-title"><?php esc_html_e( 'Button', self::$textdomain ); ?></th>
105
+ <?php echo $pt_title; ?>
106
+ <th class="row-title num" style="width:3%;">&#x2714;</th>
107
+ </tr>
108
+
109
+ <?php
110
+ // Convert string to array
111
+ //$code_buttons = explode( ',', self::$code_quicktags );
112
+ // Loop over items to remove and unset them from the buttons
113
+ $i = 9999;
114
+ foreach ( self::$code_quicktags as $key => $value ) {
115
+
116
+ echo '<tr id="rmqtb' . $i . '">' . "\n";
117
+ echo '<td><input type="button" class="ed_button" title="" value="' . $value . '"></td>';
118
+
119
+ // loop about the post types, create html an values
120
+ $pt_checkboxes = '';
121
+ foreach ( $this->get_post_types_for_js() as $post_type ) {
122
+
123
+ $pt_checked = '';
124
+ if ( isset( $options[ 'code_buttons' ][ $value ][ $post_type ] ) && 1 == $options[ 'code_buttons' ][ $value ][ $post_type ] ) {
125
+ $pt_checked = ' checked="checked"';
126
+ }
127
+
128
+ $pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
129
+ parent :: get_option_string() . '[code_buttons][' .
130
+ $value . '][' . $post_type . ']" value="1"' .
131
+ $pt_checked . '/></td>' . "\n";
132
+ }
133
+ echo $pt_checkboxes;
134
+
135
+ echo '<td class="num"><input type="checkbox" class="toggle" id="select_all_' . $i . '" value="' . $i . '" /></td>' . "\n";
136
+
137
+ echo '</tr>' . "\n";
138
+ $i ++;
139
+ }
140
+
141
+ // Convert new buttons array back into a comma-separated string
142
+ //$code_qt = implode( ',', $code_buttons );
143
+ ?>
144
+
145
+ </table>
146
+ <?php
147
+ }
148
+
149
+ } // end class
150
+
151
+ $add_quicktag_code_quicktags = Add_Quicktag_Code_Quicktags::get_object();
inc/class-imexport.php CHANGED
@@ -1,238 +1,238 @@
1
- <?php
2
- /**
3
- * AddQuicktag - Settings
4
- *
5
- * @license GPLv3
6
- * @package AddQuicktag
7
- * @subpackage AddQuicktag Settings
8
- * @author Frank Bueltge <frank@bueltge.de>
9
- * @version 06/19/2014
10
- */
11
-
12
- if ( ! function_exists( 'add_action' ) ) {
13
- echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
14
- exit;
15
- }
16
-
17
- /**
18
- * Class Add_Quicktag_Im_Export
19
- */
20
- class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
21
-
22
- /**
23
- * string for translation
24
- * @var string
25
- */
26
- static public $textdomain;
27
-
28
- /**
29
- * string for options in table options
30
- * @var string
31
- */
32
- static private $option_string;
33
-
34
- /**
35
- * string for plugin file
36
- * @var string
37
- */
38
- static private $plugin;
39
-
40
- /**
41
- * Post types for the settings
42
- *
43
- * @var Array
44
- */
45
- private static $post_types_for_js;
46
-
47
- /**
48
- * Handler for the action 'init'. Instantiates this class.
49
- *
50
- * @access public
51
- * @since 2.0.0
52
- * @return \Add_Quicktag|\Add_Quicktag_Im_Export|\Add_Quicktag_Settings $instance
53
- */
54
- public static function get_object() {
55
-
56
- static $instance;
57
-
58
- if ( NULL === $instance ) {
59
- $instance = new self();
60
- }
61
-
62
- return $instance;
63
- }
64
-
65
- /**
66
- * Constructor, init on defined hooks of WP and include second class
67
- *
68
- * @access public
69
- * @since 0.0.2
70
- * @uses register_activation_hook, register_uninstall_hook, add_action
71
- * @return \Add_Quicktag_Im_Export
72
- */
73
- private function __construct() {
74
-
75
- // textdomain from parent class
76
- self::$textdomain = parent::get_textdomain();
77
- self::$option_string = parent::get_option_string();
78
- self::$plugin = parent::get_plugin_string();
79
- self::$post_types_for_js = parent::get_post_types_for_js();
80
-
81
- if ( isset( $_GET[ 'addquicktag_download' ] ) && check_admin_referer( parent :: $nonce_string ) ) {
82
- $this->get_export_file();
83
- }
84
- //add_action( 'init', array( $this, 'get_export_file' ) );
85
-
86
- if ( isset( $_POST[ 'addquicktag_import' ] ) && check_admin_referer( parent :: $nonce_string ) ) {
87
- $this->import_file();
88
- }
89
- //add_action( 'init', array( $this, 'import_file' ) );
90
-
91
- add_action( 'addquicktag_settings_page', array( $this, 'get_im_export_part' ) );
92
- }
93
-
94
- /**
95
- * get markup for ex- and import on settings page
96
- *
97
- * @access public
98
- * @since 2.0.0
99
- * @uses wp_nonce_field
100
- * @return string
101
- */
102
- public function get_im_export_part() {
103
-
104
- ?>
105
- <div class="postbox">
106
- <h3><span><?php _e( 'Export', parent :: get_textdomain() ); ?></span></h3>
107
-
108
- <div class="inside">
109
- <p><?php _e( 'When you click the button below the plugin will create an XML file for you to save to your computer.', parent :: get_textdomain() ); ?></p>
110
-
111
- <p><?php _e( 'This format, a custom XML, will contain your options from quicktags.', parent :: get_textdomain() ); ?></p>
112
-
113
- <p><?php _e( 'Once you’ve saved the download file, you can use the Import function in another WordPress installation to import this site.', parent :: get_textdomain() ); ?></p>
114
-
115
- <form method="get" action="">
116
- <?php wp_nonce_field( parent :: $nonce_string ); ?>
117
- <p class="submit">
118
- <input type="submit" name="submit" value="<?php _e( 'Download Export File', parent :: get_textdomain() ); ?> &raquo;" />
119
- <input type="hidden" name="addquicktag_download" value="true" />
120
- </p>
121
- </form>
122
- </div>
123
- </div>
124
-
125
- <div class="postbox">
126
- <h3><span><?php _e( 'Import', parent :: get_textdomain() ); ?></span></h3>
127
-
128
- <div class="inside">
129
- <p><?php _e( 'If you have quicktags from other installs, the plugin can import those into this site. To get started, choose a file to import. (json-Format)', parent :: get_textdomain() ); ?></p>
130
-
131
- <form method="post" action="" enctype="multipart/form-data">
132
- <?php wp_nonce_field( parent :: $nonce_string ); ?>
133
- <p class="submit">
134
- <input type="file" name="import_file" />
135
- <input type="submit" name="submit" value="<?php _e( 'Upload file and import', parent :: get_textdomain() ); ?> &raquo;" />
136
- <input type="hidden" name="addquicktag_import" value="true" />
137
- </p>
138
- </form>
139
- </div>
140
- </div>
141
- <?php
142
- }
143
-
144
- /**
145
- * Build export file, json
146
- *
147
- * @access public
148
- * @since 2.0.0
149
- */
150
- public function get_export_file() {
151
-
152
- if ( ! current_user_can( 'manage_options' ) ) {
153
- return;
154
- }
155
-
156
- check_admin_referer( parent :: $nonce_string );
157
-
158
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
159
- $options = get_site_option( self::$option_string );
160
- } else {
161
- $options = get_option( self::$option_string );
162
- }
163
-
164
- ignore_user_abort( TRUE );
165
-
166
- nocache_headers();
167
- header( 'Content-Type: application/json; charset=utf-8' );
168
- header( 'Content-Disposition: attachment; filename=addquicktag.-' . date( 'm-d-Y' ) . '.json' );
169
- header( "Expires: 0" );
170
-
171
- echo json_encode( $options );
172
- exit;
173
- }
174
-
175
- /**
176
- * Import json and update settings
177
- *
178
- * @access public
179
- * @since 2.0.0
180
- *
181
- * @internal param bool|string $filename
182
- *
183
- * @uses current_user_can, wp_die, is_plugin_active_for_network, update_site_option, update_option
184
- * @return void
185
- */
186
- public function import_file() {
187
-
188
- if ( ! current_user_can( 'manage_options' ) ) {
189
- wp_die( __( 'Options not update - you don&lsquo;t have the privilidges to do this!', parent::get_textdomain() ) );
190
- }
191
-
192
- check_admin_referer( parent :: $nonce_string );
193
-
194
- $extension = explode( '.', $_FILES[ 'import_file' ][ 'name' ] );
195
- $extension = end( $extension );
196
-
197
- if ( $extension != 'json' ) {
198
- wp_die( __( 'Please upload a valid .json file', parent::get_textdomain() ) );
199
- }
200
-
201
- $import_file = $_FILES[ 'import_file' ][ 'tmp_name' ];
202
-
203
- if ( empty( $import_file ) ) {
204
- wp_die( __( 'Please upload a file to import.', parent::get_textdomain() ) );
205
- }
206
-
207
- // Retrieve the settings from the file and convert the json object to an array.
208
- $options = (array) json_decode( file_get_contents( $import_file ), TRUE );
209
-
210
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
211
- update_site_option( self::$option_string, $options );
212
- } else {
213
- update_option( self::$option_string, $options );
214
- }
215
-
216
- // redirect to settings page in network
217
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
218
- wp_redirect(
219
- add_query_arg(
220
- array( 'page' => self::$plugin, 'updated' => 'true' ),
221
- network_admin_url( 'settings.php' )
222
- )
223
- );
224
- } else {
225
- $page = str_replace( basename( __FILE__ ), 'class-settings.php', plugin_basename( __FILE__ ) );
226
- wp_redirect(
227
- add_query_arg(
228
- array( 'page' => $page, 'updated' => 'true' ),
229
- admin_url( 'options-general.php' )
230
- )
231
- );
232
- }
233
- exit;
234
- }
235
-
236
- } // end class
237
-
238
- $add_quicktag_im_export = Add_Quicktag_Im_Export::get_object();
1
+ <?php
2
+ /**
3
+ * AddQuicktag - Settings
4
+ *
5
+ * @license GPLv3
6
+ * @package AddQuicktag
7
+ * @subpackage AddQuicktag Settings
8
+ * @author Frank Bueltge <frank@bueltge.de>
9
+ * @version 06/19/2014
10
+ */
11
+
12
+ if ( ! function_exists( 'add_action' ) ) {
13
+ echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
14
+ exit;
15
+ }
16
+
17
+ /**
18
+ * Class Add_Quicktag_Im_Export
19
+ */
20
+ class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
21
+
22
+ /**
23
+ * string for translation
24
+ * @var string
25
+ */
26
+ static public $textdomain;
27
+
28
+ /**
29
+ * string for options in table options
30
+ * @var string
31
+ */
32
+ static private $option_string;
33
+
34
+ /**
35
+ * string for plugin file
36
+ * @var string
37
+ */
38
+ static private $plugin;
39
+
40
+ /**
41
+ * Post types for the settings
42
+ *
43
+ * @var Array
44
+ */
45
+ private static $post_types_for_js;
46
+
47
+ /**
48
+ * Handler for the action 'init'. Instantiates this class.
49
+ *
50
+ * @access public
51
+ * @since 2.0.0
52
+ * @return \Add_Quicktag|\Add_Quicktag_Im_Export|\Add_Quicktag_Settings $instance
53
+ */
54
+ public static function get_object() {
55
+
56
+ static $instance;
57
+
58
+ if ( NULL === $instance ) {
59
+ $instance = new self();
60
+ }
61
+
62
+ return $instance;
63
+ }
64
+
65
+ /**
66
+ * Constructor, init on defined hooks of WP and include second class
67
+ *
68
+ * @access public
69
+ * @since 0.0.2
70
+ * @uses register_activation_hook, register_uninstall_hook, add_action
71
+ * @return \Add_Quicktag_Im_Export
72
+ */
73
+ private function __construct() {
74
+
75
+ // textdomain from parent class
76
+ self::$textdomain = parent::get_textdomain();
77
+ self::$option_string = parent::get_option_string();
78
+ self::$plugin = parent::get_plugin_string();
79
+ self::$post_types_for_js = parent::get_post_types_for_js();
80
+
81
+ if ( isset( $_GET[ 'addquicktag_download' ] ) && check_admin_referer( parent :: $nonce_string ) ) {
82
+ $this->get_export_file();
83
+ }
84
+ //add_action( 'init', array( $this, 'get_export_file' ) );
85
+
86
+ if ( isset( $_POST[ 'addquicktag_import' ] ) && check_admin_referer( parent :: $nonce_string ) ) {
87
+ $this->import_file();
88
+ }
89
+ //add_action( 'init', array( $this, 'import_file' ) );
90
+
91
+ add_action( 'addquicktag_settings_page', array( $this, 'get_im_export_part' ) );
92
+ }
93
+
94
+ /**
95
+ * get markup for ex- and import on settings page
96
+ *
97
+ * @access public
98
+ * @since 2.0.0
99
+ * @uses wp_nonce_field
100
+ * @return string
101
+ */
102
+ public function get_im_export_part() {
103
+
104
+ ?>
105
+ <div class="postbox">
106
+ <h3><span><?php esc_html_e( 'Export', parent :: get_textdomain() ); ?></span></h3>
107
+
108
+ <div class="inside">
109
+ <p><?php esc_html_e( 'When you click the button below the plugin will create an JSON file for you to save to your computer.', parent :: get_textdomain() ); ?></p>
110
+
111
+ <p><?php esc_html_e( 'This format, a custom JSON, will contain your options from quicktags.', parent :: get_textdomain() ); ?></p>
112
+
113
+ <p><?php esc_html_e( 'Once you’ve saved the download file, you can use the Import function in another WordPress installation to import this site.', parent :: get_textdomain() ); ?></p>
114
+
115
+ <form method="get" action="">
116
+ <?php wp_nonce_field( parent :: $nonce_string ); ?>
117
+ <p class="submit">
118
+ <input type="submit" name="submit" value="<?php esc_html_e( 'Download Export File', parent :: get_textdomain() ); ?> &raquo;" />
119
+ <input type="hidden" name="addquicktag_download" value="true" />
120
+ </p>
121
+ </form>
122
+ </div>
123
+ </div>
124
+
125
+ <div class="postbox">
126
+ <h3><span><?php esc_html_e( 'Import', parent :: get_textdomain() ); ?></span></h3>
127
+
128
+ <div class="inside">
129
+ <p><?php esc_html_e( 'If you have quicktags from other installs, the plugin can import those into this site. To get started, choose a file to import. (json-Format)', parent :: get_textdomain() ); ?></p>
130
+
131
+ <form method="post" action="" enctype="multipart/form-data">
132
+ <?php wp_nonce_field( parent :: $nonce_string ); ?>
133
+ <p class="submit">
134
+ <input type="file" name="import_file" />
135
+ <input type="submit" name="submit" value="<?php esc_html_e( 'Upload file and import', parent :: get_textdomain() ); ?> &raquo;" />
136
+ <input type="hidden" name="addquicktag_import" value="true" />
137
+ </p>
138
+ </form>
139
+ </div>
140
+ </div>
141
+ <?php
142
+ }
143
+
144
+ /**
145
+ * Build export file, json
146
+ *
147
+ * @access public
148
+ * @since 2.0.0
149
+ */
150
+ public function get_export_file() {
151
+
152
+ if ( ! current_user_can( 'manage_options' ) ) {
153
+ return;
154
+ }
155
+
156
+ check_admin_referer( parent :: $nonce_string );
157
+
158
+ if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
159
+ $options = get_site_option( self::$option_string );
160
+ } else {
161
+ $options = get_option( self::$option_string );
162
+ }
163
+
164
+ ignore_user_abort( TRUE );
165
+
166
+ nocache_headers();
167
+ header( 'Content-Type: application/json; charset=utf-8' );
168
+ header( 'Content-Disposition: attachment; filename=addquicktag.-' . date( 'm-d-Y' ) . '.json' );
169
+ header( 'Expires: 0' );
170
+
171
+ echo json_encode( $options );
172
+ exit;
173
+ }
174
+
175
+ /**
176
+ * Import json and update settings
177
+ *
178
+ * @access public
179
+ * @since 2.0.0
180
+ *
181
+ * @internal param bool|string $filename
182
+ *
183
+ * @uses current_user_can, wp_die, is_plugin_active_for_network, update_site_option, update_option
184
+ * @return void
185
+ */
186
+ public function import_file() {
187
+
188
+ if ( ! current_user_can( 'manage_options' ) ) {
189
+ wp_die( esc_html__( 'Options not update - you don&lsquo;t have the privileges to do this!', parent::get_textdomain() ) );
190
+ }
191
+
192
+ check_admin_referer( parent :: $nonce_string );
193
+
194
+ $extension = explode( '.', $_FILES[ 'import_file' ][ 'name' ] );
195
+ $extension = end( $extension );
196
+
197
+ if ( $extension !== 'json' ) {
198
+ wp_die( esc_html__( 'Please upload a valid .json file', parent::get_textdomain() ) );
199
+ }
200
+
201
+ $import_file = $_FILES[ 'import_file' ][ 'tmp_name' ];
202
+
203
+ if ( empty( $import_file ) ) {
204
+ wp_die( esc_html__( 'Please upload a file to import.', parent::get_textdomain() ) );
205
+ }
206
+
207
+ // Retrieve the settings from the file and convert the json object to an array.
208
+ $options = (array) json_decode( file_get_contents( $import_file ), TRUE );
209
+
210
+ if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
211
+ update_site_option( self::$option_string, $options );
212
+ } else {
213
+ update_option( self::$option_string, $options );
214
+ }
215
+
216
+ // redirect to settings page in network
217
+ if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
218
+ wp_redirect(
219
+ add_query_arg(
220
+ array( 'page' => self::$plugin, 'updated' => 'true' ),
221
+ network_admin_url( 'settings.php' )
222
+ )
223
+ );
224
+ } else {
225
+ $page = str_replace( basename( __FILE__ ), 'class-settings.php', plugin_basename( __FILE__ ) );
226
+ wp_redirect(
227
+ add_query_arg(
228
+ array( 'page' => $page, 'updated' => 'true' ),
229
+ admin_url( 'options-general.php' )
230
+ )
231
+ );
232
+ }
233
+ exit;
234
+ }
235
+
236
+ } // end class
237
+
238
+ $add_quicktag_im_export = Add_Quicktag_Im_Export::get_object();
inc/class-remove-quicktags.php CHANGED
@@ -1,152 +1,152 @@
1
- <?php
2
- /**
3
- * AddQuicktag - Settings to remove core quicktags
4
- * @license GPLv2
5
- * @package AddQuicktag
6
- * @subpackage AddQuicktag Settings
7
- * @author Frank Bueltge <frank@bueltge.de>
8
- * @version 06/19/2014
9
- */
10
-
11
- if ( ! function_exists( 'add_action' ) ) {
12
- echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
13
- exit;
14
- }
15
-
16
- /**
17
- * Class Add_Quicktag_Remove_Quicktags
18
- */
19
- class Add_Quicktag_Remove_Quicktags extends Add_Quicktag_Settings {
20
-
21
- // default buttons from WP Core
22
- private static $core_quicktags = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,fullscreen';
23
-
24
- /**
25
- * Handler for the action 'init'. Instantiates this class.
26
- *
27
- * @access public
28
- * @since 2.0.0
29
- * @return \Add_Quicktag|\Add_Quicktag_Remove_Quicktags|\Add_Quicktag_Settings $instance
30
- */
31
- public static function get_object() {
32
-
33
- static $instance;
34
-
35
- if ( NULL === $instance ) {
36
- $instance = new self();
37
- }
38
-
39
- return $instance;
40
- }
41
-
42
- /**
43
- * Constructor, init on defined hooks of WP and include second class
44
- *
45
- * @access public
46
- * @since 0.0.2
47
- * @uses register_activation_hook, register_uninstall_hook, add_action
48
- * @return \Add_Quicktag_Remove_Quicktags
49
- */
50
- private function __construct() {
51
-
52
- add_action( 'addquicktag_settings_form_page', array( $this, 'get_remove_quicktag_area' ) );
53
- }
54
-
55
- /**
56
- * Add settings area
57
- *
58
- * @param $options
59
- */
60
- public function get_remove_quicktag_area( $options ) {
61
-
62
- if ( ! isset( $options[ 'core_buttons' ] ) ) {
63
- $options[ 'core_buttons' ] = array();
64
- }
65
- ?>
66
- <h3><?php _e( 'Remove Core Quicktag buttons', parent::get_textdomain() ); ?></h3>
67
- <p><?php _e( 'Select the checkbox below to remove a core quicktags in the editors of the respective post type.', $this->get_textdomain() ); ?></p>
68
-
69
- <?php
70
- // loop about the post types, create html an values for title in table
71
- $pt_title = '';
72
- $pt_colgroup = '';
73
- foreach ( $this->get_post_types_for_js() as $post_type ) {
74
- $pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
75
- $pt_colgroup .= '<colgroup></colgroup>' . "\n";
76
- }
77
- ?>
78
-
79
- <table class="widefat form-table rmnlCoreQuicktagSettings">
80
- <colgroup></colgroup>
81
- <?php echo $pt_colgroup; ?>
82
- <colgroup></colgroup>
83
-
84
- <tr>
85
- <th class="row-title"><?php _e( 'Button', parent::get_textdomain() ); ?></th>
86
- <?php echo $pt_title; ?>
87
- <th class="row-title num" style="width:3%;">&#x2714;</th>
88
- </tr>
89
-
90
- <?php
91
- // Convert string to array
92
- $core_buttons = explode( ',', self::$core_quicktags );
93
- // Loop over items to remove and unset them from the buttons
94
- $i = 999;
95
- foreach ( $core_buttons as $key => $value ) {
96
-
97
- // same style as in editor
98
- if ( 'strong' === $value ) {
99
- $text = 'b';
100
- $style = ' style="font-weight: bold;"';
101
- } else if ( 'em' === $value ) {
102
- $text = 'i';
103
- $style = ' style="font-style: italic;"';
104
- } else if ( 'link' === $value ) {
105
- $text = $value;
106
- $style = ' style="text-decoration: underline;"';
107
- } else if ( 'del' === $value ) {
108
- $text = $value;
109
- $style = ' style="text-decoration: line-through;"';
110
- } else if ( 'block' === $value ) {
111
- $text = 'b-quote';
112
- $style = '';
113
- } else {
114
- $text = $value;
115
- $style = '';
116
- }
117
-
118
- echo '<tr id="rmqtb' . $i . '">' . "\n";
119
- echo '<td><input type="button" class="ed_button" title="" value="' . $text . '"' . $style . '> <code>' . $value . '</code></td>';
120
-
121
- // loop about the post types, create html an values
122
- $pt_checkboxes = '';
123
- foreach ( $this->get_post_types_for_js() as $post_type ) {
124
-
125
- $pt_checked = '';
126
- if ( isset( $options[ 'core_buttons' ][ $value ][ $post_type ] ) && 1 == $options[ 'core_buttons' ][ $value ][ $post_type ] ) {
127
- $pt_checked = ' checked="checked"';
128
- }
129
-
130
- $pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
131
- parent :: get_option_string() . '[core_buttons][' .
132
- $value . '][' . $post_type . ']" value="1"' .
133
- $pt_checked . '/></td>' . "\n";
134
- }
135
- echo $pt_checkboxes;
136
-
137
- echo '<td class="num"><input type="checkbox" class="toggle" id="select_all_' . $i . '" value="' . $i . '" /></td>' . "\n";
138
-
139
- echo '</tr>' . "\n";
140
- $i ++;
141
- }
142
-
143
- // Convert new buttons array back into a comma-separated string
144
- $core_qt = implode( ',', $core_buttons );
145
- ?>
146
- </table>
147
- <?php
148
- }
149
-
150
- } // end class
151
-
152
  $add_quicktag_remove_quicktags = Add_Quicktag_Remove_Quicktags::get_object();
1
+ <?php
2
+ /**
3
+ * AddQuicktag - Settings to remove core quicktags
4
+ * @license GPLv2
5
+ * @package AddQuicktag
6
+ * @subpackage AddQuicktag Settings
7
+ * @author Frank Bueltge <frank@bueltge.de>
8
+ * @version 06/19/2014
9
+ */
10
+
11
+ if ( ! function_exists( 'add_action' ) ) {
12
+ echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
13
+ exit;
14
+ }
15
+
16
+ /**
17
+ * Class Add_Quicktag_Remove_Quicktags
18
+ */
19
+ class Add_Quicktag_Remove_Quicktags extends Add_Quicktag_Settings {
20
+
21
+ // default buttons from WP Core
22
+ private static $core_quicktags = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,fullscreen';
23
+
24
+ /**
25
+ * Handler for the action 'init'. Instantiates this class.
26
+ *
27
+ * @access public
28
+ * @since 2.0.0
29
+ * @return \Add_Quicktag|\Add_Quicktag_Remove_Quicktags|\Add_Quicktag_Settings $instance
30
+ */
31
+ public static function get_object() {
32
+
33
+ static $instance;
34
+
35
+ if ( NULL === $instance ) {
36
+ $instance = new self();
37
+ }
38
+
39
+ return $instance;
40
+ }
41
+
42
+ /**
43
+ * Constructor, init on defined hooks of WP and include second class
44
+ *
45
+ * @access public
46
+ * @since 0.0.2
47
+ * @uses register_activation_hook, register_uninstall_hook, add_action
48
+ * @return \Add_Quicktag_Remove_Quicktags
49
+ */
50
+ private function __construct() {
51
+
52
+ add_action( 'addquicktag_settings_form_page', array( $this, 'get_remove_quicktag_area' ) );
53
+ }
54
+
55
+ /**
56
+ * Add settings area
57
+ *
58
+ * @param $options
59
+ */
60
+ public function get_remove_quicktag_area( $options ) {
61
+
62
+ if ( ! isset( $options[ 'core_buttons' ] ) ) {
63
+ $options[ 'core_buttons' ] = array();
64
+ }
65
+ ?>
66
+ <h3><?php esc_html_e( 'Remove Core Quicktag buttons', parent::get_textdomain() ); ?></h3>
67
+ <p><?php esc_html_e( 'Select the checkbox below to remove a core quicktags in the editors of the respective post type.', $this->get_textdomain() ); ?></p>
68
+
69
+ <?php
70
+ // loop about the post types, create html an values for title in table
71
+ $pt_title = '';
72
+ $pt_colgroup = '';
73
+ foreach ( $this->get_post_types_for_js() as $post_type ) {
74
+ $pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
75
+ $pt_colgroup .= '<colgroup></colgroup>' . "\n";
76
+ }
77
+ ?>
78
+
79
+ <table class="widefat form-table rmnlCoreQuicktagSettings">
80
+ <colgroup></colgroup>
81
+ <?php echo $pt_colgroup; ?>
82
+ <colgroup></colgroup>
83
+
84
+ <tr>
85
+ <th class="row-title"><?php esc_html_e( 'Button', parent::get_textdomain() ); ?></th>
86
+ <?php echo $pt_title; ?>
87
+ <th class="row-title num" style="width:3%;">&#x2714;</th>
88
+ </tr>
89
+
90
+ <?php
91
+ // Convert string to array
92
+ $core_buttons = explode( ',', self::$core_quicktags );
93
+ // Loop over items to remove and unset them from the buttons
94
+ $i = 999;
95
+ foreach ( $core_buttons as $key => $value ) {
96
+
97
+ // same style as in editor
98
+ if ( 'strong' === $value ) {
99
+ $text = 'b';
100
+ $style = ' style="font-weight: bold;"';
101
+ } else if ( 'em' === $value ) {
102
+ $text = 'i';
103
+ $style = ' style="font-style: italic;"';
104
+ } else if ( 'link' === $value ) {
105
+ $text = $value;
106
+ $style = ' style="text-decoration: underline;"';
107
+ } else if ( 'del' === $value ) {
108
+ $text = $value;
109
+ $style = ' style="text-decoration: line-through;"';
110
+ } else if ( 'block' === $value ) {
111
+ $text = 'b-quote';
112
+ $style = '';
113
+ } else {
114
+ $text = $value;
115
+ $style = '';
116
+ }
117
+
118
+ echo '<tr id="rmqtb' . $i . '">' . "\n";
119
+ echo '<td><input type="button" class="ed_button" title="" value="' . $text . '"' . $style . '> <code>' . $value . '</code></td>';
120
+
121
+ // loop about the post types, create html an values
122
+ $pt_checkboxes = '';
123
+ foreach ( $this->get_post_types_for_js() as $post_type ) {
124
+
125
+ $pt_checked = '';
126
+ if ( isset( $options[ 'core_buttons' ][ $value ][ $post_type ] ) && 1 == $options[ 'core_buttons' ][ $value ][ $post_type ] ) {
127
+ $pt_checked = ' checked="checked"';
128
+ }
129
+
130
+ $pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
131
+ parent :: get_option_string() . '[core_buttons][' .
132
+ $value . '][' . $post_type . ']" value="1"' .
133
+ $pt_checked . '/></td>' . "\n";
134
+ }
135
+ echo $pt_checkboxes;
136
+
137
+ echo '<td class="num"><input type="checkbox" class="toggle" id="select_all_' . $i . '" value="' . $i . '" /></td>' . "\n";
138
+
139
+ echo '</tr>' . "\n";
140
+ $i ++;
141
+ }
142
+
143
+ // Convert new buttons array back into a comma-separated string
144
+ $core_qt = implode( ',', $core_buttons );
145
+ ?>
146
+ </table>
147
+ <?php
148
+ }
149
+
150
+ } // end class
151
+
152
  $add_quicktag_remove_quicktags = Add_Quicktag_Remove_Quicktags::get_object();
inc/class-settings.php CHANGED
@@ -1,805 +1,781 @@
1
- <?php
2
- /**
3
- * AddQuicktag - Settings
4
- * @license GPLv2
5
- * @package AddQuicktag
6
- * @subpackage AddQuicktag Settings
7
- * @author Frank Bueltge <frank@bueltge.de>
8
- * @version 06/19/2014
9
- * @since 2.0.0
10
- */
11
-
12
- if ( ! function_exists( 'add_action' ) ) {
13
- echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
14
- exit;
15
- }
16
-
17
- /**
18
- * Class Add_Quicktag_Settings
19
- */
20
- class Add_Quicktag_Settings extends Add_Quicktag {
21
-
22
- /**
23
- * string for translation
24
- * @var string
25
- */
26
- static public $textdomain;
27
-
28
- /**
29
- * string for options in table options
30
- * @var string
31
- */
32
- static private $option_string;
33
-
34
- /**
35
- * string for plugin file
36
- * @var string
37
- */
38
- static private $plugin;
39
-
40
- /**
41
- * post types for the settings
42
- * @var Array
43
- */
44
- static private $post_types_for_js;
45
-
46
- /**
47
- * string for nonce fields
48
- * @var string
49
- */
50
- static public $nonce_string;
51
-
52
- /**
53
- * @var
54
- */
55
- protected $page_hook;
56
-
57
- /**
58
- * Handler for the action 'init'. Instantiates this class.
59
- * @access public
60
- * @since 2.0.0
61
- * @return \Add_Quicktag|\Add_Quicktag_Settings $instance
62
- */
63
- public static function get_object() {
64
-
65
- static $instance;
66
-
67
- if ( NULL === $instance ) {
68
- $instance = new self();
69
- }
70
-
71
- return $instance;
72
- }
73
-
74
- /**
75
- * Constructor, init on defined hooks of WP and include second class
76
- * @access public
77
- * @since 0.0.2
78
- * @uses register_activation_hook, register_uninstall_hook, add_action
79
- * @return \Add_Quicktag_Settings
80
- */
81
- private function __construct() {
82
-
83
- if ( ! is_admin() ) {
84
- return NULL;
85
- }
86
-
87
- // textdomain from parent class
88
- self::$textdomain = parent::get_textdomain();
89
- self::$option_string = parent::get_option_string();
90
- self::$plugin = parent::get_plugin_string();
91
- self::$post_types_for_js = parent::get_post_types_for_js();
92
- self::$nonce_string = 'addquicktag_nonce';
93
-
94
- register_uninstall_hook( __FILE__, array( 'Add_Quicktag_Settings', 'unregister_settings' ) );
95
- // settings for an active multisite
96
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
97
- add_action( 'network_admin_menu', array( $this, 'add_settings_page' ) );
98
- // add settings link
99
- add_filter(
100
- 'network_admin_plugin_action_links', array(
101
- $this,
102
- 'network_admin_plugin_action_links'
103
- ), 10, 2
104
- );
105
- // save settings on network
106
- add_action( 'network_admin_edit_' . self::$option_string, array( $this, 'save_network_settings_page' ) );
107
- // return message for update settings
108
- add_action( 'network_admin_notices', array( $this, 'get_network_admin_notices' ) );
109
- // add script on settings page
110
- } else {
111
- add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
112
- // add settings link
113
- add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 );
114
- // use settings API
115
- add_action( 'admin_init', array( $this, 'register_settings' ) );
116
- }
117
- // include js
118
- add_action(
119
- 'admin_print_scripts-settings_page_' . str_replace( '.php', '', plugin_basename( __FILE__ ) ),
120
- array( $this, 'print_scripts' )
121
- );
122
-
123
- // add meta boxes on settings pages
124
- add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_plugin_infos' ) );
125
- add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_about_plugin' ) );
126
-
127
- // include class for remove core quicktags
128
- require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-remove-quicktags.php';
129
- // include class for add enhanced code quicktags
130
- // @TODO Solution for special code tags in quicktags
131
- require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-code-quicktags.php';
132
- // include class for im/export
133
- require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-imexport.php';
134
- }
135
-
136
- /**
137
- * Return allowed post types for include scripts
138
- * @since 2.1.1
139
- * @access public
140
- * @return Array
141
- */
142
- public function get_post_types_for_js() {
143
-
144
- return self::$post_types_for_js;
145
- }
146
-
147
- /**
148
- * Return Textdomain string
149
- * @access public
150
- * @since 2.0.0
151
- * @return string
152
- */
153
- public function get_textdomain() {
154
-
155
- return self::$textdomain;
156
- }
157
-
158
- /**
159
- * Add settings link on plugins.php in backend
160
- * @uses
161
- * @access public
162
- *
163
- * @param array $links , string $file
164
- * @param string $file
165
- *
166
- * @since 2.0.0
167
- * @return string $links
168
- */
169
- public function plugin_action_links( $links, $file ) {
170
-
171
- if ( parent :: get_plugin_string() == $file ) {
172
- $links[ ] = '<a href="options-general.php?page=' . plugin_basename( __FILE__ ) . '">' . __( 'Settings' ) . '</a>';
173
- }
174
-
175
- return $links;
176
- }
177
-
178
- /**
179
- * Add settings link on plugins.php on network admin in backend
180
- * @uses
181
- * @access public
182
- * @since 2.0.0
183
- *
184
- * @param array $links , string $file
185
- * @param $file
186
- *
187
- * @return string $links
188
- */
189
- public function network_admin_plugin_action_links( $links, $file ) {
190
-
191
- if ( parent :: get_plugin_string() == $file ) {
192
- $links[ ] = '<a href="settings.php?page=' . plugin_basename( __FILE__ ) . '">' . __( 'Settings' ) . '</a>';
193
- }
194
-
195
- return $links;
196
- }
197
-
198
- /**
199
- * Add settings page in WP backend
200
- * @uses add_options_page
201
- * @access public
202
- * @since 2.0.0
203
- * @return void
204
- */
205
- public function add_settings_page() {
206
-
207
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
208
- add_submenu_page(
209
- 'settings.php',
210
- parent :: get_plugin_data( 'Name' ) . ' ' . __( 'Settings', $this->get_textdomain() ),
211
- parent :: get_plugin_data( 'Name' ),
212
- 'manage_options',
213
- plugin_basename( __FILE__ ),
214
- array( $this, 'get_settings_page' )
215
- );
216
- } else {
217
- add_options_page(
218
- parent :: get_plugin_data( 'Name' ) . ' ' . __( 'Settings', $this->get_textdomain() ),
219
- parent :: get_plugin_data( 'Name' ),
220
- 'manage_options',
221
- plugin_basename( __FILE__ ),
222
- array( $this, 'get_settings_page' )
223
- );
224
- add_action( 'contextual_help', array( $this, 'contextual_help' ), 10, 3 );
225
- }
226
- }
227
-
228
- /**
229
- * Return form and markup on settings page
230
- * @uses settings_fields, normalize_whitespace, is_plugin_active_for_network, get_site_option, get_option
231
- * @access public
232
- * @since 0.0.2
233
- * @return void
234
- */
235
- public function get_settings_page() {
236
-
237
- ?>
238
- <div class="wrap">
239
- <h2><?php echo parent :: get_plugin_data( 'Name' ); ?></h2>
240
-
241
- <h3><?php _e( 'Add or delete Quicktag buttons', $this->get_textdomain() ); ?></h3>
242
-
243
- <p><?php _e( 'Fill in the fields below to add or edit the quicktags. Fields with * are required. To delete a tag simply empty all fields.', $this->get_textdomain() ); ?></p>
244
-
245
- <?php
246
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
247
- $action = 'edit.php?action=' . self::$option_string;
248
- } else {
249
- $action = 'options.php';
250
- }
251
- ?>
252
- <form method="post" action="<?php echo $action; ?>">
253
- <?php
254
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
255
- wp_nonce_field( self::$nonce_string );
256
- $options = get_site_option( self::$option_string );
257
- } else {
258
- settings_fields( self::$option_string . '_group' );
259
- $options = get_option( self::$option_string );
260
- }
261
-
262
- if ( ! isset( $options[ 'buttons' ] ) ) {
263
- $options[ 'buttons' ] = array();
264
- }
265
-
266
- if ( 1 < count( $options[ 'buttons' ] ) ) {
267
- // sort array by order value
268
- $tmp = array();
269
- foreach ( $options[ 'buttons' ] as $order ) {
270
- if ( isset( $order[ 'order' ] ) ) {
271
- $tmp[ ] = $order[ 'order' ];
272
- } else {
273
- $tmp[ ] = 0;
274
- }
275
- }
276
- array_multisort( $tmp, SORT_ASC, $options[ 'buttons' ] );
277
- }
278
-
279
- // loop about the post types, create html an values for title in table
280
- $pt_title = '';
281
- $pt_colgroup = '';
282
- foreach ( $this->get_post_types_for_js() as $post_type ) {
283
-
284
- $pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
285
- $pt_colgroup .= '<colgroup></colgroup>' . "\n";
286
- }
287
- ?>
288
-
289
- <table class="widefat form-table rmnlQuicktagSettings">
290
- <colgroup></colgroup>
291
- <colgroup></colgroup>
292
- <colgroup></colgroup>
293
- <colgroup></colgroup>
294
- <colgroup></colgroup>
295
- <?php echo $pt_colgroup; ?>
296
- <colgroup></colgroup>
297
-
298
- <tr class="rmnlqsheader">
299
- <th class="row-title"><?php _e( 'Button Label* and', $this->get_textdomain() ); ?><br />
300
- <?php _e( 'Title Attribute', $this->get_textdomain() ); ?></th>
301
- <th class="row-title"><?php _e( 'Start Tag(s)* and', $this->get_textdomain() ); ?><br />
302
- <?php _e( 'End Tag(s)', $this->get_textdomain() ); ?></th>
303
- <th class="row-title"><?php _e( 'Access Key and', $this->get_textdomain() ); ?><br />
304
- <?php _e( 'Order', $this->get_textdomain() ); ?></th>
305
- <th class="row-title rotate"><span><?php _e( 'Visual', $this->get_textdomain() ); ?></span></th>
306
- <?php echo $pt_title ?>
307
- <th class="row-title rotate">&#x2714;</th>
308
- </tr>
309
- <?php
310
- if ( empty( $options[ 'buttons' ] ) ) {
311
- $options[ 'buttons' ] = array();
312
- }
313
- $class = '';
314
- for ( $i = 0; $i < count( $options[ 'buttons' ] ); $i ++ ) {
315
- $class = ( ' class="alternate"' == $class ) ? '' : ' class="alternate"';
316
- $b = $options[ 'buttons' ][ $i ];
317
- $b[ 'text' ] = htmlentities( stripslashes( $b[ 'text' ] ), ENT_COMPAT, get_option( 'blog_charset' ) );
318
- if ( isset( $b[ 'title' ] ) ) {
319
- $b[ 'title' ] = htmlentities( stripslashes( $b[ 'title' ] ), ENT_COMPAT, get_option( 'blog_charset' ) );
320
- }
321
- $b[ 'start' ] = htmlentities( $b[ 'start' ], ENT_COMPAT, get_option( 'blog_charset' ) );
322
- if ( isset( $b[ 'end' ] ) ) {
323
- $b[ 'end' ] = htmlentities( $b[ 'end' ], ENT_COMPAT, get_option( 'blog_charset' ) );
324
- }
325
- if ( ! isset( $b[ 'access' ] ) ) {
326
- $b[ 'access' ] = '';
327
- }
328
- $b[ 'access' ] = htmlentities( $b[ 'access' ], ENT_COMPAT, get_option( 'blog_charset' ) );
329
- if ( ! isset( $b[ 'order' ] ) ) {
330
- $b[ 'order' ] = 0;
331
- }
332
- $b[ 'order' ] = intval( $b[ 'order' ] );
333
- if ( ! isset( $b[ 'visual' ] ) ) {
334
- $b[ 'visual' ] = 0;
335
- }
336
- $b[ 'visual' ] = intval( $b[ 'visual' ] );
337
- if ( 1 == $b[ 'visual' ] ) {
338
- $checked = ' checked="checked"';
339
- } else {
340
- $checked = '';
341
- }
342
- // loop about the post types, create html an values
343
- $pt_checkboxes = '';
344
- foreach ( $this->get_post_types_for_js() as $post_type ) {
345
-
346
- if ( ! isset( $b[ $post_type ] ) ) {
347
- $b[ $post_type ] = 0;
348
- }
349
-
350
- $b[ $post_type ] = intval( $b[ $post_type ] );
351
-
352
- if ( 1 == $b[ $post_type ] ) {
353
- $pt_checked = ' checked="checked"';
354
- } else {
355
- $pt_checked = '';
356
- }
357
-
358
- $pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
359
- self::$option_string . '[buttons][' .
360
- $i . '][' . $post_type . ']" value="1"' .
361
- $pt_checked . '/></td>' . "\n";
362
- }
363
-
364
- echo '
365
- <tr id="rmqtb' . $i . '">
366
- <td><input type="text" name="' . self::$option_string . '[buttons][' . $i
367
- . '][text]" value="' . $b[ 'text' ] . '" /><br />
368
- <input type="text" name="' . self::$option_string . '[buttons][' . $i . '][title]" value="'
369
- . $b[ 'title' ] . '" /></td>
370
- <td><textarea class="code" name="' . self::$option_string . '[buttons][' . $i
371
- . '][start]" rows="2" cols="25" >' . $b[ 'start' ] . '</textarea><br />
372
- <textarea class="code" name="' . self::$option_string . '[buttons][' . $i
373
- . '][end]" rows="2" cols="25" >' . $b[ 'end' ] . '</textarea></td>
374
- <td><input class="small-text" type="text" name="' . self::$option_string . '[buttons][' . $i
375
- . '][access]" value="' . $b[ 'access' ] . '" /><br />
376
- <input class="small-text" type="text" name="' . self::$option_string . '[buttons][' . $i
377
- . '][order]" value="' . $b[ 'order' ] . '" /></td>
378
- <td class="num"><input type="checkbox" name="' . self::$option_string . '[buttons][' . $i
379
- . '][visual]" value="1"' . $checked . '/></td>' .
380
- $pt_checkboxes . '
381
- <td class="num"><input type="checkbox" class="toggle" id="select_all_' . $i . '" value="' . $i . '" /></td>' . '
382
- </tr>
383
- ';
384
- }
385
-
386
- // loop about the post types, create html an values for empty new checkboxes
387
- $pt_new_boxes = '';
388
- foreach ( $this->get_post_types_for_js() as $post_type ) {
389
- if ( ! isset( $b[ $post_type ] ) ) {
390
- $b[ $post_type ] = 0;
391
- }
392
-
393
- $b[ $post_type ] = intval( $b[ $post_type ] );
394
-
395
- if ( 1 == $b[ $post_type ] ) {
396
- $pt_checked = ' checked="checked"';
397
- } else {
398
- $pt_checked = '';
399
- }
400
-
401
- $pt_new_boxes .= '<td class="num"><input type="checkbox" name="' .
402
- self::$option_string . '[buttons][' .
403
- $i . '][' . $post_type . ']" value="1" /></td>' . "\n";
404
- }
405
- ?>
406
- <tr id="rmqtb<?php echo $i ?>">
407
- <td>
408
- <input type="text" placeholder="<?php _e( 'Button Label*', $this->get_textdomain() ); ?>" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][text]" value="" /><br />
409
- <input type="text" placeholder="<?php _e( 'Title Attribute', $this->get_textdomain() ); ?>" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][title]" value="" />
410
- </td>
411
- <td>
412
- <textarea placeholder="<?php _e( 'Start Tag(s)*', $this->get_textdomain() ); ?>" class="code" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][start]" rows="2" cols="25"></textarea><br />
413
- <textarea placeholder="<?php _e( 'End Tag(s)', $this->get_textdomain() ); ?>" class="code" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][end]" rows="2" cols="25"></textarea>
414
- </td>
415
- <td>
416
- <input type="text" placeholder="<?php _e( 'Access Key', $this->get_textdomain() ); ?>" title="<?php _e( 'Access Key', $this->get_textdomain() ); ?>" class="small-text" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][access]" value="" /><br />
417
- <input type="text" placeholder="<?php _e( 'Order', $this->get_textdomain() ); ?>" title="<?php _e( 'Order', $this->get_textdomain() ); ?>" class="small-text" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][order]" value="" />
418
- </td>
419
- <td class="num">
420
- <input type="checkbox" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][visual]" value="1" />
421
- </td>
422
- <?php echo $pt_new_boxes; ?>
423
- <td class="num">
424
- <input type="checkbox" class="toggle" id="select_all_<?php echo $i ?>" value="<?php echo $i ?>" />
425
- </td>
426
- </tr>
427
- </table>
428
-
429
- <?php do_action( 'addquicktag_settings_form_page', $options ); ?>
430
-
431
- <p class="submit">
432
- <input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" />
433
- </p>
434
-
435
- </form>
436
-
437
- <div class="metabox-holder has-right-sidebar">
438
-
439
- <div class="inner-sidebar">
440
- <?php do_action( 'addquicktag_settings_page_sidebar' ); ?>
441
- </div>
442
- <!-- .inner-sidebar -->
443
-
444
- <div id="post-body">
445
- <div id="post-body-content">
446
- <?php do_action( 'addquicktag_settings_page', $options ); ?>
447
- </div>
448
- <!-- #post-body-content -->
449
- </div>
450
- <!-- #post-body -->
451
-
452
- </div>
453
- <!-- .metabox-holder -->
454
-
455
- </div>
456
- <?php
457
- }
458
-
459
- /*
460
- * Return information to donate
461
- *
462
- * @uses _e,esc_attr_e
463
- * @access public
464
- * @since 2.0.0
465
- * @return void
466
- */
467
- public function get_plugin_infos() {
468
-
469
- ?>
470
- <div class="postbox">
471
-
472
- <h3><span><?php _e( 'Like this plugin?', $this->get_textdomain() ); ?></span></h3>
473
-
474
- <div class="inside">
475
- <p><?php _e( 'Here\'s how you can give back:', $this->get_textdomain() ); ?></p>
476
- <ul>
477
- <li>
478
- <a href="http://wordpress.org/support/view/plugin-reviews/addquicktag" title="<?php esc_attr_e( 'The Plugin on the WordPress plugin repository', $this->get_textdomain() ); ?>"><?php esc_attr_e( 'Give the plugin a good rating.', $this->get_textdomain() ); ?></a>
479
- </li>
480
- <li>
481
- <a href="http://wordpress.org/support/plugin/addquicktag" title="<?php esc_attr_e( 'Help inside the community other useres and write answer to this plugin questions.', $this->get_textdomain() ); ?>"><?php esc_attr_e( 'Help other users in the Support Forum.', $this->get_textdomain() ); ?></a>
482
- </li>
483
- <li>
484
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=6069955" title="<?php esc_attr_e( 'Donate via PayPal', $this->get_textdomain() ); ?>"><?php esc_attr_e( 'Donate a few euros.', $this->get_textdomain() ); ?></a>
485
- </li>
486
- <li>
487
- <a href="http://www.amazon.de/gp/registry/3NTOGEK181L23/ref=wl_s_3" title="<?php esc_attr_e( 'Frank Bültge\'s Amazon Wish List', $this->get_textdomain() ); ?>"><?php esc_attr_e( 'Get me something from my wish list.', $this->get_textdomain() ); ?></a>
488
- </li>
489
- <li>
490
- <a href="https://github.com/bueltge/AddQuicktag" title="<?php esc_attr_e( 'Please give me feedback, contribute and file technical bugs on this GitHub Repo, use Issues.', $this->get_textdomain() ); ?>"><?php esc_attr_e( 'Github Repo for Contribute, Issues & Bugs', $this->get_textdomain() ); ?></a>
491
- </li>
492
- </ul>
493
- </div>
494
- </div>
495
- <?php
496
- }
497
-
498
- /*
499
- * Return informations about the plugin
500
- *
501
- * @uses _e,esc_attr_e
502
- * @access public
503
- * @since 2.0.0
504
- * @return void
505
- */
506
- public function get_about_plugin() {
507
-
508
- ?>
509
- <div class="postbox">
510
-
511
- <h3><span><?php _e( 'About this plugin', $this->get_textdomain() ); ?></span></h3>
512
-
513
- <div class="inside">
514
- <p>
515
- <strong><?php _e( 'Version:', $this->get_textdomain() ); ?></strong>
516
- <?php echo parent :: get_plugin_data( 'Version' ); ?>
517
- </p>
518
-
519
- <p>
520
- <strong><?php _e( 'Description:', $this->get_textdomain() ); ?></strong>
521
- <?php echo parent :: get_plugin_data( 'Description' ); ?>
522
- </p>
523
- </div>
524
-
525
- </div>
526
- <?php
527
- }
528
-
529
- /*
530
- * Save network settings
531
- *
532
- * @uses update_site_option, wp_redirect, add_query_arg, network_admin_url
533
- * @access public
534
- * @since 2.0.0
535
- * @return void
536
- */
537
- public function save_network_settings_page() {
538
-
539
- if ( ! wp_verify_nonce( $_REQUEST[ '_wpnonce' ], self::$nonce_string ) ) {
540
- wp_die( 'Sorry, you failed the nonce test.' );
541
- }
542
-
543
- // validate options
544
- $value = $this->validate_settings( $_POST[ self::$option_string ] );
545
-
546
- // update options
547
- update_site_option( self::$option_string, $value );
548
- // redirect to settings page in network
549
- wp_redirect(
550
- add_query_arg(
551
- array( 'page' => plugin_basename( __FILE__ ), 'updated' => 'true' ),
552
- network_admin_url( 'settings.php' )
553
- )
554
- );
555
- exit();
556
- }
557
-
558
- /*
559
- * Retrun string vor update message
560
- *
561
- * @uses
562
- * @access public
563
- * @since 2.0.0
564
- * @return string $notice
565
- */
566
- public function get_network_admin_notices() {
567
-
568
- // if updated and the right page
569
- if ( isset( $_GET[ 'updated' ] ) &&
570
- 'settings_page_addquicktag/inc/class-settings-network' === $GLOBALS[ 'current_screen' ] ->id
571
- ) {
572
- $message = __( 'Options saved.', $this->get_textdomain() );
573
- $notice = '<div id="message" class="updated"><p>' . $message . '</p></div>';
574
- echo $notice;
575
- }
576
- }
577
-
578
- /**
579
- * Validate settings for options
580
- * @uses normalize_whitespace
581
- * @access public
582
- *
583
- * @param array $value
584
- *
585
- * @since 2.0.0
586
- * @return string $value
587
- */
588
- public function validate_settings( $value ) {
589
-
590
- // Save core buttons changes
591
- if ( isset( $value[ 'core_buttons' ] ) ) {
592
- $core_buttons = $value[ 'core_buttons' ];
593
- }
594
-
595
- // Save Code buttons
596
- if ( isset( $value[ 'code_buttons' ] ) ) {
597
- $code_buttons = $value[ 'code_buttons' ];
598
- }
599
-
600
- // set allowed values for import, only the defaults of plugin and custom post types
601
- $allowed_settings = (array) array_merge(
602
- $this->get_post_types_for_js(),
603
- array( 'text', 'title', 'start', 'end', 'access', 'order', 'visual' )
604
- );
605
-
606
- $buttons = '';
607
- // filter for allowed values
608
- foreach ( $value[ 'buttons' ] as $key => $button ) {
609
-
610
- foreach ( $button as $label => $val ) {
611
-
612
- if ( ! in_array( $label, $allowed_settings ) ) {
613
- unset( $button[ $label ] );
614
- }
615
- }
616
-
617
- $buttons[ ] = $button;
618
- }
619
-
620
- // return filtered array
621
- $filtered_values[ 'buttons' ] = $buttons;
622
- $value = $filtered_values;
623
-
624
- $buttons = array();
625
- for ( $i = 0; $i < count( $value[ 'buttons' ] ); $i ++ ) {
626
-
627
- $b = $value[ 'buttons' ][ $i ];
628
- if ( ! empty( $b[ 'text' ] ) && ! empty( $b[ 'start' ] ) ) {
629
-
630
- $b[ 'text' ] = esc_html( $b[ 'text' ] );
631
- $b[ 'title' ] = esc_html( $b[ 'title' ] );
632
- $b[ 'start' ] = stripslashes( $b[ 'start' ] );
633
- $b[ 'end' ] = stripslashes( $b[ 'end' ] );
634
-
635
- if ( isset( $b[ 'access' ] ) ) {
636
- $b[ 'access' ] = esc_html( $b[ 'access' ] );
637
- }
638
-
639
- if ( isset( $b[ 'order' ] ) ) {
640
- $b[ 'order' ] = intval( $b[ 'order' ] );
641
- }
642
-
643
- // visual settings
644
- if ( isset( $b[ 'visual' ] ) ) {
645
- $b[ 'visual' ] = intval( $b[ 'visual' ] );
646
- } else {
647
- $b[ 'visual' ] = 0;
648
- }
649
-
650
- // post types
651
- foreach ( $this->get_post_types_for_js() as $post_type ) {
652
-
653
- if ( isset( $b[ $post_type ] ) ) {
654
- $b[ $post_type ] = intval( $b[ $post_type ] );
655
- } else {
656
- $b[ $post_type ] = 0;
657
- }
658
-
659
- }
660
-
661
- $buttons[ ] = $b;
662
- }
663
-
664
- }
665
-
666
- // Check for wrong empty values and kill
667
- foreach ( $value[ 'buttons' ] as $key => $b ) {
668
-
669
- if ( empty( $b[ 'text' ] ) && empty( $b[ 'start' ] ) ) {
670
- unset( $value[ 'buttons' ][ $key ] );
671
- }
672
- }
673
- // reorder the array
674
- $value[ 'buttons' ] = array_values( $value[ 'buttons' ] );
675
-
676
- // Filter core button values, strings and convert to integer
677
- if ( ! empty( $core_buttons ) ) {
678
-
679
- /**
680
- * $key is core-string
681
- * 'core_buttons' =>
682
- array (size=1)
683
- 'strong' =>
684
- array (size=2)
685
- 'post' => string '1' (length=1)
686
- 'page' => string '1' (length=1)
687
- */
688
- $filtered_core_buttons = array();
689
- foreach ( $core_buttons as $key => $var ) {
690
-
691
- $core_button = array();
692
- foreach ( $var as $post_type => $val ) {
693
- $core_button[ $post_type ] = intval( $val );
694
- }
695
-
696
- $filtered_core_buttons[ $key ] = $core_button;
697
-
698
- }
699
-
700
- $value[ 'core_buttons' ] = $filtered_core_buttons;
701
-
702
- }
703
-
704
- // Filter code button values, strings and convert to integer
705
- if ( ! empty( $code_buttons ) ) {
706
-
707
- $filtered_code_buttons = array();
708
- foreach ( $code_buttons as $key => $var ) {
709
-
710
- $code_button = array();
711
- foreach ( $var as $post_type => $val ) {
712
- $code_button[ $post_type ] = intval( $val );
713
- }
714
-
715
- $filtered_code_buttons[ $key ] = $code_button;
716
-
717
- }
718
-
719
- $value[ 'code_buttons' ] = $filtered_code_buttons;
720
-
721
- }
722
-
723
- return $value;
724
- }
725
-
726
- /**
727
- * Register settings for options
728
- * @uses register_setting
729
- * @access public
730
- * @since 2.0.0
731
- * @return void
732
- */
733
- public function register_settings() {
734
-
735
- register_setting( self::$option_string . '_group', self::$option_string, array( $this, 'validate_settings' ) );
736
- }
737
-
738
- /**
739
- * Unregister and delete settings; clean database
740
- * @uses unregister_setting, delete_option
741
- * @access public
742
- * @since 0.0.2
743
- * @return void
744
- */
745
- public function unregister_settings() {
746
-
747
- unregister_setting( self::$option_string . '_group', self::$option_string );
748
- delete_option( self::$option_string );
749
- }
750
-
751
- /**
752
- * Enqueue scripts and stylesheets
753
- * @since 0.0.2
754
- *
755
- * @internal param $where
756
- */
757
- public function print_scripts() {
758
-
759
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
760
-
761
- wp_register_script(
762
- self::$option_string . '_admin_script',
763
- plugins_url( '/js/settings' . $suffix . '.js', parent::get_plugin_string() ),
764
- array( 'jquery', 'quicktags' ),
765
- '',
766
- TRUE
767
- );
768
- wp_enqueue_script( self::$option_string . '_admin_script' );
769
-
770
- wp_register_style(
771
- self::$option_string . '_admin_style',
772
- plugins_url( '/css/settings' . $suffix . '.css', parent::get_plugin_string() ),
773
- array(),
774
- FALSE,
775
- 'screen'
776
- );
777
- wp_enqueue_style( self::$option_string . '_admin_style' );
778
- }
779
-
780
- /**
781
- * Add help text
782
- * @uses normalize_whitespace
783
- *
784
- * @param string $contextual_help
785
- * @param string $screen_id