AddQuicktag - Version 2.3.0-RC1

Version Description

(05/22/2014) = * Use on default all post types with active UI, incl. Custom and Defaul Post types * New settings UI to easier add quicktags to each post type * Add Widget area, now it is possible to use Quicktags on widgets with WP editor * Add brazilian translation * Add turkish translation * Add possibility to remove default quicktags * Changes on settings style, check in MP6 design, WP 3.8 * Add ukranian translation * Add solution to remove core quicktag, Beta Status * Fix TinyMCE Select Box in WordPress 3.9*

Download this release

Release Info

Developer Bueltge
Plugin Icon wp plugin AddQuicktag
Version 2.3.0-RC1
Comparing to
See all releases

Code changes from version 2.2.2 to 2.3.0-RC1

addquicktag.php CHANGED
@@ -1,110 +1,198 @@
1
  <?php
 
2
  /**
3
  * Plugin Name: AddQuicktag
4
  * Plugin URI: http://bueltge.de/wp-addquicktags-de-plugin/120/
5
  * Text Domain: addquicktag
6
  * Domain Path: /languages
7
  * Description: Allows you to easily add custom Quicktags to the html- and visual-editor.
8
- * Version: 2.2.2
9
  * Author: Frank Bültge
10
  * Author URI: http://bueltge.de
11
- * License: GPLv3
12
- *
13
- *
14
- *
15
- License:
16
- ==============================================================================
17
- Copyright 2011 - 2013 Frank Bültge (email : frank@bueltge.de)
18
-
19
- This program is free software; you can redistribute it and/or modify
20
- it under the terms of the GNU General Public License as published by
21
- the Free Software Foundation; either version 2 of the License, or
22
- (at your option) any later version.
23
-
24
- This program is distributed in the hope that it will be useful,
25
- but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- GNU General Public License for more details.
28
-
29
- You should have received a copy of the GNU General Public License
30
- along with this program; if not, write to the Free Software
31
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32
-
33
- Requirements:
34
- ==============================================================================
35
- This plugin requires WordPress >= 3.3 and tested with PHP Interpreter >= 5.3
36
- *
37
- *
38
  *
39
  * Add Quicktag Plugin class
40
- *
41
  * @since 2.0.0
42
  */
