Code Snippets - Version 2.9.6

Version Description

(14 Jan 2018) = * Added Brazilian Portuguese translation by Bruno Borges * Fixed: Use standard WordPress capabilities instead of custom capabilities to prevent lockouts * Fixed: Multisite issue with retrieving active shared snippets from the wrong table causing duplicate snippet execution * Moved scope and other settings on single snippet page to below code area

Download this release

Release Info

Developer bungeshea
Plugin Icon Code Snippets
Version 2.9.6
Comparing to
See all releases

Code changes from version 2.9.5 to 2.9.6

code-snippets.php CHANGED
@@ -10,7 +10,7 @@
10
  * @author Shea Bunge <shea@bungeshea.com>
11
  * @copyright 2012-2018 Shea Bunge
12
  * @license MIT http://opensource.org/licenses/MIT
13
- * @version 2.9.4
14
  * @link https://github.com/sheabunge/code-snippets
15
  */
16
 
@@ -20,7 +20,7 @@ Plugin URI: https://github.com/sheabunge/code-snippets
20
  Description: An easy, clean and simple way to add code snippets to your site. No need to edit to your theme's functions.php file again!
21
  Author: Shea Bunge
22
  Author URI: https://bungeshea.com
23
- Version: 2.9.5
24
  License: MIT
25
  License URI: license.txt
26
  Text Domain: code-snippets
