Post Snippets - Version 2.5.1

Version Description

Download this release

Release Info

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

Code changes from version 2.5 to 2.5.1

assets/post-snippets.js CHANGED
@@ -40,9 +40,11 @@ jQuery(document).ready(function($)
40
  var title = $("input[name$='"+index+"_title']").val();
41
 
42
  $(element).removeClass('post-snippets-invalid');
 
43
 
44
  if ($('#'+index+'_shortcode').prop('checked') && !isTitleValid(title)) {
45
  $(element).addClass('post-snippets-invalid');
 
46
  }
47
  }
48
 
40
  var title = $("input[name$='"+index+"_title']").val();
41
 
42
  $(element).removeClass('post-snippets-invalid');
43
+ $(element).next().remove('p');
44
 
45
  if ($('#'+index+'_shortcode').prop('checked') && !isTitleValid(title)) {
46
  $(element).addClass('post-snippets-invalid');
47
+ $(element).after("<p><em><font color='red'>"+post_snippets.invalid_shortcode+"</font></em></p>");
48
  }
49
  }
50
 
lang/post-snippets.pot CHANGED
@@ -8,7 +8,7 @@ msgid ""
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2015-07-15 09:31+0000\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -23,12 +23,12 @@ msgid "Title"
23
  msgstr ""
24
 
25
  #: views/admin_snippets.php:9 views/admin_snippets.php:18
26
- #: views/help/usage.php:10 src/PostSnippets/Admin.php:378
27
  msgid "Variables"
28
  msgstr ""
29
 
30
  #: views/admin_snippets.php:10 views/admin_snippets.php:19
31
- #: views/help/usage.php:21 src/PostSnippets/Admin.php:397
32
  msgid "Snippet"
33
  msgstr ""
34
 
@@ -56,7 +56,7 @@ msgstr ""
56
  msgid "Delete Selected"
57
  msgstr ""
58
 
59
- #: views/jquery-ui-dialog.php:64
60
  msgid "This snippet is insert only, no variables defined."
61
  msgstr ""
62
 
@@ -194,76 +194,6 @@ msgstr ""
194
  msgid "Donate"
195
  msgstr ""
196
 
197
- #: views/help/translators.php:1 src/PostSnippets/Help.php:87
198
- msgid "Translators"
199
- msgstr ""
200
-
201
- #: views/help/translators.php:3
202
- msgid ""
203
- "Other than the default English language, Post Snippets has been translated "
204
- "to the following languages by these great people:"
205
- msgstr ""
206
-
207
- #: views/help/translators.php:19
208
- msgid "by"
209
- msgstr ""
210
-
211
- #: views/help/translators.php:22
212
- msgid "Belarusian"
213
- msgstr ""
214
-
215
- #: views/help/translators.php:23
216
- msgid "French"
217
- msgstr ""
218
-
219
- #: views/help/translators.php:24
220
- msgid "German"
221
- msgstr ""
222
-
223
- #: views/help/translators.php:25
224
- msgid "Hebrew"
225
- msgstr ""
226
-
227
- #: views/help/translators.php:26
228
- msgid "Lithuanian"
229
- msgstr ""
230
-
231
- #: views/help/translators.php:27
232
- msgid "Polish"
233
- msgstr ""
234
-
235
- #: views/help/translators.php:28
236
- msgid "Romanian"
237
- msgstr ""
238
-
239
- #: views/help/translators.php:29
240
- msgid "Russian"
241
- msgstr ""
242
-
243
- #: views/help/translators.php:30
244
- msgid "Slovak"
245
- msgstr ""
246
-
247
- #: views/help/translators.php:31
248
- msgid "Serbo-Croatian"
249
- msgstr ""
250
-
251
- #: views/help/translators.php:32
252
- msgid "Spanish"
253
- msgstr ""
254
-
255
- #: views/help/translators.php:33
256
- msgid "Swedish"
257
- msgstr ""
258
-
259
- #: views/help/translators.php:34
260
- msgid "Turkish"
261
- msgstr ""
262
-
263
- #: views/help/translators.php:35
264
- msgid "Ukrainian"
265
- msgstr ""
266
-
267
  #: views/help/usage.php:6