43
  class Add_Quicktag {
44
-
45
- protected static $classobj;
46
-
47
- static private $option_string = 'rmnlQuicktagSettings';
48
- // use filter 'addquicktag_pages' for add custom pages
 
 
 
 
 
 
 
 
49
  static private $admin_pages_for_js = array(
50
- 'post.php', 'post-new.php', 'comment.php', 'edit-comments.php'
 
 
 
 
51
  );
52
- // use filter 'addquicktag_post_types' for add custom post_types
53
- static private $post_types_for_js = array(
54
- 'post', 'page', 'comment', 'edit-comments'
55
- );
56
-
 
 
 
 
 
 
57
  static private $plugin;
58
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  /**
60
  * Constructor, init the functions inside WP
61
  *
62
  * @since 2.0.0
63
- * @return void
64
  */
65
- function __construct() {
66
-
67
- if ( ! is_admin() )
68
  return;
69
-
 
70
  // get string of plugin
71
- self :: $plugin = plugin_basename( __FILE__ );
72
-
73
  // on uninstall remove capability from roles
74
- register_uninstall_hook( __FILE__, array('Add_Quicktag', 'uninstall' ) );
75
  // on deactivate delete all settings in database
76
  // register_deactivation_hook( __FILE__, array('Add_Quicktag', 'uninstall' ) );
77
-
78
  // load translation files
79
  add_action( 'admin_init', array( $this, 'localize_plugin' ) );
80
  // on init register post type for addquicktag and print js
81
  add_action( 'init', array( $this, 'on_admin_init' ) );
82
-
 
83
  }
84
-
85
-
86
  /**
87
  * Include other files and print JS
88
- *
89
  * @since 07/16/2012
90
  * @return void
91
  */
92
  public function on_admin_init() {
93
-
94
- if ( ! is_admin() )
95
  return NULL;
96
-
 
97
  // Include settings
98
  require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-settings.php';
99
  // Include solution for TinyMCE
100
  require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-tinymce.php';
101
-
102
  foreach ( $this->get_admin_pages_for_js() as $page ) {
103
  add_action( 'admin_print_scripts-' . $page, array( $this, 'get_json' ) );
104
- add_action( 'admin_print_scripts-' . $page, array( $this, 'admin_enqueue_scripts') );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
 
 
 
 
 
 
106
  }
107
-
108
  /**
109
  * Uninstall data in options table, if the plugin was uninstall via backend
110
  *
@@ -112,11 +200,10 @@ class Add_Quicktag {
112
  * @return void
113
  */
114
  public function uninstall() {
115
-
116
- delete_option( self :: $option_string );
117
- delete_site_option( self :: $option_string );
118
  }
119
-
120
  /**
121
  * Print json data in head
122
  *
@@ -124,83 +211,96 @@ class Add_Quicktag {
124
  * @return void
125
  */
126
  public function get_json() {
 
127
  global $current_screen;
128
-
129
- if ( isset( $current_screen->id ) &&
130
- ! in_array(
131
- $current_screen->id,
132
- $this->get_post_types_for_js()
133
- )
134
- )
135
  return NULL;
136
-
137
- if ( is_multisite() && is_plugin_active_for_network( $this -> get_plugin_string() ) )
138
- $options = get_site_option( self :: $option_string );
139
- else
140
- $options = get_option( self :: $option_string );
141
-
 
 
 
 
 
 
142
  // allow change or enhance buttons array
143
- $options['buttons'] = apply_filters( 'addquicktag_buttons', $options['buttons'] );
144
  // hook for filter options
145
  $options = apply_filters( 'addquicktag_options', $options );
146
-
147
- if ( ! $options )
148
  return NULL;
149
-
150
- if ( 1 < count($options['buttons']) ) {
 
151
  // sort array by order value
152
  $tmp = array();
153
- foreach( $options['buttons'] as $order ) {
154
- if ( isset( $order['order'] ) )
155
- $tmp[] = $order['order'];
156
- else
157
- $tmp[] = 0;
 
158
  }
159
- array_multisort( $tmp, SORT_ASC, $options['buttons'] );
160
  }
161
-
162
  ?>
163
  <script type="text/javascript">
164
  var addquicktag_tags = <?php echo json_encode( $options ); ?>,
165
  addquicktag_post_type = <?php echo json_encode( $current_screen->id ); ?>,
166
  addquicktag_pt_for_js = <?php echo json_encode( $this->get_post_types_for_js() ); ?>;
167
  </script>
168
- <?php
169
  }
170
-
171
  /**
172
  * Enqueue Scripts for plugin
173
- *
174
  * @param $where string
 
175
  * @since 2.0.0
176
  * @access public
177
  * @return void
178
  */
179
  public function admin_enqueue_scripts( $where ) {
 
180
  global $current_screen;
181
-
182
- if ( isset( $current_screen->id ) &&
183
- ! in_array(
184
- $current_screen->id,
185
- $this->get_post_types_for_js()
186
- )
187
- )
188
  return NULL;
189
-
190
- $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
191
-
192
- if ( version_compare( $GLOBALS['wp_version'], '3.3alpha', '>=' ) ) {
 
193
  wp_enqueue_script(
194
- self :: get_textdomain() . '_script',
195
- plugins_url( '/js/add-quicktags' . $suffix. '.js', __FILE__ ),
196
  array( 'jquery', 'quicktags' ),
197
  '',
198
  TRUE
199
  );
 
200
  } else {
201
  wp_enqueue_script(
202
- self :: get_textdomain() . '_script',
203
- plugins_url( '/js/add-quicktags_32' . $suffix. '.js', __FILE__ ),
204
  array( 'jquery', 'quicktags' ),
205
  '',
206
  TRUE
@@ -209,121 +309,127 @@ class Add_Quicktag {
209
  // Alternative to JSON function
210
  // wp_localize_script( self :: get_textdomain() . '_script', 'addquicktag_tags', get_option( self :: $option_string ) );
211
  }
212
-
213
- /**
214
- * Handler for the action 'init'. Instantiates this class.
215
- *
216
- * @since 2.0.0
217
- * @access public
218
- * @return $classobj
219
- */
220
- public static function get_object() {
221
-
222
- if ( NULL === self :: $classobj ) {
223
- self :: $classobj = new self;
224
- }
225
-
226
- return self :: $classobj;
227
- }
228
-
229
  /**
230
  * Localize_plugin function.
231
  *
232
- * @uses load_plugin_textdomain, plugin_basename
233
  * @access public
234
  * @since 2.0.0
235
  * @return void
236
  */
237
  public function localize_plugin() {
238
-
239
- load_plugin_textdomain( $this -> get_textdomain(), FALSE, dirname( plugin_basename(__FILE__) ) . '/languages' );
240
  }
241
-
242
  /**
243
  * return plugin comment data
244
- *
245
  * @since 2.0.0
246
  * @access public
 
247
  * @param $value string, default = 'TextDomain'
248
- * Name, PluginURI, Version, Description, Author, AuthorURI, TextDomain, DomainPath, Network, Title
 
249
  * @return string
250
  */
251
  public function get_plugin_data( $value = 'TextDomain' ) {
252
-
253
- static $plugin_data = array ();
254
-
255
  // fetch the data just once.
256
- if ( isset( $plugin_data[ $value ] ) )
257
  return $plugin_data[ $value ];
258
-
259
- if ( ! function_exists( 'get_plugin_data' ) )
 
260
  require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
261
-
262
- $plugin_data = get_plugin_data( __FILE__ );
263
- $plugin_value = $plugin_data[$value];
264
-
265
- return empty ( $plugin_data[ $value ] ) ? '' : $plugin_data[ $value ];
266
  }
267
-
268
  /**
269
  * Return string of plugin
270
- *
271
  * @since 2.0.0
272
  * @return string
273
  */
274
  public function get_plugin_string() {
275
-
276
  return self::$plugin;
277
  }
278
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  /**
280
- * Retrun allowed post types for include scripts
281
- *
282
  * @since 2.1.1
283
  * @access public
284
  * @return Array
285
  */
286
  public function get_post_types_for_js() {
287
-
288
- return apply_filters( 'addquicktag_post_types', self::$post_types_for_js );
289
  }
290
-
291
  /**
292
- * Retrun allowed post types for include scripts
293
- *
294
  * @since 2.1.1
295
  * @access public
296
  * @return Array
297
  */
298
  public function get_admin_pages_for_js() {
299
-
300
  return apply_filters( 'addquicktag_pages', self::$admin_pages_for_js );
301
  }
302
-
303
  /**
304
- * Retrun textdomain string
305
- *
306
  * @since 2.0.0
307
  * @access public
308
  * @return string
309
  */
310
  public function get_textdomain() {
311
-
312
  return self::get_plugin_data( 'TextDomain' );
313
  }
314
-
315
  /**
316
  * Return string for options
317
  *
318
  * @since 2.0.0
319
- * @retrun string
320
  */
321
  public function get_option_string() {
322
-
323
- return self :: $option_string;
324
  }
325
-
326
-
327
  } // end class
328
 
329
  if ( function_exists( 'add_action' ) && class_exists( 'Add_Quicktag' ) ) {
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-RC1
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( '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 $qtInit 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 $qtInit the Buttons
158
+ */
159
+ public function remove_quicktags( $qtInit ) {
160
+
161
+ // No core buttons, not necessary to filter
162
+ if ( empty( $qtInit[ 'buttons' ] ) ) {
163
+ return $qtInit;
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 $qtInit;
175
+ }
176
+
177
+ // get only the keys
178
+ $remove_these = array_keys( $options[ 'core_buttons' ] );
179
+
180
+ // Convert string to array
181
+ $buttons = explode( ',', $qtInit[ 'buttons' ] );
182
+ // Loop over items to remove and unset them from the buttons
183
+ for ( $i = 0; $i < count( $remove_these ); $i ++ ) {
184
+ if ( FALSE !== ( $key = array_search( $remove_these[ $i ], $buttons ) ) ) {
185
+ unset( $buttons[ $key ] );
186
+ }
187
  }
188
+
189
+ // Convert new buttons array back into a comma-separated string
190
+ $qtInit[ 'buttons' ] = implode( ',', $buttons );
191
+ $qtInit[ 'buttons' ] = apply_filters( 'addquicktag_remove_buttons', $qtInit[ 'buttons' ] );
192
+
193
+ return $qtInit;
194
  }
195
+
196
  /**
197
  * Uninstall data in options table, if the plugin was uninstall via backend
198
  *
200
  * @return void
201
  */
202
  public function uninstall() {
203
+
204
+ delete_site_option( self::$option_string );
 
205
  }
206
+
207
  /**
208
  * Print json data in head
209
  *
211
  * @return void
212
  */
213
  public function get_json() {
214
+
215
  global $current_screen;
216
+
217
+ if ( isset( $current_screen->id ) &&
218
+ ! in_array(
219
+ $current_screen->id,
220
+ $this->get_post_types_for_js()
221
+ )
222
+ ) {
223
  return NULL;
224
+ }
225
+
226
+ if ( is_multisite() && is_plugin_active_for_network( $this ->get_plugin_string() ) ) {
227
+ $options = get_site_option( self::$option_string );
228
+ } else {
229
+ $options = get_option( self::$option_string );
230
+ }
231
+
232
+ if ( empty( $options[ 'buttons' ] ) ) {
233
+ $options[ 'buttons' ] = '';
234
+ }
235
+
236
  // allow change or enhance buttons array
237
+ $options[ 'buttons' ] = apply_filters( 'addquicktag_buttons', $options[ 'buttons' ] );
238
  // hook for filter options
239
  $options = apply_filters( 'addquicktag_options', $options );
240
+
241
+ if ( ! $options ) {
242
  return NULL;
243
+ }
244
+
245
+ if ( 1 < count( $options[ 'buttons' ] ) ) {
246
  // sort array by order value
247
  $tmp = array();
248
+ foreach ( $options[ 'buttons' ] as $order ) {
249
+ if ( isset( $order[ 'order' ] ) ) {
250
+ $tmp[ ] = $order[ 'order' ];
251
+ } else {
252
+ $tmp[ ] = 0;
253
+ }
254
  }
255
+ array_multisort( $tmp, SORT_ASC, $options[ 'buttons' ] );
256
  }
257
+
258
  ?>
259
  <script type="text/javascript">
260
  var addquicktag_tags = <?php echo json_encode( $options ); ?>,
261
  addquicktag_post_type = <?php echo json_encode( $current_screen->id ); ?>,
262
  addquicktag_pt_for_js = <?php echo json_encode( $this->get_post_types_for_js() ); ?>;
263
  </script>
264
+ <?php
265
  }
266
+
267
  /**
268
  * Enqueue Scripts for plugin
269
+ *
270
  * @param $where string
271
+ *
272
  * @since 2.0.0
273
  * @access public
274
  * @return void
275
  */
276
  public function admin_enqueue_scripts( $where ) {
277
+
278
  global $current_screen;
279
+
280
+ if ( isset( $current_screen->id ) &&
281
+ ! in_array(
282
+ $current_screen->id,
283
+ $this->get_post_types_for_js()
284
+ )
285
+ ) {
286
  return NULL;
287
+ }
288
+
289
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
290
+
291
+ if ( version_compare( $GLOBALS[ 'wp_version' ], '3.3alpha', '>=' ) ) {
292
  wp_enqueue_script(
293
+ self::get_textdomain() . '_script',
294
+ plugins_url( '/js/add-quicktags' . $suffix . '.js', __FILE__ ),
295
  array( 'jquery', 'quicktags' ),
296
  '',
297
  TRUE
298
  );
299
+ // Load only for WPs, there version is smaller then 3.2
300
  } else {
301
  wp_enqueue_script(
302
+ self::get_textdomain() . '_script',
303
+ plugins_url( '/js/add-quicktags_32' . $suffix . '.js', __FILE__ ),
304
  array( 'jquery', 'quicktags' ),
305
  '',
306
  TRUE
309
  // Alternative to JSON function
310
  // wp_localize_script( self :: get_textdomain() . '_script', 'addquicktag_tags', get_option( self :: $option_string ) );
311
  }
312
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  /**
314
  * Localize_plugin function.
315
  *
316
+ * @uses load_plugin_textdomain, plugin_basename
317
  * @access public
318
  * @since 2.0.0
319
  * @return void
320
  */
321
  public function localize_plugin() {
322
+
323
+ load_plugin_textdomain( $this->get_textdomain(), FALSE, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
324
  }
325
+
326
  /**
327
  * return plugin comment data
328
+ *
329
  * @since 2.0.0
330
  * @access public
331
+ *
332
  * @param $value string, default = 'TextDomain'
333
+ * Name, PluginURI, Version, Description, Author, AuthorURI, TextDomain, DomainPath, Network, Title
334
+ *
335
  * @return string
336
  */
337
  public function get_plugin_data( $value = 'TextDomain' ) {
338
+
339
+ static $plugin_data = array();
340
+
341
  // fetch the data just once.
342
+ if ( isset( $plugin_data[ $value ] ) ) {
343
  return $plugin_data[ $value ];
344
+ }
345
+
346
+ if ( ! function_exists( 'get_plugin_data' ) ) {
347
  require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
348
+ }
349
+
350
+ $plugin_data = get_plugin_data( __FILE__ );
351
+
352
+ return empty( $plugin_data[ $value ] ) ? '' : $plugin_data[ $value ];
353
  }
354
+
355
  /**
356
  * Return string of plugin
357
+ *
358
  * @since 2.0.0
359
  * @return string
360
  */
361
  public function get_plugin_string() {
362
+
363
  return self::$plugin;
364
  }
365
+
366
+ /**
367
+ * Get Post types with UI to use optional the quicktags
368
+ *
369
+ * @since 08/1/2013
370
+ * @return Array
371
+ */
372
+ private function get_post_types() {
373
+
374
+ // list only post types, there was used in UI
375
+ $args = array( 'show_ui' => TRUE );
376
+ $post_types = get_post_types( $args, 'names' );
377
+ // simplify the array
378
+ $post_types = array_values( $post_types );
379
+ // merge with strings from var
380
+ $post_types = array_merge( $post_types, self::$post_types_for_js );
381
+
382
+ return $post_types;
383
+ }
384
+
385
  /**
386
+ * Return allowed post types for include scripts
387
+ *
388
  * @since 2.1.1
389
  * @access public
390
  * @return Array
391
  */
392
  public function get_post_types_for_js() {
393
+
394
+ return apply_filters( 'addquicktag_post_types', $this->get_post_types() );
395
  }
396
+
397
  /**
398
+ * Return allowed post types for include scripts
399
+ *
400
  * @since 2.1.1
401
  * @access public
402
  * @return Array
403
  */
404
  public function get_admin_pages_for_js() {
405
+
406
  return apply_filters( 'addquicktag_pages', self::$admin_pages_for_js );
407
  }
408
+
409
  /**
410
+ * Return textdomain string
411
+ *
412
  * @since 2.0.0
413
  * @access public
414
  * @return string
415
  */
416
  public function get_textdomain() {
417
+
418
  return self::get_plugin_data( 'TextDomain' );
419
  }
420
+
421
  /**
422
  * Return string for options
423
  *
424
  * @since 2.0.0
425
+ * @return string
426
  */
427
  public function get_option_string() {
428
+
429
+ return self::$option_string;
430
  }
431
+
432
+
433
  } // end class
434
 
435
  if ( function_exists( 'add_action' ) && class_exists( 'Add_Quicktag' ) ) {
css/settings.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * AddQuicktag settings style
3
+ *
4
+ * @package AddQuicktag Plugin
5
+ * @author Frank Bueltge <frank@bueltge.de>
6
+ * @version 03/27/2014
7
+ * @since 2.02.3
8
+ */
9
+
10
+ .rmnlQuicktagSettings .rmnlqsheader{height:10em;vertical-align:bottom}.hover,table tr:hover{background-color:#ccc}.rmnlQuicktagSettings th{vertical-align:bottom!important;text-align:center}.rmnlQuicktagSettings .rotate{padding:0!important;margin:0 auto;width:1.2em;vertical-align:bottom!important}.rmnlQuicktagSettings .rotate span{display:block;padding:0!important;margin:0 auto;width:1.2em;vertical-align:middle!important;white-space:nowrap;writing-mode:tb-rl;-webkit-transform:rotate(-90deg);-moz-transform:rotate(-90deg);-ms-transform:rotate(-90deg);-o-transform:rotate(-90deg);transform:rotate(-90deg);filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)"}.rmnlQuicktagSettings input[type=text]{height:3.5em;width:99%;margin:0 0 .5em}.rmnlQuicktagSettings textarea{height:3.5em;width:99%;margin:0 0 .2em}
css/settings.dev.css ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * AddQuicktag settings style
3
+ *
4
+ * @package AddQuicktag Plugin
5
+ * @author Frank Bueltge <frank@bueltge.de>
6
+ * @version 03/27/2014
7
+ * @since 2.02.3
8
+ */
9
+
10
+ .rmnlQuicktagSettings .rmnlqsheader {
11
+ height: 10em;
12
+ vertical-align: bottom;
13
+ }
14
+
15
+ .hover, table tr:hover {
16
+ background-color: #ccc;
17
+ }
18
+
19
+ .rmnlQuicktagSettings th {
20
+ vertical-align: bottom !important;
21
+ text-align: center;
22
+ }
23
+
24
+ .rmnlQuicktagSettings .rotate {
25
+ padding: 0 !important;
26
+ margin: 0 auto;
27
+ width: 1.2em;
28
+ vertical-align: bottom !important;
29
+ }
30
+
31
+ .rmnlQuicktagSettings .rotate span {
32
+ display: block;
33
+ padding: 0 !important;
34
+ margin: 0 auto;
35
+ width: 1.2em;
36
+ vertical-align: middle !important;
37
+ white-space: nowrap;
38
+ filter: flipv fliph;
39
+ writing-mode: tb-rl;
40
+ -webkit-transform: rotate(-90deg);
41
+ -moz-transform: rotate(-90deg);
42
+ -ms-transform: rotate(-90deg);
43
+ -o-transform: rotate(-90deg);
44
+ transform: rotate(-90deg);
45
+
46
+ /* Should be unset in IE9+ I think. */
47
+ filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); /* IE6,IE7 */
48
+ -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=3)"; /* IE8 */
49
+ }
50
+
51
+ .rmnlQuicktagSettings input[type='text'] {
52
+ height: 3.5em;
53
+ width: 99%;
54
+ margin: 0 0 .5em 0;
55
+ }
56
+
57
+ .rmnlQuicktagSettings textarea {
58
+ height: 3.5em;
59
+ width: 99%;
60
+ margin: 0 0 .2em 0;
61
+ }
inc/class-code-quicktags.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
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_Code_Quicktags
19
+ */
20
+ class Add_Quicktag_Code_Quicktags extends Add_Quicktag_Settings {
21
+
22
+ /**
23
+ * Post types for the settings
24
+ *
25
+ * @var
26
+ */
27
+ private static $post_types_for_js;
28
+
29
+ /**
30
+ * Static var for textdomain
31
+ *
32
+ * @var string
33
+ */
34
+ public static $textdomain = '';
35
+
36
+ /**
37
+ * Handler for the action 'init'. Instantiates this class.
38
+ *
39
+ * @access public
40
+ * @since 2.0.0
41
+ * @return \Add_Quicktag|\Add_Quicktag_Code_Quicktags|\Add_Quicktag_Settings $instance
42
+ */
43
+ public static function get_object() {
44
+
45
+ static $instance;
46
+
47
+ if ( NULL === $instance ) {
48
+ $instance = new self();
49
+ }
50
+
51
+ return $instance;
52
+ }
53
+
54
+ /**
55
+ * Constructor, init on defined hooks of WP and include second class
56
+ *
57
+ * @access public
58
+ * @since 0.0.2
59
+ * @uses register_activation_hook, register_uninstall_hook, add_action
60
+ * @return \Add_Quicktag_Code_Quicktags
61
+ */
62
+ private function __construct() {
63
+
64
+ self::$textdomain = parent::get_textdomain();
65
+
66
+ add_action( 'addquicktag_settings_form_page', array( $this, 'get_code_quicktag_area' ) );
67
+ }
68
+
69
+ /**
70
+ * Add settings area
71
+ *
72
+ * @param $options
73
+ */
74
+ public function get_code_quicktag_area( $options ) {
75
+
76
+ if ( ! isset( $options['code_buttons'] ) ) {
77
+ $options['code_buttons'] = array();
78
+ }
79
+
80
+ $checked_enhanced_code = $checked_ende_coding = '';
81
+ if ( array_key_exists( 'enhanced_code', $options['code_buttons'] ) ) {
82
+ $checked_enhanced_code = ' checked="checked"';
83
+ }
84
+ if ( array_key_exists( 'ende_coding', $options['code_buttons'] ) ) {
85
+ $checked_ende_coding = ' checked="checked"';
86
+ }
87
+ ?>
88
+ <h3><?php _e( 'Enhanced Code Quicktag buttons', self::$textdomain ); ?></h3>
89
+ <p><?php _e( 'Select the checkbox below to add enhanced code buttons.', $this->get_textdomain() ); ?></p>
90
+
91
+ <table class="widefat">
92
+ <tr>
93
+ <th class="row-title num" style="width:3%;">&#x2714;</th>
94
+ <th class="row-title"><?php _e( 'Button', self::$textdomain ); ?></th>
95
+ </tr>
96
+
97
+ <tr>
98
+ <td class="num">
99
+ <?php echo '<input type="checkbox" name="' . parent::get_option_string()
100
+ . '[code_buttons][enhanced_code]" value="1" '
101
+ . $checked_enhanced_code . ' />';
102
+ ?>
103
+ </td>
104
+ <td>
105
+ <?php _e( 'Enhanced Code buttons.<br />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 ); ?>
106
+ </td>
107
+ <td>
108
+ <tr>
109
+ <td class="num">
110
+ <?php echo '<input type="checkbox" name="' . parent::get_option_string()
111
+ . '[code_buttons][ende_coding]" value="1" '
112
+ . $checked_ende_coding . ' />';
113
+ ?>
114
+ </td>
115
+ <td><?php _e( 'Add buttons to do the inconvient HTML encoding/decoding, like &lt; to &amp;lt; and back.', self::$textdomain ); ?></td>
116
+ </tr>
117
+ </table>
118
+ <?php
119
+ }
120
+
121
+ } // end class
122
+
123
+ $add_quicktag_code_quicktags = Add_Quicktag_Code_Quicktags::get_object();
inc/class-imexport.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * AddQuicktag - Settings
4
- *
5
  * @license GPLv3
6
  * @package AddQuicktag
7
  * @subpackage AddQuicktag Settings
@@ -13,67 +13,82 @@ if ( ! function_exists( 'add_action' ) ) {
13
  exit;
14
  }
15
 
 
 
 
16
  class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
17
-
18
- protected static $classobj = NULL;
19
- // post types for the settings
 
 
 
20
  private static $post_types_for_js;
21
-
22
  /**
23
  * Handler for the action 'init'. Instantiates this class.
24
- *
25
  * @access public
26
  * @since 2.0.0
27
- * @return $classobj
28
  */
29
  public static function get_object() {
30
-
31
- if ( NULL === self :: $classobj ) {
32
- self :: $classobj = new self;
 
 
33
  }
34
-
35
- return self :: $classobj;
36
  }
37
-
38
  /**
39
  * Constructor, init on defined hooks of WP and include second class
40
- *
41
  * @access public
42
  * @since 0.0.2
43
  * @uses register_activation_hook, register_uninstall_hook, add_action
44
- * @return void
45
  */
46
- public function __construct() {
47
-
48
  self::$post_types_for_js = parent::get_post_types_for_js();
49
-
50
- if ( isset( $_GET['addquicktag_download'] ) && check_admin_referer( parent :: $nonce_string ) )
51
  $this->get_export_file();
52
- //add_action( 'init', array( $this, 'get_export_file' ) );
53
-
54
- if ( isset( $_POST['addquicktag_import'] ) && check_admin_referer( parent :: $nonce_string ) )
 
55
  $this->import_file();
56
- //add_action( 'init', array( $this, 'import_file' ) );
57
-
 
58
  add_action( 'addquicktag_settings_page', array( $this, 'get_im_export_part' ) );
59
  }
60
-
61
  /**
62
  * get markup for ex- and import on settings page
63
- *
64
  * @access public
65
  * @since 2.0.0
66
  * @uses wp_nonce_field
67
  * @return string
68
  */
69
  public function get_im_export_part() {
 
70
  ?>
71
  <div class="postbox">
72
  <h3><span><?php _e( 'Export', parent :: get_textdomain() ); ?></span></h3>
 
73
  <div class="inside">
74
  <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>
 
75
  <p><?php _e( 'This format, a custom XML, will contain your options from quicktags.', parent :: get_textdomain() ); ?></p>
 
76
  <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>
 
77
  <form method="get" action="">
78
  <?php wp_nonce_field( parent :: $nonce_string ); ?>
79
  <p class="submit">
@@ -83,11 +98,13 @@ class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
83
  </form>
84
  </div>
85
  </div>
86
-
87
  <div class="postbox">
88
  <h3><span><?php _e( 'Import', parent :: get_textdomain() ); ?></span></h3>
 
89
  <div class="inside">
90
  <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.', parent :: get_textdomain() ); ?></p>
 
91
  <form method="post" action="" enctype="multipart/form-data">
92
  <?php wp_nonce_field( parent :: $nonce_string ); ?>
93
  <p class="submit">
@@ -98,9 +115,9 @@ class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
98
  </form>
99
  </div>
100
  </div>
101
- <?php
102
  }
103
-
104
  /*
105
  * Build export file, xml
106
  *
@@ -110,23 +127,20 @@ class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
110
  * @return string $xml
111
  */
112
  public function get_export_file() {
113
-
114
- if ( is_multisite() && is_plugin_active_for_network( parent :: get_plugin_string() ) )
115
- $options = get_site_option( parent :: get_option_string() );
116
- else
117
- $options = get_option( parent :: get_option_string() );
118
-
119
  if ( $options['buttons'] ) {
120
-
121
- $xml = '<?xml version="1.0" encoding="UTF-8"?>';
122
  $xml .= "\n" . '<buttons>' . "\n";
123
-
124
- for ( $i = 0; $i < count( $options['buttons'] ); $i++ ) {
125
  $xml .= "\t" . '<quicktag>' . "\n";
126
- foreach( $options['buttons'][$i] as $name => $value ) {
127
-
128
  $value = stripslashes( $value );
129
-
130
  if ( empty( $value ) ) {
131
  $xml .= "\t\t" . '<' . $name . '/>' . "\n";
132
  } elseif ( preg_match( '/^[0-9]*$/', $value ) ) {
@@ -138,80 +152,91 @@ class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
138
  $xml .= "\t" . '</quicktag>' . "\n";
139
  }
140
  $xml .= '</buttons>';
141
-
142
  } else {
143
  $xml = 'We dont find settings in database';
144
  }
145
-
146
- $filename = urlencode( 'addquicktag.' . date('Y-m-d') . '.xml' );
147
  $filesize = strlen( $xml );
148
-
149
- $this -> export_xml( $filename, $filesize, $filetype = 'text/xml' );
150
  echo $xml;
151
  exit;
152
  }
153
-
154
  /**
155
  * Create download file
156
- *
157
  * @access public
158
  * @since 2.0.0
 
159
  * @param string $filename
160
  * @param string $filesize
161
  * @param string $filetype
 
162
  * @uses get_option
163
  * @return void
164
  */
165
  public function export_xml( $filename, $filesize, $filetype ) {
166
-
167
  header( 'Content-Description: File Transfer' );
168
  header( 'Content-Disposition: attachment; filename=' . $filename );
169
  header( 'Content-Length: ' . $filesize );
170
- header( 'Content-type: ' . $filetype . '; charset=' . get_option('blog_charset'), TRUE );
171
  flush();
172
  }
173
-
174
  /**
175
  * Import XML and update settings
176
- *
177
  * @access public
178
  * @since 2.0.0
179
- * @param string $filename
 
 
180
  * @uses current_user_can, wp_die, is_plugin_active_for_network, update_site_option, update_option
181
  * @return void
182
  */
183
  public function import_file( $filename = FALSE ) {
184
-
185
- if ( ! current_user_can( 'manage_options' ) )
186
- wp_die( __('Options not update - you don&lsquo;t have the privilidges to do this!', parent :: get_textdomain() ) );
187
-
 
188
  // use tmp file
189
- if ( ! $filename )
190
  $filename = $_FILES['xml']['tmp_name'];
191
-
 
192
  $filename = preg_replace( "/\<\!\[CDATA\[(.*?)\]\]\>/ies", "'[CDATA]' . base64_encode('$1') . '[/CDATA]'", $filename );
193
  $filename = utf8_encode( $filename );
194
  $matches = simplexml_load_file( $filename );
195
-
 
196
  // create array from xml
197
  $button = array();
198
- foreach ( $matches -> quicktag as $key ) {
199
- foreach ($key as $value) {
200
- $buttons[$value -> getName()] = $value;
 
 
 
 
 
201
  }
 
202
  $button[] = $buttons;
203
  }
204
  $options['buttons'] = $button;
 
205
  // validate the values from xml
206
- $options = parent :: validate_settings($options);
207
-
208
  // update settings in database
209
- if ( is_multisite() && is_plugin_active_for_network( parent :: get_plugin_string() ) )
210
- update_site_option( parent :: get_option_string(), $options );
211
- else
212
- update_option( parent :: get_option_string(), $options );
213
  }
214
-
215
  } // end class
216
 
217
- $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
13
  exit;
14
  }
15
 
16
+ /**
17
+ * Class Add_Quicktag_Im_Export
18
+ */
19
  class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
20
+
21
+ /**
22
+ * Post types for the settings
23
+ *
24
+ * @var Array
25
+ */
26
  private static $post_types_for_js;
27
+
28
  /**
29
  * Handler for the action 'init'. Instantiates this class.
30
+ *
31
  * @access public
32
  * @since 2.0.0
33
+ * @return \Add_Quicktag|\Add_Quicktag_Im_Export|\Add_Quicktag_Settings $instance
34
  */
35
  public static function get_object() {
36
+
37
+ static $instance;
38
+
39
+ if ( NULL === $instance ) {
40
+ $instance = new self();
41
  }
42
+
43
+ return $instance;
44
  }
45
+
46
  /**
47
  * Constructor, init on defined hooks of WP and include second class
48
+ *
49
  * @access public
50
  * @since 0.0.2
51
  * @uses register_activation_hook, register_uninstall_hook, add_action
52
+ * @return \Add_Quicktag_Im_Export
53
  */
54
+ private function __construct() {
55
+
56
  self::$post_types_for_js = parent::get_post_types_for_js();
57
+
58
+ if ( isset( $_GET['addquicktag_download'] ) && check_admin_referer( parent :: $nonce_string ) ) {
59
  $this->get_export_file();
60
+ }
61
+ //add_action( 'init', array( $this, 'get_export_file' ) );
62
+
63
+ if ( isset( $_POST['addquicktag_import'] ) && check_admin_referer( parent :: $nonce_string ) ) {
64
  $this->import_file();
65
+ }
66
+ //add_action( 'init', array( $this, 'import_file' ) );
67
+
68
  add_action( 'addquicktag_settings_page', array( $this, 'get_im_export_part' ) );
69
  }
70
+
71
  /**
72
  * get markup for ex- and import on settings page
73
+ *
74
  * @access public
75
  * @since 2.0.0
76
  * @uses wp_nonce_field
77
  * @return string
78
  */
79
  public function get_im_export_part() {
80
+
81
  ?>
82
  <div class="postbox">
83
  <h3><span><?php _e( 'Export', parent :: get_textdomain() ); ?></span></h3>
84
+
85
  <div class="inside">
86
  <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>
87
+
88
  <p><?php _e( 'This format, a custom XML, will contain your options from quicktags.', parent :: get_textdomain() ); ?></p>
89
+
90
  <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>
91
+
92
  <form method="get" action="">
93
  <?php wp_nonce_field( parent :: $nonce_string ); ?>
94
  <p class="submit">
98
  </form>
99
  </div>
100
  </div>
101
+
102
  <div class="postbox">
103
  <h3><span><?php _e( 'Import', parent :: get_textdomain() ); ?></span></h3>
104
+
105
  <div class="inside">
106
  <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.', parent :: get_textdomain() ); ?></p>
107
+
108
  <form method="post" action="" enctype="multipart/form-data">
109
  <?php wp_nonce_field( parent :: $nonce_string ); ?>
110
  <p class="submit">
115
  </form>
116
  </div>
117
  </div>
118
+ <?php
119
  }
120
+
121
  /*
122
  * Build export file, xml
123
  *
127
  * @return string $xml
128
  */
129
  public function get_export_file() {
130
+
131
+ $options = get_site_option( parent :: get_option_string() );
132
+
 
 
 
133
  if ( $options['buttons'] ) {
134
+
135
+ $xml = '<?xml version="1.0" encoding="UTF-8"?>';
136
  $xml .= "\n" . '<buttons>' . "\n";
137
+
138
+ for( $i = 0; $i < count( $options['buttons'] ); $i ++ ) {
139
  $xml .= "\t" . '<quicktag>' . "\n";
140
+ foreach( $options['buttons'][ $i ] as $name => $value ) {
141
+
142
  $value = stripslashes( $value );
143
+
144
  if ( empty( $value ) ) {
145
  $xml .= "\t\t" . '<' . $name . '/>' . "\n";
146
  } elseif ( preg_match( '/^[0-9]*$/', $value ) ) {
152
  $xml .= "\t" . '</quicktag>' . "\n";
153
  }
154
  $xml .= '</buttons>';
155
+
156
  } else {
157
  $xml = 'We dont find settings in database';
158
  }
159
+
160
+ $filename = urlencode( 'addquicktag.' . date( 'Y-m-d' ) . '.xml' );
161
  $filesize = strlen( $xml );
162
+
163
+ $this ->export_xml( $filename, $filesize, $filetype = 'text/xml' );
164
  echo $xml;
165
  exit;
166
  }
167
+
168
  /**
169
  * Create download file
170
+ *
171
  * @access public
172
  * @since 2.0.0
173
+ *
174
  * @param string $filename
175
  * @param string $filesize
176
  * @param string $filetype
177
+ *
178
  * @uses get_option
179
  * @return void
180
  */
181
  public function export_xml( $filename, $filesize, $filetype ) {
182
+
183
  header( 'Content-Description: File Transfer' );
184
  header( 'Content-Disposition: attachment; filename=' . $filename );
185
  header( 'Content-Length: ' . $filesize );
186
+ header( 'Content-type: ' . $filetype . '; charset=' . get_option( 'blog_charset' ), TRUE );
187
  flush();
188
  }
189
+
190
  /**
191
  * Import XML and update settings
192
+ *
193
  * @access public
194
  * @since 2.0.0
195
+ *
196
+ * @param bool|string $filename
197
+ *
198
  * @uses current_user_can, wp_die, is_plugin_active_for_network, update_site_option, update_option
199
  * @return void
200
  */
201
  public function import_file( $filename = FALSE ) {
202
+
203
+ if ( ! current_user_can( 'manage_options' ) ) {
204
+ wp_die( __( 'Options not update - you don&lsquo;t have the privilidges to do this!', parent::get_textdomain() ) );
205
+ }
206
+
207
  // use tmp file
208
+ if ( ! $filename ) {
209
  $filename = $_FILES['xml']['tmp_name'];
210
+ }
211
+
212
  $filename = preg_replace( "/\<\!\[CDATA\[(.*?)\]\]\>/ies", "'[CDATA]' . base64_encode('$1') . '[/CDATA]'", $filename );
213
  $filename = utf8_encode( $filename );
214
  $matches = simplexml_load_file( $filename );
215
+
216
+ $buttons = '';
217
  // create array from xml
218
  $button = array();
219
+ /**
220
+ * @var $matches stdClass
221
+ */
222
+ foreach( $matches->quicktag as $key ) {
223
+
224
+ foreach( $key as $value ) {
225
+ /* @var $value stdClass */
226
+ $buttons[ $value->getName() ] = $value;
227
  }
228
+
229
  $button[] = $buttons;
230
  }
231
  $options['buttons'] = $button;
232
+
233
  // validate the values from xml
234
+ $options = parent::validate_settings( $options );
235
+
236
  // update settings in database
237
+ update_site_option( parent::get_option_string(), $options );
 
 
 
238
  }
239
+
240
  } // end class
241
 
242
+ $add_quicktag_im_export = Add_Quicktag_Im_Export::get_object();
inc/class-remove-quicktags.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 05/22/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
+ class Add_Quicktag_Remove_Quicktags extends Add_Quicktag_Settings {
17
+
18
+ // post types for the settings
19
+ private static $post_types_for_js;
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
+ // Transient string
25
+ private static $addquicktag_core_quicktags = 'addquicktag_core_quicktags';
26
+
27
+ /**
28
+ * Handler for the action 'init'. Instantiates this class.
29
+ *
30
+ * @access public
31
+ * @since 2.0.0
32
+ * @return \Add_Quicktag|\Add_Quicktag_Remove_Quicktags|\Add_Quicktag_Settings $instance
33
+ */
34
+ public static function get_object() {
35
+
36
+ static $instance;
37
+
38
+ if ( NULL === $instance ) {
39
+ $instance = new self();
40
+ }
41
+
42
+ return $instance;
43
+ }
44
+
45
+ /**
46
+ * Constructor, init on defined hooks of WP and include second class
47
+ *
48
+ * @access public
49
+ * @since 0.0.2
50
+ * @uses register_activation_hook, register_uninstall_hook, add_action
51
+ * @return \Add_Quicktag_Remove_Quicktags
52
+ */
53
+ private function __construct() {
54
+
55
+ add_action( 'addquicktag_settings_form_page', array( $this, 'get_remove_quicktag_area' ) );
56
+ }
57
+
58
+ /**
59
+ * Add settings area
60
+ *
61
+ * @param $options
62
+ */
63
+ public function get_remove_quicktag_area( $options ) {
64
+
65
+ if ( ! isset( $options['core_buttons'] ) ) {
66
+ $options['core_buttons'] = array();
67
+ }
68
+ ?>
69
+ <h3><?php _e( 'Remove Core Quicktag buttons', parent::get_textdomain() ); ?></h3>
70
+ <p><?php _e( 'Select the checkbox below to remove a core quicktags in all editors.', $this->get_textdomain() ); ?></p>
71
+ <p><?php _e( '<strong>Currently a Beta option</strong>, to validate and only usable global on each post type. Please give me hints, feedback via the support possibilities, like <a href="https://github.com/bueltge/AddQuicktag/issues">Github Issues</a> or <a href="http://wordpress.org/support/plugin/addquicktag">WP Support Forum</a>.', $this->get_textdomain() ); ?></p>
72
+
73
+ <table class="widefat">
74
+ <tr>
75
+ <th class="row-title num" style="width:3%;">&#x2714;</th>
76
+ <th class="row-title"><?php _e( 'Button', parent::get_textdomain() ); ?></th>
77
+ </tr>
78
+
79
+ <?php
80
+ // Convert string to array
81
+ $core_buttons = explode( ',', self::$core_quicktags );
82
+ // Loop over items to remove and unset them from the buttons
83
+ foreach( $core_buttons as $key => $value ) {
84
+
85
+ if ( array_key_exists( $value, $options['core_buttons'] ) ) {
86
+ $checked = ' checked="checked"';
87
+ } else {
88
+ $checked = '';
89
+ }
90
+
91
+ // same style as in editor
92
+ if ( 'strong' === $value ) {
93
+ $text = 'b';
94
+ $style = ' style="font-weight: bold;"';
95
+ } else if ( 'em' === $value ) {
96
+ $text = 'i';
97
+ $style = ' style="font-style: italic;"';
98
+ } else if ( 'link' === $value ) {
99
+ $text = $value;
100
+ $style = ' style="text-decoration: underline;"';
101
+ } else if ( 'del' === $value ) {
102
+ $text = $value;
103
+ $style = ' style="text-decoration: line-through;"';
104
+ } else if ( 'block' === $value ) {
105
+ $text = 'b-quote';
106
+ $style = '';
107
+ } else {
108
+ $text = $value;
109
+ $style = '';
110
+ }
111
+
112
+ echo '<tr><td class="num"><input type="checkbox" name="' . parent :: get_option_string()
113
+ . '[core_buttons][' . $value . ']" value="1" '
114
+ . $checked . ' /></td><td>';
115
+ echo '<input type="button" class="ed_button" title="" value="' . $text . '"' . $style . '> <code>' . $value . '</code></td></tr>';
116
+ }
117
+
118
+ // Convert new buttons array back into a comma-separated string
119
+ $core_qt = implode( ',', $core_buttons );
120
+ ?>
121
+ </table>
122
+ <?php
123
+ }
124
+
125
+ } // end class
126
+
127
+ $add_quicktag_remove_quicktags = Add_Quicktag_Remove_Quicktags::get_object();
inc/class-settings.php CHANGED
@@ -1,12 +1,11 @@
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 02/09/2013
10
  * @since 2.0.0
11
  */
12
 
@@ -16,162 +15,199 @@ if ( ! function_exists( 'add_action' ) ) {
16
  }
17
 
18
  class Add_Quicktag_Settings extends Add_Quicktag {
19
-
20
- protected static $classobj = NULL;
21
- // string for translation
22
- static public $textdomain;
23
- // string for options in table options
24
- static private $option_string;
25
- // string for plugin file
26
- static private $plugin;
27
- // post types for the settings
28
- static private $post_types_for_js;
29
- // string for nonce fields
30
- static public $nonce_string;
31
-
32
- protected $page_hook;
33
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  /**
35
  * Handler for the action 'init'. Instantiates this class.
36
- *
37
  * @access public
38
  * @since 2.0.0
39
- * @return $classobj
40
  */
41
  public static function get_object() {
42
-
43
- if ( NULL === self :: $classobj ) {
44
- self :: $classobj = new self;
 
 
45
  }
46
-
47
- return self :: $classobj;
48
  }
49
-
50
  /**
51
  * Constructor, init on defined hooks of WP and include second class
52
- *
53
  * @access public
54
  * @since 0.0.2
55
  * @uses register_activation_hook, register_uninstall_hook, add_action
56
- * @return void
57
  */
58
- public function __construct() {
59
-
60
- if ( ! is_admin() )
61
  return NULL;
62
-
 
63
  // textdomain from parent class
64
  self::$textdomain = parent::get_textdomain();
65
  self::$option_string = parent::get_option_string();
66
  self::$plugin = parent::get_plugin_string();
67
  self::$post_types_for_js = parent::get_post_types_for_js();
68
  self::$nonce_string = 'addquicktag_nonce';
69
-
70
- register_uninstall_hook( __FILE__, array( 'Add_Quicktag_Settings', 'unregister_settings' ) );
71
  // settings for an active multisite
72
  if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
73
- add_action( 'network_admin_menu', array( $this, 'add_settings_page' ) );
74
  // add settings link
75
- add_filter( 'network_admin_plugin_action_links', array( $this, 'network_admin_plugin_action_links' ), 10, 2 );
 
 
 
 
 
76
  // save settings on network
77
  add_action( 'network_admin_edit_' . self::$option_string, array( $this, 'save_network_settings_page' ) );
78
  // return message for update settings
79
  add_action( 'network_admin_notices', array( $this, 'get_network_admin_notices' ) );
80
  // add script on settings page
81
  } else {
82
- add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
83
  // add settings link
84
- add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 );
85
  // use settings API
86
- add_action( 'admin_init', array( $this, 'register_settings' ) );
87
  }
88
  // include js
89
- add_action( 'admin_print_scripts-settings_page_' . str_replace( '.php', '', plugin_basename( __FILE__ ) ),
 
90
  array( $this, 'print_scripts' )
91
  );
92
-
93
  // add meta boxes on settings pages
94
  add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_plugin_infos' ) );
95
  add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_about_plugin' ) );
 
 
 
 
 
 
96
  // include class for im/export
97
  require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-imexport.php';
98
  }
99
-
100
  /**
101
- * Retrun allowed post types for include scripts
102
- *
103
  * @since 2.1.1
104
  * @access public
105
  * @return Array
106
  */
107
  public function get_post_types_for_js() {
108
-
109
  return self::$post_types_for_js;
110
  }
111
-
112
  /**
113
  * Return Textdomain string
114
- *
115
  * @access public
116
  * @since 2.0.0
117
  * @return string
118
  */
119
  public function get_textdomain() {
120
-
121
- return self :: $textdomain;
122
  }
123
-
124
  /**
125
  * Add settings link on plugins.php in backend
126
- *
127
- * @uses
128
- * @access public
129
- * @param array $links, string $file
130
- * @since 2.0.0
131
- * @return string $links
 
 
132
  */
133
  public function plugin_action_links( $links, $file ) {
134
-
135
- if ( parent :: get_plugin_string() == $file )
136
- $links[] = '<a href="options-general.php?page=' . plugin_basename( __FILE__ ) . '">' . __('Settings') . '</a>';
137
-
 
138
  return $links;
139
  }
140
-
141
  /**
142
  * Add settings link on plugins.php on network admin in backend
143
- *
144
- * @uses
145
  * @access public
146
- * @param array $links, string $file
147
  * @since 2.0.0
 
 
 
 
148
  * @return string $links
149
  */
150
  public function network_admin_plugin_action_links( $links, $file ) {
151
-
152
- if ( parent :: get_plugin_string() == $file )
153
- $links[] = '<a href="settings.php?page=' . plugin_basename( __FILE__ ) . '">' . __('Settings') . '</a>';
154
-
 
155
  return $links;
156
  }
157
-
158
  /**
159
  * Add settings page in WP backend
160
- *
161
  * @uses add_options_page
162
  * @access public
163
  * @since 2.0.0
164
  * @return void
165
  */
166
- public function add_settings_page () {
167
-
168
  if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
169
  add_submenu_page(
170
  'settings.php',
171
  parent :: get_plugin_data( 'Name' ) . ' ' . __( 'Settings', $this->get_textdomain() ),
172
  parent :: get_plugin_data( 'Name' ),
173
  'manage_options',
174
- plugin_basename(__FILE__),
175
  array( $this, 'get_settings_page' )
176
  );
177
  } else {
@@ -179,208 +215,246 @@ class Add_Quicktag_Settings extends Add_Quicktag {
179
  parent :: get_plugin_data( 'Name' ) . ' ' . __( 'Settings', $this->get_textdomain() ),
180
  parent :: get_plugin_data( 'Name' ),
181
  'manage_options',
182
- plugin_basename(__FILE__),
183
  array( $this, 'get_settings_page' )
184
  );
185
  add_action( 'contextual_help', array( $this, 'contextual_help' ), 10, 3 );
186
  }
187
  }
188
-
189
  /**
190
  * Return form and markup on settings page
191
- *
192
- * @uses settings_fields, normalize_whitespace, is_plugin_active_for_network, get_site_option, get_option
193
- * @access public
194
- * @since 0.0.2
195
  * @return void
196
  */
197
  public function get_settings_page() {
198
-
199
  ?>
200
  <div class="wrap">
201
- <?php screen_icon('options-general'); ?>
202
- <h2><?php echo parent :: get_plugin_data( 'Name' ); ?></h2>
203
-
204
- <h3><?php _e('Add or delete Quicktag buttons', $this->get_textdomain() ); ?></h3>
 
 
 
 
 
 
 
 
 
 
205
  <?php
206
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) )
207
- $action = 'edit.php?action=' . self::$option_string;
208
- else
209
- $action = 'options.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  ?>
211
- <form method="post" action="<?php echo $action; ?>">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  <?php
213
- if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
214
- wp_nonce_field( self::$nonce_string );
215
- $options = get_site_option( self::$option_string );
216
- } else {
217
- settings_fields( self::$option_string . '_group' );
218
- $options = get_option( self::$option_string );
219
  }
220
-
221
- if ( ! $options )
222
- $options['buttons'] = array();
223
-
224
- if ( 1 < count($options['buttons']) ) {
225
- // sort array by order value
226
- $tmp = array();
227
- foreach( $options['buttons'] as $order ) {
228
- if ( isset( $order['order'] ) )
229
- $tmp[] = $order['order'];
230
- else
231
- $tmp[] = 0;
232
  }
233
- array_multisort( $tmp, SORT_ASC, $options['buttons'] );
234
- }
235
-
236
- // loop about the post types, create html an values for title in table
237
- $pt_title = '';
238
- foreach ( $this->get_post_types_for_js() as $post_type ) {
239
-
240
- $pt_title .= '<th class="row-title" title="Post Type"><code>' . $post_type . '</code></th>' . "\n";
241
- }
242
- ?>
243
-
244
- <table class="widefat">
245
- <tr>
246
- <th class="row-title"><?php _e( 'Button Label*', $this->get_textdomain() ); ?></th>
247
- <th class="row-title"><?php _e( 'Title Attribute', $this->get_textdomain() ); ?></th>
248
- <th class="row-title"><?php _e( 'Start Tag(s)*', $this->get_textdomain() ); ?></th>
249
- <th class="row-title"><?php _e( 'End Tag(s)', $this->get_textdomain() ); ?></th>
250
- <th class="row-title"><?php _e( 'Access Key', $this->get_textdomain() ); ?></th>
251
- <th class="row-title"><?php _e( 'Order', $this->get_textdomain() ); ?></th>
252
- <th class="row-title"><?php _e( 'Visual', $this->get_textdomain() ); ?></th>
253
- <?php echo $pt_title ?>
254
- <th class="row-title">&#x2714;</th>
255
- </tr>
256
- <?php
257
- if ( empty($options['buttons']) )
258
- $options['buttons'] = array();
259
- $class = '';
260
- for ( $i = 0; $i < count( $options['buttons'] ); $i++ ) {
261
- $class = ( ' class="alternate"' == $class ) ? '' : ' class="alternate"';
262
- $b = $options['buttons'][$i];
263
- $b['text'] = htmlentities( stripslashes($b['text']), ENT_COMPAT, get_option('blog_charset') );
264
- if ( isset( $b['title'] ) )
265
- $b['title'] = htmlentities( stripslashes($b['title']), ENT_COMPAT, get_option('blog_charset') );
266
- $b['start'] = htmlentities( $b['start'], ENT_COMPAT, get_option('blog_charset') );
267
- if ( isset( $b['end'] ) )
268
- $b['end'] = htmlentities( $b['end'], ENT_COMPAT, get_option('blog_charset') );
269
- if ( ! isset( $b['access'] ) )
270
- $b['access'] = '';
271
- $b['access'] = htmlentities( $b['access'], ENT_COMPAT, get_option('blog_charset') );
272
- if ( ! isset( $b['order'] ) )
273
- $b['order'] = 0;
274
- $b['order'] = intval( $b['order'] );
275
- if ( ! isset( $b['visual'] ) )
276
- $b['visual'] = 0;
277
- $b['visual'] = intval( $b['visual'] );
278
- if ( 1 == $b['visual'] )
279
- $checked = ' checked="checked"';
280
- else
281
- $checked = '';
282
- // loop about the post types, create html an values
283
- $pt_checkboxes = '';
284
- foreach ( $this->get_post_types_for_js() as $post_type ) {
285
-
286
- if ( ! isset( $b[$post_type] ) )
287
- $b[$post_type] = 0;
288
-
289
- $b[$post_type] = intval( $b[$post_type] );
290
-
291
- if ( 1 == $b[$post_type] )
292
- $pt_checked = ' checked="checked"';
293
- else
294
- $pt_checked = '';
295
-
296
- $pt_checkboxes .= '<td><input type="checkbox" name="' .
297
- self::$option_string . '[buttons][' .
298
- $i . '][' . $post_type . ']" value="1"' .
299
- $pt_checked . '/></td>' . "\n";
300
  }
301
-
302
- $nr = $i + 1;
303
-
 
 
 
 
 
 
 
 
 
 
 
 
304
  echo '
305
  <tr id="rmqtb' . $i . '">
306
- <td><input type="text" name="' . self::$option_string . '[buttons][' . $i
307
- . '][text]" value="' . $b['text'] . '" style="width: 95%;" /></td>
308
- <td><input type="text" name="' . self::$option_string . '[buttons][' . $i . '][title]" value="'
309
- . $b['title'] . '" style="width: 95%;" /></td>
310
- <td><textarea class="code" name="' . self::$option_string . '[buttons][' . $i
311
- . '][start]" rows="2" cols="25" style="width: 95%;">' . $b['start'] . '</textarea></td>
312
- <td><textarea class="code" name="' . self::$option_string . '[buttons][' . $i
313
- . '][end]" rows="2" cols="25" style="width: 95%;">' . $b['end'] . '</textarea></td>
314
- <td><input type="text" name="' . self::$option_string . '[buttons][' . $i
315
- . '][access]" value="' . $b['access'] . '" style="width: 95%;" /></td>
316
- <td><input type="text" name="' . self::$option_string . '[buttons][' . $i
317
- . '][order]" value="' . $b['order'] . '" style="width: 95%;" /></td>
318
- <td><input type="checkbox" name="' . self::$option_string . '[buttons][' . $i
319
- . '][visual]" value="1"' . $checked . '/></td>' .
320
- $pt_checkboxes . '
321
- <td><input type="checkbox" class="toggle" id="select_all_' . $i . '" value="'. $i . '" /></td>' . '
322
  </tr>
323
  ';
 
 
 
 
 
 
 
324
  }
325
-
326
- // loop about the post types, create html an values for empty new checkboxes
327
- $pt_new_boxes = '';
328
- foreach ( $this->get_post_types_for_js() as $post_type ) {
329
- if ( ! isset( $b[$post_type] ) )
330
- $b[$post_type] = 0;
331
-
332
- $b[$post_type] = intval( $b[$post_type] );
333
-
334
- if ( 1 == $b[$post_type] )
335
- $pt_checked = ' checked="checked"';
336
- else
337
- $pt_checked = '';
338
-
339
- $pt_new_boxes .= '<td><input type="checkbox" name="' .
340
- self::$option_string . '[buttons][' .
341
- $i . '][' . $post_type . ']" value="1" /></td>' . "\n";
342
  }
343
- ?>
344
- <tr id="rmqtb<?php echo $i ?>">
345
- <td><input type="text" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][text]" value="" style="width: 95%;" /></td>
346
- <td><input type="text" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][title]" value="" style="width: 95%;" /></td>
347
- <td><textarea class="code" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][start]" rows="2" cols="25" style="width: 95%;"></textarea></td>
348
- <td><textarea class="code" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][end]" rows="2" cols="25" style="width: 95%;"></textarea></td>
349
- <td><input type="text" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][access]" value="" class="code" style="width: 95%;" /></td>
350
- <td><input type="text" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][order]" value="" style="width: 95%;" /></td>
351
- <td><input type="checkbox" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][visual]" value="1" /></td>
352
- <?php echo $pt_new_boxes; ?>
353
- <td><input type="checkbox" class="toggle" id="select_all_<?php echo $i ?>" value="<?php echo $i ?>" /></td>
354
- </tr>
355
- </table>
356
-
357
- <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>
358
- <p class="submit">
359
- <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
360
- </p>
361
-
362
- </form>
363
-
364
- <div class="metabox-holder has-right-sidebar">
365
-
366
- <div class="inner-sidebar">
367
- <?php do_action( 'addquicktag_settings_page_sidebar' ); ?>
368
- </div> <!-- .inner-sidebar -->
369
-
370
- <div id="post-body">
371
- <div id="post-body-content">
372
- <?php do_action( 'addquicktag_settings_page' ); ?>
373
- </div> <!-- #post-body-content -->
374
- </div> <!-- #post-body -->
375
-
376
- </div> <!-- .metabox-holder -->
377
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
378
  </div>
