Version Description
(2021-04-29) = * Maintenance for the jQuery Update to run with the last WP Core update, jQuery 3.5* * Maintenance several code styles, testing PHP7/8 * Remove dependecies for WP version smaller 3.3
Download this release
Release Info
Developer | Bueltge |
Plugin | AddQuicktag |
Version | 2.6.0 |
Comparing to | |
See all releases |
Code changes from version 2.5.3 to 2.6.0
- addquicktag.php +15 -41
- addquicktag_cpt.php.example +0 -36
- addquicktag_quickedit_comment.php.example +0 -50
- css/dashicons-picker.css +1 -1
- css/dashicons-picker.dev.css +43 -43
- css/settings.css +1 -1
- inc/class-code-quicktags.php +19 -26
- inc/class-imexport.php +245 -232
- inc/class-remove-quicktags.php +158 -158
- inc/class-settings.php +281 -246
- inc/class-tinymce.php +14 -18
- inc/tinymce/editor_plugin.dev.js +0 -170
- inc/tinymce/editor_plugin.js +0 -1
- js/add-quicktags.dev.js +85 -68
- js/add-quicktags.js +1 -1
- js/add-quicktags_32.dev.js +0 -44
- js/add-quicktags_32.js +0 -1
- js/dashicons-picker.dev.js +96 -21
- js/dashicons-picker.js +1 -1
- js/editor_plugin.dev.js +169 -0
- js/editor_plugin.js +1 -0
- {inc/tinymce → js}/langs/de.js +0 -0
- {inc/tinymce → js}/langs/en.js +0 -0
- js/settings.dev.js +71 -73
- js/settings.js +1 -1
- readme.txt +13 -18
addquicktag.php
CHANGED
@@ -6,7 +6,7 @@
|
|
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.
|
10 |
* Author: Frank Bültge
|
11 |
* Author URI: https://bueltge.de
|
12 |
* License: GPLv3+
|
@@ -23,14 +23,14 @@ class Add_Quicktag {
|
|
23 |
*
|
24 |
* @var string
|
25 |
*/
|
26 |
-
static
|
27 |
|
28 |
/**
|
29 |
* Use filter 'addquicktag_pages' for add custom pages
|
30 |
*
|
31 |
* @var array
|
32 |
*/
|
33 |
-
static
|
34 |
'post.php',
|
35 |
'post-new.php',
|
36 |
'comment.php',
|
@@ -43,13 +43,14 @@ class Add_Quicktag {
|
|
43 |
*
|
44 |
* @var array
|
45 |
*/
|
46 |
-
static
|
47 |
|
48 |
/**
|
|
|
49 |
*
|
50 |
* @var string
|
51 |
*/
|
52 |
-
static
|
53 |
|
54 |
/**
|
55 |
* Handler for the action 'init'. Instantiates this class.
|
@@ -59,7 +60,6 @@ class Add_Quicktag {
|
|
59 |
* @return \Add_Quicktag $instance
|
60 |
*/
|
61 |
public static function get_object() {
|
62 |
-
|
63 |
static $instance;
|
64 |
|
65 |
if ( null === $instance ) {
|
@@ -75,7 +75,6 @@ class Add_Quicktag {
|
|
75 |
* @since 2.0.0
|
76 |
*/
|
77 |
private function __construct() {
|
78 |
-
|
79 |
if ( ! is_admin() ) {
|
80 |
return;
|
81 |
}
|
@@ -103,7 +102,6 @@ class Add_Quicktag {
|
|
103 |
* @return null|void
|
104 |
*/
|
105 |
public function on_admin_init() {
|
106 |
-
|
107 |
if ( ! is_admin() ) {
|
108 |
return null;
|
109 |
}
|
@@ -185,7 +183,6 @@ class Add_Quicktag {
|
|
185 |
* @return void
|
186 |
*/
|
187 |
public static function uninstall() {
|
188 |
-
|
189 |
delete_site_option( self::$option_string );
|
190 |
}
|
191 |
|
@@ -260,7 +257,7 @@ class Add_Quicktag {
|
|
260 |
global $current_screen;
|
261 |
|
262 |
if ( null !== $current_screen->id &&
|
263 |
-
|
264 |
$current_screen->id,
|
265 |
$this->get_post_types_for_js(),
|
266 |
true
|
@@ -271,26 +268,13 @@ class Add_Quicktag {
|
|
271 |
|
272 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
273 |
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
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
|
293 |
-
// wp_localize_script( self :: get_textdomain() . '_script', 'addquicktag_tags', get_option( self :: $option_string ) );
|
294 |
}
|
295 |
|
296 |
/**
|
@@ -302,7 +286,6 @@ class Add_Quicktag {
|
|
302 |
* @return void
|
303 |
*/
|
304 |
public function localize_plugin() {
|
305 |
-
|
306 |
load_plugin_textdomain(
|
307 |
$this->get_textdomain(),
|
308 |
false,
|
@@ -316,14 +299,10 @@ class Add_Quicktag {
|
|
316 |
* @since 2.0.0
|
317 |
* @access public
|
318 |
*
|
319 |
-
* @param $value
|
320 |
-
* default = 'TextDomain'
|
321 |
-
* Name, PluginURI, Version, Description, Author, AuthorURI, TextDomain, DomainPath, Network, Title
|
322 |
-
*
|
323 |
* @return string
|
324 |
*/
|
325 |
public function get_plugin_data( $value = 'TextDomain' ) {
|
326 |
-
|
327 |
static $plugin_data = array();
|
328 |
|
329 |
// fetch the data just once.
|
@@ -348,7 +327,6 @@ class Add_Quicktag {
|
|
348 |
* @return string
|
349 |
*/
|
350 |
public function get_plugin_string() {
|
351 |
-
|
352 |
return self::$plugin;
|
353 |
}
|
354 |
|
@@ -377,7 +355,6 @@ class Add_Quicktag {
|
|
377 |
* @return array
|
378 |
*/
|
379 |
public function get_post_types_for_js() {
|
380 |
-
|
381 |
return apply_filters( 'addquicktag_post_types', $this->get_post_types() );
|
382 |
}
|
383 |
|
@@ -389,7 +366,6 @@ class Add_Quicktag {
|
|
389 |
* @return array
|
390 |
*/
|
391 |
public function get_admin_pages_for_js() {
|
392 |
-
|
393 |
return apply_filters( 'addquicktag_pages', self::$admin_pages_for_js );
|
394 |
}
|
395 |
|
@@ -401,7 +377,6 @@ class Add_Quicktag {
|
|
401 |
* @return string
|
402 |
*/
|
403 |
public function get_textdomain() {
|
404 |
-
|
405 |
return $this->get_plugin_data();
|
406 |
}
|
407 |
|
@@ -412,7 +387,6 @@ class Add_Quicktag {
|
|
412 |
* @return string
|
413 |
*/
|
414 |
public function get_option_string() {
|
415 |
-
|
416 |
return self::$option_string;
|
417 |
}
|
418 |
|
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.6.0
|
10 |
* Author: Frank Bültge
|
11 |
* Author URI: https://bueltge.de
|
12 |
* License: GPLv3+
|
23 |
*
|
24 |
* @var string
|
25 |
*/
|
26 |
+
private static $option_string = 'rmnlQuicktagSettings';
|
27 |
|
28 |
/**
|
29 |
* Use filter 'addquicktag_pages' for add custom pages
|
30 |
*
|
31 |
* @var array
|
32 |
*/
|
33 |
+
private static $admin_pages_for_js = array(
|
34 |
'post.php',
|
35 |
'post-new.php',
|
36 |
'comment.php',
|
43 |
*
|
44 |
* @var array
|
45 |
*/
|
46 |
+
private static $post_types_for_js = array( 'comment', 'edit-comments', 'widgets' );
|
47 |
|
48 |
/**
|
49 |
+
* Store plugin string.
|
50 |
*
|
51 |
* @var string
|
52 |
*/
|
53 |
+
private static $plugin;
|
54 |
|
55 |
/**
|
56 |
* Handler for the action 'init'. Instantiates this class.
|
60 |
* @return \Add_Quicktag $instance
|
61 |
*/
|
62 |
public static function get_object() {
|
|
|
63 |
static $instance;
|
64 |
|
65 |
if ( null === $instance ) {
|
75 |
* @since 2.0.0
|
76 |
*/
|
77 |
private function __construct() {
|
|
|
78 |
if ( ! is_admin() ) {
|
79 |
return;
|
80 |
}
|
102 |
* @return null|void
|
103 |
*/
|
104 |
public function on_admin_init() {
|
|
|
105 |
if ( ! is_admin() ) {
|
106 |
return null;
|
107 |
}
|
183 |
* @return void
|
184 |
*/
|
185 |
public static function uninstall() {
|
|
|
186 |
delete_site_option( self::$option_string );
|
187 |
}
|
188 |
|
257 |
global $current_screen;
|
258 |
|
259 |
if ( null !== $current_screen->id &&
|
260 |
+
! in_array(
|
261 |
$current_screen->id,
|
262 |
$this->get_post_types_for_js(),
|
263 |
true
|
268 |
|
269 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
270 |
|
271 |
+
wp_enqueue_script(
|
272 |
+
$this->get_textdomain() . '_script',
|
273 |
+
plugins_url( '/js/add-quicktags' . $suffix . '.js', __FILE__ ),
|
274 |
+
array( 'jquery', 'quicktags' ),
|
275 |
+
'2021-05-26',
|
276 |
+
true
|
277 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
}
|
279 |
|
280 |
/**
|
286 |
* @return void
|
287 |
*/
|
288 |
public function localize_plugin() {
|
|
|
289 |
load_plugin_textdomain(
|
290 |
$this->get_textdomain(),
|
291 |
false,
|
299 |
* @since 2.0.0
|
300 |
* @access public
|
301 |
*
|
302 |
+
* @param string $value default = 'TextDomain'.
|
|
|
|
|
|
|
303 |
* @return string
|
304 |
*/
|
305 |
public function get_plugin_data( $value = 'TextDomain' ) {
|
|
|
306 |
static $plugin_data = array();
|
307 |
|
308 |
// fetch the data just once.
|
327 |
* @return string
|
328 |
*/
|
329 |
public function get_plugin_string() {
|
|
|
330 |
return self::$plugin;
|
331 |
}
|
332 |
|
355 |
* @return array
|
356 |
*/
|
357 |
public function get_post_types_for_js() {
|
|
|
358 |
return apply_filters( 'addquicktag_post_types', $this->get_post_types() );
|
359 |
}
|
360 |
|
366 |
* @return array
|
367 |
*/
|
368 |
public function get_admin_pages_for_js() {
|
|
|
369 |
return apply_filters( 'addquicktag_pages', self::$admin_pages_for_js );
|
370 |
}
|
371 |
|
377 |
* @return string
|
378 |
*/
|
379 |
public function get_textdomain() {
|
|
|
380 |
return $this->get_plugin_data();
|
381 |
}
|
382 |
|
387 |
* @return string
|
388 |
*/
|
389 |
public function get_option_string() {
|
|
|
390 |
return self::$option_string;
|
391 |
}
|
392 |
|
addquicktag_cpt.php.example
DELETED
@@ -1,36 +0,0 @@
|
|
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
DELETED
@@ -1,50 +0,0 @@
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/dashicons-picker.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.dashicon-picker-container{position:absolute;width:220px;height:252px;font-size:14px;background-color:#fff;-webkit-box-shadow:0 1px 2px rgba(0,0,0,.1);box-shadow:0 1px 2px rgba(0,0,0,.1);overflow:hidden;padding:5px;box-sizing:border-box}.dashicon-picker-container ul{margin:0
|
1 |
+
.dashicon-picker-container{position:absolute;width:220px;height:252px;font-size:14px;background-color:#fff;-webkit-box-shadow:0 1px 2px rgba(0,0,0,.1);box-shadow:0 1px 2px rgba(0,0,0,.1);overflow:hidden;padding:5px;box-sizing:border-box}.dashicon-picker-container ul{margin:0;padding:0;margin-bottom:10px}.dashicon-picker-container ul .dashicons{width:20px;height:20px;font-size:20px}.dashicon-picker-container ul li{display:inline-block;margin:5px;float:left}.dashicon-picker-container ul li a{display:block;text-decoration:none;color:#373737;padding:5px 5px;border:1px solid #dfdfdf}.dashicon-picker-container ul li a:hover{border-color:#999;background:#efefef}.dashicon-picker-control{height:32px}.dashicon-picker-control a{padding:5px;text-decoration:none;line-height:32px;width:25px}.dashicon-picker-control a span{display:inline;vertical-align:middle}.dashicon-picker-control input{font-size:12px;width:140px}
|
css/dashicons-picker.dev.css
CHANGED
@@ -10,47 +10,47 @@
|
|
10 |
padding: 5px;
|
11 |
box-sizing: border-box;
|
12 |
}
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
10 |
padding: 5px;
|
11 |
box-sizing: border-box;
|
12 |
}
|
13 |
+
.dashicon-picker-container ul {
|
14 |
+
margin: 0;
|
15 |
+
padding: 0;
|
16 |
+
margin-bottom: 10px;
|
17 |
+
}
|
18 |
+
.dashicon-picker-container ul .dashicons {
|
19 |
+
width: 20px;
|
20 |
+
height: 20px;
|
21 |
+
font-size: 20px;
|
22 |
+
}
|
23 |
+
.dashicon-picker-container ul li {
|
24 |
+
display: inline-block;
|
25 |
+
margin: 5px;
|
26 |
+
float: left;
|
27 |
+
}
|
28 |
+
.dashicon-picker-container ul li a {
|
29 |
+
display: block;
|
30 |
+
text-decoration: none;
|
31 |
+
color: #373737;
|
32 |
+
padding: 5px 5px;
|
33 |
+
border: 1px solid #dfdfdf;
|
34 |
+
}
|
35 |
+
.dashicon-picker-container ul li a:hover {
|
36 |
+
border-color: #999;
|
37 |
+
background: #efefef;
|
38 |
+
}
|
39 |
|
40 |
+
.dashicon-picker-control {
|
41 |
+
height: 32px;
|
42 |
+
}
|
43 |
+
.dashicon-picker-control a {
|
44 |
+
padding: 5px;
|
45 |
+
text-decoration: none;
|
46 |
+
line-height: 32px;
|
47 |
+
width: 25px;
|
48 |
+
}
|
49 |
+
.dashicon-picker-control a span {
|
50 |
+
display: inline;
|
51 |
+
vertical-align: middle;
|
52 |
+
}
|
53 |
+
.dashicon-picker-control input {
|
54 |
+
font-size: 12px;
|
55 |
+
width: 140px;
|
56 |
+
}
|
css/settings.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.fixed{top:0;position:fixed;width:auto;z-index:999;display:none;border:none}.rmnlQuicktagSettings .rmnlqsheader{height:10em;vertical-align:bottom}.hover,table tr:hover{background-color:#ccc}.rmnlCodeQuicktagSettings th,.rmnlCoreQuicktagSettings th,.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;-webkit-transform:rotate(270deg);-moz-transform:rotate(270deg);-ms-transform:rotate(270deg);-o-transform:rotate(270deg);transform:rotate(270deg)
|
1 |
+
.fixed{top:0;position:fixed;width:auto;z-index:999;display:none;border:none}.rmnlQuicktagSettings .rmnlqsheader{height:10em;vertical-align:bottom}.hover,table tr:hover{background-color:#ccc}.rmnlCodeQuicktagSettings th,.rmnlCoreQuicktagSettings th,.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;filter:flipv fliph;-webkit-transform:rotate(270deg);-moz-transform:rotate(270deg);-ms-transform:rotate(270deg);-o-transform:rotate(270deg);transform:rotate(270deg)}.rmnlQuicktagSettings input[type=text]{height:3.5em;width:99%;margin:0 0 .5em 0}.rmnlQuicktagSettings input[type=text].small{height:auto;width:80%;margin:0 0 .5em 0}.rmnlQuicktagSettings button{padding:0 2px!important;font-size:20px!important;width:auto!important}.rmnlQuicktagSettings textarea{height:3.5em;width:99%;margin:0 0 .2em 0}
|
inc/class-code-quicktags.php
CHANGED
@@ -25,7 +25,10 @@ class Add_Quicktag_Code_Quicktags extends Add_Quicktag_Settings {
|
|
25 |
*
|
26 |
* @var
|
27 |
*/
|
28 |
-
private static $code_quicktags = array(
|
|
|
|
|
|
|
29 |
|
30 |
/**
|
31 |
* Handler for the action 'init'. Instantiates this class.
|
@@ -35,10 +38,9 @@ class Add_Quicktag_Code_Quicktags extends Add_Quicktag_Settings {
|
|
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 (
|
42 |
$instance = new self();
|
43 |
}
|
44 |
|
@@ -46,26 +48,24 @@ class Add_Quicktag_Code_Quicktags extends Add_Quicktag_Settings {
|
|
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[
|
69 |
}
|
70 |
?>
|
71 |
<h3><?php esc_html_e( 'Enhanced Code Quicktag buttons', 'addquicktag' ); ?></h3>
|
@@ -76,11 +76,11 @@ class Add_Quicktag_Code_Quicktags extends Add_Quicktag_Settings {
|
|
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 |
-
//
|
80 |
$pt_title = '';
|
81 |
$pt_colgroup = '';
|
82 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
83 |
-
$pt_title
|
84 |
$pt_colgroup .= '<colgroup></colgroup>' . "\n";
|
85 |
}
|
86 |
?>
|
@@ -100,30 +100,26 @@ class Add_Quicktag_Code_Quicktags extends Add_Quicktag_Settings {
|
|
100 |
|
101 |
<tbody>
|
102 |
<?php
|
103 |
-
//
|
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 |
-
//
|
113 |
$pt_checkboxes = '';
|
114 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
115 |
-
|
116 |
$pt_checked = '';
|
117 |
-
if ( isset( $options[
|
118 |
-
&& 1 === (int) $options[
|
119 |
) {
|
120 |
$pt_checked = ' checked="checked"';
|
121 |
}
|
122 |
|
123 |
$pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
}
|
128 |
echo $pt_checkboxes;
|
129 |
|
@@ -132,13 +128,10 @@ class Add_Quicktag_Code_Quicktags extends Add_Quicktag_Settings {
|
|
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 |
-
|
142 |
}
|
143 |
|
144 |
} // end class
|
25 |
*
|
26 |
* @var
|
27 |
*/
|
28 |
+
private static $code_quicktags = array(
|
29 |
+
'enhanced_code' => 'pre',
|
30 |
+
'en_de_coding' => 'htmlentities',
|
31 |
+
);
|
32 |
|
33 |
/**
|
34 |
* Handler for the action 'init'. Instantiates this class.
|
38 |
* @return \Add_Quicktag|\Add_Quicktag_Code_Quicktags|\Add_Quicktag_Settings $instance
|
39 |
*/
|
40 |
public static function get_object() {
|
|
|
41 |
static $instance;
|
42 |
|
43 |
+
if ( null === $instance ) {
|
44 |
$instance = new self();
|
45 |
}
|
46 |
|
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 |
*/
|
57 |
private function __construct() {
|
|
|
58 |
add_action( 'addquicktag_settings_form_page', array( $this, 'get_code_quicktag_area' ) );
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
+
* Add settings area.
|
63 |
*
|
64 |
+
* @param array $options Store options content.
|
65 |
*/
|
66 |
public function get_code_quicktag_area( $options ) {
|
|
|
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>
|
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 |
?>
|
100 |
|
101 |
<tbody>
|
102 |
<?php
|
103 |
+
// Loop over items to remove and unset them from the buttons.
|
|
|
|
|
104 |
$i = 9999;
|
105 |
foreach ( self::$code_quicktags as $key => $value ) {
|
|
|
106 |
echo '<tr id="rmqtb' . $i . '">' . "\n";
|
107 |
echo '<td><input type="button" class="ed_button" title="" value="' . $value . '"></td>';
|
108 |
|
109 |
+
// Loop about the post types, create html an values.
|
110 |
$pt_checkboxes = '';
|
111 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
|
|
112 |
$pt_checked = '';
|
113 |
+
if ( isset( $options['code_buttons'][ $value ][ $post_type ] )
|
114 |
+
&& 1 === (int) $options['code_buttons'][ $value ][ $post_type ]
|
115 |
) {
|
116 |
$pt_checked = ' checked="checked"';
|
117 |
}
|
118 |
|
119 |
$pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
|
120 |
+
parent::get_option_string() . '[code_buttons][' .
|
121 |
+
$value . '][' . $post_type . ']" value="1"' .
|
122 |
+
$pt_checked . '/></td>' . "\n";
|
123 |
}
|
124 |
echo $pt_checkboxes;
|
125 |
|
128 |
echo '</tr>' . "\n";
|
129 |
$i ++;
|
130 |
}
|
|
|
|
|
|
|
131 |
?>
|
132 |
</tbody>
|
133 |
</table>
|
134 |
+
<?php
|
135 |
}
|
136 |
|
137 |
} // end class
|
inc/class-imexport.php
CHANGED
@@ -1,232 +1,245 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* AddQuicktag - Settings
|
4 |
-
*
|
5 |
-
* @license GPLv3
|
6 |
-
* @package AddQuicktag
|
7 |
-
* @subpackage AddQuicktag Settings
|
8 |
-
* @author Frank Bueltge <frank@bueltge.de>
|
9 |
-
* @version 06/19/2014
|
10 |
-
*/
|
11 |
-
|
12 |
-
if ( ! function_exists( 'add_action' ) ) {
|
13 |
-
echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
|
14 |
-
exit;
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Class Add_Quicktag_Im_Export
|
19 |
-
*/
|
20 |
-
class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
|
21 |
-
|
22 |
-
/**
|
23 |
-
*
|
24 |
-
*
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
*
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
*
|
52 |
-
*
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
*
|
69 |
-
*
|
70 |
-
* @
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
self::$
|
76 |
-
self::$
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
*
|
92 |
-
*
|
93 |
-
* @
|
94 |
-
* @
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
<input type="
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
<input type="
|
130 |
-
<input type="
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
*
|
141 |
-
*
|
142 |
-
* @
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
147 |
-
return;
|
148 |
-
}
|
149 |
-
|
150 |
-
check_admin_referer( parent
|
151 |
-
|
152 |
-
if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
|
153 |
-
$options = get_site_option( self::$option_string );
|
154 |
-
} else {
|
155 |
-
$options = get_option( self::$option_string );
|
156 |
-
}
|
157 |
-
|
158 |
-
ignore_user_abort(
|
159 |
-
|
160 |
-
nocache_headers();
|
161 |
-
header( 'Content-Type: application/json; charset=utf-8' );
|
162 |
-
header( 'Content-Disposition: attachment; filename=addquicktag.-' .
|
163 |
-
header( 'Expires: 0' );
|
164 |
-
|
165 |
-
echo json_encode( $options );
|
166 |
-
exit;
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Import json and update settings
|
171 |
-
*
|
172 |
-
* @access public
|
173 |
-
* @since 2.0.0
|
174 |
-
*
|
175 |
-
* @internal param bool|string $filename
|
176 |
-
*
|
177 |
-
* @uses current_user_can, wp_die, is_plugin_active_for_network, update_site_option, update_option
|
178 |
-
* @return void
|
179 |
-
*/
|
180 |
-
public function import_file() {
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
$
|
203 |
-
|
204 |
-
if (
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* AddQuicktag - Settings
|
4 |
+
*
|
5 |
+
* @license GPLv3
|
6 |
+
* @package AddQuicktag
|
7 |
+
* @subpackage AddQuicktag Settings
|
8 |
+
* @author Frank Bueltge <frank@bueltge.de>
|
9 |
+
* @version 06/19/2014
|
10 |
+
*/
|
11 |
+
|
12 |
+
if ( ! function_exists( 'add_action' ) ) {
|
13 |
+
echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
|
14 |
+
exit;
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Class Add_Quicktag_Im_Export
|
19 |
+
*/
|
20 |
+
class Add_Quicktag_Im_Export extends Add_Quicktag_Settings {
|
21 |
+
|
22 |
+
/**
|
23 |
+
* String for translation.
|
24 |
+
*
|
25 |
+
* @var string
|
26 |
+
*/
|
27 |
+
public static $textdomain;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* String for options in table options.
|
31 |
+
*
|
32 |
+
* @var string
|
33 |
+
*/
|
34 |
+
private static $option_string;
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Store string for plugin file.
|
38 |
+
*
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
private static $plugin;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Post types for the settings.
|
45 |
+
*
|
46 |
+
* @var array
|
47 |
+
*/
|
48 |
+
private static $post_types_for_js;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Handler for the action 'init'. Instantiates this class.
|
52 |
+
*
|
53 |
+
* @access public
|
54 |
+
* @since 2.0.0
|
55 |
+
* @return \Add_Quicktag|\Add_Quicktag_Im_Export|\Add_Quicktag_Settings $instance
|
56 |
+
*/
|
57 |
+
public static function get_object() {
|
58 |
+
static $instance;
|
59 |
+
|
60 |
+
if ( null === $instance ) {
|
61 |
+
$instance = new self();
|
62 |
+
}
|
63 |
+
|
64 |
+
return $instance;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Constructor, init on defined hooks of WP and include second class
|
69 |
+
*
|
70 |
+
* @access public
|
71 |
+
* @since 0.0.2
|
72 |
+
* @uses register_activation_hook, register_uninstall_hook, add_action
|
73 |
+
*/
|
74 |
+
private function __construct() {
|
75 |
+
self::$option_string = parent::get_option_string();
|
76 |
+
self::$plugin = parent::get_plugin_string();
|
77 |
+
self::$post_types_for_js = parent::get_post_types_for_js();
|
78 |
+
|
79 |
+
if ( isset( $_GET['addquicktag_download'] ) && check_admin_referer( parent::$nonce_string ) ) {
|
80 |
+
$this->get_export_file();
|
81 |
+
}
|
82 |
+
|
83 |
+
if ( isset( $_POST['addquicktag_import'] ) && check_admin_referer( parent::$nonce_string ) ) {
|
84 |
+
$this->import_file();
|
85 |
+
}
|
86 |
+
|
87 |
+
add_action( 'addquicktag_settings_page', array( $this, 'get_im_export_part' ) );
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Get markup for ex- and import on settings page.
|
92 |
+
*
|
93 |
+
* @access public
|
94 |
+
* @since 2.0.0
|
95 |
+
* @uses wp_nonce_field
|
96 |
+
*/
|
97 |
+
public function get_im_export_part() {
|
98 |
+
|
99 |
+
?>
|
100 |
+
<div class="postbox">
|
101 |
+
<h3><span><?php esc_html_e( 'Export', 'addquicktag' ); ?></span></h3>
|
102 |
+
|
103 |
+
<div class="inside">
|
104 |
+
<p><?php esc_html_e( 'When you click the button below the plugin will create an JSON file for you to save to your computer.', 'addquicktag' ); ?></p>
|
105 |
+
|
106 |
+
<p><?php esc_html_e( 'This format, a custom JSON, will contain your options from quicktags.', 'addquicktag' ); ?></p>
|
107 |
+
|
108 |
+
<p><?php esc_html_e( 'Once you’ve saved the download file, you can use the Import function in another WordPress installation to import this site.', 'addquicktag' ); ?></p>
|
109 |
+
|
110 |
+
<form method="get" action="">
|
111 |
+
<?php wp_nonce_field( parent::$nonce_string ); ?>
|
112 |
+
<p class="submit">
|
113 |
+
<input type="submit" name="submit" value="<?php esc_html_e( 'Download Export File', 'addquicktag' ); ?> »" />
|
114 |
+
<input type="hidden" name="addquicktag_download" value="true" />
|
115 |
+
</p>
|
116 |
+
</form>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
|
120 |
+
<div class="postbox">
|
121 |
+
<h3><span><?php esc_html_e( 'Import', 'addquicktag' ); ?></span></h3>
|
122 |
+
|
123 |
+
<div class="inside">
|
124 |
+
<p><?php esc_html_e( 'If you have quicktags from other installs, the plugin can import those into this site. To get started, choose a file to import. (json-Format)', 'addquicktag' ); ?></p>
|
125 |
+
|
126 |
+
<form method="post" action="" enctype="multipart/form-data">
|
127 |
+
<?php wp_nonce_field( parent::$nonce_string ); ?>
|
128 |
+
<p class="submit">
|
129 |
+
<input type="file" name="import_file" />
|
130 |
+
<input type="submit" name="submit" value="<?php esc_html_e( 'Upload file and import', 'addquicktag' ); ?> »" />
|
131 |
+
<input type="hidden" name="addquicktag_import" value="true" />
|
132 |
+
</p>
|
133 |
+
</form>
|
134 |
+
</div>
|
135 |
+
</div>
|
136 |
+
<?php
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Build export file, json
|
141 |
+
*
|
142 |
+
* @access public
|
143 |
+
* @since 2.0.0
|
144 |
+
*/
|
145 |
+
public function get_export_file() {
|
146 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
147 |
+
return;
|
148 |
+
}
|
149 |
+
|
150 |
+
check_admin_referer( parent::$nonce_string );
|
151 |
+
|
152 |
+
if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
|
153 |
+
$options = get_site_option( self::$option_string );
|
154 |
+
} else {
|
155 |
+
$options = get_option( self::$option_string );
|
156 |
+
}
|
157 |
+
|
158 |
+
ignore_user_abort( true );
|
159 |
+
|
160 |
+
nocache_headers();
|
161 |
+
header( 'Content-Type: application/json; charset=utf-8' );
|
162 |
+
header( 'Content-Disposition: attachment; filename=addquicktag.-' . gmdate( 'm-d-Y' ) . '.json' );
|
163 |
+
header( 'Expires: 0' );
|
164 |
+
|
165 |
+
echo json_encode( $options );
|
166 |
+
exit;
|
167 |
+
}
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Import json and update settings
|
171 |
+
*
|
172 |
+
* @access public
|
173 |
+
* @since 2.0.0
|
174 |
+
*
|
175 |
+
* @internal param bool|string $filename
|
176 |
+
*
|
177 |
+
* @uses current_user_can, wp_die, is_plugin_active_for_network, update_site_option, update_option
|
178 |
+
* @return void
|
179 |
+
*/
|
180 |
+
public function import_file() {
|
181 |
+
if ( ! current_user_can( 'manage_options' ) ) {
|
182 |
+
wp_die( esc_html__( 'Options not update - you don‘t have the privileges to do this!', 'addquicktag' ) );
|
183 |
+
}
|
184 |
+
|
185 |
+
check_admin_referer( parent::$nonce_string );
|
186 |
+
|
187 |
+
if ( ! isset( $_FILES ) || ! isset( $_FILES['import_file']['name'] ) ) {
|
188 |
+
wp_die( esc_html__( 'Please upload a file to import.', 'addquicktag' ) );
|
189 |
+
}
|
190 |
+
|
191 |
+
$extension = explode( '.', sanitize_file_name( wp_unslash( $_FILES['import_file']['name'] ) ) );
|
192 |
+
$extension = end( $extension );
|
193 |
+
|
194 |
+
if ( 'json' !== $extension ) {
|
195 |
+
wp_die( esc_html__( 'Please upload a valid .json file', 'addquicktag' ) );
|
196 |
+
}
|
197 |
+
|
198 |
+
if ( ! isset( $_FILES['import_file']['tmp_name'] ) ) {
|
199 |
+
wp_die( esc_html__( 'Please upload a file to import.', 'addquicktag' ) );
|
200 |
+
}
|
201 |
+
|
202 |
+
$import_file = sanitize_file_name( wp_unslash( $_FILES['import_file']['tmp_name'] ) );
|
203 |
+
|
204 |
+
if ( empty( $import_file ) ) {
|
205 |
+
wp_die( esc_html__( 'Please upload a file to import.', 'addquicktag' ) );
|
206 |
+
}
|
207 |
+
|
208 |
+
// Retrieve the settings from the file and convert the json object to an array.
|
209 |
+
$options = (array) json_decode( file_get_contents( $import_file ), true );
|
210 |
+
|
211 |
+
if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
|
212 |
+
update_site_option( self::$option_string, $options );
|
213 |
+
} else {
|
214 |
+
update_option( self::$option_string, $options );
|
215 |
+
}
|
216 |
+
|
217 |
+
// Redirect to settings page in network.
|
218 |
+
if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
|
219 |
+
wp_safe_redirect(
|
220 |
+
add_query_arg(
|
221 |
+
array(
|
222 |
+
'page' => self::$plugin,
|
223 |
+
'updated' => 'true',
|
224 |
+
),
|
225 |
+
network_admin_url( 'settings.php' )
|
226 |
+
)
|
227 |
+
);
|
228 |
+
} else {
|
229 |
+
$page = str_replace( basename( __FILE__ ), 'class-settings.php', plugin_basename( __FILE__ ) );
|
230 |
+
wp_safe_redirect(
|
231 |
+
add_query_arg(
|
232 |
+
array(
|
233 |
+
'page' => $page,
|
234 |
+
'updated' => 'true',
|
235 |
+
),
|
236 |
+
admin_url( 'options-general.php' )
|
237 |
+
)
|
238 |
+
);
|
239 |
+
}
|
240 |
+
exit;
|
241 |
+
}
|
242 |
+
|
243 |
+
} // end class
|
244 |
+
|
245 |
+
$add_quicktag_im_export = Add_Quicktag_Im_Export::get_object();
|
inc/class-remove-quicktags.php
CHANGED
@@ -1,158 +1,158 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* AddQuicktag - Settings to remove core quicktags
|
4 |
-
*
|
5 |
-
* @package AddQuicktag
|
6 |
-
* @subpackage AddQuicktag Settings
|
7 |
-
* @author Frank Bueltge <frank@bueltge.de>
|
8 |
-
* @version 2015-12-23
|
9 |
-
*/
|
10 |
-
|
11 |
-
if ( ! function_exists( 'add_action' ) ) {
|
12 |
-
echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
|
13 |
-
exit;
|
14 |
-
}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Class Add_Quicktag_Remove_Quicktags
|
18 |
-
*/
|
19 |
-
class Add_Quicktag_Remove_Quicktags extends Add_Quicktag_Settings {
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
*
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
*
|
47 |
-
*
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
*
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
<
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
$
|
72 |
-
|
73 |
-
|
74 |
-
$
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
<
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
</
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
$
|
103 |
-
|
104 |
-
|
105 |
-
$
|
106 |
-
|
107 |
-
|
108 |
-
$
|
109 |
-
|
110 |
-
|
111 |
-
$
|
112 |
-
|
113 |
-
|
114 |
-
$
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
echo '<
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
$pt_checked = '';
|
129 |
-
if ( isset( $options[
|
130 |
-
&& 1 === (int) $options[
|
131 |
-
$pt_checked = ' checked="checked"';
|
132 |
-
}
|
133 |
-
|
134 |
-
$pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
}
|
139 |
-
echo $pt_checkboxes;
|
140 |
-
|
141 |
-
echo '<td class="num"><input type="checkbox" class="toggle" id="select_all_'
|
142 |
-
. $i . '" value="' . $i . '" /></td>' . "\n";
|
143 |
-
|
144 |
-
echo '</tr>' . "\n";
|
145 |
-
$i ++;
|
146 |
-
}
|
147 |
-
|
148 |
-
// Convert new buttons array back into a comma-separated string
|
149 |
-
$core_qt = implode( ',', $core_buttons );
|
150 |
-
?>
|
151 |
-
</tbody>
|
152 |
-
</table>
|
153 |
-
|
154 |
-
}
|
155 |
-
|
156 |
-
} // end class
|
157 |
-
|
158 |
-
$add_quicktag_remove_quicktags = Add_Quicktag_Remove_Quicktags::get_object();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* AddQuicktag - Settings to remove core quicktags
|
4 |
+
*
|
5 |
+
* @package AddQuicktag
|
6 |
+
* @subpackage AddQuicktag Settings
|
7 |
+
* @author Frank Bueltge <frank@bueltge.de>
|
8 |
+
* @version 2015-12-23
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! function_exists( 'add_action' ) ) {
|
12 |
+
echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
|
13 |
+
exit;
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Class Add_Quicktag_Remove_Quicktags
|
18 |
+
*/
|
19 |
+
class Add_Quicktag_Remove_Quicktags extends Add_Quicktag_Settings {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Default buttons from WP Core.
|
23 |
+
*
|
24 |
+
* @var string
|
25 |
+
*/
|
26 |
+
private static $core_quicktags = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,fullscreen';
|
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_Remove_Quicktags|\Add_Quicktag_Settings $instance
|
34 |
+
*/
|
35 |
+
public static function get_object() {
|
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 |
+
*/
|
52 |
+
private function __construct() {
|
53 |
+
add_action( 'addquicktag_settings_form_page', array( $this, 'get_remove_quicktag_area' ) );
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Add settings area.
|
58 |
+
*
|
59 |
+
* @param array $options Store options content.
|
60 |
+
*/
|
61 |
+
public function get_remove_quicktag_area( $options ) {
|
62 |
+
if ( ! array_key_exists( 'core_buttons', $options ) ) {
|
63 |
+
$options['core_buttons'] = array();
|
64 |
+
}
|
65 |
+
?>
|
66 |
+
<h3><?php esc_html_e( 'Remove Core Quicktag buttons', 'addquicktag' ); ?></h3>
|
67 |
+
<p><?php esc_html_e( 'Select the checkbox below to remove a core quicktags in the editors of the respective post type.', 'addquicktag' ); ?></p>
|
68 |
+
|
69 |
+
<?php
|
70 |
+
// Loop about the post types, create html an values for title in table.
|
71 |
+
$pt_title = '';
|
72 |
+
$pt_colgroup = '';
|
73 |
+
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
74 |
+
$pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
|
75 |
+
$pt_colgroup .= '<colgroup></colgroup>' . "\n";
|
76 |
+
}
|
77 |
+
?>
|
78 |
+
|
79 |
+
<table class="widefat form-table rmnlCoreQuicktagSettings">
|
80 |
+
<colgroup></colgroup>
|
81 |
+
<?php echo $pt_colgroup; ?>
|
82 |
+
<colgroup></colgroup>
|
83 |
+
|
84 |
+
<thead>
|
85 |
+
<tr>
|
86 |
+
<th class="row-title"><?php esc_html_e( 'Button', 'addquicktag' ); ?></th>
|
87 |
+
<?php echo $pt_title; ?>
|
88 |
+
<th class="row-title num" style="width:3%;">✔</th>
|
89 |
+
</tr>
|
90 |
+
</thead>
|
91 |
+
|
92 |
+
<tbody>
|
93 |
+
<?php
|
94 |
+
// Convert string to array.
|
95 |
+
$core_buttons = explode( ',', self::$core_quicktags );
|
96 |
+
// Loop over items to remove and unset them from the buttons.
|
97 |
+
$i = 999;
|
98 |
+
foreach ( $core_buttons as $key => $value ) {
|
99 |
+
|
100 |
+
// Same style as in editor.
|
101 |
+
if ( 'strong' === $value ) {
|
102 |
+
$text = 'b';
|
103 |
+
$style = ' style="font-weight: bold;"';
|
104 |
+
} elseif ( 'em' === $value ) {
|
105 |
+
$text = 'i';
|
106 |
+
$style = ' style="font-style: italic;"';
|
107 |
+
} elseif ( 'link' === $value ) {
|
108 |
+
$text = $value;
|
109 |
+
$style = ' style="text-decoration: underline;"';
|
110 |
+
} elseif ( 'del' === $value ) {
|
111 |
+
$text = $value;
|
112 |
+
$style = ' style="text-decoration: line-through;"';
|
113 |
+
} elseif ( 'block' === $value ) {
|
114 |
+
$text = 'b-quote';
|
115 |
+
$style = '';
|
116 |
+
} else {
|
117 |
+
$text = $value;
|
118 |
+
$style = '';
|
119 |
+
}
|
120 |
+
|
121 |
+
echo '<tr id="rmqtb' . $i . '">' . "\n";
|
122 |
+
echo '<td><input type="button" class="ed_button" title="" value="'
|
123 |
+
. $text . '"' . $style . '> <code>' . $value . '</code></td>';
|
124 |
+
|
125 |
+
// Loop about the post types, create html an values.
|
126 |
+
$pt_checkboxes = '';
|
127 |
+
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
128 |
+
$pt_checked = '';
|
129 |
+
if ( isset( $options['core_buttons'][ $value ][ $post_type ] )
|
130 |
+
&& 1 === (int) $options['core_buttons'][ $value ][ $post_type ] ) {
|
131 |
+
$pt_checked = ' checked="checked"';
|
132 |
+
}
|
133 |
+
|
134 |
+
$pt_checkboxes .= '<td class="num"><input type="checkbox" name="' .
|
135 |
+
parent::get_option_string() . '[core_buttons][' .
|
136 |
+
$value . '][' . $post_type . ']" value="1"' .
|
137 |
+
$pt_checked . '/></td>' . "\n";
|
138 |
+
}
|
139 |
+
echo $pt_checkboxes;
|
140 |
+
|
141 |
+
echo '<td class="num"><input type="checkbox" class="toggle" id="select_all_'
|
142 |
+
. $i . '" value="' . $i . '" /></td>' . "\n";
|
143 |
+
|
144 |
+
echo '</tr>' . "\n";
|
145 |
+
$i ++;
|
146 |
+
}
|
147 |
+
|
148 |
+
// Convert new buttons array back into a comma-separated string.
|
149 |
+
$core_qt = implode( ',', $core_buttons );
|
150 |
+
?>
|
151 |
+
</tbody>
|
152 |
+
</table>
|
153 |
+
<?php
|
154 |
+
}
|
155 |
+
|
156 |
+
} // end class
|
157 |
+
|
158 |
+
$add_quicktag_remove_quicktags = Add_Quicktag_Remove_Quicktags::get_object();
|
inc/class-settings.php
CHANGED
@@ -20,42 +20,44 @@ if ( ! function_exists( 'add_action' ) ) {
|
|
20 |
class Add_Quicktag_Settings extends Add_Quicktag {
|
21 |
|
22 |
/**
|
23 |
-
*
|
24 |
*
|
25 |
* @var string
|
26 |
*/
|
27 |
-
static
|
28 |
|
29 |
/**
|
30 |
-
*
|
31 |
*
|
32 |
* @var string
|
33 |
*/
|
34 |
-
static
|
35 |
|
36 |
/**
|
37 |
-
*
|
38 |
*
|
39 |
* @var string
|
40 |
*/
|
41 |
-
static
|
42 |
|
43 |
/**
|
44 |
-
*
|
45 |
*
|
46 |
* @var array
|
47 |
*/
|
48 |
-
static
|
49 |
|
50 |
/**
|
51 |
-
*
|
52 |
*
|
53 |
* @var string
|
54 |
*/
|
55 |
-
static
|
56 |
|
57 |
/**
|
58 |
-
*
|
|
|
|
|
59 |
*/
|
60 |
protected $page_hook;
|
61 |
|
@@ -67,10 +69,9 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
67 |
* @return \Add_Quicktag|\Add_Quicktag_Settings $instance
|
68 |
*/
|
69 |
public static function get_object() {
|
70 |
-
|
71 |
static $instance;
|
72 |
|
73 |
-
if (
|
74 |
$instance = new self();
|
75 |
}
|
76 |
|
@@ -85,7 +86,6 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
85 |
* @uses register_activation_hook, register_uninstall_hook, add_action
|
86 |
*/
|
87 |
private function __construct() {
|
88 |
-
|
89 |
if ( ! is_admin() ) {
|
90 |
return;
|
91 |
}
|
@@ -95,90 +95,91 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
95 |
self::$post_types_for_js = parent::get_post_types_for_js();
|
96 |
self::$nonce_string = 'addquicktag_nonce';
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
|
103 |
register_uninstall_hook( __FILE__, array( 'Add_Quicktag_Settings', 'unregister_settings' ) );
|
104 |
-
//
|
105 |
if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
|
106 |
add_action( 'network_admin_menu', array( $this, 'add_settings_page' ) );
|
107 |
-
// add settings link
|
108 |
add_filter(
|
109 |
-
'network_admin_plugin_action_links',
|
110 |
-
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
113 |
);
|
114 |
-
//
|
115 |
add_action( 'network_admin_edit_' . self::$option_string, array( $this, 'save_network_settings_page' ) );
|
116 |
-
//
|
117 |
add_action( 'network_admin_notices', array( $this, 'get_network_admin_notices' ) );
|
118 |
-
//
|
119 |
} else {
|
120 |
add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
|
121 |
-
//
|
122 |
add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 );
|
123 |
-
//
|
124 |
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
125 |
}
|
126 |
-
//
|
127 |
add_action(
|
128 |
'admin_print_scripts-settings_page_' . str_replace( '.php', '', plugin_basename( __FILE__ ) ),
|
129 |
array( $this, 'print_scripts' )
|
130 |
);
|
131 |
|
132 |
-
//
|
133 |
add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_plugin_infos' ) );
|
134 |
add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_about_plugin' ) );
|
135 |
|
136 |
-
//
|
137 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-remove-quicktags.php';
|
138 |
-
//
|
139 |
-
// @TODO Solution for special code tags in quicktags
|
140 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-code-quicktags.php';
|
141 |
-
//
|
142 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-imexport.php';
|
143 |
}
|
144 |
|
145 |
/**
|
146 |
-
* Return allowed post types for include scripts
|
147 |
*
|
148 |
* @since 2.1.1
|
149 |
* @access public
|
150 |
* @return array
|
151 |
*/
|
152 |
public function get_post_types_for_js() {
|
153 |
-
|
154 |
return self::$post_types_for_js;
|
155 |
}
|
156 |
|
157 |
/**
|
158 |
-
* Add settings link on plugins.php in backend
|
159 |
*
|
160 |
* @uses
|
161 |
* @access public
|
162 |
*
|
163 |
-
* @param array $links
|
164 |
-
* @param string $file
|
165 |
*
|
166 |
* @since 2.0.0
|
167 |
* @return string $links
|
168 |
*/
|
169 |
public function plugin_action_links( $links, $file ) {
|
170 |
-
|
171 |
if ( parent::get_plugin_string() === $file ) {
|
172 |
$links[] = '<a href="options-general.php?page=' . plugin_basename( __FILE__ ) . '">' . esc_html__(
|
173 |
-
|
174 |
-
|
175 |
}
|
176 |
|
177 |
return $links;
|
178 |
}
|
179 |
|
180 |
/**
|
181 |
-
* Add settings link on plugins.php on network admin in backend
|
182 |
*
|
183 |
* @uses
|
184 |
* @access public
|
@@ -190,25 +191,23 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
190 |
* @return string $links
|
191 |
*/
|
192 |
public function network_admin_plugin_action_links( $links, $file ) {
|
193 |
-
|
194 |
if ( parent::get_plugin_string() === $file ) {
|
195 |
$links[] = '<a href="settings.php?page=' . plugin_basename( __FILE__ ) . '">' . esc_html__(
|
196 |
-
|
197 |
-
|
198 |
}
|
199 |
|
200 |
return $links;
|
201 |
}
|
202 |
|
203 |
/**
|
204 |
-
* Add settings page in WP backend
|
205 |
*
|
206 |
* @uses add_options_page
|
207 |
* @access public
|
208 |
* @since 2.0.0
|
209 |
*/
|
210 |
public function add_settings_page() {
|
211 |
-
|
212 |
if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
|
213 |
add_submenu_page(
|
214 |
'settings.php',
|
@@ -230,7 +229,7 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
230 |
}
|
231 |
|
232 |
/**
|
233 |
-
* Return form and markup on settings page
|
234 |
*
|
235 |
* @uses settings_fields, normalize_whitespace, is_plugin_active_for_network, get_site_option, get_option
|
236 |
* @access public
|
@@ -244,10 +243,14 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
244 |
|
245 |
<h3><?php esc_html_e( 'Add or delete Quicktag buttons', 'addquicktag' ); ?></h3>
|
246 |
|
247 |
-
<p
|
248 |
-
|
249 |
-
|
250 |
-
|
|
|
|
|
|
|
|
|
251 |
<p><?php esc_html_e( 'Leave the Button Label to don\'t add the button to the quicktags, html mode.', 'addquicktag' ); ?></p>
|
252 |
|
253 |
<?php
|
@@ -267,29 +270,28 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
267 |
}
|
268 |
|
269 |
/** @var array $options */
|
270 |
-
if ( ! isset( $options[
|
271 |
-
$options[
|
272 |
}
|
273 |
|
274 |
-
if ( 1 < count( $options[
|
275 |
-
//
|
276 |
$tmp = array();
|
277 |
-
foreach ( (array) $options[
|
278 |
-
if ( isset( $order[
|
279 |
-
$tmp[] = $order[
|
280 |
} else {
|
281 |
$tmp[] = 0;
|
282 |
}
|
283 |
}
|
284 |
-
array_multisort( $tmp, SORT_ASC, $options[
|
285 |
}
|
286 |
|
287 |
-
//
|
288 |
$pt_title = '';
|
289 |
$pt_colgroup = '';
|
290 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
291 |
-
|
292 |
-
$pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
|
293 |
$pt_colgroup .= '<colgroup></colgroup>' . "\n";
|
294 |
}
|
295 |
?>
|
@@ -313,59 +315,64 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
313 |
<?php esc_html_e( 'Order', 'addquicktag' ); ?></th>
|
314 |
<th class="row-title rotate">
|
315 |
<span><?php esc_html_e( 'Visual', 'addquicktag' ); ?></span></th>
|
316 |
-
<?php echo $pt_title ?>
|
317 |
<th class="row-title rotate">✔</th>
|
318 |
</tr>
|
319 |
</thead>
|
320 |
<tbody>
|
321 |
<?php
|
322 |
-
if ( empty( $options[
|
323 |
-
$options[
|
324 |
}
|
325 |
$class = '';
|
326 |
-
$imax
|
327 |
for ( $i = 0; $i < $imax; $i ++ ) {
|
328 |
-
$class
|
329 |
-
$b
|
330 |
-
$b[
|
331 |
-
stripslashes( $b[
|
|
|
|
|
332 |
);
|
333 |
-
if ( ! isset( $b[
|
334 |
-
$b[
|
335 |
}
|
336 |
-
$b[
|
337 |
-
stripslashes( $b[
|
|
|
|
|
338 |
);
|
339 |
-
if ( isset( $b[
|
340 |
-
$b[
|
341 |
-
stripslashes( $b[
|
|
|
|
|
342 |
);
|
343 |
}
|
344 |
-
$b[
|
345 |
-
if ( isset( $b[
|
346 |
-
$b[
|
347 |
}
|
348 |
-
if ( ! isset( $b[
|
349 |
-
$b[
|
350 |
}
|
351 |
-
$b[
|
352 |
-
if ( ! isset( $b[
|
353 |
-
$b[
|
354 |
}
|
355 |
-
$b[
|
356 |
-
if ( ! isset( $b[
|
357 |
-
$b[
|
358 |
}
|
359 |
-
$b[
|
360 |
-
$checked
|
361 |
-
if ( 1 === $b[
|
362 |
$checked = ' checked="checked"';
|
363 |
}
|
364 |
|
365 |
-
//
|
366 |
$pt_checkboxes = '';
|
367 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
368 |
-
|
369 |
if ( ! isset( $b[ $post_type ] ) ) {
|
370 |
$b[ $post_type ] = 0;
|
371 |
}
|
@@ -388,33 +395,33 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
388 |
<td>
|
389 |
<input type="text" placeholder="' . esc_html__( 'Button Label', 'addquicktag' )
|
390 |
. '" name="' . self::$option_string . '[buttons][' . $i
|
391 |
-
. '][text]" value="' . $b[
|
392 |
<input class="small" id="dashicons_picker_icon_' . $i
|
393 |
. '" type="text" placeholder="' . esc_html__( 'Dashicon', 'addquicktag' )
|
394 |
. '" name="' . self::$option_string . '[buttons][' . $i
|
395 |
-
. '][dashicon]" value="' . $b[
|
396 |
<button type="button" data-target="#dashicons_picker_icon_'
|
397 |
. $i . '"class="button dashicons-picker dashicons dashicons-dashboard"></button>
|
398 |
<br />
|
399 |
<input type="text" placeholder="' . esc_html__( 'Title Attribute', 'addquicktag' )
|
400 |
. '" name="' . self::$option_string . '[buttons][' . $i . '][title]" value="'
|
401 |
-
. $b[
|
402 |
</td>
|
403 |
<td>
|
404 |
<textarea placeholder="' . esc_html__( 'Start Tag(s)*', 'addquicktag' )
|
405 |
. '" class="code" name="' . self::$option_string . '[buttons][' . $i
|
406 |
-
. '][start]" rows="2" cols="25" >' . $b[
|
407 |
<textarea placeholder="' . esc_html__( 'End Tag(s)', 'addquicktag' )
|
408 |
. '" class="code" name="' . self::$option_string . '[buttons][' . $i
|
409 |
-
. '][end]" rows="2" cols="25" >' . $b[
|
410 |
</td>
|
411 |
<td>
|
412 |
<input placeholder="' . esc_html__( 'Access Key', 'addquicktag' )
|
413 |
. '" class="small-text" type="text" name="' . self::$option_string . '[buttons][' . $i
|
414 |
-
. '][access]" value="' . $b[
|
415 |
<input placeholder="' . esc_html__( 'Order', 'addquicktag' )
|
416 |
. '" class="small-text" type="text" name="' . self::$option_string . '[buttons][' . $i
|
417 |
-
. '][order]" value="' . $b[
|
418 |
</td>
|
419 |
<td class="num">
|
420 |
<input type="checkbox" name="' . self::$option_string . '[buttons][' . $i
|
@@ -428,7 +435,7 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
428 |
';
|
429 |
}
|
430 |
|
431 |
-
//
|
432 |
$pt_new_boxes = '';
|
433 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
434 |
if ( ! isset( $b[ $post_type ] ) ) {
|
@@ -442,52 +449,61 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
442 |
$i . '][' . $post_type . ']" value="1" /></td>' . "\n";
|
443 |
}
|
444 |
?>
|
445 |
-
<tr id="rmqtb<?php echo $i ?>">
|
446 |
<td>
|
447 |
-
<input type="text" placeholder="<?php esc_html_e(
|
448 |
-
'Button Label*', 'addquicktag'
|
449 |
-
); ?>"
|
450 |
name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][text]" value="" /><br />
|
451 |
-
<input type="text" class="small" id="dashicons_picker_icon_new" placeholder="
|
452 |
-
esc_html_e( 'Dashicon', 'addquicktag' ); ?>
|
453 |
-
echo self::$option_string; ?>[buttons][<?php echo $i; ?>][dashicon]" value="" />
|
454 |
<button type="button" data-target="#dashicons_picker_icon_new"
|
455 |
class="button dashicons-picker dashicons dashicons-dashboard"></button>
|
456 |
<br />
|
457 |
-
<input type="text" placeholder="<?php esc_html_e(
|
458 |
-
'Title Attribute', 'addquicktag'
|
459 |
-
); ?>"
|
460 |
name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][title]" value="" />
|
461 |
</td>
|
462 |
<td>
|
463 |
<textarea placeholder="<?php esc_html_e( 'Start Tag(s)*', 'addquicktag' ); ?>"
|
464 |
-
class="code" name="<?php echo self::$option_string; ?>[buttons][
|
465 |
-
|
|
|
466 |
<textarea placeholder="<?php esc_html_e( 'End Tag(s)', 'addquicktag' ); ?>"
|
467 |
-
class="code" name="<?php echo self::$option_string; ?>[buttons][
|
468 |
-
|
|
|
469 |
</td>
|
470 |
<td>
|
471 |
-
<input type="text" placeholder="
|
472 |
-
|
473 |
-
|
|
|
|
|
|
|
|
|
|
|
474 |
title="<?php esc_html_e( 'Access Key', 'addquicktag' ); ?>"
|
475 |
-
class="small-text" name="<?php echo self::$option_string; ?>[buttons][
|
476 |
-
|
|
|
|
|
|
|
477 |
<input type="text" placeholder="<?php esc_html_e( 'Order', 'addquicktag' ); ?>"
|
478 |
title="<?php esc_html_e( 'Order', 'addquicktag' ); ?>" class="small-text"
|
479 |
name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][order]" value="" />
|
480 |
</td>
|
481 |
<td class="num">
|
482 |
<label>
|
483 |
-
<input type="checkbox" name="<?php echo self::$option_string; ?>[buttons][
|
484 |
-
|
|
|
|
|
|
|
485 |
</label>
|
486 |
</td>
|
487 |
<?php echo $pt_new_boxes; ?>
|
488 |
<td class="num">
|
489 |
-
<label for="select_all_<?php echo $i ?>">
|
490 |
-
<input type="checkbox" class="toggle" id="select_all_<?php echo $i ?>" value="<?php echo $i ?>" />
|
491 |
</label>
|
492 |
</td>
|
493 |
</tr>
|
@@ -495,13 +511,13 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
495 |
</table>
|
496 |
|
497 |
<p class="submit">
|
498 |
-
<input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes' ) ?>" />
|
499 |
</p>
|
500 |
|
501 |
<?php do_action( 'addquicktag_settings_form_page', $options ); ?>
|
502 |
|
503 |
<p class="submit">
|
504 |
-
<input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes' ) ?>" />
|
505 |
</p>
|
506 |
|
507 |
</form>
|
@@ -529,8 +545,8 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
529 |
}
|
530 |
|
531 |
/*
|
532 |
-
* Return information to donate
|
533 |
-
*
|
534 |
* @uses _e,esc_attr_e
|
535 |
* @access public
|
536 |
* @since 2.0.0
|
@@ -547,37 +563,75 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
547 |
<p><?php esc_html_e( 'Here\'s how you can give back:', 'addquicktag' ); ?></p>
|
548 |
<ul>
|
549 |
<li>
|
550 |
-
<a href="http://wordpress.org/support/view/plugin-reviews/addquicktag" title="
|
551 |
-
|
552 |
-
|
|
|
|
|
|
|
|
|
|
|
553 |
</li>
|
554 |
<li>
|
555 |
-
<a href="http://wordpress.org/support/plugin/addquicktag" title="
|
|
|
|
|
556 |
'Help inside the community other useres and write answer to this plugin questions.',
|
557 |
'addquicktag'
|
558 |
-
);
|
559 |
-
|
560 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
</li>
|
562 |
<li>
|
563 |
-
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6069955" title="
|
564 |
-
|
565 |
-
|
|
|
|
|
|
|
|
|
|
|
566 |
</li>
|
567 |
<li>
|
568 |
-
<a href="http://www.amazon.de/gp/registry/3NTOGEK181L23/ref=wl_s_3" title="
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
</li>
|
574 |
<li>
|
575 |
-
<a href="https://github.com/bueltge/AddQuicktag" title="
|
|
|
|
|
576 |
'Please give me feedback, contribute and file technical bugs on this GitHub Repo, use Issues.',
|
577 |
'addquicktag'
|
578 |
-
);
|
579 |
-
|
580 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
581 |
</li>
|
582 |
</ul>
|
583 |
</div>
|
@@ -585,10 +639,10 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
585 |
<?php
|
586 |
}
|
587 |
|
588 |
-
|
589 |
-
* Return information about the plugin
|
590 |
-
*
|
591 |
-
* @uses _e,esc_attr_e
|
592 |
* @access public
|
593 |
* @since 2.0.0
|
594 |
* @return void
|
@@ -616,93 +670,96 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
616 |
<?php
|
617 |
}
|
618 |
|
619 |
-
|
620 |
-
* Save network settings
|
621 |
-
*
|
622 |
* @uses update_site_option, wp_redirect, add_query_arg, network_admin_url
|
623 |
* @access public
|
624 |
* @since 2.0.0
|
625 |
* @return void
|
626 |
*/
|
627 |
public function save_network_settings_page() {
|
628 |
-
|
629 |
-
if ( ! wp_verify_nonce( $_REQUEST[ '_wpnonce' ], self::$nonce_string ) ) {
|
630 |
wp_die( 'Sorry, you failed the nonce test.' );
|
631 |
}
|
632 |
|
633 |
-
//
|
634 |
-
|
|
|
635 |
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
|
|
|
|
640 |
add_query_arg(
|
641 |
-
array(
|
|
|
|
|
|
|
642 |
network_admin_url( 'settings.php' )
|
643 |
)
|
644 |
);
|
645 |
exit();
|
646 |
}
|
647 |
|
648 |
-
|
649 |
-
* Retrun string vor update message
|
650 |
-
*
|
651 |
-
* @uses
|
652 |
* @access public
|
653 |
* @since 2.0.0
|
654 |
* @return string $notice
|
655 |
*/
|
656 |
public function get_network_admin_notices() {
|
657 |
|
658 |
-
//
|
659 |
if ( array_key_exists(
|
660 |
-
|
661 |
-
|
662 |
-
|
|
|
663 |
) {
|
664 |
$message = esc_html__( 'Options saved.', 'addquicktag' );
|
665 |
-
|
666 |
-
echo $notice;
|
667 |
}
|
668 |
}
|
669 |
|
670 |
/**
|
671 |
-
* Validate settings for options
|
672 |
*
|
673 |
* @uses normalize_whitespace
|
674 |
* @access public
|
675 |
*
|
676 |
-
* @param array $value
|
677 |
*
|
678 |
* @since 2.0.0
|
679 |
* @return string $value
|
680 |
*/
|
681 |
public function validate_settings( $value ) {
|
682 |
|
683 |
-
// Save core buttons changes
|
684 |
if ( array_key_exists( 'core_buttons', $value ) ) {
|
685 |
-
$core_buttons = $value[
|
686 |
}
|
687 |
|
688 |
-
// Save Code buttons
|
689 |
if ( array_key_exists( 'code_buttons', $value ) ) {
|
690 |
-
$code_buttons = $value[
|
691 |
}
|
692 |
|
693 |
-
//
|
694 |
$allowed_settings = (array) array_merge(
|
695 |
$this->get_post_types_for_js(),
|
696 |
array( 'text', 'dashicon', 'title', 'start', 'end', 'access', 'order', 'visual' )
|
697 |
);
|
698 |
|
699 |
$buttons = array();
|
700 |
-
//
|
701 |
-
foreach ( (array) $value[
|
702 |
-
|
703 |
foreach ( (array) $button as $label => $val ) {
|
704 |
-
|
705 |
-
if ( ! in_array( $label, $allowed_settings, TRUE ) ) {
|
706 |
unset( $button[ $label ] );
|
707 |
}
|
708 |
}
|
@@ -710,67 +767,55 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
710 |
$buttons[] = $button;
|
711 |
}
|
712 |
|
713 |
-
//
|
714 |
-
$filtered_values[
|
715 |
-
$value
|
716 |
|
717 |
$buttons = array();
|
718 |
-
$c_buttons = count( $value[
|
719 |
for ( $i = 0; $i < $c_buttons; $i ++ ) {
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
$b[
|
727 |
-
$b[ 'dashicon' ] = sanitize_text_field( $b[ 'dashicon' ] );
|
728 |
-
$b[ 'title' ] = sanitize_text_field( $b[ 'title' ] );
|
729 |
-
$b[ 'start' ] = wp_kses_stripslashes( $b[ 'start' ] );
|
730 |
-
$b[ 'end' ] = wp_kses_stripslashes( $b[ 'end' ] );
|
731 |
|
732 |
if ( array_key_exists( 'access', $b ) ) {
|
733 |
-
$b[
|
734 |
}
|
735 |
|
736 |
if ( array_key_exists( 'order', $b ) ) {
|
737 |
-
$b[
|
738 |
}
|
739 |
|
740 |
-
|
741 |
if ( array_key_exists( 'visual', $b ) ) {
|
742 |
-
$b[
|
743 |
-
} else {
|
744 |
-
$b[ 'visual' ] = 0;
|
745 |
}
|
746 |
|
747 |
-
// post types
|
748 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
749 |
-
|
750 |
if ( array_key_exists( $post_type, $b ) ) {
|
751 |
$b[ $post_type ] = (int) $b[ $post_type ];
|
752 |
-
} else {
|
753 |
-
$b[ $post_type ] = 0;
|
754 |
}
|
755 |
-
|
756 |
}
|
757 |
|
758 |
$buttons[] = $b;
|
759 |
}
|
760 |
-
|
761 |
}
|
762 |
-
$value[
|
763 |
-
// Check for wrong empty values and kill
|
764 |
-
foreach ( $value[
|
765 |
-
|
766 |
-
|
767 |
-
unset( $value[ 'buttons' ][ $key ] );
|
768 |
}
|
769 |
}
|
770 |
-
//
|
771 |
-
$value[
|
772 |
|
773 |
-
// Filter core button values, strings and convert to integer
|
774 |
if ( ! empty( $core_buttons ) ) {
|
775 |
|
776 |
/**
|
@@ -784,44 +829,37 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
784 |
*/
|
785 |
$filtered_core_buttons = array();
|
786 |
foreach ( (array) $core_buttons as $key => $var ) {
|
787 |
-
|
788 |
$core_button = array();
|
789 |
foreach ( (array) $var as $post_type => $val ) {
|
790 |
$core_button[ $post_type ] = (int) $val;
|
791 |
}
|
792 |
|
793 |
$filtered_core_buttons[ $key ] = $core_button;
|
794 |
-
|
795 |
}
|
796 |
|
797 |
-
$value[
|
798 |
-
|
799 |
}
|
800 |
|
801 |
-
// Filter code button values, strings and convert to integer
|
802 |
if ( ! empty( $code_buttons ) ) {
|
803 |
-
|
804 |
$filtered_code_buttons = array();
|
805 |
foreach ( (array) $code_buttons as $key => $var ) {
|
806 |
-
|
807 |
$code_button = array();
|
808 |
foreach ( (array) $var as $post_type => $val ) {
|
809 |
$code_button[ $post_type ] = (int) $val;
|
810 |
}
|
811 |
|
812 |
$filtered_code_buttons[ $key ] = $code_button;
|
813 |
-
|
814 |
}
|
815 |
|
816 |
-
$value[
|
817 |
-
|
818 |
}
|
819 |
|
820 |
return $value;
|
821 |
}
|
822 |
|
823 |
/**
|
824 |
-
* Register settings for options
|
825 |
*
|
826 |
* @uses register_setting
|
827 |
* @access public
|
@@ -829,12 +867,11 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
829 |
* @return void
|
830 |
*/
|
831 |
public function register_settings() {
|
832 |
-
|
833 |
register_setting( self::$option_string . '_group', self::$option_string, array( $this, 'validate_settings' ) );
|
834 |
}
|
835 |
|
836 |
/**
|
837 |
-
* Unregister and delete settings; clean database
|
838 |
*
|
839 |
* @uses unregister_setting, delete_option
|
840 |
* @access public
|
@@ -842,36 +879,34 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
842 |
* @return void
|
843 |
*/
|
844 |
public function unregister_settings() {
|
845 |
-
|
846 |
unregister_setting( self::$option_string . '_group', self::$option_string );
|
847 |
delete_option( self::$option_string );
|
848 |
}
|
849 |
|
850 |
/**
|
851 |
-
* Enqueue scripts and stylesheets
|
852 |
*
|
853 |
* @since 0.0.2
|
854 |
*
|
855 |
* @internal param $where
|
856 |
*/
|
857 |
public function print_scripts() {
|
858 |
-
|
859 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
860 |
|
861 |
wp_register_script(
|
862 |
self::$option_string . '_dashicon_picker',
|
863 |
plugins_url( '/js/dashicons-picker' . $suffix . '.js', parent::get_plugin_string() ),
|
864 |
array( 'jquery' ),
|
865 |
-
'',
|
866 |
-
|
867 |
);
|
868 |
|
869 |
wp_register_script(
|
870 |
self::$option_string . '_admin_script',
|
871 |
plugins_url( '/js/settings' . $suffix . '.js', parent::get_plugin_string() ),
|
872 |
array( 'jquery', 'quicktags' ),
|
873 |
-
'',
|
874 |
-
|
875 |
);
|
876 |
wp_enqueue_script( self::$option_string . '_dashicon_picker' );
|
877 |
wp_enqueue_script( self::$option_string . '_admin_script' );
|
@@ -880,7 +915,7 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
880 |
self::$option_string . '_dashicon_picker',
|
881 |
plugins_url( '/css/dashicons-picker' . $suffix . '.css', parent::get_plugin_string() ),
|
882 |
array( 'dashicons' ),
|
883 |
-
|
884 |
'screen'
|
885 |
);
|
886 |
|
@@ -888,7 +923,7 @@ class Add_Quicktag_Settings extends Add_Quicktag {
|
|
888 |
self::$option_string . '_admin_style',
|
889 |
plugins_url( '/css/settings' . $suffix . '.css', parent::get_plugin_string() ),
|
890 |
array(),
|
891 |
-
|
892 |
'screen'
|
893 |
);
|
894 |
wp_enqueue_style( self::$option_string . '_dashicon_picker' );
|
20 |
class Add_Quicktag_Settings extends Add_Quicktag {
|
21 |
|
22 |
/**
|
23 |
+
* String for translation.
|
24 |
*
|
25 |
* @var string
|
26 |
*/
|
27 |
+
public static $textdomain;
|
28 |
|
29 |
/**
|
30 |
+
* String for options in table options.
|
31 |
*
|
32 |
* @var string
|
33 |
*/
|
34 |
+
private static $option_string;
|
35 |
|
36 |
/**
|
37 |
+
* String for plugin file.
|
38 |
*
|
39 |
* @var string
|
40 |
*/
|
41 |
+
private static $plugin;
|
42 |
|
43 |
/**
|
44 |
+
* Post types for the settings.
|
45 |
*
|
46 |
* @var array
|
47 |
*/
|
48 |
+
private static $post_types_for_js;
|
49 |
|
50 |
/**
|
51 |
+
* String for nonce fields.
|
52 |
*
|
53 |
* @var string
|
54 |
*/
|
55 |
+
public static $nonce_string;
|
56 |
|
57 |
/**
|
58 |
+
* Store page string for hook to the settings page.
|
59 |
+
*
|
60 |
+
* @var string
|
61 |
*/
|
62 |
protected $page_hook;
|
63 |
|
69 |
* @return \Add_Quicktag|\Add_Quicktag_Settings $instance
|
70 |
*/
|
71 |
public static function get_object() {
|
|
|
72 |
static $instance;
|
73 |
|
74 |
+
if ( null === $instance ) {
|
75 |
$instance = new self();
|
76 |
}
|
77 |
|
86 |
* @uses register_activation_hook, register_uninstall_hook, add_action
|
87 |
*/
|
88 |
private function __construct() {
|
|
|
89 |
if ( ! is_admin() ) {
|
90 |
return;
|
91 |
}
|
95 |
self::$post_types_for_js = parent::get_post_types_for_js();
|
96 |
self::$nonce_string = 'addquicktag_nonce';
|
97 |
|
98 |
+
// Makes sure the plugin is defined before trying to use it.
|
99 |
+
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
100 |
+
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
101 |
+
}
|
102 |
|
103 |
register_uninstall_hook( __FILE__, array( 'Add_Quicktag_Settings', 'unregister_settings' ) );
|
104 |
+
// Settings for an active multisite.
|
105 |
if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
|
106 |
add_action( 'network_admin_menu', array( $this, 'add_settings_page' ) );
|
107 |
+
// add settings link.
|
108 |
add_filter(
|
109 |
+
'network_admin_plugin_action_links',
|
110 |
+
array(
|
111 |
+
$this,
|
112 |
+
'network_admin_plugin_action_links',
|
113 |
+
),
|
114 |
+
10,
|
115 |
+
2
|
116 |
);
|
117 |
+
// Save settings on network.
|
118 |
add_action( 'network_admin_edit_' . self::$option_string, array( $this, 'save_network_settings_page' ) );
|
119 |
+
// Return message for update settings.
|
120 |
add_action( 'network_admin_notices', array( $this, 'get_network_admin_notices' ) );
|
121 |
+
// Add script on settings page.
|
122 |
} else {
|
123 |
add_action( 'admin_menu', array( $this, 'add_settings_page' ) );
|
124 |
+
// Add settings link.
|
125 |
add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 );
|
126 |
+
// Use settings API.
|
127 |
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
128 |
}
|
129 |
+
// Include js.
|
130 |
add_action(
|
131 |
'admin_print_scripts-settings_page_' . str_replace( '.php', '', plugin_basename( __FILE__ ) ),
|
132 |
array( $this, 'print_scripts' )
|
133 |
);
|
134 |
|
135 |
+
// Add meta boxes on settings pages.
|
136 |
add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_plugin_infos' ) );
|
137 |
add_action( 'addquicktag_settings_page_sidebar', array( $this, 'get_about_plugin' ) );
|
138 |
|
139 |
+
// Include class for remove core quicktags.
|
140 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-remove-quicktags.php';
|
141 |
+
// Include class for add enhanced code quicktags.
|
142 |
+
// @TODO Solution for special code tags in quicktags.
|
143 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-code-quicktags.php';
|
144 |
+
// Include class for im/export.
|
145 |
require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-imexport.php';
|
146 |
}
|
147 |
|
148 |
/**
|
149 |
+
* Return allowed post types for include scripts.
|
150 |
*
|
151 |
* @since 2.1.1
|
152 |
* @access public
|
153 |
* @return array
|
154 |
*/
|
155 |
public function get_post_types_for_js() {
|
|
|
156 |
return self::$post_types_for_js;
|
157 |
}
|
158 |
|
159 |
/**
|
160 |
+
* Add settings link on plugins.php in backend.
|
161 |
*
|
162 |
* @uses
|
163 |
* @access public
|
164 |
*
|
165 |
+
* @param array $links An array of plugin action links.
|
166 |
+
* @param string $file Path to the plugin file relative to the plugins directory.
|
167 |
*
|
168 |
* @since 2.0.0
|
169 |
* @return string $links
|
170 |
*/
|
171 |
public function plugin_action_links( $links, $file ) {
|
|
|
172 |
if ( parent::get_plugin_string() === $file ) {
|
173 |
$links[] = '<a href="options-general.php?page=' . plugin_basename( __FILE__ ) . '">' . esc_html__(
|
174 |
+
'Settings', 'addquicktag'
|
175 |
+
) . '</a>';
|
176 |
}
|
177 |
|
178 |
return $links;
|
179 |
}
|
180 |
|
181 |
/**
|
182 |
+
* Add settings link on plugins.php on network admin in backend.
|
183 |
*
|
184 |
* @uses
|
185 |
* @access public
|
191 |
* @return string $links
|
192 |
*/
|
193 |
public function network_admin_plugin_action_links( $links, $file ) {
|
|
|
194 |
if ( parent::get_plugin_string() === $file ) {
|
195 |
$links[] = '<a href="settings.php?page=' . plugin_basename( __FILE__ ) . '">' . esc_html__(
|
196 |
+
'Settings'
|
197 |
+
) . '</a>';
|
198 |
}
|
199 |
|
200 |
return $links;
|
201 |
}
|
202 |
|
203 |
/**
|
204 |
+
* Add settings page in WP backend.
|
205 |
*
|
206 |
* @uses add_options_page
|
207 |
* @access public
|
208 |
* @since 2.0.0
|
209 |
*/
|
210 |
public function add_settings_page() {
|
|
|
211 |
if ( is_multisite() && is_plugin_active_for_network( self::$plugin ) ) {
|
212 |
add_submenu_page(
|
213 |
'settings.php',
|
229 |
}
|
230 |
|
231 |
/**
|
232 |
+
* Return form and markup on settings page.
|
233 |
*
|
234 |
* @uses settings_fields, normalize_whitespace, is_plugin_active_for_network, get_site_option, get_option
|
235 |
* @access public
|
243 |
|
244 |
<h3><?php esc_html_e( 'Add or delete Quicktag buttons', 'addquicktag' ); ?></h3>
|
245 |
|
246 |
+
<p>
|
247 |
+
<?php
|
248 |
+
esc_html_e(
|
249 |
+
'Fill in the fields below to add or edit the quicktags. Fields with * are required. To delete a tag simply empty all fields.',
|
250 |
+
'addquicktag'
|
251 |
+
);
|
252 |
+
?>
|
253 |
+
</p>
|
254 |
<p><?php esc_html_e( 'Leave the Button Label to don\'t add the button to the quicktags, html mode.', 'addquicktag' ); ?></p>
|
255 |
|
256 |
<?php
|
270 |
}
|
271 |
|
272 |
/** @var array $options */
|
273 |
+
if ( ! isset( $options['buttons'] ) ) {
|
274 |
+
$options['buttons'] = array();
|
275 |
}
|
276 |
|
277 |
+
if ( 1 < count( $options['buttons'] ) ) {
|
278 |
+
// Sort array by order value.
|
279 |
$tmp = array();
|
280 |
+
foreach ( (array) $options['buttons'] as $order ) {
|
281 |
+
if ( isset( $order['order'] ) ) {
|
282 |
+
$tmp[] = $order['order'];
|
283 |
} else {
|
284 |
$tmp[] = 0;
|
285 |
}
|
286 |
}
|
287 |
+
array_multisort( $tmp, SORT_ASC, $options['buttons'] );
|
288 |
}
|
289 |
|
290 |
+
// Loop about the post types, create html an values for title in table.
|
291 |
$pt_title = '';
|
292 |
$pt_colgroup = '';
|
293 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
294 |
+
$pt_title .= '<th class="row-title rotate" title="Post Type"><span><code>' . $post_type . '</code></span></th>' . "\n";
|
|
|
295 |
$pt_colgroup .= '<colgroup></colgroup>' . "\n";
|
296 |
}
|
297 |
?>
|
315 |
<?php esc_html_e( 'Order', 'addquicktag' ); ?></th>
|
316 |
<th class="row-title rotate">
|
317 |
<span><?php esc_html_e( 'Visual', 'addquicktag' ); ?></span></th>
|
318 |
+
<?php echo $pt_title; ?>
|
319 |
<th class="row-title rotate">✔</th>
|
320 |
</tr>
|
321 |
</thead>
|
322 |
<tbody>
|
323 |
<?php
|
324 |
+
if ( empty( $options['buttons'] ) ) {
|
325 |
+
$options['buttons'] = array();
|
326 |
}
|
327 |
$class = '';
|
328 |
+
$imax = count( $options['buttons'] );
|
329 |
for ( $i = 0; $i < $imax; $i ++ ) {
|
330 |
+
$class = ( ' class="alternate"' === $class ) ? '' : ' class="alternate"';
|
331 |
+
$b = $options['buttons'][ $i ];
|
332 |
+
$b['text'] = htmlentities(
|
333 |
+
stripslashes( $b['text'] ),
|
334 |
+
ENT_COMPAT,
|
335 |
+
get_option( 'blog_charset' )
|
336 |
);
|
337 |
+
if ( ! isset( $b['dashicon'] ) ) {
|
338 |
+
$b['dashicon'] = '';
|
339 |
}
|
340 |
+
$b['dashicon'] = htmlentities(
|
341 |
+
stripslashes( $b['dashicon'] ),
|
342 |
+
ENT_COMPAT,
|
343 |
+
get_option( 'blog_charset' )
|
344 |
);
|
345 |
+
if ( isset( $b['title'] ) ) {
|
346 |
+
$b['title'] = htmlentities(
|
347 |
+
stripslashes( $b['title'] ),
|
348 |
+
ENT_COMPAT,
|
349 |
+
get_option( 'blog_charset' )
|
350 |
);
|
351 |
}
|
352 |
+
$b['start'] = htmlentities( $b['start'], ENT_COMPAT, get_option( 'blog_charset' ) );
|
353 |
+
if ( isset( $b['end'] ) ) {
|
354 |
+
$b['end'] = htmlentities( $b['end'], ENT_COMPAT, get_option( 'blog_charset' ) );
|
355 |
}
|
356 |
+
if ( ! isset( $b['access'] ) ) {
|
357 |
+
$b['access'] = '';
|
358 |
}
|
359 |
+
$b['access'] = htmlentities( $b['access'], ENT_COMPAT, get_option( 'blog_charset' ) );
|
360 |
+
if ( ! isset( $b['order'] ) ) {
|
361 |
+
$b['order'] = 0;
|
362 |
}
|
363 |
+
$b['order'] = (int) $b['order'];
|
364 |
+
if ( ! isset( $b['visual'] ) ) {
|
365 |
+
$b['visual'] = 0;
|
366 |
}
|
367 |
+
$b['visual'] = (int) $b['visual'];
|
368 |
+
$checked = '';
|
369 |
+
if ( 1 === $b['visual'] ) {
|
370 |
$checked = ' checked="checked"';
|
371 |
}
|
372 |
|
373 |
+
// Loop about the post types, create html an values.
|
374 |
$pt_checkboxes = '';
|
375 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
|
|
376 |
if ( ! isset( $b[ $post_type ] ) ) {
|
377 |
$b[ $post_type ] = 0;
|
378 |
}
|
395 |
<td>
|
396 |
<input type="text" placeholder="' . esc_html__( 'Button Label', 'addquicktag' )
|
397 |
. '" name="' . self::$option_string . '[buttons][' . $i
|
398 |
+
. '][text]" value="' . $b['text'] . '" /><br />
|
399 |
<input class="small" id="dashicons_picker_icon_' . $i
|
400 |
. '" type="text" placeholder="' . esc_html__( 'Dashicon', 'addquicktag' )
|
401 |
. '" name="' . self::$option_string . '[buttons][' . $i
|
402 |
+
. '][dashicon]" value="' . $b['dashicon'] . '" />
|
403 |
<button type="button" data-target="#dashicons_picker_icon_'
|
404 |
. $i . '"class="button dashicons-picker dashicons dashicons-dashboard"></button>
|
405 |
<br />
|
406 |
<input type="text" placeholder="' . esc_html__( 'Title Attribute', 'addquicktag' )
|
407 |
. '" name="' . self::$option_string . '[buttons][' . $i . '][title]" value="'
|
408 |
+
. $b['title'] . '" />
|
409 |
</td>
|
410 |
<td>
|
411 |
<textarea placeholder="' . esc_html__( 'Start Tag(s)*', 'addquicktag' )
|
412 |
. '" class="code" name="' . self::$option_string . '[buttons][' . $i
|
413 |
+
. '][start]" rows="2" cols="25" >' . $b['start'] . '</textarea><br />
|
414 |
<textarea placeholder="' . esc_html__( 'End Tag(s)', 'addquicktag' )
|
415 |
. '" class="code" name="' . self::$option_string . '[buttons][' . $i
|
416 |
+
. '][end]" rows="2" cols="25" >' . $b['end'] . '</textarea>
|
417 |
</td>
|
418 |
<td>
|
419 |
<input placeholder="' . esc_html__( 'Access Key', 'addquicktag' )
|
420 |
. '" class="small-text" type="text" name="' . self::$option_string . '[buttons][' . $i
|
421 |
+
. '][access]" value="' . $b['access'] . '" /><br />
|
422 |
<input placeholder="' . esc_html__( 'Order', 'addquicktag' )
|
423 |
. '" class="small-text" type="text" name="' . self::$option_string . '[buttons][' . $i
|
424 |
+
. '][order]" value="' . $b['order'] . '" />
|
425 |
</td>
|
426 |
<td class="num">
|
427 |
<input type="checkbox" name="' . self::$option_string . '[buttons][' . $i
|
435 |
';
|
436 |
}
|
437 |
|
438 |
+
// Loop about the post types, create html an values for empty new checkboxes.
|
439 |
$pt_new_boxes = '';
|
440 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
441 |
if ( ! isset( $b[ $post_type ] ) ) {
|
449 |
$i . '][' . $post_type . ']" value="1" /></td>' . "\n";
|
450 |
}
|
451 |
?>
|
452 |
+
<tr id="rmqtb<?php echo $i; ?>">
|
453 |
<td>
|
454 |
+
<input type="text" placeholder="<?php esc_html_e( 'Button Label*', 'addquicktag' ); ?>"
|
|
|
|
|
455 |
name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][text]" value="" /><br />
|
456 |
+
<input type="text" class="small" id="dashicons_picker_icon_new" placeholder="
|
457 |
+
<?php esc_html_e( 'Dashicon', 'addquicktag' ); ?>
|
458 |
+
" name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][dashicon]" value="" />
|
459 |
<button type="button" data-target="#dashicons_picker_icon_new"
|
460 |
class="button dashicons-picker dashicons dashicons-dashboard"></button>
|
461 |
<br />
|
462 |
+
<input type="text" placeholder="<?php esc_html_e( 'Title Attribute', 'addquicktag' ); ?>"
|
|
|
|
|
463 |
name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][title]" value="" />
|
464 |
</td>
|
465 |
<td>
|
466 |
<textarea placeholder="<?php esc_html_e( 'Start Tag(s)*', 'addquicktag' ); ?>"
|
467 |
+
class="code" name="<?php echo self::$option_string; ?>[buttons][
|
468 |
+
<?php echo $i; ?>
|
469 |
+
][start]" rows="2" cols="25"></textarea><br />
|
470 |
<textarea placeholder="<?php esc_html_e( 'End Tag(s)', 'addquicktag' ); ?>"
|
471 |
+
class="code" name="<?php echo self::$option_string; ?>[buttons][
|
472 |
+
<?php echo $i; ?>
|
473 |
+
][end]" rows="2" cols="25"></textarea>
|
474 |
</td>
|
475 |
<td>
|
476 |
+
<input type="text" placeholder="
|
477 |
+
<?php
|
478 |
+
esc_html_e(
|
479 |
+
'Access Key',
|
480 |
+
'addquicktag'
|
481 |
+
);
|
482 |
+
?>
|
483 |
+
"
|
484 |
title="<?php esc_html_e( 'Access Key', 'addquicktag' ); ?>"
|
485 |
+
class="small-text" name="<?php echo self::$option_string; ?>[buttons][
|
486 |
+
<?php
|
487 |
+
echo $i;
|
488 |
+
?>
|
489 |
+
][access]" value="" /><br />
|
490 |
<input type="text" placeholder="<?php esc_html_e( 'Order', 'addquicktag' ); ?>"
|
491 |
title="<?php esc_html_e( 'Order', 'addquicktag' ); ?>" class="small-text"
|
492 |
name="<?php echo self::$option_string; ?>[buttons][<?php echo $i; ?>][order]" value="" />
|
493 |
</td>
|
494 |
<td class="num">
|
495 |
<label>
|
496 |
+
<input type="checkbox" name="<?php echo self::$option_string; ?>[buttons][
|
497 |
+
<?php
|
498 |
+
echo $i;
|
499 |
+
?>
|
500 |
+
][visual]" value="1" />
|
501 |
</label>
|
502 |
</td>
|
503 |
<?php echo $pt_new_boxes; ?>
|
504 |
<td class="num">
|
505 |
+
<label for="select_all_<?php echo $i; ?>">
|
506 |
+
<input type="checkbox" class="toggle" id="select_all_<?php echo $i; ?>" value="<?php echo $i; ?>" />
|
507 |
</label>
|
508 |
</td>
|
509 |
</tr>
|
511 |
</table>
|
512 |
|
513 |
<p class="submit">
|
514 |
+
<input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes', 'addquicktag' ); ?>" />
|
515 |
</p>
|
516 |
|
517 |
<?php do_action( 'addquicktag_settings_form_page', $options ); ?>
|
518 |
|
519 |
<p class="submit">
|
520 |
+
<input type="submit" class="button-primary" value="<?php esc_html_e( 'Save Changes', 'addquicktag' ); ?>" />
|
521 |
</p>
|
522 |
|
523 |
</form>
|
545 |
}
|
546 |
|
547 |
/*
|
548 |
+
* Return information to donate.
|
549 |
+
*
|
550 |
* @uses _e,esc_attr_e
|
551 |
* @access public
|
552 |
* @since 2.0.0
|
563 |
<p><?php esc_html_e( 'Here\'s how you can give back:', 'addquicktag' ); ?></p>
|
564 |
<ul>
|
565 |
<li>
|
566 |
+
<a href="http://wordpress.org/support/view/plugin-reviews/addquicktag" title="
|
567 |
+
<?php
|
568 |
+
esc_html_e(
|
569 |
+
'The Plugin on the WordPress plugin repository',
|
570 |
+
'addquicktag'
|
571 |
+
);
|
572 |
+
?>
|
573 |
+
"><?php esc_html_e( 'Give the plugin a good rating.', 'addquicktag' ); ?></a>
|
574 |
</li>
|
575 |
<li>
|
576 |
+
<a href="http://wordpress.org/support/plugin/addquicktag" title="
|
577 |
+
<?php
|
578 |
+
esc_html_e(
|
579 |
'Help inside the community other useres and write answer to this plugin questions.',
|
580 |
'addquicktag'
|
581 |
+
);
|
582 |
+
?>
|
583 |
+
">
|
584 |
+
<?php
|
585 |
+
esc_html_e(
|
586 |
+
'Help other users in the Support Forum.',
|
587 |
+
'addquicktag'
|
588 |
+
);
|
589 |
+
?>
|
590 |
+
</a>
|
591 |
</li>
|
592 |
<li>
|
593 |
+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6069955" title="
|
594 |
+
<?php
|
595 |
+
esc_html_e(
|
596 |
+
'Donate via PayPal',
|
597 |
+
'addquicktag'
|
598 |
+
);
|
599 |
+
?>
|
600 |
+
"><?php esc_html_e( 'Donate a few euros.', 'addquicktag' ); ?></a>
|
601 |
</li>
|
602 |
<li>
|
603 |
+
<a href="http://www.amazon.de/gp/registry/3NTOGEK181L23/ref=wl_s_3" title="
|
604 |
+
<?php
|
605 |
+
esc_html_e(
|
606 |
+
'Frank Bültge\'s Amazon Wish List',
|
607 |
+
'addquicktag'
|
608 |
+
);
|
609 |
+
?>
|
610 |
+
">
|
611 |
+
<?php
|
612 |
+
esc_html_e(
|
613 |
+
'Get me something from my wish list.',
|
614 |
+
'addquicktag'
|
615 |
+
);
|
616 |
+
?>
|
617 |
+
</a>
|
618 |
</li>
|
619 |
<li>
|
620 |
+
<a href="https://github.com/bueltge/AddQuicktag" title="
|
621 |
+
<?php
|
622 |
+
esc_html_e(
|
623 |
'Please give me feedback, contribute and file technical bugs on this GitHub Repo, use Issues.',
|
624 |
'addquicktag'
|
625 |
+
);
|
626 |
+
?>
|
627 |
+
">
|
628 |
+
<?php
|
629 |
+
esc_html_e(
|
630 |
+
'Github Repo for Contribute, Issues & Bugs',
|
631 |
+
'addquicktag'
|
632 |
+
);
|
633 |
+
?>
|
634 |
+
</a>
|
635 |
</li>
|
636 |
</ul>
|
637 |
</div>
|
639 |
<?php
|
640 |
}
|
641 |
|
642 |
+
/**
|
643 |
+
* Return information about the plugin.
|
644 |
+
*
|
645 |
+
* @uses _e, esc_attr_e
|
646 |
* @access public
|
647 |
* @since 2.0.0
|
648 |
* @return void
|
670 |
<?php
|
671 |
}
|
672 |
|
673 |
+
/**
|
674 |
+
* Save network settings.
|
675 |
+
*
|
676 |
* @uses update_site_option, wp_redirect, add_query_arg, network_admin_url
|
677 |
* @access public
|
678 |
* @since 2.0.0
|
679 |
* @return void
|
680 |
*/
|
681 |
public function save_network_settings_page() {
|
682 |
+
if ( null !== wp_unslash( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( wp_unslash( $_REQUEST['_wpnonce'] ), self::$nonce_string ) ) {
|
|
|
683 |
wp_die( 'Sorry, you failed the nonce test.' );
|
684 |
}
|
685 |
|
686 |
+
// Validate options.
|
687 |
+
if ( isset( $_POST[ self::$option_string ] ) ) {
|
688 |
+
$value = $this->validate_settings( wp_unslash( $_POST[ self::$option_string ] ) );
|
689 |
|
690 |
+
// Update options.
|
691 |
+
update_site_option( self::$option_string, $value );
|
692 |
+
}
|
693 |
+
|
694 |
+
// Redirect to settings page in network.
|
695 |
+
wp_safe_redirect(
|
696 |
add_query_arg(
|
697 |
+
array(
|
698 |
+
'page' => plugin_basename( __FILE__ ),
|
699 |
+
'updated' => 'true',
|
700 |
+
),
|
701 |
network_admin_url( 'settings.php' )
|
702 |
)
|
703 |
);
|
704 |
exit();
|
705 |
}
|
706 |
|
707 |
+
/**
|
708 |
+
* Retrun string vor update message.
|
709 |
+
*
|
710 |
+
* @uses
|
711 |
* @access public
|
712 |
* @since 2.0.0
|
713 |
* @return string $notice
|
714 |
*/
|
715 |
public function get_network_admin_notices() {
|
716 |
|
717 |
+
// If updated and the right page.
|
718 |
if ( array_key_exists(
|
719 |
+
'updated',
|
720 |
+
$_GET
|
721 |
+
)
|
722 |
+
&& 'settings_page_addquicktag/inc/class-settings-network' === $GLOBALS['current_screen']->id
|
723 |
) {
|
724 |
$message = esc_html__( 'Options saved.', 'addquicktag' );
|
725 |
+
echo '<div id="message" class="updated"><p>' . $message . '</p></div>';
|
|
|
726 |
}
|
727 |
}
|
728 |
|
729 |
/**
|
730 |
+
* Validate settings for options.
|
731 |
*
|
732 |
* @uses normalize_whitespace
|
733 |
* @access public
|
734 |
*
|
735 |
+
* @param array $value String for validation.
|
736 |
*
|
737 |
* @since 2.0.0
|
738 |
* @return string $value
|
739 |
*/
|
740 |
public function validate_settings( $value ) {
|
741 |
|
742 |
+
// Save core buttons changes.
|
743 |
if ( array_key_exists( 'core_buttons', $value ) ) {
|
744 |
+
$core_buttons = $value['core_buttons'];
|
745 |
}
|
746 |
|
747 |
+
// Save Code buttons.
|
748 |
if ( array_key_exists( 'code_buttons', $value ) ) {
|
749 |
+
$code_buttons = $value['code_buttons'];
|
750 |
}
|
751 |
|
752 |
+
// Set allowed values for import, only the defaults of plugin and custom post types.
|
753 |
$allowed_settings = (array) array_merge(
|
754 |
$this->get_post_types_for_js(),
|
755 |
array( 'text', 'dashicon', 'title', 'start', 'end', 'access', 'order', 'visual' )
|
756 |
);
|
757 |
|
758 |
$buttons = array();
|
759 |
+
// Filter for allowed values.
|
760 |
+
foreach ( (array) $value['buttons'] as $key => $button ) {
|
|
|
761 |
foreach ( (array) $button as $label => $val ) {
|
762 |
+
if ( ! in_array( $label, $allowed_settings, true ) ) {
|
|
|
763 |
unset( $button[ $label ] );
|
764 |
}
|
765 |
}
|
767 |
$buttons[] = $button;
|
768 |
}
|
769 |
|
770 |
+
// Return filtered array.
|
771 |
+
$filtered_values['buttons'] = $buttons;
|
772 |
+
$value = $filtered_values;
|
773 |
|
774 |
$buttons = array();
|
775 |
+
$c_buttons = count( $value['buttons'] );
|
776 |
for ( $i = 0; $i < $c_buttons; $i ++ ) {
|
777 |
+
$b = $value['buttons'][ $i ];
|
778 |
+
if ( ! empty( $b['start'] ) ) {
|
779 |
+
$b['text'] = sanitize_text_field( $b['text'] );
|
780 |
+
$b['dashicon'] = sanitize_text_field( $b['dashicon'] );
|
781 |
+
$b['title'] = sanitize_text_field( $b['title'] );
|
782 |
+
$b['start'] = wp_kses_stripslashes( $b['start'] );
|
783 |
+
$b['end'] = wp_kses_stripslashes( $b['end'] );
|
|
|
|
|
|
|
|
|
784 |
|
785 |
if ( array_key_exists( 'access', $b ) ) {
|
786 |
+
$b['access'] = esc_html( $b['access'] );
|
787 |
}
|
788 |
|
789 |
if ( array_key_exists( 'order', $b ) ) {
|
790 |
+
$b['order'] = (int) $b['order'];
|
791 |
}
|
792 |
|
793 |
+
$b['visual'] = 0;
|
794 |
if ( array_key_exists( 'visual', $b ) ) {
|
795 |
+
$b['visual'] = (int) $b['visual'];
|
|
|
|
|
796 |
}
|
797 |
|
|
|
798 |
foreach ( $this->get_post_types_for_js() as $post_type ) {
|
799 |
+
$b[ $post_type ] = 0;
|
800 |
if ( array_key_exists( $post_type, $b ) ) {
|
801 |
$b[ $post_type ] = (int) $b[ $post_type ];
|
|
|
|
|
802 |
}
|
|
|
803 |
}
|
804 |
|
805 |
$buttons[] = $b;
|
806 |
}
|
|
|
807 |
}
|
808 |
+
$value['buttons'] = $buttons;
|
809 |
+
// Check for wrong empty values and kill.
|
810 |
+
foreach ( $value['buttons'] as $key => $b ) {
|
811 |
+
if ( empty( $b['text'] ) && empty( $b['start'] ) ) {
|
812 |
+
unset( $value['buttons'][ $key ] );
|
|
|
813 |
}
|
814 |
}
|
815 |
+
// Reorder the array.
|
816 |
+
$value['buttons'] = array_values( $value['buttons'] );
|
817 |
|
818 |
+
// Filter core button values, strings and convert to integer.
|
819 |
if ( ! empty( $core_buttons ) ) {
|
820 |
|
821 |
/**
|
829 |
*/
|
830 |
$filtered_core_buttons = array();
|
831 |
foreach ( (array) $core_buttons as $key => $var ) {
|
|
|
832 |
$core_button = array();
|
833 |
foreach ( (array) $var as $post_type => $val ) {
|
834 |
$core_button[ $post_type ] = (int) $val;
|
835 |
}
|
836 |
|
837 |
$filtered_core_buttons[ $key ] = $core_button;
|
|
|
838 |
}
|
839 |
|
840 |
+
$value['core_buttons'] = $filtered_core_buttons;
|
|
|
841 |
}
|
842 |
|
843 |
+
// Filter code button values, strings and convert to integer.
|
844 |
if ( ! empty( $code_buttons ) ) {
|
|
|
845 |
$filtered_code_buttons = array();
|
846 |
foreach ( (array) $code_buttons as $key => $var ) {
|
|
|
847 |
$code_button = array();
|
848 |
foreach ( (array) $var as $post_type => $val ) {
|
849 |
$code_button[ $post_type ] = (int) $val;
|
850 |
}
|
851 |
|
852 |
$filtered_code_buttons[ $key ] = $code_button;
|
|
|
853 |
}
|
854 |
|
855 |
+
$value['code_buttons'] = $filtered_code_buttons;
|
|
|
856 |
}
|
857 |
|
858 |
return $value;
|
859 |
}
|
860 |
|
861 |
/**
|
862 |
+
* Register settings for options.
|
863 |
*
|
864 |
* @uses register_setting
|
865 |
* @access public
|
867 |
* @return void
|
868 |
*/
|
869 |
public function register_settings() {
|
|
|
870 |
register_setting( self::$option_string . '_group', self::$option_string, array( $this, 'validate_settings' ) );
|
871 |
}
|
872 |
|
873 |
/**
|
874 |
+
* Unregister and delete settings; clean database.
|
875 |
*
|
876 |
* @uses unregister_setting, delete_option
|
877 |
* @access public
|
879 |
* @return void
|
880 |
*/
|
881 |
public function unregister_settings() {
|
|
|
882 |
unregister_setting( self::$option_string . '_group', self::$option_string );
|
883 |
delete_option( self::$option_string );
|
884 |
}
|
885 |
|
886 |
/**
|
887 |
+
* Enqueue scripts and stylesheets.
|
888 |
*
|
889 |
* @since 0.0.2
|
890 |
*
|
891 |
* @internal param $where
|
892 |
*/
|
893 |
public function print_scripts() {
|
|
|
894 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
895 |
|
896 |
wp_register_script(
|
897 |
self::$option_string . '_dashicon_picker',
|
898 |
plugins_url( '/js/dashicons-picker' . $suffix . '.js', parent::get_plugin_string() ),
|
899 |
array( 'jquery' ),
|
900 |
+
'2021-04-26',
|
901 |
+
true
|
902 |
);
|
903 |
|
904 |
wp_register_script(
|
905 |
self::$option_string . '_admin_script',
|
906 |
plugins_url( '/js/settings' . $suffix . '.js', parent::get_plugin_string() ),
|
907 |
array( 'jquery', 'quicktags' ),
|
908 |
+
'2021-04-26',
|
909 |
+
true
|
910 |
);
|
911 |
wp_enqueue_script( self::$option_string . '_dashicon_picker' );
|
912 |
wp_enqueue_script( self::$option_string . '_admin_script' );
|
915 |
self::$option_string . '_dashicon_picker',
|
916 |
plugins_url( '/css/dashicons-picker' . $suffix . '.css', parent::get_plugin_string() ),
|
917 |
array( 'dashicons' ),
|
918 |
+
'2021-04-26',
|
919 |
'screen'
|
920 |
);
|
921 |
|
923 |
self::$option_string . '_admin_style',
|
924 |
plugins_url( '/css/settings' . $suffix . '.css', parent::get_plugin_string() ),
|
925 |
array(),
|
926 |
+
'2021-04-26',
|
927 |
'screen'
|
928 |
);
|
929 |
wp_enqueue_style( self::$option_string . '_dashicon_picker' );
|
inc/class-tinymce.php
CHANGED
@@ -21,21 +21,22 @@ class Add_Quicktag_2_TinyMce extends Add_Quicktag {
|
|
21 |
|
22 |
/**
|
23 |
* Key for custom button
|
|
|
24 |
* @var string
|
25 |
*/
|
26 |
-
static
|
27 |
|
28 |
/**
|
29 |
* Handler for the action 'init'. Instantiates this class.
|
|
|
30 |
* @access public
|
31 |
* @since 2.0.0
|
32 |
* @return \Add_Quicktag|\Add_Quicktag_2_TinyMce $instance
|
33 |
*/
|
34 |
public static function get_object() {
|
35 |
-
|
36 |
static $instance;
|
37 |
|
38 |
-
if (
|
39 |
$instance = new self();
|
40 |
}
|
41 |
|
@@ -43,49 +44,44 @@ class Add_Quicktag_2_TinyMce extends Add_Quicktag {
|
|
43 |
}
|
44 |
|
45 |
/**
|
46 |
-
* Constructor, init on defined hooks of WP and include second class
|
|
|
47 |
* @access public
|
48 |
* @since 0.0.2
|
49 |
* @uses add_action
|
50 |
*/
|
51 |
private function __construct() {
|
52 |
-
|
53 |
add_filter( 'mce_external_plugins', array( $this, 'add_externel_buttons' ) );
|
54 |
add_filter( 'mce_buttons_2', array( $this, 'extend_editor_buttons' ), 10, 2 );
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
-
* Add the script url to plugins of TinyMCE
|
59 |
*
|
60 |
-
* @param $plugins
|
61 |
*
|
62 |
* @return array
|
63 |
*/
|
64 |
public function add_externel_buttons( $plugins ) {
|
65 |
-
|
66 |
if ( ! is_array( $plugins ) ) {
|
67 |
$plugins = array();
|
68 |
}
|
69 |
|
70 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
71 |
|
72 |
-
$url
|
73 |
-
|
74 |
-
|
75 |
-
return $plugins;
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
* Add key for address the button via script
|
80 |
*
|
81 |
-
* @param
|
|
|
82 |
*
|
83 |
* @return array
|
84 |
-
*
|
85 |
-
* @param $buttons
|
86 |
*/
|
87 |
-
public function extend_editor_buttons( $buttons, $editor_id =
|
88 |
-
|
89 |
return array_merge( array( self::$option_string ), $buttons );
|
90 |
}
|
91 |
|
21 |
|
22 |
/**
|
23 |
* Key for custom button
|
24 |
+
*
|
25 |
* @var string
|
26 |
*/
|
27 |
+
private static $option_string = 'rmnlQuicktagSettings_tmce';
|
28 |
|
29 |
/**
|
30 |
* Handler for the action 'init'. Instantiates this class.
|
31 |
+
*
|
32 |
* @access public
|
33 |
* @since 2.0.0
|
34 |
* @return \Add_Quicktag|\Add_Quicktag_2_TinyMce $instance
|
35 |
*/
|
36 |
public static function get_object() {
|
|
|
37 |
static $instance;
|
38 |
|
39 |
+
if ( null === $instance ) {
|
40 |
$instance = new self();
|
41 |
}
|
42 |
|
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 add_action
|
52 |
*/
|
53 |
private function __construct() {
|
|
|
54 |
add_filter( 'mce_external_plugins', array( $this, 'add_externel_buttons' ) );
|
55 |
add_filter( 'mce_buttons_2', array( $this, 'extend_editor_buttons' ), 10, 2 );
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* Add the script url to plugins of TinyMCE.
|
60 |
*
|
61 |
+
* @param array $plugins List of plugins.
|
62 |
*
|
63 |
* @return array
|
64 |
*/
|
65 |
public function add_externel_buttons( $plugins ) {
|
|
|
66 |
if ( ! is_array( $plugins ) ) {
|
67 |
$plugins = array();
|
68 |
}
|
69 |
|
70 |
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.dev' : '';
|
71 |
|
72 |
+
$url = plugins_url( '/js/editor_plugin' . $suffix . '.js', __DIR__ );
|
73 |
+
return array_merge( $plugins, array( self::$option_string => $url ) );
|
|
|
|
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
+
* Add key for address the button via script.
|
78 |
*
|
79 |
+
* @param array $buttons TinyMCE buttons.
|
80 |
+
* @param bool $editor_id ID of the editor.
|
81 |
*
|
82 |
* @return array
|
|
|
|
|
83 |
*/
|
84 |
+
public function extend_editor_buttons( $buttons, $editor_id = false ) {
|
|
|
85 |
return array_merge( array( self::$option_string ), $buttons );
|
86 |
}
|
87 |
|
inc/tinymce/editor_plugin.dev.js
DELETED
@@ -1,170 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* AddQuicktag Script to add listbox to visual-editor
|
3 |
-
*
|
4 |
-
* @package AddQuicktag Plugin
|
5 |
-
* @author Frank Bueltge <frank@bueltge.de>
|
6 |
-
* @version 2017-11-16
|
7 |
-
* @since 2.3.0
|
8 |
-
*/
|
9 |
-
|
10 |
-
jQuery( document ).ready( function( $ ) {
|
11 |
-
|
12 |
-
if ( typeof addquicktag_tags === 'undefined' ) {
|
13 |
-
return;
|
14 |
-
}
|
15 |
-
|
16 |
-
if ( typeof addquicktag_post_type === 'undefined' ) {
|
17 |
-
return;
|
18 |
-
}
|
19 |
-
|
20 |
-
if ( typeof addquicktag_pt_for_js === 'undefined' ) {
|
21 |
-
return;
|
22 |
-
}
|
23 |
-
|
24 |
-
// wrong post type
|
25 |
-
if ( -1 === $.inArray( addquicktag_post_type, addquicktag_pt_for_js ) ) {
|
26 |
-
return;
|
27 |
-
}
|
28 |
-
|
29 |
-
// break, if not an button for visual and post type
|
30 |
-
var visual = 0,
|
31 |
-
post_type = 0,
|
32 |
-
i = 0;
|
33 |
-
|
34 |
-
for ( i; i < addquicktag_tags.buttons.length; i++ ) {
|
35 |
-
// if not visual button in the list, return
|
36 |
-
if ( 1 === parseInt( addquicktag_tags.buttons[ i ][ 'visual' ] ) ) {
|
37 |
-
visual = addquicktag_tags.buttons[ i ][ 'visual' ];
|
38 |
-
}
|
39 |
-
// check for active on this post type on each buttons
|
40 |
-
if ( 1 === parseInt( addquicktag_tags.buttons[ i ][ addquicktag_post_type ] ) ) {
|
41 |
-
post_type = addquicktag_tags.buttons[ i ][ addquicktag_post_type ];
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
if ( 1 !== parseInt( visual ) ) {
|
46 |
-
return;
|
47 |
-
}
|
48 |
-
|
49 |
-
if ( 1 !== parseInt( post_type ) ) {
|
50 |
-
return;
|
51 |
-
}
|
52 |
-
|
53 |
-
// Add listbox plugin to TinyMCE editor
|
54 |
-
tinymce.PluginManager.add( 'rmnlQuicktagSettings_tmce', function( editor ) {
|
55 |
-
|
56 |
-
editor.addButton( 'rmnlQuicktagSettings_tmce', function() {
|
57 |
-
|
58 |
-
var tiny_tags = addquicktag_tags[ 'buttons' ],
|
59 |
-
values = [],
|
60 |
-
i = 0;
|
61 |
-
|
62 |
-
for ( i; i < tiny_tags.length; i++ ) {
|
63 |
-
|
64 |
-
// check for active on this post type
|
65 |
-
if ( 1 === parseInt( tiny_tags[ i ][ addquicktag_post_type ] ) ) {
|
66 |
-
|
67 |
-
// Create the list items with all custom values from settings.
|
68 |
-
// @see http://www.tinymce.com/wiki.php/api4:class.tinymce.ui.ListBox
|
69 |
-
if ( 1 === tiny_tags[ i ].visual ) {
|
70 |
-
//console.log( tiny_tags[ i ] );
|
71 |
-
values.push( {
|
72 |
-
text : tiny_tags[ i ].text,
|
73 |
-
value : String( i ),
|
74 |
-
tooltip: tiny_tags[ i ].title,
|
75 |
-
icon : 'icon dashicons dashicons-before ' + tiny_tags[ i ].dashicon
|
76 |
-
} );
|
77 |
-
}
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
return {
|
82 |
-
type : 'listbox',
|
83 |
-
//name : 'align',
|
84 |
-
icon : '',
|
85 |
-
text : 'Quicktags',
|
86 |
-
label : 'Select :',
|
87 |
-
fixedWidth: true,
|
88 |
-
onselect : function( v ) {
|
89 |
-
// For debugging purpose
|
90 |
-
console.log( v );
|
91 |
-
|
92 |
-
var // Set short var for the value identifier
|
93 |
-
// v = v.control._value,
|
94 |
-
// Change since WordPress 4.3 to new object values.
|
95 |
-
value = v.control.settings.value,
|
96 |
-
marked = false;
|
97 |
-
|
98 |
-
if ( typeof(
|
99 |
-
tinymce.activeEditor.selection.getContent()
|
100 |
-
) !== 'undefined' ) {
|
101 |
-
marked = true;
|
102 |
-
}
|
103 |
-
|
104 |
-
if ( marked === true ) {
|
105 |
-
|
106 |
-
console.log( tiny_tags );
|
107 |
-
console.log( value );
|
108 |
-
|
109 |
-
var content = tinymce.activeEditor.selection.getContent(),
|
110 |
-
start_content = tinymce.activeEditor.selection.getStart().nodeName,
|
111 |
-
all = tinymce.activeEditor.selection.getNode(),
|
112 |
-
start = tiny_tags[ value ].start,
|
113 |
-
start_tag = start.match( /[a-z]+/ ),
|
114 |
-
end = tiny_tags[ value ].end;
|
115 |
-
|
116 |
-
if ( typeof start === 'undefined' ) {
|
117 |
-
start = '';
|
118 |
-
}
|
119 |
-
|
120 |
-
if ( typeof end === 'undefined' ) {
|
121 |
-
end = '';
|
122 |
-
}
|
123 |
-
|
124 |
-
/*
|
125 |
-
// For debugging purpose
|
126 |
-
console.log(v);
|
127 |
-
console.log('TinyTags: ' + tiny_tags[value]);
|
128 |
-
console.log('start_content: ' + start_content);
|
129 |
-
console.log('start_content.nodeName: ' + tinymce.activeEditor.selection.getStart().nodeName);
|
130 |
-
console.log('start_content.outerHMTL: ' + tinymce.activeEditor.selection.getStart().outerHMTL);
|
131 |
-
console.log('Content: ' + content);
|
132 |
-
console.log(all);
|
133 |
-
console.log('Start tag: ' + start);
|
134 |
-
console.log('Start tag, only: ' + start.match(/[a-z]+/));
|
135 |
-
console.log('End tag: ' + end);
|
136 |
-
//console.log(start_content.indexOf( start ));
|
137 |
-
console.log('Search nodeName: ' + start_content.search(start));
|
138 |
-
/**/
|
139 |
-
|
140 |
-
// Add tag to content
|
141 |
-
if ( start.match( /[a-z]+/i ) !== start_content.toLowerCase() ) {
|
142 |
-
tinymce.activeEditor.selection.setContent(
|
143 |
-
tiny_tags[ value ].start + content + tiny_tags[ value ].end
|
144 |
-
);
|
145 |
-
}
|
146 |
-
|
147 |
-
// Remove existing tag
|
148 |
-
if ( start.match( /[a-z]+/i ) === start_content.toLowerCase() ) {
|
149 |
-
|
150 |
-
// Remove content with tag
|
151 |
-
tinyMCE.activeEditor.dom.remove(
|
152 |
-
tinymce.activeEditor.selection.getNode(
|
153 |
-
start_content.toLowerCase()
|
154 |
-
)
|
155 |
-
);
|
156 |
-
// Add content, without tag
|
157 |
-
tinymce.activeEditor.selection.setContent(
|
158 |
-
content
|
159 |
-
);
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
}
|
164 |
-
},
|
165 |
-
values : values
|
166 |
-
};
|
167 |
-
} );
|
168 |
-
|
169 |
-
} );
|
170 |
-
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/tinymce/editor_plugin.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function(a){if("undefined"!=typeof addquicktag_tags&&"undefined"!=typeof addquicktag_post_type&&"undefined"!=typeof addquicktag_pt_for_js&&-1!==a.inArray(addquicktag_post_type,addquicktag_pt_for_js)){var b=0,c=0,d=0;for(d;d<addquicktag_tags.buttons.length;d++)1===parseInt(addquicktag_tags.buttons[d].visual)&&(b=addquicktag_tags.buttons[d].visual),1===parseInt(addquicktag_tags.buttons[d][addquicktag_post_type])&&(c=addquicktag_tags.buttons[d][addquicktag_post_type]);1===parseInt(b)&&1===parseInt(c)&&tinymce.PluginManager.add("rmnlQuicktagSettings_tmce",function(a){a.addButton("rmnlQuicktagSettings_tmce",function(){var a=addquicktag_tags.buttons,b=[],c=0;for(c;c<a.length;c++)1===parseInt(a[c][addquicktag_post_type])&&1===a[c].visual&&b.push({text:a[c].text,value:String(c),tooltip:a[c].title,icon:"icon dashicons dashicons-before "+a[c].dashicon});return{type:"listbox",icon:"",text:"Quicktags",label:"Select :",fixedWidth:!0,onselect:function(b){console.log(b);var c=b.control.settings.value,d=!1;if("undefined"!=typeof tinymce.activeEditor.selection.getContent()&&(d=!0),d===!0){console.log(a),console.log(c);var e=tinymce.activeEditor.selection.getContent(),f=tinymce.activeEditor.selection.getStart().nodeName,g=(tinymce.activeEditor.selection.getNode(),a[c].start),h=(g.match(/[a-z]+/),a[c].end);"undefined"==typeof g&&(g=""),"undefined"==typeof h&&(h=""),g.match(/[a-z]+/i)!==f.toLowerCase()&&tinymce.activeEditor.selection.setContent(a[c].start+e+a[c].end),g.match(/[a-z]+/i)===f.toLowerCase()&&(tinyMCE.activeEditor.dom.remove(tinymce.activeEditor.selection.getNode(f.toLowerCase())),tinymce.activeEditor.selection.setContent(e))}},values:b}})})}});
|
|
js/add-quicktags.dev.js
CHANGED
@@ -3,89 +3,106 @@
|
|
3 |
*
|
4 |
* @package AddQuicktag Plugin
|
5 |
* @author Frank Bueltge <frank@bueltge.de>
|
6 |
-
* @version
|
7 |
* @since 2.0.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
|
12 |
-
if (
|
13 |
return;
|
14 |
}
|
15 |
|
16 |
-
if (
|
17 |
return;
|
18 |
}
|
19 |
|
20 |
-
if (
|
21 |
return;
|
22 |
}
|
23 |
|
24 |
-
var tags = addquicktag_tags[
|
25 |
-
if (
|
26 |
return;
|
27 |
}
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
/*Firefox (and IE if the string contains no elements surrounded by angle brackets )*/
|
31 |
try {
|
32 |
-
var ta = document.createElement(
|
33 |
ta.innerHTML = str;
|
34 |
return ta.value;
|
35 |
-
} catch (
|
36 |
}
|
37 |
|
38 |
/*Internet Explorer*/
|
39 |
try {
|
40 |
-
var d = document.createElement(
|
41 |
-
d.innerHTML = str.replace(
|
42 |
-
if (
|
43 |
return d.innerText;
|
44 |
}
|
45 |
/*Sadly this strips tags as well*/
|
46 |
-
} catch (
|
47 |
}
|
48 |
}
|
49 |
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
var prmt = prompt(
|
54 |
|
55 |
-
if (
|
56 |
return;
|
57 |
}
|
58 |
|
59 |
this.tagStart = '[tag]' + prmt + '[/tag]';
|
60 |
|
61 |
-
QTags.TagButton.prototype.callback.call(
|
62 |
}
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
canvas.focus();
|
66 |
|
67 |
-
if (
|
68 |
return document.selection.createRange().text;
|
69 |
-
} else { // standards
|
70 |
-
return canvas.value.substring( canvas.selectionStart, canvas.selectionEnd );
|
71 |
}
|
|
|
72 |
}
|
73 |
|
74 |
// check post type
|
75 |
-
if (
|
76 |
|
77 |
-
for (
|
78 |
// check for active on this post type
|
79 |
-
if (
|
80 |
//console.log(tags[i]);
|
81 |
-
if (
|
82 |
-
tags[
|
83 |
}
|
84 |
-
if (
|
85 |
-
tags[
|
86 |
}
|
87 |
-
if (
|
88 |
-
tags[
|
89 |
}
|
90 |
|
91 |
/**
|
@@ -99,12 +116,12 @@ jQuery( document ).ready( function( $ ) {
|
|
99 |
* @param instance string optional Limit the button to a specific instance of Quicktags, add to all instances if not present.
|
100 |
*/
|
101 |
QTags.addButton(
|
102 |
-
html_entity_decode(
|
103 |
-
tags[
|
104 |
-
tags[
|
105 |
-
tags[
|
106 |
-
tags[
|
107 |
-
tags[
|
108 |
);
|
109 |
|
110 |
/**
|
@@ -125,82 +142,82 @@ jQuery( document ).ready( function( $ ) {
|
|
125 |
} // end check post type
|
126 |
|
127 |
// Check the Code buttons, if inside the json
|
128 |
-
var code_buttons = addquicktag_tags[
|
129 |
|
130 |
// Fallback, if WP core don't set the var
|
131 |
-
if (
|
132 |
typenow = '';
|
133 |
}
|
134 |
|
135 |
// IF no code buttons was active
|
136 |
-
if (
|
137 |
return;
|
138 |
}
|
139 |
|
140 |
// Fallback for no htmlentities settings
|
141 |
-
if (
|
142 |
code_buttons.htmlentities = 0;
|
143 |
}
|
144 |
|
145 |
// Fallback for no pre settings
|
146 |
-
if (
|
147 |
code_buttons.pre = 0;
|
148 |
}
|
149 |
|
150 |
// if the htmlentities settings is active for each post type (var typenow from WP core)
|
151 |
-
if (
|
152 |
/**
|
153 |
* ideas for code buttons and optional window with input possibility
|
154 |
*
|
155 |
* @see @see http://bililite.com/blog/2012/08/20/custom-buttons-in-the-wordpress-html-editor/
|
156 |
*/
|
157 |
-
QTags.addButton(
|
158 |
QTags.insertContent(
|
159 |
-
get_selected_text(
|
160 |
);
|
161 |
-
}, 'Encode HTML Entities'
|
162 |
|
163 |
-
QTags.addButton(
|
164 |
QTags.insertContent(
|
165 |
-
get_selected_text(
|
166 |
);
|
167 |
-
}, 'Decode HTML Entities'
|
168 |
}
|
169 |
|
170 |
// if the pre settings is active for each post type (var typenow from WP core)
|
171 |
-
if (
|
172 |
-
var code_languages = [
|
173 |
// Insert before the code button
|
174 |
-
edButtons[
|
175 |
-
html: function(
|
176 |
return '<select id="' + id_prefix + 'code_language" class="language-select">' +
|
177 |
'<option>blank</option>' + // include a blank option
|
178 |
-
'<option>' + code_languages.join(
|
179 |
'</select>';
|
180 |
}
|
181 |
};
|
182 |
-
$(
|
183 |
-
var lang = $(
|
184 |
// 110 is the code qt-tag from core, wp-includes/js/quicktags.js
|
185 |
-
edButtons[
|
186 |
-
}
|
187 |
|
188 |
// Add pre button for preformatted text
|
189 |
-
QTags.addButton(
|
190 |
}
|
191 |
|
192 |
-
}
|
193 |
|
194 |
var decodeEntities = (
|
195 |
-
function() {
|
196 |
// this prevents any overhead from creating the object each time
|
197 |
-
var element = document.createElement(
|
198 |
|
199 |
-
function decodeHTMLEntities(
|
200 |
-
if (
|
201 |
// strip script/html tags
|
202 |
-
str = str.replace(
|
203 |
-
str = str.replace(
|
204 |
element.innerHTML = str;
|
205 |
str = element.textContent;
|
206 |
element.textContent = '';
|
@@ -211,4 +228,4 @@ var decodeEntities = (
|
|
211 |
|
212 |
return decodeHTMLEntities;
|
213 |
}
|
214 |
-
)();
|
3 |
*
|
4 |
* @package AddQuicktag Plugin
|
5 |
* @author Frank Bueltge <frank@bueltge.de>
|
6 |
+
* @version 2021-04-09
|
7 |
* @since 2.0.0
|
8 |
*/
|
9 |
|
10 |
+
(function ($) {
|
11 |
|
12 |
+
if (typeof addquicktag_tags === 'undefined') {
|
13 |
return;
|
14 |
}
|
15 |
|
16 |
+
if (typeof addquicktag_post_type === 'undefined') {
|
17 |
return;
|
18 |
}
|
19 |
|
20 |
+
if (typeof addquicktag_pt_for_js === 'undefined') {
|
21 |
return;
|
22 |
}
|
23 |
|
24 |
+
var tags = addquicktag_tags['buttons'];
|
25 |
+
if (typeof tags === 'undefined') {
|
26 |
return;
|
27 |
}
|
28 |
|
29 |
+
/**
|
30 |
+
* Decode html strings.
|
31 |
+
*
|
32 |
+
* @param str
|
33 |
+
* @returns {string}
|
34 |
+
*/
|
35 |
+
function html_entity_decode(str) {
|
36 |
/*Firefox (and IE if the string contains no elements surrounded by angle brackets )*/
|
37 |
try {
|
38 |
+
var ta = document.createElement("textarea");
|
39 |
ta.innerHTML = str;
|
40 |
return ta.value;
|
41 |
+
} catch (e) {
|
42 |
}
|
43 |
|
44 |
/*Internet Explorer*/
|
45 |
try {
|
46 |
+
var d = document.createElement("div");
|
47 |
+
d.innerHTML = str.replace(/</g, "<").replace(/>/g, ">");
|
48 |
+
if (typeof d.innerText !== "undefined") {
|
49 |
return d.innerText;
|
50 |
}
|
51 |
/*Sadly this strips tags as well*/
|
52 |
+
} catch (e) {
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
/**
|
57 |
+
* Window for input.
|
58 |
+
*
|
59 |
+
* @param e
|
60 |
+
* @param c
|
61 |
+
* @param ed
|
62 |
+
*/
|
63 |
+
function qt_callback_input_window(e, c, ed) {
|
64 |
|
65 |
+
var prmt = prompt('Enter Tag Name');
|
66 |
|
67 |
+
if (prmt === null) {
|
68 |
return;
|
69 |
}
|
70 |
|
71 |
this.tagStart = '[tag]' + prmt + '[/tag]';
|
72 |
|
73 |
+
QTags.TagButton.prototype.callback.call(this, e, c, ed);
|
74 |
}
|
75 |
|
76 |
+
/**
|
77 |
+
* Get string from selection.
|
78 |
+
*
|
79 |
+
* @param canvas
|
80 |
+
* @returns {string|*}
|
81 |
+
*/
|
82 |
+
function get_selected_text(canvas) { // "canvas" is what they call the textarea of the editor
|
83 |
canvas.focus();
|
84 |
|
85 |
+
if (document.selection) { // IE
|
86 |
return document.selection.createRange().text;
|
|
|
|
|
87 |
}
|
88 |
+
return canvas.value.substring(canvas.selectionStart, canvas.selectionEnd);
|
89 |
}
|
90 |
|
91 |
// check post type
|
92 |
+
if ($.inArray("addquicktag_post_type", addquicktag_pt_for_js)) {
|
93 |
|
94 |
+
for (var i = 0; i < tags.length; i++) {
|
95 |
// check for active on this post type
|
96 |
+
if (1 === parseInt(tags[i][addquicktag_post_type])) {
|
97 |
//console.log(tags[i]);
|
98 |
+
if (typeof tags[i].title === 'undefined') {
|
99 |
+
tags[i].title = ' ';
|
100 |
}
|
101 |
+
if (typeof tags[i].end === 'undefined') {
|
102 |
+
tags[i].end = '';
|
103 |
}
|
104 |
+
if (typeof tags[i].access === 'undefined') {
|
105 |
+
tags[i].access = '';
|
106 |
}
|
107 |
|
108 |
/**
|
116 |
* @param instance string optional Limit the button to a specific instance of Quicktags, add to all instances if not present.
|
117 |
*/
|
118 |
QTags.addButton(
|
119 |
+
html_entity_decode(tags[i].text).replace(/["\\]/gi, "").toLowerCase(),
|
120 |
+
tags[i].text,
|
121 |
+
tags[i].start,
|
122 |
+
tags[i].end,
|
123 |
+
tags[i].access,
|
124 |
+
tags[i].title.replace(/["\\]/gi, "")
|
125 |
);
|
126 |
|
127 |
/**
|
142 |
} // end check post type
|
143 |
|
144 |
// Check the Code buttons, if inside the json
|
145 |
+
var code_buttons = addquicktag_tags['code_buttons'];
|
146 |
|
147 |
// Fallback, if WP core don't set the var
|
148 |
+
if (typeof typenow === 'undefined') {
|
149 |
typenow = '';
|
150 |
}
|
151 |
|
152 |
// IF no code buttons was active
|
153 |
+
if (typeof code_buttons === 'undefined') {
|
154 |
return;
|
155 |
}
|
156 |
|
157 |
// Fallback for no htmlentities settings
|
158 |
+
if (typeof code_buttons.htmlentities === 'undefined') {
|
159 |
code_buttons.htmlentities = 0;
|
160 |
}
|
161 |
|
162 |
// Fallback for no pre settings
|
163 |
+
if (typeof code_buttons.pre === 'undefined') {
|
164 |
code_buttons.pre = 0;
|
165 |
}
|
166 |
|
167 |
// if the htmlentities settings is active for each post type (var typenow from WP core)
|
168 |
+
if (code_buttons.htmlentities[typenow] === 1) {
|
169 |
/**
|
170 |
* ideas for code buttons and optional window with input possibility
|
171 |
*
|
172 |
* @see @see http://bililite.com/blog/2012/08/20/custom-buttons-in-the-wordpress-html-editor/
|
173 |
*/
|
174 |
+
QTags.addButton('toHTML', 'HTML Entities', function (el, canvas) {
|
175 |
QTags.insertContent(
|
176 |
+
get_selected_text(canvas).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
177 |
);
|
178 |
+
}, 'Encode HTML Entities');
|
179 |
|
180 |
+
QTags.addButton('fromHTML', 'Decode HTML', function (el, canvas) {
|
181 |
QTags.insertContent(
|
182 |
+
get_selected_text(canvas).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
183 |
);
|
184 |
+
}, 'Decode HTML Entities');
|
185 |
}
|
186 |
|
187 |
// if the pre settings is active for each post type (var typenow from WP core)
|
188 |
+
if (code_buttons.pre[typenow] === 1) {
|
189 |
+
var code_languages = ['html', 'javascript', 'css', 'bash', 'php', 'vb'];
|
190 |
// Insert before the code button
|
191 |
+
edButtons[109] = {
|
192 |
+
html: function (id_prefix) {
|
193 |
return '<select id="' + id_prefix + 'code_language" class="language-select">' +
|
194 |
'<option>blank</option>' + // include a blank option
|
195 |
+
'<option>' + code_languages.join('</option><option>') + '</option>' +
|
196 |
'</select>';
|
197 |
}
|
198 |
};
|
199 |
+
$('body').on('change', 'select.language-select', function () {
|
200 |
+
var lang = $(this).val();
|
201 |
// 110 is the code qt-tag from core, wp-includes/js/quicktags.js
|
202 |
+
edButtons[110].tagStart = lang ? '<code class="language-' + lang + '">' : '<code>';
|
203 |
+
});
|
204 |
|
205 |
// Add pre button for preformatted text
|
206 |
+
QTags.addButton('qt_pre', 'pre', '<pre>', '</pre>', '', 'Preformatted text', '108');
|
207 |
}
|
208 |
|
209 |
+
})(jQuery);
|
210 |
|
211 |
var decodeEntities = (
|
212 |
+
function () {
|
213 |
// this prevents any overhead from creating the object each time
|
214 |
+
var element = document.createElement('div');
|
215 |
|
216 |
+
function decodeHTMLEntities(str) {
|
217 |
+
if (str && typeof str === 'string') {
|
218 |
// strip script/html tags
|
219 |
+
str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, '');
|
220 |
+
str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, '');
|
221 |
element.innerHTML = str;
|
222 |
str = element.textContent;
|
223 |
element.textContent = '';
|
228 |
|
229 |
return decodeHTMLEntities;
|
230 |
}
|
231 |
+
)();
|
js/add-quicktags.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
1 |
+
!function(a){function b(a){try{var b=document.createElement("textarea");return b.innerHTML=a,b.value}catch(c){}try{var d=document.createElement("div");if(d.innerHTML=a.replace(/</g,"<").replace(/>/g,">"),"undefined"!=typeof d.innerText)return d.innerText}catch(c){}}function c(a){return a.focus(),document.selection?document.selection.createRange().text:a.value.substring(a.selectionStart,a.selectionEnd)}if("undefined"!=typeof addquicktag_tags&&"undefined"!=typeof addquicktag_post_type&&"undefined"!=typeof addquicktag_pt_for_js){var d=addquicktag_tags.buttons;if("undefined"!=typeof d){if(a.inArray("addquicktag_post_type",addquicktag_pt_for_js))for(var e=0;e<d.length;e++)1===parseInt(d[e][addquicktag_post_type])&&("undefined"==typeof d[e].title&&(d[e].title=" "),"undefined"==typeof d[e].end&&(d[e].end=""),"undefined"==typeof d[e].access&&(d[e].access=""),QTags.addButton(b(d[e].text).replace(/["\\]/gi,"").toLowerCase(),d[e].text,d[e].start,d[e].end,d[e].access,d[e].title.replace(/["\\]/gi,"")));var f=addquicktag_tags.code_buttons;if("undefined"==typeof typenow&&(typenow=""),"undefined"!=typeof f&&("undefined"==typeof f.htmlentities&&(f.htmlentities=0),"undefined"==typeof f.pre&&(f.pre=0),1===f.htmlentities[typenow]&&(QTags.addButton("toHTML","HTML Entities",function(a,b){QTags.insertContent(c(b).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"))},"Encode HTML Entities"),QTags.addButton("fromHTML","Decode HTML",function(a,b){QTags.insertContent(c(b).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"))},"Decode HTML Entities")),1===f.pre[typenow])){var g=["html","javascript","css","bash","php","vb"];edButtons[109]={html:function(a){return'<select id="'+a+'code_language" class="language-select"><option>blank</option><option>'+g.join("</option><option>")+"</option></select>"}},a("body").on("change","select.language-select",function(){var b=a(this).val();edButtons[110].tagStart=b?'<code class="language-'+b+'">':"<code>"}),QTags.addButton("qt_pre","pre","<pre>","</pre>","","Preformatted text","108")}}}}(jQuery);var decodeEntities=function(){function a(a){return a&&"string"==typeof a&&(a=a.replace(/<script[^>]*>([\S\s]*?)<\/script>/gim,""),a=a.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gim,""),b.innerHTML=a,a=b.textContent,b.textContent=""),a}var b=document.createElement("div");return a}();
|
js/add-quicktags_32.dev.js
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* AddQuicktag Script to add buttons to html-editor for WordPress version smaller 3.3
|
3 |
-
* @since 2.0.0
|
4 |
-
* @package AddQuicktag Plugin
|
5 |
-
*/
|
6 |
-
|
7 |
-
jQuery( document ).ready( function( $ ) {
|
8 |
-
|
9 |
-
if ( typeof addquicktag_tags == 'undefined' )
|
10 |
-
return;
|
11 |
-
|
12 |
-
var tags = addquicktag_tags['buttons'];
|
13 |
-
var wpaqToolbar = document.getElementById("ed_toolbar");
|
14 |
-
|
15 |
-
if ( typeof tags !== 'undefined' && wpaqToolbar ) {
|
16 |
-
|
17 |
-
var wpaqBut, wpaqNr;
|
18 |
-
|
19 |
-
for ( var i = 0; i < tags.length; i++ ) {
|
20 |
-
if ( typeof tags[i].title == 'undefined' ) tags[i].title = ' ';
|
21 |
-
if ( typeof tags[i].end == 'undefined' ) tags[i].end = '';
|
22 |
-
if ( typeof tags[i].access == 'undefined' ) tags[i].access = '';
|
23 |
-
|
24 |
-
wpaqNr = edButtons.length;
|
25 |
-
edButtons[wpaqNr] = new edButton(
|
26 |
-
// id, display, tagStart, tagEnd, access_key, title
|
27 |
-
tags[i].text.toLowerCase(), tags[i].text, tags[i].start, tags[i].end, tags[i].access, tags[i].title
|
28 |
-
);
|
29 |
-
wpaqBut = wpaqToolbar.lastChild;
|
30 |
-
while ( wpaqBut.nodeType != 1 ) {
|
31 |
-
wpaqBut = wpaqBut.previousSibling;
|
32 |
-
}
|
33 |
-
wpaqBut = wpaqBut.cloneNode( true );
|
34 |
-
wpaqBut.id = 'ed_' + wpaqNr;
|
35 |
-
wpaqBut._idx = wpaqNr; //store our current index at element itself
|
36 |
-
wpaqBut.value = tags[i].text;
|
37 |
-
wpaqBut.title = tags[i].title;
|
38 |
-
wpaqBut.onclick = function() { edInsertTag( edCanvas, this._idx ); return false; };
|
39 |
-
wpaqToolbar.appendChild( wpaqBut );
|
40 |
-
}
|
41 |
-
|
42 |
-
} // end if tags
|
43 |
-
|
44 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/add-quicktags_32.js
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
jQuery(document).ready(function(a){if("undefined"!=typeof addquicktag_tags){var b=addquicktag_tags.buttons,c=document.getElementById("ed_toolbar");if("undefined"!=typeof b&&c)for(var d,e,f=0;f<b.length;f++){for("undefined"==typeof b[f].title&&(b[f].title=" "),"undefined"==typeof b[f].end&&(b[f].end=""),"undefined"==typeof b[f].access&&(b[f].access=""),e=edButtons.length,edButtons[e]=new edButton(b[f].text.toLowerCase(),b[f].text,b[f].start,b[f].end,b[f].access,b[f].title),d=c.lastChild;1!=d.nodeType;)d=d.previousSibling;d=d.cloneNode(!0),d.id="ed_"+e,d._idx=e,d.value=b[f].text,d.title=b[f].title,d.onclick=function(){return edInsertTag(edCanvas,this._idx),!1},c.appendChild(d)}}});
|
|
js/dashicons-picker.dev.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
*/
|
6 |
|
7 |
( function ( $ ) {
|
8 |
-
|
9 |
/**
|
10 |
*
|
11 |
* @returns {void}
|
@@ -255,6 +255,72 @@
|
|
255 |
'thumbs-up',
|
256 |
'thumbs-down',
|
257 |
'layout',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
'',
|
259 |
'',
|
260 |
''
|
@@ -262,45 +328,54 @@
|
|
262 |
|
263 |
return this.each( function () {
|
264 |
|
265 |
-
var button = $( this )
|
|
|
|
|
266 |
|
267 |
-
button.on( 'click.dashiconsPicker', function () {
|
|
|
|
|
268 |
createPopup( button );
|
269 |
} );
|
270 |
|
271 |
function createPopup( button ) {
|
272 |
|
273 |
var target = $( button.data( 'target' ) ),
|
274 |
-
|
275 |
-
|
276 |
-
<
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
list = popup.find( '.dashicon-picker-list' );
|
283 |
|
284 |
for ( var i in icons ) {
|
285 |
-
|
|
|
|
|
286 |
}
|
287 |
|
288 |
-
$( 'a', list ).
|
289 |
e.preventDefault();
|
290 |
var title = $( this ).attr( 'title' );
|
291 |
target.val( 'dashicons-' + title );
|
|
|
|
|
|
|
292 |
removePopup();
|
293 |
} );
|
294 |
|
295 |
var control = popup.find( '.dashicon-picker-control' );
|
296 |
|
297 |
-
control.html( '<a data-direction="back" href="#">
|
298 |
-
<span class="dashicons dashicons-arrow-left-alt2"></span></a>
|
299 |
-
<input type="text" class="" placeholder="Search" />
|
300 |
-
<a data-direction="forward" href="#"><span class="dashicons dashicons-arrow-right-alt2"></span></a>'
|
301 |
);
|
302 |
|
303 |
-
$( 'a', control ).
|
304 |
e.preventDefault();
|
305 |
if ( $( this ).data( 'direction' ) === 'back' ) {
|
306 |
$( 'li:gt(' + ( icons.length - 26 ) + ')', list ).prependTo( list );
|
@@ -311,7 +386,7 @@
|
|
311 |
|
312 |
popup.appendTo( 'body' ).show();
|
313 |
|
314 |
-
$( 'input', control ).on( 'keyup', function () {
|
315 |
var search = $( this ).val();
|
316 |
if ( search === '' ) {
|
317 |
$( 'li:lt(25)', list ).show();
|
@@ -326,7 +401,7 @@
|
|
326 |
}
|
327 |
} );
|
328 |
|
329 |
-
$( document ).
|
330 |
if ( ! popup.is( e.target ) && popup.has( e.target ).length === 0 ) {
|
331 |
removePopup();
|
332 |
}
|
@@ -335,7 +410,7 @@
|
|
335 |
|
336 |
function removePopup() {
|
337 |
$( '.dashicon-picker-container' ).remove();
|
338 |
-
$( document ).
|
339 |
}
|
340 |
} );
|
341 |
};
|
5 |
*/
|
6 |
|
7 |
( function ( $ ) {
|
8 |
+
'use strict';
|
9 |
/**
|
10 |
*
|
11 |
* @returns {void}
|
255 |
'thumbs-up',
|
256 |
'thumbs-down',
|
257 |
'layout',
|
258 |
+
'align-pull-left',
|
259 |
+
'align-pull-right',
|
260 |
+
'block-default',
|
261 |
+
'cloud-saved',
|
262 |
+
'cloud-upload',
|
263 |
+
'columns',
|
264 |
+
'cover-image',
|
265 |
+
'embed-audio',
|
266 |
+
'embed-generic',
|
267 |
+
'embed-photo',
|
268 |
+
'embed-post',
|
269 |
+
'embed-video',
|
270 |
+
'exit',
|
271 |
+
'html',
|
272 |
+
'info-outline',
|
273 |
+
'insert-after',
|
274 |
+
'insert-before',
|
275 |
+
'insert',
|
276 |
+
'remove',
|
277 |
+
'shortcode',
|
278 |
+
'table-col-after',
|
279 |
+
'table-col-before',
|
280 |
+
'table-col-delete',
|
281 |
+
'table-row-after',
|
282 |
+
'table-row-before',
|
283 |
+
'table-row-delete',
|
284 |
+
'saved',
|
285 |
+
'amazon',
|
286 |
+
'google',
|
287 |
+
'linkedin',
|
288 |
+
'pinterest',
|
289 |
+
'podio',
|
290 |
+
'reddit',
|
291 |
+
'spotify',
|
292 |
+
'twitch',
|
293 |
+
'whatsapp',
|
294 |
+
'xing',
|
295 |
+
'youtube',
|
296 |
+
'database-add',
|
297 |
+
'database-export',
|
298 |
+
'database-import',
|
299 |
+
'database-remove',
|
300 |
+
'database-view',
|
301 |
+
'database',
|
302 |
+
'bell',
|
303 |
+
'airplane',
|
304 |
+
'car',
|
305 |
+
'calculator',
|
306 |
+
'ames',
|
307 |
+
'printer',
|
308 |
+
'beer',
|
309 |
+
'coffee',
|
310 |
+
'drumstick',
|
311 |
+
'food',
|
312 |
+
'bank',
|
313 |
+
'hourglass',
|
314 |
+
'money-alt',
|
315 |
+
'open-folder',
|
316 |
+
'pdf',
|
317 |
+
'pets',
|
318 |
+
'privacy',
|
319 |
+
'superhero',
|
320 |
+
'superhero-alt',
|
321 |
+
'edit-page',
|
322 |
+
'fullscreen-alt',
|
323 |
+
'fullscreen-exit-alt',
|
324 |
'',
|
325 |
'',
|
326 |
''
|
328 |
|
329 |
return this.each( function () {
|
330 |
|
331 |
+
var button = $( this ),
|
332 |
+
offsetTop,
|
333 |
+
offsetLeft;
|
334 |
|
335 |
+
button.on( 'click.dashiconsPicker', function ( e ) {
|
336 |
+
offsetTop = $( e.currentTarget ).offset().top;
|
337 |
+
offsetLeft = $( e.currentTarget ).offset().left;
|
338 |
createPopup( button );
|
339 |
} );
|
340 |
|
341 |
function createPopup( button ) {
|
342 |
|
343 |
var target = $( button.data( 'target' ) ),
|
344 |
+
preview = $( button.data( 'preview' ) ),
|
345 |
+
popup = $( '<div class="dashicon-picker-container">' +
|
346 |
+
'<div class="dashicon-picker-control"></div>' +
|
347 |
+
'<ul class="dashicon-picker-list"></ul>' +
|
348 |
+
'</div>' ).css( {
|
349 |
+
'top': offsetTop,
|
350 |
+
'left': offsetLeft
|
351 |
+
} ),
|
352 |
list = popup.find( '.dashicon-picker-list' );
|
353 |
|
354 |
for ( var i in icons ) {
|
355 |
+
if ( icons.hasOwnProperty(i) ) {
|
356 |
+
list.append('<li data-icon="' + icons[i] + '"><a href="#" title="' + icons[i] + '"><span class="dashicons dashicons-' + icons[i] + '"></span></a></li>');
|
357 |
+
}
|
358 |
}
|
359 |
|
360 |
+
$( 'a', list ).on( 'click', function ( e ) {
|
361 |
e.preventDefault();
|
362 |
var title = $( this ).attr( 'title' );
|
363 |
target.val( 'dashicons-' + title );
|
364 |
+
preview
|
365 |
+
.prop('class', 'dashicons')
|
366 |
+
.addClass( 'dashicons-' + title );
|
367 |
removePopup();
|
368 |
} );
|
369 |
|
370 |
var control = popup.find( '.dashicon-picker-control' );
|
371 |
|
372 |
+
control.html( '<a data-direction="back" href="#">' +
|
373 |
+
'<span class="dashicons dashicons-arrow-left-alt2"></span></a>' +
|
374 |
+
'<input type="text" class="" placeholder="Search" />' +
|
375 |
+
'<a data-direction="forward" href="#"><span class="dashicons dashicons-arrow-right-alt2"></span></a>'
|
376 |
);
|
377 |
|
378 |
+
$( 'a', control ).on( 'click', function ( e ) {
|
379 |
e.preventDefault();
|
380 |
if ( $( this ).data( 'direction' ) === 'back' ) {
|
381 |
$( 'li:gt(' + ( icons.length - 26 ) + ')', list ).prependTo( list );
|
386 |
|
387 |
popup.appendTo( 'body' ).show();
|
388 |
|
389 |
+
$( 'input', control ).on( 'keyup', function ( e ) {
|
390 |
var search = $( this ).val();
|
391 |
if ( search === '' ) {
|
392 |
$( 'li:lt(25)', list ).show();
|
401 |
}
|
402 |
} );
|
403 |
|
404 |
+
$( document ).on( 'mouseup.dashicons-picker', function ( e ) {
|
405 |
if ( ! popup.is( e.target ) && popup.has( e.target ).length === 0 ) {
|
406 |
removePopup();
|
407 |
}
|
410 |
|
411 |
function removePopup() {
|
412 |
$( '.dashicon-picker-container' ).remove();
|
413 |
+
$( document ).off( '.dashicons-picker' );
|
414 |
}
|
415 |
} );
|
416 |
};
|
js/dashicons-picker.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(a){a.fn.dashiconsPicker=function(){var b=["menu","admin-site","dashboard","admin-media","admin-page","admin-comments","admin-appearance","admin-plugins","admin-users","admin-tools","admin-settings","admin-network","admin-generic","admin-home","admin-collapse","filter","admin-customizer","admin-multisite","admin-links","format-links","admin-post","format-standard","format-image","format-gallery","format-audio","format-video","format-chat","format-status","format-aside","format-quote","welcome-write-blog","welcome-edit-page","welcome-add-page","welcome-view-site","welcome-widgets-menus","welcome-comments","welcome-learn-more","image-crop","image-rotate","image-rotate-left","image-rotate-right","image-flip-vertical","image-flip-horizontal","image-filter","undo","redo","editor-bold","editor-italic","editor-ul","editor-ol","editor-quote","editor-alignleft","editor-aligncenter","editor-alignright","editor-insertmore","editor-spellcheck","editor-distractionfree","editor-expand","editor-contract","editor-kitchensink","editor-underline","editor-justify","editor-textcolor","editor-paste-word","editor-paste-text","editor-removeformatting","editor-video","editor-customchar","editor-outdent","editor-indent","editor-help","editor-strikethrough","editor-unlink","editor-rtl","editor-break","editor-code","editor-paragraph","editor-table","align-left","align-right","align-center","align-none","lock","unlock","calendar","calendar-alt","visibility","hidden","post-status","edit","post-trash","trash","sticky","external","arrow-up","arrow-down","arrow-left","arrow-right","arrow-up-alt","arrow-down-alt","arrow-left-alt","arrow-right-alt","arrow-up-alt2","arrow-down-alt2","arrow-left-alt2","arrow-right-alt2","leftright","sort","randomize","list-view","excerpt-view","grid-view","hammer","art","migrate","performance","universal-access","universal-access-alt","tickets","nametag","clipboard","heart","megaphone","schedule","wordpress","wordpress-alt","pressthis","update","screenoptions","cart","feedback","cloud","translation","tag","category","archive","tagcloud","text","media-archive","media-audio","media-code","media-default","media-document","media-interactive","media-spreadsheet","media-text","media-video","playlist-audio","playlist-video","controls-play","controls-pause","controls-forward","controls-skipforward","controls-back","controls-skipback","controls-repeat","controls-volumeon","controls-volumeoff","yes","no","no-alt","plus","plus-alt","plus-alt2","minus","dismiss","marker","star-filled","star-half","star-empty","flag","info","warning","share","share1","share-alt","share-alt2","twitter","rss","email","email-alt","facebook","facebook-alt","networking","googleplus","location","location-alt","camera","images-alt","images-alt2","video-alt","video-alt2","video-alt3","vault","shield","shield-alt","sos","search","slides","analytics","chart-pie","chart-bar","chart-line","chart-area","groups","businessman","id","id-alt","products","awards","forms","testimonial","portfolio","book","book-alt","download","upload","backup","clock","lightbulb","microphone","desktop","tablet","smartphone","phone","smiley","index-card","carrot","building","store","album","palmtree","tickets-alt","money","thumbs-up","thumbs-down","layout","","",""];return this.each(function(){function c(c){var
|
1 |
+
!function(a){"use strict";a.fn.dashiconsPicker=function(){var b=["menu","admin-site","dashboard","admin-media","admin-page","admin-comments","admin-appearance","admin-plugins","admin-users","admin-tools","admin-settings","admin-network","admin-generic","admin-home","admin-collapse","filter","admin-customizer","admin-multisite","admin-links","format-links","admin-post","format-standard","format-image","format-gallery","format-audio","format-video","format-chat","format-status","format-aside","format-quote","welcome-write-blog","welcome-edit-page","welcome-add-page","welcome-view-site","welcome-widgets-menus","welcome-comments","welcome-learn-more","image-crop","image-rotate","image-rotate-left","image-rotate-right","image-flip-vertical","image-flip-horizontal","image-filter","undo","redo","editor-bold","editor-italic","editor-ul","editor-ol","editor-quote","editor-alignleft","editor-aligncenter","editor-alignright","editor-insertmore","editor-spellcheck","editor-distractionfree","editor-expand","editor-contract","editor-kitchensink","editor-underline","editor-justify","editor-textcolor","editor-paste-word","editor-paste-text","editor-removeformatting","editor-video","editor-customchar","editor-outdent","editor-indent","editor-help","editor-strikethrough","editor-unlink","editor-rtl","editor-break","editor-code","editor-paragraph","editor-table","align-left","align-right","align-center","align-none","lock","unlock","calendar","calendar-alt","visibility","hidden","post-status","edit","post-trash","trash","sticky","external","arrow-up","arrow-down","arrow-left","arrow-right","arrow-up-alt","arrow-down-alt","arrow-left-alt","arrow-right-alt","arrow-up-alt2","arrow-down-alt2","arrow-left-alt2","arrow-right-alt2","leftright","sort","randomize","list-view","excerpt-view","grid-view","hammer","art","migrate","performance","universal-access","universal-access-alt","tickets","nametag","clipboard","heart","megaphone","schedule","wordpress","wordpress-alt","pressthis","update","screenoptions","cart","feedback","cloud","translation","tag","category","archive","tagcloud","text","media-archive","media-audio","media-code","media-default","media-document","media-interactive","media-spreadsheet","media-text","media-video","playlist-audio","playlist-video","controls-play","controls-pause","controls-forward","controls-skipforward","controls-back","controls-skipback","controls-repeat","controls-volumeon","controls-volumeoff","yes","no","no-alt","plus","plus-alt","plus-alt2","minus","dismiss","marker","star-filled","star-half","star-empty","flag","info","warning","share","share1","share-alt","share-alt2","twitter","rss","email","email-alt","facebook","facebook-alt","networking","googleplus","location","location-alt","camera","images-alt","images-alt2","video-alt","video-alt2","video-alt3","vault","shield","shield-alt","sos","search","slides","analytics","chart-pie","chart-bar","chart-line","chart-area","groups","businessman","id","id-alt","products","awards","forms","testimonial","portfolio","book","book-alt","download","upload","backup","clock","lightbulb","microphone","desktop","tablet","smartphone","phone","smiley","index-card","carrot","building","store","album","palmtree","tickets-alt","money","thumbs-up","thumbs-down","layout","align-pull-left","align-pull-right","block-default","cloud-saved","cloud-upload","columns","cover-image","embed-audio","embed-generic","embed-photo","embed-post","embed-video","exit","html","info-outline","insert-after","insert-before","insert","remove","shortcode","table-col-after","table-col-before","table-col-delete","table-row-after","table-row-before","table-row-delete","saved","amazon","google","linkedin","pinterest","podio","reddit","spotify","twitch","whatsapp","xing","youtube","database-add","database-export","database-import","database-remove","database-view","database","bell","airplane","car","calculator","ames","printer","beer","coffee","drumstick","food","bank","hourglass","money-alt","open-folder","pdf","pets","privacy","superhero","superhero-alt","edit-page","fullscreen-alt","fullscreen-exit-alt","","",""];return this.each(function(){function c(c){var g=a(c.data("target")),h=a(c.data("preview")),i=a('<div class="dashicon-picker-container"><div class="dashicon-picker-control"></div><ul class="dashicon-picker-list"></ul></div>').css({top:e,left:f}),j=i.find(".dashicon-picker-list");for(var k in b)b.hasOwnProperty(k)&&j.append('<li data-icon="'+b[k]+'"><a href="#" title="'+b[k]+'"><span class="dashicons dashicons-'+b[k]+'"></span></a></li>');a("a",j).on("click",function(b){b.preventDefault();var c=a(this).attr("title");g.val("dashicons-"+c),h.prop("class","dashicons").addClass("dashicons-"+c),d()});var l=i.find(".dashicon-picker-control");l.html('<a data-direction="back" href="#"><span class="dashicons dashicons-arrow-left-alt2"></span></a><input type="text" class="" placeholder="Search" /><a data-direction="forward" href="#"><span class="dashicons dashicons-arrow-right-alt2"></span></a>'),a("a",l).on("click",function(c){c.preventDefault(),"back"===a(this).data("direction")?a("li:gt("+(b.length-26)+")",j).prependTo(j):a("li:lt(25)",j).appendTo(j)}),i.appendTo("body").show(),a("input",l).on("keyup",function(b){var c=a(this).val();""===c?a("li:lt(25)",j).show():a("li",j).each(function(){a(this).data("icon").toLowerCase().indexOf(c.toLowerCase())!==-1?a(this).show():a(this).hide()})}),a(document).on("mouseup.dashicons-picker",function(a){i.is(a.target)||0!==i.has(a.target).length||d()})}function d(){a(".dashicon-picker-container").remove(),a(document).off(".dashicons-picker")}var e,f,g=a(this);g.on("click.dashiconsPicker",function(b){e=a(b.currentTarget).offset().top,f=a(b.currentTarget).offset().left,c(g)})})},a(function(){a(".dashicons-picker").dashiconsPicker()})}(jQuery);
|
js/editor_plugin.dev.js
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* AddQuicktag Script to add the listbox button to the visual-editor TinyMCE.
|
3 |
+
*
|
4 |
+
* @package AddQuicktag Plugin
|
5 |
+
* @author Frank Bueltge <frank@bueltge.de>
|
6 |
+
* @version 2021-04-19
|
7 |
+
* @since 2.3.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
(function ($) {
|
11 |
+
|
12 |
+
if (typeof addquicktag_tags === 'undefined') {
|
13 |
+
return;
|
14 |
+
}
|
15 |
+
|
16 |
+
if (typeof addquicktag_post_type === 'undefined') {
|
17 |
+
return;
|
18 |
+
}
|
19 |
+
|
20 |
+
if (typeof addquicktag_pt_for_js === 'undefined') {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
// wrong post type
|
25 |
+
if (-1 === $.inArray(addquicktag_post_type, addquicktag_pt_for_js)) {
|
26 |
+
return;
|
27 |
+
}
|
28 |
+
|
29 |
+
// break, if not an button for visual and post type
|
30 |
+
var visual = 0,
|
31 |
+
post_type = 0,
|
32 |
+
i = 0;
|
33 |
+
|
34 |
+
for (i; i < addquicktag_tags.buttons.length; i++) {
|
35 |
+
// if not visual button in the list, return
|
36 |
+
if (1 === parseInt(addquicktag_tags.buttons[i]['visual'])) {
|
37 |
+
visual = addquicktag_tags.buttons[i]['visual'];
|
38 |
+
}
|
39 |
+
// check for active on this post type on each buttons
|
40 |
+
if (1 === parseInt(addquicktag_tags.buttons[i][addquicktag_post_type])) {
|
41 |
+
post_type = addquicktag_tags.buttons[i][addquicktag_post_type];
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
if (1 !== parseInt(visual)) {
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
|
49 |
+
if (1 !== parseInt(post_type)) {
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
|
53 |
+
// Add listbox plugin to TinyMCE editor.
|
54 |
+
tinymce.PluginManager.add('rmnlQuicktagSettings_tmce', function (editor) {
|
55 |
+
|
56 |
+
editor.addButton('rmnlQuicktagSettings_tmce', function () {
|
57 |
+
|
58 |
+
var tiny_tags = addquicktag_tags['buttons'],
|
59 |
+
values = [],
|
60 |
+
i = 0;
|
61 |
+
|
62 |
+
for (i; i < tiny_tags.length; i++) {
|
63 |
+
|
64 |
+
// check for active on this post type
|
65 |
+
if (1 === parseInt(tiny_tags[i][addquicktag_post_type])) {
|
66 |
+
|
67 |
+
// Create the list items with all custom values from settings.
|
68 |
+
// @see http://www.tinymce.com/wiki.php/api4:class.tinymce.ui.ListBox
|
69 |
+
if (1 === tiny_tags[i].visual) {
|
70 |
+
console.log( tiny_tags[ i ] );
|
71 |
+
values.push({
|
72 |
+
text: tiny_tags[i].text,
|
73 |
+
value: String(i),
|
74 |
+
tooltip: tiny_tags[i].title,
|
75 |
+
icon: 'icon dashicons dashicons-before ' + tiny_tags[i].dashicon
|
76 |
+
});
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
return {
|
82 |
+
type: 'listbox',
|
83 |
+
//name : 'align',
|
84 |
+
icon: '',
|
85 |
+
text: 'Quicktags',
|
86 |
+
label: 'Select :',
|
87 |
+
fixedWidth: true,
|
88 |
+
onselect: function (v) {
|
89 |
+
// For debugging purpose
|
90 |
+
console.log(v);
|
91 |
+
|
92 |
+
var // Set short var for the value identifier
|
93 |
+
// v = v.control._value,
|
94 |
+
// Change since WordPress 4.3 to new object values.
|
95 |
+
value = v.control.settings.value,
|
96 |
+
marked = false;
|
97 |
+
|
98 |
+
if (typeof (
|
99 |
+
tinymce.activeEditor.selection.getContent()
|
100 |
+
) !== 'undefined') {
|
101 |
+
marked = true;
|
102 |
+
}
|
103 |
+
|
104 |
+
if (marked === true) {
|
105 |
+
|
106 |
+
console.log(tiny_tags);
|
107 |
+
console.log(value);
|
108 |
+
|
109 |
+
var content = tinymce.activeEditor.selection.getContent(),
|
110 |
+
start_content = tinymce.activeEditor.selection.getStart().nodeName,
|
111 |
+
all = tinymce.activeEditor.selection.getNode(),
|
112 |
+
start = tiny_tags[value].start,
|
113 |
+
start_tag = start.match(/[a-z]+/),
|
114 |
+
end = tiny_tags[value].end;
|
115 |
+
|
116 |
+
if (typeof start === 'undefined') {
|
117 |
+
start = '';
|
118 |
+
}
|
119 |
+
|
120 |
+
if (typeof end === 'undefined') {
|
121 |
+
end = '';
|
122 |
+
}
|
123 |
+
|
124 |
+
/**/
|
125 |
+
// For debugging purpose
|
126 |
+
console.log(v);
|
127 |
+
console.log('TinyTags: ' + tiny_tags[value]);
|
128 |
+
console.log('start_content: ' + start_content);
|
129 |
+
console.log('start_content.nodeName: ' + tinymce.activeEditor.selection.getStart().nodeName);
|
130 |
+
console.log('start_content.outerHMTL: ' + tinymce.activeEditor.selection.getStart().outerHMTL);
|
131 |
+
console.log('Content: ' + content);
|
132 |
+
console.log(all);
|
133 |
+
console.log('Start tag: ' + start);
|
134 |
+
console.log('Start tag, only: ' + start.match(/[a-z]+/));
|
135 |
+
console.log('End tag: ' + end);
|
136 |
+
//console.log(start_content.indexOf( start ));
|
137 |
+
console.log('Search nodeName: ' + start_content.search(start));
|
138 |
+
/**/
|
139 |
+
|
140 |
+
// Add tag to content
|
141 |
+
if (start.match(/[a-z]+/i) !== start_content.toLowerCase()) {
|
142 |
+
tinymce.activeEditor.selection.setContent(
|
143 |
+
tiny_tags[value].start + content + tiny_tags[value].end
|
144 |
+
);
|
145 |
+
}
|
146 |
+
|
147 |
+
// Remove existing tag
|
148 |
+
if (start.match(/[a-z]+/i) === start_content.toLowerCase()) {
|
149 |
+
// Remove content with tag
|
150 |
+
tinyMCE.activeEditor.dom.remove(
|
151 |
+
tinymce.activeEditor.selection.getNode(
|
152 |
+
start_content.toLowerCase()
|
153 |
+
)
|
154 |
+
);
|
155 |
+
// Add content, without tag
|
156 |
+
tinymce.activeEditor.selection.setContent(
|
157 |
+
content
|
158 |
+
);
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
}
|
163 |
+
},
|
164 |
+
values: values
|
165 |
+
};
|
166 |
+
});
|
167 |
+
|
168 |
+
});
|
169 |
+
})(jQuery);
|
js/editor_plugin.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(a){if("undefined"!=typeof addquicktag_tags&&"undefined"!=typeof addquicktag_post_type&&"undefined"!=typeof addquicktag_pt_for_js&&-1!==a.inArray(addquicktag_post_type,addquicktag_pt_for_js)){var b=0,c=0,d=0;for(d;d<addquicktag_tags.buttons.length;d++)1===parseInt(addquicktag_tags.buttons[d].visual)&&(b=addquicktag_tags.buttons[d].visual),1===parseInt(addquicktag_tags.buttons[d][addquicktag_post_type])&&(c=addquicktag_tags.buttons[d][addquicktag_post_type]);1===parseInt(b)&&1===parseInt(c)&&tinymce.PluginManager.add("rmnlQuicktagSettings_tmce",function(a){a.addButton("rmnlQuicktagSettings_tmce",function(){var a=addquicktag_tags.buttons,b=[],c=0;for(c;c<a.length;c++)1===parseInt(a[c][addquicktag_post_type])&&1===a[c].visual&&b.push({text:a[c].text,value:String(c),tooltip:a[c].title,icon:"icon dashicons dashicons-before "+a[c].dashicon});return{type:"listbox",icon:"",text:"Quicktags",label:"Select :",fixedWidth:!0,onselect:function(b){var c=b.control.settings.value,d=!1;if("undefined"!=typeof tinymce.activeEditor.selection.getContent()&&(d=!0),d===!0){var e=tinymce.activeEditor.selection.getContent(),f=tinymce.activeEditor.selection.getStart().nodeName,g=(tinymce.activeEditor.selection.getNode(),a[c].start),h=(g.match(/[a-z]+/),a[c].end);"undefined"==typeof g&&(g=""),"undefined"==typeof h&&(h=""),g.match(/[a-z]+/i)!==f.toLowerCase()&&tinymce.activeEditor.selection.setContent(a[c].start+e+a[c].end),g.match(/[a-z]+/i)===f.toLowerCase()&&(tinyMCE.activeEditor.dom.remove(tinymce.activeEditor.selection.getNode(f.toLowerCase())),tinymce.activeEditor.selection.setContent(e))}},values:b}})})}}(jQuery);
|
{inc/tinymce → js}/langs/de.js
RENAMED
File without changes
|
{inc/tinymce → js}/langs/en.js
RENAMED
File without changes
|
js/settings.dev.js
CHANGED
@@ -1,104 +1,102 @@
|
|
1 |
/**
|
2 |
* AddQuicktag Script settings page of the plugin.
|
3 |
*
|
4 |
-
* @version
|
5 |
-
* @since 06/19
|
6 |
* @package AddQuicktag Plugin
|
7 |
*/
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
var i = $( this ).attr( 'value' ),
|
13 |
sel = '#rmqtb' + i + ' input:checkbox';
|
14 |
|
15 |
-
$(
|
16 |
-
}
|
17 |
|
18 |
-
$(
|
19 |
var hover = 'hover';
|
20 |
|
21 |
-
if (
|
22 |
-
$(
|
23 |
-
$(
|
24 |
} else {
|
25 |
-
$(
|
26 |
-
$(
|
27 |
}
|
28 |
-
}
|
29 |
|
30 |
-
$(
|
31 |
var hover = 'hover';
|
32 |
|
33 |
-
if (
|
34 |
-
$(
|
35 |
-
$(
|
36 |
} else {
|
37 |
-
$(
|
38 |
-
$(
|
39 |
}
|
40 |
-
}
|
41 |
|
42 |
-
$(
|
43 |
var hover = 'hover';
|
44 |
|
45 |
-
if (
|
46 |
-
$(
|
47 |
-
$(
|
48 |
} else {
|
49 |
-
$(
|
50 |
-
$(
|
51 |
}
|
52 |
-
}
|
53 |
-
}
|
54 |
|
55 |
/**
|
56 |
* Kudos to: http://codepen.io/jgx/pen/wiIGc
|
57 |
*/
|
58 |
-
(
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
}
|
82 |
-
$( this ).css( "width", $th_width + "px" );
|
83 |
-
} );
|
84 |
-
}
|
85 |
-
|
86 |
-
function scrollFixed() {
|
87 |
-
var offset = $( this ).scrollTop(),
|
88 |
-
tableOffsetTop = $this.offset().top,
|
89 |
-
tableOffsetBottom = tableOffsetTop + $this.height() - $this.find( "thead" ).height();
|
90 |
-
if ( offset < tableOffsetTop || offset > tableOffsetBottom ) {
|
91 |
-
$t_fixed.hide();
|
92 |
-
} else if ( offset >= tableOffsetTop && offset <= tableOffsetBottom && $t_fixed.is( ":hidden" ) ) {
|
93 |
-
$t_fixed.show();
|
94 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
|
|
96 |
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
)( jQuery );
|
1 |
/**
|
2 |
* AddQuicktag Script settings page of the plugin.
|
3 |
*
|
4 |
+
* @version 2021/04/08
|
5 |
+
* @since 2014/06/19
|
6 |
* @package AddQuicktag Plugin
|
7 |
*/
|
8 |
|
9 |
+
(function ($) {
|
10 |
+
$('input:checkbox.toggle').on('click', function () {
|
11 |
+
var i = $(this).attr('value'),
|
|
|
12 |
sel = '#rmqtb' + i + ' input:checkbox';
|
13 |
|
14 |
+
$(sel).prop('checked', this.checked);
|
15 |
+
});
|
16 |
|
17 |
+
$('table.rmnlQuicktagSettings').on('mouseover mouseout', 'td', function (e) {
|
18 |
var hover = 'hover';
|
19 |
|
20 |
+
if (e.type === 'mouseover') {
|
21 |
+
$(this).parent().addClass(hover);
|
22 |
+
$('table.rmnlQuicktagSettings colgroup').eq($(this).index()).addClass(hover);
|
23 |
} else {
|
24 |
+
$(this).parent().removeClass(hover);
|
25 |
+
$('table.rmnlQuicktagSettings colgroup').eq($(this).index()).removeClass(hover);
|
26 |
}
|
27 |
+
});
|
28 |
|
29 |
+
$('table.rmnlCoreQuicktagSettings').on('mouseover mouseout', 'td', function (e) {
|
30 |
var hover = 'hover';
|
31 |
|
32 |
+
if (e.type === 'mouseover') {
|
33 |
+
$(this).parent().addClass(hover);
|
34 |
+
$('table.rmnlCoreQuicktagSettings colgroup').eq($(this).index()).addClass(hover);
|
35 |
} else {
|
36 |
+
$(this).parent().removeClass(hover);
|
37 |
+
$('table.rmnlCoreQuicktagSettings colgroup').eq($(this).index()).removeClass(hover);
|
38 |
}
|
39 |
+
});
|
40 |
|
41 |
+
$('table.rmnlCodeQuicktagSettings').on('mouseover mouseout', 'td', function (e) {
|
42 |
var hover = 'hover';
|
43 |
|
44 |
+
if (e.type === 'mouseover') {
|
45 |
+
$(this).parent().addClass(hover);
|
46 |
+
$('table.rmnlCodeQuicktagSettings colgroup').eq($(this).index()).addClass(hover);
|
47 |
} else {
|
48 |
+
$(this).parent().removeClass(hover);
|
49 |
+
$('table.rmnlCodeQuicktagSettings colgroup').eq($(this).index()).removeClass(hover);
|
50 |
}
|
51 |
+
});
|
52 |
+
})(jQuery);
|
53 |
|
54 |
/**
|
55 |
* Kudos to: http://codepen.io/jgx/pen/wiIGc
|
56 |
*/
|
57 |
+
(function ($) {
|
58 |
+
'use strict';
|
59 |
+
$.fn.fixMe = function () {
|
60 |
+
return this.each(function () {
|
61 |
+
|
62 |
+
var $this = $(this),
|
63 |
+
$t_fixed, $x, $th_width;
|
64 |
+
|
65 |
+
function init() {
|
66 |
+
$this.wrap('<div class="container" />');
|
67 |
+
$t_fixed = $this.clone();
|
68 |
+
$t_fixed.find("tbody").remove().end().addClass("fixed").insertBefore($this);
|
69 |
+
resizeFixed();
|
70 |
+
}
|
71 |
+
|
72 |
+
function resizeFixed() {
|
73 |
+
$x = 0;
|
74 |
+
$t_fixed.find("th").each(function (index) {
|
75 |
+
$x++;
|
76 |
+
$th_width = $this.find("th").eq(index).outerWidth();
|
77 |
+
// The first 3 columns are sm
|
78 |
+
if ($x < 4) {
|
79 |
+
$th_width = $th_width - 11;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
81 |
+
$(this).css("width", $th_width + "px");
|
82 |
+
});
|
83 |
+
}
|
84 |
+
|
85 |
+
function scrollFixed() {
|
86 |
+
var offset = this.scrollTop(),
|
87 |
+
tableOffsetTop = $this.offset().top,
|
88 |
+
tableOffsetBottom = tableOffsetTop + $this.height() - $this.find("thead").height();
|
89 |
+
if (offset < tableOffsetTop || offset > tableOffsetBottom) {
|
90 |
+
$t_fixed.hide();
|
91 |
+
} else if (offset >= tableOffsetTop && offset <= tableOffsetBottom && $t_fixed.is(":hidden")) {
|
92 |
+
$t_fixed.show();
|
93 |
}
|
94 |
+
}
|
95 |
|
96 |
+
$(window).on('resize', resizeFixed);
|
97 |
+
$(window).on('scroll', scrollFixed);
|
98 |
+
init();
|
99 |
|
100 |
+
});
|
101 |
+
};
|
102 |
+
})(jQuery);
|
|
js/settings.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
1 |
+
!function(a){a("input:checkbox.toggle").on("click",function(){var b=a(this).attr("value"),c="#rmqtb"+b+" input:checkbox";a(c).prop("checked",this.checked)}),a("table.rmnlQuicktagSettings").on("mouseover mouseout","td",function(b){var c="hover";"mouseover"===b.type?(a(this).parent().addClass(c),a("table.rmnlQuicktagSettings colgroup").eq(a(this).index()).addClass(c)):(a(this).parent().removeClass(c),a("table.rmnlQuicktagSettings colgroup").eq(a(this).index()).removeClass(c))}),a("table.rmnlCoreQuicktagSettings").on("mouseover mouseout","td",function(b){var c="hover";"mouseover"===b.type?(a(this).parent().addClass(c),a("table.rmnlCoreQuicktagSettings colgroup").eq(a(this).index()).addClass(c)):(a(this).parent().removeClass(c),a("table.rmnlCoreQuicktagSettings colgroup").eq(a(this).index()).removeClass(c))}),a("table.rmnlCodeQuicktagSettings").on("mouseover mouseout","td",function(b){var c="hover";"mouseover"===b.type?(a(this).parent().addClass(c),a("table.rmnlCodeQuicktagSettings colgroup").eq(a(this).index()).addClass(c)):(a(this).parent().removeClass(c),a("table.rmnlCodeQuicktagSettings colgroup").eq(a(this).index()).removeClass(c))})}(jQuery),function(a){"use strict";a.fn.fixMe=function(){return this.each(function(){function b(){h.wrap('<div class="container" />'),e=h.clone(),e.find("tbody").remove().end().addClass("fixed").insertBefore(h),c()}function c(){f=0,e.find("th").each(function(b){f++,g=h.find("th").eq(b).outerWidth(),f<4&&(g-=11),a(this).css("width",g+"px")})}function d(){var a=this.scrollTop(),b=h.offset().top,c=b+h.height()-h.find("thead").height();a<b||a>c?e.hide():a>=b&&a<=c&&e.is(":hidden")&&e.show()}var e,f,g,h=a(this);a(window).on("resize",c),a(window).on("scroll",d),b()})}}(jQuery);
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
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:
|
6 |
-
Tested up to: 5
|
7 |
-
Stable tag: 2.
|
8 |
|
9 |
This plugin makes it easy to add Quicktags to the html - and visual-editor.
|
10 |
|
@@ -14,17 +14,17 @@ This plugin makes it easy to add Quicktags to the html - and visual-editor. It i
|
|
14 |
WP-AddQuicktag for WordPress is originally created by [Roel Meurders](http://roel.meurders.nl/ "Roel Meurders"). The versions in the Repo of AddQuicktag are newer versions, this is a complete rewrite of version 2.0.0 with more functionality.
|
15 |
|
16 |
The plugin can add configurable custom quicktags to the editor of every post type, including custom post types from other sources. You may choose a post type for which a quicktag shall show up in the editor.
|
17 |
-
If this should not work perfectly well for you, you may also use the hooks inside the plugin. See the examples and hint inside the tab "[Other Notes](
|
18 |
|
19 |
= Bugs, technical hints or contribute =
|
20 |
-
Please give me feedback, contribute and file technical bugs on [GitHub Repo](https://github.com/bueltge/
|
21 |
|
22 |
-
**Crafted by [Inpsyde](
|
23 |
|
24 |
|
25 |
== Installation ==
|
26 |
= Requirements =
|
27 |
-
* WordPress version
|
28 |
|
29 |
= Installation =
|
30 |
1. Unpack the download-package
|
@@ -32,17 +32,11 @@ Please give me feedback, contribute and file technical bugs on [GitHub Repo](htt
|
|
32 |
1. Activate the plugin through the 'Plugins' menu in WordPress or for the Network, if you will use in Multisite for all Sites
|
33 |
1. Got to 'Settings' menu and configure the plugin
|
34 |
|
35 |
-
**Versions before WordPress 3.0**
|
36 |
-
|
37 |
-
If you wish to use this plugin with an older version of WordPress, please use an older version of this plugin, older than version 2.0.0 - you find old versions in the [repo](http://wordpress.org/extend/plugins/addquicktag/download/). Anyway, I will not support this version. The plugin version 2.0.0 and newer are rewrites, that use all new possibilities of the WordPress Core that are not available in WordPress versions before 3.x.
|
38 |
-
|
39 |
-
|
40 |
== Screenshots ==
|
41 |
1. Settings area in WordPress 4.0-alpha
|
42 |
2. HTML Editor with new Quicktags
|
43 |
3. Visual editor with new Quicktags
|
44 |
|
45 |
-
|
46 |
== Other Notes ==
|
47 |
= Hook for custom post types =
|
48 |
The plugin adds the quicktag by default to post types/ID `post`, `page` and `comment`. To use the plugin for other post types also you may use a filter; see the following example or an example plugin in the [Gist 1595155](https://gist.github.com/1595155).
|
@@ -58,7 +52,6 @@ The plugin adds the quicktag by default to post types/ID `post`, `page` and `com
|
|
58 |
function my_addquicktag_post_types( $post_types ) {
|
59 |
|
60 |
$post_types[] = 'edit-comments';
|
61 |
-
|
62 |
return $post_types;
|
63 |
}
|
64 |
|
@@ -76,7 +69,6 @@ It is possible also to filter the pages inside the backend. By default the scrip
|
|
76 |
function my_addquicktag_pages( $page ) {
|
77 |
|
78 |
$page[] = 'edit-comments.php';
|
79 |
-
|
80 |
return $page;
|
81 |
}
|
82 |
|
@@ -120,16 +112,19 @@ The following example adds buttons. The params inside the array are the same as
|
|
120 |
'comment' => 0,
|
121 |
'edit-comments' => 0
|
122 |
);
|
123 |
-
|
124 |
return $buttons;
|
125 |
}
|
126 |
endif;
|
127 |
|
128 |
-
|
129 |
= License =
|
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 |
|
@@ -249,4 +244,4 @@ Good news, this plugin is free for everyone! Since it's released under the GPL,
|
|
249 |
= v1.6.3 (16/06/2009) =
|
250 |
* Add belorussian language file, thanks to Fat Cow
|
251 |
|
252 |
-
Find out about older changes on the [the official website](
|
2 |
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: 4.0
|
6 |
+
Tested up to: 5.7
|
7 |
+
Stable tag: 2.6.0
|
8 |
|
9 |
This plugin makes it easy to add Quicktags to the html - and visual-editor.
|
10 |
|
14 |
WP-AddQuicktag for WordPress is originally created by [Roel Meurders](http://roel.meurders.nl/ "Roel Meurders"). The versions in the Repo of AddQuicktag are newer versions, this is a complete rewrite of version 2.0.0 with more functionality.
|
15 |
|
16 |
The plugin can add configurable custom quicktags to the editor of every post type, including custom post types from other sources. You may choose a post type for which a quicktag shall show up in the editor.
|
17 |
+
If this should not work perfectly well for you, you may also use the hooks inside the plugin. See the examples and hint inside the tab "[Other Notes](https://wordpress.org/extend/plugins/addquicktag/other_notes/)".
|
18 |
|
19 |
= Bugs, technical hints or contribute =
|
20 |
+
Please give me feedback, contribute and file technical bugs on [GitHub Repo](https://github.com/bueltge/addquicktag). The Wiki on this page has also several hints for the plugin.
|
21 |
|
22 |
+
**Crafted by [Inpsyde](https://inpsyde.com) · Engineering the web since 2006.**
|
23 |
|
24 |
|
25 |
== Installation ==
|
26 |
= Requirements =
|
27 |
+
* WordPress version 4.0 and later (see _Compatible up to_)
|
28 |
|
29 |
= Installation =
|
30 |
1. Unpack the download-package
|
32 |
1. Activate the plugin through the 'Plugins' menu in WordPress or for the Network, if you will use in Multisite for all Sites
|
33 |
1. Got to 'Settings' menu and configure the plugin
|
34 |
|
|
|
|
|
|
|
|
|
|
|
35 |
== Screenshots ==
|
36 |
1. Settings area in WordPress 4.0-alpha
|
37 |
2. HTML Editor with new Quicktags
|
38 |
3. Visual editor with new Quicktags
|
39 |
|
|
|
40 |
== Other Notes ==
|
41 |
= Hook for custom post types =
|
42 |
The plugin adds the quicktag by default to post types/ID `post`, `page` and `comment`. To use the plugin for other post types also you may use a filter; see the following example or an example plugin in the [Gist 1595155](https://gist.github.com/1595155).
|
52 |
function my_addquicktag_post_types( $post_types ) {
|
53 |
|
54 |
$post_types[] = 'edit-comments';
|
|
|
55 |
return $post_types;
|
56 |
}
|
57 |
|
69 |
function my_addquicktag_pages( $page ) {
|
70 |
|
71 |
$page[] = 'edit-comments.php';
|
|
|
72 |
return $page;
|
73 |
}
|
74 |
|
112 |
'comment' => 0,
|
113 |
'edit-comments' => 0
|
114 |
);
|
|
|
115 |
return $buttons;
|
116 |
}
|
117 |
endif;
|
118 |
|
|
|
119 |
= License =
|
120 |
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 ;)
|
121 |
|
122 |
== Changelog ==
|
123 |
+
= 2.6.0 (2021-04-29) =
|
124 |
+
* Maintenance for the jQuery Update to run with the last WP Core update, jQuery 3.5*
|
125 |
+
* Maintenance several code styles, testing PHP7/8
|
126 |
+
* Remove dependecies for WP version smaller 3.3
|
127 |
+
|
128 |
= 2.5.3 (2018-11-06) =
|
129 |
* Fix error warning in edit mode without button settings.
|
130 |
|
244 |
= v1.6.3 (16/06/2009) =
|
245 |
* Add belorussian language file, thanks to Fat Cow
|
246 |
|
247 |
+
Find out about older changes on the [the official website](https://bueltge.de/wp-addquicktags-de-plugin/120/#historie "AddQuicktag")!
|