Post Snippets - Version 2.2.1

Version Description

Download this release

Release Info

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

Code changes from version 2.2 to 2.2.1

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: 2013-04-26 10:36+0700\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"
@@ -16,22 +16,18 @@ msgstr ""
16
  "Content-Type: text/plain; charset=CHARSET\n"
17
  "Content-Transfer-Encoding: 8bit\n"
18
 
19
- #: post-snippets.php:168
20
- msgid "Settings"
21
- msgstr ""
22
-
23
  #: views/admin_snippets.php:8 views/admin_snippets.php:17
24
  #: views/help_basic.php:1
25
  msgid "Title"
26
  msgstr ""
27
 
28
  #: views/admin_snippets.php:9 views/admin_snippets.php:18
29
- #: views/help_basic.php:6 lib/PostSnippets/Admin.php:316
30
  msgid "Variables"
31
  msgstr ""
32
 
33
  #: views/admin_snippets.php:10 views/admin_snippets.php:19
34
- #: views/help_basic.php:16 lib/PostSnippets/Admin.php:335
35
  msgid "Snippet"
36
  msgstr ""
37
 
@@ -179,7 +175,7 @@ msgid ""
179
  "variable is reserved, so don't use it in the variables field."
180
  msgstr ""
181
 
182
- #: views/help_shortcode.php:13 lib/PostSnippets/Admin.php:332
183
  msgid "Options"
184
  msgstr ""
185
 
@@ -215,47 +211,51 @@ msgstr ""
215
  msgid "This snippet is insert only, no variables defined."
216
  msgstr ""
217
 
218
- #: lib/PostSnippets/Admin.php:47
 
 
 
 
219
  msgid "A snippet named Untitled has been added."
220
  msgstr ""
221
 
222
- #: lib/PostSnippets/Admin.php:67
223
  msgid "Nothing selected to delete."
224
  msgstr ""
225
 
226
- #: lib/PostSnippets/Admin.php:83
227
  msgid "Selected snippets have been deleted."
228
  msgstr ""
229
 
230
- #: lib/PostSnippets/Admin.php:118
231
  msgid "Snippets have been updated."
232
  msgstr ""
233
 
234
- #: lib/PostSnippets/Admin.php:216
235
  msgid "Manage Snippets"
236
  msgstr ""
237
 
238
- #: lib/PostSnippets/Admin.php:216 lib/PostSnippets/Admin.php:259
239
  msgid "Import/Export"
240
  msgstr ""
241
 
242
- #: lib/PostSnippets/Admin.php:224
243
  msgid "Use the help dropdown button for additional information."
244
  msgstr ""
245
 
246
- #: lib/PostSnippets/Admin.php:260
247
  msgid "Export"
248
  msgstr ""
249
 
250
- #: lib/PostSnippets/Admin.php:263
251
  msgid "Export your snippets for backup or to import them on another site."
252
  msgstr ""
253
 
254
- #: lib/PostSnippets/Admin.php:265
255
  msgid "Export Snippets"
256
  msgstr ""
257
 
258
- #: lib/PostSnippets/Admin.php:288
259
  msgid ""
260
  "This is an overview of all snippets defined for this site. These snippets "
261
  "are inserted into posts from the post editor using the Post Snippets button. "
@@ -266,11 +266,11 @@ msgid ""
266
  "recommended to keep this option disabled."
267
  msgstr ""
268
 
269
- #: lib/PostSnippets/Admin.php:298
270
  msgid "Display rendered snippets"
271
  msgstr ""
272
 
273
- #: lib/PostSnippets/Admin.php:299
274
  msgid "Update"
275
  msgstr ""
276
 
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
  "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2013-05-01 18:50+0700\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"
16
  "Content-Type: text/plain; charset=CHARSET\n"
17
  "Content-Transfer-Encoding: 8bit\n"
18
 
 
 
 
 
19
  #: views/admin_snippets.php:8 views/admin_snippets.php:17
20
  #: views/help_basic.php:1
21
  msgid "Title"
22
  msgstr ""
23
 
24
  #: views/admin_snippets.php:9 views/admin_snippets.php:18
25
+ #: views/help_basic.php:6 lib/PostSnippets/Admin.php:364
26
  msgid "Variables"
27
  msgstr ""
28
 
29
  #: views/admin_snippets.php:10 views/admin_snippets.php:19
30
+ #: views/help_basic.php:16 lib/PostSnippets/Admin.php:383
31
  msgid "Snippet"
32
  msgstr ""
33
 
175
  "variable is reserved, so don't use it in the variables field."
176
  msgstr ""
177
 
