Version Description
Download this release
Release Info
Developer | artstorm |
Plugin | Post Snippets |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.9.7 to 2.0
- assets/post-snippets.css +6 -0
- classes/help.php +267 -267
- classes/import-export.php +136 -0
- classes/settings.php +427 -281
- languages/post-snippets.pot +76 -67
- post-snippets.php +808 -984
- readme.txt +14 -5
- screenshot-1.jpg +0 -0
- screenshot-3.jpg +0 -0
- screenshot-4.jpg +0 -0
- uninstall.php +3 -3
assets/post-snippets.css
CHANGED
@@ -67,3 +67,9 @@
|
|
67 |
#post-snippets-tabs .ui-tabs-hide {
|
68 |
display: none !important;
|
69 |
}
|
|
|
|
|
|
|
|
|
|
|
|
67 |
#post-snippets-tabs .ui-tabs-hide {
|
68 |
display: none !important;
|
69 |
}
|
70 |
+
|
71 |
+
|
72 |
+
#post-snippets-dialog label {
|
73 |
+
width: 60px;
|
74 |
+
display: inline-block;
|
75 |
+
}
|
classes/help.php
CHANGED
@@ -1,267 +1,267 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Post Snippets Help.
|
4 |
-
*
|
5 |
-
* Class to handle the help texts and tabs on the settings screen.
|
6 |
-
*
|
7 |
-
* @package Post Snippets
|
8 |
-
* @author Johan Steen <artstorm at gmail dot com>
|
9 |
-
* @since Post Snippets 1.8.9
|
10 |
-
*/
|
11 |
-
class Post_Snippets_Help
|
12 |
-
{
|
13 |
-
/**
|
14 |
-
* Constructor.
|
15 |
-
*
|
16 |
-
* @since Post Snippets 1.8.9
|
17 |
-
* @param string The option page to load the help text on
|
18 |
-
*/
|
19 |
-
public function __construct( $option_page )
|
20 |
-
{
|
21 |
-
// If WordPress is 3.3 or higher, use the new Help API, otherwise call
|
22 |
-
// the old contextual help action.
|
23 |
-
global $wp_version;
|
24 |
-
if ( version_compare($wp_version, '3.3', '>=') ) {
|
25 |
-
add_action( 'load-' . $option_page, array(&$this,'add_help_tabs') );
|
26 |
-
} else {
|
27 |
-
add_action( 'contextual_help', array(&$this,'add_help'), 10, 3 );
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Setup the help tabs and sidebar.
|
33 |
-
*
|
34 |
-
* @since Post Snippets 1.8.9
|
35 |
-
*/
|
36 |
-
public function add_help_tabs() {
|
37 |
-
$screen = get_current_screen();
|
38 |
-
$screen->set_help_sidebar( $this->help_sidebar() );
|
39 |
-
$screen->add_help_tab( array(
|
40 |
-
'id' => 'basic-plugin-help',
|
41 |
-
'title' => __( 'Basic', 'post-snippets' ),
|
42 |
-
'content' => $this->help_basic()
|
43 |
-
) );
|
44 |
-
$screen->add_help_tab( array(
|
45 |
-
'id' => 'shortcode-plugin-help',
|
46 |
-
'title' => __( 'Shortcode', 'post-snippets' ),
|
47 |
-
'content' => $this->help_shortcode()
|
48 |
-
) );
|
49 |
-
$screen->add_help_tab( array(
|
50 |
-
'id' => 'php-plugin-help',
|
51 |
-
'title' => __( 'PHP', 'post-snippets' ),
|
52 |
-
'content' => $this->help_php()
|
53 |
-
) );
|
54 |
-
$screen->add_help_tab( array(
|
55 |
-
'id' => 'advanced-plugin-help',
|
56 |
-
'title' => __( 'Advanced', 'post-snippets' ),
|
57 |
-
'content' => $this->help_advanced()
|
58 |
-
) );
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* The right sidebar help text.
|
63 |
-
*
|
64 |
-
* @since Post Snippets 1.8.9
|
65 |
-
* @return string The help text
|
66 |
-
*/
|
67 |
-
public function help_sidebar()
|
68 |
-
{
|
69 |
-
return '<p><strong>'.
|
70 |
-
__( 'For more information:', 'post-snippets' ).
|
71 |
-
'</strong></p>
|
72 |
-
|
73 |
-
<p><a href="http://wpstorm.net/wordpress-plugins/post-snippets/" target="_blank">'.
|
74 |
-
__( 'Post Snippets Documentation', 'post-snippets' ).
|
75 |
-
'</a></p>
|
76 |
-
|
77 |
-
<p><a href="http://wordpress.org/tags/post-snippets?forum_id=10" target="_blank">'.
|
78 |
-
__( 'Support Forums', 'post-snippets' ).
|
79 |
-
'</a></p>';
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* The basic help tab.
|
84 |
-
*
|
85 |
-
* @since Post Snippets 1.9.1
|
86 |
-
* @return string The help text
|
87 |
-
*/
|
88 |
-
public function help_basic()
|
89 |
-
{
|
90 |
-
return '<h2>'.
|
91 |
-
__( 'Title', 'post-snippets' ).
|
92 |
-
'</h2>
|
93 |
-
<p>'.
|
94 |
-
__( 'Give the snippet a title that helps you identify it in the post editor. This also becomes the name of the shortcode if you enable that option', 'post-snippets' ).
|
95 |
-
'</p>
|
96 |
-
|
97 |
-
<h2>'.
|
98 |
-
__( 'Variables', 'post-snippets' ).
|
99 |
-
'</h2>
|
100 |
-
<p>'.
|
101 |
-
__( 'A comma separated list of custom variables you can reference in your snippet. A variable can also be assigned a default value that will be used in the insert window by using the equal sign, variable=default.', 'post-snippets' ).
|
102 |
-
'</p>
|
103 |
-
<p><strong>'.
|
104 |
-
__( 'Example', 'post-snippets' ).
|
105 |
-
'</strong><br/>
|
106 |
-
<code>url,name,role=user,title</code></p>'.
|
107 |
-
|
108 |
-
'<h2>'.
|
109 |
-
__( 'Snippet', 'post-snippets' ).
|
110 |
-
'</h2>
|
111 |
-
<p>'.
|
112 |
-
__('This is the block of text, HTML or PHP to insert in the post or as a shortcode. If you have entered predefined variables you can reference them from the snippet by enclosing them in {} brackets.', 'post-snippets' ).
|
113 |
-
'</p>
|
114 |
-
<p><strong>'.
|
115 |
-
__( 'Example', 'post-snippets' ).
|
116 |
-
'</strong><br/>'.
|
117 |
-
__( 'To reference the variables in the example above, you would enter {url} and {name}. So if you enter this snippet:', 'post-snippets' ).
|
118 |
-
'<br/>
|
119 |
-
<code>This is the website of <a href="{url}">{name}</a></code>
|
120 |
-
<br/>'.
|
121 |
-
__( 'You will get the option to replace url and name on insert if they are defined as variables.', 'post-snippets').
|
122 |
-
'</p>
|
123 |
-
|
124 |
-
<h2>'
|
125 |
-
. __( 'Description', 'post-snippets' ).
|
126 |
-
'</h2>
|
127 |
-
<p>'.
|
128 |
-
__( 'An optional description for the Snippet. If filled out, the description will be displayed in the snippets insert window in the post editor.', 'post-snippets').
|
129 |
-
'</p>';
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* The shortcode help tab.
|
134 |
-
*
|
135 |
-
* @since Post Snippets 1.9.1
|
136 |
-
* @return string The help text
|
137 |
-
*/
|
138 |
-
public function help_shortcode()
|
139 |
-
{
|
140 |
-
return '<p>'.
|
141 |
-
__( 'When enabling the shortcode checkbox, the snippet is no longer inserted directly but instead inserted as a shortcode. The obvious advantage of this is of course that you can insert a block of text or code in many places on the site, and update the content from one single place.', 'post-snippets' ).
|
142 |
-
'</p>
|
143 |
-
|
144 |
-
<p>'.
|
145 |
-
__( 'The name to use the shortcode is the same as the title of the snippet (spaces are not allowed). When inserting a shortcode snippet, the shortcode and not the content will be inserted in the post.', 'post-snippets' ).
|
146 |
-
'</p>
|
147 |
-
<p>'.
|
148 |
-
__( 'If you enclose the shortcode in your posts, you can access the enclosed content by using the variable {content} in your snippet. The {content} variable is reserved, so don\'t use it in the variables field.', 'post-snippets' ).
|
149 |
-
'</p>
|
150 |
-
|
151 |
-
<h2>'
|
152 |
-
. __( 'Options', 'post-snippets' ).
|
153 |
-
'</h2>
|
154 |
-
<p><strong>PHP</strong><br/>'.
|
155 |
-
__( 'See the dedicated help section for information about PHP shortcodes.', 'post-snippets' ).
|
156 |
-
'</p>
|
157 |
-
<p><strong>wptexturize</strong><br/>'.
|
158 |
-
sprintf(__( 'Before the shortcode is outputted, it can optionally be formatted with %s, to transform quotes to smart quotes, apostrophes, dashes, ellipses, the trademark symbol, and the multiplication symbol.', 'post-snippets' ), '<a href="http://codex.wordpress.org/Function_Reference/wptexturize">wptexturize</a>' ).
|
159 |
-
'</p>';
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* The PHP help tab.
|
164 |
-
*
|
165 |
-
* @since Post Snippets 1.9.1
|
166 |
-
* @return string The help text
|
167 |
-
*/
|
168 |
-
public function help_php()
|
169 |
-
{
|
170 |
-
return '<p>'.
|
171 |
-
__('Snippets defined as shortcodes can optionally also be evaluated as PHP Code by enabling the PHP checkbox. PHP snippets is only available when treating the snippet as a shortcode.', 'post-snippets' ).
|
172 |
-
'</p>
|
173 |
-
<p><strong>'.
|
174 |
-
__( 'Example PHP Snippet', 'post-snippets' ).
|
175 |
-
'</strong><br/>
|
176 |
-
<code>
|
177 |
-
for ($i=1; $i<5; $i++) {<br/>
|
178 |
-
echo "{loop_me}<br/>";<br/>
|
179 |
-
};
|
180 |
-
</code></p>
|
181 |
-
|
182 |
-
<p>'.
|
183 |
-
__( 'With a snippet defined like the one above, you can call it with its shortcode definition in a post. Let\'s pretend that the example snippet is named phpcode and have one variable defined loop_me, then it would be called like this from a post:' , 'post-snippets' ).
|
184 |
-
'</p>
|
185 |
-
|
186 |
-
<code>[phpcode loop_me="post snippet with PHP!"]</code>
|
187 |
-
|
188 |
-
<p>'.
|
189 |
-
__( 'When the shortcode is executed the loop_me variable will be replaced with the string supplied in the shortcode and then the PHP code will be evaluated. (Outputting the string five times in this case. Wow!)', 'post-snippets' ).
|
190 |
-
'</p>
|
191 |
-
<p>'.
|
192 |
-
__( 'Note the evaluation order, any snippet variables will be replaced before the snippet is evaluated as PHP code. Also note that a PHP snippet don\'t need to be wrapped in <?php #code; ?>.', 'post-snippets' ).
|
193 |
-
'</p>';
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* The advanced help tab.
|
198 |
-
*
|
199 |
-
* @since Post Snippets 1.9.1
|
200 |
-
* @return string The help text
|
201 |
-
*/
|
202 |
-
public function help_advanced()
|
203 |
-
{
|
204 |
-
return '<p>'.
|
205 |
-
__('You can retrieve a Post Snippet directly from PHP, in a theme for instance, by using the get_post_snippet() function.', 'post-snippets').
|
206 |
-
'</p>
|
207 |
-
|
208 |
-
<h2>'.
|
209 |
-
__('Usage', 'post-snippets').
|
210 |
-
'</h2>
|
211 |
-
<p>'.
|
212 |
-
'<code>
|
213 |
-
<?php $my_snippet = get_post_snippet( $snippet_name, $snippet_vars ); ?>
|
214 |
-
</code></p>
|
215 |
-
|
216 |
-
<h2>'.
|
217 |
-
__('Parameters', 'post-snippets').
|
218 |
-
'</h2>
|
219 |
-
<p>
|
220 |
-
<code>$snippet_name</code><br/>'.
|
221 |
-
__('(string) (required) The name of the snippet to retrieve.', 'post-snippets').
|
222 |
-
|
223 |
-
'<br/><br/><code>'.
|
224 |
-
'$snippet_vars
|
225 |
-
</code><br/>'.
|
226 |
-
__('(string) The variables to pass to the snippet, formatted as a query string.', 'post-snippets').
|
227 |
-
'</p>
|
228 |
-
|
229 |
-
<h2>'.
|
230 |
-
__('Example', 'post-snippets').
|
231 |
-
'</h2>
|
232 |
-
<p><code>
|
233 |
-
<?php<br/>
|
234 |
-
$my_snippet = get_post_snippet( \'internal-link\', \'title=Awesome&url=2011/02/awesome/\' );<br/>
|
235 |
-
echo $my_snippet;<br/>
|
236 |
-
?>
|
237 |
-
</code></p>';
|
238 |
-
}
|
239 |
-
|
240 |
-
|
241 |
-
// -------------------------------------------------------------------------
|
242 |
-
// For compability with WordPress before v3.3.
|
243 |
-
// -------------------------------------------------------------------------
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Contextual Help for WP < v3.3.
|
247 |
-
*
|
248 |
-
* Combines the help tabs above into one long help text for the help tab
|
249 |
-
* when run on WordPress versions before v3.3.
|
250 |
-
*
|
251 |
-
* @since Post Snippets 1.7.1
|
252 |
-
* @return string The Contextual Help
|
253 |
-
*/
|
254 |
-
public function add_help($contextual_help, $screen_id, $screen) {
|
255 |
-
if ( $screen->id == 'settings_page_post-snippets/post-snippets' ) {
|
256 |
-
$contextual_help = '<h1>'.__( 'Basic', 'post-snippets' ).'</h1>';
|
257 |
-
$contextual_help .= $this->help_basic();
|
258 |
-
$contextual_help .= '<h1>'.__( 'Shortcode', 'post-snippets' ).'</h1>';
|
259 |
-
$contextual_help .= $this->help_shortcode();
|
260 |
-
$contextual_help .= '<h1>'.__( 'PHP', 'post-snippets' ).'</h1>';
|
261 |
-
$contextual_help .= $this->help_php();
|
262 |
-
$contextual_help .= '<h1>'.__( 'Advanced', 'post-snippets' ).'</h1>';
|
263 |
-
$contextual_help .= $this->help_advanced();
|
264 |
-
}
|
265 |
-
return $contextual_help;
|
266 |
-
}
|
267 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Post Snippets Help.
|
4 |
+
*
|
5 |
+
* Class to handle the help texts and tabs on the settings screen.
|
6 |
+
*
|
7 |
+
* @package Post Snippets
|
8 |
+
* @author Johan Steen <artstorm at gmail dot com>
|
9 |
+
* @since Post Snippets 1.8.9
|
10 |
+
*/
|
11 |
+
class Post_Snippets_Help extends Post_Snippets_Base
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Constructor.
|
15 |
+
*
|
16 |
+
* @since Post Snippets 1.8.9
|
17 |
+
* @param string The option page to load the help text on
|
18 |
+
*/
|
19 |
+
public function __construct( $option_page )
|
20 |
+
{
|
21 |
+
// If WordPress is 3.3 or higher, use the new Help API, otherwise call
|
22 |
+
// the old contextual help action.
|
23 |
+
global $wp_version;
|
24 |
+
if ( version_compare($wp_version, '3.3', '>=') ) {
|
25 |
+
add_action( 'load-' . $option_page, array(&$this,'add_help_tabs') );
|
26 |
+
} else {
|
27 |
+
add_action( 'contextual_help', array(&$this,'add_help'), 10, 3 );
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Setup the help tabs and sidebar.
|
33 |
+
*
|
34 |
+
* @since Post Snippets 1.8.9
|
35 |
+
*/
|
36 |
+
public function add_help_tabs() {
|
37 |
+
$screen = get_current_screen();
|
38 |
+
$screen->set_help_sidebar( $this->help_sidebar() );
|
39 |
+
$screen->add_help_tab( array(
|
40 |
+
'id' => 'basic-plugin-help',
|
41 |
+
'title' => __( 'Basic', 'post-snippets' ),
|
42 |
+
'content' => $this->help_basic()
|
43 |
+
) );
|
44 |
+
$screen->add_help_tab( array(
|
45 |
+
'id' => 'shortcode-plugin-help',
|
46 |
+
'title' => __( 'Shortcode', 'post-snippets' ),
|
47 |
+
'content' => $this->help_shortcode()
|
48 |
+
) );
|
49 |
+
$screen->add_help_tab( array(
|
50 |
+
'id' => 'php-plugin-help',
|
51 |
+
'title' => __( 'PHP', 'post-snippets' ),
|
52 |
+
'content' => $this->help_php()
|
53 |
+
) );
|
54 |
+
$screen->add_help_tab( array(
|
55 |
+
'id' => 'advanced-plugin-help',
|
56 |
+
'title' => __( 'Advanced', 'post-snippets' ),
|
57 |
+
'content' => $this->help_advanced()
|
58 |
+
) );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* The right sidebar help text.
|
63 |
+
*
|
64 |
+
* @since Post Snippets 1.8.9
|
65 |
+
* @return string The help text
|
66 |
+
*/
|
67 |
+
public function help_sidebar()
|
68 |
+
{
|
69 |
+
return '<p><strong>'.
|
70 |
+
__( 'For more information:', 'post-snippets' ).
|
71 |
+
'</strong></p>
|
72 |
+
|
73 |
+
<p><a href="http://wpstorm.net/wordpress-plugins/post-snippets/" target="_blank">'.
|
74 |
+
__( 'Post Snippets Documentation', 'post-snippets' ).
|
75 |
+
'</a></p>
|
76 |
+
|
77 |
+
<p><a href="http://wordpress.org/tags/post-snippets?forum_id=10" target="_blank">'.
|
78 |
+
__( 'Support Forums', 'post-snippets' ).
|
79 |
+
'</a></p>';
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* The basic help tab.
|
84 |
+
*
|
85 |
+
* @since Post Snippets 1.9.1
|
86 |
+
* @return string The help text
|
87 |
+
*/
|
88 |
+
public function help_basic()
|
89 |
+
{
|
90 |
+
return '<h2>'.
|
91 |
+
__( 'Title', 'post-snippets' ).
|
92 |
+
'</h2>
|
93 |
+
<p>'.
|
94 |
+
__( 'Give the snippet a title that helps you identify it in the post editor. This also becomes the name of the shortcode if you enable that option', 'post-snippets' ).
|
95 |
+
'</p>
|
96 |
+
|
97 |
+
<h2>'.
|
98 |
+
__( 'Variables', 'post-snippets' ).
|
99 |
+
'</h2>
|
100 |
+
<p>'.
|
101 |
+
__( 'A comma separated list of custom variables you can reference in your snippet. A variable can also be assigned a default value that will be used in the insert window by using the equal sign, variable=default.', 'post-snippets' ).
|
102 |
+
'</p>
|
103 |
+
<p><strong>'.
|
104 |
+
__( 'Example', 'post-snippets' ).
|
105 |
+
'</strong><br/>
|
106 |
+
<code>url,name,role=user,title</code></p>'.
|
107 |
+
|
108 |
+
'<h2>'.
|
109 |
+
__( 'Snippet', 'post-snippets' ).
|
110 |
+
'</h2>
|
111 |
+
<p>'.
|
112 |
+
__('This is the block of text, HTML or PHP to insert in the post or as a shortcode. If you have entered predefined variables you can reference them from the snippet by enclosing them in {} brackets.', 'post-snippets' ).
|
113 |
+
'</p>
|
114 |
+
<p><strong>'.
|
115 |
+
__( 'Example', 'post-snippets' ).
|
116 |
+
'</strong><br/>'.
|
117 |
+
__( 'To reference the variables in the example above, you would enter {url} and {name}. So if you enter this snippet:', 'post-snippets' ).
|
118 |
+
'<br/>
|
119 |
+
<code>This is the website of <a href="{url}">{name}</a></code>
|
120 |
+
<br/>'.
|
121 |
+
__( 'You will get the option to replace url and name on insert if they are defined as variables.', 'post-snippets').
|
122 |
+
'</p>
|
123 |
+
|
124 |
+
<h2>'
|
125 |
+
. __( 'Description', 'post-snippets' ).
|
126 |
+
'</h2>
|
127 |
+
<p>'.
|
128 |
+
__( 'An optional description for the Snippet. If filled out, the description will be displayed in the snippets insert window in the post editor.', 'post-snippets').
|
129 |
+
'</p>';
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* The shortcode help tab.
|
134 |
+
*
|
135 |
+
* @since Post Snippets 1.9.1
|
136 |
+
* @return string The help text
|
137 |
+
*/
|
138 |
+
public function help_shortcode()
|
139 |
+
{
|
140 |
+
return '<p>'.
|
141 |
+
__( 'When enabling the shortcode checkbox, the snippet is no longer inserted directly but instead inserted as a shortcode. The obvious advantage of this is of course that you can insert a block of text or code in many places on the site, and update the content from one single place.', 'post-snippets' ).
|
142 |
+
'</p>
|
143 |
+
|
144 |
+
<p>'.
|
145 |
+
__( 'The name to use the shortcode is the same as the title of the snippet (spaces are not allowed). When inserting a shortcode snippet, the shortcode and not the content will be inserted in the post.', 'post-snippets' ).
|
146 |
+
'</p>
|
147 |
+
<p>'.
|
148 |
+
__( 'If you enclose the shortcode in your posts, you can access the enclosed content by using the variable {content} in your snippet. The {content} variable is reserved, so don\'t use it in the variables field.', 'post-snippets' ).
|
149 |
+
'</p>
|
150 |
+
|
151 |
+
<h2>'
|
152 |
+
. __( 'Options', 'post-snippets' ).
|
153 |
+
'</h2>
|
154 |
+
<p><strong>PHP</strong><br/>'.
|
155 |
+
__( 'See the dedicated help section for information about PHP shortcodes.', 'post-snippets' ).
|
156 |
+
'</p>
|
157 |
+
<p><strong>wptexturize</strong><br/>'.
|
158 |
+
sprintf(__( 'Before the shortcode is outputted, it can optionally be formatted with %s, to transform quotes to smart quotes, apostrophes, dashes, ellipses, the trademark symbol, and the multiplication symbol.', 'post-snippets' ), '<a href="http://codex.wordpress.org/Function_Reference/wptexturize">wptexturize</a>' ).
|
159 |
+
'</p>';
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* The PHP help tab.
|
164 |
+
*
|
165 |
+
* @since Post Snippets 1.9.1
|
166 |
+
* @return string The help text
|
167 |
+
*/
|
168 |
+
public function help_php()
|
169 |
+
{
|
170 |
+
return '<p>'.
|
171 |
+
__('Snippets defined as shortcodes can optionally also be evaluated as PHP Code by enabling the PHP checkbox. PHP snippets is only available when treating the snippet as a shortcode.', 'post-snippets' ).
|
172 |
+
'</p>
|
173 |
+
<p><strong>'.
|
174 |
+
__( 'Example PHP Snippet', 'post-snippets' ).
|
175 |
+
'</strong><br/>
|
176 |
+
<code>
|
177 |
+
for ($i=1; $i<5; $i++) {<br/>
|
178 |
+
echo "{loop_me}<br/>";<br/>
|
179 |
+
};
|
180 |
+
</code></p>
|
181 |
+
|
182 |
+
<p>'.
|
183 |
+
__( 'With a snippet defined like the one above, you can call it with its shortcode definition in a post. Let\'s pretend that the example snippet is named phpcode and have one variable defined loop_me, then it would be called like this from a post:' , 'post-snippets' ).
|
184 |
+
'</p>
|
185 |
+
|
186 |
+
<code>[phpcode loop_me="post snippet with PHP!"]</code>
|
187 |
+
|
188 |
+
<p>'.
|
189 |
+
__( 'When the shortcode is executed the loop_me variable will be replaced with the string supplied in the shortcode and then the PHP code will be evaluated. (Outputting the string five times in this case. Wow!)', 'post-snippets' ).
|
190 |
+
'</p>
|
191 |
+
<p>'.
|
192 |
+
__( 'Note the evaluation order, any snippet variables will be replaced before the snippet is evaluated as PHP code. Also note that a PHP snippet don\'t need to be wrapped in <?php #code; ?>.', 'post-snippets' ).
|
193 |
+
'</p>';
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* The advanced help tab.
|
198 |
+
*
|
199 |
+
* @since Post Snippets 1.9.1
|
200 |
+
* @return string The help text
|
201 |
+
*/
|
202 |
+
public function help_advanced()
|
203 |
+
{
|
204 |
+
return '<p>'.
|
205 |
+
__('You can retrieve a Post Snippet directly from PHP, in a theme for instance, by using the get_post_snippet() function.', 'post-snippets').
|
206 |
+
'</p>
|
207 |
+
|
208 |
+
<h2>'.
|
209 |
+
__('Usage', 'post-snippets').
|
210 |
+
'</h2>
|
211 |
+
<p>'.
|
212 |
+
'<code>
|
213 |
+
<?php $my_snippet = get_post_snippet( $snippet_name, $snippet_vars ); ?>
|
214 |
+
</code></p>
|
215 |
+
|
216 |
+
<h2>'.
|
217 |
+
__('Parameters', 'post-snippets').
|
218 |
+
'</h2>
|
219 |
+
<p>
|
220 |
+
<code>$snippet_name</code><br/>'.
|
221 |
+
__('(string) (required) The name of the snippet to retrieve.', 'post-snippets').
|
222 |
+
|
223 |
+
'<br/><br/><code>'.
|
224 |
+
'$snippet_vars
|
225 |
+
</code><br/>'.
|
226 |
+
__('(string) The variables to pass to the snippet, formatted as a query string.', 'post-snippets').
|
227 |
+
'</p>
|
228 |
+
|
229 |
+
<h2>'.
|
230 |
+
__('Example', 'post-snippets').
|
231 |
+
'</h2>
|
232 |
+
<p><code>
|
233 |
+
<?php<br/>
|
234 |
+
$my_snippet = get_post_snippet( \'internal-link\', \'title=Awesome&url=2011/02/awesome/\' );<br/>
|
235 |
+
echo $my_snippet;<br/>
|
236 |
+
?>
|
237 |
+
</code></p>';
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
// -------------------------------------------------------------------------
|
242 |
+
// For compability with WordPress before v3.3.
|
243 |
+
// -------------------------------------------------------------------------
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Contextual Help for WP < v3.3.
|
247 |
+
*
|
248 |
+
* Combines the help tabs above into one long help text for the help tab
|
249 |
+
* when run on WordPress versions before v3.3.
|
250 |
+
*
|
251 |
+
* @since Post Snippets 1.7.1
|
252 |
+
* @return string The Contextual Help
|
253 |
+
*/
|
254 |
+
public function add_help($contextual_help, $screen_id, $screen) {
|
255 |
+
if ( $screen->id == 'settings_page_post-snippets/post-snippets' ) {
|
256 |
+
$contextual_help = '<h1>'.__( 'Basic', 'post-snippets' ).'</h1>';
|
257 |
+
$contextual_help .= $this->help_basic();
|
258 |
+
$contextual_help .= '<h1>'.__( 'Shortcode', 'post-snippets' ).'</h1>';
|
259 |
+
$contextual_help .= $this->help_shortcode();
|
260 |
+
$contextual_help .= '<h1>'.__( 'PHP', 'post-snippets' ).'</h1>';
|
261 |
+
$contextual_help .= $this->help_php();
|
262 |
+
$contextual_help .= '<h1>'.__( 'Advanced', 'post-snippets' ).'</h1>';
|
263 |
+
$contextual_help .= $this->help_advanced();
|
264 |
+
}
|
265 |
+
return $contextual_help;
|
266 |
+
}
|
267 |
+
}
|
classes/import-export.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Post Snippets I/O.
|
4 |
+
*
|
5 |
+
* Class to handle import and export of Snippets.
|
6 |
+
*
|
7 |
+
* @package Post Snippets
|
8 |
+
* @author Johan Steen <artstorm at gmail dot com>
|
9 |
+
* @since Post Snippets 2.0
|
10 |
+
*/
|
11 |
+
class Post_Snippets_ImportExport extends Post_Snippets_Base
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Export Snippets.
|
15 |
+
*
|
16 |
+
* Check if an export file shall be created, or if a download url should be
|
17 |
+
* pushed to the footer. Also checks for old export files laying around and
|
18 |
+
* deletes them (for security).
|
19 |
+
*
|
20 |
+
* @since Post Snippets 1.8
|
21 |
+
*/
|
22 |
+
public function export_snippets() {
|
23 |
+
if ( isset($_POST['postsnippets_export']) ) {
|
24 |
+
$url = $this->create_export_file();
|
25 |
+
if ($url) {
|
26 |
+
define('PSURL', $url);
|
27 |
+
function psnippets_footer() {
|
28 |
+
$export = '<script type="text/javascript">
|
29 |
+
document.location = \''.PSURL.'\';
|
30 |
+
</script>';
|
31 |
+
echo $export;
|
32 |
+
}
|
33 |
+
add_action('admin_footer', 'psnippets_footer', 10000);
|
34 |
+
|
35 |
+
} else {
|
36 |
+
$export .= 'Error: '.$url;
|
37 |
+
}
|
38 |
+
} else {
|
39 |
+
// Check if there is any old export files to delete
|
40 |
+
$dir = wp_upload_dir();
|
41 |
+
$upload_dir = $dir['basedir'] . '/';
|
42 |
+
chdir($upload_dir);
|
43 |
+
if (file_exists ( './post-snippets-export.zip' ) )
|
44 |
+
unlink('./post-snippets-export.zip');
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Create a zipped filed containing all Post Snippets, for export.
|
50 |
+
*
|
51 |
+
* @since Post Snippets 1.8
|
52 |
+
* @return string URL to the exported snippets
|
53 |
+
*/
|
54 |
+
private function create_export_file() {
|
55 |
+
$snippets = serialize(get_option( self::PLUGIN_OPTION_KEY ));
|
56 |
+
$snippets = apply_filters( 'post_snippets_export', $snippets );
|
57 |
+
$dir = wp_upload_dir();
|
58 |
+
$upload_dir = $dir['basedir'] . '/';
|
59 |
+
$upload_url = $dir['baseurl'] . '/';
|
60 |
+
|
61 |
+
// Open a file stream and write the serialized options to it.
|
62 |
+
if ( !$handle = fopen( $upload_dir.'post-snippets-export.cfg', 'w' ) )
|
63 |
+
die();
|
64 |
+
if ( !fwrite($handle, $snippets) )
|
65 |
+
die();
|
66 |
+
fclose($handle);
|
67 |
+
|
68 |
+
// Create a zip archive
|
69 |
+
require_once (ABSPATH . 'wp-admin/includes/class-pclzip.php');
|
70 |
+
chdir($upload_dir);
|
71 |
+
$zip = new PclZip('./post-snippets-export.zip');
|
72 |
+
$zipped = $zip->create('./post-snippets-export.cfg');
|
73 |
+
|
74 |
+
// Delete the snippet file
|
75 |
+
unlink('./post-snippets-export.cfg');
|
76 |
+
|
77 |
+
if (!$zipped)
|
78 |
+
return false;
|
79 |
+
|
80 |
+
return $upload_url.'post-snippets-export.zip';
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Handles uploading of post snippets archive and import the snippets.
|
85 |
+
*
|
86 |
+
* @uses wp_handle_upload() in wp-admin/includes/file.php
|
87 |
+
* @since Post Snippets 1.8
|
88 |
+
* @return string HTML to handle the import
|
89 |
+
*/
|
90 |
+
public function import_snippets() {
|
91 |
+
$import = '<br/><br/><strong>'.__( 'Import', 'post-snippets' ).'</strong><br/>';
|
92 |
+
if ( !isset($_FILES['postsnippets_import_file']) || empty($_FILES['postsnippets_import_file']) ) {
|
93 |
+
$import .= '<p>'.__( 'Import snippets from a post-snippets-export.zip file. Importing overwrites any existing snippets.', 'post-snippets' ).'</p>';
|
94 |
+
$import .= '<form method="post" enctype="multipart/form-data">';
|
95 |
+
$import .= '<input type="file" name="postsnippets_import_file"/>';
|
96 |
+
$import .= '<input type="hidden" name="action" value="wp_handle_upload"/>';
|
97 |
+
$import .= '<input type="submit" class="button" value="'.__( 'Import Snippets', 'post-snippets' ).'"/>';
|
98 |
+
$import .= '</form>';
|
99 |
+
} else {
|
100 |
+
$file = wp_handle_upload( $_FILES['postsnippets_import_file'] );
|
101 |
+
|
102 |
+
if ( isset( $file['file'] ) && !is_wp_error($file) ) {
|
103 |
+
require_once (ABSPATH . 'wp-admin/includes/class-pclzip.php');
|
104 |
+
$zip = new PclZip( $file['file'] );
|
105 |
+
$dir = wp_upload_dir();
|
106 |
+
$upload_dir = $dir['basedir'] . '/';
|
107 |
+
chdir($upload_dir);
|
108 |
+
$unzipped = $zip->extract();
|
109 |
+
|
110 |
+
if ( $unzipped[0]['stored_filename'] == 'post-snippets-export.cfg' && $unzipped[0]['status'] == 'ok') {
|
111 |
+
// Delete the uploaded archive
|
112 |
+
unlink($file['file']);
|
113 |
+
|
114 |
+
$snippets = file_get_contents( $upload_dir.'post-snippets-export.cfg' ); // Returns false on failure, else the contents
|
115 |
+
if ($snippets) {
|
116 |
+
$snippets = apply_filters( 'post_snippets_import', $snippets );
|
117 |
+
update_option( self::PLUGIN_OPTION_KEY, unserialize($snippets));
|
118 |
+
}
|
119 |
+
|
120 |
+
// Delete the snippet file
|
121 |
+
unlink('./post-snippets-export.cfg');
|
122 |
+
|
123 |
+
$import .= '<p><strong>'.__( 'Snippets successfully imported.').'</strong></p>';
|
124 |
+
} else {
|
125 |
+
$import .= '<p><strong>'.__( 'Snippets could not be imported:').' '.__('Unzipping failed.').'</strong></p>';
|
126 |
+
}
|
127 |
+
} else {
|
128 |
+
if ( $file['error'] || is_wp_error( $file ) )
|
129 |
+
$import .= '<p><strong>'.__( 'Snippets could not be imported:').' '.$file['error'].'</strong></p>';
|
130 |
+
else
|
131 |
+
$import .= '<p><strong>'.__( 'Snippets could not be imported:').' '.__('Upload failed.').'</strong></p>';
|
132 |
+
}
|
133 |
+
}
|
134 |
+
return $import;
|
135 |
+
}
|
136 |
+
}
|
classes/settings.php
CHANGED
@@ -1,281 +1,427 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Post Snippets Settings.
|
4 |
-
*
|
5 |
-
* Class that renders out the HTML for the settings screen and contains helpful
|
6 |
-
* methods to simply the maintainance of the admin screen.
|
7 |
-
*
|
8 |
-
* @package Post Snippets
|
9 |
-
* @author Johan Steen <artstorm at gmail dot com>
|
10 |
-
* @since Post Snippets 1.8.8
|
11 |
-
*/
|
12 |
-
class Post_Snippets_Settings
|
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 |
-
private function
|
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 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
*
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
// Header
|
183 |
-
echo '<div class=wrap>';
|
184 |
-
echo '<h2>Post Snippets</h2>';
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
$
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
echo '</
|
199 |
-
|
200 |
-
//
|
201 |
-
$
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Post Snippets Settings.
|
4 |
+
*
|
5 |
+
* Class that renders out the HTML for the settings screen and contains helpful
|
6 |
+
* methods to simply the maintainance of the admin screen.
|
7 |
+
*
|
8 |
+
* @package Post Snippets
|
9 |
+
* @author Johan Steen <artstorm at gmail dot com>
|
10 |
+
* @since Post Snippets 1.8.8
|
11 |
+
*/
|
12 |
+
class Post_Snippets_Settings extends Post_Snippets_Base
|
13 |
+
{
|
14 |
+
// -------------------------------------------------------------------------
|
15 |
+
// Handle form submissions
|
16 |
+
// -------------------------------------------------------------------------
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Add New Snippet.
|
20 |
+
*/
|
21 |
+
private function add()
|
22 |
+
{
|
23 |
+
if (isset( $_POST['add-snippet'] )
|
24 |
+
&& isset( $_POST['update_snippets_nonce'])
|
25 |
+
&& wp_verify_nonce( $_POST['update_snippets_nonce'], 'update_snippets') )
|
26 |
+
{
|
27 |
+
$snippets = get_option( self::PLUGIN_OPTION_KEY );
|
28 |
+
if (empty($snippets)) { $snippets = array(); }
|
29 |
+
|
30 |
+
array_push($snippets, array (
|
31 |
+
'title' => 'Untitled',
|
32 |
+
'vars' => '',
|
33 |
+
'description' => '',
|
34 |
+
'shortcode' => false,
|
35 |
+
'php' => false,
|
36 |
+
'wptexturize' => false,
|
37 |
+
'snippet' => '')
|
38 |
+
);
|
39 |
+
|
40 |
+
update_option( self::PLUGIN_OPTION_KEY, $snippets );
|
41 |
+
$this->message( __( 'A snippet named Untitled has been added.', 'post-snippets' ) );
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Delete Snippet/s.
|
47 |
+
*/
|
48 |
+
private function delete()
|
49 |
+
{
|
50 |
+
if (isset( $_POST['delete-snippets'] )
|
51 |
+
&& isset( $_POST['update_snippets_nonce'])
|
52 |
+
&& wp_verify_nonce( $_POST['update_snippets_nonce'], 'update_snippets') )
|
53 |
+
{
|
54 |
+
$snippets = get_option( self::PLUGIN_OPTION_KEY );
|
55 |
+
|
56 |
+
if ( empty($snippets) || !isset($_POST['checked']) ) {
|
57 |
+
$this->message( __( 'Nothing selected to delete.', 'post-snippets' ) );
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
|
61 |
+
$delete = $_POST['checked'];
|
62 |
+
$newsnippets = array();
|
63 |
+
foreach ($snippets as $key => $snippet) {
|
64 |
+
if (in_array($key,$delete) == false) {
|
65 |
+
array_push($newsnippets,$snippet);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
update_option( self::PLUGIN_OPTION_KEY, $newsnippets );
|
70 |
+
$this->message( __( 'Selected snippets have been deleted.', 'post-snippets' ) );
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Update Snippet/s.
|
76 |
+
*/
|
77 |
+
private function update()
|
78 |
+
{
|
79 |
+
if (isset( $_POST['update-snippets'] )
|
80 |
+
&& isset( $_POST['update_snippets_nonce'])
|
81 |
+
&& wp_verify_nonce( $_POST['update_snippets_nonce'], 'update_snippets') )
|
82 |
+
{
|
83 |
+
$snippets = get_option( self::PLUGIN_OPTION_KEY );
|
84 |
+
if (!empty($snippets)) {
|
85 |
+
foreach ($snippets as $key => $value) {
|
86 |
+
$new_snippets[$key]['title'] = trim($_POST[$key.'_title']);
|
87 |
+
$new_snippets[$key]['vars'] = str_replace(' ', '', trim($_POST[$key.'_vars']) );
|
88 |
+
$new_snippets[$key]['shortcode'] = isset($_POST[$key.'_shortcode']) ? true : false;
|
89 |
+
$new_snippets[$key]['php'] = isset($_POST[$key.'_php']) ? true : false;
|
90 |
+
$new_snippets[$key]['wptexturize'] = isset($_POST[$key.'_wptexturize']) ? true : false;
|
91 |
+
|
92 |
+
$new_snippets[$key]['snippet'] = wp_specialchars_decode( trim(stripslashes($_POST[$key.'_snippet'])), ENT_NOQUOTES);
|
93 |
+
$new_snippets[$key]['description'] = wp_specialchars_decode( trim(stripslashes($_POST[$key.'_description'])), ENT_NOQUOTES);
|
94 |
+
}
|
95 |
+
update_option( self::PLUGIN_OPTION_KEY, $new_snippets );
|
96 |
+
$this->message( __( 'Snippets have been updated.', 'post-snippets' ) );
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Update User Option.
|
103 |
+
*
|
104 |
+
* Sets the per user option for the read-only overview page.
|
105 |
+
*
|
106 |
+
* @since Post Snippets 1.9.7
|
107 |
+
*/
|
108 |
+
private function set_user_options()
|
109 |
+
{
|
110 |
+
if ( isset($_POST['post_snippets_user_nonce']) && wp_verify_nonce( $_POST['post_snippets_user_nonce'], 'post_snippets_user_options') )
|
111 |
+
{
|
112 |
+
$id = get_current_user_id();
|
113 |
+
$render = isset( $_POST['render'] ) ? true : false;
|
114 |
+
update_user_meta( $id, self::USER_OPTION_KEY, $render );
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Get User Option.
|
120 |
+
*
|
121 |
+
* Gets the per user option for the read-only overview page.
|
122 |
+
*
|
123 |
+
* @since Post Snippets 1.9.7
|
124 |
+
* @return boolean If overview should be rendered on output or not
|
125 |
+
*/
|
126 |
+
private function get_user_options()
|
127 |
+
{
|
128 |
+
$id = get_current_user_id();
|
129 |
+
$options = get_user_meta( $id, self::USER_OPTION_KEY, true );
|
130 |
+
return $options;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
// -------------------------------------------------------------------------
|
135 |
+
// HTML generation for option pages
|
136 |
+
// -------------------------------------------------------------------------
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Render the options page.
|
140 |
+
*
|
141 |
+
* @since Post Snippets 1.9.7
|
142 |
+
* @param string $page Admin page to render. Default: options
|
143 |
+
*/
|
144 |
+
public function render( $page )
|
145 |
+
{
|
146 |
+
switch ( $page ) {
|
147 |
+
case 'options':
|
148 |
+
$this->options_page();
|
149 |
+
break;
|
150 |
+
|
151 |
+
default:
|
152 |
+
$this->overview_page();
|
153 |
+
break;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Display Flashing Message.
|
159 |
+
*
|
160 |
+
* @param string $message Message to display to the user.
|
161 |
+
*/
|
162 |
+
private function message( $message )
|
163 |
+
{
|
164 |
+
if ( $message )
|
165 |
+
echo "<div class='updated'><p><strong>{$message}</strong></p></div>";
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Creates the snippets administration page.
|
170 |
+
*
|
171 |
+
* For users with manage_options capability (admin, super admin).
|
172 |
+
*
|
173 |
+
* @since Post Snippets 1.8.8
|
174 |
+
*/
|
175 |
+
private function options_page()
|
176 |
+
{
|
177 |
+
// Handle Form Submits
|
178 |
+
$this->add();
|
179 |
+
$this->delete();
|
180 |
+
$this->update();
|
181 |
+
|
182 |
+
// Header
|
183 |
+
echo '<div class="wrap">';
|
184 |
+
echo '<h2>Post Snippets</h2>';
|
185 |
+
|
186 |
+
// Tabs
|
187 |
+
$active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'snippets';
|
188 |
+
$base_url = '?page=post-snippets/post-snippets.php&tab=';
|
189 |
+
$tabs = array( 'snippets' => __( 'Manage Snippets', 'post-snippets' ), 'tools' => __( 'Import/Export', 'post-snippets' ) );
|
190 |
+
echo '<h2 class="nav-tab-wrapper">';
|
191 |
+
foreach ( $tabs as $tab => $title ) {
|
192 |
+
$active = ( $active_tab == $tab ) ? ' nav-tab-active' : '';
|
193 |
+
echo "<a href='{$base_url}{$tab}' class='nav-tab {$active}'>{$title}</a>";
|
194 |
+
}
|
195 |
+
echo '</h2>';
|
196 |
+
echo '<p class="description">';
|
197 |
+
_e( 'Use the help dropdown button for additional information.', 'post-snippets' );
|
198 |
+
echo '</p>';
|
199 |
+
|
200 |
+
// Tab content
|
201 |
+
if( $active_tab == 'snippets' )
|
202 |
+
$this->tab_snippets();
|
203 |
+
else
|
204 |
+
$this->tab_tools();
|
205 |
+
|
206 |
+
// Close it
|
207 |
+
echo '</div>';
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Tab to Manage Snippets.
|
212 |
+
*
|
213 |
+
* @since Post Snippets 2.0
|
214 |
+
*/
|
215 |
+
private function tab_snippets()
|
216 |
+
{
|
217 |
+
echo '<form method="post" action="">';
|
218 |
+
wp_nonce_field( 'update_snippets', 'update_snippets_nonce' );
|
219 |
+
?>
|
220 |
+
|
221 |
+
<table class="widefat fixed" cellspacing="0">
|
222 |
+
<thead>
|
223 |
+
<tr>
|
224 |
+
<th scope="col" class="check-column"><input type="checkbox" /></th>
|
225 |
+
<th scope="col" style="width: 180px;"><?php _e( 'Title', 'post-snippets' ) ?></th>
|
226 |
+
<th scope="col" style="width: 180px;"><?php _e( 'Variables', 'post-snippets' ) ?></th>
|
227 |
+
<th scope="col"><?php _e( 'Snippet', 'post-snippets' ) ?></th>
|
228 |
+
</tr>
|
229 |
+
</thead>
|
230 |
+
|
231 |
+
<tfoot>
|
232 |
+
<tr>
|
233 |
+
<th scope="col" class="check-column"><input type="checkbox" /></th>
|
234 |
+
<th scope="col"><?php _e( 'Title', 'post-snippets' ) ?></th>
|
235 |
+
<th scope="col"><?php _e( 'Variables', 'post-snippets' ) ?></th>
|
236 |
+
<th scope="col"><?php _e( 'Snippet', 'post-snippets' ) ?></th>
|
237 |
+
</tr>
|
238 |
+
</tfoot>
|
239 |
+
|
240 |
+
<tbody>
|
241 |
+
<?php
|
242 |
+
$snippets = get_option( self::PLUGIN_OPTION_KEY );
|
243 |
+
if (!empty($snippets)) {
|
244 |
+
foreach ($snippets as $key => $snippet) {
|
245 |
+
?>
|
246 |
+
<tr class='recent'>
|
247 |
+
<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='<?php echo $key; ?>' /></th>
|
248 |
+
<td class='row-title'>
|
249 |
+
<input type='text' name='<?php echo $key; ?>_title' value='<?php echo $snippet['title']; ?>' />
|
250 |
+
</td>
|
251 |
+
<td class='name'>
|
252 |
+
<input type='text' name='<?php echo $key; ?>_vars' value='<?php echo $snippet['vars']; ?>' />
|
253 |
+
<br/>
|
254 |
+
<br/>
|
255 |
+
<?php
|
256 |
+
$this->checkbox(__('Shortcode', 'post-snippets'), $key.'_shortcode',
|
257 |
+
$snippet['shortcode']);
|
258 |
+
|
259 |
+
echo '<br/><strong>Shortcode Options:</strong><br/>';
|
260 |
+
|
261 |
+
$this->checkbox(__('PHP Code', 'post-snippets'), $key.'_php',
|
262 |
+
$snippet['php']);
|
263 |
+
|
264 |
+
$wptexturize = isset( $snippet['wptexturize'] ) ? $snippet['wptexturize'] : false;
|
265 |
+
$this->checkbox('wptexturize', $key.'_wptexturize', $wptexturize);
|
266 |
+
?>
|
267 |
+
</td>
|
268 |
+
<td class='desc'>
|
269 |
+
<textarea name="<?php echo $key; ?>_snippet" class="large-text" style='width: 100%;' rows="5"><?php echo htmlspecialchars($snippet['snippet'], ENT_NOQUOTES); ?></textarea>
|
270 |
+
<?php _e( 'Description', 'post-snippets' ) ?>:
|
271 |
+
<input type='text' style='width: 100%;' name='<?php echo $key; ?>_description' value='<?php if (isset( $snippet['description'] ) ) echo esc_html($snippet['description']); ?>' /><br/>
|
272 |
+
</td>
|
273 |
+
</tr>
|
274 |
+
<?php
|
275 |
+
}
|
276 |
+
}
|
277 |
+
?>
|
278 |
+
</tbody>
|
279 |
+
</table>
|
280 |
+
|
281 |
+
<?php
|
282 |
+
$this->submit( 'update-snippets', __('Update Snippets', 'post-snippets') );
|
283 |
+
$this->submit( 'add-snippet', __('Add New Snippet', 'post-snippets'), 'button-secondary', false );
|
284 |
+
$this->submit( 'delete-snippets', __('Delete Selected', 'post-snippets'), 'button-secondary', false );
|
285 |
+
echo '</form>';
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Tab for Import/Export
|
290 |
+
*
|
291 |
+
* @since Post Snippets 2.0
|
292 |
+
*/
|
293 |
+
private function tab_tools()
|
294 |
+
{
|
295 |
+
$ie = new Post_Snippets_ImportExport();
|
296 |
+
|
297 |
+
// Create header and export html form
|
298 |
+
printf( "<h3>%s</h3>", __( 'Import/Export', 'post-snippets' ));
|
299 |
+
printf( "<h4>%s</h4>", __( 'Export', 'post-snippets' ));
|
300 |
+
echo '<form method="post">';
|
301 |
+
echo '<p>';
|
302 |
+
_e( 'Export your snippets for backup or to import them on another site.', 'post-snippets' );
|
303 |
+
echo '</p>';
|
304 |
+
printf("<input type='submit' class='button' name='postsnippets_export' value='%s' />", __( 'Export Snippets', 'post-snippets') );
|
305 |
+
echo '</form>';
|
306 |
+
|
307 |
+
// Export logic, and import html form and logic
|
308 |
+
$ie->export_snippets();
|
309 |
+
echo $ie->import_snippets();
|
310 |
+
}
|
311 |
+
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Creates a read-only overview page.
|
315 |
+
*
|
316 |
+
* For users with edit_posts capability but without manage_options
|
317 |
+
* capability.
|
318 |
+
*
|
319 |
+
* @since Post Snippets 1.9.7
|
320 |
+
*/
|
321 |
+
private function overview_page()
|
322 |
+
{
|
323 |
+
// Header
|
324 |
+
echo '<div class="wrap">';
|
325 |
+
echo '<h2>Post Snippets</h2>';
|
326 |
+
echo '<p>';
|
327 |
+
_e( 'This is an overview of all snippets defined for this site. These snippets are inserted into posts from the post editor using the Post Snippets button. You can choose to see the snippets here as-is or as they are actually rendered on the website. Enabling rendered snippets for this overview might look strange if the snippet have dependencies on variables, CSS or other parameters only available on the frontend. If that is the case it is recommended to keep this option disabled.', 'post-snippets' );
|
328 |
+
echo '</p>';
|
329 |
+
|
330 |
+
// Form
|
331 |
+
$this->set_user_options();
|
332 |
+
$render = $this->get_user_options();
|
333 |
+
|
334 |
+
echo '<form method="post" action="">';
|
335 |
+
wp_nonce_field( 'post_snippets_user_options', 'post_snippets_user_nonce' );
|
336 |
+
|
337 |
+
$this->checkbox(__('Display rendered snippets', 'post-snippets'), 'render', $render );
|
338 |
+
$this->submit( 'update-post-snippets-user', __('Update', 'post-snippets') );
|
339 |
+
echo '</form>';
|
340 |
+
|
341 |
+
// Snippet List
|
342 |
+
$snippets = get_option( self::PLUGIN_OPTION_KEY );
|
343 |
+
if (!empty($snippets)) {
|
344 |
+
foreach ($snippets as $key => $snippet) {
|
345 |
+
|
346 |
+
echo "<hr style='border: none;border-top:1px dashed #aaa; margin:24px 0;' />";
|
347 |
+
|
348 |
+
echo "<h3>{$snippet['title']}";
|
349 |
+
if ($snippet['description'])
|
350 |
+
echo "<span class='description'> {$snippet['description']}</span>";
|
351 |
+
echo "</h3>";
|
352 |
+
|
353 |
+
if ($snippet['vars'])
|
354 |
+
printf( "<strong>%s:</strong> {$snippet['vars']}<br/>", __('Variables', 'post-snippets') );
|
355 |
+
|
356 |
+
// echo "<strong>Variables:</strong> {$snippet['vars']}<br/>";
|
357 |
+
|
358 |
+
$options = array();
|
359 |
+
if ($snippet['shortcode'])
|
360 |
+
array_push($options, 'Shortcode');
|
361 |
+
if ($snippet['php'])
|
362 |
+
array_push($options, 'PHP');
|
363 |
+
if ($snippet['wptexturize'])
|
364 |
+
array_push($options, 'wptexturize');
|
365 |
+
if ($options)
|
366 |
+
printf ( "<strong>%s:</strong> %s<br/>", __('Options', 'post-snippets'), implode(', ', $options) );
|
367 |
+
|
368 |
+
printf( "<br/><strong>%s:</strong><br/>", __('Snippet', 'post-snippets') );
|
369 |
+
if ( $render ) {
|
370 |
+
echo do_shortcode( $snippet['snippet'] );
|
371 |
+
} else {
|
372 |
+
echo "<code>";
|
373 |
+
echo nl2br( htmlspecialchars($snippet['snippet'], ENT_NOQUOTES) );
|
374 |
+
echo "</code>";
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
// Close
|
380 |
+
echo '</div>';
|
381 |
+
}
|
382 |
+
|
383 |
+
|
384 |
+
// -------------------------------------------------------------------------
|
385 |
+
// HTML and Form element methods
|
386 |
+
// -------------------------------------------------------------------------
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Checkbox.
|
390 |
+
*
|
391 |
+
* Renders the HTML for an input checkbox.
|
392 |
+
*
|
393 |
+
* @param string $label The label rendered to screen
|
394 |
+
* @param string $name The unique name and id to identify the input
|
395 |
+
* @param boolean $checked If the input is checked or not
|
396 |
+
*/
|
397 |
+
private function checkbox( $label, $name, $checked )
|
398 |
+
{
|
399 |
+
echo "<label for=\"{$name}\">";
|
400 |
+
printf( '<input type="checkbox" name="%1$s" id="%1$s" value="true"', $name );
|
401 |
+
if ($checked)
|
402 |
+
echo ' checked';
|
403 |
+
echo ' />';
|
404 |
+
echo " {$label}</label><br/>";
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Submit.
|
409 |
+
*
|
410 |
+
* Renders the HTML for a submit button.
|
411 |
+
*
|
412 |
+
* @since Post Snippets 1.9.7
|
413 |
+
* @param string $name The name that identifies the button on submit
|
414 |
+
* @param string $label The label rendered on the button
|
415 |
+
* @param string $class Optional. Button class. Default: button-primary
|
416 |
+
* @param boolean $wrap Optional. Wrap in a submit div. Default: true
|
417 |
+
*/
|
418 |
+
private function submit( $name, $label, $class='button-primary', $wrap=true )
|
419 |
+
{
|
420 |
+
$btn = sprintf( '<input type="submit" name="%s" value="%s" class="%s" />', $name, $label, $class );
|
421 |
+
|
422 |
+
if ($wrap)
|
423 |
+
$btn = "<div class=\"submit\">{$btn}</div>";
|
424 |
+
|
425 |
+
echo $btn;
|
426 |
+
}
|
427 |
+
}
|
languages/post-snippets.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the Post Snippets package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Post Snippets 1.9.
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/post-snippets\n"
|
7 |
-
"POT-Creation-Date: 2012-03-21
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -16,7 +16,7 @@ msgstr ""
|
|
16 |
msgid "Basic"
|
17 |
msgstr ""
|
18 |
|
19 |
-
#: classes/help.php:46 classes/help.php:258 classes/settings.php:
|
20 |
msgid "Shortcode"
|
21 |
msgstr ""
|
22 |
|
@@ -40,7 +40,7 @@ msgstr ""
|
|
40 |
msgid "Support Forums"
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: classes/help.php:91 classes/settings.php:
|
44 |
msgid "Title"
|
45 |
msgstr ""
|
46 |
|
@@ -50,8 +50,8 @@ msgid ""
|
|
50 |
"also becomes the name of the shortcode if you enable that option"
|
51 |
msgstr ""
|
52 |
|
53 |
-
#: classes/help.php:98 classes/settings.php:
|
54 |
-
#: classes/settings.php:
|
55 |
msgid "Variables"
|
56 |
msgstr ""
|
57 |
|
@@ -66,8 +66,8 @@ msgstr ""
|
|
66 |
msgid "Example"
|
67 |
msgstr ""
|
68 |
|
69 |
-
#: classes/help.php:109 classes/settings.php:
|
70 |
-
#: classes/settings.php:
|
71 |
msgid "Snippet"
|
72 |
msgstr ""
|
73 |
|
@@ -90,7 +90,7 @@ msgid ""
|
|
90 |
"defined as variables."
|
91 |
msgstr ""
|
92 |
|
93 |
-
#: classes/help.php:125 classes/settings.php:
|
94 |
msgid "Description"
|
95 |
msgstr ""
|
96 |
|
@@ -122,7 +122,7 @@ msgid ""
|
|
122 |
"variable is reserved, so don't use it in the variables field."
|
123 |
msgstr ""
|
124 |
|
125 |
-
#: classes/help.php:152 classes/settings.php:
|
126 |
msgid "Options"
|
127 |
msgstr ""
|
128 |
|
@@ -193,109 +193,118 @@ msgid ""
|
|
193 |
"(string) The variables to pass to the snippet, formatted as a query string."
|
194 |
msgstr ""
|
195 |
|
196 |
-
#: classes/
|
197 |
-
msgid "
|
198 |
-
msgstr ""
|
199 |
-
|
200 |
-
#: classes/settings.php:104
|
201 |
-
msgid "Delete Selected"
|
202 |
msgstr ""
|
203 |
|
204 |
-
#: classes/
|
205 |
-
msgid "
|
|
|
|
|
206 |
msgstr ""
|
207 |
|
208 |
-
#: classes/
|
209 |
-
msgid "
|
210 |
msgstr ""
|
211 |
|
212 |
-
#: classes/
|
213 |
-
msgid "
|
214 |
msgstr ""
|
215 |
|
216 |
-
#: classes/
|
217 |
-
|
218 |
-
"
|
219 |
-
"are inserted into posts from the post editor using the Post Snippets button. "
|
220 |
-
"You can choose to see the snippets here as-is or as they are actually "
|
221 |
-
"rendered on the website. Enabling rendered snippets for this overview might "
|
222 |
-
"look strange if the snippet have dependencies on variables, CSS or other "
|
223 |
-
"parameters only available on the frontend. If that is the case it is "
|
224 |
-
"recommended to keep this option disabled."
|
225 |
msgstr ""
|
226 |
|
227 |
-
#: classes/
|
228 |
-
msgid "
|
229 |
msgstr ""
|
230 |
|
231 |
-
#: classes/
|
232 |
-
msgid "
|
233 |
msgstr ""
|
234 |
|
235 |
-
#:
|
236 |
-
msgid "
|
237 |
msgstr ""
|
238 |
|
239 |
-
#:
|
240 |
-
msgid "
|
241 |
msgstr ""
|
242 |
|
243 |
-
#:
|
244 |
-
msgid "
|
245 |
msgstr ""
|
246 |
|
247 |
-
#:
|
248 |
msgid "Snippets have been updated."
|
249 |
msgstr ""
|
250 |
|
251 |
-
#:
|
252 |
-
msgid "
|
253 |
msgstr ""
|
254 |
|
255 |
-
#:
|
256 |
msgid "Import/Export"
|
257 |
msgstr ""
|
258 |
|
259 |
-
#:
|
260 |
-
msgid "
|
261 |
msgstr ""
|
262 |
|
263 |
-
#:
|
264 |
-
msgid "
|
265 |
msgstr ""
|
266 |
|
267 |
-
#:
|
268 |
-
msgid "
|
269 |
msgstr ""
|
270 |
|
271 |
-
#:
|
272 |
-
msgid "
|
273 |
msgstr ""
|
274 |
|
275 |
-
#:
|
276 |
-
msgid ""
|
277 |
-
"Import snippets from a post-snippets-export.zip file. Importing overwrites "
|
278 |
-
"any existing snippets."
|
279 |
msgstr ""
|
280 |
|
281 |
-
#:
|
282 |
-
msgid "
|
283 |
msgstr ""
|
284 |
|
285 |
-
#:
|
286 |
-
msgid "
|
287 |
msgstr ""
|
288 |
|
289 |
-
#:
|
290 |
-
msgid "Snippets
|
291 |
msgstr ""
|
292 |
|
293 |
-
#:
|
294 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
msgstr ""
|
296 |
|
297 |
-
#:
|
298 |
-
msgid "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
msgstr ""
|
300 |
|
301 |
#. Plugin Name of the plugin/theme
|
2 |
# This file is distributed under the same license as the Post Snippets package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Post Snippets 1.9.7\n"
|
6 |
"Report-Msgid-Bugs-To: http://wordpress.org/tag/post-snippets\n"
|
7 |
+
"POT-Creation-Date: 2012-03-28 21:41:26+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
16 |
msgid "Basic"
|
17 |
msgstr ""
|
18 |
|
19 |
+
#: classes/help.php:46 classes/help.php:258 classes/settings.php:256
|
20 |
msgid "Shortcode"
|
21 |
msgstr ""
|
22 |
|
40 |
msgid "Support Forums"
|
41 |
msgstr ""
|
42 |
|
43 |
+
#: classes/help.php:91 classes/settings.php:225 classes/settings.php:234
|
44 |
msgid "Title"
|
45 |
msgstr ""
|
46 |
|
50 |
"also becomes the name of the shortcode if you enable that option"
|
51 |
msgstr ""
|
52 |
|
53 |
+
#: classes/help.php:98 classes/settings.php:226 classes/settings.php:235
|
54 |
+
#: classes/settings.php:354
|
55 |
msgid "Variables"
|
56 |
msgstr ""
|
57 |
|
66 |
msgid "Example"
|
67 |
msgstr ""
|
68 |
|
69 |
+
#: classes/help.php:109 classes/settings.php:227 classes/settings.php:236
|
70 |
+
#: classes/settings.php:368
|
71 |
msgid "Snippet"
|
72 |
msgstr ""
|
73 |
|
90 |
"defined as variables."
|
91 |
msgstr ""
|
92 |
|
93 |
+
#: classes/help.php:125 classes/settings.php:270
|
94 |
msgid "Description"
|
95 |
msgstr ""
|
96 |
|
122 |
"variable is reserved, so don't use it in the variables field."
|
123 |
msgstr ""
|
124 |
|
125 |
+
#: classes/help.php:152 classes/settings.php:366
|
126 |
msgid "Options"
|
127 |
msgstr ""
|
128 |
|
193 |
"(string) The variables to pass to the snippet, formatted as a query string."
|
194 |
msgstr ""
|
195 |
|
196 |
+
#: classes/import-export.php:91
|
197 |
+
msgid "Import"
|
|
|
|
|
|
|
|
|
198 |
msgstr ""
|
199 |
|
200 |
+
#: classes/import-export.php:93
|
201 |
+
msgid ""
|
202 |
+
"Import snippets from a post-snippets-export.zip file. Importing overwrites "
|
203 |
+
"any existing snippets."
|
204 |
msgstr ""
|
205 |
|
206 |
+
#: classes/import-export.php:97
|
207 |
+
msgid "Import Snippets"
|
208 |
msgstr ""
|
209 |
|
210 |
+
#: classes/import-export.php:123
|
211 |
+
msgid "Snippets successfully imported."
|
212 |
msgstr ""
|
213 |
|
214 |
+
#: classes/import-export.php:125 classes/import-export.php:129
|
215 |
+
#: classes/import-export.php:131
|
216 |
+
msgid "Snippets could not be imported:"
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
msgstr ""
|
218 |
|
219 |
+
#: classes/import-export.php:125
|
220 |
+
msgid "Unzipping failed."
|
221 |
msgstr ""
|
222 |
|
223 |
+
#: classes/import-export.php:131
|
224 |
+
msgid "Upload failed."
|
225 |
msgstr ""
|
226 |
|
227 |
+
#: classes/settings.php:41
|
228 |
+
msgid "A snippet named Untitled has been added."
|
229 |
msgstr ""
|
230 |
|
231 |
+
#: classes/settings.php:57
|
232 |
+
msgid "Nothing selected to delete."
|
233 |
msgstr ""
|
234 |
|
235 |
+
#: classes/settings.php:70
|
236 |
+
msgid "Selected snippets have been deleted."
|
237 |
msgstr ""
|
238 |
|
239 |
+
#: classes/settings.php:96
|
240 |
msgid "Snippets have been updated."
|
241 |
msgstr ""
|
242 |
|
243 |
+
#: classes/settings.php:189
|
244 |
+
msgid "Manage Snippets"
|
245 |
msgstr ""
|
246 |
|
247 |
+
#: classes/settings.php:189 classes/settings.php:298
|
248 |
msgid "Import/Export"
|
249 |
msgstr ""
|
250 |
|
251 |
+
#: classes/settings.php:197
|
252 |
+
msgid "Use the help dropdown button for additional information."
|
253 |
msgstr ""
|
254 |
|
255 |
+
#: classes/settings.php:261
|
256 |
+
msgid "PHP Code"
|
257 |
msgstr ""
|
258 |
|
259 |
+
#: classes/settings.php:282
|
260 |
+
msgid "Update Snippets"
|
261 |
msgstr ""
|
262 |
|
263 |
+
#: classes/settings.php:283
|
264 |
+
msgid "Add New Snippet"
|
265 |
msgstr ""
|
266 |
|
267 |
+
#: classes/settings.php:284
|
268 |
+
msgid "Delete Selected"
|
|
|
|
|
269 |
msgstr ""
|
270 |
|
271 |
+
#: classes/settings.php:299
|
272 |
+
msgid "Export"
|
273 |
msgstr ""
|
274 |
|
275 |
+
#: classes/settings.php:302
|
276 |
+
msgid "Export your snippets for backup or to import them on another site."
|
277 |
msgstr ""
|
278 |
|
279 |
+
#: classes/settings.php:304
|
280 |
+
msgid "Export Snippets"
|
281 |
msgstr ""
|
282 |
|
283 |
+
#: classes/settings.php:327
|
284 |
+
msgid ""
|
285 |
+
"This is an overview of all snippets defined for this site. These snippets "
|
286 |
+
"are inserted into posts from the post editor using the Post Snippets button. "
|
287 |
+
"You can choose to see the snippets here as-is or as they are actually "
|
288 |
+
"rendered on the website. Enabling rendered snippets for this overview might "
|
289 |
+
"look strange if the snippet have dependencies on variables, CSS or other "
|
290 |
+
"parameters only available on the frontend. If that is the case it is "
|
291 |
+
"recommended to keep this option disabled."
|
292 |
msgstr ""
|
293 |
|
294 |
+
#: classes/settings.php:337
|
295 |
+
msgid "Display rendered snippets"
|
296 |
+
msgstr ""
|
297 |
+
|
298 |
+
#: classes/settings.php:338
|
299 |
+
msgid "Update"
|
300 |
+
msgstr ""
|
301 |
+
|
302 |
+
#: post-snippets.php:99
|
303 |
+
msgid "Settings"
|
304 |
+
msgstr ""
|
305 |
+
|
306 |
+
#: post-snippets.php:472
|
307 |
+
msgid "This snippet is insert only, no variables defined."
|
308 |
msgstr ""
|
309 |
|
310 |
#. Plugin Name of the plugin/theme
|
post-snippets.php
CHANGED
@@ -1,984 +1,808 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Post Snippets
|
4 |
-
Plugin URI: http://wpstorm.net/wordpress-plugins/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 |
-
Version:
|
7 |
-
Author: Johan Steen
|
8 |
-
Author URI: http://johansteen.se/
|
9 |
-
Text Domain: post-snippets
|
10 |
-
|
11 |
-
Copyright 2009-2012 Johan Steen (email : artstorm [at] gmail [dot] com)
|
12 |
-
|
13 |
-
This program is free software; you can redistribute it and/or modify
|
14 |
-
it under the terms of the GNU General Public License as published by
|
15 |
-
the Free Software Foundation; either version 2 of the License, or
|
16 |
-
(at your option) any later version.
|
17 |
-
|
18 |
-
This program is distributed in the hope that it will be useful,
|
19 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
-
GNU General Public License for more details.
|
22 |
-
|
23 |
-
You should have received a copy of the GNU General Public License
|
24 |
-
along with this program; if not, write to the Free Software
|
25 |
-
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
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 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
*
|
158 |
-
*
|
159 |
-
*
|
160 |
-
*
|
161 |
-
*
|
162 |
-
* @
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
*
|
179 |
-
*
|
180 |
-
*
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
$
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
}
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
//
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
if
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
$snippet =
|
542 |
-
|
543 |
-
|
544 |
-
$
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
* The
|
575 |
-
*/
|
576 |
-
function
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
$
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
$
|
771 |
-
|
772 |
-
$
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
}
|
810 |
-
|
811 |
-
// -------------------------------------------------------------------------
|
812 |
-
// Helpers
|
813 |
-
// -------------------------------------------------------------------------
|
814 |
-
|
815 |
-
/**
|
816 |
-
* Get __FILE__ with no symlinks.
|
817 |
-
*
|
818 |
-
* For development purposes mainly. Returns __FILE__ without resolved
|
819 |
-
* symlinks to be used when __FILE__ is needed while resolving symlinks
|
820 |
-
* breaks WP functionaly, so the actual WordPress path is returned instead.
|
821 |
-
* This makes it possible for all WordPress versions to point to the same
|
822 |
-
* plugin folder for faster testing of the plugin in different WordPress
|
823 |
-
* versions.
|
824 |
-
*
|
825 |
-
* @since Post Snippets 1.9
|
826 |
-
* @return The __FILE__ constant without resolved symlinks.
|
827 |
-
*/
|
828 |
-
private function get_FILE()
|
829 |
-
{
|
830 |
-
$dev_path = 'E:\Code\WordPress';
|
831 |
-
$result = strpos( __FILE__, $dev_path );
|
832 |
-
|
833 |
-
if ( $result === false ) {
|
834 |
-
return __FILE__;
|
835 |
-
} else {
|
836 |
-
return str_replace($dev_path, WP_PLUGIN_DIR, __FILE__);
|
837 |
-
}
|
838 |
-
}
|
839 |
-
|
840 |
-
/**
|
841 |
-
* Allow snippets to be retrieved directly from PHP.
|
842 |
-
*
|
843 |
-
* @since Post Snippets 1.8.9.1
|
844 |
-
*
|
845 |
-
* @param string $snippet_name
|
846 |
-
* The name of the snippet to retrieve
|
847 |
-
* @param string $snippet_vars
|
848 |
-
* The variables to pass to the snippet, formatted as a query string.
|
849 |
-
* @return string
|
850 |
-
* The Snippet
|
851 |
-
*/
|
852 |
-
public function get_snippet( $snippet_name, $snippet_vars = '' )
|
853 |
-
{
|
854 |
-
$snippets = get_option($this->plugin_options);
|
855 |
-
for ($i = 0; $i < count($snippets); $i++) {
|
856 |
-
if ($snippets[$i]['title'] == $snippet_name) {
|
857 |
-
parse_str( htmlspecialchars_decode($snippet_vars), $snippet_output );
|
858 |
-
$snippet = $snippets[$i]['snippet'];
|
859 |
-
$var_arr = explode(",",$snippets[$i]['vars']);
|
860 |
-
|
861 |
-
if ( !empty($var_arr[0]) ) {
|
862 |
-
for ($j = 0; $j < count($var_arr); $j++) {
|
863 |
-
$snippet = str_replace("{".$var_arr[$j]."}", $snippet_output[$var_arr[$j]], $snippet);
|
864 |
-
}
|
865 |
-
}
|
866 |
-
}
|
867 |
-
}
|
868 |
-
return $snippet;
|
869 |
-
}
|
870 |
-
}
|
871 |
-
|
872 |
-
|
873 |
-
// -----------------------------------------------------------------------------
|
874 |
-
// Start the plugin
|
875 |
-
// -----------------------------------------------------------------------------
|
876 |
-
|
877 |
-
// Check the host environment
|
878 |
-
$test_post_snippets_host = new Post_Snippets_Host_Environment();
|
879 |
-
|
880 |
-
// If environment is up to date, start the plugin
|
881 |
-
if($test_post_snippets_host->passed) {
|
882 |
-
// Load external classes
|
883 |
-
if (is_admin()) {
|
884 |
-
require plugin_dir_path(__FILE__).'classes/settings.php';
|
885 |
-
require plugin_dir_path(__FILE__).'classes/help.php';
|
886 |
-
}
|
887 |
-
|
888 |
-
add_action(
|
889 |
-
'plugins_loaded',
|
890 |
-
create_function(
|
891 |
-
'',
|
892 |
-
'global $post_snippets; $post_snippets = new Post_Snippets();'
|
893 |
-
)
|
894 |
-
);
|
895 |
-
}
|
896 |
-
|
897 |
-
|
898 |
-
/**
|
899 |
-
* Post Snippets Host Environment.
|
900 |
-
*
|
901 |
-
* Checks that the host environment fulfils the requirements of Post Snippets.
|
902 |
-
* This class is designed to work with PHP versions below 5, to make sure it's
|
903 |
-
* always executed.
|
904 |
-
*
|
905 |
-
* - PHP Version 5.2.4 is on par with the requirements for WordPress 3.3.
|
906 |
-
*
|
907 |
-
* @since Post Snippets 1.8.8
|
908 |
-
*/
|
909 |
-
class Post_Snippets_Host_Environment
|
910 |
-
{
|
911 |
-
// Minimum versions required
|
912 |
-
var $MIN_PHP_VERSION = '5.2.4';
|
913 |
-
var $MIN_WP_VERSION = '3.0';
|
914 |
-
var $passed = true;
|
915 |
-
|
916 |
-
/**
|
917 |
-
* Constructor.
|
918 |
-
*
|
919 |
-
* Checks PHP and WordPress versions. If any check failes, a system notice
|
920 |
-
* is added and $passed is set to fail, which can be checked before trying
|
921 |
-
* to create the main class.
|
922 |
-
*/
|
923 |
-
function Post_Snippets_Host_Environment()
|
924 |
-
{
|
925 |
-
// Check if PHP is too old
|
926 |
-
if (version_compare(PHP_VERSION, $this->MIN_PHP_VERSION, '<')) {
|
927 |
-
// Display notice
|
928 |
-
add_action( 'admin_notices', array(&$this, 'php_version_error') );
|
929 |
-
$this->passed = false;
|
930 |
-
}
|
931 |
-
|
932 |
-
// Check if WordPress is too old
|
933 |
-
global $wp_version;
|
934 |
-
if ( version_compare($wp_version, $this->MIN_WP_VERSION, '<') ) {
|
935 |
-
add_action( 'admin_notices', array(&$this, 'wp_version_error') );
|
936 |
-
$this->passed = false;
|
937 |
-
}
|
938 |
-
}
|
939 |
-
|
940 |
-
/**
|
941 |
-
* Displays a warning when installed on an old PHP version.
|
942 |
-
*/
|
943 |
-
function php_version_error() {
|
944 |
-
echo '<div class="error"><p><strong>';
|
945 |
-
printf(
|
946 |
-
'Error: Post Snippets requires PHP version %1$s or greater.<br/>'.
|
947 |
-
'Your installed PHP version: %2$s',
|
948 |
-
$this->MIN_PHP_VERSION, PHP_VERSION);
|
949 |
-
echo '</strong></p></div>';
|
950 |
-
}
|
951 |
-
|
952 |
-
/**
|
953 |
-
* Displays a warning when installed in an old Wordpress version.
|
954 |
-
*/
|
955 |
-
function wp_version_error() {
|
956 |
-
echo '<div class="error"><p><strong>';
|
957 |
-
printf(
|
958 |
-
'Error: Post Snippets requires WordPress version %s or greater.',
|
959 |
-
$this->MIN_WP_VERSION );
|
960 |
-
echo '</strong></p></div>';
|
961 |
-
}
|
962 |
-
}
|
963 |
-
|
964 |
-
// -----------------------------------------------------------------------------
|
965 |
-
// Helper functions
|
966 |
-
// -----------------------------------------------------------------------------
|
967 |
-
|
968 |
-
/**
|
969 |
-
* Allow snippets to be retrieved directly from PHP.
|
970 |
-
* This function is a wrapper for Post_Snippets::get_snippet().
|
971 |
-
*
|
972 |
-
* @since Post Snippets 1.6
|
973 |
-
*
|
974 |
-
* @param string $snippet_name
|
975 |
-
* The name of the snippet to retrieve
|
976 |
-
* @param string $snippet_vars
|
977 |
-
* The variables to pass to the snippet, formatted as a query string.
|
978 |
-
* @return string
|
979 |
-
* The Snippet
|
980 |
-
*/
|
981 |
-
function get_post_snippet( $snippet_name, $snippet_vars = '' ) {
|
982 |
-
global $post_snippets;
|
983 |
-
return $post_snippets->get_snippet( $snippet_name, $snippet_vars );
|
984 |
-
}
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Post Snippets
|
4 |
+
Plugin URI: http://wpstorm.net/wordpress-plugins/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 |
+
Version: 2.0
|
7 |
+
Author: Johan Steen
|
8 |
+
Author URI: http://johansteen.se/
|
9 |
+
Text Domain: post-snippets
|
10 |
+
|
11 |
+
Copyright 2009-2012 Johan Steen (email : artstorm [at] gmail [dot] com)
|
12 |
+
|
13 |
+
This program is free software; you can redistribute it and/or modify
|
14 |
+
it under the terms of the GNU General Public License as published by
|
15 |
+
the Free Software Foundation; either version 2 of the License, or
|
16 |
+
(at your option) any later version.
|
17 |
+
|
18 |
+
This program is distributed in the hope that it will be useful,
|
19 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
+
GNU General Public License for more details.
|
22 |
+
|
23 |
+
You should have received a copy of the GNU General Public License
|
24 |
+
along with this program; if not, write to the Free Software
|
25 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
+
*/
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Base Class.
|
30 |
+
*/
|
31 |
+
class Post_Snippets_Base {
|
32 |
+
// Constants
|
33 |
+
const PLUGIN_OPTION_KEY = 'post_snippets_options';
|
34 |
+
const USER_OPTION_KEY = 'post_snippets';
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Plugin Main Class.
|
39 |
+
*/
|
40 |
+
class Post_Snippets extends Post_Snippets_Base
|
41 |
+
{
|
42 |
+
// Constants
|
43 |
+
const TINYMCE_PLUGIN_NAME = 'post_snippets';
|
44 |
+
|
45 |
+
// -------------------------------------------------------------------------
|
46 |
+
|
47 |
+
public function __construct() {
|
48 |
+
// Define the domain and path for translations
|
49 |
+
$rel_path = dirname(plugin_basename($this->get_File())).'/languages/';
|
50 |
+
load_plugin_textdomain( 'post-snippets', false, $rel_path );
|
51 |
+
|
52 |
+
$this->init_hooks();
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Initializes the hooks for the plugin
|
57 |
+
*/
|
58 |
+
function init_hooks() {
|
59 |
+
|
60 |
+
// Add TinyMCE button
|
61 |
+
add_action('init', array(&$this, 'add_tinymce_button') );
|
62 |
+
|
63 |
+
// Settings link on plugins list
|
64 |
+
add_filter( 'plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2 );
|
65 |
+
// Options Page
|
66 |
+
add_action( 'admin_menu', array(&$this,'wp_admin') );
|
67 |
+
|
68 |
+
$this->create_shortcodes();
|
69 |
+
|
70 |
+
// Adds the JS and HTML code in the header and footer for the jQuery
|
71 |
+
// insert UI dialog in the editor
|
72 |
+
add_action( 'admin_init', array(&$this,'enqueue_assets') );
|
73 |
+
add_action( 'admin_head', array(&$this,'jquery_ui_dialog') );
|
74 |
+
add_action( 'admin_footer', array(&$this,'add_jquery_ui_dialog') );
|
75 |
+
|
76 |
+
// Add Editor QuickTag button:
|
77 |
+
// IF WordPress is 3.3 or higher, use the new refactored method to add
|
78 |
+
// the quicktag button.
|
79 |
+
// Start showing a deprecated message from version 1.9 of the plugin for
|
80 |
+
// the old method. And remove it completely when the plugin hits 2.0.
|
81 |
+
global $wp_version;
|
82 |
+
if ( version_compare($wp_version, '3.3', '>=') ) {
|
83 |
+
add_action( 'admin_print_footer_scripts',
|
84 |
+
array(&$this,'add_quicktag_button'), 100 );
|
85 |
+
} else {
|
86 |
+
add_action( 'edit_form_advanced', array(&$this,'add_quicktag_button_pre33') );
|
87 |
+
add_action( 'edit_page_form', array(&$this,'add_quicktag_button_pre33') );
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Quick link to the Post Snippets Settings page from the Plugins page.
|
94 |
+
*
|
95 |
+
* @return Array with all the plugin's action links
|
96 |
+
*/
|
97 |
+
function plugin_action_links( $links, $file ) {
|
98 |
+
if ( $file == plugin_basename( dirname($this->get_FILE()).'/post-snippets.php' ) ) {
|
99 |
+
$links[] = '<a href="options-general.php?page=post-snippets/post-snippets.php">'.__('Settings', 'post-snippets').'</a>';
|
100 |
+
}
|
101 |
+
return $links;
|
102 |
+
}
|
103 |
+
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Enqueues the necessary scripts and styles for the plugins
|
107 |
+
*
|
108 |
+
* @since Post Snippets 1.7
|
109 |
+
*/
|
110 |
+
function enqueue_assets() {
|
111 |
+
wp_enqueue_script( 'jquery-ui-dialog' );
|
112 |
+
wp_enqueue_script( 'jquery-ui-tabs' );
|
113 |
+
wp_enqueue_style( 'wp-jquery-ui-dialog' );
|
114 |
+
|
115 |
+
# Adds the CSS stylesheet for the jQuery UI dialog
|
116 |
+
$style_url = plugins_url( '/assets/post-snippets.css', $this->get_FILE() );
|
117 |
+
wp_register_style( 'post-snippets', $style_url, false, '2.0' );
|
118 |
+
wp_enqueue_style( 'post-snippets' );
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
// -------------------------------------------------------------------------
|
123 |
+
// WordPress Editor Buttons
|
124 |
+
// -------------------------------------------------------------------------
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Add TinyMCE button.
|
128 |
+
*
|
129 |
+
* Adds filters to add custom buttons to the TinyMCE editor (Visual Editor)
|
130 |
+
* in WordPress.
|
131 |
+
*
|
132 |
+
* @since Post Snippets 1.8.7
|
133 |
+
*/
|
134 |
+
public function add_tinymce_button()
|
135 |
+
{
|
136 |
+
// Don't bother doing this stuff if the current user lacks permissions
|
137 |
+
if ( !current_user_can('edit_posts') &&
|
138 |
+
!current_user_can('edit_pages') )
|
139 |
+
return;
|
140 |
+
|
141 |
+
// Add only in Rich Editor mode
|
142 |
+
if ( get_user_option('rich_editing') == 'true') {
|
143 |
+
add_filter('mce_external_plugins',
|
144 |
+
array(&$this, 'register_tinymce_plugin') );
|
145 |
+
add_filter('mce_buttons',
|
146 |
+
array(&$this, 'register_tinymce_button') );
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Register TinyMCE button.
|
152 |
+
*
|
153 |
+
* Pushes the custom TinyMCE button into the array of with button names.
|
154 |
+
* 'separator' or '|' can be pushed to the array as well. See the link
|
155 |
+
* for all available TinyMCE controls.
|
156 |
+
*
|
157 |
+
* @see wp-includes/class-wp-editor.php
|
158 |
+
* @link http://www.tinymce.com/wiki.php/Buttons/controls
|
159 |
+
* @since Post Snippets 1.8.7
|
160 |
+
*
|
161 |
+
* @param array $buttons Filter supplied array of buttons to modify
|
162 |
+
* @return array The modified array with buttons
|
163 |
+
*/
|
164 |
+
public function register_tinymce_button( $buttons )
|
165 |
+
{
|
166 |
+
array_push( $buttons, 'separator', self::TINYMCE_PLUGIN_NAME );
|
167 |
+
return $buttons;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Register TinyMCE plugin.
|
172 |
+
*
|
173 |
+
* Adds the absolute URL for the TinyMCE plugin to the associative array of
|
174 |
+
* plugins. Array structure: 'plugin_name' => 'plugin_url'
|
175 |
+
*
|
176 |
+
* @see wp-includes/class-wp-editor.php
|
177 |
+
* @since Post Snippets 1.8.7
|
178 |
+
*
|
179 |
+
* @param array $plugins Filter supplied array of plugins to modify
|
180 |
+
* @return array The modified array with plugins
|
181 |
+
*/
|
182 |
+
public function register_tinymce_plugin( $plugins )
|
183 |
+
{
|
184 |
+
// Load the TinyMCE plugin, editor_plugin.js, into the array
|
185 |
+
$plugins[self::TINYMCE_PLUGIN_NAME] =
|
186 |
+
plugins_url('/tinymce/editor_plugin.js?ver=1.9', $this->get_FILE());
|
187 |
+
|
188 |
+
return $plugins;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Adds a QuickTag button to the HTML editor.
|
193 |
+
*
|
194 |
+
* Compatible with WordPress 3.3 and newer.
|
195 |
+
*
|
196 |
+
* @see wp-includes/js/quicktags.dev.js -> qt.addButton()
|
197 |
+
* @since Post Snippets 1.8.6
|
198 |
+
*/
|
199 |
+
public function add_quicktag_button()
|
200 |
+
{
|
201 |
+
// Only run the function on post edit screens
|
202 |
+
if ( function_exists( 'get_current_screen' ) ) {
|
203 |
+
$screen = get_current_screen();
|
204 |
+
if ($screen->base != 'post')
|
205 |
+
return;
|
206 |
+
}
|
207 |
+
|
208 |
+
echo "\n<!-- START: Add QuickTag button for Post Snippets -->\n";
|
209 |
+
?>
|
210 |
+
<script type="text/javascript" charset="utf-8">
|
211 |
+
QTags.addButton( 'post_snippets_id', 'Post Snippets', qt_post_snippets );
|
212 |
+
function qt_post_snippets() {
|
213 |
+
post_snippets_caller = 'html';
|
214 |
+
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
215 |
+
}
|
216 |
+
</script>
|
217 |
+
<?php
|
218 |
+
echo "\n<!-- END: Add QuickTag button for Post Snippets -->\n";
|
219 |
+
}
|
220 |
+
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Adds a QuickTag button to the HTML editor.
|
224 |
+
*
|
225 |
+
* Used when running on WordPress lower than version 3.3.
|
226 |
+
*
|
227 |
+
* @see wp-includes/js/quicktags.dev.js
|
228 |
+
* @since Post Snippets 1.7
|
229 |
+
* @deprecated Since 1.8.6
|
230 |
+
*/
|
231 |
+
function add_quicktag_button_pre33() {
|
232 |
+
// Only run the function on post edit screens
|
233 |
+
if ( function_exists( 'get_current_screen' ) ) {
|
234 |
+
$screen = get_current_screen();
|
235 |
+
if ($screen->base != 'post')
|
236 |
+
return;
|
237 |
+
}
|
238 |
+
|
239 |
+
echo "\n<!-- START: Post Snippets QuickTag button -->\n";
|
240 |
+
?>
|
241 |
+
<script type="text/javascript" charset="utf-8">
|
242 |
+
// <![CDATA[
|
243 |
+
//edButton(id, display, tagStart, tagEnd, access, open)
|
244 |
+
edbuttonlength = edButtons.length;
|
245 |
+
edButtons[edbuttonlength++] = new edButton('ed_postsnippets', 'Post Snippets', '', '', '', -1);
|
246 |
+
(function(){
|
247 |
+
if (typeof jQuery === 'undefined') {
|
248 |
+
return;
|
249 |
+
}
|
250 |
+
jQuery(document).ready(function(){
|
251 |
+
jQuery("#ed_toolbar").append('<input type="button" value="Post Snippets" id="ed_postsnippets" class="ed_button" onclick="edOpenPostSnippets(edCanvas);" title="Post Snippets" />');
|
252 |
+
});
|
253 |
+
}());
|
254 |
+
// ]]>
|
255 |
+
</script>
|
256 |
+
<?php
|
257 |
+
echo "\n<!-- END: Post Snippets QuickTag button -->\n";
|
258 |
+
}
|
259 |
+
|
260 |
+
|
261 |
+
// -------------------------------------------------------------------------
|
262 |
+
// JavaScript / jQuery handling for the post editor
|
263 |
+
// -------------------------------------------------------------------------
|
264 |
+
|
265 |
+
/**
|
266 |
+
* jQuery control for the dialog and Javascript needed to insert snippets into the editor
|
267 |
+
*
|
268 |
+
* @since Post Snippets 1.7
|
269 |
+
*/
|
270 |
+
public function jquery_ui_dialog()
|
271 |
+
{
|
272 |
+
// Only run the function on post edit screens
|
273 |
+
if ( function_exists( 'get_current_screen' ) ) {
|
274 |
+
$screen = get_current_screen();
|
275 |
+
if ($screen->base != 'post')
|
276 |
+
return;
|
277 |
+
}
|
278 |
+
|
279 |
+
echo "\n<!-- START: Post Snippets jQuery UI and related functions -->\n";
|
280 |
+
echo "<script type='text/javascript'>\n";
|
281 |
+
|
282 |
+
# Prepare the snippets and shortcodes into javascript variables
|
283 |
+
# so they can be inserted into the editor, and get the variables replaced
|
284 |
+
# with user defined strings.
|
285 |
+
$snippets = get_option( self::PLUGIN_OPTION_KEY );
|
286 |
+
foreach ($snippets as $key => $snippet) {
|
287 |
+
if ($snippet['shortcode']) {
|
288 |
+
# Build a long string of the variables, ie: varname1={varname1} varname2={varname2}
|
289 |
+
# so {varnameX} can be replaced at runtime.
|
290 |
+
$var_arr = explode(",",$snippet['vars']);
|
291 |
+
$variables = '';
|
292 |
+
if (!empty($var_arr[0])) {
|
293 |
+
foreach ($var_arr as $var) {
|
294 |
+
// '[test2 yet="{yet}" mupp=per="{mupp=per}" content="{content}"]';
|
295 |
+
$var = $this->strip_default_val( $var );
|
296 |
+
|
297 |
+
$variables .= ' ' . $var . '="{' . $var . '}"';
|
298 |
+
}
|
299 |
+
}
|
300 |
+
$shortcode = $snippet['title'] . $variables;
|
301 |
+
echo "var postsnippet_{$key} = '[" . $shortcode . "]';\n";
|
302 |
+
} else {
|
303 |
+
// To use $snippet is probably not a good naming convention here.
|
304 |
+
// rename to js_snippet or something?
|
305 |
+
$snippet = $snippet['snippet'];
|
306 |
+
# Fixes for potential collisions:
|
307 |
+
/* Replace <> with char codes, otherwise </script> in a snippet will break it */
|
308 |
+
$snippet = str_replace( '<', '\x3C', str_replace( '>', '\x3E', $snippet ) );
|
309 |
+
/* Escape " with \" */
|
310 |
+
$snippet = str_replace( '"', '\"', $snippet );
|
311 |
+
/* Remove CR and replace LF with \n to keep formatting */
|
312 |
+
$snippet = str_replace( chr(13), '', str_replace( chr(10), '\n', $snippet ) );
|
313 |
+
# Print out the variable containing the snippet
|
314 |
+
echo "var postsnippet_{$key} = \"" . $snippet . "\";\n";
|
315 |
+
}
|
316 |
+
}
|
317 |
+
?>
|
318 |
+
|
319 |
+
jQuery(document).ready(function($){
|
320 |
+
<?php
|
321 |
+
# Create js variables for all form fields
|
322 |
+
foreach ($snippets as $key => $snippet) {
|
323 |
+
$var_arr = explode(",",$snippet['vars']);
|
324 |
+
if (!empty($var_arr[0])) {
|
325 |
+
foreach ($var_arr as $key_2 => $var) {
|
326 |
+
$varname = "var_" . $key . "_" . $key_2;
|
327 |
+
echo "var {$varname} = $( \"#{$varname}\" );\n";
|
328 |
+
}
|
329 |
+
}
|
330 |
+
}
|
331 |
+
?>
|
332 |
+
|
333 |
+
var $tabs = $("#post-snippets-tabs").tabs();
|
334 |
+
|
335 |
+
$(function() {
|
336 |
+
$( "#post-snippets-dialog" ).dialog({
|
337 |
+
autoOpen: false,
|
338 |
+
modal: true,
|
339 |
+
dialogClass: 'wp-dialog',
|
340 |
+
buttons: {
|
341 |
+
Cancel: function() {
|
342 |
+
$( this ).dialog( "close" );
|
343 |
+
},
|
344 |
+
"Insert": function() {
|
345 |
+
$( this ).dialog( "close" );
|
346 |
+
var selected = $tabs.tabs('option', 'selected');
|
347 |
+
<?php
|
348 |
+
foreach ($snippets as $key => $snippet) {
|
349 |
+
?>
|
350 |
+
if (selected == <?php echo $key; ?>) {
|
351 |
+
insert_snippet = postsnippet_<?php echo $key; ?>;
|
352 |
+
<?php
|
353 |
+
$var_arr = explode(",",$snippet['vars']);
|
354 |
+
if (!empty($var_arr[0])) {
|
355 |
+
foreach ($var_arr as $key_2 => $var) {
|
356 |
+
$varname = "var_" . $key . "_" . $key_2; ?>
|
357 |
+
insert_snippet = insert_snippet.replace(/\{<?php echo $this->strip_default_val( $var ); ?>\}/g, <?php echo $varname; ?>.val());
|
358 |
+
<?php
|
359 |
+
echo "\n";
|
360 |
+
}
|
361 |
+
}
|
362 |
+
?>
|
363 |
+
}
|
364 |
+
<?php
|
365 |
+
}
|
366 |
+
?>
|
367 |
+
|
368 |
+
// Decide what method to use to insert the snippet depending
|
369 |
+
// from what editor the window was opened from
|
370 |
+
if (post_snippets_caller == 'html') {
|
371 |
+
// HTML editor in WordPress 3.3 and greater
|
372 |
+
QTags.insertContent(insert_snippet);
|
373 |
+
} else if (post_snippets_caller == 'html_pre33') {
|
374 |
+
// HTML editor in WordPress below 3.3.
|
375 |
+
edInsertContent(post_snippets_canvas, insert_snippet);
|
376 |
+
} else {
|
377 |
+
// Visual Editor
|
378 |
+
post_snippets_canvas.execCommand('mceInsertContent', false, insert_snippet);
|
379 |
+
}
|
380 |
+
|
381 |
+
}
|
382 |
+
},
|
383 |
+
width: 500,
|
384 |
+
});
|
385 |
+
});
|
386 |
+
});
|
387 |
+
|
388 |
+
// Global variables to keep track on the canvas instance and from what editor
|
389 |
+
// that opened the Post Snippets popup.
|
390 |
+
var post_snippets_canvas;
|
391 |
+
var post_snippets_caller = '';
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Used in WordPress lower than version 3.3.
|
395 |
+
* Not used anymore starting with WordPress version 3.3.
|
396 |
+
* Called from: add_quicktag_button_pre33()
|
397 |
+
*/
|
398 |
+
function edOpenPostSnippets(myField) {
|
399 |
+
post_snippets_canvas = myField;
|
400 |
+
post_snippets_caller = 'html_pre33';
|
401 |
+
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
402 |
+
};
|
403 |
+
<?php
|
404 |
+
echo "</script>\n";
|
405 |
+
echo "\n<!-- END: Post Snippets jQuery UI and related functions -->\n";
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Build jQuery UI Window.
|
410 |
+
*
|
411 |
+
* Creates the jQuery for Post Editor popup window, its snippet tabs and the
|
412 |
+
* form fields to enter variables.
|
413 |
+
*
|
414 |
+
* @since Post Snippets 1.7
|
415 |
+
*/
|
416 |
+
public function add_jquery_ui_dialog()
|
417 |
+
{
|
418 |
+
// Only run the function on post edit screens
|
419 |
+
if ( function_exists( 'get_current_screen' ) ) {
|
420 |
+
$screen = get_current_screen();
|
421 |
+
if ($screen->base != 'post')
|
422 |
+
return;
|
423 |
+
}
|
424 |
+
|
425 |
+
echo "\n<!-- START: Post Snippets UI Dialog -->\n";
|
426 |
+
// Setup the dialog divs
|
427 |
+
echo "<div class=\"hidden\">\n";
|
428 |
+
echo "\t<div id=\"post-snippets-dialog\" title=\"Post Snippets\">\n";
|
429 |
+
// Init the tabs div
|
430 |
+
echo "\t\t<div id=\"post-snippets-tabs\">\n";
|
431 |
+
echo "\t\t\t<ul>\n";
|
432 |
+
|
433 |
+
// Create a tab for each available snippet
|
434 |
+
$snippets = get_option( self::PLUGIN_OPTION_KEY );
|
435 |
+
foreach ($snippets as $key => $snippet) {
|
436 |
+
echo "\t\t\t\t";
|
437 |
+
echo "<li><a href=\"#ps-tabs-{$key}\">{$snippet['title']}</a></li>";
|
438 |
+
echo "\n";
|
439 |
+
}
|
440 |
+
echo "\t\t\t</ul>\n";
|
441 |
+
|
442 |
+
// Create a panel with form fields for each available snippet
|
443 |
+
foreach ($snippets as $key => $snippet) {
|
444 |
+
echo "\t\t\t<div id=\"ps-tabs-{$key}\">\n";
|
445 |
+
|
446 |
+
// Print a snippet description is available
|
447 |
+
if ( isset($snippet['description']) )
|
448 |
+
echo "\t\t\t\t<p class=\"howto\">" . $snippet['description'] . "</p>\n";
|
449 |
+
|
450 |
+
// Get all variables defined for the snippet and output them as
|
451 |
+
// input fields
|
452 |
+
$var_arr = explode(',', $snippet['vars']);
|
453 |
+
if (!empty($var_arr[0])) {
|
454 |
+
foreach ($var_arr as $key_2 => $var) {
|
455 |
+
// Default value exists?
|
456 |
+
$def_pos = strpos( $var, '=' );
|
457 |
+
if ( $def_pos !== false ) {
|
458 |
+
$split = explode( '=', $var );
|
459 |
+
$var = $split[0];
|
460 |
+
$def = $split[1];
|
461 |
+
} else {
|
462 |
+
$def = '';
|
463 |
+
}
|
464 |
+
echo "\t\t\t\t<label for=\"var_{$key}_{$key_2}\">{$var}:</label>\n";
|
465 |
+
echo "\t\t\t\t<input type=\"text\" id=\"var_{$key}_{$key_2}\" name=\"var_{$key}_{$key_2}\" value=\"{$def}\" style=\"width: 190px\" />\n";
|
466 |
+
echo "\t\t\t\t<br/>\n";
|
467 |
+
}
|
468 |
+
} else {
|
469 |
+
// If no variables and no description available, output a text
|
470 |
+
// to inform the user that it's an insert snippet only.
|
471 |
+
if ( empty($snippet['description']) )
|
472 |
+
echo "\t\t\t\t<p class=\"howto\">" . __('This snippet is insert only, no variables defined.', 'post-snippets') . "</p>\n";
|
473 |
+
}
|
474 |
+
echo "\t\t\t</div><!-- #ps-tabs-{$key} -->\n";
|
475 |
+
}
|
476 |
+
// Close the tabs and dialog divs
|
477 |
+
echo "\t\t</div><!-- #post-snippets-tabs -->\n";
|
478 |
+
echo "\t</div><!-- #post-snippets-dialog -->\n";
|
479 |
+
echo "</div><!-- .hidden -->\n";
|
480 |
+
|
481 |
+
echo "<!-- END: Post Snippets UI Dialog -->\n\n";
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Strip Default Value.
|
486 |
+
*
|
487 |
+
* Checks if a variable string contains a default value, and if it does it
|
488 |
+
* will strip it away and return the string with only the variable name
|
489 |
+
* kept.
|
490 |
+
*
|
491 |
+
* @since Post Snippets 1.9.3
|
492 |
+
* @param string $variable The variable to check for default value
|
493 |
+
* @return string The variable without any default value
|
494 |
+
*/
|
495 |
+
public function strip_default_val( $variable )
|
496 |
+
{
|
497 |
+
// Check if variable contains a default defintion
|
498 |
+
$def_pos = strpos( $variable, '=' );
|
499 |
+
|
500 |
+
if ( $def_pos !== false ) {
|
501 |
+
$split = str_split( $variable, $def_pos );
|
502 |
+
$variable = $split[0];
|
503 |
+
}
|
504 |
+
return $variable;
|
505 |
+
}
|
506 |
+
|
507 |
+
// -------------------------------------------------------------------------
|
508 |
+
// Shortcode
|
509 |
+
// -------------------------------------------------------------------------
|
510 |
+
|
511 |
+
/**
|
512 |
+
* Create the functions for shortcodes dynamically and register them
|
513 |
+
*/
|
514 |
+
function create_shortcodes() {
|
515 |
+
$snippets = get_option( self::PLUGIN_OPTION_KEY );
|
516 |
+
if (!empty($snippets)) {
|
517 |
+
foreach ($snippets as $snippet) {
|
518 |
+
// If shortcode is enabled for the snippet, and a snippet has been entered, register it as a shortcode.
|
519 |
+
if ( $snippet['shortcode'] && !empty($snippet['snippet']) ) {
|
520 |
+
|
521 |
+
$vars = explode(",",$snippet['vars']);
|
522 |
+
$vars_str = '';
|
523 |
+
foreach ($vars as $var) {
|
524 |
+
$vars_str = $vars_str . '"'.$var.'" => "",';
|
525 |
+
}
|
526 |
+
|
527 |
+
// Get the wptexturize setting
|
528 |
+
$texturize = isset( $snippet["wptexturize"] ) ? $snippet["wptexturize"] : false;
|
529 |
+
|
530 |
+
add_shortcode($snippet['title'], create_function('$atts,$content=null',
|
531 |
+
'$shortcode_symbols = array('.$vars_str.');
|
532 |
+
extract(shortcode_atts($shortcode_symbols, $atts));
|
533 |
+
|
534 |
+
$attributes = compact( array_keys($shortcode_symbols) );
|
535 |
+
|
536 |
+
// Add enclosed content if available to the attributes array
|
537 |
+
if ( $content != null )
|
538 |
+
$attributes["content"] = $content;
|
539 |
+
|
540 |
+
|
541 |
+
$snippet = \''. addslashes($snippet["snippet"]) .'\';
|
542 |
+
$snippet = str_replace("&", "&", $snippet);
|
543 |
+
|
544 |
+
foreach ($attributes as $key => $val) {
|
545 |
+
$snippet = str_replace("{".$key."}", $val, $snippet);
|
546 |
+
}
|
547 |
+
|
548 |
+
// Handle PHP shortcodes
|
549 |
+
$php = "'. $snippet["php"] .'";
|
550 |
+
if ($php == true) {
|
551 |
+
$snippet = Post_Snippets::php_eval( $snippet );
|
552 |
+
}
|
553 |
+
|
554 |
+
// Strip escaping and execute nested shortcodes
|
555 |
+
$snippet = do_shortcode(stripslashes($snippet));
|
556 |
+
|
557 |
+
// WPTexturize the Snippet
|
558 |
+
$texturize = "'. $texturize .'";
|
559 |
+
if ($texturize == true) {
|
560 |
+
$snippet = wptexturize( $snippet );
|
561 |
+
}
|
562 |
+
|
563 |
+
return $snippet;') );
|
564 |
+
}
|
565 |
+
}
|
566 |
+
}
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Evaluate a snippet as PHP code.
|
571 |
+
*
|
572 |
+
* @since Post Snippets 1.9
|
573 |
+
* @param string $content The snippet to evaluate
|
574 |
+
* @return string The result of the evaluation
|
575 |
+
*/
|
576 |
+
public static function php_eval( $content )
|
577 |
+
{
|
578 |
+
$content = stripslashes($content);
|
579 |
+
|
580 |
+
ob_start();
|
581 |
+
eval ($content);
|
582 |
+
$content = ob_get_clean();
|
583 |
+
|
584 |
+
return addslashes( $content );
|
585 |
+
}
|
586 |
+
|
587 |
+
|
588 |
+
// -------------------------------------------------------------------------
|
589 |
+
// Admin
|
590 |
+
// -------------------------------------------------------------------------
|
591 |
+
|
592 |
+
/**
|
593 |
+
* The Admin Page.
|
594 |
+
*/
|
595 |
+
function wp_admin() {
|
596 |
+
if ( current_user_can('manage_options') ) {
|
597 |
+
// If user can manage options, display the admin page
|
598 |
+
$option_page = add_options_page( 'Post Snippets Options', 'Post Snippets', 'administrator', $this->get_FILE(), array(&$this, 'options_page') );
|
599 |
+
if ( $option_page and class_exists('Post_Snippets_Help') ) {
|
600 |
+
$help = new Post_Snippets_Help( $option_page );
|
601 |
+
}
|
602 |
+
} else {
|
603 |
+
// If user can't manage options, but can edit posts, display the overview page
|
604 |
+
$option_page = add_options_page( 'Post Snippets', 'Post Snippets', 'edit_posts', $this->get_FILE(), array(&$this, 'overview_page') );
|
605 |
+
}
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* The options Overview page.
|
610 |
+
*
|
611 |
+
* For users without manage_options cap but with edit_posts cap. A read-only
|
612 |
+
* view.
|
613 |
+
*
|
614 |
+
* @since Post Snippets 1.9.7
|
615 |
+
*/
|
616 |
+
public function overview_page()
|
617 |
+
{
|
618 |
+
$settings = new Post_Snippets_Settings();
|
619 |
+
$settings->render( 'overview' );
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* The options Admin page.
|
624 |
+
*
|
625 |
+
* For users with manage_options capability.
|
626 |
+
*/
|
627 |
+
public function options_page()
|
628 |
+
{
|
629 |
+
$settings = new Post_Snippets_Settings();
|
630 |
+
$settings->render( 'options' );
|
631 |
+
}
|
632 |
+
|
633 |
+
|
634 |
+
// -------------------------------------------------------------------------
|
635 |
+
// Helpers
|
636 |
+
// -------------------------------------------------------------------------
|
637 |
+
|
638 |
+
/**
|
639 |
+
* Get __FILE__ with no symlinks.
|
640 |
+
*
|
641 |
+
* For development purposes mainly. Returns __FILE__ without resolved
|
642 |
+
* symlinks to be used when __FILE__ is needed while resolving symlinks
|
643 |
+
* breaks WP functionaly, so the actual WordPress path is returned instead.
|
644 |
+
* This makes it possible for all WordPress versions to point to the same
|
645 |
+
* plugin folder for faster testing of the plugin in different WordPress
|
646 |
+
* versions.
|
647 |
+
*
|
648 |
+
* @since Post Snippets 1.9
|
649 |
+
* @return The __FILE__ constant without resolved symlinks.
|
650 |
+
*/
|
651 |
+
private function get_FILE()
|
652 |
+
{
|
653 |
+
$dev_path = 'E:\Code\WordPress';
|
654 |
+
$result = strpos( __FILE__, $dev_path );
|
655 |
+
|
656 |
+
if ( $result === false ) {
|
657 |
+
return __FILE__;
|
658 |
+
} else {
|
659 |
+
return str_replace($dev_path, WP_PLUGIN_DIR, __FILE__);
|
660 |
+
}
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* Allow snippets to be retrieved directly from PHP.
|
665 |
+
*
|
666 |
+
* @since Post Snippets 1.8.9.1
|
667 |
+
*
|
668 |
+
* @param string $snippet_name
|
669 |
+
* The name of the snippet to retrieve
|
670 |
+
* @param string $snippet_vars
|
671 |
+
* The variables to pass to the snippet, formatted as a query string.
|
672 |
+
* @return string
|
673 |
+
* The Snippet
|
674 |
+
*/
|
675 |
+
public function get_snippet( $snippet_name, $snippet_vars = '' )
|
676 |
+
{
|
677 |
+
$snippets = get_option( self::PLUGIN_OPTION_KEY );
|
678 |
+
for ($i = 0; $i < count($snippets); $i++) {
|
679 |
+
if ($snippets[$i]['title'] == $snippet_name) {
|
680 |
+
parse_str( htmlspecialchars_decode($snippet_vars), $snippet_output );
|
681 |
+
$snippet = $snippets[$i]['snippet'];
|
682 |
+
$var_arr = explode(",",$snippets[$i]['vars']);
|
683 |
+
|
684 |
+
if ( !empty($var_arr[0]) ) {
|
685 |
+
for ($j = 0; $j < count($var_arr); $j++) {
|
686 |
+
$snippet = str_replace("{".$var_arr[$j]."}", $snippet_output[$var_arr[$j]], $snippet);
|
687 |
+
}
|
688 |
+
}
|
689 |
+
}
|
690 |
+
}
|
691 |
+
return $snippet;
|
692 |
+
}
|
693 |
+
}
|
694 |
+
|
695 |
+
|
696 |
+
// -----------------------------------------------------------------------------
|
697 |
+
// Start the plugin
|
698 |
+
// -----------------------------------------------------------------------------
|
699 |
+
|
700 |
+
// Check the host environment
|
701 |
+
$test_post_snippets_host = new Post_Snippets_Host_Environment();
|
702 |
+
|
703 |
+
// If environment is up to date, start the plugin
|
704 |
+
if($test_post_snippets_host->passed) {
|
705 |
+
// Load external classes
|
706 |
+
if (is_admin()) {
|
707 |
+
require plugin_dir_path(__FILE__).'classes/settings.php';
|
708 |
+
require plugin_dir_path(__FILE__).'classes/help.php';
|
709 |
+
require plugin_dir_path(__FILE__).'classes/import-export.php';
|
710 |
+
}
|
711 |
+
|
712 |
+
add_action(
|
713 |
+
'plugins_loaded',
|
714 |
+
create_function(
|
715 |
+
'',
|
716 |
+
'global $post_snippets; $post_snippets = new Post_Snippets();'
|
717 |
+
)
|
718 |
+
);
|
719 |
+
}
|
720 |
+
|
721 |
+
|
722 |
+
/**
|
723 |
+
* Post Snippets Host Environment.
|
724 |
+
*
|
725 |
+
* Checks that the host environment fulfils the requirements of Post Snippets.
|
726 |
+
* This class is designed to work with PHP versions below 5, to make sure it's
|
727 |
+
* always executed.
|
728 |
+
*
|
729 |
+
* - PHP Version 5.2.4 is on par with the requirements for WordPress 3.3.
|
730 |
+
*
|
731 |
+
* @since Post Snippets 1.8.8
|
732 |
+
*/
|
733 |
+
class Post_Snippets_Host_Environment
|
734 |
+
{
|
735 |
+
// Minimum versions required
|
736 |
+
var $MIN_PHP_VERSION = '5.2.4';
|
737 |
+
var $MIN_WP_VERSION = '3.0';
|
738 |
+
var $passed = true;
|
739 |
+
|
740 |
+
/**
|
741 |
+
* Constructor.
|
742 |
+
*
|
743 |
+
* Checks PHP and WordPress versions. If any check failes, a system notice
|
744 |
+
* is added and $passed is set to fail, which can be checked before trying
|
745 |
+
* to create the main class.
|
746 |
+
*/
|
747 |
+
function Post_Snippets_Host_Environment()
|
748 |
+
{
|
749 |
+
// Check if PHP is too old
|
750 |
+
if (version_compare(PHP_VERSION, $this->MIN_PHP_VERSION, '<')) {
|
751 |
+
// Display notice
|
752 |
+
add_action( 'admin_notices', array(&$this, 'php_version_error') );
|
753 |
+
$this->passed = false;
|
754 |
+
}
|
755 |
+
|
756 |
+
// Check if WordPress is too old
|
757 |
+
global $wp_version;
|
758 |
+
if ( version_compare($wp_version, $this->MIN_WP_VERSION, '<') ) {
|
759 |
+
add_action( 'admin_notices', array(&$this, 'wp_version_error') );
|
760 |
+
$this->passed = false;
|
761 |
+
}
|
762 |
+
}
|
763 |
+
|
764 |
+
/**
|
765 |
+
* Displays a warning when installed on an old PHP version.
|
766 |
+
*/
|
767 |
+
function php_version_error() {
|
768 |
+
echo '<div class="error"><p><strong>';
|
769 |
+
printf(
|
770 |
+
'Error: Post Snippets requires PHP version %1$s or greater.<br/>'.
|
771 |
+
'Your installed PHP version: %2$s',
|
772 |
+
$this->MIN_PHP_VERSION, PHP_VERSION);
|
773 |
+
echo '</strong></p></div>';
|
774 |
+
}
|
775 |
+
|
776 |
+
/**
|
777 |
+
* Displays a warning when installed in an old Wordpress version.
|
778 |
+
*/
|
779 |
+
function wp_version_error() {
|
780 |
+
echo '<div class="error"><p><strong>';
|
781 |
+
printf(
|
782 |
+
'Error: Post Snippets requires WordPress version %s or greater.',
|
783 |
+
$this->MIN_WP_VERSION );
|
784 |
+
echo '</strong></p></div>';
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
+
// -----------------------------------------------------------------------------
|
789 |
+
// Helper functions
|
790 |
+
// -----------------------------------------------------------------------------
|
791 |
+
|
792 |
+
/**
|
793 |
+
* Allow snippets to be retrieved directly from PHP.
|
794 |
+
* This function is a wrapper for Post_Snippets::get_snippet().
|
795 |
+
*
|
796 |
+
* @since Post Snippets 1.6
|
797 |
+
*
|
798 |
+
* @param string $snippet_name
|
799 |
+
* The name of the snippet to retrieve
|
800 |
+
* @param string $snippet_vars
|
801 |
+
* The variables to pass to the snippet, formatted as a query string.
|
802 |
+
* @return string
|
803 |
+
* The Snippet
|
804 |
+
*/
|
805 |
+
function get_post_snippet( $snippet_name, $snippet_vars = '' ) {
|
806 |
+
global $post_snippets;
|
807 |
+
return $post_snippets->get_snippet( $snippet_name, $snippet_vars );
|
808 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: artstorm
|
|
3 |
Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.3.1
|
6 |
-
Stable tag:
|
7 |
|
8 |
Keep a snippet library of text, HTML or PHP code to be used in posts. Variables
|
9 |
can be set for more flexibility. Inserts directly or as shortcodes.
|
@@ -86,19 +86,28 @@ for questions, answers, support and feature requests.
|
|
86 |
|
87 |
== Screenshots ==
|
88 |
|
89 |
-
1. The Admin page where you
|
90 |
2. The TinyMCE button for Post Snippets.
|
91 |
-
3. The Post Snippet
|
|
|
|
|
92 |
|
93 |
== Changelog ==
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
= Version 1.9.7 - 22 Mar 2012 =
|
96 |
* Updated the styling for the snippet insert window in the post editor. This
|
97 |
fixes the visual glitch with tabs spanning multiple rows.
|
98 |
* Users without `manage_options` but with `edit_posts` capability (authors,
|
99 |
-
contributors, editors)can now see a read-only list of available snippets and
|
100 |
related info.
|
101 |
-
* Users with read-only access
|
102 |
overview as rendered output or as-is.
|
103 |
* Enabled `label for=` with checkboxes.
|
104 |
* Included Romanian translation by Web Hosting Geeks.
|
3 |
Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 3.3.1
|
6 |
+
Stable tag: 2.0
|
7 |
|
8 |
Keep a snippet library of text, HTML or PHP code to be used in posts. Variables
|
9 |
can be set for more flexibility. Inserts directly or as shortcodes.
|
86 |
|
87 |
== Screenshots ==
|
88 |
|
89 |
+
1. The Admin page where you create and manage snippets.
|
90 |
2. The TinyMCE button for Post Snippets.
|
91 |
+
3. The Post Snippet insert dialog.
|
92 |
+
4. Help system available on the admin page.
|
93 |
+
|
94 |
|
95 |
== Changelog ==
|
96 |
|
97 |
+
= Version 2.0 - 29 Mar 2012 =
|
98 |
+
* Added tabs to the Admin page, and moved Import/Export to a separate tab.
|
99 |
+
* Pressing enter in a text field now defaults to Update and not Add.
|
100 |
+
* Fixed debug notice message displayed when deleting without any snippets
|
101 |
+
selected.
|
102 |
+
* Various code refactoring and optimizations.
|
103 |
+
|
104 |
= Version 1.9.7 - 22 Mar 2012 =
|
105 |
* Updated the styling for the snippet insert window in the post editor. This
|
106 |
fixes the visual glitch with tabs spanning multiple rows.
|
107 |
* Users without `manage_options` but with `edit_posts` capability (authors,
|
108 |
+
contributors, editors) can now see a read-only list of available snippets and
|
109 |
related info.
|
110 |
+
* Users with read-only access can toggle if they want to see their snippets
|
111 |
overview as rendered output or as-is.
|
112 |
* Enabled `label for=` with checkboxes.
|
113 |
* Included Romanian translation by Web Hosting Geeks.
|
screenshot-1.jpg
CHANGED
Binary file
|
screenshot-3.jpg
CHANGED
Binary file
|
screenshot-4.jpg
ADDED
Binary file
|
uninstall.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Uninstall.
|
4 |
-
* Clean up the WP DB by deleting the options created by the plugin.
|
5 |
-
*/
|
6 |
function post_snippets_uninstall()
|
7 |
{
|
8 |
// Delete all snippets
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Uninstall.
|
4 |
+
* Clean up the WP DB by deleting the options created by the plugin.
|
5 |
+
*/
|
6 |
function post_snippets_uninstall()
|
7 |
{
|
8 |
// Delete all snippets
|