Version Description
Download this release
Release Info
Developer | artstorm |
Plugin | Post Snippets |
Version | 1.9.2 |
Comparing to | |
See all releases |
Code changes from version 1.9.1 to 1.9.2
- assets/post-snippets.css +1 -0
- classes/help.php +2 -2
- post-snippets.php +144 -116
- readme.txt +15 -9
- tests/post-snippets-test.php +7 -0
- tinymce/editor_plugin.js +9 -17
assets/post-snippets.css
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
/**
|
2 |
* Styling for the jQuery UI dialog used by Post Snippets
|
3 |
*
|
|
|
4 |
* @since Post Snippets 1.7.1
|
5 |
*/
|
6 |
#post-snippets-tabs {
|
1 |
/**
|
2 |
* Styling for the jQuery UI dialog used by Post Snippets
|
3 |
*
|
4 |
+
* @version 1.0
|
5 |
* @since Post Snippets 1.7.1
|
6 |
*/
|
7 |
#post-snippets-tabs {
|
classes/help.php
CHANGED
@@ -98,12 +98,12 @@ class Post_Snippets_Help
|
|
98 |
__( 'Variables', 'post-snippets' ).
|
99 |
'</h2>
|
100 |
<p>'.
|
101 |
-
__( 'A comma separated list of custom variables you can reference in your snippet.', 'post-snippets' ).
|
102 |
'</p>
|
103 |
<p><strong>'.
|
104 |
__( 'Example', 'post-snippets' ).
|
105 |
'</strong><br/>
|
106 |
-
<code>url,name</code></p>'.
|
107 |
|
108 |
'<h2>'.
|
109 |
__( 'Snippet', 'post-snippets' ).
|
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' ).
|
post-snippets.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Post Snippets
|
4 |
Plugin URI: http://wpstorm.net/wordpress-plugins/post-snippets/
|
5 |
Description: Stores snippets of HTML code or reoccurring text that you often use in your posts. You can use predefined variables to replace parts of the snippet on insert. All snippets are available in the post editor with a TinyMCE button or Quicktags.
|
6 |
-
Version: 1.9.
|
7 |
Author: Johan Steen
|
8 |
Author URI: http://johansteen.se/
|
9 |
Text Domain: post-snippets
|
@@ -57,7 +57,7 @@ class Post_Snippets {
|
|
57 |
# Adds the JS and HTML code in the header and footer for the jQuery insert UI dialog in the editor
|
58 |
add_action( 'admin_init', array(&$this,'enqueue_assets') );
|
59 |
add_action( 'admin_head', array(&$this,'jquery_ui_dialog') );
|
60 |
-
add_action( 'admin_footer', array(&$this,'
|
61 |
|
62 |
# Add Editor QuickTag button
|
63 |
// IF WordPress is 3.3 or higher, use the new refactored method to add
|
@@ -99,9 +99,8 @@ class Post_Snippets {
|
|
99 |
wp_enqueue_style( 'wp-jquery-ui-dialog');
|
100 |
|
101 |
# Adds the CSS stylesheet for the jQuery UI dialog
|
102 |
-
$style_url = plugins_url( '/assets/post-snippets.css', __FILE__ );
|
103 |
$style_url = plugins_url( '/assets/post-snippets.css', $this->get_FILE() );
|
104 |
-
wp_register_style('post-snippets', $style_url);
|
105 |
wp_enqueue_style( 'post-snippets');
|
106 |
}
|
107 |
|
@@ -170,14 +169,69 @@ class Post_Snippets {
|
|
170 |
{
|
171 |
// Load the TinyMCE plugin, editor_plugin.js, into the array
|
172 |
$plugins[$this->tinymce_plugin_name] =
|
173 |
-
plugins_url('/tinymce/editor_plugin.js', $this->get_FILE());
|
174 |
|
175 |
return $plugins;
|
176 |
}
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
-
// -------------------------------------------------------------------------
|
180 |
|
|
|
|
|
|
|
181 |
|
182 |
/**
|
183 |
* jQuery control for the dialog and Javascript needed to insert snippets into the editor
|
@@ -271,10 +325,17 @@ class Post_Snippets {
|
|
271 |
}
|
272 |
?>
|
273 |
|
274 |
-
|
275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
} else {
|
277 |
-
|
|
|
278 |
}
|
279 |
|
280 |
}
|
@@ -284,13 +345,19 @@ class Post_Snippets {
|
|
284 |
});
|
285 |
});
|
286 |
|
287 |
-
|
288 |
-
|
|
|
|
|
289 |
|
290 |
-
|
|
|
|
|
|
|
|
|
291 |
function edOpenPostSnippets(myField) {
|
292 |
-
|
293 |
-
|
294 |
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
295 |
};
|
296 |
<?php
|
@@ -298,118 +365,79 @@ function edOpenPostSnippets(myField) {
|
|
298 |
echo "\n<!-- END: Post Snippets jQuery UI and related functions -->\n";
|
299 |
}
|
300 |
|
301 |
-
|
302 |
/**
|
303 |
-
*
|
|
|
|
|
|
|
304 |
*
|
305 |
* @since Post Snippets 1.7
|
306 |
*/
|
307 |
-
function
|
|
|
308 |
echo "\n<!-- START: Post Snippets UI Dialog -->\n";
|
309 |
-
|
310 |
-
<div class
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
<?php
|
325 |
-
# Create a panel with form fields for each available snippet
|
326 |
-
foreach ($snippets as $key => $snippet) { ?>
|
327 |
-
<div id="ps-tabs-<?php echo $key; ?>">
|
328 |
-
<?php
|
329 |
-
// Print a snippet description is available
|
330 |
-
if ( isset($snippet['description']) )
|
331 |
-
echo '<p class="howto">' . $snippet['description'] . "</p>\n";
|
332 |
-
|
333 |
-
// Get all variables defined for the snippet and output them as input fields
|
334 |
-
$var_arr = explode(",",$snippet['vars']);
|
335 |
-
if (!empty($var_arr[0])) {
|
336 |
-
foreach ($var_arr as $key_2 => $var) { ?>
|
337 |
-
<label for="var_<?php echo $key; ?>_<?php echo $key_2; ?>"><?php echo($var);?>:</label>
|
338 |
-
<input type="text" id="var_<?php echo $key; ?>_<?php echo $key_2; ?>" name="var_<?php echo $key; ?>_<?php echo $key_2; ?>" style="width: 190px" />
|
339 |
-
<br/>
|
340 |
-
<?php
|
341 |
-
}
|
342 |
-
} else {
|
343 |
-
// If no variables and no description available, output a text to inform the user that it's an insert snippet only
|
344 |
-
if ( empty($snippet['description']) )
|
345 |
-
echo '<p class="howto">' . __('This snippet is insert only, no variables defined.', 'post-snippets') . "</p>";
|
346 |
-
}
|
347 |
-
?>
|
348 |
-
</div><!-- #ps-tabs-## -->
|
349 |
-
<?php
|
350 |
-
}
|
351 |
-
?>
|
352 |
-
</div><!-- #post-snippets-tabs -->
|
353 |
-
</div><!-- #post-snippets-dialog -->
|
354 |
-
</div><!-- .hidden -->
|
355 |
-
<?php
|
356 |
-
echo "\n<!-- END: Post Snippets UI Dialog -->\n";
|
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 |
-
* Adds a QuickTag button to the HTML editor
|
385 |
-
*
|
386 |
-
* @see wp-includes/js/quicktags.dev.js
|
387 |
-
* @since Post Snippets 1.7
|
388 |
-
* @deprecated Since 1.8.6
|
389 |
-
*/
|
390 |
-
function add_quicktag_button_pre33() {
|
391 |
-
echo "\n<!-- START: Post Snippets QuickTag button -->\n";
|
392 |
-
?>
|
393 |
-
<script type="text/javascript" charset="utf-8">
|
394 |
-
// <![CDATA[
|
395 |
-
//edButton(id, display, tagStart, tagEnd, access, open)
|
396 |
-
edbuttonlength = edButtons.length;
|
397 |
-
edButtons[edbuttonlength++] = new edButton('ed_postsnippets', 'Post Snippets', '', '', '', -1);
|
398 |
-
(function(){
|
399 |
-
if (typeof jQuery === 'undefined') {
|
400 |
-
return;
|
401 |
-
}
|
402 |
-
jQuery(document).ready(function(){
|
403 |
-
jQuery("#ed_toolbar").append('<input type="button" value="Post Snippets" id="ed_postsnippets" class="ed_button" onclick="edOpenPostSnippets(edCanvas);" title="Post Snippets" />');
|
404 |
-
});
|
405 |
-
}());
|
406 |
-
// ]]>
|
407 |
-
</script>
|
408 |
-
<?php
|
409 |
-
echo "\n<!-- END: Post Snippets QuickTag button -->\n";
|
410 |
}
|
411 |
|
412 |
|
|
|
|
|
|
|
|
|
413 |
/**
|
414 |
* Create the functions for shortcodes dynamically and register them
|
415 |
*/
|
@@ -513,7 +541,7 @@ function edOpenPostSnippets(myField) {
|
|
513 |
if (!empty($snippets)) {
|
514 |
foreach ($snippets as $key => $value) {
|
515 |
$new_snippets[$key]['title'] = trim($_POST[$key.'_title']);
|
516 |
-
$new_snippets[$key]['vars'] = str_replace(
|
517 |
$new_snippets[$key]['shortcode'] = isset($_POST[$key.'_shortcode']) ? true : false;
|
518 |
$new_snippets[$key]['php'] = isset($_POST[$key.'_php']) ? true : false;
|
519 |
|
3 |
Plugin Name: Post Snippets
|
4 |
Plugin URI: http://wpstorm.net/wordpress-plugins/post-snippets/
|
5 |
Description: Stores snippets of HTML code or reoccurring text that you often use in your posts. You can use predefined variables to replace parts of the snippet on insert. All snippets are available in the post editor with a TinyMCE button or Quicktags.
|
6 |
+
Version: 1.9.2
|
7 |
Author: Johan Steen
|
8 |
Author URI: http://johansteen.se/
|
9 |
Text Domain: post-snippets
|
57 |
# Adds the JS and HTML code in the header and footer for the jQuery insert UI dialog in the editor
|
58 |
add_action( 'admin_init', array(&$this,'enqueue_assets') );
|
59 |
add_action( 'admin_head', array(&$this,'jquery_ui_dialog') );
|
60 |
+
add_action( 'admin_footer', array(&$this,'add_jquery_ui_dialog') );
|
61 |
|
62 |
# Add Editor QuickTag button
|
63 |
// IF WordPress is 3.3 or higher, use the new refactored method to add
|
99 |
wp_enqueue_style( 'wp-jquery-ui-dialog');
|
100 |
|
101 |
# Adds the CSS stylesheet for the jQuery UI dialog
|
|
|
102 |
$style_url = plugins_url( '/assets/post-snippets.css', $this->get_FILE() );
|
103 |
+
wp_register_style( 'post-snippets', $style_url, false, '1.0' );
|
104 |
wp_enqueue_style( 'post-snippets');
|
105 |
}
|
106 |
|
169 |
{
|
170 |
// Load the TinyMCE plugin, editor_plugin.js, into the array
|
171 |
$plugins[$this->tinymce_plugin_name] =
|
172 |
+
plugins_url('/tinymce/editor_plugin.js?ver=1.9', $this->get_FILE());
|
173 |
|
174 |
return $plugins;
|
175 |
}
|
176 |
|
177 |
+
/**
|
178 |
+
* Adds a QuickTag button to the HTML editor.
|
179 |
+
*
|
180 |
+
* Compatible with WordPress 3.3 and newer.
|
181 |
+
*
|
182 |
+
* @see wp-includes/js/quicktags.dev.js -> qt.addButton()
|
183 |
+
* @since Post Snippets 1.8.6
|
184 |
+
*/
|
185 |
+
public function add_quicktag_button() {
|
186 |
+
echo "\n<!-- START: Add QuickTag button for Post Snippets -->\n";
|
187 |
+
?>
|
188 |
+
<script type="text/javascript" charset="utf-8">
|
189 |
+
QTags.addButton( 'post_snippets_id', 'Post Snippets', qt_post_snippets );
|
190 |
+
function qt_post_snippets() {
|
191 |
+
post_snippets_caller = 'html';
|
192 |
+
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
193 |
+
}
|
194 |
+
</script>
|
195 |
+
<?php
|
196 |
+
echo "\n<!-- END: Add QuickTag button for Post Snippets -->\n";
|
197 |
+
}
|
198 |
+
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Adds a QuickTag button to the HTML editor.
|
202 |
+
*
|
203 |
+
* Used when running on WordPress lower than version 3.3.
|
204 |
+
*
|
205 |
+
* @see wp-includes/js/quicktags.dev.js
|
206 |
+
* @since Post Snippets 1.7
|
207 |
+
* @deprecated Since 1.8.6
|
208 |
+
*/
|
209 |
+
function add_quicktag_button_pre33() {
|
210 |
+
echo "\n<!-- START: Post Snippets QuickTag button -->\n";
|
211 |
+
?>
|
212 |
+
<script type="text/javascript" charset="utf-8">
|
213 |
+
// <![CDATA[
|
214 |
+
//edButton(id, display, tagStart, tagEnd, access, open)
|
215 |
+
edbuttonlength = edButtons.length;
|
216 |
+
edButtons[edbuttonlength++] = new edButton('ed_postsnippets', 'Post Snippets', '', '', '', -1);
|
217 |
+
(function(){
|
218 |
+
if (typeof jQuery === 'undefined') {
|
219 |
+
return;
|
220 |
+
}
|
221 |
+
jQuery(document).ready(function(){
|
222 |
+
jQuery("#ed_toolbar").append('<input type="button" value="Post Snippets" id="ed_postsnippets" class="ed_button" onclick="edOpenPostSnippets(edCanvas);" title="Post Snippets" />');
|
223 |
+
});
|
224 |
+
}());
|
225 |
+
// ]]>
|
226 |
+
</script>
|
227 |
+
<?php
|
228 |
+
echo "\n<!-- END: Post Snippets QuickTag button -->\n";
|
229 |
+
}
|
230 |
|
|
|
231 |
|
232 |
+
// -------------------------------------------------------------------------
|
233 |
+
// JavaScript / jQuery handling for the post editor
|
234 |
+
// -------------------------------------------------------------------------
|
235 |
|
236 |
/**
|
237 |
* jQuery control for the dialog and Javascript needed to insert snippets into the editor
|
325 |
}
|
326 |
?>
|
327 |
|
328 |
+
// Decide what method to use to insert the snippet depending
|
329 |
+
// from what editor the window was opened from
|
330 |
+
if (post_snippets_caller == 'html') {
|
331 |
+
// HTML editor in WordPress 3.3 and greater
|
332 |
+
QTags.insertContent(insert_snippet);
|
333 |
+
} else if (post_snippets_caller == 'html_pre33') {
|
334 |
+
// HTML editor in WordPress below 3.3.
|
335 |
+
edInsertContent(post_snippets_canvas, insert_snippet);
|
336 |
} else {
|
337 |
+
// Visual Editor
|
338 |
+
post_snippets_canvas.execCommand('mceInsertContent', false, insert_snippet);
|
339 |
}
|
340 |
|
341 |
}
|
345 |
});
|
346 |
});
|
347 |
|
348 |
+
// Global variables to keep track on the canvas instance and from what editor
|
349 |
+
// that opened the Post Snippets popup.
|
350 |
+
var post_snippets_canvas;
|
351 |
+
var post_snippets_caller = '';
|
352 |
|
353 |
+
/**
|
354 |
+
* Used in WordPress lower than version 3.3.
|
355 |
+
* Not used anymore starting with WordPress version 3.3.
|
356 |
+
* Called from: add_quicktag_button_pre33()
|
357 |
+
*/
|
358 |
function edOpenPostSnippets(myField) {
|
359 |
+
post_snippets_canvas = myField;
|
360 |
+
post_snippets_caller = 'html_pre33';
|
361 |
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
362 |
};
|
363 |
<?php
|
365 |
echo "\n<!-- END: Post Snippets jQuery UI and related functions -->\n";
|
366 |
}
|
367 |
|
|
|
368 |
/**
|
369 |
+
* Build jQuery UI Window.
|
370 |
+
*
|
371 |
+
* Creates the jQuery for Post Editor popup window, its snippet tabs and the
|
372 |
+
* form fields to enter variables.
|
373 |
*
|
374 |
* @since Post Snippets 1.7
|
375 |
*/
|
376 |
+
public function add_jquery_ui_dialog()
|
377 |
+
{
|
378 |
echo "\n<!-- START: Post Snippets UI Dialog -->\n";
|
379 |
+
// Setup the dialog divs
|
380 |
+
echo "<div class=\"hidden\">\n";
|
381 |
+
echo "\t<div id=\"post-snippets-dialog\" title=\"Post Snippets\">\n";
|
382 |
+
// Init the tabs div
|
383 |
+
echo "\t\t<div id=\"post-snippets-tabs\">\n";
|
384 |
+
echo "\t\t\t<ul>\n";
|
385 |
+
|
386 |
+
// Create a tab for each available snippet
|
387 |
+
$snippets = get_option($this->plugin_options);
|
388 |
+
foreach ($snippets as $key => $snippet) {
|
389 |
+
echo "\t\t\t\t";
|
390 |
+
echo "<li><a href=\"#ps-tabs-{$key}\">{$snippet['title']}</a></li>";
|
391 |
+
echo "\n";
|
392 |
+
}
|
393 |
+
echo "\t\t\t</ul>\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
|
395 |
+
// Create a panel with form fields for each available snippet
|
396 |
+
foreach ($snippets as $key => $snippet) {
|
397 |
+
echo "\t\t\t<div id=\"ps-tabs-{$key}\">\n";
|
398 |
+
|
399 |
+
// Print a snippet description is available
|
400 |
+
if ( isset($snippet['description']) )
|
401 |
+
echo "\t\t\t\t<p class=\"howto\">" . $snippet['description'] . "</p>\n";
|
402 |
+
|
403 |
+
// Get all variables defined for the snippet and output them as
|
404 |
+
// input fields
|
405 |
+
$var_arr = explode(',', $snippet['vars']);
|
406 |
+
if (!empty($var_arr[0])) {
|
407 |
+
foreach ($var_arr as $key_2 => $var) {
|
408 |
+
// Default value exists?
|
409 |
+
if (strpos($var, '=') !== false) {
|
410 |
+
$result = explode('=', $var);
|
411 |
+
$var = $result[0];
|
412 |
+
$def = $result[1];
|
413 |
+
} else {
|
414 |
+
$def = '';
|
415 |
+
}
|
416 |
+
echo "\t\t\t\t<label for=\"var_{$key}_{$key_2}\">{$var}:</label>\n";
|
417 |
+
echo "\t\t\t\t<input type=\"text\" id=\"var_{$key}_{$key_2}\" name=\"var_{$key}_{$key_2}\" value=\"{$def}\" style=\"width: 190px\" />\n";
|
418 |
+
echo "\t\t\t\t<br/>\n";
|
419 |
+
}
|
420 |
+
} else {
|
421 |
+
// If no variables and no description available, output a text
|
422 |
+
// to inform the user that it's an insert snippet only.
|
423 |
+
if ( empty($snippet['description']) )
|
424 |
+
echo "\t\t\t\t<p class=\"howto\">" . __('This snippet is insert only, no variables defined.', 'post-snippets') . "</p>\n";
|
425 |
}
|
426 |
+
echo "\t\t\t</div><!-- #ps-tabs-{$key} -->\n";
|
427 |
+
}
|
428 |
+
// Close the tabs and dialog divs
|
429 |
+
echo "\t\t</div><!-- #post-snippets-tabs -->\n";
|
430 |
+
echo "\t</div><!-- #post-snippets-dialog -->\n";
|
431 |
+
echo "</div><!-- .hidden -->\n";
|
432 |
|
433 |
+
echo "<!-- END: Post Snippets UI Dialog -->\n\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
}
|
435 |
|
436 |
|
437 |
+
// -------------------------------------------------------------------------
|
438 |
+
// XXXXXX
|
439 |
+
// -------------------------------------------------------------------------
|
440 |
+
|
441 |
/**
|
442 |
* Create the functions for shortcodes dynamically and register them
|
443 |
*/
|
541 |
if (!empty($snippets)) {
|
542 |
foreach ($snippets as $key => $value) {
|
543 |
$new_snippets[$key]['title'] = trim($_POST[$key.'_title']);
|
544 |
+
$new_snippets[$key]['vars'] = str_replace(' ', '', trim($_POST[$key.'_vars']) );
|
545 |
$new_snippets[$key]['shortcode'] = isset($_POST[$key.'_shortcode']) ? true : false;
|
546 |
$new_snippets[$key]['php'] = isset($_POST[$key.'_php']) ? true : false;
|
547 |
|
readme.txt
CHANGED
@@ -4,19 +4,19 @@ Donate link: http://wpstorm.net/wordpress-plugins/post-snippets/#donation
|
|
4 |
Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
-
Stable tag: 1.9.
|
8 |
|
9 |
Keep a snippet library of text, HTML or PHP code to be used in posts. Variables
|
10 |
can be set for more flexibility. Inserts directly or as shortcodes.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
This
|
15 |
-
often use in your posts. You can use
|
16 |
-
the snippet on insert. All snippets are
|
17 |
-
|
18 |
-
|
19 |
-
snippets inserted as shortcodes.
|
20 |
|
21 |
= Features =
|
22 |
|
@@ -91,9 +91,15 @@ for questions, answers, support and feature requests.
|
|
91 |
|
92 |
== Changelog ==
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
= Version 1.9.1 - 22 Jan 2012 =
|
95 |
-
* Updated the built
|
96 |
-
is up to date.
|
97 |
|
98 |
= Version 1.9 - 17 Jan 2012 =
|
99 |
* Initial implementation to allow snippets to be evaluated as PHP code.
|
4 |
Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
+
Stable tag: 1.9.2
|
8 |
|
9 |
Keep a snippet library of text, HTML or PHP code to be used in posts. Variables
|
10 |
can be set for more flexibility. Inserts directly or as shortcodes.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
This plugin lets you build a library with snippets of HTML, PHP code or
|
15 |
+
reoccurring text that you often use in your posts and pages. You can use
|
16 |
+
predefined variables to replace parts of the snippet on insert. All snippets are
|
17 |
+
available in the post editor via a button in the Visual and HTML modes. The
|
18 |
+
snippet can be inserted as defined, or as a shortcode to keep flexibility for
|
19 |
+
updating the snippet. PHP code is supported for snippets inserted as shortcodes.
|
20 |
|
21 |
= Features =
|
22 |
|
91 |
|
92 |
== Changelog ==
|
93 |
|
94 |
+
= Version 1.9.2 - 30 Jan 2012 =
|
95 |
+
* A variable can now be assigned a default value that will be used in the
|
96 |
+
insert window. Use the = sign to give a variable a default value. Ie.
|
97 |
+
var1,var2=default,var3.
|
98 |
+
* Added versioning to the admin jQuery dialog CSS and the TinyMCE plugin
|
99 |
+
JavaScript to prevent browser caching of older versions on update.
|
100 |
+
|
101 |
= Version 1.9.1 - 22 Jan 2012 =
|
102 |
+
* Updated the built-in help text to include all the latest features added.
|
|
|
103 |
|
104 |
= Version 1.9 - 17 Jan 2012 =
|
105 |
* Initial implementation to allow snippets to be evaluated as PHP code.
|
tests/post-snippets-test.php
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
/**
|
3 |
* Post Snippets PHPUnit Tests.
|
4 |
*
|
1 |
<?php
|
2 |
+
// Hack to set the theme to test. As WP needs to reload once after a new theme
|
3 |
+
// is set, I can't switch in the setUp, and then switch back to the old theme
|
4 |
+
// in teardown, so instead I do it like this.
|
5 |
+
// Another option would be to load the functions.php directly, but that might
|
6 |
+
// collide with the alread loaded functions.php from the set theme.
|
7 |
+
switch_theme( 'twentyeleven', 'twentyeleven' );
|
8 |
+
|
9 |
/**
|
10 |
* Post Snippets PHPUnit Tests.
|
11 |
*
|
tinymce/editor_plugin.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
// Docu : http://
|
2 |
|
3 |
(function() {
|
4 |
// Load plugin specific language pack
|
@@ -14,26 +14,18 @@
|
|
14 |
* @param {string} url Absolute URL to where the plugin is located.
|
15 |
*/
|
16 |
init : function(ed, url) {
|
17 |
-
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
22 |
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
23 |
-
|
24 |
-
file : url + '/window.php',
|
25 |
-
width : 360 + ed.getLang('post_snippets.delta_width', 0),
|
26 |
-
height : 210 + ed.getLang('post_snippets.delta_height', 0),
|
27 |
-
inline : 1
|
28 |
-
}, {
|
29 |
-
plugin_url : url // Plugin absolute URL
|
30 |
-
});
|
31 |
-
*/ });
|
32 |
|
33 |
// Register example button
|
34 |
ed.addButton('post_snippets', {
|
35 |
title : 'post_snippets.desc',
|
36 |
-
cmd : '
|
37 |
image : url + '/post-snippets.gif'
|
38 |
});
|
39 |
},
|
@@ -46,11 +38,11 @@
|
|
46 |
*/
|
47 |
getInfo : function() {
|
48 |
return {
|
49 |
-
longname : '
|
50 |
author : 'Johan Steen',
|
51 |
authorurl : 'http://johansteen.se/',
|
52 |
infourl : 'http://wpstorm.net/wordpress-plugins/post-snippets/',
|
53 |
-
version :
|
54 |
};
|
55 |
}
|
56 |
});
|
1 |
+
// Docu : http://www.tinymce.com/wiki.php/API3:tinymce.api.3.x
|
2 |
|
3 |
(function() {
|
4 |
// Load plugin specific language pack
|
14 |
* @param {string} url Absolute URL to where the plugin is located.
|
15 |
*/
|
16 |
init : function(ed, url) {
|
|
|
17 |
|
18 |
+
// Register the command so that it can be invoked from the button
|
19 |
+
ed.addCommand('mce_post_snippets', function() {
|
20 |
+
post_snippets_canvas = ed;
|
21 |
+
post_snippets_caller = 'visual';
|
22 |
jQuery( "#post-snippets-dialog" ).dialog( "open" );
|
23 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
// Register example button
|
26 |
ed.addButton('post_snippets', {
|
27 |
title : 'post_snippets.desc',
|
28 |
+
cmd : 'mce_post_snippets',
|
29 |
image : url + '/post-snippets.gif'
|
30 |
});
|
31 |
},
|
38 |
*/
|
39 |
getInfo : function() {
|
40 |
return {
|
41 |
+
longname : 'Post Snippets',
|
42 |
author : 'Johan Steen',
|
43 |
authorurl : 'http://johansteen.se/',
|
44 |
infourl : 'http://wpstorm.net/wordpress-plugins/post-snippets/',
|
45 |
+
version : '1.9'
|
46 |
};
|
47 |
}
|
48 |
});
|