Post Snippets - Version 2.1

Version Description

The function get_post_snippet() used to retrieve snippets from other places in WordPress has been deprecated. Please update any code you might have modified that uses this function to use PostSnippets::getSnippet() instead, which replaces the old function. get_post_snippet() will be removed in a future version.

Most users are not affected by this change.

Download this release

Release Info

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

Code changes from version 2.0 to 2.1

Files changed (41) hide show
  1. assets/post-snippets.css +74 -74
  2. {languages → lang}/post-snippets-be_BY.mo +0 -0
  3. {languages → lang}/post-snippets-be_BY.po +0 -0
  4. {languages → lang}/post-snippets-de_DE.mo +0 -0
  5. {languages → lang}/post-snippets-de_DE.po +0 -0
  6. {languages → lang}/post-snippets-es_ES.mo +0 -0
  7. {languages → lang}/post-snippets-es_ES.po +0 -0
  8. {languages → lang}/post-snippets-fr_FR.mo +0 -0
  9. {languages → lang}/post-snippets-fr_FR.po +0 -0
  10. {languages → lang}/post-snippets-he_IL.mo +0 -0
  11. {languages → lang}/post-snippets-he_IL.po +0 -0
  12. {languages → lang}/post-snippets-lt_LT.mo +0 -0
  13. {languages → lang}/post-snippets-lt_LT.po +0 -0
  14. lang/post-snippets-pl_PL.mo +0 -0
  15. lang/post-snippets-pl_PL.po +360 -0
  16. {languages → lang}/post-snippets-ro_RO.mo +0 -0
  17. {languages → lang}/post-snippets-ro_RO.po +0 -0
  18. {languages → lang}/post-snippets-ru_RU.mo +0 -0
  19. {languages → lang}/post-snippets-ru_RU.po +0 -0
  20. lang/post-snippets-sk_SK.mo +0 -0
  21. lang/post-snippets-sk_SK.po +349 -0
  22. {languages → lang}/post-snippets-sv_SE.mo +0 -0
  23. {languages → lang}/post-snippets-sv_SE.po +0 -0
  24. {languages → lang}/post-snippets-tr_TR.mo +0 -0
  25. {languages → lang}/post-snippets-tr_TR.po +0 -0
  26. {languages → lang}/post-snippets.pot +0 -0
  27. classes/settings.php → lib/PostSnippets/Admin.php +22 -15
  28. classes/help.php → lib/PostSnippets/Help.php +9 -6
  29. classes/import-export.php → lib/PostSnippets/ImportExport.php +3 -3
  30. phpunit.xml +12 -0
  31. post-snippets.php +195 -153
  32. readme.txt +55 -4
  33. tests/phpunit.xml +0 -11
  34. tests/post-snippets-test.php +0 -85
  35. tinymce/editor_plugin.js +54 -54
  36. tinymce/langs/en.js +4 -4
  37. tinymce/langs/en_US.js +3 -3
  38. tinymce/langs/en_en.js +3 -3
  39. uninstall.php +0 -21
  40. unittest/PostSnippetsTest.php +66 -0
  41. unittest/bootstrap.php +8 -0
assets/post-snippets.css CHANGED
@@ -1,75 +1,75 @@
1
- /**
2
- * Styling for the jQuery UI dialog used by Post Snippets
3
- *
4
- * @version 2.0
5
- * @since Post Snippets 1.7.1
6
- */
7
- #post-snippets-tabs {
8
- /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
9
- position: relative;
10
- padding: .2em;
11
- zoom: 1;
12
- }
13
- #post-snippets-tabs .ui-tabs-nav {
14
- margin: 0;
15
- padding: .2em .2em 0;
16
-
17
- /* Overrides */
18
- background-color: #f9f9f9;
19
- border-bottom: 1px solid #dfdfdf;
20
- padding-bottom: 1px;
21
- }
22
-
23
- #post-snippets-tabs .ui-tabs-nav li {
24
- list-style: none;
25
- float: left;
26
- position: relative;
27
- top: 1px;
28
- margin: 0 .2em 1px 0;
29
- border-bottom: 0 !important;
30
- padding: 0;
31
- white-space: nowrap;
32
- }
33
- #post-snippets-tabs .ui-tabs-nav li a {
34
- float: left;
35
- padding: .5em 1em;
36
- text-decoration: none;
37
-
38
- /* Overrides */
39
- border: 1px solid #dfdfdf;
40
- -webkit-border-radius: 3px;
41
- border-radius: 3px;
42
- }
43
- #post-snippets-tabs .ui-tabs-nav li.ui-tabs-selected {
44
- margin-bottom: 0;
45
- padding-bottom: 1px;
46
-
47
- /* Overrides */
48
- background-color: #fff;
49
- padding-bottom: 0;
50
- }
51
- #post-snippets-tabs .ui-tabs-nav li.ui-tabs-selected a,
52
- #post-snippets-tabs .ui-tabs-nav li.ui-state-disabled a,
53
- #post-snippets-tabs .ui-tabs-nav li.ui-state-processing a {
54
- cursor: text;
55
- }
56
- #post-snippets-tabs .ui-tabs-nav li a,
57
- #post-snippets-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a {
58
- /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
59
- cursor: pointer;
60
- }
61
- #post-snippets-tabs .ui-tabs-panel {
62
- display: block;
63
- border-width: 0;
64
- padding: 1em 1.4em;
65
- background: none;
66
- }
67
- #post-snippets-tabs .ui-tabs-hide {
68
- display: none !important;
69
- }
70
-
71
-
72
- #post-snippets-dialog label {
73
- width: 60px;
74
- display: inline-block;
75
  }
