Post Snippets - Version 1.4.3

Version Description

Download this release

Release Info

Developer artstorm
Plugin Icon 128x128 Post Snippets
Version 1.4.3
Comparing to
See all releases

Code changes from version 1.4.2 to 1.4.3

Files changed (2) hide show
  1. post-snippets.php +15 -14
  2. readme.txt +6 -2
post-snippets.php CHANGED
@@ -3,7 +3,7 @@
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.4.2
7
  Author: Johan Steen
8
  Author URI: http://coding.cglounge.com/
9
  Text Domain: post-snippets
@@ -93,13 +93,13 @@ class postSnippets {
93
 
94
  $newArr = compact( array_keys($shortcode_symbols) );
95
 
96
- $snippet = "'.$snippets[$i]["snippet"].'";
97
 
98
  foreach ($newArr as $key => $val) {
99
  $snippet = str_replace("{".$key."}", $val, $snippet);
100
  }
101
 
102
- return "{$snippet}";') );
103
  }
104
  }
105
  }
@@ -141,11 +141,11 @@ class postSnippets {
141
  echo "var variables" . $i ." = new Array(".$theVariables.");";
142
  echo "var insertString" . $i ." = createShortcode('".$snippets[$i]['title']."', variables".$i.");";
143
  }else{
144
- echo "var insertString" . $i ." = '" .$theSnippet. "';";
145
  }
146
  echo '
147
  postSnippetsNr = edButtons.length;
148
- edButtons[postSnippetsNr] = new edButton(\'ed_ps'. $i . '\', \'' . $snippets[$i]['title'] . '\', \''.$snippets[$i]['snippet'].'\', \'\', \'\', -1);
149
  var postSnippetsButton = postSnippetsToolbar.lastChild;
150
 
151
  while (postSnippetsButton.nodeType != 1) {
@@ -162,15 +162,16 @@ class postSnippets {
162
  ';
163
  } // End if
164
  } // Next
165
- echo '
 
166
  }
167
  function createShortcode(shortcodeTag, shortcodeAtts) {
168
- theSnippet = \'[\' + shortcodeTag;
169
  for (x in shortcodeAtts)
170
  {
171
- theSnippet += \' \' + shortcodeAtts[x] + \'="{\' + shortcodeAtts[x] + \'}"\';
172
  }
173
- theSnippet += \']\';
174
  return theSnippet;
175
  }
176
 
@@ -181,19 +182,19 @@ class postSnippets {
181
  for (x in theVariables)
182
  {
183
  myValue = prompt(theVariables[x]);
184
- var searchfor = \'{\' + theVariables[x] + \'}\';
185
- var re = new RegExp(searchfor, \'g\');
186
  insertString = insertString.replace(re, myValue);
187
 
188
  }
189
  theSnippet = insertString;
190
  if (theSnippet) {
191
- edInsertContent(myField, theSnippet);
192
  }
193
- }
194
  //-->
195
  </script>
196
- ';
197
  }
198
  break;
199
  }
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.4.3
7
  Author: Johan Steen
8
  Author URI: http://coding.cglounge.com/
9
  Text Domain: post-snippets
93
 
94
  $newArr = compact( array_keys($shortcode_symbols) );
95
 
96
+ $snippet = "'. addslashes($snippets[$i]["snippet"]) .'";
97
 
98
  foreach ($newArr as $key => $val) {
99
  $snippet = str_replace("{".$key."}", $val, $snippet);
100
  }
101
 
102
+ return stripslashes($snippet);') );
103
  }
104
  }
105
  }
141
  echo "var variables" . $i ." = new Array(".$theVariables.");";
142
  echo "var insertString" . $i ." = createShortcode('".$snippets[$i]['title']."', variables".$i.");";
143
  }else{
144
+ echo "var insertString" . $i ." = '" . addslashes(stripslashes($theSnippet)). "';";
145
  }
146
  echo '
147
  postSnippetsNr = edButtons.length;
148
+ edButtons[postSnippetsNr] = new edButton(\'ed_ps'. $i . '\', \'' . $snippets[$i]['title'] . '\', \''.addslashes($snippets[$i]['snippet']).'\', \'\', \'\', -1);
149
  var postSnippetsButton = postSnippetsToolbar.lastChild;
150
 
151
  while (postSnippetsButton.nodeType != 1) {
162
  ';
163
  } // End if
164
  } // Next
165
+ // echo '
166
+ echo <<<JAVASCRIPT
167
  }
168
  function createShortcode(shortcodeTag, shortcodeAtts) {
169
+ theSnippet = '[' + shortcodeTag;
170
  for (x in shortcodeAtts)
171
  {
172
+ theSnippet += ' ' + shortcodeAtts[x] + '="{' + shortcodeAtts[x] + '}"';
173
  }
174
+ theSnippet += ']';
175
  return theSnippet;
176
  }
177
 
182
  for (x in theVariables)
183
  {
184
  myValue = prompt(theVariables[x]);
185
+ var searchfor = '{' + theVariables[x] + '}';
186
+ var re = new RegExp(searchfor, 'g');
187
  insertString = insertString.replace(re, myValue);
188
 
189
  }
190
  theSnippet = insertString;
191
  if (theSnippet) {
192
+ edInsertContent( myField, theSnippet );
193
  }
194
+ }
195
  //-->
196
  </script>
197
+ JAVASCRIPT;
198
  }
199
  break;
200
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://coding.cglounge.com/wordpress-plugins/post-snippets/#pintwar
4
  Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
5
  Requires at least: 2.7
6
  Tested up to: 2.7.1
7
- Stable tag: 1.4.2
8
 
9
  Store snippets of HTML code or reoccurring text that you often use in your posts. Custom variables can be used.
10
 
@@ -47,8 +47,12 @@ Meditation.
47
 
48
  == Changelog ==
49
 
 
 
 
 
50
  = Version 1.4.2 - 11 Apr 2009 =
51
- * Fixed some additional syntax for servers where the short_open_tag configuration setting disabled.
52
 
53
  = Version 1.4.1 - 10 Apr 2009 =
54
  * Removed all short syntax commands and replaced them with the full versions so the plugin also works on servers with the short_open_tag configuration setting disabled.
4
  Tags: post, admin, snippet, html, custom, page, dynamic, editor, quicktag
5
  Requires at least: 2.7
6
  Tested up to: 2.7.1
7
+ Stable tag: 1.4.3
8
 
9
  Store snippets of HTML code or reoccurring text that you often use in your posts. Custom variables can be used.
10
 
47
 
48
  == Changelog ==
49
 
50
+ = Version 1.4.3 - 16 Apr 2009 =
51
+ * Fixed an escaping problem with the recently implemented shortcode function, that could cause problems on certain strings.
52
+ * Fixed an escaping problem with the quicktag javascript, that could cause problems on certain strings.
53
+
54
  = Version 1.4.2 - 11 Apr 2009 =
55
+ * Fixed some additional syntax for servers where the short_open_tag configuration setting is disabled.
56
 
57
  = Version 1.4.1 - 10 Apr 2009 =
58
  * Removed all short syntax commands and replaced them with the full versions so the plugin also works on servers with the short_open_tag configuration setting disabled.