268
  msgid ""
269
  "Give the snippet a title that helps you identify it in the post editor. This "
@@ -340,51 +270,59 @@ msgid ""
340
  "trademark symbol, and the multiplication symbol."
341
  msgstr ""
342
 
343
- #: src/PostSnippets/Admin.php:40
 
 
 
 
344
  msgid "Settings"
345
  msgstr ""
346
 
347
- #: src/PostSnippets/Admin.php:128
348
  msgid "A snippet named Untitled has been added."
349
  msgstr ""
350
 
351
- #: src/PostSnippets/Admin.php:148
352
  msgid "Nothing selected to delete."
353
  msgstr ""
354
 
355
- #: src/PostSnippets/Admin.php:164
356
  msgid "Selected snippets have been deleted."
357
  msgstr ""
358
 
359
- #: src/PostSnippets/Admin.php:199
360
  msgid "Snippets have been updated."
361
  msgstr ""
362
 
363
- #: src/PostSnippets/Admin.php:279
364
  msgid "Manage Snippets"
365
  msgstr ""
366
 
367
- #: src/PostSnippets/Admin.php:279 src/PostSnippets/Admin.php:322
 
 
 
 
368
  msgid "Import/Export"
369
  msgstr ""
370
 
371
- #: src/PostSnippets/Admin.php:287
372
  msgid "Use the help dropdown button for additional information."
373
  msgstr ""
374
 
375
- #: src/PostSnippets/Admin.php:323
376
  msgid "Export"
377
  msgstr ""
378
 
379
- #: src/PostSnippets/Admin.php:326
380
  msgid "Export your snippets for backup or to import them on another site."
381
  msgstr ""
382
 
383
- #: src/PostSnippets/Admin.php:328
384
  msgid "Export Snippets"
385
  msgstr ""
386
 
387
- #: src/PostSnippets/Admin.php:351
388
  msgid ""
389
  "This is an overview of all snippets defined for this site. These snippets "
390
  "are inserted into posts from the post editor using the Post Snippets button. "
@@ -395,16 +333,26 @@ msgid ""
395
  "recommended to keep this option disabled."
396
  msgstr ""
397
 
398
- #: src/PostSnippets/Admin.php:361
399
  msgid "Display rendered snippets"
400
  msgstr ""
401
 
402
- #: src/PostSnippets/Admin.php:362
403
  msgid "Update"
404
  msgstr ""
405
 
406
- #: src/PostSnippets/Admin.php:394
407
- msgid "Options"
 
 
 
 
 
 
 
 
 
 
408
  msgstr ""
409
 
410
  #: src/PostSnippets/Help.php:57
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2016-02-06 08:29+0000\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
23
  msgstr ""
24
 
25
  #: views/admin_snippets.php:9 views/admin_snippets.php:18
26
+ #: views/help/usage.php:10 src/PostSnippets/Admin.php:445
27
  msgid "Variables"
28
  msgstr ""
29
 
30
  #: views/admin_snippets.php:10 views/admin_snippets.php:19
31
+ #: views/help/usage.php:21 src/PostSnippets/Admin.php:464
32
  msgid "Snippet"
33
  msgstr ""
34
 
56
  msgid "Delete Selected"
57
  msgstr ""
58
 
59
+ #: views/jquery-ui-dialog.php:67
60
  msgid "This snippet is insert only, no variables defined."
61
  msgstr ""
62
 
194
  msgid "Donate"
195
  msgstr ""
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  #: views/help/usage.php:6
198
  msgid ""
199
  "Give the snippet a title that helps you identify it in the post editor. This "
270
  "trademark symbol, and the multiplication symbol."
271
  msgstr ""
272
 
273
+ #: src/PostSnippets/Admin.php:101
274
+ msgid "Invalid shortcode name"
275
+ msgstr ""
276
+
277
+ #: src/PostSnippets/Admin.php:137
278
  msgid "Settings"
279
  msgstr ""
280
 
281
+ #: src/PostSnippets/Admin.php:178
282
  msgid "A snippet named Untitled has been added."
283
  msgstr ""
284
 
285
+ #: src/PostSnippets/Admin.php:198
286
  msgid "Nothing selected to delete."
287
  msgstr ""
