Version Description
Download this release
Release Info
Developer | artstorm |
Plugin | Post Snippets |
Version | 2.3.8 |
Comparing to | |
See all releases |
Code changes from version 2.3.7 to 2.3.8
- assets/post-snippets.css +7 -2
- assets/post-snippets.js +60 -0
- post-snippets.php +1 -1
- readme.txt +6 -2
- src/PostSnippets/Admin.php +34 -2
assets/post-snippets.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/**
|
2 |
-
* Styling for the jQuery UI dialog used by Post Snippets
|
3 |
*
|
4 |
* @version 2.0
|
5 |
* @since Post Snippets 1.7.1
|
@@ -8,7 +8,7 @@
|
|
8 |
/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
|
9 |
position: relative;
|
10 |
padding: .2em;
|
11 |
-
zoom: 1;
|
12 |
}
|
13 |
#post-snippets-tabs .ui-tabs-nav {
|
14 |
margin: 0;
|
@@ -72,4 +72,9 @@
|
|
72 |
#post-snippets-dialog label {
|
73 |
width: 60px;
|
74 |
display: inline-block;
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
1 |
/**
|
2 |
+
* Styling for the jQuery UI dialog used by Post Snippets
|
3 |
*
|
4 |
* @version 2.0
|
5 |
* @since Post Snippets 1.7.1
|
8 |
/* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
|
9 |
position: relative;
|
10 |
padding: .2em;
|
11 |
+
zoom: 1;
|
12 |
}
|
13 |
#post-snippets-tabs .ui-tabs-nav {
|
14 |
margin: 0;
|
72 |
#post-snippets-dialog label {
|
73 |
width: 60px;
|
74 |
display: inline-block;
|
75 |
+
}
|
76 |
+
|
77 |
+
.post-snippets-invalid {
|
78 |
+
background-color: #ffaaaa !important;
|
79 |
+
border: 1px solid #ff0000 !important;
|
80 |
}
|
assets/post-snippets.js
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(document).ready(function($)
|
2 |
+
{
|
3 |
+
/**
|
4 |
+
* Loops through all snippets when page has loaded.
|
5 |
+
*/
|
6 |
+
$("input[name$='_title']").each(function(index)
|
7 |
+
{
|
8 |
+
validateTitle($(this).prop('name'));
|
9 |
+
});
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Listens for title text input change events.
|
13 |
+
*/
|
14 |
+
$("input[name$='_title']").change(function (e)
|
15 |
+
{
|
16 |
+
validateTitle(e.target.name);
|
17 |
+
});
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Listens for shortcode checkbox change events.
|
21 |
+
*/
|
22 |
+
$("input[name$='_shortcode']").change(function (e)
|
23 |
+
{
|
24 |
+
validateTitle(e.target.name);
|
25 |
+
});
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Handle title validation and managing CSS classes.
|
29 |
+
*
|
30 |
+
* @param string name
|
31 |
+
*
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
function validateTitle(name)
|
35 |
+
{
|
36 |
+
// Extract the snippet index number
|
37 |
+
var index = name.substring(0, name.indexOf('_'));
|
38 |
+
|
39 |
+
var element = $("input[name$='"+index+"_title']");
|
40 |
+
var title = $("input[name$='"+index+"_title']").val();
|
41 |
+
|
42 |
+
$(element).removeClass('post-snippets-invalid');
|
43 |
+
|
44 |
+
if ($('#'+index+'_shortcode').prop('checked') && !isTitleValid(title)) {
|
45 |
+
$(element).addClass('post-snippets-invalid');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Determine if a title is shortcode valid.
|
51 |
+
*
|
52 |
+
* @param string title
|
53 |
+
*
|
54 |
+
* @return boolean
|
55 |
+
*/
|
56 |
+
function isTitleValid(title)
|
57 |
+
{
|
58 |
+
return !Boolean(title.match(/[<>&/\[\]\x00-\x20]/gi));
|
59 |
+
}
|
60 |
+
});
|
post-snippets.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://johansteen.se/code/post-snippets/
|
|
5 |
Description: Build a library with snippets of HTML, PHP code or reoccurring text that you often use in your posts. Variables to replace parts of the snippet on insert can be used. The snippets can be inserted as-is or as shortcodes.
|
6 |
Author: Johan Steen
|
7 |
Author URI: http://johansteen.se/
|
8 |
-
Version: 2.3.
|
9 |
License: GPLv2 or later
|
10 |
Text Domain: post-snippets
|
11 |
Domain Path: /lang
|
5 |
Description: Build a library with snippets of HTML, PHP code or reoccurring text that you often use in your posts. Variables to replace parts of the snippet on insert can be used. The snippets can be inserted as-is or as shortcodes.
|
6 |
Author: Johan Steen
|
7 |
Author URI: http://johansteen.se/
|
8 |
+
Version: 2.3.8
|
9 |
License: GPLv2 or later
|
10 |
Text Domain: post-snippets
|
11 |
Domain Path: /lang
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: artstorm
|
|
3 |
Donate link: http://johansteen.se/donate/
|
4 |
Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
|
5 |
Requires at least: 3.3
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 2.3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -128,6 +128,10 @@ Contributions are appreciated and encouraged.
|
|
128 |
|
129 |
== Changelog ==
|
130 |
|
|
|
|
|
|
|
|
|
131 |
= Version 2.3.7 - 4 Nov 2015 =
|
132 |
* Updates translatable strings to be Language Pack compatible.
|
133 |
|
3 |
Donate link: http://johansteen.se/donate/
|
4 |
Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
|
5 |
Requires at least: 3.3
|
6 |
+
Tested up to: 4.4
|
7 |
+
Stable tag: 2.3.8
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
128 |
|
129 |
== Changelog ==
|
130 |
|
131 |
+
= Version 2.3.8 - 10 Dec 2015 =
|
132 |
+
* Adds validation of shortcode names. Invalid shortcode names now gets
|
133 |
+
highlighted in red.
|
134 |
+
|
135 |
= Version 2.3.7 - 4 Nov 2015 =
|
136 |
* Updates translatable strings to be Language Pack compatible.
|
137 |
|
src/PostSnippets/Admin.php
CHANGED
@@ -13,6 +13,7 @@ class PostSnippets_Admin
|
|
13 |
public function __construct()
|
14 |
{
|
15 |
add_filter('plugin_action_links', array(&$this, 'actionLinks'), 10, 2);
|
|
|
16 |
add_action('admin_menu', array(&$this, 'menu'));
|
17 |
add_action('current_screen', array(&$this, 'addHeaderXss'));
|
18 |
}
|
@@ -44,7 +45,23 @@ class PostSnippets_Admin
|
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
* Initialize the administration page.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
*/
|
49 |
public function menu()
|
50 |
{
|
@@ -66,7 +83,7 @@ class PostSnippets_Admin
|
|
66 |
);
|
67 |
new PostSnippets_Help($optionPage);
|
68 |
} else {
|
69 |
-
$
|
70 |
'Post Snippets',
|
71 |
'Post Snippets',
|
72 |
'edit_posts',
|
@@ -74,6 +91,21 @@ class PostSnippets_Admin
|
|
74 |
array(&$this, 'overviewPage')
|
75 |
);
|
76 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
|
79 |
/**
|
13 |
public function __construct()
|
14 |
{
|
15 |
add_filter('plugin_action_links', array(&$this, 'actionLinks'), 10, 2);
|
16 |
+
add_action('admin_init', array(&$this, 'init'));
|
17 |
add_action('admin_menu', array(&$this, 'menu'));
|
18 |
add_action('current_screen', array(&$this, 'addHeaderXss'));
|
19 |
}
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
+
* Initialize assets for the administration page.
|
49 |
+
*
|
50 |
+
* @return void
|
51 |
+
*/
|
52 |
+
public function init()
|
53 |
+
{
|
54 |
+
wp_register_script(
|
55 |
+
'post-snippets',
|
56 |
+
plugins_url('/assets/post-snippets.js', PostSnippets::FILE),
|
57 |
+
array('jquery')
|
58 |
+
);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Register the administration page.
|
63 |
+
*
|
64 |
+
* @return void
|
65 |
*/
|
66 |
public function menu()
|
67 |
{
|
83 |
);
|
84 |
new PostSnippets_Help($optionPage);
|
85 |
} else {
|
86 |
+
$optionPage = add_options_page(
|
87 |
'Post Snippets',
|
88 |
'Post Snippets',
|
89 |
'edit_posts',
|
91 |
array(&$this, 'overviewPage')
|
92 |
);
|
93 |
}
|
94 |
+
|
95 |
+
add_action(
|
96 |
+
'admin_print_scripts-'.$optionPage,
|
97 |
+
array(&$this, 'scripts')
|
98 |
+
);
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Enqueue scripts to be loaded.
|
103 |
+
*
|
104 |
+
* @return void
|
105 |
+
*/
|
106 |
+
public function scripts()
|
107 |
+
{
|
108 |
+
wp_enqueue_script('post-snippets');
|
109 |
}
|
110 |
|
111 |
/**
|