Version Description
Download this release
Release Info
Developer | artstorm |
Plugin | Post Snippets |
Version | 1.8.9.1 |
Comparing to | |
See all releases |
Code changes from version 1.8.9 to 1.8.9.1
- post-snippets.php +37 -21
- readme.txt +18 -8
- tests/phpunit.xml +1 -1
- tests/post-snippets-test.php +16 -3
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.8.9
|
7 |
Author: Johan Steen
|
8 |
Author URI: http://johansteen.se/
|
9 |
Text Domain: post-snippets
|
@@ -681,7 +681,8 @@ function edOpenPostSnippets(myField) {
|
|
681 |
* @since Post Snippets 1.9
|
682 |
* @return The __FILE__ constant without resolved symlinks.
|
683 |
*/
|
684 |
-
private function get_FILE()
|
|
|
685 |
$dev_path = 'E:\Code\WordPress';
|
686 |
$result = strpos( __FILE__, $dev_path );
|
687 |
|
@@ -691,6 +692,37 @@ function edOpenPostSnippets(myField) {
|
|
691 |
return str_replace($dev_path, WP_PLUGIN_DIR, __FILE__);
|
692 |
}
|
693 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
694 |
}
|
695 |
|
696 |
|
@@ -698,7 +730,6 @@ function edOpenPostSnippets(myField) {
|
|
698 |
// Start the plugin
|
699 |
// -----------------------------------------------------------------------------
|
700 |
|
701 |
-
|
702 |
// Check the host environment
|
703 |
$test_post_snippets_host = new Post_Snippets_Host_Environment();
|
704 |
|
@@ -793,13 +824,13 @@ class Post_Snippets_Host_Environment
|
|
793 |
}
|
794 |
}
|
795 |
|
796 |
-
|
797 |
// -----------------------------------------------------------------------------
|
798 |
// Helper functions
|
799 |
// -----------------------------------------------------------------------------
|
800 |
|
801 |
/**
|
802 |
-
* Allow snippets to be retrieved directly from PHP
|
|
|
803 |
*
|
804 |
* @since Post Snippets 1.6
|
805 |
*
|
@@ -812,20 +843,5 @@ class Post_Snippets_Host_Environment
|
|
812 |
*/
|
813 |
function get_post_snippet( $snippet_name, $snippet_vars = '' ) {
|
814 |
global $post_snippets;
|
815 |
-
$
|
816 |
-
for ($i = 0; $i < count($snippets); $i++) {
|
817 |
-
if ($snippets[$i]['title'] == $snippet_name) {
|
818 |
-
parse_str( htmlspecialchars_decode($snippet_vars), $snippet_output );
|
819 |
-
$snippet = $snippets[$i]['snippet'];
|
820 |
-
$var_arr = explode(",",$snippets[$i]['vars']);
|
821 |
-
|
822 |
-
if ( !empty($var_arr[0]) ) {
|
823 |
-
for ($j = 0; $j < count($var_arr); $j++) {
|
824 |
-
$snippet = str_replace("{".$var_arr[$j]."}", $snippet_output[$var_arr[$j]], $snippet);
|
825 |
-
}
|
826 |
-
}
|
827 |
-
}
|
828 |
-
}
|
829 |
-
return $snippet;
|
830 |
}
|
831 |
-
|
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.8.9.1
|
7 |
Author: Johan Steen
|
8 |
Author URI: http://johansteen.se/
|
9 |
Text Domain: post-snippets
|
681 |
* @since Post Snippets 1.9
|
682 |
* @return The __FILE__ constant without resolved symlinks.
|
683 |
*/
|
684 |
+
private function get_FILE()
|
685 |
+
{
|
686 |
$dev_path = 'E:\Code\WordPress';
|
687 |
$result = strpos( __FILE__, $dev_path );
|
688 |
|
692 |
return str_replace($dev_path, WP_PLUGIN_DIR, __FILE__);
|
693 |
}
|
694 |
}
|
695 |
+
|
696 |
+
/**
|
697 |
+
* Allow snippets to be retrieved directly from PHP.
|
698 |
+
*
|
699 |
+
* @since Post Snippets 1.8.9.1
|
700 |
+
*
|
701 |
+
* @param string $snippet_name
|
702 |
+
* The name of the snippet to retrieve
|
703 |
+
* @param string $snippet_vars
|
704 |
+
* The variables to pass to the snippet, formatted as a query string.
|
705 |
+
* @return string
|
706 |
+
* The Snippet
|
707 |
+
*/
|
708 |
+
public function get_snippet( $snippet_name, $snippet_vars = '' )
|
709 |
+
{
|
710 |
+
$snippets = get_option($this->plugin_options);
|
711 |
+
for ($i = 0; $i < count($snippets); $i++) {
|
712 |
+
if ($snippets[$i]['title'] == $snippet_name) {
|
713 |
+
parse_str( htmlspecialchars_decode($snippet_vars), $snippet_output );
|
714 |
+
$snippet = $snippets[$i]['snippet'];
|
715 |
+
$var_arr = explode(",",$snippets[$i]['vars']);
|
716 |
+
|
717 |
+
if ( !empty($var_arr[0]) ) {
|
718 |
+
for ($j = 0; $j < count($var_arr); $j++) {
|
719 |
+
$snippet = str_replace("{".$var_arr[$j]."}", $snippet_output[$var_arr[$j]], $snippet);
|
720 |
+
}
|
721 |
+
}
|
722 |
+
}
|
723 |
+
}
|
724 |
+
return $snippet;
|
725 |
+
}
|
726 |
}
|
727 |
|
728 |
|
730 |
// Start the plugin
|
731 |
// -----------------------------------------------------------------------------
|
732 |
|
|
|
733 |
// Check the host environment
|
734 |
$test_post_snippets_host = new Post_Snippets_Host_Environment();
|
735 |
|
824 |
}
|
825 |
}
|
826 |
|
|
|
827 |
// -----------------------------------------------------------------------------
|
828 |
// Helper functions
|
829 |
// -----------------------------------------------------------------------------
|
830 |
|
831 |
/**
|
832 |
+
* Allow snippets to be retrieved directly from PHP.
|
833 |
+
* This function is a wrapper for Post_Snippets::get_snippet().
|
834 |
*
|
835 |
* @since Post Snippets 1.6
|
836 |
*
|
843 |
*/
|
844 |
function get_post_snippet( $snippet_name, $snippet_vars = '' ) {
|
845 |
global $post_snippets;
|
846 |
+
return $post_snippets->get_snippet( $snippet_name, $snippet_vars );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
847 |
}
|
|
readme.txt
CHANGED
@@ -4,10 +4,10 @@ Donate link: http://wpstorm.net/wordpress-plugins/post-snippets/#donation
|
|
4 |
Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
-
Stable tag: 1.8.9
|
8 |
|
9 |
-
|
10 |
-
|
11 |
|
12 |
== Description ==
|
13 |
|
@@ -15,13 +15,18 @@ This admin plugin stores snippets of HTML code or reoccurring text that you ofte
|
|
15 |
|
16 |
= Features =
|
17 |
|
18 |
-
* **Insert** All defined snippets is inserted from a button directly in the post
|
|
|
19 |
* **Shortcodes** You can use this plugin to create your own shortcodes.
|
20 |
-
* **Buttons** The snippets are available in the viusal editor with a TinyMCE
|
21 |
-
|
22 |
-
* **
|
|
|
|
|
|
|
23 |
* **Import/Export** Snippets can be imported and exported between sites.
|
24 |
-
* **Uninstall** If you delete the plugin from your plugins panel it cleans up
|
|
|
25 |
|
26 |
= Related Links =
|
27 |
|
@@ -80,6 +85,11 @@ for questions, answers, support and feature requests.
|
|
80 |
|
81 |
== Changelog ==
|
82 |
|
|
|
|
|
|
|
|
|
|
|
83 |
= Version 1.8.9 - 10 Jan 2012 =
|
84 |
* Updated the help text to take advantage of the new Help API introduced with
|
85 |
WordPress 3.3.
|
4 |
Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3.1
|
7 |
+
Stable tag: 1.8.9.1
|
8 |
|
9 |
+
Keep a library of snippets of text, HTML or PHP code to be used in posts.
|
10 |
+
Variables can be set for flexibility. Insert directly or as a shortcode.
|
11 |
|
12 |
== Description ==
|
13 |
|
15 |
|
16 |
= Features =
|
17 |
|
18 |
+
* **Insert** All defined snippets is inserted from a button directly in the post
|
19 |
+
editor.
|
20 |
* **Shortcodes** You can use this plugin to create your own shortcodes.
|
21 |
+
* **Buttons** The snippets are available in the viusal editor with a TinyMCE
|
22 |
+
button and in the HTML editor with a quicktag button.
|
23 |
+
* **Admin** Easy to use administration panel where you can add, edit and remove
|
24 |
+
snippets.
|
25 |
+
* **Variables** Each snippet can have as many custom variables as you like,
|
26 |
+
which can be used on insert.
|
27 |
* **Import/Export** Snippets can be imported and exported between sites.
|
28 |
+
* **Uninstall** If you delete the plugin from your plugins panel it cleans up
|
29 |
+
all data it has created in the Wordpress database.
|
30 |
|
31 |
= Related Links =
|
32 |
|
85 |
|
86 |
== Changelog ==
|
87 |
|
88 |
+
= Version 1.8.9.1 - 11 Jan 2012 =
|
89 |
+
* A bug fixed with get_post_snippets() that were introduced in the last update.
|
90 |
+
* Unit test for get_post_snippets() added to automate testing that it won't
|
91 |
+
break in future updates.
|
92 |
+
|
93 |
= Version 1.8.9 - 10 Jan 2012 =
|
94 |
* Updated the help text to take advantage of the new Help API introduced with
|
95 |
WordPress 3.3.
|
tests/phpunit.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<phpunit
|
3 |
colors="true"
|
4 |
stopOnFailure="false"
|
5 |
-
bootstrap="
|
6 |
<testsuites>
|
7 |
<testsuite name="PostSnippets">
|
8 |
<file>post-snippets-test.php</file>
|
2 |
<phpunit
|
3 |
colors="true"
|
4 |
stopOnFailure="false"
|
5 |
+
bootstrap="E:/Code/_Tools/UniformServer/www/wordpress.dev/wordpress-tests/init.php">
|
6 |
<testsuites>
|
7 |
<testsuite name="PostSnippets">
|
8 |
<file>post-snippets-test.php</file>
|
tests/post-snippets-test.php
CHANGED
@@ -12,7 +12,8 @@
|
|
12 |
*/
|
13 |
class Post_Snippets_Test extends WP_UnitTestCase {
|
14 |
|
15 |
-
protected
|
|
|
16 |
|
17 |
/**
|
18 |
* setUp runs before each test to create a Fixture.
|
@@ -22,7 +23,18 @@ class Post_Snippets_Test extends WP_UnitTestCase {
|
|
22 |
*/
|
23 |
public function setUp() {
|
24 |
parent::setUp();
|
25 |
-
$this->post_snippets = new Post_Snippets();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
|
28 |
|
@@ -59,7 +71,8 @@ class Post_Snippets_Test extends WP_UnitTestCase {
|
|
59 |
|
60 |
public function test_get_post_snippet()
|
61 |
{
|
62 |
-
$test = get_post_snippet('
|
63 |
$this->assertTrue(is_string($test));
|
|
|
64 |
}
|
65 |
}
|
12 |
*/
|
13 |
class Post_Snippets_Test extends WP_UnitTestCase {
|
14 |
|
15 |
+
// protected $post_snippets;
|
16 |
+
public $plugin_slug = 'post-snippets';
|
17 |
|
18 |
/**
|
19 |
* setUp runs before each test to create a Fixture.
|
23 |
*/
|
24 |
public function setUp() {
|
25 |
parent::setUp();
|
26 |
+
// $this->post_snippets = new Post_Snippets();
|
27 |
+
global $post_snippets; $post_snippets = new Post_Snippets();
|
28 |
+
|
29 |
+
$snippets = array();
|
30 |
+
array_push($snippets, array(
|
31 |
+
'title' => "TestTmp",
|
32 |
+
'vars' => "",
|
33 |
+
'description' => "",
|
34 |
+
'shortcode' => false,
|
35 |
+
'php' => false,
|
36 |
+
'snippet' => "A test snippet..."));
|
37 |
+
update_option('post_snippets_options', $snippets);
|
38 |
}
|
39 |
|
40 |
|
71 |
|
72 |
public function test_get_post_snippet()
|
73 |
{
|
74 |
+
$test = get_post_snippet('TestTmp');
|
75 |
$this->assertTrue(is_string($test));
|
76 |
+
$this->assertEquals($test, 'A test snippet...');
|
77 |
}
|
78 |
}
|