Insert Headers and Footers - Version 2.0.2

Version Description

  • Tweak: Snippets used as shortcodes will no longer be executed if they are inactive.
  • Fix: Conditional logic rules for homepage were not working correctly in all scenarios.
  • Fix: Improved auto-insert location matching to avoid snippets not loading in some setups.
  • Fix: We improved the importer tools to avoid unslashing certain types of PHP code.
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.0.2

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.1
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.2
6
  * Requires at least: 4.6
7
  * Requires PHP: 5.5
8
  * Tested up to: 6.0
includes/admin/importers/class-wpcode-importer-code-snippets.php CHANGED
@@ -148,7 +148,7 @@ class WPCode_Importer_Code_Snippets extends WPCode_Importer_Type {
148
  }
149
 
150
  return array(
151
- 'code' => $snippet->code,
152
  'note' => $snippet->desc,
153
  'title' => $snippet->name,
154
  'tags' => $snippet->tags,
148
  }
149
 
150
  return array(
151
+ 'code' => wp_slash( $snippet->code ),
152
  'note' => $snippet->desc,
153
  'title' => $snippet->name,
154
  'tags' => $snippet->tags,
includes/admin/importers/class-wpcode-importer-woody.php CHANGED
@@ -150,7 +150,7 @@ class WPCode_Importer_Woody extends WPCode_Importer_Type {
150
  }
151
 
152
  return array(
153
- 'code' => WINP_Helper::get_snippet_code( $snippet ),
154
  'note' => WINP_Helper::getMetaOption( $snippet->ID, 'snippet_description', '' ),
155
  'title' => $snippet->post_title,
156
  'tags' => wp_get_post_terms( $snippet->ID, WINP_SNIPPETS_TAXONOMY, array( 'fields' => 'slugs' ) ),
150
  }
151
 
152
  return array(
153
+ 'code' => wp_slash( WINP_Helper::get_snippet_code( $snippet ) ),
154
  'note' => WINP_Helper::getMetaOption( $snippet->ID, 'snippet_description', '' ),
155
  'title' => $snippet->post_title,
156
  'tags' => wp_get_post_terms( $snippet->ID, WINP_SNIPPETS_TAXONOMY, array( 'fields' => 'slugs' ) ),
includes/admin/pages/class-wpcode-admin-page-snippet-manager.php CHANGED
@@ -825,6 +825,8 @@ class WPCode_Admin_Page_Snippet_Manager extends WPCode_Admin_Page {
825
  public function set_code_type() {
826
  if ( isset( $this->snippet ) ) {
827
  $this->code_type = $this->snippet->get_code_type();
 
 
828
  }
829
  }
830
 
825
  public function set_code_type() {
826
  if ( isset( $this->snippet ) ) {
827
  $this->code_type = $this->snippet->get_code_type();
828
+ } else {
829
+ $this->code_type = apply_filters( 'wpcode_default_code_type', $this->code_type );
830
  }
831
  }
832
 
includes/admin/pages/class-wpcode-admin-page-tools.php CHANGED
@@ -616,7 +616,8 @@ class WPCode_Admin_Page_Tools extends WPCode_Admin_Page {
616
  // We don't want to update existing snippets/posts.
617
  unset( $snippet['id'] );
618
  }
619
- $new_snippet = new WPCode_Snippet( $snippet );
 
620
  $new_snippet->save();
621
  }
622
 
616
  // We don't want to update existing snippets/posts.
617
  unset( $snippet['id'] );
618
  }
619
+ $snippet['code'] = wp_slash( $snippet['code'] );
620
+ $new_snippet = new WPCode_Snippet( $snippet );
621
  $new_snippet->save();
622
  }
623
 
