Version Description
Download this release
Release Info
Developer | artstorm |
Plugin | Post Snippets |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.9.1 to 1.5
- post-snippets.php +88 -60
- readme.txt +5 -2
post-snippets.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
Plugin Name: Post Snippets
|
4 |
Plugin URI: http://coding.cglounge.com/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.
|
7 |
Author: Johan Steen
|
8 |
Author URI: http://coding.cglounge.com/
|
9 |
Text Domain: post-snippets
|
10 |
|
11 |
-
Copyright 2009 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
|
@@ -58,7 +58,8 @@ class post_snippets {
|
|
58 |
*/
|
59 |
function init_hooks() {
|
60 |
add_action('admin_menu', array(&$this,'wp_admin'));
|
61 |
-
add_action('
|
|
|
62 |
$this->create_shortcodes();
|
63 |
}
|
64 |
|
@@ -110,63 +111,92 @@ class post_snippets {
|
|
110 |
*
|
111 |
*/
|
112 |
function quicktags() {
|
113 |
-
$
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
';
|
125 |
-
for ($i = 0; $i < count($snippets); $i++) {
|
126 |
-
if ($snippets[$i]['quicktag']) {
|
127 |
-
// Make it js safe
|
128 |
-
$theSnippet = str_replace('"','\"',str_replace(Chr(13), '', str_replace(Chr(10), '', $snippets[$i]['snippet'])));
|
129 |
-
//$theSnippet = str_replace('<', '\x3C', str_replace('>', '\x3E', $theSnippet));
|
130 |
-
$var_arr = explode(",",$snippets[$i]['vars']);
|
131 |
-
$theVariables = "";
|
132 |
-
if (!empty($var_arr[0])) {
|
133 |
-
for ($j = 0; $j < count($var_arr); $j++) {
|
134 |
-
$theVariables = $theVariables . "'" . $var_arr[$j] . "'";
|
135 |
-
if ( $j < (count($var_arr) -1) )
|
136 |
-
$theVariables = $theVariables . ", ";
|
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 |
function createShortcode(shortcodeTag, shortcodeAtts) {
|
171 |
theSnippet = '[' + shortcodeTag;
|
172 |
for (x in shortcodeAtts)
|
@@ -198,12 +228,10 @@ echo <<<JAVASCRIPT
|
|
198 |
//-->
|
199 |
</script>
|
200 |
JAVASCRIPT;
|
201 |
-
}
|
202 |
-
break;
|
203 |
-
}
|
204 |
}
|
205 |
}
|
206 |
|
|
|
207 |
/**
|
208 |
* The Admin Page and all it's functions
|
209 |
*
|
3 |
Plugin Name: Post Snippets
|
4 |
Plugin URI: http://coding.cglounge.com/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.5
|
7 |
Author: Johan Steen
|
8 |
Author URI: http://coding.cglounge.com/
|
9 |
Text Domain: post-snippets
|
10 |
|
11 |
+
Copyright 2009-2010 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
|
58 |
*/
|
59 |
function init_hooks() {
|
60 |
add_action('admin_menu', array(&$this,'wp_admin'));
|
61 |
+
add_action('admin_head', array(&$this,'quicktags'));
|
62 |
+
// add_action('admin_footer', array(&$this,'quicktags'));
|
63 |
$this->create_shortcodes();
|
64 |
}
|
65 |
|
111 |
*
|
112 |
*/
|
113 |
function quicktags() {
|
114 |
+
$snippets = get_option($this->plugin_options);
|
115 |
+
if (!empty($snippets)) { ?>
|
116 |
+
<script type="text/javascript">
|
117 |
+
if(typeof(edButtons)!='undefined') {
|
118 |
+
var postSnippetsNr, postSnippetsButton; <?php
|
119 |
+
for ($i = 0; $i < count($snippets); $i++) {
|
120 |
+
if ($snippets[$i]['quicktag']) {
|
121 |
+
// Make it js safe
|
122 |
+
$theSnippet = str_replace('"','\"',str_replace(Chr(13), '', str_replace(Chr(10), '', $snippets[$i]['snippet'])));
|
123 |
+
//$theSnippet = str_replace('<', '\x3C', str_replace('>', '\x3E', $theSnippet));
|
124 |
+
$var_arr = explode(",",$snippets[$i]['vars']);
|
125 |
+
$theVariables = "";
|
126 |
+
if (!empty($var_arr[0])) {
|
127 |
+
for ($j = 0; $j < count($var_arr); $j++) {
|
128 |
+
$theVariables = $theVariables . "'" . $var_arr[$j] . "'";
|
129 |
+
if ( $j < (count($var_arr) -1) )
|
130 |
+
$theVariables = $theVariables . ", ";
|
131 |
+
}
|
132 |
+
}
|
133 |
|
134 |
+
if ($snippets[$i]['shortcode']) {
|
135 |
+
echo "var variables" . $i ." = new Array(".$theVariables.");";
|
136 |
+
echo "var insertString" . $i ." = createShortcode('".$snippets[$i]['title']."', variables".$i.");";
|
137 |
+
}else{
|
138 |
+
//echo "var insertString" . $i ." = '" . addslashes(stripslashes($theSnippet)). "';";
|
139 |
+
echo "var insertString" . $i ." = '" . str_replace('<', '\x3C', str_replace('>', '\x3E', addslashes(stripslashes($theSnippet)) )). "';";
|
140 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
+
echo '
|
143 |
+
postSnippetsNr = edButtons.length;
|
144 |
+
edButtons[postSnippetsNr] = new edButton(\'ed_psnip'. $i . '\', \'' . $snippets[$i]['title'] . '\', insertString'. $i .', \'\', \'\', -1);
|
145 |
+
|
146 |
+
';
|
147 |
+
/* postSnippetsNr = edButtons.length;
|
148 |
+
edButtons[postSnippetsNr] = new edButton(\'ed_ps'. $i . '\', \'' . $snippets[$i]['title'] . '\', insertString'. $i .', \'\', \'\', -1);
|
149 |
+
var postSnippetsButton = postSnippetsToolbar.lastChild;
|
150 |
+
|
151 |
+
while (postSnippetsButton.nodeType != 1) {
|
152 |
+
postSnippetsButton = postSnippetsButton.previousSibling;
|
153 |
+
}
|
154 |
+
|
155 |
+
postSnippetsButton = postSnippetsButton.cloneNode(true);
|
156 |
+
postSnippetsToolbar.appendChild(postSnippetsButton);
|
157 |
+
postSnippetsButton.value = \'' . $snippets[$i]['title'] . '\';
|
158 |
+
postSnippetsButton.title = postSnippetsNr;
|
159 |
+
var variables' . $i .' = new Array('.$theVariables.');
|
160 |
+
postSnippetsButton.onclick = function () {edInsertSnippet(edCanvas, insertString' . $i .', variables' . $i .', parseInt(this.title));}
|
161 |
+
postSnippetsButton.id = "ed_ps' . $i .'"; */
|
162 |
+
} // end if
|
163 |
+
} //next ?>
|
164 |
+
};
|
165 |
+
window.onload = ps_quicktags;
|
166 |
+
function ps_quicktags() { <?php
|
167 |
+
for ($i = 0; $i < count($snippets); $i++) {
|
168 |
+
if ($snippets[$i]['quicktag']) {
|
169 |
+
// Make it js safe
|
170 |
+
$theSnippet = str_replace('"','\"',str_replace(Chr(13), '', str_replace(Chr(10), '', $snippets[$i]['snippet'])));
|
171 |
+
//$theSnippet = str_replace('<', '\x3C', str_replace('>', '\x3E', $theSnippet));
|
172 |
+
$var_arr = explode(",",$snippets[$i]['vars']);
|
173 |
+
$theVariables = "";
|
174 |
+
if (!empty($var_arr[0])) {
|
175 |
+
for ($j = 0; $j < count($var_arr); $j++) {
|
176 |
+
$theVariables = $theVariables . "'" . $var_arr[$j] . "'";
|
177 |
+
if ( $j < (count($var_arr) -1) )
|
178 |
+
$theVariables = $theVariables . ", ";
|
179 |
+
}
|
180 |
}
|
181 |
+
if ($snippets[$i]['shortcode']) {
|
182 |
+
echo "var variables" . $i ." = new Array(".$theVariables.");";
|
183 |
+
echo "var insertString" . $i ." = createShortcode('".$snippets[$i]['title']."', variables".$i.");";
|
184 |
+
}else{
|
185 |
+
//echo "var insertString" . $i ." = '" . addslashes(stripslashes($theSnippet)). "';";
|
186 |
+
echo "var insertString" . $i ." = '" . str_replace('<', '\x3C', str_replace('>', '\x3E', addslashes(stripslashes($theSnippet)) )). "';";
|
187 |
+
}
|
188 |
+
?>
|
189 |
+
var postSnippetsButton = document.getElementById('ed_psnip<?php echo $i; ?>');
|
190 |
+
var variables<?php echo $i; ?> = new Array(<?php echo $theVariables; ?>);
|
191 |
+
postSnippetsButton.onclick = function () {edInsertSnippet(edCanvas, insertString<?php echo $i; ?>, variables<?php echo $i; ?>, parseInt(this.title));}
|
192 |
+
<?php
|
193 |
+
} // end if
|
194 |
+
} // next ?>
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
<?php
|
199 |
+
echo <<<JAVASCRIPT
|
200 |
function createShortcode(shortcodeTag, shortcodeAtts) {
|
201 |
theSnippet = '[' + shortcodeTag;
|
202 |
for (x in shortcodeAtts)
|
228 |
//-->
|
229 |
</script>
|
230 |
JAVASCRIPT;
|
|
|
|
|
|
|
231 |
}
|
232 |
}
|
233 |
|
234 |
+
|
235 |
/**
|
236 |
* The Admin Page and all it's functions
|
237 |
*
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: artstorm
|
|
3 |
Donate link: http://coding.cglounge.com/wordpress-plugins/post-snippets/#pintware
|
4 |
Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
|
5 |
Requires at least: 2.7
|
6 |
-
Tested up to: 2.
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Store snippets of HTML code or reoccurring text that you often use in your posts. Custom variables can be used.
|
10 |
|
@@ -52,6 +52,9 @@ Please visit [Post Snippets' Comments](http://coding.cglounge.com/wordpress-plug
|
|
52 |
|
53 |
== Changelog ==
|
54 |
|
|
|
|
|
|
|
55 |
= Version 1.4.9.1 - 5 Sep 2009 =
|
56 |
* Included French translation by [Thomas Cailhe (Oyabi)](http://www.oyabi.fr/).
|
57 |
|
3 |
Donate link: http://coding.cglounge.com/wordpress-plugins/post-snippets/#pintware
|
4 |
Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
|
5 |
Requires at least: 2.7
|
6 |
+
Tested up to: 2.9.1
|
7 |
+
Stable tag: 1.5
|
8 |
|
9 |
Store snippets of HTML code or reoccurring text that you often use in your posts. Custom variables can be used.
|
10 |
|
52 |
|
53 |
== Changelog ==
|
54 |
|
55 |
+
= Version 1.5 - 12 Jan 2010 =
|
56 |
+
* Updated the plugin so it works with WordPress 2.9.x (the quicktags didn't work in 2.9, now fixed.).
|
57 |
+
|
58 |
= Version 1.4.9.1 - 5 Sep 2009 =
|
59 |
* Included French translation by [Thomas Cailhe (Oyabi)](http://www.oyabi.fr/).
|
60 |
|