1
+ /**
2
+ * Styling for the jQuery UI dialog used by Post Snippets
3
+ *
4
+ * @version 2.0
5
+ * @since Post Snippets 1.7.1
6
+ */
7
+ #post-snippets-tabs {
8
+ /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
9
+ position: relative;
10
+ padding: .2em;
11
+ zoom: 1;
12
+ }
13
+ #post-snippets-tabs .ui-tabs-nav {
14
+ margin: 0;
15
+ padding: .2em .2em 0;
16
+
17
+ /* Overrides */
18
+ background-color: #f9f9f9;
19
+ border-bottom: 1px solid #dfdfdf;
20
+ padding-bottom: 1px;
21
+ }
22
+
23
+ #post-snippets-tabs .ui-tabs-nav li {
24
+ list-style: none;
25
+ float: left;
26
+ position: relative;
27
+ top: 1px;
28
+ margin: 0 .2em 1px 0;
29
+ border-bottom: 0 !important;
30
+ padding: 0;
31
+ white-space: nowrap;
32
+ }
33
+ #post-snippets-tabs .ui-tabs-nav li a {
34
+ float: left;
35
+ padding: .5em 1em;
36
+ text-decoration: none;
37
+
38
+ /* Overrides */
39
+ border: 1px solid #dfdfdf;
40
+ -webkit-border-radius: 3px;
41
+ border-radius: 3px;
42
+ }
43
+ #post-snippets-tabs .ui-tabs-nav li.ui-tabs-selected {
44
+ margin-bottom: 0;
45
+ padding-bottom: 1px;
46
+
47
+ /* Overrides */
48
+ background-color: #fff;
49
+ padding-bottom: 0;
50
+ }
51
+ #post-snippets-tabs .ui-tabs-nav li.ui-tabs-selected a,
52
+ #post-snippets-tabs .ui-tabs-nav li.ui-state-disabled a,
53
+ #post-snippets-tabs .ui-tabs-nav li.ui-state-processing a {
54
+ cursor: text;
55
+ }
56
+ #post-snippets-tabs .ui-tabs-nav li a,
57
+ #post-snippets-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a {
58
+ /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
59
+ cursor: pointer;
60
+ }
61
+ #post-snippets-tabs .ui-tabs-panel {
62
+ display: block;
63
+ border-width: 0;
64
+ padding: 1em 1.4em;
65
+ background: none;
66
+ }
67
+ #post-snippets-tabs .ui-tabs-hide {
68
+ display: none !important;
69
+ }
70
+
71
+
72
+ #post-snippets-dialog label {
73
+ width: 60px;
74
+ display: inline-block;
75
  }
{languages → lang}/post-snippets-be_BY.mo RENAMED
File without changes
{languages → lang}/post-snippets-be_BY.po RENAMED
File without changes
{languages → lang}/post-snippets-de_DE.mo RENAMED
File without changes
{languages → lang}/post-snippets-de_DE.po RENAMED
File without changes
{languages → lang}/post-snippets-es_ES.mo RENAMED
File without changes
{languages → lang}/post-snippets-es_ES.po RENAMED
File without changes
{languages → lang}/post-snippets-fr_FR.mo RENAMED
File without changes
{languages → lang}/post-snippets-fr_FR.po RENAMED
File without changes
{languages → lang}/post-snippets-he_IL.mo RENAMED
File without changes
{languages → lang}/post-snippets-he_IL.po RENAMED
File without changes
{languages → lang}/post-snippets-lt_LT.mo RENAMED
File without changes
{languages → lang}/post-snippets-lt_LT.po RENAMED
File without changes
lang/post-snippets-pl_PL.mo ADDED
Binary file
lang/post-snippets-pl_PL.po ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2012 Post Snippets
2
+ # This file is distributed under the same license as the Post Snippets package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Post Snippets 1.9.7\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/post-snippets\n"
7
+ "POT-Creation-Date: 2013-01-18 19:05+0100\n"
8
+ "PO-Revision-Date: 2013-01-18 20:51+0100\n"
9
+ "Last-Translator: Tomasz Wesołowski <twesolowski@grafeina.pl>\n"
10
+ "Language-Team: LANGUAGE <LL@li.org>\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Generator: Poedit 1.5.3\n"
15
+ "X-Poedit-KeywordsList: _e;__;_x\n"
16
+ "X-Poedit-Basepath: .\n"
17
+ "X-Poedit-SearchPath-0: ..\n"
18
+
19
+ #: ../post-snippets.php:99
20
+ msgid "Settings"
21
+ msgstr "Ustawienia"
22
+
23
+ #: ../post-snippets.php:472
24
+ msgid "This snippet is insert only, no variables defined."
25
+ msgstr "Ten snippet nie posiada parametrów. Możesz go tylko wstawić."
26
+
27
+ #: ../classes/help.php:41 ../classes/help.php:256
28
+ msgid "Basic"
29
+ msgstr "Podstawowe"
30
+
31
+ #: ../classes/help.php:46 ../classes/help.php:258 ../classes/settings.php:256
32
+ msgid "Shortcode"
33
+ msgstr "Shortcode"
34
+
35
+ #: ../classes/help.php:51 ../classes/help.php:260
36
+ msgid "PHP"
37
+ msgstr "PHP"
38
+
39
+ #: ../classes/help.php:56 ../classes/help.php:262
40
+ msgid "Advanced"
41
+ msgstr "Zaawansowane"
42
+
43
+ #: ../classes/help.php:70
44
+ msgid "For more information:"
45
+ msgstr "Więcej informacji:"
46
+
47
+ #: ../classes/help.php:74
48
+ msgid "Post Snippets Documentation"
49
+ msgstr "Dokumentacja"
50
+
51
+ #: ../classes/help.php:78
52
+ msgid "Support Forums"
53
+ msgstr "Forum"
54
+
55
+ #: ../classes/help.php:91 ../classes/settings.php:225
56
+ #: ../classes/settings.php:234
57
+ msgid "Title"
58
+ msgstr "Nazwa"
59
+
60
+ #: ../classes/help.php:94
61
+ msgid ""
62
+ "Give the snippet a title that helps you identify it in the post editor. This "
63
+ "also becomes the name of the shortcode if you enable that option"
64
+ msgstr ""
65
+ "Nazwa snippeta pomoże odnaleźć go w edytorze treści. Jest to także nazwa "
66
+ "funkcji shortcode (jeżeli wybierzesz taką opcję)"
67
+
68
+ #: ../classes/help.php:98 ../classes/settings.php:226
69
+ #: ../classes/settings.php:235 ../classes/settings.php:354
70
+ msgid "Variables"
71
+ msgstr "Zmienne"
72
+
73
+ #: ../classes/help.php:101
74
+ msgid ""
75
+ "A comma separated list of custom variables you can reference in your "
76
+ "snippet. A variable can also be assigned a default value that will be used "
77
+ "in the insert window by using the equal sign, variable=default."
78
+ msgstr ""
79
+ "Rozdzielona przecinkami lista zmiennych snippeta. Domyślną wartość zmiennej "
80
+ "możesz nadać używająć znaku równości, zmienna=wartość_domyślna"
81
+
82
+ #: ../classes/help.php:104 ../classes/help.php:115 ../classes/help.php:230
83
+ msgid "Example"
84
+ msgstr "Przykład"
85
+
86
+ #: ../classes/help.php:109 ../classes/settings.php:227
87
+ #: ../classes/settings.php:236 ../classes/settings.php:368
88
+ msgid "Snippet"
89
+ msgstr "Snippet"
90
+
91
+ #: ../classes/help.php:112
92
+ msgid ""
93
+ "This is the block of text, HTML or PHP to insert in the post or as a "
94
+ "shortcode. If you have entered predefined variables you can reference them "
95
+ "from the snippet by enclosing them in {} brackets."
96
+ msgstr ""
97
+ "Blok teksu, kodu HTML lub PHP, który będzie wstawiony jako shortcode. "
98
+ "Zdefiniowane zmienne możesz wstawić używając nawiasów klamrowych {}."
99
+
100
+ #: ../classes/help.php:117
101
+ msgid ""
102
+ "To reference the variables in the example above, you would enter {url} and "
103
+ "{name}. So if you enter this snippet:"
104
+ msgstr ""
105
+ "Aby użyć zmiennych z powyższego przykładu, wykorzystaj {url} i {name}. "
106
+ "Jeżeli wstawisz:"
107
+
108
+ #: ../classes/help.php:121
109
+ msgid ""
110
+ "You will get the option to replace url and name on insert if they are "
111
+ "defined as variables."
112
+ msgstr ""
113
+ "będziesz mógł podać URL {url} i nazwę {name} w momencie wstawiania do "
114
+ "treści (jeżeli te pola zostały zdefiniowane jako zmienne)."
115
+
116
+ #: ../classes/help.php:125 ../classes/settings.php:270
117
+ msgid "Description"
118
+ msgstr "Opis"
119
+
120
+ #: ../classes/help.php:128
121
+ msgid ""
122
+ "An optional description for the Snippet. If filled out, the description will "
123
+ "be displayed in the snippets insert window in the post editor."
124
+ msgstr ""
125
+ "Opcjonalny opis Snippeta. Zostanie wyświetlony w oknie wstawiania snippeta w "
126
+ "edytorze treści."
127
+
128
+ #: ../classes/help.php:141
129
+ msgid ""
130
+ "When enabling the shortcode checkbox, the snippet is no longer inserted "
131
+ "directly but instead inserted as a shortcode. The obvious advantage of this "
132
+ "is of course that you can insert a block of text or code in many places on "
133
+ "the site, and update the content from one single place."
134
+ msgstr ""
135
+ "Zaznaczenie opcji Shortcode spowoduje, że snippet nie zostanie wstawiony "
136
+ "bezpośrednio lecz użyty jak shortcode. Podstawową zaletą tej opcji jest "
137
+ "fakt, że możesz wielokrotnie wstawić kod do wielu postów i kontrolować ich "
138
+ "działanie w jednym miejscu."
139
+
140
+ #: ../classes/help.php:145
141
+ msgid ""
142
+ "The name to use the shortcode is the same as the title of the snippet "
143
+ "(spaces are not allowed). When inserting a shortcode snippet, the shortcode "
144
+ "and not the content will be inserted in the post."
145
+ msgstr ""
146
+ "Nazwa kodu shortcode będzie taka sama jak nazwa snippeta (nie używaj "
147
+ "spacji). Wstawienie snippeta z opcją shortcode spowoduje wstawienie "
148
+ "znacznika shortcode, nie kodu snippeta."
149
+
150
+ #: ../classes/help.php:148
151
+ msgid ""
152
+ "If you enclose the shortcode in your posts, you can access the enclosed "
153
+ "content by using the variable {content} in your snippet. The {content} "
154
+ "variable is reserved, so don't use it in the variables field."
155
+ msgstr ""
156
+ "Jeżeli otoczysz dowolną treść kodem shortcode, możesz użyć zawartości za "
157
+ "pomocą zmiennej {content}. Zmienna {content} jest zastrzeżona, nie używaj "
158
+ "jej w snippetach."
159
+
160
+ #: ../classes/help.php:152 ../classes/settings.php:366
161
+ msgid "Options"
162
+ msgstr "Opcje"
163
+
164
+ #: ../classes/help.php:155
165
+ msgid "See the dedicated help section for information about PHP shortcodes."
166
+ msgstr "Zajrzyj do działu pomocy o PHP."
167
+
168
+ #: ../classes/help.php:158
169
+ #, php-format
170
+ msgid ""
171
+ "Before the shortcode is outputted, it can optionally be formatted with %s, "
172
+ "to transform quotes to smart quotes, apostrophes, dashes, ellipses, the "
173
+ "trademark symbol, and the multiplication symbol."
174
+ msgstr ""
175
+ "Kod zwracany przez shortcode zostanie dodatkowo przefiltrowany przez funkcję "
176
+ "%s. "
177
+
178
+ #: ../classes/help.php:171
179
+ msgid ""
180
+ "Snippets defined as shortcodes can optionally also be evaluated as PHP Code "
181
+ "by enabling the PHP checkbox. PHP snippets is only available when treating "
182
+ "the snippet as a shortcode."
183
+ msgstr ""
184
+ "Zaznaczenie opcji 'Kod PHP' spowoduje przetworzenie snippeta jako kodu PHP. "
185
+ "Snippety będą interpretowane jako kod PHP wyłącznie po włączeniu opcji "
186
+ "Shortcode."
187
+
188
+ #: ../classes/help.php:174
189
+ msgid "Example PHP Snippet"
190
+ msgstr "Przykładowy Snippet PHP"
191
+
192
+ #: ../classes/help.php:183
193
+ msgid ""
194
+ "With a snippet defined like the one above, you can call it with its "
195
+ "shortcode definition in a post. Let's pretend that the example snippet is "
196
+ "named phpcode and have one variable defined loop_me, then it would be called "
197
+ "like this from a post:"
198
+ msgstr ""
199
+ "Snippeta zdefionawanego jak ten powyżej możej użyć jako kodu shortcode. "
200
+ "Zakładając, że przykładowy snippet został nazwany phpcode i posiada zmienną "
201
+ "loop_me, możesz go użyć w treści posta w następujący sposób:"
202
+
203
+ #: ../classes/help.php:189
204
+ msgid ""
205
+ "When the shortcode is executed the loop_me variable will be replaced with "
206
+ "the string supplied in the shortcode and then the PHP code will be "
207
+ "evaluated. (Outputting the string five times in this case. Wow!)"
208
+ msgstr ""
209
+ "W chwili wykonania kodu shortcode, zmienna loop_me zostanie zastąpiona przez "
210
+ "wprowadzoną wartość i kod PHP zostanie przetworzony (wyświetli 5 razy "
211
+ "wprowadzoną wartość. Wa wa wee wa!)."
212
+
213
+ #: ../classes/help.php:192
214
+ msgid ""
215
+ "Note the evaluation order, any snippet variables will be replaced before the "
216
+ "snippet is evaluated as PHP code. Also note that a PHP snippet don't need to "
217
+ "be wrapped in &lt;?php #code; ?&gt;."
218
+ msgstr ""
219
+ "Zwróć uwagę na kolejność interpretacji zmiennych. Zmienne snippeta zostaną "
220
+ "zastąpione podanymi wartościami przed wykonaniem kodu jako PHP. Pamiętaj "
221
+ "także, że kod nie musi być zawarty w znacznikach &lt;?php #code; ?&gt;."
222
+
223
+ #: ../classes/help.php:205
224
+ msgid ""
225
+ "You can retrieve a Post Snippet directly from PHP, in a theme for instance, "
226
+ "by using the get_post_snippet() function."
227
+ msgstr ""
228
+ "Możesz pobrać Snippeta za pomocą PHP (np. w pliku motywu). Użyj funkcji "
229
+ "get_post_snippet()."
230
+
231
+ #: ../classes/help.php:209
232
+ msgid "Usage"
233
+ msgstr "Użycie"
234
+
235
+ #: ../classes/help.php:217
236
+ msgid "Parameters"
237
+ msgstr "Parametry"
238
+
239
+ #: ../classes/help.php:221
240
+ msgid "(string) (required) The name of the snippet to retrieve."
241
+ msgstr "(strong)(wymagany) Nazwa snippeta, który chcesz pobrać."
242
+
243
+ #: ../classes/help.php:226
244
+ msgid ""
245
+ "(string) The variables to pass to the snippet, formatted as a query string."
246
+ msgstr "(string) Zmienne snippeta przekazane jako 'query string'"
247
+
248
+ #: ../classes/import-export.php:91
249
+ msgid "Import"
250
+ msgstr "Import"
251
+
252
+ #: ../classes/import-export.php:93
253
+ msgid ""
254
+ "Import snippets from a post-snippets-export.zip file. Importing overwrites "
255
+ "any existing snippets."
256
+ msgstr ""
257
+ "Zaimportuj Snippety z pliku post-snippets-export.zip. Import nadpisze "
258
+ "instniejące Snippety."
259
+
260
+ #: ../classes/import-export.php:97
261
+ msgid "Import Snippets"
262
+ msgstr "Importuj"
263
+
264
+ #: ../classes/import-export.php:123
265
+ msgid "Snippets successfully imported."
266
+ msgstr "Snippety zostały zaimportowane."
267
+
268
+ #: ../classes/import-export.php:125 ../classes/import-export.php:129
269
+ #: ../classes/import-export.php:131
270
+ msgid "Snippets could not be imported:"
271
+ msgstr "Snippety nie mogły zostać zaimportowane."
272
+
273
+ #: ../classes/import-export.php:125
274
+ msgid "Unzipping failed."
275
+ msgstr "Rozpakowanie zakończone niepowodzeniem."
276
+
277
+ #: ../classes/import-export.php:131
278
+ msgid "Upload failed."
279
+ msgstr "Upload nieudany."
280
+
281
+ #: ../classes/settings.php:41
282
+ msgid "A snippet named Untitled has been added."
283
+ msgstr "Dodano snippet 'Untitled'"
284
+
285
+ #: ../classes/settings.php:57
286
+ msgid "Nothing selected to delete."
287
+ msgstr "Niczego nie zaznaczono do usunięcia."
288
+
289
+ #: ../classes/settings.php:70
290
+ msgid "Selected snippets have been deleted."
291
+ msgstr "Zaznaczone snippety zostały usunięte."
292
+
293
+ #: ../classes/settings.php:96
294
+ msgid "Snippets have been updated."
295
+ msgstr "Zmiany zostały zapisane."
296
+
297
+ #: ../classes/settings.php:189
298
+ msgid "Manage Snippets"
299
+ msgstr "Zarządzaj"
300
+
301
+ #: ../classes/settings.php:189 ../classes/settings.php:298
302
+ msgid "Import/Export"
303
+ msgstr "Import/Eksport"
304
+
305
+ #: ../classes/settings.php:197
306
+ msgid "Use the help dropdown button for additional information."
307
+ msgstr ""
308
+ "Więcej informacji znajdziesz w zakładce Pomoc (rozwijane menu w prawym "
309
+ "górnym rogu)."
310
+
311
+ #: ../classes/settings.php:261
312
+ msgid "PHP Code"
313
+ msgstr "Kod PHP"
314
+
315
+ #: ../classes/settings.php:282
316
+ msgid "Update Snippets"
317
+ msgstr "Zaktualizuj"
318
+
319
+ #: ../classes/settings.php:283
320
+ msgid "Add New Snippet"
321
+ msgstr "Dodaj nowy"
322
+
323
+ #: ../classes/settings.php:284
324
+ msgid "Delete Selected"
325
+ msgstr "Usuń zaznaczone"
326
+
327
+ #: ../classes/settings.php:299
328
+ msgid "Export"
329
+ msgstr "Exportuj"
330
+
331
+ #: ../classes/settings.php:302
332
+ msgid "Export your snippets for backup or to import them on another site."
333
+ msgstr ""
334
+ "Wyeksportuj swoje Snippety dla bezpieczeństwa lub użycia ich na innej "
335
+ "stronie."
336
+
337
+ #: ../classes/settings.php:304
338
+ msgid "Export Snippets"
339
+ msgstr "Exportuj Snippety"
340
+
341
+ #: ../classes/settings.php:327
342
+ msgid ""
343
+ "This is an overview of all snippets defined for this site. These snippets "
344
+ "are inserted into posts from the post editor using the Post Snippets button. "
345
+ "You can choose to see the snippets here as-is or as they are actually "
346
+ "rendered on the website. Enabling rendered snippets for this overview might "
347
+ "look strange if the snippet have dependencies on variables, CSS or other "
348
+ "parameters only available on the frontend. If that is the case it is "
349
+ "recommended to keep this option disabled."
350
+ msgstr ""
351
+ "To jest lista wszystkich snippetów zdefiniowanych dla tej strony. Możesz je "
352
+ "wstawiać używając przycisku Post Snippets w edytorze treści."
353
+
354
+ #: ../classes/settings.php:337
355
+ msgid "Display rendered snippets"
356
+ msgstr "Pokaż utworzone snippety."
357
+
358
+ #: ../classes/settings.php:338
359
+ msgid "Update"
360
+ msgstr "Zaktualizuj"
{languages → lang}/post-snippets-ro_RO.mo RENAMED
File without changes
{languages → lang}/post-snippets-ro_RO.po RENAMED
File without changes
{languages → lang}/post-snippets-ru_RU.mo RENAMED
File without changes
{languages → lang}/post-snippets-ru_RU.po RENAMED
File without changes
lang/post-snippets-sk_SK.mo ADDED
Binary file
lang/post-snippets-sk_SK.po ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is distributed under the same license as the Post Snippets package.
2
+ msgid ""
3
+ msgstr ""
4
+ "Project-Id-Version: Post Snippets 1.9.3\n"
5
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/post-snippets\n"
6
+ "POT-Creation-Date: 2012-02-08 16:54:26+00:00\n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "PO-Revision-Date: 2012-12-03 15:17+0400\n"
11
+ "Last-Translator: \n"
12
+ "Language-Team: \n"
13
+ "X-Generator: Poedit 1.5.4\n"
14
+
15
+ #: classes/settings.php:33
16
+ msgid "Add New Snippet"
17
+ msgstr "Pridať nové úryvok"
18
+
19
+ #: classes/settings.php:34
20
+ msgid "Delete Selected"
21
+ msgstr "Zmazať vybrané"
22
+
23
+ #: classes/settings.php:35
24
+ msgid "(Use the help dropdown button above for additional information.)"
25
+ msgstr "(Použite Rozbaľovacie tlačidlo Pomocník vyššie dodatočné informácie.)"
26
+
27
+ #: classes/settings.php:44 classes/settings.php:53 classes/help.php:91
28
+ msgid "Title"
29
+ msgstr "Názov"
30
+
31
+ #: classes/settings.php:45 classes/settings.php:54 classes/help.php:98
32
+ msgid "Variables"
33
+ msgstr "Premenné"
34
+
35
+ #: classes/settings.php:46 classes/settings.php:55 classes/help.php:109
36
+ msgid "Snippet"
37
+ msgstr "Úryvok"
38
+
39
+ #: classes/settings.php:76 classes/help.php:46 classes/help.php:258
40
+ msgid "Shortcode"
41
+ msgstr "Krátky"
42
+
43
+ #: classes/settings.php:81
44
+ msgid "PHP Code"
45
+ msgstr "PHP kód"
46
+
47
+ #: classes/settings.php:90 classes/help.php:125
48
+ msgid "Description"
49
+ msgstr "Popis"
50
+
51
+ #: classes/settings.php:101
52
+ msgid "Update Snippets"
53
+ msgstr "Aktualizácia úryvky"
54
+
55
+ #: classes/help.php:41 classes/help.php:256
56
+ msgid "Basic"
57
+ msgstr "Základné"
58
+
59
+ #: classes/help.php:51 classes/help.php:260
60
+ msgid "PHP"
61
+ msgstr "PHP"
62
+
63
+ #: classes/help.php:56 classes/help.php:262
64
+ msgid "Advanced"
65
+ msgstr "Pokročilé"
66
+
67
+ #: classes/help.php:70
68
+ msgid "For more information:"
69
+ msgstr "Ďalšie informácie:"
70
+
71
+ #: classes/help.php:74
72
+ msgid "Post Snippets Documentation"
73
+ msgstr "Príspevok úryvky dokumentácie"
74
+
75
+ #: classes/help.php:78
76
+ msgid "Support Forums"
77
+ msgstr "Diskusné fóra"
78
+
79
+ #: classes/help.php:94
80
+ msgid ""
81
+ "Give the snippet a title that helps you identify it in the post editor. This "
82
+ "also becomes the name of the shortcode if you enable that option"
83
+ msgstr ""
84
+ "Dať úryvok titul, ktorý pomáha identifikovať v editore post. To sa tiež "
85
+ "stáva názov krátky kód, ak povolíte túto možnosť"
86
+
87
+ #: classes/help.php:101
88
+ msgid ""
89
+ "A comma separated list of custom variables you can reference in your "
90
+ "snippet. A variable can also be assigned a default value that will be used "
91
+ "in the insert window by using the equal sign, variable=default."
92
+ msgstr ""
93
+ "Čiarkou oddelený zoznam vlastné premenné môžete použiť odkaz vo vašom "
94
+ "úryvku. Premennej možno tiež priradiť predvolenú hodnotu, ktorá sa použije v "
95
+ "okne vložiť pomocou znamienko rovnosti, variabilné = predvolené."
96
+
97
+ #: classes/help.php:104 classes/help.php:115 classes/help.php:230
98
+ msgid "Example"
99
+ msgstr "Príklad"
100
+
101
+ #: classes/help.php:112
102
+ msgid ""
103
+ "This is the block of text, HTML or PHP to insert in the post or as a "
104
+ "shortcode. If you have entered predefined variables you can reference them "
105
+ "from the snippet by enclosing them in {} brackets."
106
+ msgstr ""
107
+ "To je blok textu, HTML alebo PHP vložiť v post alebo ako krátky. Ak ste "
108
+ "zadali preddefinované premenné môžete im odkaz z úryvok uzavretím do "
109
+ "zátvoriek {}."
110
+
111
+ #: classes/help.php:117
112
+ msgid ""
113
+ "To reference the variables in the example above, you would enter {url} and "
114
+ "{name}. So if you enter this snippet:"
115
+ msgstr ""
116
+ "Odkaz premenné v príklade, by ste zadajte {url} a {meno}. Takže ak zadáte "
117
+ "tento úryvok:"
118
+
119
+ #: classes/help.php:121
120
+ msgid ""
121
+ "You will get the option to replace url and name on insert if they are "
122
+ "defined as variables."
123
+ msgstr ""
124
+ "Budete mať možnosť nahradiť url a názov na vložiť, ak sú vymedzené ako "
125
+ "premenné."
126
+
127
+ #: classes/help.php:128
128
+ msgid ""
129
+ "An optional description for the Snippet. If filled out, the description will "
130
+ "be displayed in the snippets insert window in the post editor."
131
+ msgstr ""
132
+ "Voliteľný popis úryvok. Ak vyplnené, opis sa zobrazí v okne vložiť úryvky v "
133
+ "editore post."
134
+
135
+ #: classes/help.php:141
136
+ msgid ""
137
+ "When enabling the shortcode checkbox, the snippet is no longer inserted "
138
+ "directly but instead inserted as a shortcode. The obvious advantage of this "
139
+ "is of course that you can insert a block of text or code in many places on "
140
+ "the site, and update the content from one single place."
141
+ msgstr ""
142
+ "Pri povoľovaní krátky políčko, úryvok je už vložený priamo, ale namiesto "
143
+ "toho vkladá ako krátky. Očividná výhoda to je samozrejme, že môžete vložiť "
144
+ "blok textu alebo kódu na mnohých miestach na webe, a aktualizovať obsah z "
145
+ "jedného jediného miesta."
146
+
147
+ #: classes/help.php:145
148
+ msgid ""
149
+ "The name to use the shortcode is the same as the title of the snippet "
150
+ "(spaces are not allowed). When inserting a shortcode snippet, the shortcode "
151
+ "and not the content will be inserted in the post."
152
+ msgstr ""
153
+ "Použite krátky názov je rovnaký ako názov úryvok (priestory nie sú "
154
+ "povolené). Pri vkladaní krátky úryvok, krátky a nie obsah bude vložený v "
155
+ "post."
156
+
157
+ #: classes/help.php:148
158
+ msgid ""
159
+ "If you enclose the shortcode in your posts, you can access the enclosed "
160
+ "content by using the variable {content} in your snippet. The {content} "
161
+ "variable is reserved, so don't use it in the variables field."
162
+ msgstr ""
163
+ "Ak je priložiť krátky kód na vaše príspevky, vložený obsah môžete "
164
+ "pristupovať pomocou premennej {obsah} vo vašom úryvku. Premenná {obsah} je "
165
+ "vyhradené, takže sa nemusíte používať v poli premenných."
166
+
167
+ #: classes/help.php:152
168
+ msgid "Options"
169
+ msgstr "Možnosti"
170
+
171
+ #: classes/help.php:155
172
+ msgid "See the dedicated help section for information about PHP shortcodes."
173
+ msgstr ""
174
+ "Nájdete časti Pomocníka špecializované informácie o PHP kódy shortcode."
175
+
176
+ #: classes/help.php:158
177
+ msgid ""
178
+ "Before the shortcode is outputted, it can optionally be formatted with %s, "
179
+ "to transform quotes to smart quotes, apostrophes, dashes, ellipses, the "
180
+ "trademark symbol, and the multiplication symbol."
181
+ msgstr ""
182
+ "Pred outputted je krátky, to môžete voliteľne formátovaný pomocou % s, "
183
+ "transformovať úvodzovky úvodzovky, apostrofy, pomlčky, elipsy, symbol "
184
+ "ochrannej známky a násobenie symbol."
185
+
186
+ #: classes/help.php:171
187
+ msgid ""
188
+ "Snippets defined as shortcodes can optionally also be evaluated as PHP Code "
189
+ "by enabling the PHP checkbox. PHP snippets is only available when treating "
190
+ "the snippet as a shortcode."
191
+ msgstr ""
192
+ "Úryvky definované ako shortcodes môžu voliteľne aj hodnotiť ako PHP kód "
193
+ "umožnením PHP políčko. PHP úryvky je k dispozícii len pri liečbe ako krátky "
194
+ "úryvok."
195
+
196
+ #: classes/help.php:174
197
+ msgid "Example PHP Snippet"
198
+ msgstr "Príklad PHP úryvok"
199
+
200
+ #: classes/help.php:183
201
+ msgid ""
202
+ "With a snippet defined like the one above, you can call it with its "
203
+ "shortcode definition in a post. Let's pretend that the example snippet is "
204
+ "named phpcode and have one variable defined loop_me, then it would be called "
205
+ "like this from a post:"
206
+ msgstr ""
207
+ "S úryvok definované ako bola tá vyššie, môžete volať to s jeho krátky "
208
+ "definície v post. Poďme predstierať, že príklad úryvok je pomenovaný phpcode "
209
+ "a definovali jednu premennú loop_me, potom by sa dalo takto od príspevok:"
210
+
211
+ #: classes/help.php:189
212
+ msgid ""
213
+ "When the shortcode is executed the loop_me variable will be replaced with "
214
+ "the string supplied in the shortcode and then the PHP code will be "
215
+ "evaluated. (Outputting the string five times in this case. Wow!)"
216
+ msgstr ""
217
+ "Keď krátky kód je vykonaný loop_me premennej sa nahradí reťazec dodávané v "
218
+ "krátky kód a potom sa vyhodnotí kód PHP. (Výstup reťazec päťkrát v tomto "
219
+ "prípade. Wow!)"
220
+
221
+ #: classes/help.php:192
222
+ msgid ""
223
+ "Note the evaluation order, any snippet variables will be replaced before the "
224
+ "snippet is evaluated as PHP code. Also note that a PHP snippet don't need to "
225
+ "be wrapped in <?php #code; ?>."
226
+ msgstr ""
227
+ "Pozor na hodnotiace poradie, akékoľvek úryvok premenné budú nahradené pred "
228
+ "úryvok sa vyhodnocuje ako PHP kód. Tiež Upozorňujeme, že PHP úryvok nemusíte "
229
+ "byť zabalené v <? php #code;? >."
230
+
231
+ #: classes/help.php:205
232
+ msgid ""
233
+ "You can retrieve a Post Snippet directly from PHP, in a theme for instance, "
234
+ "by using the get_post_snippet() function."
235
+ msgstr ""
236
+ "Môžete získať príspevok úryvok priamo z PHP, na tému napríklad pomocou "
237
+ "funkcie get_post_snippet()."
238
+
239
+ #: classes/help.php:209
240
+ msgid "Usage"
241
+ msgstr "Využitie"
242
+
243
+ #: classes/help.php:217
244
+ msgid "Parameters"
245
+ msgstr "Parametre"
246
+
247
+ #: classes/help.php:221
248
+ msgid "(string) (required) The name of the snippet to retrieve."
249
+ msgstr "(reťazec) (povinné) Názov úryvok načítať."
250
+
251
+ #: classes/help.php:226
252
+ msgid ""
253
+ "(string) The variables to pass to the snippet, formatted as a query string."
254
+ msgstr ""
255
+ "(reťazec) Premenné majú postúpiť fragment, formátované ako reťazec dotazu."
256
+
257
+ #: post-snippets.php:85
258
+ msgid "Settings"
259
+ msgstr "Nastavenia"
260
+
261
+ #: post-snippets.php:430
262
+ msgid "This snippet is insert only, no variables defined."
263
+ msgstr "Tento úryvok je vložiť iba, žiadne premenné definované."
264
+
265
+ #: post-snippets.php:577
266
+ msgid "A snippet named Untitled has been added."
267
+ msgstr "Úryvok s názvom Untitled bola pridaná."
268
+
269
+ #: post-snippets.php:595 post-snippets.php:745
270
+ msgid "Snippets have been updated."
271
+ msgstr "Úryvky boli aktualizované."
272
+
273
+ #: post-snippets.php:611
274
+ msgid "Selected snippets have been deleted."
275
+ msgstr "Vybrané úryvky boli odstránené."
276
+
277
+ #: post-snippets.php:625
278
+ msgid "Import/Export"
279
+ msgstr "Import a Export"
280
+
281
+ #: post-snippets.php:626
282
+ msgid "Export"
283
+ msgstr "Export"
284
+
285
+ #: post-snippets.php:628
286
+ msgid "Export your snippets for backup or to import them on another site."
287
+ msgstr "Export vašich úryvky pre zálohovanie alebo pre import na inom mieste."
288
+
289
+ #: post-snippets.php:629
290
+ msgid "Export Snippets"
291
+ msgstr "Export úryvky"
292
+
293
+ #: post-snippets.php:715
294
+ msgid "Import"
295
+ msgstr "Import"
296
+
297
+ #: post-snippets.php:717
298
+ msgid ""
299
+ "Import snippets from a post-snippets-export.zip file. Importing overwrites "
300
+ "any existing snippets."
301
+ msgstr ""
302
+ "Importovať úryvky zo súboru snippets-export.zip. Import prepíše akékoľvek "
303
+ "existujúce úryvky."
304
+
305
+ #: post-snippets.php:721
306
+ msgid "Import Snippets"
307
+ msgstr "Import úryvky"
308
+
309
+ #: post-snippets.php:747
310
+ msgid "Snippets successfully imported."
311
+ msgstr "Úryvky úspešne importoval."
312
+
313
+ #: post-snippets.php:749 post-snippets.php:753 post-snippets.php:755
314
+ msgid "Snippets could not be imported:"
315
+ msgstr "Nie je možné importovať úryvky:"
316
+
317
+ #: post-snippets.php:749
318
+ msgid "Unzipping failed."
319
+ msgstr "Rozopínajúci zlyhala."
320
+
321
+ #: post-snippets.php:755
322
+ msgid "Upload failed."
323
+ msgstr "Odovzdávanie zlyhalo."
324
+
325
+ #. Plugin Name of the plugin/theme
326
+ msgid "Post Snippets"
327
+ msgstr "Príspevok úryvky"
328
+
329
+ #. Plugin URI of the plugin/theme
330
+ msgid "http://wpstorm.net/wordpress-plugins/post-snippets/"
331
+ msgstr "http://wpstorm.net/Wordpress-plugins/post-snippets/"
332
+
333
+ #. Description of the plugin/theme
334
+ msgid ""
335
+ "Build a library with snippets of HTML, PHP code or reoccurring text that you "
336
+ "often use in your posts. Variables to replace parts of the snippet on insert "
337
+ "can be used. The snippets can be inserted as-is or as shortcodes."
338
+ msgstr ""
339
+ "Budovať knižnice s úryvky z HTML, PHP kód alebo opakovanému textu, ktoré "
340
+ "často používate vo vašich príspevkoch. Môžu byť použité premenné na výmenu "
341
+ "súčiastok úryvok na vložiť. Úryvky možno vložiť ako-je, alebo ako shortcodes."
342
+
343
+ #. Author of the plugin/theme
344
+ msgid "Johan Steen"
345
+ msgstr "Johan Steen"
346
+
347
+ #. Author URI of the plugin/theme
348
+ msgid "http://johansteen.se/"
349
+ msgstr "http://johansteen.se/"
{languages → lang}/post-snippets-sv_SE.mo RENAMED
File without changes
{languages → lang}/post-snippets-sv_SE.po RENAMED
File without changes
{languages → lang}/post-snippets-tr_TR.mo RENAMED
File without changes
{languages → lang}/post-snippets-tr_TR.po RENAMED
File without changes
{languages → lang}/post-snippets.pot RENAMED
File without changes
classes/settings.php → lib/PostSnippets/Admin.php RENAMED
@@ -9,7 +9,7 @@
9
  * @author Johan Steen <artstorm at gmail dot com>