includes/auto-insert/class-wpcode-auto-insert-archive.php CHANGED
@@ -32,7 +32,7 @@ class WPCode_Auto_Insert_Archive extends WPCode_Auto_Insert_Type {
32
  * @return bool
33
  */
34
  public function conditions() {
35
- return is_archive();
36
  }
37
 
38
  /**
32
  * @return bool
33
  */
34
  public function conditions() {
35
+ return is_archive() || is_home();
36
  }
37
 
38
  /**
includes/auto-insert/class-wpcode-auto-insert-type.php CHANGED
@@ -207,7 +207,7 @@ abstract class WPCode_Auto_Insert_Type {
207
  // so that they can be picked up by id later without having to query again.
208
  $location_terms = $this->get_location_terms();
209
  foreach ( $location_terms as $location_key => $location_term ) {
210
- $term_id = $location_term->term_id;
211
  $this->snippets[ $location_key ] = array();
212
  // Until we update to PHP 5.3 this is the easiest way to do this.
213
  foreach ( $snippets as $snippet ) {
207
  // so that they can be picked up by id later without having to query again.
208
  $location_terms = $this->get_location_terms();
209
  foreach ( $location_terms as $location_key => $location_term ) {
210
+ $term_id = $location_term->term_taxonomy_id;
211
  $this->snippets[ $location_key ] = array();
212
  // Until we update to PHP 5.3 this is the easiest way to do this.
213
  foreach ( $snippets as $snippet ) {
includes/conditional-logic/class-wpcode-conditional-page.php CHANGED
@@ -147,6 +147,9 @@ class WPCode_Conditional_Page extends WPCode_Conditional_Type {
147
  * @return string
148
  */
149
  public function get_type_of_page() {
 
 
 
150
  if ( is_singular() ) {
151
  return 'is_single';
152
  }
@@ -156,9 +159,6 @@ class WPCode_Conditional_Page extends WPCode_Conditional_Type {
156
  if ( is_search() ) {
157
  return 'is_search';
158
  }
159
- if ( is_front_page() || is_home() ) {
160
- return 'is_front_page';
161
- }
162
  if ( is_404() ) {
163
  return 'is_404';
164
  }
147
  * @return string
148
  */
149
  public function get_type_of_page() {
150
+ if ( is_front_page() || is_home() ) {
151
+ return 'is_front_page';
152
+ }
153
  if ( is_singular() ) {
154
  return 'is_single';
155
  }
159
  if ( is_search() ) {
160
  return 'is_search';
161
  }
 
 
 
162
  if ( is_404() ) {
163
  return 'is_404';
164
  }
includes/shortcode.php CHANGED
@@ -26,5 +26,11 @@ function wpcode_shortcode_handler( $args ) {
26
  return '';
27
  }
28
 
29
- return wpcode()->execute->get_snippet_output( absint( $atts['id'] ) );
 
 
 
 
 
 
30
  }
26
  return '';
27
  }
28
 
29
+ $snippet = new WPCode_Snippet( absint( $atts['id'] ) );
30
+
31
+ if ( ! $snippet->is_active() ) {
32
+ return '';
33
+ }
34
+
35
+ return wpcode()->execute->get_snippet_output( $snippet );
36
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: code, css, php, footer, functions, content, facebook pixel, footer code, f
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
 
@@ -285,6 +285,12 @@ Syed Balkhi
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.
4
  Requires at least: 4.6
5
  Tested up to: 6.0
6
  Requires PHP: 5.5
7
+ Stable tag: 2.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
285
 
286
  == Changelog ==
287
 
288
+ = 2.0.2 =
289
+ * Tweak: Snippets used as shortcodes will no longer be executed if they are inactive.
290
+ * Fix: Conditional logic rules for homepage were not working correctly in all scenarios.
291
+ * Fix: Improved auto-insert location matching to avoid snippets not loading in some setups.
292
+ * Fix: We improved the importer tools to avoid unslashing certain types of PHP code.
293
+
294
  = 2.0.1 =
295
  * Tweak: Auto-insert is now the default option when creating a new snippet.
296
  * Tweak: We updated the way we add custom capabilities to improve a scenario where the plugin needed to be reactivated.