379
- <?php
 
 
 
380
  }
381
-
382
  /*
383
- * Return informations to donate
384
  *
385
  * @uses _e,esc_attr_e
386
  * @access public
@@ -388,23 +462,36 @@ class Add_Quicktag_Settings extends Add_Quicktag {
388
  * @return void
389
  */
390
  public function get_plugin_infos() {
 
391
  ?>
392
  <div class="postbox">
393
-
394
  <h3><span><?php _e( 'Like this plugin?', $this->get_textdomain() ); ?></span></h3>
 
395
  <div class="inside">
396
  <p><?php _e( 'Here\'s how you can give back:', $this->get_textdomain() ); ?></p>
397
  <ul>
398
- <li><a href="http://wordpress.org/extend/plugins/addquicktag/" title="<?php esc_attr_e( 'The Plugin on the WordPress plugin repository', $this->get_textdomain() ); ?>"><?php _e( 'Give the plugin a good rating.', $this->get_textdomain() ); ?></a></li>
399
- <li><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 _e( 'Donate a few euros.', $this->get_textdomain() ); ?></a></li>
400
- <li><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 _e( 'Get me something from my wish list.', $this->get_textdomain() ); ?></a></li>
401
- <li><a href="https://github.com/bueltge/AddQuicktag" title="<?php _e( 'Please give me feedback, contribute and file technical bugs on this GitHub Repo, use Issues.', $this->get_textdomain() ); ?>"><?php _e( 'Github Repo for Contribute, Issues & Bugs', $this->get_textdomain() ); ?></a></li>
 
 
 
 
 
 
 
 
 
 
 
402
  </ul>
403
  </div>
404
  </div>
405
- <?php
406
  }