10
  * @since Post Snippets 1.8.8
11
  */
12
- class Post_Snippets_Settings extends Post_Snippets_Base
13
  {
14
  // -------------------------------------------------------------------------
15
  // Handle form submissions
@@ -24,7 +24,7 @@ class Post_Snippets_Settings extends Post_Snippets_Base
24
  && isset( $_POST['update_snippets_nonce'])
25
  && wp_verify_nonce( $_POST['update_snippets_nonce'], 'update_snippets') )
26
  {
27
- $snippets = get_option( self::PLUGIN_OPTION_KEY );
28
  if (empty($snippets)) { $snippets = array(); }
29
 
30
  array_push($snippets, array (
@@ -37,7 +37,7 @@ class Post_Snippets_Settings extends Post_Snippets_Base
37
  'snippet' => '')
38
  );
39
 
40
- update_option( self::PLUGIN_OPTION_KEY, $snippets );
41
  $this->message( __( 'A snippet named Untitled has been added.', 'post-snippets' ) );
42
  }
43
  }
@@ -51,7 +51,7 @@ class Post_Snippets_Settings extends Post_Snippets_Base
51
  && isset( $_POST['update_snippets_nonce'])
52
  && wp_verify_nonce( $_POST['update_snippets_nonce'], 'update_snippets') )