178
+ #: views/help_shortcode.php:13 lib/PostSnippets/Admin.php:380
179
  msgid "Options"
180
  msgstr ""
181
 
211
  msgid "This snippet is insert only, no variables defined."
212
  msgstr ""
213
 
214
+ #: lib/PostSnippets/Admin.php:39
215
+ msgid "Settings"
216
+ msgstr ""
217
+
218
+ #: lib/PostSnippets/Admin.php:113
219
  msgid "A snippet named Untitled has been added."
220
  msgstr ""
221
 
222
+ #: lib/PostSnippets/Admin.php:133
223
  msgid "Nothing selected to delete."
224
  msgstr ""
225
 
226
+ #: lib/PostSnippets/Admin.php:149
227
  msgid "Selected snippets have been deleted."
228
  msgstr ""
229
 
230
+ #: lib/PostSnippets/Admin.php:184
231
  msgid "Snippets have been updated."
232
  msgstr ""
233
 
234
+ #: lib/PostSnippets/Admin.php:264
235
  msgid "Manage Snippets"
236
  msgstr ""
237
 
238
+ #: lib/PostSnippets/Admin.php:264 lib/PostSnippets/Admin.php:307
239
  msgid "Import/Export"
240
  msgstr ""
241
 
242
+ #: lib/PostSnippets/Admin.php:272
243
  msgid "Use the help dropdown button for additional information."
244
  msgstr ""
245
 
246
+ #: lib/PostSnippets/Admin.php:308
247
  msgid "Export"
248
  msgstr ""
249
 
250
+ #: lib/PostSnippets/Admin.php:311
251
  msgid "Export your snippets for backup or to import them on another site."
252
  msgstr ""
253
 
254
+ #: lib/PostSnippets/Admin.php:313
255
  msgid "Export Snippets"
256
  msgstr ""
257
 
258
+ #: lib/PostSnippets/Admin.php:336
259
  msgid ""
260
  "This is an overview of all snippets defined for this site. These snippets "
261
  "are inserted into posts from the post editor using the Post Snippets button. "
266
  "recommended to keep this option disabled."
267
  msgstr ""
268
 
269
+ #: lib/PostSnippets/Admin.php:346
270
  msgid "Display rendered snippets"
271
  msgstr ""
272
 
273
+ #: lib/PostSnippets/Admin.php:347
274
  msgid "Update"
275
  msgstr ""
276
 
lib/PostSnippets/Admin.php CHANGED
@@ -10,6 +10,72 @@
10
  */
11
  class PostSnippets_Admin
12
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  // -------------------------------------------------------------------------
14
  // Handle form submissions
15
  // -------------------------------------------------------------------------
@@ -158,24 +224,6 @@ class PostSnippets_Admin
158
  // HTML generation for option pages
159
  // -------------------------------------------------------------------------
160
 
161
- /**
162
- * Render the options page.
163
- *
164
- * @since Post Snippets 1.9.7
165
- * @param string $page Admin page to render. Default: options
166
- */
167
- public function render($page)
168
- {
169
- switch ($page) {
170
- case 'options':
171
- $this->optionsPage();
172
- break;
173
- default:
174
- $this->overviewPage();
175
- break;
176
- }
177
- }
178
-
179
  /**
180
  * Display Flashing Message.
181
  *
@@ -195,7 +243,7 @@ class PostSnippets_Admin
195
  *
196
  * @since Post Snippets 1.8.8
197
  */
198
- private function optionsPage()
199
  {
200
  // Handle Form Submits
201
  $this->add();
@@ -279,7 +327,7 @@ class PostSnippets_Admin
279
  *
280
  * @since Post Snippets 1.9.7
281
  */
282
- private function overviewPage()
283
  {
284
  // Header
285
  echo '<div class="wrap">';
@@ -342,7 +390,6 @@ class PostSnippets_Admin
342
  }
343
  }
344
  }
345
-
346
  // Close
347
  echo '</div>';
348
  }
10
  */
11
  class PostSnippets_Admin