407
-
408
  /*
409
  * Return informations about the plugin
410
  *
@@ -414,25 +501,28 @@ class Add_Quicktag_Settings extends Add_Quicktag {
414
  * @return void
415
  */
416
  public function get_about_plugin() {
 
417
  ?>
418
  <div class="postbox">
419
-
420
  <h3><span><?php _e( 'About this plugin', $this->get_textdomain() ); ?></span></h3>
 
421
  <div class="inside">
422
  <p>
423
  <strong><?php _e( 'Version:', $this->get_textdomain() ); ?></strong>
424
  <?php echo parent :: get_plugin_data( 'Version' ); ?>
425
  </p>
 
426
  <p>
427
  <strong><?php _e( 'Description:', $this->get_textdomain() ); ?></strong>
428
  <?php echo parent :: get_plugin_data( 'Description' ); ?>
429
  </p>
430
  </div>
431
-
432
  </div>
433
- <?php
434
  }
435
-
436
  /*
437
  * Save network settings
438
  *
@@ -442,13 +532,14 @@ class Add_Quicktag_Settings extends Add_Quicktag {
442
  * @return void
443
  */
444
  public function save_network_settings_page() {
445
-
446
- if ( ! wp_verify_nonce( $_REQUEST[ '_wpnonce' ], self::$nonce_string ) )
447
  wp_die( 'Sorry, you failed the nonce test.' );
448
-
 
449
  // validate options
450
- $value = $this->validate_settings( $_POST[self::$option_string] );
451
-
452
  // update options
453
  update_site_option( self::$option_string, $value );
454
  // redirect to settings page in network
@@ -460,7 +551,7 @@ class Add_Quicktag_Settings extends Add_Quicktag {
460
  );
461
  exit();
462
  }
