Version Description
(2018-11-06) = * Fix error warning in edit mode without button settings.
Download this release
Release Info
Developer | Bueltge |
Plugin | AddQuicktag |
Version | 2.5.3 |
Comparing to | |
See all releases |
Code changes from version 2.5.2 to 2.5.3
- addquicktag.php +81 -84
- addquicktag_cpt.php.example +36 -0
- addquicktag_quickedit_comment.php.example +50 -0
- inc/class-code-quicktags.php +146 -146
- readme.txt +5 -2
addquicktag.php
CHANGED
@@ -6,10 +6,10 @@
|
|
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.5.
|
10 |
* Author: Frank Bültge
|
11 |
* Author URI: https://bueltge.de
|
12 |
-
* License:
|
13 |
* License URI: ./license.txt
|
14 |
*
|
15 |
* Add Quicktag Plugin class
|
@@ -35,7 +35,7 @@ class Add_Quicktag {
|
|
35 |
'post-new.php',
|
36 |
'comment.php',
|
37 |
'edit-comments.php',
|
38 |
-
'widgets.php'
|
39 |
);
|
40 |
|
41 |
/**
|
@@ -46,6 +46,7 @@ class Add_Quicktag {
|
|
46 |
static private $post_types_for_js = array( 'comment', 'edit-comments', 'widgets' );
|
47 |
|
48 |
/**
|
|
|
49 |
* @var string
|
50 |
*/
|
51 |
static private $plugin;
|
@@ -61,7 +62,7 @@ class Add_Quicktag {
|
|
61 |
|
62 |
static $instance;
|
63 |
|
64 |
-
if (
|
65 |
$instance = new self();
|
66 |
}
|
67 |
|
@@ -79,17 +80,16 @@ class Add_Quicktag {
|
|
79 |
return;
|
80 |
}
|
81 |
|
82 |
-
// get string of plugin
|
83 |
self::$plugin = plugin_basename( __FILE__ );
|
84 |
|
85 |
-
// on uninstall remove capability from roles
|
86 |
register_uninstall_hook( __FILE__, array( 'Add_Quicktag', 'uninstall' ) );
|
87 |
// on deactivate delete all settings in database
|
88 |
// register_deactivation_hook( __FILE__, array('Add_Quicktag', 'uninstall' ) );
|
89 |
-
|
90 |
-
// load translation files
|
91 |
add_action( 'admin_init', array( $this, 'localize_plugin' ) );
|
92 |
-
// on init register post type for addquicktag and print js
|
93 |
add_action( 'init', array( $this, 'on_admin_init' ) );
|
94 |
|
95 |
add_filter( 'quicktags_settings', array( $this, 'remove_quicktags' ), 10, 1 );
|
@@ -100,17 +100,17 @@ class Add_Quicktag {
|
|
100 |
* Include other files and print JS
|
101 |
*
|
102 |
* @since 07/16/2012
|
103 |
-
* @return void
|
104 |
*/
|
105 |
public function on_admin_init() {
|
106 |
|
107 |
if ( ! is_admin() ) {
|
108 |
-
return
|
109 |
}
|
110 |
|
111 |
-
// Include settings
|
112 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-settings.php';
|
113 |
-
// Include solution for TinyMCE
|
114 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-tinymce.php';
|
115 |
|
116 |
foreach ( $this->get_admin_pages_for_js() as $page ) {
|
@@ -124,7 +124,7 @@ class Add_Quicktag {
|
|
124 |
*
|
125 |
* @since 08/15/2013
|
126 |
*
|
127 |
-
* @param array $qtags_init the Buttons
|
128 |
*
|
129 |
* @type string id
|
130 |
* @type array buttons, default: 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,fullscreen'
|
@@ -132,8 +132,8 @@ class Add_Quicktag {
|
|
132 |
*/
|
133 |
public function remove_quicktags( $qtags_init ) {
|
134 |
|
135 |
-
// No core buttons, not necessary to filter
|
136 |
-
if ( empty( $qtags_init[
|
137 |
return $qtags_init;
|
138 |
}
|
139 |
|
@@ -143,37 +143,37 @@ class Add_Quicktag {
|
|
143 |
$options = get_option( self::$option_string );
|
144 |
}
|
145 |
|
146 |
-
// No settings, not necessary to filter
|
147 |
-
if ( empty( $options[
|
148 |
return $qtags_init;
|
149 |
}
|
150 |
|
151 |
-
// get current screen, post type
|
152 |
$screen = get_current_screen();
|
153 |
// No information about the backend page, return.
|
154 |
-
if (
|
155 |
return $qtags_init;
|
156 |
}
|
157 |
|
158 |
-
// Convert string to array from default core buttons
|
159 |
-
$buttons = explode( ',', $qtags_init[
|
160 |
|
161 |
-
// loop about the options to check for each post type
|
162 |
-
foreach ( (array) $options[
|
163 |
|
164 |
-
// if the post type is inside the settings array active, then remove qtags
|
165 |
if ( is_array( $post_type ) && array_key_exists( $screen->id, $post_type ) ) {
|
166 |
|
167 |
-
// If settings have key inside, then unset this button
|
168 |
-
if (
|
169 |
unset( $buttons[ $key ] );
|
170 |
}
|
171 |
}
|
172 |
}
|
173 |
|
174 |
-
// Convert new buttons array back into a comma-separated string
|
175 |
-
$qtags_init[
|
176 |
-
$qtags_init[
|
177 |
|
178 |
return $qtags_init;
|
179 |
}
|
@@ -193,60 +193,58 @@ class Add_Quicktag {
|
|
193 |
* Print json data in head
|
194 |
*
|
195 |
* @since 2.0.0
|
196 |
-
* @return void
|
197 |
*/
|
198 |
public function get_json() {
|
199 |
global $current_screen;
|
200 |
|
201 |
-
if (
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
) {
|
208 |
-
return NULL;
|
209 |
}
|
210 |
|
211 |
-
if ( is_multisite() && is_plugin_active_for_network( $this
|
212 |
-
$options = get_site_option( self::$option_string );
|
213 |
} else {
|
214 |
-
$options = get_option( self::$option_string );
|
215 |
}
|
216 |
|
217 |
-
if ( empty( $options[
|
218 |
-
$options[
|
219 |
}
|
220 |
|
221 |
-
// allow change or enhance buttons array
|
222 |
-
$options[
|
223 |
-
// hook for filter options
|
224 |
-
$options = apply_filters( 'addquicktag_options', $options );
|
225 |
|
226 |
if ( ! $options ) {
|
227 |
-
return
|
228 |
}
|
229 |
|
230 |
-
if ( 1 < count( $options[
|
231 |
-
// sort array by order value
|
232 |
$tmp = array();
|
233 |
-
foreach ( (array) $options[
|
234 |
-
if ( isset( $order[
|
235 |
-
$tmp[
|
236 |
} else {
|
237 |
-
$tmp[
|
238 |
}
|
239 |
}
|
240 |
-
array_multisort( $tmp, SORT_ASC, $options[
|
241 |
}
|
242 |
|
243 |
?>
|
244 |
<script type="text/javascript">
|
245 |
-
var addquicktag_tags = <?php echo
|
246 |
-
addquicktag_post_type = <?php echo
|
247 |
-
addquicktag_pt_for_js = <?php echo
|
248 |
</script>
|
249 |
-
|
250 |
}
|
251 |
|
252 |
/**
|
@@ -254,41 +252,41 @@ class Add_Quicktag {
|
|
254 |
*
|
255 |
* @internal param string $where
|
256 |
*
|
257 |
-
* @since
|
258 |
-
* @access
|
259 |
-
* @return void
|
260 |
*/
|
261 |
public function admin_enqueue_scripts() {
|
262 |
global $current_screen;
|
263 |
|
264 |
-
if (
|
265 |
! in_array(
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
) {
|
271 |
-
return
|
272 |
}
|
273 |
|
274 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
275 |
|
276 |
-
if ( version_compare( $GLOBALS[
|
277 |
wp_enqueue_script(
|
278 |
$this->get_textdomain() . '_script',
|
279 |
plugins_url( '/js/add-quicktags' . $suffix . '.js', __FILE__ ),
|
280 |
array( 'jquery', 'quicktags' ),
|
281 |
'',
|
282 |
-
|
283 |
);
|
284 |
-
// Load only for WPs, there version is smaller then 3.2
|
285 |
} else {
|
286 |
wp_enqueue_script(
|
287 |
$this->get_textdomain() . '_script',
|
288 |
plugins_url( '/js/add-quicktags_32' . $suffix . '.js', __FILE__ ),
|
289 |
array( 'jquery', 'quicktags' ),
|
290 |
'',
|
291 |
-
|
292 |
);
|
293 |
}
|
294 |
// Alternative to JSON function
|
@@ -307,18 +305,19 @@ class Add_Quicktag {
|
|
307 |
|
308 |
load_plugin_textdomain(
|
309 |
$this->get_textdomain(),
|
310 |
-
|
311 |
dirname( plugin_basename( __FILE__ ) ) . '/languages'
|
312 |
);
|
313 |
}
|
314 |
|
315 |
/**
|
316 |
-
*
|
317 |
*
|
318 |
* @since 2.0.0
|
319 |
* @access public
|
320 |
*
|
321 |
-
* @param $value string
|
|
|
322 |
* Name, PluginURI, Version, Description, Author, AuthorURI, TextDomain, DomainPath, Network, Title
|
323 |
*
|
324 |
* @return string
|
@@ -333,7 +332,7 @@ class Add_Quicktag {
|
|
333 |
}
|
334 |
|
335 |
if ( ! function_exists( 'get_plugin_data' ) ) {
|
336 |
-
|
337 |
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
338 |
}
|
339 |
|
@@ -361,15 +360,13 @@ class Add_Quicktag {
|
|
361 |
*/
|
362 |
private function get_post_types() {
|
363 |
|
364 |
-
// list only post types, there was used in UI
|
365 |
-
$args = array( 'show_ui' =>
|
366 |
$post_types = get_post_types( $args );
|
367 |
-
// simplify the array
|
368 |
$post_types = array_values( $post_types );
|
369 |
-
// merge with strings from var
|
370 |
-
|
371 |
-
|
372 |
-
return $post_types;
|
373 |
}
|
374 |
|
375 |
/**
|
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.5.3
|
10 |
* Author: Frank Bültge
|
11 |
* Author URI: https://bueltge.de
|
12 |
+
* License: GPLv3+
|
13 |
* License URI: ./license.txt
|
14 |
*
|
15 |
* Add Quicktag Plugin class
|
35 |
'post-new.php',
|
36 |
'comment.php',
|
37 |
'edit-comments.php',
|
38 |
+
'widgets.php',
|
39 |
);
|
40 |
|
41 |
/**
|
46 |
static private $post_types_for_js = array( 'comment', 'edit-comments', 'widgets' );
|
47 |
|
48 |
/**
|
49 |
+
*
|
50 |
* @var string
|
51 |
*/
|
52 |
static private $plugin;
|
62 |
|
63 |
static $instance;
|
64 |
|
65 |
+
if ( null === $instance ) {
|
66 |
$instance = new self();
|
67 |
}
|
68 |
|
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 |
+
// load translation files.
|
|
|
91 |
add_action( 'admin_init', array( $this, 'localize_plugin' ) );
|
92 |
+
// on init register post type for addquicktag and print js.
|
93 |
add_action( 'init', array( $this, 'on_admin_init' ) );
|
94 |
|
95 |
add_filter( 'quicktags_settings', array( $this, 'remove_quicktags' ), 10, 1 );
|
100 |
* Include other files and print JS
|
101 |
*
|
102 |
* @since 07/16/2012
|
103 |
+
* @return null|void
|
104 |
*/
|
105 |
public function on_admin_init() {
|
106 |
|
107 |
if ( ! is_admin() ) {
|
108 |
+
return null;
|
109 |
}
|
110 |
|
111 |
+
// Include settings.
|
112 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-settings.php';
|
113 |
+
// Include solution for TinyMCE.
|
114 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'inc/class-tinymce.php';
|
115 |
|
116 |
foreach ( $this->get_admin_pages_for_js() as $page ) {
|
124 |
*
|
125 |
* @since 08/15/2013
|
126 |
*
|
127 |
+
* @param array $qtags_init the Buttons.
|
128 |
*
|
129 |
* @type string id
|
130 |
* @type array buttons, default: 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,fullscreen'
|
132 |
*/
|
133 |
public function remove_quicktags( $qtags_init ) {
|
134 |
|
135 |
+
// No core buttons, not necessary to filter.
|
136 |
+
if ( empty( $qtags_init['buttons'] ) ) {
|
137 |
return $qtags_init;
|
138 |
}
|
139 |
|
143 |
$options = get_option( self::$option_string );
|
144 |
}
|
145 |
|
146 |
+
// No settings, not necessary to filter.
|
147 |
+
if ( empty( $options['core_buttons'] ) ) {
|
148 |
return $qtags_init;
|
149 |
}
|
150 |
|
151 |
+
// get current screen, post type.
|
152 |
$screen = get_current_screen();
|
153 |
// No information about the backend page, return.
|
154 |
+
if ( null === $screen->id ) {
|
155 |
return $qtags_init;
|
156 |
}
|
157 |
|
158 |
+
// Convert string to array from default core buttons.
|
159 |
+
$buttons = explode( ',', $qtags_init['buttons'] );
|
160 |
|
161 |
+
// loop about the options to check for each post type.
|
162 |
+
foreach ( (array) $options['core_buttons'] as $button => $post_type ) {
|
163 |
|
164 |
+
// if the post type is inside the settings array active, then remove qtags.
|
165 |
if ( is_array( $post_type ) && array_key_exists( $screen->id, $post_type ) ) {
|
166 |
|
167 |
+
// If settings have key inside, then unset this button.
|
168 |
+
if ( false !== ( $key = array_search( $button, $buttons, true ) ) ) {
|
169 |
unset( $buttons[ $key ] );
|
170 |
}
|
171 |
}
|
172 |
}
|
173 |
|
174 |
+
// Convert new buttons array back into a comma-separated string.
|
175 |
+
$qtags_init['buttons'] = implode( ',', $buttons );
|
176 |
+
$qtags_init['buttons'] = apply_filters( 'addquicktag_remove_buttons', $qtags_init['buttons'] );
|
177 |
|
178 |
return $qtags_init;
|
179 |
}
|
193 |
* Print json data in head
|
194 |
*
|
195 |
* @since 2.0.0
|
196 |
+
* @return null|void
|
197 |
*/
|
198 |
public function get_json() {
|
199 |
global $current_screen;
|
200 |
|
201 |
+
if ( null !== $current_screen->id && ! in_array(
|
202 |
+
$current_screen->id,
|
203 |
+
$this->get_post_types_for_js(),
|
204 |
+
true
|
205 |
+
) ) {
|
206 |
+
return null;
|
|
|
|
|
207 |
}
|
208 |
|
209 |
+
if ( is_multisite() && is_plugin_active_for_network( $this->get_plugin_string() ) ) {
|
210 |
+
$options = (array) get_site_option( self::$option_string );
|
211 |
} else {
|
212 |
+
$options = (array) get_option( self::$option_string );
|
213 |
}
|
214 |
|
215 |
+
if ( empty( $options['buttons'] ) ) {
|
216 |
+
$options['buttons'] = array();
|
217 |
}
|
218 |
|
219 |
+
// allow change or enhance buttons array.
|
220 |
+
$options['buttons'] = apply_filters( 'addquicktag_buttons', $options['buttons'] );
|
221 |
+
// hook for filter options.
|
222 |
+
$options = (array) apply_filters( 'addquicktag_options', $options );
|
223 |
|
224 |
if ( ! $options ) {
|
225 |
+
return null;
|
226 |
}
|
227 |
|
228 |
+
if ( 1 < count( $options['buttons'] ) ) {
|
229 |
+
// sort array by order value.
|
230 |
$tmp = array();
|
231 |
+
foreach ( (array) $options['buttons'] as $order ) {
|
232 |
+
if ( isset( $order['order'] ) ) {
|
233 |
+
$tmp[] = $order['order'];
|
234 |
} else {
|
235 |
+
$tmp[] = 0;
|
236 |
}
|
237 |
}
|
238 |
+
array_multisort( $tmp, SORT_ASC, $options['buttons'] );
|
239 |
}
|
240 |
|
241 |
?>
|
242 |
<script type="text/javascript">
|
243 |
+
var addquicktag_tags = <?php echo wp_json_encode( $options ); ?>,
|
244 |
+
addquicktag_post_type = <?php echo wp_json_encode( $current_screen->id ); ?>,
|
245 |
+
addquicktag_pt_for_js = <?php echo wp_json_encode( $this->get_post_types_for_js() ); ?>;
|
246 |
</script>
|
247 |
+
<?php
|
248 |
}
|
249 |
|
250 |
/**
|
252 |
*
|
253 |
* @internal param string $where
|
254 |
*
|
255 |
+
* @since 2.0.0
|
256 |
+
* @access public
|
257 |
+
* @return null|void
|
258 |
*/
|
259 |
public function admin_enqueue_scripts() {
|
260 |
global $current_screen;
|
261 |
|
262 |
+
if ( null !== $current_screen->id &&
|
263 |
! in_array(
|
264 |
+
$current_screen->id,
|
265 |
+
$this->get_post_types_for_js(),
|
266 |
+
true
|
267 |
+
)
|
268 |
) {
|
269 |
+
return null;
|
270 |
}
|
271 |
|
272 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
273 |
|
274 |
+
if ( version_compare( $GLOBALS['wp_version'], '3.3alpha', '>=' ) ) {
|
275 |
wp_enqueue_script(
|
276 |
$this->get_textdomain() . '_script',
|
277 |
plugins_url( '/js/add-quicktags' . $suffix . '.js', __FILE__ ),
|
278 |
array( 'jquery', 'quicktags' ),
|
279 |
'',
|
280 |
+
true
|
281 |
);
|
282 |
+
// Load only for WPs, there version is smaller then 3.2.
|
283 |
} else {
|
284 |
wp_enqueue_script(
|
285 |
$this->get_textdomain() . '_script',
|
286 |
plugins_url( '/js/add-quicktags_32' . $suffix . '.js', __FILE__ ),
|
287 |
array( 'jquery', 'quicktags' ),
|
288 |
'',
|
289 |
+
true
|
290 |
);
|
291 |
}
|
292 |
// Alternative to JSON function
|
305 |
|
306 |
load_plugin_textdomain(
|
307 |
$this->get_textdomain(),
|
308 |
+
false,
|
309 |
dirname( plugin_basename( __FILE__ ) ) . '/languages'
|
310 |
);
|
311 |
}
|
312 |
|
313 |
/**
|
314 |
+
* Return plugin comment data.
|
315 |
*
|
316 |
* @since 2.0.0
|
317 |
* @access public
|
318 |
*
|
319 |
+
* @param $value string
|
320 |
+
* default = 'TextDomain'
|
321 |
* Name, PluginURI, Version, Description, Author, AuthorURI, TextDomain, DomainPath, Network, Title
|
322 |
*
|
323 |
* @return string
|
332 |
}
|
333 |
|
334 |
if ( ! function_exists( 'get_plugin_data' ) ) {
|
335 |
+
// @noinspection
|
336 |
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
337 |
}
|
338 |
|
360 |
*/
|
361 |
private function get_post_types() {
|
362 |
|
363 |
+
// list only post types, there was used in UI.
|
364 |
+
$args = array( 'show_ui' => true );
|
365 |
$post_types = get_post_types( $args );
|
366 |
+
// simplify the array.
|
367 |
$post_types = array_values( $post_types );
|
368 |
+
// merge with strings from var.
|
369 |
+
return array_merge( $post_types, self::$post_types_for_js );
|
|
|
|
|
370 |
}
|
371 |
|
372 |
/**
|
addquicktag_cpt.php.example
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: AddQuicktag Example for CPT
|
4 |
+
* Plugin URI: http://bueltge.de/
|
5 |
+
* Description: Add custom post type 'my_custom_post_type' to AddQuicktag plugin
|
6 |
+
* Author: Frank Bültge
|
7 |
+
* Version: 0.0.1
|
8 |
+
* Licence: GPLv3
|
9 |
+
* Author URI: http://bueltge.de
|
10 |
+
*/
|
11 |
+
|
12 |
+
// This file is not called from WordPress. We don't like that.
|
13 |
+
if ( ! function_exists( 'add_filter' ) ) {
|
14 |
+
echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
|
15 |
+
exit;
|
16 |
+
}
|
17 |
+
|
18 |
+
if ( ! function_exists( 'my_addquicktag_post_types' ) ) {
|
19 |
+
|
20 |
+
// add custom function to filter hook 'addquicktag_post_types'
|
21 |
+
add_filter( 'addquicktag_post_types', 'my_addquicktag_post_types' );
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Return array $post_types with custom post types strings
|
25 |
+
*
|
26 |
+
* @param $post_type Array
|
27 |
+
* @return $post_type Array
|
28 |
+
*/
|
29 |
+
function my_addquicktag_post_types( $post_types ) {
|
30 |
+
|
31 |
+
$post_types[] = 'snippet';
|
32 |
+
|
33 |
+
return $post_types;
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
addquicktag_quickedit_comment.php.example
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: Use AddQuicktag on Quickedit of comments
|
4 |
+
* Plugin URI: http://bueltge.de/
|
5 |
+
* Description: Add the quicktags fomr AddQuicktag plugin to the editor of Quickedit on comments
|
6 |
+
* Author: Frank Bültge
|
7 |
+
* Version: 0.0.1
|
8 |
+
* Licence: GPLv3
|
9 |
+
* Author URI: http://bueltge.de
|
10 |
+
*/
|
11 |
+
|
12 |
+
// This file is not called from WordPress. We don't like that.
|
13 |
+
if ( ! function_exists( 'add_filter' ) ) {
|
14 |
+
echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
|
15 |
+
exit;
|
16 |
+
}
|
17 |
+
|
18 |
+
if ( ! function_exists( 'my_addquicktag_post_types' ) ) {
|
19 |
+
|
20 |
+
// add custom function to filter hook 'addquicktag_post_types'
|
21 |
+
add_filter( 'addquicktag_post_types', 'my_addquicktag_post_types' );
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Return array $post_types with custom post types strings
|
25 |
+
*
|
26 |
+
* @param $post_type Array
|
27 |
+
* @return $post_type Array
|
28 |
+
*/
|
29 |
+
function my_addquicktag_post_types( $post_types ) {
|
30 |
+
|
31 |
+
$post_types[] = 'edit-comments';
|
32 |
+
|
33 |
+
return $post_types;
|
34 |
+
}
|
35 |
+
|
36 |
+
add_filter( 'addquicktag_pages', 'my_addquicktag_pages' );
|
37 |
+
/**
|
38 |
+
* Return array $page with custom page strings
|
39 |
+
*
|
40 |
+
* @param $page Array
|
41 |
+
* @return $page Array
|
42 |
+
*/
|
43 |
+
function my_addquicktag_pages( $page ) {
|
44 |
+
|
45 |
+
$page[] = 'edit-comments.php';
|
46 |
+
|
47 |
+
return $page;
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
inc/class-code-quicktags.php
CHANGED
@@ -1,146 +1,146 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* AddQuicktag - Settings for enhanced code buttons
|
4 |
-
*
|
5 |
-
* @license
|
6 |
-
* @package AddQuicktag
|
7 |
-
* @subpackage AddQuicktag Settings
|
8 |
-
* @author Frank Bueltge <frank@bueltge.de>
|
9 |
-
* @since 01/26/2014
|
10 |
-
* @version 2015-12-23
|
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 |
-
* Handler for the action 'init'. Instantiates this class.
|
32 |
-
*
|
33 |
-
* @access public
|
34 |
-
* @since 2.0.0
|
35 |
-
* @return \Add_Quicktag|\Add_Quicktag_Code_Quicktags|\Add_Quicktag_Settings $instance
|
36 |
-
*/
|
37 |
-
public static function get_object() {
|
38 |
-
|
39 |
-
static $instance;
|
40 |
-
|
41 |
-
if ( NULL === $instance ) {
|
42 |
-
$instance = new self();
|
43 |
-
}
|
44 |
-
|
45 |
-
return $instance;
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Constructor, init on defined hooks of WP and include second class
|
50 |
-
*
|
51 |
-
* @access public
|
52 |
-
* @since 0.0.2
|
53 |
-
* @uses register_activation_hook, register_uninstall_hook, add_action
|
54 |
-
*/
|
55 |
-
private function __construct() {
|
56 |
-
|
57 |
-
add_action( 'addquicktag_settings_form_page', array( $this, 'get_code_quicktag_area' ) );
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Add settings area
|
62 |
-
*
|
63 |
-
* @param $options
|
64 |
-
*/
|
65 |
-
public function get_code_quicktag_area( $options ) {
|
66 |
-
|
67 |
-
if ( ! array_key_exists( 'code_buttons', $options ) ) {
|
68 |
-
$options[ 'code_buttons' ] = array();
|
69 |
-
}
|
70 |
-
?>
|
71 |
-
<h3><?php esc_html_e( 'Enhanced Code Quicktag buttons', 'addquicktag' ); ?></h3>
|
72 |
-
<p><?php esc_html_e( 'Select the checkbox below to add enhanced code buttons.', 'addquicktag' ); ?></p>
|
73 |
-
<h4><?php esc_html_e( 'pre: Enhanced Code buttons', 'addquicktag' ); ?></h4>
|
74 |
-
<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.', 'addquicktag' ); ?></p>
|
75 |
-
<h4><?php esc_html_e( 'htmlentities: HTML Entities, HTML Decode', 'addquicktag' ); ?></h4>
|
76 |
-
<p><?php esc_html_e( 'Add buttons to do the inconvient HTML encoding/decoding, like < to &lt; and back.', 'addquicktag' ); ?></p>
|
77 |
-
|
78 |
-
<?php
|
79 |
-
// loop about the post types, create html an values for title in table
|
80 |
-
$pt_title = '';
|
81 |
-
$pt_colgroup = '';
|
82 |
-
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
83 |
-
$pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
|
84 |
-
$pt_colgroup .= '<colgroup></colgroup>' . "\n";
|
85 |
-
}
|
86 |
-
?>
|
87 |
-
|
88 |
-
<table class="widefat form-table rmnlCodeQuicktagSettings">
|
89 |
-
<colgroup></colgroup>
|
90 |
-
<?php echo $pt_colgroup; ?>
|
91 |
-
<colgroup></colgroup>
|
92 |
-
|
93 |
-
<thead>
|
94 |
-
<tr>
|
95 |
-
<th class="row-title"><?php esc_html_e( 'Button', 'addquicktag' ); ?></th>
|
96 |
-
<?php echo $pt_title; ?>
|
97 |
-
<th class="row-title num" style="width:3%;">✔</th>
|
98 |
-
</tr>
|
99 |
-
</thead>
|
100 |
-
|
101 |
-
<tbody>
|
102 |
-
<?php
|
103 |
-
// Convert string to array
|
104 |
-
//$code_buttons = explode( ',', self::$code_quicktags );
|
105 |
-
// Loop over items to remove and unset them from the buttons
|
106 |
-
$i = 9999;
|
107 |
-
foreach ( self::$code_quicktags as $key => $value ) {
|
108 |
-
|
109 |
-
echo '<tr id="rmqtb' . $i . '">' . "\n";
|
110 |
-
echo '<td><input type="button" class="ed_button" title="" value="' . $value . '"></td>';
|
111 |
-
|
112 |
-
// loop about the post types, create html an values
|
113 |
-
$pt_checkboxes = '';
|
114 |
-
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
115 |
-
|
116 |
-
$pt_checked = '';
|
117 |
-
if ( isset( $options[ 'code_buttons' ][ $value ][ $post_type ] )
|
118 |
-
&& 1 === (int) $options[ 'code_buttons' ][ $value ][ $post_type ]
|
119 |
-
) {
|
120 |
-
$pt_checked = ' checked="checked"';
|
121 |
-
}
|
122 |
-
|
123 |
-
$pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
|
124 |
-
parent :: get_option_string() . '[code_buttons][' .
|
125 |
-
$value . '][' . $post_type . ']" value="1"' .
|
126 |
-
$pt_checked . '/></td>' . "\n";
|
127 |
-
}
|
128 |
-
echo $pt_checkboxes;
|
129 |
-
|
130 |
-
echo '<td class="num"><input type="checkbox" class="toggle" id="select_all_' . $i . '" value="' . $i . '" /></td>' . "\n";
|
131 |
-
|
132 |
-
echo '</tr>' . "\n";
|
133 |
-
$i ++;
|
134 |
-
}
|
135 |
-
|
136 |
-
// Convert new buttons array back into a comma-separated string
|
137 |
-
//$code_qt = implode( ',', $code_buttons );
|
138 |
-
?>
|
139 |
-
</tbody>
|
140 |
-
</table>
|
141 |
-
<?php
|
142 |
-
}
|
143 |
-
|
144 |
-
} // end class
|
145 |
-
|
146 |
-
$add_quicktag_code_quicktags = Add_Quicktag_Code_Quicktags::get_object();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* AddQuicktag - Settings for enhanced code buttons
|
4 |
+
*
|
5 |
+
* @license GPLv3
|
6 |
+
* @package AddQuicktag
|
7 |
+
* @subpackage AddQuicktag Settings
|
8 |
+
* @author Frank Bueltge <frank@bueltge.de>
|
9 |
+
* @since 01/26/2014
|
10 |
+
* @version 2015-12-23
|
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 |
+
* Handler for the action 'init'. Instantiates this class.
|
32 |
+
*
|
33 |
+
* @access public
|
34 |
+
* @since 2.0.0
|
35 |
+
* @return \Add_Quicktag|\Add_Quicktag_Code_Quicktags|\Add_Quicktag_Settings $instance
|
36 |
+
*/
|
37 |
+
public static function get_object() {
|
38 |
+
|
39 |
+
static $instance;
|
40 |
+
|
41 |
+
if ( NULL === $instance ) {
|
42 |
+
$instance = new self();
|
43 |
+
}
|
44 |
+
|
45 |
+
return $instance;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Constructor, init on defined hooks of WP and include second class
|
50 |
+
*
|
51 |
+
* @access public
|
52 |
+
* @since 0.0.2
|
53 |
+
* @uses register_activation_hook, register_uninstall_hook, add_action
|
54 |
+
*/
|
55 |
+
private function __construct() {
|
56 |
+
|
57 |
+
add_action( 'addquicktag_settings_form_page', array( $this, 'get_code_quicktag_area' ) );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Add settings area
|
62 |
+
*
|
63 |
+
* @param $options
|
64 |
+
*/
|
65 |
+
public function get_code_quicktag_area( $options ) {
|
66 |
+
|
67 |
+
if ( ! array_key_exists( 'code_buttons', $options ) ) {
|
68 |
+
$options[ 'code_buttons' ] = array();
|
69 |
+
}
|
70 |
+
?>
|
71 |
+
<h3><?php esc_html_e( 'Enhanced Code Quicktag buttons', 'addquicktag' ); ?></h3>
|
72 |
+
<p><?php esc_html_e( 'Select the checkbox below to add enhanced code buttons.', 'addquicktag' ); ?></p>
|
73 |
+
<h4><?php esc_html_e( 'pre: Enhanced Code buttons', 'addquicktag' ); ?></h4>
|
74 |
+
<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.', 'addquicktag' ); ?></p>
|
75 |
+
<h4><?php esc_html_e( 'htmlentities: HTML Entities, HTML Decode', 'addquicktag' ); ?></h4>
|
76 |
+
<p><?php esc_html_e( 'Add buttons to do the inconvient HTML encoding/decoding, like < to &lt; and back.', 'addquicktag' ); ?></p>
|
77 |
+
|
78 |
+
<?php
|
79 |
+
// loop about the post types, create html an values for title in table
|
80 |
+
$pt_title = '';
|
81 |
+
$pt_colgroup = '';
|
82 |
+
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
83 |
+
$pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
|
84 |
+
$pt_colgroup .= '<colgroup></colgroup>' . "\n";
|
85 |
+
}
|
86 |
+
?>
|
87 |
+
|
88 |
+
<table class="widefat form-table rmnlCodeQuicktagSettings">
|
89 |
+
<colgroup></colgroup>
|
90 |
+
<?php echo $pt_colgroup; ?>
|
91 |
+
<colgroup></colgroup>
|
92 |
+
|
93 |
+
<thead>
|
94 |
+
<tr>
|
95 |
+
<th class="row-title"><?php esc_html_e( 'Button', 'addquicktag' ); ?></th>
|
96 |
+
<?php echo $pt_title; ?>
|
97 |
+
<th class="row-title num" style="width:3%;">✔</th>
|
98 |
+
</tr>
|
99 |
+
</thead>
|
100 |
+
|
101 |
+
<tbody>
|
102 |
+
<?php
|
103 |
+
// Convert string to array
|
104 |
+
//$code_buttons = explode( ',', self::$code_quicktags );
|
105 |
+
// Loop over items to remove and unset them from the buttons
|
106 |
+
$i = 9999;
|
107 |
+
foreach ( self::$code_quicktags as $key => $value ) {
|
108 |
+
|
109 |
+
echo '<tr id="rmqtb' . $i . '">' . "\n";
|
110 |
+
echo '<td><input type="button" class="ed_button" title="" value="' . $value . '"></td>';
|
111 |
+
|
112 |
+
// loop about the post types, create html an values
|
113 |
+
$pt_checkboxes = '';
|
114 |
+
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
115 |
+
|
116 |
+
$pt_checked = '';
|
117 |
+
if ( isset( $options[ 'code_buttons' ][ $value ][ $post_type ] )
|
118 |
+
&& 1 === (int) $options[ 'code_buttons' ][ $value ][ $post_type ]
|
119 |
+
) {
|
120 |
+
$pt_checked = ' checked="checked"';
|
121 |
+
}
|
122 |
+
|
123 |
+
$pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
|
124 |
+
parent :: get_option_string() . '[code_buttons][' .
|
125 |
+
$value . '][' . $post_type . ']" value="1"' .
|
126 |
+
$pt_checked . '/></td>' . "\n";
|
127 |
+
}
|
128 |
+
echo $pt_checkboxes;
|
129 |
+
|
130 |
+
echo '<td class="num"><input type="checkbox" class="toggle" id="select_all_' . $i . '" value="' . $i . '" /></td>' . "\n";
|
131 |
+
|
132 |
+
echo '</tr>' . "\n";
|
133 |
+
$i ++;
|
134 |
+
}
|
135 |
+
|
136 |
+
// Convert new buttons array back into a comma-separated string
|
137 |
+
//$code_qt = implode( ',', $code_buttons );
|
138 |
+
?>
|
139 |
+
</tbody>
|
140 |
+
</table>
|
141 |
+
<?php
|
142 |
+
}
|
143 |
+
|
144 |
+
} // end class
|
145 |
+
|
146 |
+
$add_quicktag_code_quicktags = Add_Quicktag_Code_Quicktags::get_object();
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: Bueltge, inpsyde
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6069955
|
4 |
Tags: quicktag, editor, tinymce, add buttons, button, buttons, visual editor
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 2.5.
|
8 |
|
9 |
This plugin makes it easy to add Quicktags to the html - and visual-editor.
|
10 |
|
@@ -130,6 +130,9 @@ The following example adds buttons. The params inside the array are the same as
|
|
130 |
Good news, this plugin is free for everyone! Since it's released under the GPL, you can use it free of charge on your personal or commercial blog. But if you enjoy this plugin, you may consider to thank me and leave a [positive review](https://wordpress.org/support/plugin/addquicktag/reviews/#new-post) for the time I've spent writing and supporting this plugin. And I really don't want to know how many hours of my life this plugin has already eaten ;)
|
131 |
|
132 |
== Changelog ==
|
|
|
|
|
|
|
133 |
= 2.5.2 (2017-11-16) =
|
134 |
* Fixed several code strict style issues.
|
135 |
* Fixed javascript topics to write more strict.
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6069955
|
4 |
Tags: quicktag, editor, tinymce, add buttons, button, buttons, visual editor
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 5
|
7 |
+
Stable tag: 2.5.3
|
8 |
|
9 |
This plugin makes it easy to add Quicktags to the html - and visual-editor.
|
10 |
|
130 |
Good news, this plugin is free for everyone! Since it's released under the GPL, you can use it free of charge on your personal or commercial blog. But if you enjoy this plugin, you may consider to thank me and leave a [positive review](https://wordpress.org/support/plugin/addquicktag/reviews/#new-post) for the time I've spent writing and supporting this plugin. And I really don't want to know how many hours of my life this plugin has already eaten ;)
|
131 |
|
132 |
== Changelog ==
|
133 |
+
= 2.5.3 (2018-11-06) =
|
134 |
+
* Fix error warning in edit mode without button settings.
|
135 |
+
|
136 |
= 2.5.2 (2017-11-16) =
|
137 |
* Fixed several code strict style issues.
|
138 |
* Fixed javascript topics to write more strict.
|