53
  {
54
- $snippets = get_option( self::PLUGIN_OPTION_KEY );
55
 
56
  if ( empty($snippets) || !isset($_POST['checked']) ) {
57
  $this->message( __( 'Nothing selected to delete.', 'post-snippets' ) );
@@ -66,7 +66,7 @@ class Post_Snippets_Settings extends Post_Snippets_Base
66
  }
67
  }
68
 
69
- update_option( self::PLUGIN_OPTION_KEY, $newsnippets );
70
  $this->message( __( 'Selected snippets have been deleted.', 'post-snippets' ) );
71
  }
72
  }
@@ -80,19 +80,24 @@ class Post_Snippets_Settings extends Post_Snippets_Base
80
  && isset( $_POST['update_snippets_nonce'])
81
  && wp_verify_nonce( $_POST['update_snippets_nonce'], 'update_snippets') )
82
  {
83
- $snippets = get_option( self::PLUGIN_OPTION_KEY );
84
  if (!empty($snippets)) {
85
  foreach ($snippets as $key => $value) {
86
  $new_snippets[$key]['title'] = trim($_POST[$key.'_title']);
87
  $new_snippets[$key]['vars'] = str_replace(' ', '', trim($_POST[$key.'_vars']) );
88
  $new_snippets[$key]['shortcode'] = isset($_POST[$key.'_shortcode']) ? true : false;
89
- $new_snippets[$key]['php'] = isset($_POST[$key.'_php']) ? true : false;
 
 
 
 
 
90
  $new_snippets[$key]['wptexturize'] = isset($_POST[$key.'_wptexturize']) ? true : false;
91
 
92
  $new_snippets[$key]['snippet'] = wp_specialchars_decode( trim(stripslashes($_POST[$key.'_snippet'])), ENT_NOQUOTES);
93
  $new_snippets[$key]['description'] = wp_specialchars_decode( trim(stripslashes($_POST[$key.'_description'])), ENT_NOQUOTES);
94
  }
95
- update_option( self::PLUGIN_OPTION_KEY, $new_snippets );
96
  $this->message( __( 'Snippets have been updated.', 'post-snippets' ) );
97
  }
98
  }
@@ -111,7 +116,7 @@ class Post_Snippets_Settings extends Post_Snippets_Base
111
  {
112
  $id = get_current_user_id();
113
  $render = isset( $_POST['render'] ) ? true : false;
114
- update_user_meta( $id, self::USER_OPTION_KEY, $render );
115
  }
116
  }
117
 
@@ -126,7 +131,7 @@ class Post_Snippets_Settings extends Post_Snippets_Base
126
  private function get_user_options()
127
  {
128
  $id = get_current_user_id();
129
- $options = get_user_meta( $id, self::USER_OPTION_KEY, true );
130
  return $options;
131
  }
132
 
@@ -239,7 +244,7 @@ class Post_Snippets_Settings extends Post_Snippets_Base
239
 
240
  <tbody>
241
  <?php
242
- $snippets = get_option( self::PLUGIN_OPTION_KEY );
243
  if (!empty($snippets)) {
244
  foreach ($snippets as $key => $snippet) {
245
  ?>
@@ -258,8 +263,10 @@ class Post_Snippets_Settings extends Post_Snippets_Base
258
 
259
  echo '<br/><strong>Shortcode Options:</strong><br/>';
260
 
261
- $this->checkbox(__('PHP Code', 'post-snippets'), $key.'_php',
262
- $snippet['php']);
 
 
263
 
264
  $wptexturize = isset( $snippet['wptexturize'] ) ? $snippet['wptexturize'] : false;
265
  $this->checkbox('wptexturize', $key.'_wptexturize', $wptexturize);
@@ -292,7 +299,7 @@ class Post_Snippets_Settings extends Post_Snippets_Base
292
  */
293
  private function tab_tools()
294
  {
295
- $ie = new Post_Snippets_ImportExport();
296
 
297
  // Create header and export html form
298
  printf( "<h3>%s</h3>", __( 'Import/Export', 'post-snippets' ));
@@ -339,7 +346,7 @@ class Post_Snippets_Settings extends Post_Snippets_Base
339
  echo '</form>';
340
 
341
  // Snippet List
342
- $snippets = get_option( self::PLUGIN_OPTION_KEY );
343
  if (!empty($snippets)) {
344
  foreach ($snippets as $key => $snippet) {
345
 
9
  * @author Johan Steen <artstorm at gmail dot com>
10
  * @since Post Snippets 1.8.8
11
  */
12
+ class PostSnippets_Admin
13
  {
14
  // -------------------------------------------------------------------------
15
  // Handle form submissions
24
  && isset( $_POST['update_snippets_nonce'])
25
  && wp_verify_nonce( $_POST['update_snippets_nonce'], 'update_snippets') )
26
  {
27
+ $snippets = get_option( PostSnippets::optionDBKey() );
28
  if (empty($snippets)) { $snippets = array(); }
29
 
30
  array_push($snippets, array (
37
  'snippet' => '')
38
  );
39
 
40
+ update_option( PostSnippets::optionDBKey(), $snippets );
41
  $this->message( __( 'A snippet named Untitled has been added.', 'post-snippets' ) );
42
  }
43
  }
51
  && isset( $_POST['update_snippets_nonce'])
52
  && wp_verify_nonce( $_POST['update_snippets_nonce'], 'update_snippets') )
53
  {
54
+ $snippets = get_option( PostSnippets::optionDBKey() );
55
 
56
  if ( empty($snippets) || !isset($_POST['checked']) ) {
57
  $this->message( __( 'Nothing selected to delete.', 'post-snippets' ) );
66
  }
67
  }
68
 
69
+ update_option( PostSnippets::optionDBKey(), $newsnippets );
70
  $this->message( __( 'Selected snippets have been deleted.', 'post-snippets' ) );
71
  }
72
  }
80
  && isset( $_POST['update_snippets_nonce'])
81
  && wp_verify_nonce( $_POST['update_snippets_nonce'], 'update_snippets') )