463
-
464
  /*
465
  * Retrun string vor update message
466
  *
@@ -470,143 +561,215 @@ class Add_Quicktag_Settings extends Add_Quicktag {
470
  * @return string $notice
471
  */
472
  public function get_network_admin_notices() {
473
-
474
  // if updated and the right page
475
- if ( isset( $_GET['updated'] ) &&
476
- 'settings_page_addquicktag/inc/class-settings-network' === $GLOBALS['current_screen'] -> id
477
- ) {
478
  $message = __( 'Options saved.', $this->get_textdomain() );
479
- $notice = '<div id="message" class="updated"><p>' .$message . '</p></div>';
480
  echo $notice;
481
  }
482
  }
483
-
484
  /**
485
  * Validate settings for options
486
- *
487
  * @uses normalize_whitespace
488
  * @access public
 
489
  * @param array $value
 
490
  * @since 2.0.0
491
  * @return string $value
492
  */
493
  public function validate_settings( $value ) {
494
-
495
- // set allowd values for import, only the defaults of plugin and custom post types
 
 
 
 
 
 
 
 
 
 
496
  $allowed_settings = (array) array_merge(
497
  $this->get_post_types_for_js(),
498
  array( 'text', 'title', 'start', 'end', 'access', 'order', 'visual' )
499
  );
 
 
500
  // filter for allowed values
501
- foreach ( $value['buttons'] as $key => $button ) {
502
-
503
- foreach ($button as $key => $val) {
504
-
505
- if ( ! in_array( $key, $allowed_settings) )
506
- unset( $button[$key] );
 
507
  }
508
- $buttons[] = $button;
 
509
  }
 
510
  // return filtered array
511
- $filtered_values['buttons'] = $buttons;
512
- $value = $filtered_values;
513
-
514
  $buttons = array();
515
- for ( $i = 0; $i < count( $value['buttons']); $i++ ) {
516
-
517
- $b = $value['buttons'][$i];
518
- if ($b['text'] != '' && $b['start'] != '') {
519
- $b['text'] = esc_html( $b['text'] );
520
- $b['title'] = esc_html( $b['title'] );
521
- $b['start'] = stripslashes( $b['start'] );
522
- $b['end'] = stripslashes( $b['end'] );
523
- if ( isset( $b['access'] ) )
524
- $b['access'] = esc_html( $b['access'] );
525
- if ( isset( $b['order'] ) )
526
- $b['order'] = intval( $b['order'] );
527
- // visual settings
528
- if ( isset( $b['visual'] ) )
529
- $b['visual'] = intval( $b['visual'] );
530
- else
531
- $b['visual'] = 0;
532
- // post types
533
- foreach ( $this->get_post_types_for_js() as $post_type ) {
534
- if ( isset( $b[$post_type] ) )
535
- $b[$post_type] = intval( $b[$post_type] );
536
- else
537
- $b[$post_type] = 0;
 
 
 
 
 
 
 
 
 
538
  }
539
-
540
- $buttons[] = $b;
541
  }
542
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
543
  }
544
- $value['buttons'] = $buttons;
545
-
546
  return $value;
547
  }