@@ -42,7 +42,7 @@ if ( ! defined( 'ABSPATH' ) ) {
42
  * @since 2.0
43
  * @var string A PHP-standardized version number string
44
  */
45
- define( 'CODE_SNIPPETS_VERSION', '2.9.5' );
46
 
47
  /**
48
  * The full path to the main file of this plugin
10
  * @author Shea Bunge <shea@bungeshea.com>
11
  * @copyright 2012-2018 Shea Bunge
12
  * @license MIT http://opensource.org/licenses/MIT
13
+ * @version 2.9.6
14
  * @link https://github.com/sheabunge/code-snippets
15
  */
16
 
20
  Description: An easy, clean and simple way to add code snippets to your site. No need to edit to your theme's functions.php file again!
21
  Author: Shea Bunge
22
  Author URI: https://bungeshea.com
23
+ Version: 2.9.6
24
  License: MIT
25
  License URI: license.txt
26
  Text Domain: code-snippets
42
  * @since 2.0
43
  * @var string A PHP-standardized version number string
44
  */
45
+ define( 'CODE_SNIPPETS_VERSION', '2.9.6' );
46
 
47
  /**
48
  * The full path to the main file of this plugin
css/min/edit.css CHANGED
@@ -1 +1 @@
1
- .form-table th{width:auto}h3{margin:1em 0}label{cursor:auto}label[for=snippet_description] h3 div{position:absolute}ul.tagit{background-color:#fff!important}.submit .button{margin-right:.5em}.snippet-scope div{margin-right:30px;display:inline-block}.CodeMirror{width:100%;height:auto!important;border:1px solid #dfdfdf;border-radius:3px;background-color:#fff}.CodeMirror-code{outline:0;direction:ltr;text-align:left}.CodeMirror-sizer{min-height:300px!important}.CodeMirror-focused .cm-matchhighlight{color:#fff!important;outline:1px solid green}.cm-s-rubyblue .CodeMirror-cursor{border-left:1px solid #fff!important}
1
+ .form-table th{width:auto}h2{margin:25px 0 15px}h2:first-of-type{margin-top:20px}label{cursor:auto}label[for=snippet_description] h3 div{position:absolute}ul.tagit{background-color:#fff!important}.submit .button{margin-right:.5em}.snippet-scope{margin-top:15px}.snippet-scope label{margin-right:30px;display:inline-block}.CodeMirror{width:100%;height:auto!important;border:1px solid #dfdfdf;border-radius:3px;background-color:#fff}.CodeMirror-code{outline:0;direction:ltr;text-align:left}.CodeMirror-sizer{min-height:300px!important}.CodeMirror-focused .cm-matchhighlight{color:#fff!important;outline:1px solid green}.cm-s-rubyblue .CodeMirror-cursor{border-left:1px solid #fff!important}
css/min/manage.css CHANGED
@@ -1 +1 @@
1
- .admin-scope .column-name>a:after,.frontend-scope .column-name>a:after{padding-left:5px;font-family:"dashicons";vertical-align:top}.admin-scope .column-name>a:after{font-size:14px;content:"\f111"}.frontend-scope .column-name>a:after{font-size:16px;content:"\f177"}.snippets .badge{margin-left:4px;padding:3px 6px;text-decoration:none;border:medium;border-radius:2px;background:#e0e0e0;font-size:smaller}.clear-filters{vertical-align:bottom}.snippets td,.snippets th{color:#000}.snippets tr{background:#fff}.snippets .row-actions{color:#ddd}.snippets .clear-filters{vertical-align:middle}.snippets tfoot th{border-top:none!important}.snippets tfoot th.check-column{padding:13px 0 0 3px}.snippets .inactive th.check-column,.snippets tfoot th.check-column,.snippets thead th.check-column{padding-left:5px}.snippets .column-description p{color:#333}.snippets .inactive a{color:#579}.snippets .active td,.snippets .active th,.snippets .inactive td,.snippets .inactive th{padding:10px 9px;border:0;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.snippets .active td,.snippets .active th{background-color:rgba(120,200,230,.06)}.snippets .active th.check-column{border-left:2px solid #2ea2cc}.snippets tr.active+tr.inactive td,.snippets tr.active+tr.inactive th{border-top:1px solid rgba(0,0,0,.03);-webkit-box-shadow:inset 0 1px 0 rgba(0,0,0,.02),inset 0 -1px 0 #e1e1e1;box-shadow:inset 0 1px 0 rgba(0,0,0,.02),inset 0 -1px 0 #e1e1e1}.snippets #all-snippets-table a.delete:hover,.snippets #search-snippets-table a.delete:hover,.snippets a.delete:hover{border-bottom:1px solid red;color:red}#wpbody-content .snippets .column-name{white-space:nowrap}
1
+ .admin-scope .column-name>a::after,.front-end-scope .column-name>a::after{padding-left:5px;font-family:"dashicons";vertical-align:top}.admin-scope .column-name>a::after{font-size:14px;content:"\f107"}.front-end-scope .column-name>a::after{font-size:16px;content:"\f100"}.snippets .badge{margin-left:4px;padding:3px 6px;text-decoration:none;border:medium;border-radius:2px;background:#e0e0e0;font-size:smaller}.clear-filters{vertical-align:bottom}.snippets td,.snippets th{color:#000}.snippets tr{background:#fff}.snippets .row-actions{color:#ddd}.snippets .clear-filters{vertical-align:middle}.snippets tfoot th{border-top:none!important}.snippets tfoot th.check-column{padding:13px 0 0 3px}.snippets .inactive th.check-column,.snippets tfoot th.check-column,.snippets thead th.check-column{padding-left:5px}.snippets .column-description p{color:#333}.snippets .inactive a{color:#579}.snippets .active td,.snippets .active th,.snippets .inactive td,.snippets .inactive th{padding:10px 9px;border:0;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);box-shadow:inset 0 -1px 0 rgba(0,0,0,.1)}.snippets .active td,.snippets .active th{background-color:rgba(120,200,230,.06)}.snippets .active th.check-column{border-left:2px solid #2ea2cc}.snippets tr.active+tr.inactive td,.snippets tr.active+tr.inactive th{border-top:1px solid rgba(0,0,0,.03);-webkit-box-shadow:inset 0 1px 0 rgba(0,0,0,.02),inset 0 -1px 0 #e1e1e1;box-shadow:inset 0 1px 0 rgba(0,0,0,.02),inset 0 -1px 0 #e1e1e1}.snippets #all-snippets-table a.delete:hover,.snippets #search-snippets-table a.delete:hover,.snippets a.delete:hover{border-bottom:1px solid red;color:red}#wpbody-content .snippets .column-name{white-space:nowrap}
languages/code-snippets.pot CHANGED
@@ -6,9 +6,9 @@
6
  #, fuzzy
7
  msgid ""
8
  msgstr ""
9
- "Project-Id-Version: code-snippets 2.9.5\n"
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2018-01-13 20:58+1100\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"
@@ -68,68 +68,68 @@ msgstr ""
68
  msgid "Description"
69
  msgstr ""
70
 
71
- #: php/admin-menus/class-edit-menu.php:318 php/class-list-table.php:348
72
  msgid "Tags"
73
  msgstr ""
74
 
75
- #: php/admin-menus/class-edit-menu.php:322
76
  msgid "Enter a list of tags; separated by commas"
77
  msgstr ""
78
 
79
- #: php/admin-menus/class-edit-menu.php:343
80
  msgid "Run snippet everywhere"
81
  msgstr ""
82
 
83
- #: php/admin-menus/class-edit-menu.php:344
84
  msgid "Only run in administration area"
85
  msgstr ""
86
 
87
- #: php/admin-menus/class-edit-menu.php:345
88
  msgid "Only run on site front-end"
89
  msgstr ""
90
 
91
- #: php/admin-menus/class-edit-menu.php:349
92
  msgid "Scope"
93
  msgstr ""
94
 
95
- #: php/admin-menus/class-edit-menu.php:369
96
- msgid "Sharing"
97
  msgstr ""
98
 
99
- #: php/admin-menus/class-edit-menu.php:373
100
  msgid "Allow this snippet to be activated on individual sites on the network"
101
  msgstr ""
102
 
103
- #: php/admin-menus/class-edit-menu.php:433
104
  #, php-format
105
  msgid "The snippet has been deactivated due to an error on line %d:"
106
  msgstr ""
107
 
108
- #: php/admin-menus/class-edit-menu.php:438
109
  msgid "The snippet has been deactivated due to an error in the code."
110
  msgstr ""
111
 
112
- #: php/admin-menus/class-edit-menu.php:445
113
  msgid "An error occurred when saving the snippet."
114
  msgstr ""
115
 
116
- #: php/admin-menus/class-edit-menu.php:450
117
  msgid "Snippet <strong>added</strong>."
118
  msgstr ""
119
 
120
- #: php/admin-menus/class-edit-menu.php:451
121
  msgid "Snippet <strong>updated</strong>."
122
  msgstr ""
123
 
124
- #: php/admin-menus/class-edit-menu.php:452
125
  msgid "Snippet <strong>added</strong> and <strong>activated</strong>."
126
  msgstr ""
127
 
128
- #: php/admin-menus/class-edit-menu.php:453
129
  msgid "Snippet <strong>updated</strong> and <strong>activated</strong>."
130
  msgstr ""
131
 
132
- #: php/admin-menus/class-edit-menu.php:454
133
  msgid "Snippet <strong>updated</strong> and <strong>deactivated</strong>."
134
  msgstr ""
135
 
@@ -222,7 +222,7 @@ msgstr ""
222
  msgid "Snippets Settings"
223
  msgstr ""
224
 
225
- #: php/admin-menus/class-settings-menu.php:39 php/views/edit.php:135
226
  msgid "Settings"
227
  msgstr ""
228
 
6
  #, fuzzy
7
  msgid ""
8
  msgstr ""
9
+ "Project-Id-Version: code-snippets 2.9.6\n"
10
  "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2018-01-14 22:42+1100\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"
68
  msgid "Description"
69
  msgstr ""
70
 
71
+ #: php/admin-menus/class-edit-menu.php:319 php/class-list-table.php:348
72
  msgid "Tags"
73
  msgstr ""
74
 
75
+ #: php/admin-menus/class-edit-menu.php:324
76
  msgid "Enter a list of tags; separated by commas"
77
  msgstr ""
78
 
79
+ #: php/admin-menus/class-edit-menu.php:345
80
  msgid "Run snippet everywhere"
81
  msgstr ""
82
 
83
+ #: php/admin-menus/class-edit-menu.php:346
84
  msgid "Only run in administration area"
85
  msgstr ""
86
 
87
+ #: php/admin-menus/class-edit-menu.php:347
88
  msgid "Only run on site front-end"
89
  msgstr ""
90
 
91
+ #: php/admin-menus/class-edit-menu.php:352
92
  msgid "Scope"
93
  msgstr ""
94
 
95
+ #: php/admin-menus/class-edit-menu.php:372
96
+ msgid "Sharing Settings"
97
  msgstr ""
98
 
99
+ #: php/admin-menus/class-edit-menu.php:376
100
  msgid "Allow this snippet to be activated on individual sites on the network"
101
  msgstr ""
102
 
103
+ #: php/admin-menus/class-edit-menu.php:436
104
  #, php-format
105
  msgid "The snippet has been deactivated due to an error on line %d:"
106
  msgstr ""
107
 
108
+ #: php/admin-menus/class-edit-menu.php:441
109
  msgid "The snippet has been deactivated due to an error in the code."
110
  msgstr ""
111
 
112
+ #: php/admin-menus/class-edit-menu.php:448
113
  msgid "An error occurred when saving the snippet."
114
  msgstr ""
115
 
116
+ #: php/admin-menus/class-edit-menu.php:453
117
  msgid "Snippet <strong>added</strong>."
118
  msgstr ""
119
 
120
+ #: php/admin-menus/class-edit-menu.php:454
121
  msgid "Snippet <strong>updated</strong>."
122
  msgstr ""
123
 
124
+ #: php/admin-menus/class-edit-menu.php:455
125
  msgid "Snippet <strong>added</strong> and <strong>activated</strong>."
126
  msgstr ""
127
 
128
+ #: php/admin-menus/class-edit-menu.php:456
129
  msgid "Snippet <strong>updated</strong> and <strong>activated</strong>."
130
  msgstr ""
131
 
132
+ #: php/admin-menus/class-edit-menu.php:457
133
  msgid "Snippet <strong>updated</strong> and <strong>deactivated</strong>."
134
  msgstr ""
135
 
222
  msgid "Snippets Settings"
223
  msgstr ""
224
 
225
+ #: php/admin-menus/class-settings-menu.php:39
226
  msgid "Settings"
227
  msgstr ""
228
 
php/admin-menus/class-edit-menu.php CHANGED
@@ -73,11 +73,11 @@ class Code_Snippets_Edit_Menu extends Code_Snippets_Admin_Menu {
73
  }
74
 
75
  if ( code_snippets_get_setting( 'general', 'snippet_scope_enabled' ) ) {
76
- add_action( 'code_snippets/admin/single/settings', array( $this, 'render_scope_setting' ) );
77
  }
78
 
79
  if ( get_current_screen()->in_admin( 'network' ) ) {
80
- add_action( 'code_snippets/admin/single/settings', array( $this, 'render_multisite_sharing_setting' ) );
81
  }
82
 
83
  $this->process_actions();
@@ -290,7 +290,7 @@ class Code_Snippets_Edit_Menu extends Code_Snippets_Admin_Menu {
290
  $heading = "<div>$heading</div>";
291
  }
292
 
293
- echo '<label for="snippet_description"><h2>', $heading, '</h2></label>';
294
 
295
  remove_editor_styles(); // stop custom theme styling interfering with the editor
296
 
@@ -314,9 +314,11 @@ class Code_Snippets_Edit_Menu extends Code_Snippets_Admin_Menu {
314
  function render_tags_editor( Code_Snippet $snippet ) {
315
 
316
  ?>
317
- <label for="snippet_tags" style="cursor: auto;">
318
- <h2><?php esc_html_e( 'Tags', 'code-snippets' ); ?></h2>
319
- </label>
 
 
320
 
321
  <input type="text" id="snippet_tags" name="snippet_tags" style="width: 100%;"
322
  placeholder="<?php esc_html_e( 'Enter a list of tags; separated by commas', 'code-snippets' ); ?>"
@@ -345,16 +347,17 @@ class Code_Snippets_Edit_Menu extends Code_Snippets_Admin_Menu {
345
  __( 'Only run on site front-end', 'code-snippets' ),
346
  );
347
 
348
- echo '<tr class="snippet-scope">';
349
- echo '<th scope="row">' . __( 'Scope', 'code-snippets' ) . '</th><td>';
 
350
 
351
  foreach ( $scopes as $scope => $label ) {
352
- printf( '<div><input type="radio" name="snippet_scope" value="%d"', $scope );
353
  checked( $scope, $snippet->scope );
354
- echo "> $label</div>";
355
  }
356
 
357
- echo '</td></tr>';
358
  }
359
 
360
  /**
@@ -365,14 +368,14 @@ class Code_Snippets_Edit_Menu extends Code_Snippets_Admin_Menu {
365
  $shared_snippets = get_site_option( 'shared_network_snippets', array() );
366
  ?>
367
 
368
- <tr class="snippet-sharing-setting">
369
- <th scope="row"><?php _e( 'Sharing', 'code-snippets' ) ?></th>
370
- <td><label for="snippet_sharing">
371
  <input type="checkbox" name="snippet_sharing"
372
  <?php checked( in_array( $snippet->id, $shared_snippets ) ); ?>>
373
  <?php _e( 'Allow this snippet to be activated on individual sites on the network', 'code-snippets' ); ?>
374
- </label></td>
375
- </tr>
376
 
377
  <?php
378
  }
73
  }
74
 
75
  if ( code_snippets_get_setting( 'general', 'snippet_scope_enabled' ) ) {
76
+ add_action( 'code_snippets/admin/single', array( $this, 'render_scope_setting' ), 1 );
77
  }
78
 
79
  if ( get_current_screen()->in_admin( 'network' ) ) {
80
+ add_action( 'code_snippets/admin/single', array( $this, 'render_multisite_sharing_setting' ), 1 );
81
  }
82
 
83
  $this->process_actions();
290
  $heading = "<div>$heading</div>";
291
  }
292
 
293
+ echo '<h2><label for="snippet_description">', $heading, '</label></h2>';
294
 
295
  remove_editor_styles(); // stop custom theme styling interfering with the editor
296
 
314
  function render_tags_editor( Code_Snippet $snippet ) {
315
 
316
  ?>
317
+ <h2 style="margin: 25px 0 10px;">
318
+ <label for="snippet_tags" style="cursor: auto;">
319
+ <?php esc_html_e( 'Tags', 'code-snippets' ); ?>
320
+ </label>
321
+ </h2>
322
 
323
  <input type="text" id="snippet_tags" name="snippet_tags" style="width: 100%;"
324
  placeholder="<?php esc_html_e( 'Enter a list of tags; separated by commas', 'code-snippets' ); ?>"
347
  __( 'Only run on site front-end', 'code-snippets' ),
348
  );
349
 
350
+ $icons = array( 'site', 'tools', 'appearance' );
351
+
352
+ echo '<h2 class="screen-reader-text">' . __( 'Scope', 'code-snippets' ) . '</h2><p class="snippet-scope">';
353
 
354
  foreach ( $scopes as $scope => $label ) {
355
+ printf( '<label><input type="radio" name="snippet_scope" value="%d"', $scope );
356
  checked( $scope, $snippet->scope );
357
+ printf( '> <span class="dashicons dashicons-admin-%s"></span> %s</label>', $icons[ $scope ], $label );
358
  }
359
 
360
+ echo '</p>';
361
  }
362
 
363
  /**
368
  $shared_snippets = get_site_option( 'shared_network_snippets', array() );
369
  ?>
370
 
371
+ <div class="snippet-sharing-setting">
372
+ <h2 class="screen-reader-text"><?php _e( 'Sharing Settings', 'code-snippets' ); ?></h2>
373
+ <label for="snippet_sharing">
374
  <input type="checkbox" name="snippet_sharing"
375
  <?php checked( in_array( $snippet->id, $shared_snippets ) ); ?>>
376
  <?php _e( 'Allow this snippet to be activated on individual sites on the network', 'code-snippets' ); ?>
377
+ </label>
378
+ </div>
379
 
380
  <?php
381
  }
php/class-code-snippets.php CHANGED
@@ -39,9 +39,6 @@ class Code_Snippets {
39
  $this->version = $version;
40
  $this->file = $file;
41
 
42
- add_action( 'grant_super_admin', array( $this, 'grant_network_cap' ) );
43
- add_action( 'remove_super_admin', array( $this, 'remove_network_cap' ) );
44
-
45
  add_action( 'init', array( $this, 'load_textdomain' ), 9 );
46
 
47
  add_filter( 'code_snippets/execute_snippets', array( $this, 'disable_snippet_execution' ), 5 );
@@ -180,7 +177,7 @@ class Code_Snippets {
180
  * @return string
181
  */
182
  public function get_cap_name() {
183
- return apply_filters( 'code_snippets_cap', 'manage_snippets' );
184
  }
185
 
186
  /**
@@ -189,7 +186,7 @@ class Code_Snippets {
189
  * @return string
190
  */
191
  public function get_network_cap_name() {
192
- return apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' );
193
  }
194
 
195
  /**
@@ -217,36 +214,6 @@ class Code_Snippets {
217
  return $this->get_cap_name();
218
  }
219
 
220
- /**
221
- * Add the multisite capabilities to a user
222
- *
223
- * @since 2.0
224
- * @param int $user_id The ID of the user to add the cap to
225
- */
226
- function grant_network_cap( $user_id ) {
227
-
228
- /* Get the user from the ID */
229
- $user = new WP_User( $user_id );
230
-
231
- /* Add the capability */
232
- $user->add_cap( $this->get_network_cap_name() );
233
- }
234
-
235
- /**
236
- * Remove the multisite capabilities from a user
237
- *
238
- * @since 2.0
239
- * @param int $user_id The ID of the user to remove the cap from
240
- */
241
- function remove_network_cap( $user_id ) {
242
-
243
- /* Get the user from the ID */
244
- $user = new WP_User( $user_id );
245
-
246
- /* Remove the capability */
247
- $user->remove_cap( $this->get_network_cap_name() );
248
- }
249
-
250
  /**
251
  * Load up the localization file if we're using WordPress in a different language.
252
  *
39
  $this->version = $version;
40
  $this->file = $file;
41
 
 
 
 
42
  add_action( 'init', array( $this, 'load_textdomain' ), 9 );
43
 
44
  add_filter( 'code_snippets/execute_snippets', array( $this, 'disable_snippet_execution' ), 5 );
177
  * @return string
178
  */
179
  public function get_cap_name() {
180
+ return apply_filters( 'code_snippets_cap', 'manage_options' );
181
  }
182
 
183
  /**
186
  * @return string
187
  */
188
  public function get_network_cap_name() {
189
+ return apply_filters( 'code_snippets_network_cap', 'manage_network_options' );
190
  }
191
 
192
  /**
214
  return $this->get_cap_name();
215
  }
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  /**
218
  * Load up the localization file if we're using WordPress in a different language.
219
  *
php/class-db.php CHANGED
@@ -7,6 +7,10 @@
7
  */
8
  class Code_Snippets_DB {
9
 
 
 
 
 
10
  /**
11
  * Class constructor
12
  */
@@ -23,13 +27,16 @@ class Code_Snippets_DB {
23
  function set_table_vars() {
24
  global $wpdb;
25
 
 
 
 
26
  /* Register the snippet table names with WordPress */
27
- $wpdb->tables[] = 'snippets';
28
- $wpdb->ms_global_tables[] = 'ms_snippets';
29
 
30
  /* Setup initial table variables */
31
- $wpdb->snippets = $wpdb->prefix . 'snippets';
32
- $wpdb->ms_snippets = $wpdb->base_prefix . 'ms_snippets';
33
  }
34
 
35
  /**
7
  */
8
  class Code_Snippets_DB {
9
 
10
+ public $table;
11
+
12
+ public $ms_table;
13
+
14
  /**
15
  * Class constructor
16
  */
27
  function set_table_vars() {
28
  global $wpdb;
29
 
30
+ $this->table = 'snippets';
31
+ $this->ms_table = 'ms_snippets';
32
+
33
  /* Register the snippet table names with WordPress */
34
+ $wpdb->tables[] = $this->table;
35
+ $wpdb->ms_global_tables[] = $this->ms_table;
36
 
37
  /* Setup initial table variables */
38
+ $wpdb->snippets = $this->table = $wpdb->prefix . $this->table;
39
+ $wpdb->ms_snippets = $this->ms_table = $wpdb->base_prefix . $this->ms_table;
40
  }
41
 
42
  /**
php/snippet-ops.php CHANGED
@@ -476,7 +476,7 @@ function execute_active_snippets() {
476
  $active_shared_ids_format = implode( ',', array_fill( 0, count( $active_shared_ids ), '%d' ) );
477
 
478
  /* Include them in the query */
479
- $sql = "SELECT id, code FROM {$wpdb->snippets} WHERE (scope=0 OR scope=%d) AND (active=1 OR id IN ($active_shared_ids_format))";
480
 
481
  /* Add the scope number to the IDs array, so that it is the first variable in the query */
482
  array_unshift( $active_shared_ids, $current_scope );
476
  $active_shared_ids_format = implode( ',', array_fill( 0, count( $active_shared_ids ), '%d' ) );
477
 
478
  /* Include them in the query */
479
+ $sql = "SELECT id, code FROM {$wpdb->ms_snippets} WHERE (scope=0 OR scope=%d) AND (active=1 OR id IN ($active_shared_ids_format))";
480
 
481
  /* Add the scope number to the IDs array, so that it is the first variable in the query */
482
  array_unshift( $active_shared_ids, $current_scope );
php/upgrade.php CHANGED
@@ -18,14 +18,6 @@ function code_snippets_upgrader() {
18
  /* Get the current plugin version from the database */
19
  $prev_version = get_option( 'code_snippets_version' );
20
 
21
- /* Check if this is the first plugin run */
22
- if ( ! $prev_version ) {
23
-
24
- /* Register capabilities */
25
- $role = get_role( apply_filters( 'code_snippets_role', 'administrator' ) );
26
- $role->add_cap( code_snippets()->get_cap_name() );
27
- }
28
-
29
  /* Check if we have upgraded from an older version */
30
  if ( version_compare( $prev_version, CODE_SNIPPETS_VERSION, '<' ) ) {
31
 
@@ -34,6 +26,12 @@ function code_snippets_upgrader() {
34
 
35
  /* Update the plugin version stored in the database */
36
  update_option( 'code_snippets_version', CODE_SNIPPETS_VERSION );
 
 
 
 
 
 
37
  }
38
 
39
  /* Run multisite-only upgrades */
@@ -43,24 +41,22 @@ function code_snippets_upgrader() {
43
  /* Get the current plugin version from the database */
44
  $prev_ms_version = get_site_option( 'code_snippets_version' );
45
 
46
- /* Check if this is the first plugin run */
47
- if ( ! $prev_ms_version ) {
48
-
49
- /* Register multisite capabilities */
50
- $network_cap = apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' );
51
- $supers = get_super_admins();
52
-
53
- foreach ( $supers as $admin ) {
54
- $user = new WP_User( 0, $admin );
55
- $user->add_cap( $network_cap );
56
- }
57
- }
58
-
59
  /* Check if we have upgraded from an older version */
60
  if ( version_compare( $prev_ms_version, CODE_SNIPPETS_VERSION, '<' ) ) {
61
 
62
  /* Update the plugin version stored in the database */
63
  update_site_option( 'code_snippets_version', CODE_SNIPPETS_VERSION );
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
  }
66
  }
18
  /* Get the current plugin version from the database */
19
  $prev_version = get_option( 'code_snippets_version' );
20
 
 
 
 
 
 
 
 
 
21
  /* Check if we have upgraded from an older version */
22
  if ( version_compare( $prev_version, CODE_SNIPPETS_VERSION, '<' ) ) {
23
 
26
 
27
  /* Update the plugin version stored in the database */
28
  update_option( 'code_snippets_version', CODE_SNIPPETS_VERSION );
29
+
30
+ /* Custom capabilities were removed after version 2.9.5 */
31
+ if ( version_compare( $prev_version, '2.9.5', '<=' ) ) {
32
+ $role = get_role( apply_filters( 'code_snippets_role', 'administrator' ) );
33
+ $role->remove_cap( apply_filters( 'code_snippets_cap', 'manage_snippets' ) );
34
+ }
35
  }
36
 
37
  /* Run multisite-only upgrades */
41
  /* Get the current plugin version from the database */
42
  $prev_ms_version = get_site_option( 'code_snippets_version' );
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  /* Check if we have upgraded from an older version */
45
  if ( version_compare( $prev_ms_version, CODE_SNIPPETS_VERSION, '<' ) ) {
46
 
47
  /* Update the plugin version stored in the database */
48
  update_site_option( 'code_snippets_version', CODE_SNIPPETS_VERSION );
49
+
50
+
51
+ /* Custom capabilities were removed after version 2.9.5 */
52
+ if ( version_compare( $prev_ms_version, '2.9.5', '<=' ) ) {
53
+ $network_cap = apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' );
54
+
55
+ foreach ( get_super_admins() as $admin ) {
56
+ $user = new WP_User( 0, $admin );
57
+ $user->remove_cap( $network_cap );
58
+ }
59
+ }
60
  }
61
  }
62
  }
php/views/edit.php CHANGED
@@ -129,16 +129,6 @@ $snippet = get_snippet( $edit_id );
129
 
130
  ?>
131
  </p>
132
-
133
- <?php if ( has_action( 'code_snippets/admin/single/settings' ) ) : ?>
134
-
135
- <h2><?php _e( 'Settings', 'code-snippets' ); ?></h2>
136
- <table class="form-table">
137
- <?php do_action( 'code_snippets/admin/single/settings', $snippet ); ?>
138
- </table>
139
-
140
- <?php endif; ?>
141
-
142
  </form>
143
  </div>
144
 
129
 
130
  ?>
131
  </p>
 
 
 
 
 
 
 
 
 
 
132
  </form>
133
  </div>
134
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://bungeshea.com/donate/
4
  Tags: code-snippets, snippets, code, php, network, multisite
5
  Requires at least: 3.6
6
  Tested up to: 4.9.1
7
- Stable tag: 2.9.5
8
  License: MIT
9
  License URI: license.txt
10
 
@@ -26,6 +26,7 @@ If you have any feedback, issues, or suggestions for improvements please leave a
26
 
27
  Code Snippets can be used in these different languages thanks to the following translators:
28
 
 
29
  * French (Canada) - [Dominic Desbiens](http://www.dominicdesbiens.com/)
30
  * Indonesian - [Jordan Silaen from ChameleonJohn.com](https://www.chameleonjohn.com/)
31
  * German - [Mario Siegmann](http://web-alltag.de/), [Joerg Knoerchen](http://www.sensorgrafie.de/), and [David Decker](http://deckerweb.de)
@@ -110,6 +111,12 @@ That's fantastic! Fork the [repository on GitHub](http://github.com/sheabunge/co
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
113
  = 2.9.5 (13 Jan 2018) =
114
  * Fixed: Undefined function error when accessing the database on multisite
115
  * Fixed: Ensured all admin headings are hierarchical for accessibility
4
  Tags: code-snippets, snippets, code, php, network, multisite
5
  Requires at least: 3.6
6
  Tested up to: 4.9.1
7
+ Stable tag: 2.9.6
8
  License: MIT
9
  License URI: license.txt
10
 
26
 
27
  Code Snippets can be used in these different languages thanks to the following translators:
28
 
29
+ * Brazilian Portuguese – [Bruno Borges](http://brunoborges.info)
30
  * French (Canada) - [Dominic Desbiens](http://www.dominicdesbiens.com/)
31
  * Indonesian - [Jordan Silaen from ChameleonJohn.com](https://www.chameleonjohn.com/)
32
  * German - [Mario Siegmann](http://web-alltag.de/), [Joerg Knoerchen](http://www.sensorgrafie.de/), and [David Decker](http://deckerweb.de)
111
 
112
  == Changelog ==
113
 
114
+ = 2.9.6 (14 Jan 2018) =
115
+ * Added Brazilian Portuguese translation by [Bruno Borges](http://brunoborges.info)
116
+ * Fixed: Use standard WordPress capabilities instead of custom capabilities to prevent lockouts
117
+ * Fixed: Multisite issue with retrieving active shared snippets from the wrong table causing duplicate snippet execution
118
+ * Moved scope and other settings on single snippet page to below code area
119
+
120
  = 2.9.5 (13 Jan 2018) =
121
  * Fixed: Undefined function error when accessing the database on multisite
122
  * Fixed: Ensured all admin headings are hierarchical for accessibility
uninstall.php CHANGED
@@ -25,10 +25,6 @@ function code_snippets_uninstall_site() {
25
  delete_option( 'code_snippets_version' );
26
  delete_option( 'recently_activated_snippets' );
27
  delete_option( 'code_snippets_settings' );
28
-
29
- /* Deregister capabilities */
30
- $role = get_role( apply_filters( 'code_snippets_role', 'administrator' ) );
31
- $role->remove_cap( apply_filters( 'code_snippets_cap', 'manage_snippets' ) );
32
  }
33
 
34
 
@@ -60,15 +56,6 @@ if ( is_multisite() ) {
60
  /* Remove saved options */
61
  delete_site_option( 'code_snippets_version' );
62
  delete_site_option( 'recently_activated_snippets' );
63
-
64
- /* Remove multisite capabilities */
65
- $network_cap = apply_filters( 'code_snippets_network_cap', 'manage_network_snippets' );
66
- $supers = get_super_admins();
67
-
68
- foreach ( $supers as $admin ) {
69
- $user = new WP_User( 0, $admin );
70
- $user->remove_cap( $network_cap );
71
- }
72
  } else {
73
  code_snippets_uninstall_site();
74
  }
25
  delete_option( 'code_snippets_version' );
26
  delete_option( 'recently_activated_snippets' );
27
  delete_option( 'code_snippets_settings' );
 
 
 
 
28
  }
29
 
30
 
56
  /* Remove saved options */
57
  delete_site_option( 'code_snippets_version' );
58
  delete_site_option( 'recently_activated_snippets' );
 
 
 
 
 
 
 
 
 
59
  } else {
60
  code_snippets_uninstall_site();
61
  }