82
  {
83
+ $snippets = get_option( PostSnippets::optionDBKey() );
84
  if (!empty($snippets)) {
85
  foreach ($snippets as $key => $value) {
86
  $new_snippets[$key]['title'] = trim($_POST[$key.'_title']);
87
  $new_snippets[$key]['vars'] = str_replace(' ', '', trim($_POST[$key.'_vars']) );
88
  $new_snippets[$key]['shortcode'] = isset($_POST[$key.'_shortcode']) ? true : false;
89
+
90
+ if ( PostSnippets::canExecutePHP() )
91
+ $new_snippets[$key]['php'] = isset($_POST[$key.'_php']) ? true : false;
92
+ else
93
+ $new_snippets[$key]['php'] = isset($snippets[$key]['php']) ? $snippets[$key]['php'] : false;
94
+
95
  $new_snippets[$key]['wptexturize'] = isset($_POST[$key.'_wptexturize']) ? true : false;
96
 
97
  $new_snippets[$key]['snippet'] = wp_specialchars_decode( trim(stripslashes($_POST[$key.'_snippet'])), ENT_NOQUOTES);
98
  $new_snippets[$key]['description'] = wp_specialchars_decode( trim(stripslashes($_POST[$key.'_description'])), ENT_NOQUOTES);
99
  }
100
+ update_option( PostSnippets::optionDBKey(), $new_snippets );
101
  $this->message( __( 'Snippets have been updated.', 'post-snippets' ) );
102
  }
103
  }
116
  {
117
  $id = get_current_user_id();
118
  $render = isset( $_POST['render'] ) ? true : false;
119
+ update_user_meta( $id, PostSnippets::userMetaKey(), $render );
120
  }
121
  }
122
 
131
  private function get_user_options()
132
  {
133
  $id = get_current_user_id();
134
+ $options = get_user_meta( $id, PostSnippets::userMetaKey(), true );
135
  return $options;
136
  }
137
 
244
 
245
  <tbody>
246
  <?php