548
-
549
  /**
550
  * Register settings for options
551
- *
552
  * @uses register_setting
553
  * @access public
554
  * @since 2.0.0
555
  * @return void
556
  */
557
  public function register_settings() {
558
-
559
  register_setting( self::$option_string . '_group', self::$option_string, array( $this, 'validate_settings' ) );
560
  }
561
-
562
  /**
563
  * Unregister and delete settings; clean database
564
- *
565
  * @uses unregister_setting, delete_option
566
  * @access public
567
  * @since 0.0.2
568
  * @return void
569
  */
570
  public function unregister_settings() {
571
-
572
  unregister_setting( self::$option_string . '_group', self::$option_string );
573
  delete_option( self::$option_string );
574
  }
575
-
 
 
 
 
 
 
576
  public function print_scripts( $where ) {
577
-
578
- $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : '';
579
-
580
  wp_register_script(
581
- self::$option_string . '_admin_script',
582
- plugins_url( '/js/settings' . $suffix. '.js', parent::get_plugin_string() ),
583
  array( 'jquery', 'quicktags' ),
584
  '',
585
  TRUE
586
  );
587
  wp_enqueue_script( self::$option_string . '_admin_script' );
 
 
 
 
 
 
 
 
 
588
  }
589
-
590
  /**
591
  * Add help text
592
- *