12
  {
13
+ public function __construct()
14
+ {
15
+ add_filter('plugin_action_links', array(&$this, 'actionLinks'), 10, 2);
16
+ add_action('admin_menu', array(&$this, 'menu'));
17
+ }
18
+
19
+
20
+ // -------------------------------------------------------------------------
21
+ // Setup
22
+ // -------------------------------------------------------------------------
23
+
24
+ /**
25
+ * Quick link to the Post Snippets Settings page from the Plugins page.
26
+ *
27
+ * @param array Array of all plugin links
28
+ * @param string The current plugin file we're filtering.
29
+ * @return Array with all the plugin's action links
30
+ */
31
+ public function actionLinks($links, $file)
32
+ {
33
+ $pluginFile = plugin_basename(dirname(PostSnippets::FILE));
34
+ $pluginFile .= '/post-snippets.php';
35
+
36
+ if ($file == $pluginFile) {
37
+ $url = 'options-general.php?page=post-snippets/post-snippets.php';
38
+ $link = "<a href='{$url}'>";
39
+ $link .= __('Settings', PostSnippets::TEXT_DOMAIN).'</a>';
40
+ $links[] = $link;
41
+ }
42
+ return $links;
43
+ }
44
+
45
+ /**
46
+ * Initialize the administration page.
47
+ */
48
+ public function menu()
49
+ {
50
+ $capability = 'manage_options';
51
+ if (defined('POST_SNIPPETS_ALLOW_EDIT_POSTS')
52
+ and current_user_can('edit_posts')
53
+ ) {
54
+ $allowed = true;
55
+ $capability = 'edit_posts';
56
+ }
57
+
58
+ if (current_user_can('manage_options') or isset($allowed)) {
59
+ $optionPage = add_options_page(
60
+ 'Post Snippets Options',
61
+ 'Post Snippets',
62
+ $capability,
63
+ PostSnippets::FILE,
64
+ array(&$this, 'optionsPage')
65
+ );
66
+ new PostSnippets_Help($optionPage);
67
+ } else {
68
+ $option_page = add_options_page(
69
+ 'Post Snippets',
70
+ 'Post Snippets',
71
+ 'edit_posts',
72
+ PostSnippets::FILE,
73
+ array(&$this, 'overviewPage')
74
+ );
75
+ }
76
+ }
77
+
78
+
79
  // -------------------------------------------------------------------------
80
  // Handle form submissions
81
  // -------------------------------------------------------------------------
224
  // HTML generation for option pages
225
  // -------------------------------------------------------------------------
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  /**
228
  * Display Flashing Message.
229
  *
243
  *
244
  * @since Post Snippets 1.8.8
245
  */
246
+ public function optionsPage()
247
  {
248
  // Handle Form Submits
249
  $this->add();
327
  *
328
  * @since Post Snippets 1.9.7
329
  */
330
+ public function overviewPage()
331
  {
332
  // Header
333
  echo '<div class="wrap">';
390
  }
391
  }
392
  }
 
393
  // Close
394
  echo '</div>';
395
  }
post-snippets.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://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: http://johansteen.se/
8
- Version: 2.2
9
  License: GPLv2 or later
10
  Text Domain: post-snippets
11
 
@@ -73,11 +73,6 @@ class PostSnippets
73
  // Add TinyMCE button
74
  add_action('init', array(&$this, 'addTinymceButton'));
75
 
76
- // Settings link on plugins list
77
- add_filter('plugin_action_links', array(&$this, 'actionLinks'), 10, 2);
78
- // Options Page
79
- add_action('admin_menu', array(&$this,'wpAdmin'));
80
-
81
  $this->createShortcodes();
82
 
83
  // Adds the JS and HTML code in the header and footer for the jQuery
@@ -92,6 +87,8 @@ class PostSnippets
92
  array(&$this,'addQuicktagButton'),
93
  100
94
  );
 
 
95
  }
96
 
97
  /**
@@ -157,37 +154,6 @@ class PostSnippets
157
  );
158
  }
159
 
160
- /**
161
- * Quick link to the Post Snippets Settings page from the Plugins page.
162
- *
163
- * @return Array with all the plugin's action links
164
- */
165
- public function actionLinks($links, $file)
166
- {
167
- if ($file == plugin_basename(dirname(__FILE__).'/post-snippets.php')) {
168
- $links[] = '<a href="options-general.php?page=post-snippets/post-snippets.php">'.__('Settings', PostSnippets::TEXT_DOMAIN).'</a>';
169
- }
170
- return $links;
171
- }
172
-
173
-
174
- /**
175
- * Enqueues the necessary scripts and styles for the plugins
176
- *
177
- * @since Post Snippets 1.7
178
- */
179
- public function enqueueAssets()
180
- {
181
- wp_enqueue_script('jquery-ui-dialog');
182
- wp_enqueue_script('jquery-ui-tabs');
183
- wp_enqueue_style('wp-jquery-ui-dialog');
184
-
185
- # Adds the CSS stylesheet for the jQuery UI dialog
186
- $style_url = plugins_url('/assets/post-snippets.css', __FILE__);
187
- wp_register_style('post-snippets', $style_url, false, '2.0');
188
- wp_enqueue_style('post-snippets');
189
- }
190
-
191
 