247
+ $snippets = get_option( PostSnippets::optionDBKey() );
248
  if (!empty($snippets)) {
249
  foreach ($snippets as $key => $snippet) {
250
  ?>
263
 
264
  echo '<br/><strong>Shortcode Options:</strong><br/>';
265
 
266
+ if ( PostSnippets::canExecutePHP() ) {
267
+ $this->checkbox(__('PHP Code', 'post-snippets'), $key.'_php',
268
+ $snippet['php']);
269
+ }
270
 
271
  $wptexturize = isset( $snippet['wptexturize'] ) ? $snippet['wptexturize'] : false;
272
  $this->checkbox('wptexturize', $key.'_wptexturize', $wptexturize);
299
  */
300
  private function tab_tools()
301
  {
302
+ $ie = new PostSnippets_ImportExport();
303
 
304
  // Create header and export html form
305
  printf( "<h3>%s</h3>", __( 'Import/Export', 'post-snippets' ));
346
  echo '</form>';
347
 
348
  // Snippet List
349
+ $snippets = get_option( PostSnippets::optionDBKey() );
350
  if (!empty($snippets)) {
351
  foreach ($snippets as $key => $snippet) {
352
 
classes/help.php → lib/PostSnippets/Help.php RENAMED
@@ -8,7 +8,7 @@
8
  * @author Johan Steen <artstorm at gmail dot com>
9
  * @since Post Snippets 1.8.9
10
  */
11
- class Post_Snippets_Help extends Post_Snippets_Base
12
  {
13
  /**
14
  * Constructor.
@@ -18,6 +18,7 @@ class Post_Snippets_Help extends Post_Snippets_Base
18
  */
19
  public function __construct( $option_page )
20
  {
 
21
  // If WordPress is 3.3 or higher, use the new Help API, otherwise call
22
  // the old contextual help action.
23
  global $wp_version;
@@ -46,11 +47,13 @@ class Post_Snippets_Help extends Post_Snippets_Base
46
  'title' => __( 'Shortcode', 'post-snippets' ),
47
  'content' => $this->help_shortcode()
48
  ) );
49
- $screen->add_help_tab( array(
50
- 'id' => 'php-plugin-help',
51
- 'title' => __( 'PHP', 'post-snippets' ),
52
- 'content' => $this->help_php()
53
- ) );
 
 
54
  $screen->add_help_tab( array(
55
  'id' => 'advanced-plugin-help',
56
  'title' => __( 'Advanced', 'post-snippets' ),
8
  * @author Johan Steen <artstorm at gmail dot com>
9
  * @since Post Snippets 1.8.9
10
  */
11
+ class PostSnippets_Help
12
  {
13
  /**
14
  * Constructor.
18
  */
19
  public function __construct( $option_page )
20
  {
21
+ // parent::__construct();
22
  // If WordPress is 3.3 or higher, use the new Help API, otherwise call
23
  // the old contextual help action.
24
  global $wp_version;
47
  'title' => __( 'Shortcode', 'post-snippets' ),
48
  'content' => $this->help_shortcode()
49
  ) );
50
+ if ( PostSnippets::canExecutePHP() ) {
51
+ $screen->add_help_tab( array(
52
+ 'id' => 'php-plugin-help',
53
+ 'title' => __( 'PHP', 'post-snippets' ),
54
+ 'content' => $this->help_php()
55
+ ) );
56
+ }
57
  $screen->add_help_tab( array(
58
  'id' => 'advanced-plugin-help',
59
  'title' => __( 'Advanced', 'post-snippets' ),
classes/import-export.php → lib/PostSnippets/ImportExport.php RENAMED
@@ -8,7 +8,7 @@
8
  * @author Johan Steen <artstorm at gmail dot com>
9
  * @since Post Snippets 2.0
10
  */
11
- class Post_Snippets_ImportExport extends Post_Snippets_Base
12
  {
13
  /**
14
  * Export Snippets.
@@ -52,7 +52,7 @@ class Post_Snippets_ImportExport extends Post_Snippets_Base
52
  * @return string URL to the exported snippets
53
  */
54
  private function create_export_file() {
55
- $snippets = serialize(get_option( self::PLUGIN_OPTION_KEY ));
56
  $snippets = apply_filters( 'post_snippets_export', $snippets );
57
  $dir = wp_upload_dir();
58
  $upload_dir = $dir['basedir'] . '/';
@@ -114,7 +114,7 @@ class Post_Snippets_ImportExport extends Post_Snippets_Base
114
  $snippets = file_get_contents( $upload_dir.'post-snippets-export.cfg' ); // Returns false on failure, else the contents
115
  if ($snippets) {
116
  $snippets = apply_filters( 'post_snippets_import', $snippets );
117
- update_option( self::PLUGIN_OPTION_KEY, unserialize($snippets));
118
  }
119
 
120
  // Delete the snippet file
8
  * @author Johan Steen <artstorm at gmail dot com>
9
  * @since Post Snippets 2.0
10
  */
11
+ class PostSnippets_ImportExport
12
  {
13
  /**
14
  * Export Snippets.
52
  * @return string URL to the exported snippets
53
  */
54
  private function create_export_file() {
55
+ $snippets = serialize(get_option( PostSnippets::optionDBKey() ));
56
  $snippets = apply_filters( 'post_snippets_export', $snippets );
57
  $dir = wp_upload_dir();
58
  $upload_dir = $dir['basedir'] . '/';
114
  $snippets = file_get_contents( $upload_dir.'post-snippets-export.cfg' ); // Returns false on failure, else the contents
115
  if ($snippets) {
116
  $snippets = apply_filters( 'post_snippets_import', $snippets );
117
+ update_option( PostSnippets::optionDBKey(), unserialize($snippets));
118
  }
119
 
120
  // Delete the snippet file
phpunit.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit
3
+ colors="true"
4
+ stopOnFailure="false"
5
+ bootstrap="unittest/bootstrap.php">
6
+ backupGlobals="false"
7
+ <testsuites>
8
+ <testsuite name="complete">
9
+ <directory>unittest</directory>
10
+ </testsuite>
11
+ </testsuites>
12
+ </phpunit>
post-snippets.php CHANGED
@@ -3,12 +3,13 @@
3
  Plugin Name: Post Snippets
4
  Plugin URI: http://wpstorm.net/wordpress-plugins/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
- Version: 2.0
7
  Author: Johan Steen
8
  Author URI: http://johansteen.se/
 
 
9
  Text Domain: post-snippets
10
 
11
- Copyright 2009-2012 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
@@ -25,37 +26,51 @@ along with this program; if not, write to the Free Software
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
28
- /**
29
- * Base Class.
30
- */
31
- class Post_Snippets_Base {
32
- // Constants
33
- const PLUGIN_OPTION_KEY = 'post_snippets_options';
34
- const USER_OPTION_KEY = 'post_snippets';
35
- }
36
 
37
  /**
38
- * Plugin Main Class.
 
 
 
39
  */
40
- class Post_Snippets extends Post_Snippets_Base
41
  {
42
- // Constants
43
- const TINYMCE_PLUGIN_NAME = 'post_snippets';
44
 
45
- // -------------------------------------------------------------------------
 
 
 
46
 
47
- public function __construct() {
48
- // Define the domain and path for translations
49
- $rel_path = dirname(plugin_basename($this->get_File())).'/languages/';
50
- load_plugin_textdomain( 'post-snippets', false, $rel_path );
51
 
52
- $this->init_hooks();
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
- /**
56
- * Initializes the hooks for the plugin
57
- */
58
- function init_hooks() {
59
 
60
  // Add TinyMCE button
61
  add_action('init', array(&$this, 'add_tinymce_button') );
@@ -88,6 +103,70 @@ class Post_Snippets extends Post_Snippets_Base
88
  }
89
  }
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
  /**
93
  * Quick link to the Post Snippets Settings page from the Plugins page.
@@ -95,7 +174,7 @@ class Post_Snippets extends Post_Snippets_Base
95
  * @return Array with all the plugin's action links
96
  */
97
  function plugin_action_links( $links, $file ) {
98
- if ( $file == plugin_basename( dirname($this->get_FILE()).'/post-snippets.php' ) ) {
99
  $links[] = '<a href="options-general.php?page=post-snippets/post-snippets.php">'.__('Settings', 'post-snippets').'</a>';
100
  }
101
  return $links;
@@ -113,7 +192,7 @@ class Post_Snippets extends Post_Snippets_Base
113
  wp_enqueue_style( 'wp-jquery-ui-dialog' );
114
 
115
  # Adds the CSS stylesheet for the jQuery UI dialog
116
- $style_url = plugins_url( '/assets/post-snippets.css', $this->get_FILE() );
117
  wp_register_style( 'post-snippets', $style_url, false, '2.0' );
118
  wp_enqueue_style( 'post-snippets' );
119
  }
@@ -183,7 +262,7 @@ class Post_Snippets extends Post_Snippets_Base
183
  {
184
  // Load the TinyMCE plugin, editor_plugin.js, into the array
185
  $plugins[self::TINYMCE_PLUGIN_NAME] =
186
- plugins_url('/tinymce/editor_plugin.js?ver=1.9', $this->get_FILE());
187
 
188
  return $plugins;
189
  }
@@ -282,7 +361,7 @@ class Post_Snippets extends Post_Snippets_Base
282
  # Prepare the snippets and shortcodes into javascript variables
283
  # so they can be inserted into the editor, and get the variables replaced
284
  # with user defined strings.
285
- $snippets = get_option( self::PLUGIN_OPTION_KEY );
286
  foreach ($snippets as $key => $snippet) {
287
  if ($snippet['shortcode']) {
288
  # Build a long string of the variables, ie: varname1={varname1} varname2={varname2}
@@ -431,7 +510,7 @@ function edOpenPostSnippets(myField) {
431
  echo "\t\t\t<ul>\n";
432
 
433
  // Create a tab for each available snippet
434
- $snippets = get_option( self::PLUGIN_OPTION_KEY );
435
  foreach ($snippets as $key => $snippet) {
436
  echo "\t\t\t\t";
437
  echo "<li><a href=\"#ps-tabs-{$key}\">{$snippet['title']}</a></li>";
@@ -512,19 +591,21 @@ function edOpenPostSnippets(myField) {
512
  * Create the functions for shortcodes dynamically and register them
513
  */
514
  function create_shortcodes() {
515
- $snippets = get_option( self::PLUGIN_OPTION_KEY );
516
  if (!empty($snippets)) {
517
  foreach ($snippets as $snippet) {
518
  // If shortcode is enabled for the snippet, and a snippet has been entered, register it as a shortcode.
519
  if ( $snippet['shortcode'] && !empty($snippet['snippet']) ) {
520
 
521
  $vars = explode(",",$snippet['vars']);
522
- $vars_str = '';
523
  foreach ($vars as $var) {
524
- $vars_str = $vars_str . '"'.$var.'" => "",';
 
 
525
  }
526
 
527
- // Get the wptexturize setting
528
  $texturize = isset( $snippet["wptexturize"] ) ? $snippet["wptexturize"] : false;
529
 
530
  add_shortcode($snippet['title'], create_function('$atts,$content=null',
@@ -575,6 +656,9 @@ function edOpenPostSnippets(myField) {
575
  */
576
  public static function php_eval( $content )
577
  {
 
 
 
578
  $content = stripslashes($content);
579
 
580
  ob_start();
@@ -595,13 +679,13 @@ function edOpenPostSnippets(myField) {
595
  function wp_admin() {
596
  if ( current_user_can('manage_options') ) {
597
  // If user can manage options, display the admin page
598
- $option_page = add_options_page( 'Post Snippets Options', 'Post Snippets', 'administrator', $this->get_FILE(), array(&$this, 'options_page') );
599
- if ( $option_page and class_exists('Post_Snippets_Help') ) {
600
- $help = new Post_Snippets_Help( $option_page );
601
  }
602
  } else {
603
  // If user can't manage options, but can edit posts, display the overview page
604
- $option_page = add_options_page( 'Post Snippets', 'Post Snippets', 'edit_posts', $this->get_FILE(), array(&$this, 'overview_page') );
605
  }
606
  }
607
 
@@ -615,7 +699,7 @@ function edOpenPostSnippets(myField) {
615
  */
616
  public function overview_page()
617
  {
618
- $settings = new Post_Snippets_Settings();
619
  $settings->render( 'overview' );
620
  }
621
 
@@ -626,7 +710,7 @@ function edOpenPostSnippets(myField) {
626
  */
627
  public function options_page()
628
  {
629
- $settings = new Post_Snippets_Settings();
630
  $settings->render( 'options' );
631
  }
632
 
@@ -635,31 +719,6 @@ function edOpenPostSnippets(myField) {
635
  // Helpers
636
  // -------------------------------------------------------------------------
637
 
638
- /**
639
- * Get __FILE__ with no symlinks.
640
- *
641
- * For development purposes mainly. Returns __FILE__ without resolved
642
- * symlinks to be used when __FILE__ is needed while resolving symlinks
643
- * breaks WP functionaly, so the actual WordPress path is returned instead.
644
- * This makes it possible for all WordPress versions to point to the same
645
- * plugin folder for faster testing of the plugin in different WordPress
646
- * versions.
647
- *
648
- * @since Post Snippets 1.9
649
- * @return The __FILE__ constant without resolved symlinks.
650
- */
651
- private function get_FILE()
652
- {
653
- $dev_path = 'E:\Code\WordPress';
654
- $result = strpos( __FILE__, $dev_path );
655
-
656
- if ( $result === false ) {
657
- return __FILE__;
658
- } else {
659
- return str_replace($dev_path, WP_PLUGIN_DIR, __FILE__);
660
- }
661
- }
662
-
663
  /**
664
  * Allow snippets to be retrieved directly from PHP.
665
  *
@@ -672,9 +731,9 @@ function edOpenPostSnippets(myField) {
672
  * @return string
673
  * The Snippet
674
  */
675
- public function get_snippet( $snippet_name, $snippet_vars = '' )
676
  {
677
- $snippets = get_option( self::PLUGIN_OPTION_KEY );
678
  for ($i = 0; $i < count($snippets); $i++) {
679
  if ($snippets[$i]['title'] == $snippet_name) {
680
  parse_str( htmlspecialchars_decode($snippet_vars), $snippet_output );
@@ -688,103 +747,84 @@ function edOpenPostSnippets(myField) {
688
  }
689
  }
690
  }
691
- return $snippet;
692
  }
693
- }
694
-
695
 
696
- // -----------------------------------------------------------------------------
697
- // Start the plugin
698
- // -----------------------------------------------------------------------------
699
-
700
- // Check the host environment
701
- $test_post_snippets_host = new Post_Snippets_Host_Environment();
702
-
703
- // If environment is up to date, start the plugin
704
- if($test_post_snippets_host->passed) {
705
- // Load external classes
706
- if (is_admin()) {
707
- require plugin_dir_path(__FILE__).'classes/settings.php';
708
- require plugin_dir_path(__FILE__).'classes/help.php';
709
- require plugin_dir_path(__FILE__).'classes/import-export.php';
710
  }
711
 
712
- add_action(
713
- 'plugins_loaded',
714
- create_function(
715
- '',
716
- 'global $post_snippets; $post_snippets = new Post_Snippets();'
717
- )
718
- );
719
- }
720
-
721
-
722
- /**
723
- * Post Snippets Host Environment.
724
- *
725
- * Checks that the host environment fulfils the requirements of Post Snippets.
726
- * This class is designed to work with PHP versions below 5, to make sure it's
727
- * always executed.
728
- *
729
- * - PHP Version 5.2.4 is on par with the requirements for WordPress 3.3.
730
- *
731
- * @since Post Snippets 1.8.8
732
- */
733
- class Post_Snippets_Host_Environment
734
- {
735
- // Minimum versions required
736
- var $MIN_PHP_VERSION = '5.2.4';
737
- var $MIN_WP_VERSION = '3.0';
738
- var $passed = true;
739
 
740
  /**
741
- * Constructor.
742
  *
743
- * Checks PHP and WordPress versions. If any check failes, a system notice
744
- * is added and $passed is set to fail, which can be checked before trying
745
- * to create the main class.
746
  */
747
- function Post_Snippets_Host_Environment()
748
  {
749
- // Check if PHP is too old
750
- if (version_compare(PHP_VERSION, $this->MIN_PHP_VERSION, '<')) {
751
- // Display notice
752
- add_action( 'admin_notices', array(&$this, 'php_version_error') );
753
- $this->passed = false;
754
- }
755
-
756
- // Check if WordPress is too old
757
- global $wp_version;
758
- if ( version_compare($wp_version, $this->MIN_WP_VERSION, '<') ) {
759
- add_action( 'admin_notices', array(&$this, 'wp_version_error') );
760
- $this->passed = false;
761
- }
762
  }
763
 
764
- /**
765
- * Displays a warning when installed on an old PHP version.
766
- */
767
- function php_version_error() {
768
- echo '<div class="error"><p><strong>';
769
- printf(
770
- 'Error: Post Snippets requires PHP version %1$s or greater.<br/>'.
771
- 'Your installed PHP version: %2$s',
772
- $this->MIN_PHP_VERSION, PHP_VERSION);
773
- echo '</strong></p></div>';
774
- }
775
 
776
- /**
777
- * Displays a warning when installed in an old Wordpress version.
778
- */
779
- function wp_version_error() {
780
- echo '<div class="error"><p><strong>';
781
- printf(
782
- 'Error: Post Snippets requires WordPress version %s or greater.',
783
- $this->MIN_WP_VERSION );
784
- echo '</strong></p></div>';
785
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
786
  }
787
 
 
 
788
  // -----------------------------------------------------------------------------
789
  // Helper functions
790
  // -----------------------------------------------------------------------------
@@ -794,6 +834,7 @@ class Post_Snippets_Host_Environment
794
  * This function is a wrapper for Post_Snippets::get_snippet().
795
  *
796
  * @since Post Snippets 1.6
 
797
  *
798
  * @param string $snippet_name
799
  * The name of the snippet to retrieve
@@ -802,7 +843,8 @@ class Post_Snippets_Host_Environment
802
  * @return string
803
  * The Snippet
804
  */
805
- function get_post_snippet( $snippet_name, $snippet_vars = '' ) {
806
- global $post_snippets;
807
- return $post_snippets->get_snippet( $snippet_name, $snippet_vars );
 
808
  }
3
  Plugin Name: Post Snippets
4
  Plugin URI: http://wpstorm.net/wordpress-plugins/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: http://johansteen.se/
8
+ Version: 2.1
9
+ License: GPLv2 or later
10
  Text Domain: post-snippets
11
 
12
+ Copyright 2009-2013 Johan Steen (email : artstorm [at] gmail [dot] com)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
26
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
 
29
+ /** Load all of the necessary class files for the plugin */
30
+ spl_autoload_register('PostSnippets::autoload');
 
 
 
 
 
 
31
 
32
  /**
33
+ * Init Singleton Class for Post Snippets.
34
+ *
35
+ * @package Post Snippets
36
+ * @author Johan Steen <artstorm at gmail dot com>
37
  */
38
+ class PostSnippets
39
  {
40
+ private static $instance = false;
 
41
 
42
+ const MIN_PHP_VERSION = '5.2.4';
43
+ const MIN_WP_VERSION = '3.0';
44
+ const OPTION_DB_KEY = 'post_snippets_options';
45
+ const USER_META_KEY = 'post_snippets';
46
 
47
+ // Constants
48
+ const TINYMCE_PLUGIN_NAME = 'post_snippets';
 
 
49
 
50
+ /**
51
+ * Singleton class
52
+ */
53
+ public static function getInstance()
54
+ {
55
+ if (!self::$instance) {
56
+ self::$instance = new self();
57
+ }
58
+ return self::$instance;
59
+ }
60
+
61
+ /**
62
+ * Constructor.
63
+ * Initializes the plugin by setting localization, filters, and
64
+ * administration functions.
65
+ */
66
+ private function __construct()
67
+ {
68
+ if (!$this->testHost()) {
69
+ return;
70
+ }
71
 
72
+ add_action('init', array($this, 'textDomain'));
73
+ register_uninstall_hook(__FILE__, array(__CLASS__, 'uninstall'));
 
 
74
 
75
  // Add TinyMCE button
76
  add_action('init', array(&$this, 'add_tinymce_button') );
103
  }
104
  }
105
 
106
+ /**
107
+ * PSR-0 compliant autoloader to load classes as needed.
108
+ *
109
+ * @since 2.1
110
+ *
111
+ * @param string $classname The name of the class
112
+ * @return null Return early if the class name does not start with the
113
+ * correct prefix
114
+ */
115
+ public static function autoload($className)
116
+ {
117
+ if ('PostSnippets' !== mb_substr($className, 0, 12)) {
118
+ return;
119
+ }
120
+ $className = ltrim($className, '\\');
121
+ $fileName = '';
122
+ $namespace = '';
123
+ if ($lastNsPos = strrpos($className, '\\')) {
124
+ $namespace = substr($className, 0, $lastNsPos);
125
+ $className = substr($className, $lastNsPos + 1);
126
+ $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
127
+ $fileName .= DIRECTORY_SEPARATOR;
128
+ }
129
+ $fileName .= str_replace('_', DIRECTORY_SEPARATOR, 'lib_'.$className);
130
+ $fileName .='.php';
131
+
132
+ require $fileName;
133
+ }
134
+
135
+ /**
136
+ * Loads the text domain for translation
137
+ */
138
+ public function textDomain()
139
+ {
140
+ $domain = 'post-snippets';
141
+ $locale = apply_filters('plugin_locale', get_locale(), $domain);
142
+ load_textdomain(
143
+ $domain,
144
+ WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo'
145
+ );
146
+ load_plugin_textdomain(
147
+ $domain,
148
+ false,
149
+ dirname(plugin_basename(__FILE__)).'/lang/'
150
+ );
151
+ }
152
+
153
+ /**
154
+ * Fired when the plugin is uninstalled.
155
+ */
156
+ public function uninstall()
157
+ {
158
+ // Delete all snippets
159
+ delete_option('post_snippets_options');
160
+
161
+ // Delete any per user settings
162
+ global $wpdb;
163
+ $wpdb->query(
164
+ "
165
+ DELETE FROM $wpdb->usermeta
166
+ WHERE meta_key = 'post_snippets'
167
+ "
168
+ );
169
+ }
170
 
171
  /**
172
  * Quick link to the Post Snippets Settings page from the Plugins page.
174
  * @return Array with all the plugin's action links
175
  */
176
  function plugin_action_links( $links, $file ) {
177
+ if ( $file == plugin_basename( dirname(__FILE__).'/post-snippets.php' ) ) {
178
  $links[] = '<a href="options-general.php?page=post-snippets/post-snippets.php">'.__('Settings', 'post-snippets').'</a>';
179
  }
180
  return $links;
192
  wp_enqueue_style( 'wp-jquery-ui-dialog' );
193
 
194
  # Adds the CSS stylesheet for the jQuery UI dialog
195
+ $style_url = plugins_url( '/assets/post-snippets.css', __FILE__ );
196
  wp_register_style( 'post-snippets', $style_url, false, '2.0' );
197
  wp_enqueue_style( 'post-snippets' );
198
  }
262
  {
263
  // Load the TinyMCE plugin, editor_plugin.js, into the array
264
  $plugins[self::TINYMCE_PLUGIN_NAME] =
265
+ plugins_url('/tinymce/editor_plugin.js?ver=1.9', __FILE__);
266
 
267
  return $plugins;
268
  }
361
  # Prepare the snippets and shortcodes into javascript variables
362
  # so they can be inserted into the editor, and get the variables replaced
363
  # with user defined strings.
364
+ $snippets = get_option( self::OPTION_DB_KEY );
365
  foreach ($snippets as $key => $snippet) {
366
  if ($snippet['shortcode']) {
367
  # Build a long string of the variables, ie: varname1={varname1} varname2={varname2}
510
  echo "\t\t\t<ul>\n";
511
 
512
  // Create a tab for each available snippet
513
+ $snippets = get_option( self::OPTION_DB_KEY );
514
  foreach ($snippets as $key => $snippet) {
515
  echo "\t\t\t\t";
516
  echo "<li><a href=\"#ps-tabs-{$key}\">{$snippet['title']}</a></li>";
591
  * Create the functions for shortcodes dynamically and register them
592
  */
593
  function create_shortcodes() {
594
+ $snippets = get_option( self::OPTION_DB_KEY );
595
  if (!empty($snippets)) {
596
  foreach ($snippets as $snippet) {
597
  // If shortcode is enabled for the snippet, and a snippet has been entered, register it as a shortcode.
598
  if ( $snippet['shortcode'] && !empty($snippet['snippet']) ) {
599
 
600
  $vars = explode(",",$snippet['vars']);
601
+ $vars_str = "";
602
  foreach ($vars as $var) {
603
+ $attribute = explode('=', $var);
604
+ $default_value = (count($attribute) > 1) ? $attribute[1] : '';
605
+ $vars_str .= "\"{$attribute[0]}\" => \"{$default_value}\",";
606
  }
607
 
608
+ // Get the wptexturize setting
609
  $texturize = isset( $snippet["wptexturize"] ) ? $snippet["wptexturize"] : false;
610
 
611
  add_shortcode($snippet['title'], create_function('$atts,$content=null',
656
  */
657
  public static function php_eval( $content )
658
  {
659
+ if ( !self::canExecutePHP() )
660
+ return $content;
661
+
662
  $content = stripslashes($content);
663
 
664
  ob_start();
679
  function wp_admin() {
680
  if ( current_user_can('manage_options') ) {
681
  // If user can manage options, display the admin page
682
+ $option_page = add_options_page( 'Post Snippets Options', 'Post Snippets', 'administrator', __FILE__, array(&$this, 'options_page') );
683
+ if ( $option_page and class_exists('PostSnippets_Help') ) {
684
+ $help = new PostSnippets_Help( $option_page );
685
  }
686
  } else {
687
  // If user can't manage options, but can edit posts, display the overview page
688
+ $option_page = add_options_page( 'Post Snippets', 'Post Snippets', 'edit_posts', __FILE__, array(&$this, 'overview_page') );
689
  }
690
  }
691
 
699
  */
700
  public function overview_page()
701
  {
702
+ $settings = new PostSnippets_Admin();
703
  $settings->render( 'overview' );
704
  }
705
 
710
  */
711
  public function options_page()
712
  {
713
+ $settings = new PostSnippets_Admin();
714
  $settings->render( 'options' );
715
  }
716
 
719
  // Helpers
720
  // -------------------------------------------------------------------------
721
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
722
  /**
723
  * Allow snippets to be retrieved directly from PHP.
724
  *
731
  * @return string
732
  * The Snippet
733
  */
734
+ public static function getSnippet( $snippet_name, $snippet_vars = '' )
735
  {
736
+ $snippets = get_option( self::OPTION_DB_KEY );
737
  for ($i = 0; $i < count($snippets); $i++) {
738
  if ($snippets[$i]['title'] == $snippet_name) {
739
  parse_str( htmlspecialchars_decode($snippet_vars), $snippet_output );
747
  }
748
  }
749
  }
750
+ return do_shortcode($snippet);
751
  }
 
 
752
 
753
+ public static function optionDBKey()
754
+ {
755
+ return self::OPTION_DB_KEY;
 
 
 
 
 
 
 
 
 
 
 
756
  }
757
 
758
+ public static function userMetaKey()
759
+ {
760
+ return self::USER_META_KEY;
761
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
762
 
763
  /**
764
+ * Allow other plugins to disable the PHP Code execution feature.
765
  *
766
+ * @see http://wordpress.org/extend/plugins/post-snippets/faq/
767
+ * @since 2.1
 
768
  */
769
+ public static function canExecutePHP()
770
  {
771
+ return apply_filters('post_snippets_php_execution_enabled', true);
 
 
 
 
 
 
 
 
 
 
 
 
772
  }
773
 
 
 
 
 
 
 
 
 
 
 
 
774
 
775
+ // -------------------------------------------------------------------------
776
+ // Environment Checks
777
+ // -------------------------------------------------------------------------
778
+
779
+ /**
780
+ * Checks PHP and WordPress versions.
781
+ */
782
+ private function testHost()
783
+ {
784
+ // Check if PHP is too old
785
+ if (version_compare(PHP_VERSION, self::MIN_PHP_VERSION, '<')) {
786
+ // Display notice
787
+ add_action( 'admin_notices', array(&$this, 'phpVersionError') );
788
+ return false;
789
+ }
790
+
791
+ // Check if WordPress is too old
792
+ global $wp_version;
793
+ if (version_compare($wp_version, self::MIN_WP_VERSION, '<')) {
794
+ add_action( 'admin_notices', array(&$this, 'wpVersionError') );
795
+ return false;
796
+ }
797
+ return true;
798
+ }
799
+
800
+ /**
801
+ * Displays a warning when installed on an old PHP version.
802
+ */
803
+ public function phpVersionError()
804
+ {
805
+ echo '<div class="error"><p><strong>';
806
+ printf(
807
+ 'Error: Post Snippets requires PHP version %1$s or greater.<br/>'.
808
+ 'Your installed PHP version: %2$s',
809
+ self::MIN_PHP_VERSION, PHP_VERSION);
810
+ echo '</strong></p></div>';
811
+ }
812
+
813
+ /**
814
+ * Displays a warning when installed in an old Wordpress version.
815
+ */
816
+ public function wpVersionError()
817
+ {
818
+ echo '<div class="error"><p><strong>';
819
+ printf(
820
+ 'Error: Post Snippets requires WordPress version %s or greater.',
821
+ self::MIN_WP_VERSION );
822
+ echo '</strong></p></div>';
823
+ }
824
  }
825
 
826
+ add_action('plugins_loaded', array('PostSnippets', 'getInstance'));
827
+
828
  // -----------------------------------------------------------------------------
829
  // Helper functions
830
  // -----------------------------------------------------------------------------
834
  * This function is a wrapper for Post_Snippets::get_snippet().
835
  *
836
  * @since Post Snippets 1.6
837
+ * @deprecated Post Snippets 2.1
838
  *
839
  * @param string $snippet_name
840
  * The name of the snippet to retrieve
843
  * @return string
844
  * The Snippet
845
  */
846
+ function get_post_snippet($snippet_name, $snippet_vars = '')
847
+ {
848
+ _deprecated_function(__FUNCTION__, '2.1', 'PostSnippets::getSnippet()');
849
+ return PostSnippets::getSnippet($snippet_name, $snippet_vars);
850
  }
readme.txt CHANGED
@@ -1,9 +1,11 @@
1
- === Post Snippets ===
2
  Contributors: artstorm
3
  Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
4
  Requires at least: 3.0
5
- Tested up to: 3.3.1
6
- Stable tag: 2.0
 
 
7
 
8
  Keep a snippet library of text, HTML or PHP code to be used in posts. Variables
9
  can be set for more flexibility. Inserts directly or as shortcodes.
@@ -39,6 +41,8 @@ updating the snippet. PHP code is supported for snippets inserted as shortcodes.
39
  "Complete usage instructions")
40
  * [Support Forum](http://wordpress.org/tags/post-snippets?forum_id=10
41
  "Use this for support and feature requests")
 
 
42
 
43
  See the [Changelog](http://wordpress.org/extend/plugins/post-snippets/changelog/)
44
  for what's new. Available [Translations](http://wpstorm.net/wordpress-plugins/post-snippets/#translations).
@@ -79,11 +83,32 @@ Example: `[shortcode]Some text[/shortcode]` the text within will be availble in
79
  a variable called content. So in your snippet use {content} to display it. Don't
80
  enter 'content' in the variable field, it's automatically assigned.
81
 
 
 
 
 
 
 
82
  = Where can I get support? =
83
 
84
  Please visit the [Support Forum](http://wordpress.org/tags/post-snippets?forum_id=10 "Use this for support and feature requests")
85
  for questions, answers, support and feature requests.
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  == Screenshots ==
88
 
89
  1. The Admin page where you create and manage snippets.
@@ -94,6 +119,23 @@ for questions, answers, support and feature requests.
94
 
95
  == Changelog ==
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  = Version 2.0 - 29 Mar 2012 =
98
  * Added tabs to the Admin page, and moved Import/Export to a separate tab.
99
  * Pressing enter in a text field now defaults to Update and not Add.
@@ -344,4 +386,13 @@ for questions, answers, support and feature requests.
344
 
345
  = 1.9 =
346
  Note that starting with this version and moving forward, at least PHP v5.2.4 is
347
- required to run Post Snippets.
 
 
 
 
 
 
 
 
 
1
+ === Post Snippets ===
2
  Contributors: artstorm
3
  Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
4
  Requires at least: 3.0
5
+ Tested up to: 3.5.1
6
+ Stable tag: 2.1
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
  Keep a snippet library of text, HTML or PHP code to be used in posts. Variables
11
  can be set for more flexibility. Inserts directly or as shortcodes.
41
  "Complete usage instructions")
42
  * [Support Forum](http://wordpress.org/tags/post-snippets?forum_id=10
43
  "Use this for support and feature requests")
44
+ * [GitHub](https://github.com/artstorm/post-snippets
45
+ "Develop and contribute your code or report bugs")
46
 
47
  See the [Changelog](http://wordpress.org/extend/plugins/post-snippets/changelog/)
48
  for what's new. Available [Translations](http://wpstorm.net/wordpress-plugins/post-snippets/#translations).
83
  a variable called content. So in your snippet use {content} to display it. Don't
84
  enter 'content' in the variable field, it's automatically assigned.
85
 
86
+ = Where can I send bug reports? =
87
+
88
+ Please visit the GitHub repository for [Post Snippet](https://github.com/artstorm/post-snippets)
89
+ and open an [issue](https://github.com/artstorm/post-snippets/issues).
90
+ Please create an issue that conforms with [necolas's guidelines](https://github.com/necolas/issue-guidelines).
91
+
92
  = Where can I get support? =
93
 
94
  Please visit the [Support Forum](http://wordpress.org/tags/post-snippets?forum_id=10 "Use this for support and feature requests")
95
  for questions, answers, support and feature requests.
96
 
97
+ = How can I disable the PHP Code Execution feature? =
98
+
99
+ To disable the "PHP Code" execution feature in this plugin, add the following code your theme's functions.php file:
100
+ `add_filter('post_snippets_php_execution_enabled', '__return_false');`
101
+
102
+ This is useful if you are using this plugin for client sites, and don't want your clients to be able to use PHP code in a post snippet.
103
+
104
+ = How can I contribute to the plugin? =
105
+
106
+ If you want to contribute improved code or new features for the plugin. Please
107
+ open a pull request at the [Post Snippets GitHub repository](https://github.com/artstorm/post-snippets).
108
+ Please open a pull request that conforms with [necolas's guidelines](https://github.com/necolas/issue-guidelines).
109
+ Contributions are appreciated and encouraged.
110
+
111
+
112
  == Screenshots ==
113
 
114
  1. The Admin page where you create and manage snippets.
119
 
120
  == Changelog ==
121
 
122
+ = Version 2.1 - 22 Feb 2013 =
123
+ * Default values are now respected as shortcode defaults and not only to
124
+ populate the insert window's fields.
125
+ * Allow other plugins or themes to disable the PHP Code execution feature using
126
+ the new `post_snippets_php_execution_enabled` filter.
127
+ * `PostSnippets::getSnippet()` now executes shortcodes within snippets.
128
+ * The function `get_post_snippet()` used to retrieve snippets from other
129
+ places in WordPress has been deprecated. Please update any code using this
130
+ function to use `PostSnippets::getSnippet()` instead, which replaces the old
131
+ function. `get_post_snippet()` will be removed in a future version. Most
132
+ users are not affected by this change.
133
+ * Refactored code to comply with the PSR-0 standard.
134
+ * Migrated to GitHub to maintain the code in development.
135
+ [Post Snippets at GitHub](https://github.com/artstorm/post-snippets).
136
+ * Included Polish translation (pl_PL) by Tomasz Wesołowski.
137
+ * Included Slovak translation (sk_SK) by Branco Radenovich.
138
+
139
  = Version 2.0 - 29 Mar 2012 =
140
  * Added tabs to the Admin page, and moved Import/Export to a separate tab.
141
  * Pressing enter in a text field now defaults to Update and not Add.
386
 
387
  = 1.9 =
388
  Note that starting with this version and moving forward, at least PHP v5.2.4 is
389
+ required to run Post Snippets.
390
+
391
+ = 2.1 =
392
+ The function `get_post_snippet()` used to retrieve snippets from other places in
393
+ WordPress has been deprecated. Please update any code you might have modified
394
+ that uses this function to use `PostSnippets::getSnippet()` instead, which
395
+ replaces the old function. `get_post_snippet()` will be removed in a future
396
+ version.
397
+
398
+ Most users are not affected by this change.
tests/phpunit.xml DELETED
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
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>
9
- </testsuite>
10
- </testsuites>
11
- </phpunit>
 
 
 
 
 
 
 
 
 
 
 
tests/post-snippets-test.php DELETED
@@ -1,85 +0,0 @@
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
- *
12
- * Unit testing for the Post Snippets WordPress plugin. The test class extends
13
- * WP_UnitTestCase from Nikolay Bachiyski's WordPress-Tests package.
14
- *
15
- * @package Post Snippets
16
- * @author Johan Steen <artstorm at gmail dot com>
17
- * @since Post Snippets 1.8.8
18
- * @see https://github.com/nb/wordpress-tests
19
- */
20
- class Post_Snippets_Test extends WP_UnitTestCase {
21
-
22
- // protected $post_snippets;
23
- public $plugin_slug = 'post-snippets';
24
-
25
- /**
26
- * setUp runs before each test to create a Fixture.
27
- *
28
- * The method should have protected access, but because WP_UnitTestCase
29
- * doesn't define it that way we'll stick with public.
30
- */
31
- public function setUp() {
32
- parent::setUp();
33
- // $this->post_snippets = new Post_Snippets();
34
- global $post_snippets; $post_snippets = new Post_Snippets();
35
-
36
- $snippets = array();
37
- array_push($snippets, array(
38
- 'title' => "TestTmp",
39
- 'vars' => "",
40
- 'description' => "",
41
- 'shortcode' => false,
42
- 'php' => false,
43
- 'snippet' => "A test snippet..."));
44
- update_option('post_snippets_options', $snippets);
45
- }
46
-
47
-
48
- // -------------------------------------------------------------------------
49
- // Tests
50
- // -------------------------------------------------------------------------
51
-
52
- public function test_Yo()
53
- {
54
- $this->assertTrue(true);
55
- }
56
-
57
- public function test_Yos()
58
- {
59
- $this->assertTrue(true);
60
- }
61
-
62
- /**
63
- * @dataProvider provider
64
- */
65
- public function test_data_inline($a, $b, $c)
66
- {
67
- // var_dump($c);
68
- }
69
- public function provider()
70
- {
71
- return array(
72
- array(0, 0, 0),
73
- array(0, 1, 1),
74
- array(1, 0, 1),
75
- array(1, 1, 3)
76
- );
77
- }
78
-
79
- public function test_get_post_snippet()
80
- {
81
- $test = get_post_snippet('TestTmp');
82
- $this->assertTrue(is_string($test));
83
- $this->assertEquals($test, 'A test snippet...');
84
- }
85
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tinymce/editor_plugin.js CHANGED
@@ -1,54 +1,54 @@
1
- // Docu : http://www.tinymce.com/wiki.php/API3:tinymce.api.3.x
2
-
3
- (function() {
4
- // Load plugin specific language pack
5
- tinymce.PluginManager.requireLangPack('post_snippets');
6
-
7
- tinymce.create('tinymce.plugins.post_snippets', {
8
- /**
9
- * Initializes the plugin, this will be executed after the plugin has been created.
10
- * This call is done before the editor instance has finished it's initialization so use the onInit event
11
- * of the editor instance to intercept that event.
12
- *
13
- * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
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
- },
32
-
33
- /**
34
- * Returns information about the plugin as a name/value array.
35
- * The current keys are longname, author, authorurl, infourl and version.
36
- *
37
- * @return {Object} Name/value array containing information about the plugin.
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
- });
49
-
50
- // Register plugin
51
- tinymce.PluginManager.add('post_snippets', tinymce.plugins.post_snippets);
52
- })();
53
-
54
-
1
+ // Docu : http://www.tinymce.com/wiki.php/API3:tinymce.api.3.x
2
+
3
+ (function() {
4
+ // Load plugin specific language pack
5
+ tinymce.PluginManager.requireLangPack('post_snippets');
6
+
7
+ tinymce.create('tinymce.plugins.post_snippets', {
8
+ /**
9
+ * Initializes the plugin, this will be executed after the plugin has been created.
10
+ * This call is done before the editor instance has finished it's initialization so use the onInit event
11
+ * of the editor instance to intercept that event.
12
+ *
13
+ * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
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
+ },
32
+
33
+ /**
34
+ * Returns information about the plugin as a name/value array.
35
+ * The current keys are longname, author, authorurl, infourl and version.
36
+ *
37
+ * @return {Object} Name/value array containing information about the plugin.
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
+ });
49
+
50
+ // Register plugin
51
+ tinymce.PluginManager.add('post_snippets', tinymce.plugins.post_snippets);
52
+ })();
53
+
54
+
tinymce/langs/en.js CHANGED
@@ -1,4 +1,4 @@
1
- tinyMCE.addI18n({en:{
2
- post_snippets:{
3
- desc : 'Insert a Post Snippet'
4
- }}});
1
+ tinyMCE.addI18n({en:{
2
+ post_snippets:{
3
+ desc : 'Insert a Post Snippet'
4
+ }}});
tinymce/langs/en_US.js CHANGED
@@ -1,4 +1,4 @@
1
- tinyMCE.addI18n({en_US:{
2
- post_snippets:{
3
- desc : 'Insert a Post Snippet'
4
  }}});
1
+ tinyMCE.addI18n({en_US:{
2
+ post_snippets:{
3
+ desc : 'Insert a Post Snippet'
4
  }}});
tinymce/langs/en_en.js CHANGED
@@ -1,4 +1,4 @@
1
- tinyMCE.addI18n({en_US:{
2
- post_snippets:{
3
- desc : 'Insert a Post Snippet'
4
  }}});
1
+ tinyMCE.addI18n({en_US:{
2
+ post_snippets:{
3
+ desc : 'Insert a Post Snippet'
4
  }}});
uninstall.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- /**
3
- * Uninstall.
4
- * Clean up the WP DB by deleting the options created by the plugin.
5
- */
6
- function post_snippets_uninstall()
7
- {
8
- // Delete all snippets
9
- delete_option('post_snippets_options');
10
-
11
- // Delete any per user settings
12
- global $wpdb;
13
- $wpdb->query(
14
- "
15
- DELETE FROM $wpdb->usermeta
16
- WHERE meta_key = 'post_snippets'
17
- "
18
- );
19
- }
20
-
21
- post_snippets_uninstall();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
unittest/PostSnippetsTest.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Post Snippets Unit Tests.
4
+ */
5
+ class PostSnippetsTest extends WP_UnitTestCase {
6
+
7
+ private $plugin = 'post-snippets';
8
+
9
+ public function setUp()
10
+ {
11
+ parent::setUp();
12
+
13
+ $snippets = array();
14
+ array_push($snippets, array(
15
+ 'title' => "TestTmp",
16
+ 'vars' => "",
17
+ 'description' => "",
18
+ 'shortcode' => false,
19
+ 'php' => false,
20
+ 'snippet' => "A test snippet..."));
21
+ update_option('post_snippets_options', $snippets);
22
+ }
23
+
24
+ // -------------------------------------------------------------------------
25
+ // Tests
26
+ // -------------------------------------------------------------------------
27
+
28
+ public function testPluginInitialization()
29
+ {
30
+ $this->assertFalse( null == $this->plugin );
31
+ }
32
+
33
+ public function teast_Yo()
34
+ {
35
+ $this->assertTrue(true);
36
+ }
37
+
38
+ public function teast_Yos()
39
+ {
40
+ $this->assertTrue(true);
41
+ }
42
+
43
+ /**
44
+ * @dataProvider provider
45
+ */
46
+ public function teast_data_inline($a, $b, $c)
47
+ {
48
+ // var_dump($c);
49
+ }
50
+ public function praovider()
51
+ {
52
+ return array(
53
+ array(0, 0, 0),
54
+ array(0, 1, 1),
55
+ array(1, 0, 1),
56
+ array(1, 1, 3)
57
+ );
58
+ }
59
+
60
+ public function test_get_post_snippet()
61
+ {
62
+ $test = get_post_snippet('TestTmp');
63
+ $this->assertTrue(is_string($test));
64
+ $this->assertEquals($test, 'A test snippet...');
65
+ }
66
+ }
unittest/bootstrap.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $GLOBALS['wp_tests_options'] = array(
3
+ 'active_plugins' => array( 'post-snippets/post-snippets.php' ),
4
+ 'template' => 'twentyeleven',
5
+ 'stylesheet' => 'twentyeleven',
6
+ );
7
+
8
+ require_once('D:/Dropbox/Code/_Tools/UniformServer/www/wordpress.dev/wordpress-tests/bootstrap.php');