Insert Headers and Footers - Version 2.0.1

Version Description

  • Tweak: Auto-insert is now the default option when creating a new snippet.
  • Tweak: We updated the way we add custom capabilities to improve a scenario where the plugin needed to be reactivated.
  • Fix: We updated the way PHP code is saved to improve support for backslashes.
  • Fix: We tweaked the Page URL rules that were not matching in some cases.
Download this release

Release Info

Developer gripgrip
Plugin Icon 128x128 Insert Headers and Footers
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0.0 to 2.0.1

ihaf.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: WPCode - Insert Headers, Footers, and Code Snippets
4
  * Plugin URI: https://www.wpcode.com/
5
- * Version: 2.0.0
6
  * Requires at least: 4.6
7
  * Requires PHP: 5.5
8
  * Tested up to: 6.0
2
  /**
3
  * Plugin Name: WPCode - Insert Headers, Footers, and Code Snippets
4
  * Plugin URI: https://www.wpcode.com/
5
+ * Version: 2.0.1
6
  * Requires at least: 4.6
7
  * Requires PHP: 5.5
8
  * Tested up to: 6.0
includes/admin/admin-menu.php CHANGED
@@ -10,6 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  }
11
 
12
  add_action( 'admin_menu', 'wpcode_register_admin_menu', 9 );
 
13
 
14
  /**
15
  * Register the admin menu items.
@@ -25,7 +26,7 @@ function wpcode_register_admin_menu() {
25
  $svg = get_wpcode_icon( 'logo', 36, 34, '-10 -6 80 80' );
26
  $wpcode_icon = 'data:image/svg+xml;base64,' . base64_encode( $svg ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
27
 
28
- add_menu_page( __( 'Code Snippets', 'insert-headers-and-footers' ), __( 'Code Snippets', 'insert-headers-and-footers' ), 'wpcode_edit_snippets', 'wpcode', 'wpcode_admin_menu_page', $wpcode_icon, '81.4568' );
29
 
30
  wpcode_load_admin_pages();
31
  }
@@ -69,3 +70,27 @@ function wpcode_load_admin_pages() {
69
  new WPCode_Admin_Page_Tools();
70
  new WPCode_Admin_Page_Settings();
71
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
11
 
12
  add_action( 'admin_menu', 'wpcode_register_admin_menu', 9 );
13
+ add_filter( 'plugin_action_links_' . WPCODE_PLUGIN_BASENAME, 'wpcode_add_plugin_action_links' );
14
 
15
  /**
16
  * Register the admin menu items.
26
  $svg = get_wpcode_icon( 'logo', 36, 34, '-10 -6 80 80' );
27
  $wpcode_icon = 'data:image/svg+xml;base64,' . base64_encode( $svg ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
28
 
29
+ add_menu_page( __( 'Code Snippets', 'insert-headers-and-footers' ), __( 'Code Snippets', 'insert-headers-and-footers' ), 'wpcode_edit_snippets', 'wpcode', 'wpcode_admin_menu_page', $wpcode_icon, '81.45687234432916' );
30
 
31
  wpcode_load_admin_pages();
32
  }
70
  new WPCode_Admin_Page_Tools();
71
  new WPCode_Admin_Page_Settings();
72
  }
73
+
74
+ /**
75
+ * Add a link to the code snippets list in the plugins list view.
76
+ *
77
+ * @param array $links The links specific to our plugin.
78
+ *
79
+ * @return array
80
+ */
81
+ function wpcode_add_plugin_action_links( $links ) {
82
+ $wpcode_links = array(
83
+ sprintf(
84
+ '<a href="%1$s">%2$s</a>',
85
+ add_query_arg(
86
+ array(
87
+ 'page' => 'wpcode',
88
+ ),
89
+ admin_url( 'admin.php' )
90
+ ),
91
+ esc_html__( 'Code Snippets', 'insert-headers-and-footers' )
92
+ ),
93
+ );
94
+
95
+ return array_merge( $wpcode_links, $links );
96
+ }
includes/admin/pages/class-wpcode-admin-page-snippet-manager.php CHANGED
@@ -298,7 +298,7 @@ class WPCode_Admin_Page_Snippet_Manager extends WPCode_Admin_Page {
298
  <?php $this->field_code_type(); ?>
299
  </div>
300
  </div>
301
- <textarea name="wpcode_snippet_code" id="wpcode_snippet_code" class="widefat" rows="8" <?php disabled( ! current_user_can( 'unfiltered_html' ) ); ?>><?php echo esc_html( wp_unslash( $value ) ); ?></textarea>
302
  <?php
303
  wp_editor(
304
  $value,
@@ -460,7 +460,7 @@ class WPCode_Admin_Page_Snippet_Manager extends WPCode_Admin_Page {
460
  * @return int
461
  */
462
  private function get_auto_insert_value() {
463
- return isset( $this->snippet ) ? $this->snippet->get_auto_insert() : 0;
464
  }
465
 
466
  /**
@@ -726,7 +726,7 @@ class WPCode_Admin_Page_Snippet_Manager extends WPCode_Admin_Page {
726
  }
727
 
728
  $code_type = isset( $_POST['wpcode_snippet_type'] ) ? sanitize_text_field( wp_unslash( $_POST['wpcode_snippet_type'] ) ) : 'html';
729
- $snippet_code = isset( $_POST['wpcode_snippet_code'] ) ? wp_unslash( $_POST['wpcode_snippet_code'] ) : '';
730
  if ( 'text' === $code_type ) {
731
  $snippet_code = wpautop( $snippet_code );
732
  }
298
  <?php $this->field_code_type(); ?>
299
  </div>
300
  </div>
301
+ <textarea name="wpcode_snippet_code" id="wpcode_snippet_code" class="widefat" rows="8" <?php disabled( ! current_user_can( 'unfiltered_html' ) ); ?>><?php echo esc_html( $value ); ?></textarea>
302
  <?php
303
  wp_editor(
304
  $value,
460
  * @return int
461
  */
462
  private function get_auto_insert_value() {
463
+ return isset( $this->snippet ) ? $this->snippet->get_auto_insert() : 1;
464
  }
465
 
466
  /**
726
  }
727
 
728
  $code_type = isset( $_POST['wpcode_snippet_type'] ) ? sanitize_text_field( wp_unslash( $_POST['wpcode_snippet_type'] ) ) : 'html';
729
+ $snippet_code = isset( $_POST['wpcode_snippet_code'] ) ? $_POST['wpcode_snippet_code'] : '';
730
  if ( 'text' === $code_type ) {
731
  $snippet_code = wpautop( $snippet_code );
732
  }
includes/class-wpcode-capabilities.php CHANGED
@@ -31,7 +31,7 @@ class WPCode_Capabilities {
31
  * @return WP_Role[]
32
  */
33
  public static function get_roles() {
34
- $roles = get_editable_roles();
35
  $role_array = array();
36
  foreach ( array_keys( $roles ) as $role_key ) {
37
  $role_array[] = get_role( $role_key );
31
  * @return WP_Role[]
32
  */
33
  public static function get_roles() {
34
+ $roles = wp_roles()->roles;
35
  $role_array = array();
36
  foreach ( array_keys( $roles ) as $role_key ) {
37
  $role_array[] = get_role( $role_key );
includes/class-wpcode-snippet-execute.php CHANGED
@@ -394,4 +394,13 @@ class WPCode_Snippet_Execute {
394
  public function is_doing_activation() {
395
  return $this->doing_activation;
396
  }
 
 
 
 
 
 
 
 
 
397
  }
394
  public function is_doing_activation() {
395
  return $this->doing_activation;
396
  }
397
+
398
+ /**
399
+ * Mark as finished activation.
400
+ *
401
+ * @return void
402
+ */
403
+ public function not_doing_activation() {
404
+ $this->doing_activation = false;
405
+ }
406
  }
includes/class-wpcode-snippet.php CHANGED
@@ -490,6 +490,8 @@ class WPCode_Snippet {
490
  if ( $has_error ) {
491
  $this->active = false;
492
  }
 
 
493
  }
494
 
495
  /**
490
  if ( $has_error ) {
491
  $this->active = false;
492
  }
493
+
494
+ wpcode()->execute->not_doing_activation();
495
  }
496
 
497
  /**
includes/conditional-logic/class-wpcode-conditional-page.php CHANGED
@@ -193,7 +193,8 @@ class WPCode_Conditional_Page extends WPCode_Conditional_Type {
193
  * @return string
194
  */
195
  public function get_page_url() {
196
- return isset( $_SERVER['REQUEST_URI'] ) ? home_url( $_SERVER['REQUEST_URI'] ) : '';
 
197
  }
198
 
199
  /**
@@ -252,19 +253,4 @@ class WPCode_Conditional_Page extends WPCode_Conditional_Type {
252
 
253
  return $labels;
254
  }
255
-
256
- /**
257
- * Override the main rule evaluate function to add some specific processing of values.
258
- *
259
- * @param array $rule_group The rule group array to evaluate.
260
- *
261
- * @return bool
262
- */
263
- public function evaluate_rule_row( $rule_group ) {
264
- if ( 'page_url' === $rule_group['option'] ) {
265
- $rule_group['value'] = trailingslashit( $rule_group['value'] );
266
- }
267
-
268
- return parent::evaluate_rule_row( $rule_group );
269
- }
270
  }
193
  * @return string
194
  */
195
  public function get_page_url() {
196
+ global $wp;
197
+ return isset( $wp->request ) ? trailingslashit( home_url( $wp->request ) ) : '';
198
  }
199
 
200
  /**
253
 
254
  return $labels;
255
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  }
includes/execute/class-wpcode-snippet-execute-php.php CHANGED
@@ -24,6 +24,10 @@ class WPCode_Snippet_Execute_PHP extends WPCode_Snippet_Execute_Type {
24
  */
25
  protected function prepare_snippet_output() {
26
  $code = $this->get_snippet_code();
 
 
 
 
27
 
28
  return wpcode()->execute->safe_execute_php( $code, $this->snippet );
29
  }
24
  */
25
  protected function prepare_snippet_output() {
26
  $code = $this->get_snippet_code();
27
+ // If we're doing the activation, unslash the code similar to how it will be unslashed before saving in wp_insert_post.
28
+ if ( wpcode()->execute->is_doing_activation() ) {
29
+ $code = wp_unslash( $code );
30
+ }
31
 
32
  return wpcode()->execute->safe_execute_php( $code, $this->snippet );
33
  }
languages/insert-headers-and-footers.pot CHANGED
@@ -2,14 +2,14 @@
2
  # This file is distributed under the GPLv2 or later.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WPCode - Insert Headers, Footers, and Code Snippets 2.0.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wpcode\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "POT-Creation-Date: 2022-07-19T10:07:09+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.5.0\n"
15
  "X-Domain: insert-headers-and-footers\n"
@@ -59,7 +59,8 @@ msgstr ""
59
  msgid "There was an error and the connection failed. Please contact your web host with the technical details below."
60
  msgstr ""
61
 
62
- #: includes/admin/admin-menu.php:28
 
63
  #: includes/admin/pages/class-wpcode-admin-page-code-snippets.php:32
64
  msgid "Code Snippets"
65
  msgstr ""
2
  # This file is distributed under the GPLv2 or later.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WPCode - Insert Headers, Footers, and Code Snippets 2.0.1\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wpcode\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "POT-Creation-Date: 2022-07-22T06:45:55+00:00\n"
13
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
  "X-Generator: WP-CLI 2.5.0\n"
15
  "X-Domain: insert-headers-and-footers\n"
59
  msgid "There was an error and the connection failed. Please contact your web host with the technical details below."
60
  msgstr ""
61
 
62
+ #: includes/admin/admin-menu.php:29
63
+ #: includes/admin/admin-menu.php:90
64
  #: includes/admin/pages/class-wpcode-admin-page-code-snippets.php:32
65
  msgid "Code Snippets"
66
  msgstr ""
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === Insert Headers and Footers - Code Snippets by WPCode - Easy WordPress Code Manager ===
2
  Contributors: WPbeginner, smub, gripgrip
3
  Tags: code, css, php, footer, functions, content, facebook pixel, footer code, footer scripts, footers, google analytics, head, header, header code, header scripts, headers, insert, insert code, insert scripts, js, meta, meta tags, scripts, html, javascript, multisite, code snippets
4
  Requires at least: 4.6
5
  Tested up to: 6.0
6
  Requires PHP: 5.5
7
- Stable tag: 2.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -108,7 +108,7 @@ Managing multiple websites or developing in a staging environment?
108
 
109
  We offer an easy way to import and export your custom code snippets, functions, and header and footer scripts to help you save time.
110
 
111
- Switching from another code snippets plugin?
112
 
113
  We have an automatic import feature that imports your custom code snippets from both Woody Code Snippets and Code Snippets Pro plugin.
114
 
@@ -285,10 +285,16 @@ Syed Balkhi
285
 
286
  == Changelog ==
287
 
 
 
 
 
 
 
288
  = 2.0.0 =
289
- * New: Insert Headers and Footers is now WPCode - We make it easy for you to add code snippets in WordPress without having to edit your theme’s functions.php file.
290
  * New: Full Code Snippets Library - WordPress code snippets library right inside the WPCode plugin.
291
- * New: WordPress code generators to help you quickly generate ready-to-use code using the latest WordPress coding standards and API’s.
292
  * New: Conditional Logic for Code Snippets - Instead of learning the various WordPress conditional logic queries, you can use our beginner-friendly conditional logic user interface.
293
  * New: Auto-insert in various locations of your site or manual code output using shortcodes.
294
 
@@ -353,4 +359,4 @@ Syed Balkhi
353
  * fixed unnecessary CSS loading
354
 
355
  = 1.0 =
356
- * Initial version
1
+ === WPCode - Insert Headers and Footers + Custom Code Snippets - WordPress Code Manager ===
2
  Contributors: WPbeginner, smub, gripgrip
3
  Tags: code, css, php, footer, functions, content, facebook pixel, footer code, footer scripts, footers, google analytics, head, header, header code, header scripts, headers, insert, insert code, insert scripts, js, meta, meta tags, scripts, html, javascript, multisite, code snippets
4
  Requires at least: 4.6
5
  Tested up to: 6.0
6
  Requires PHP: 5.5
7
+ Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
108
 
109
  We offer an easy way to import and export your custom code snippets, functions, and header and footer scripts to help you save time.
110
 
111
+ Switching from another code snippets plugin?
112
 
113
  We have an automatic import feature that imports your custom code snippets from both Woody Code Snippets and Code Snippets Pro plugin.
114
 
285
 
286
  == Changelog ==
287
 
288
+ = 2.0.1 =
289
+ * Tweak: Auto-insert is now the default option when creating a new snippet.
290
+ * Tweak: We updated the way we add custom capabilities to improve a scenario where the plugin needed to be reactivated.
291
+ * Fix: We updated the way PHP code is saved to improve support for backslashes.
292
+ * Fix: We tweaked the Page URL rules that were not matching in some cases.
293
+
294
  = 2.0.0 =
295
+ * New: Insert Headers and Footers is now WPCode - We make it easy for you to add code snippets in WordPress without having to edit your theme's functions.php file.
296
  * New: Full Code Snippets Library - WordPress code snippets library right inside the WPCode plugin.
297
+ * New: WordPress code generators to help you quickly generate ready-to-use code using the latest WordPress coding standards and APIs.
298
  * New: Conditional Logic for Code Snippets - Instead of learning the various WordPress conditional logic queries, you can use our beginner-friendly conditional logic user interface.
299
  * New: Auto-insert in various locations of your site or manual code output using shortcodes.
300
 
359
  * fixed unnecessary CSS loading
360
 
361
  = 1.0 =
362
+ * Initial version