288
 
289
+ #: src/PostSnippets/Admin.php:214
290
  msgid "Selected snippets have been deleted."
291
  msgstr ""
292
 
293
+ #: src/PostSnippets/Admin.php:249
294
  msgid "Snippets have been updated."
295
  msgstr ""
296
 
297
+ #: src/PostSnippets/Admin.php:330
298
  msgid "Manage Snippets"
299
  msgstr ""
300
 
301
+ #: src/PostSnippets/Admin.php:331 src/PostSnippets/Admin.php:461
302
+ msgid "Options"
303
+ msgstr ""
304
+
305
+ #: src/PostSnippets/Admin.php:332 src/PostSnippets/Admin.php:389
306
  msgid "Import/Export"
307
  msgstr ""
308
 
309
+ #: src/PostSnippets/Admin.php:341
310
  msgid "Use the help dropdown button for additional information."
311
  msgstr ""
312
 
313
+ #: src/PostSnippets/Admin.php:390
314
  msgid "Export"
315
  msgstr ""
316
 
317
+ #: src/PostSnippets/Admin.php:393
318
  msgid "Export your snippets for backup or to import them on another site."
319
  msgstr ""
320
 
321
+ #: src/PostSnippets/Admin.php:395
322
  msgid "Export Snippets"
323
  msgstr ""
324
 
325
+ #: src/PostSnippets/Admin.php:418
326
  msgid ""
327
  "This is an overview of all snippets defined for this site. These snippets "
328
  "are inserted into posts from the post editor using the Post Snippets button. "
333
  "recommended to keep this option disabled."
334
  msgstr ""
335
 
336
+ #: src/PostSnippets/Admin.php:428
337
  msgid "Display rendered snippets"
338
  msgstr ""
339
 
340
+ #: src/PostSnippets/Admin.php:429
341
  msgid "Update"
342
  msgstr ""
343
 
344
+ #: src/PostSnippets/Admin.php:499
345
+ msgid "General"
346
+ msgstr ""
347
+
348
+ #: src/PostSnippets/Admin.php:506
349
+ msgid "Exclude from Custom Editors"
350
+ msgstr ""
351
+
352
+ #: src/PostSnippets/Admin.php:513
353
+ msgid ""
354
+ "Checking this only includes Post Snippets on standard WordPress post editing "
355
+ "screens."
356
  msgstr ""
357
 
358
  #: src/PostSnippets/Help.php:57
post-snippets.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://johansteen.se/code/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
  Author: Johan Steen
7
  Author URI: https://johansteen.se/
8
- Version: 2.5
9
  License: GPLv2 or later
10
  Text Domain: post-snippets
11
  Domain Path: /lang
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
  Author: Johan Steen
7
  Author URI: https://johansteen.se/
8
+ Version: 2.5.1
9
  License: GPLv2 or later
10
  Text Domain: post-snippets
11
  Domain Path: /lang
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://johansteen.se/donate/
4
  Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
5
  Requires at least: 3.3
6
  Tested up to: 4.4
7
- Stable tag: 2.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -128,6 +128,10 @@ Contributions are appreciated and encouraged.
128
 
129
  == Changelog ==
130
 
 
 
 
 
131
  = Version 2.5 - 21 Jan 2016 =
132
  * Implements an options tab to handle plugin settings.
133
  * Reverts the change implemented in version 2.3.9 to exclude post snippets from
4
  Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
5
  Requires at least: 3.3
6
  Tested up to: 4.4
7
+ Stable tag: 2.5.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
128
 
129
  == Changelog ==
130
 
131
+ = Version 2.5.1 - 6 Feb 2016 =
132
+ * Makes strings inside javascripts translatable.
133
+ * Removes `{content}` from shortcode output if the shortcode is not enclosed.
134
+
135
  = Version 2.5 - 21 Jan 2016 =
136
  * Implements an options tab to handle plugin settings.
137
  * Reverts the change implemented in version 2.3.9 to exclude post snippets from
src/PostSnippets/Admin.php CHANGED
@@ -96,6 +96,12 @@ class PostSnippets_Admin
96
  */
97
  public function scripts()
98
  {
 
 
 
 
 
 
99
  wp_enqueue_script('post-snippets');
100
  }