192
  // -------------------------------------------------------------------------
193
  // WordPress Editor Buttons
@@ -571,53 +537,22 @@ class PostSnippets
571
  return addslashes($content);
572
  }
573
 
574
-
575
- // -------------------------------------------------------------------------
576
- // Admin
577
- // -------------------------------------------------------------------------
578
-
579
  /**
580
- * The Admin Page.
581
- */
582
- public function wpAdmin()
583
- {
584
- if (current_user_can('manage_options')) {
585
- // If user can manage options, display the admin page
586
- $option_page = add_options_page('Post Snippets Options', 'Post Snippets', 'administrator', __FILE__, array(&$this, 'optionsPage'));
587
- if ($option_page and class_exists('PostSnippets_Help')) {
588
- $help = new PostSnippets_Help($option_page);
589
- }
590
- } else {
591
- // If user can't manage options, but can edit posts, display the overview page
592
- $option_page = add_options_page('Post Snippets', 'Post Snippets', 'edit_posts', __FILE__, array(&$this, 'overviewPage'));
593
- }
594
- }
595
-
596
- /**
597
- * The options Overview page.
598
- *
599
- * For users without manage_options cap but with edit_posts cap. A read-only
600
- * view.
601
  *
602
- * @since Post Snippets 1.9.7
603
  */
604
- public function overviewPage()
605
  {
606
- $settings = new PostSnippets_Admin();
607
- $settings->render('overview');
608
- }
609
 
610
- /**
611
- * The options Admin page.
612
- *
613
- * For users with manage_options capability.
614
- */
615
- public function optionsPage()
616
- {
617
- $settings = new PostSnippets_Admin();
618
- $settings->render('options');
619
  }
620
-
621
 
622
  // -------------------------------------------------------------------------
623
  // Helpers
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.2.1
9
  License: GPLv2 or later
10
  Text Domain: post-snippets
11
 
73
  // Add TinyMCE button
74
  add_action('init', array(&$this, 'addTinymceButton'));
75
 
 
 
 
 
 
76
  $this->createShortcodes();
77
 
78
  // Adds the JS and HTML code in the header and footer for the jQuery
87
  array(&$this,'addQuicktagButton'),
88
  100
89
  );
90
+
91
+ new PostSnippets_Admin;
92
  }
93
 
94
  /**
154
  );
155
  }
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
 
158
  // -------------------------------------------------------------------------
159
  // WordPress Editor Buttons
537
  return addslashes($content);
538
  }
539
 
 
 
 
 
 
540
  /**
541
+ * Enqueues the necessary scripts and styles for the plugins
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
542
  *
543
+ * @since Post Snippets 1.7
544
  */
545
+ public function enqueueAssets()
546
  {
547
+ wp_enqueue_script('jquery-ui-dialog');
548
+ wp_enqueue_script('jquery-ui-tabs');
549
+ wp_enqueue_style('wp-jquery-ui-dialog');
550
 
551
+ # Adds the CSS stylesheet for the jQuery UI dialog
552
+ $style_url = plugins_url('/assets/post-snippets.css', __FILE__);
553
+ wp_register_style('post-snippets', $style_url, false, '2.0');
554
+ wp_enqueue_style('post-snippets');
 
 
 
 
 
555
  }
 
556
 
557
  // -------------------------------------------------------------------------
558
  // Helpers
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://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: 3.5.1
7
- Stable tag: 2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -117,6 +117,14 @@ Contributions are appreciated and encouraged.
117
 
118
  == Changelog ==
119
 
 
 
 
 
 
 
 
 
120
  = Version 2.2 - 26 Apr 2013 =
121
  * Bumps required WordPress version to v3.3.
122
  * Fixes a problem with using some HTML entities in snippets.
4
  Tags: post, admin, snippet, shortcode, html, custom, page, dynamic, editor, php, code
5
  Requires at least: 3.3
6
  Tested up to: 3.5.1
7
+ Stable tag: 2.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
117
 
118
  == Changelog ==
119
 
120
+ = Version 2.2.1 - 1 May 2013 =
121
+ * Added an option to give users with `edit_posts` capability access to the
122
+ Post Snippets Admin. Fixes
123
+ [issue #12](https://github.com/artstorm/post-snippets/issues/12). Add
124
+ `define('POST_SNIPPETS_ALLOW_EDIT_POSTS', true);` to wp-config.php to enable
125
+ Post Snippets access for those users.
126
+ * Optimizes code for the admin section.
127
+
128
  = Version 2.2 - 26 Apr 2013 =
129
  * Bumps required WordPress version to v3.3.
130
  * Fixes a problem with using some HTML entities in snippets.