101
 
@@ -497,14 +503,14 @@ class PostSnippets_Admin
497
 
498
  add_settings_field(
499
  'exclude_from_custom_editors',
500
- 'Exclude from Custom Editors',
501
  array($this, 'cbExcludeFromCustomEditors'),
502
  'post-snippets',
503
  'general_section',
504
  array(
505
  'id' => 'exclude_from_custom_editors',
506
  'label_for' => 'exclude_from_custom_editors',
507
- 'description' => __('Checking this only includes Post Snippets on standard WordPress post editing screens.')
508
  )
509
  );
510
  }
96
  */
97
  public function scripts()
98
  {
99
+ // Localize the strings in the script
100
+ $translation_array = array(
101
+ 'invalid_shortcode' => __('Invalid shortcode name', 'post-snippets')
102
+ );
103
+ wp_localize_script('post-snippets', 'post_snippets', $translation_array);
104
+
105
  wp_enqueue_script('post-snippets');
106
  }
107
 
503
 
504
  add_settings_field(
505
  'exclude_from_custom_editors',
506
+ __('Exclude from Custom Editors', 'post-snippets'),
507
  array($this, 'cbExcludeFromCustomEditors'),
508
  'post-snippets',
509
  'general_section',
510
  array(
511
  'id' => 'exclude_from_custom_editors',
512
  'label_for' => 'exclude_from_custom_editors',
513
+ 'description' => __('Checking this only includes Post Snippets on standard WordPress post editing screens.', 'post-snippets')
514
  )
515
  );
516
  }
src/PostSnippets/Shortcode.php CHANGED
@@ -43,9 +43,9 @@ class PostSnippets_Shortcode
43
  $attributes = compact( array_keys($shortcode_symbols) );
44
 
45
  // Add enclosed content if available to the attributes array
46
- if ( $content != null )
47
  $attributes["content"] = $content;
48
-
49
 
50
  $snippet = \''. addslashes($snippet["snippet"]) .'\';
51
  // Disables auto conversion from & to &amp; as that should be done in snippet, not code (destroys php etc).
@@ -55,6 +55,14 @@ class PostSnippets_Shortcode
55
  $snippet = str_replace("{".$key."}", $val, $snippet);
56
  }
57
 
 
 
 
 
 
 
 
 
58
  // Handle PHP shortcodes
59
  $php = "'. $snippet["php"] .'";
60
  if ($php == true) {
43
  $attributes = compact( array_keys($shortcode_symbols) );
44
 
45
  // Add enclosed content if available to the attributes array
46
+ if ($content != null) {
47
  $attributes["content"] = $content;
48
+ }
49
 
50
  $snippet = \''. addslashes($snippet["snippet"]) .'\';
51
  // Disables auto conversion from & to &amp; as that should be done in snippet, not code (destroys php etc).
55
  $snippet = str_replace("{".$key."}", $val, $snippet);
56
  }
57
 
58
+ // There might be the case that a snippet contains
59
+ // the post snippets reserved variable {content} to
60
+ // capture the content in enclosed shortcodes, but
61
+ // the shortcode is used without enclosing it. To
62
+ // avoid outputting {content} as part of the string
63
+ // lets remove possible occurences.
64
+ $snippet = str_replace("{content}", "", $snippet);
65
+
66
  // Handle PHP shortcodes
67
  $php = "'. $snippet["php"] .'";
68
  if ($php == true) {
src/PostSnippets/WPEditor.php CHANGED
@@ -193,7 +193,6 @@ class PostSnippets_WPEditor
193
  $variables = '';
194
  if (!empty($var_arr[0])) {
195
  foreach ($var_arr as $var) {
196
- // '[test2 yet="{yet}" mupp=per="{mupp=per}" content="{content}"]';
197
  $var = $this->stripDefaultVal($var);
198
 
199
  $variables .= ' ' . $var . '="{' . $var . '}"';
193
  $variables = '';
194
  if (!empty($var_arr[0])) {
195
  foreach ($var_arr as $var) {
 
196
  $var = $this->stripDefaultVal($var);
197
 
198
  $variables .= ' ' . $var . '="{' . $var . '}"';