Header Footer Code Manager - Version 1.1.22

Version Description

2022-05-10 * FIXED: PHP warnings when adding/editing snippets * UPDATED: Add confirmation before deleting snippets * UPDATED: Copy shortcode button

Download this release

Release Info

Developer 99robots
Plugin Icon 128x128 Header Footer Code Manager
Version 1.1.22
Comparing to
See all releases

Code changes from version 1.1.21 to 1.1.22

99robots-header-footer-code-manager.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Header Footer Code Manager
4
  * Plugin URI: https://draftpress.com/products
5
  * Description: Header Footer Code Manager by 99 Robots is a quick and simple way for you to add tracking code snippets, conversion pixels, or other scripts required by third party services for analytics, tracking, marketing, or chat functions. For detailed documentation, please visit the plugin's <a href="https://draftpress.com/"> official page</a>.
6
- * Version: 1.1.21
7
  * Requires at least: 4.9
8
  * Requires PHP: 5.6.20
9
  * Author: 99robots
@@ -343,8 +343,11 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
343
  ?>
344
  <div id="hfcm-message" class="notice notice-success">
345
  <p>
346
- 🔥 LIFETIME DEAL ALERT: The PRO version of this plugin is released and and available for a limited time as a one-time, exclusive lifetime deal.
347
- Want it? <b><i><a href="http://www.rockethub.com/deal/header-footer-code-manager-pro-wordpress-plugin?utm_source=freehfcm&utm_medium=banner&utm_campaign=rhltd" target="_blank">Click here</a> to get HFCM Pro for the lowest price ever</i></b>
 
 
 
348
  </p>
349
  </div>
350
  <?php
@@ -836,27 +839,31 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
836
  // Global vars
837
  global $wpdb;
838
  $table_name = $wpdb->prefix . self::$nnr_hfcm_table;
839
-
840
  // Get all selected posts
841
  if ( -1 === $id ) {
842
  $s_posts = array();
843
  $ex_posts = array();
844
  } else {
845
-
846
  // Select value to update
847
- $script = $wpdb->get_results( $wpdb->prepare( "SELECT s_posts FROM $table_name WHERE script_id=%s", $id ) );
848
- foreach ( $script as $s ) {
849
- $s_posts = json_decode( $s->s_posts );
850
- if ( !is_array( $s_posts ) ) {
851
- $s_posts = array();
 
 
 
852
  }
853
  }
854
 
 
855
  $script_ex = $wpdb->get_results( $wpdb->prepare( "SELECT ex_posts FROM $table_name WHERE script_id=%s", $id ) );
856
- foreach ( $script_ex as $s ) {
857
- $ex_posts = json_decode( $s->ex_posts );
858
- if ( !is_array( $ex_posts ) ) {
859
- $ex_posts = array();
 
 
860
  }
861
  }
862
  }
@@ -891,24 +898,26 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
891
  'excluded' => array(),
892
  );
893
 
894
- foreach ( $posts as $pdata ) {
895
- $nnr_hfcm_post_title = trim( $pdata->post_title );
 
896
 
897
- if ( empty( $nnr_hfcm_post_title ) ) {
898
- $nnr_hfcm_post_title = "(no title)";
899
- }
900
- if ( in_array( $pdata->ID, $ex_posts ) ) {
901
- $json_output['excluded'][] = $pdata->ID;
902
- }
903
 
904
- if ( in_array( $pdata->ID, $s_posts ) ) {
905
- $json_output['selected'][] = $pdata->ID;
906
- }
907
 
908
- $json_output['posts'][] = array(
909
- 'text' => sanitize_text_field( $nnr_hfcm_post_title ),
910
- 'value' => $pdata->ID,
911
- );
 
912
  }
913
 
914
  echo wp_json_encode( $json_output );
@@ -1176,11 +1185,16 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
1176
  $nnr_non_script_snippets = 1;
1177
  foreach ( $nnr_hfcm_snippets->snippets as $nnr_hfcm_key => $nnr_hfcm_snippet ) {
1178
  $nnr_hfcm_snippet = (array) $nnr_hfcm_snippet;
1179
- if ( !empty( $nnr_hfcm_snippet['snippet_type'] ) && !in_array( $nnr_hfcm_snippet['snippet_type'], array( "html", "css", "js" ) ) ) {
 
 
1180
  $nnr_non_script_snippets = 2;
1181
  continue;
1182
  }
1183
- if ( !empty( $nnr_hfcm_snippet['location'] ) && !in_array( $nnr_hfcm_snippet['location'], array( 'header', 'before_content', 'after_content', 'footer' ) ) ) {
 
 
 
1184
  $nnr_non_script_snippets = 2;
1185
  continue;
1186
  }
@@ -1247,13 +1261,13 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
1247
 
1248
  public static function hfcm_get_categories()
1249
  {
1250
- $args = array(
1251
  'public' => true,
1252
  'hierarchical' => true
1253
  );
1254
- $output = 'objects'; // or objects
1255
- $operator = 'and'; // 'and' or 'or'
1256
- $taxonomies = get_taxonomies( $args, $output, $operator );
1257
 
1258
  $nnr_hfcm_categories = [];
1259
 
@@ -1266,7 +1280,7 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
1266
  'name' => $taxonomy->label,
1267
  'terms' => $nnr_hfcm_taxonomy_categories
1268
  ];
1269
- $nnr_hfcm_categories[] = $nnr_hfcm_taxonomy_categories;
1270
  }
1271
 
1272
  return $nnr_hfcm_categories;
@@ -1274,14 +1288,14 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
1274
 
1275
  public static function hfcm_get_tags()
1276
  {
1277
- $args = array( 'hide_empty' => 0 );
1278
- $args = array(
1279
  'public' => true,
1280
  'hierarchical' => false
1281
  );
1282
- $output = 'objects'; // or objects
1283
- $operator = 'and'; // 'and' or 'or'
1284
- $taxonomies = get_taxonomies( $args, $output, $operator );
1285
 
1286
  $nnr_hfcm_tags = [];
1287
 
@@ -1294,7 +1308,7 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
1294
  'name' => $taxonomy->label,
1295
  'terms' => $nnr_hfcm_taxonomy_tags
1296
  ];
1297
- $nnr_hfcm_tags[] = $nnr_hfcm_taxonomy_tags;
1298
  }
1299
 
1300
  return $nnr_hfcm_tags;
3
  * Plugin Name: Header Footer Code Manager
4
  * Plugin URI: https://draftpress.com/products
5
  * Description: Header Footer Code Manager by 99 Robots is a quick and simple way for you to add tracking code snippets, conversion pixels, or other scripts required by third party services for analytics, tracking, marketing, or chat functions. For detailed documentation, please visit the plugin's <a href="https://draftpress.com/"> official page</a>.
6
+ * Version: 1.1.22
7
  * Requires at least: 4.9
8
  * Requires PHP: 5.6.20
9
  * Author: 99robots
343
  ?>
344
  <div id="hfcm-message" class="notice notice-success">
345
  <p>
346
+ 🔥 LIFETIME DEAL ALERT: The PRO version of this plugin is released and and available for a
347
+ limited time as a one-time, exclusive lifetime deal.
348
+ Want it? <b><i><a
349
+ href="http://www.rockethub.com/deal/header-footer-code-manager-pro-wordpress-plugin?utm_source=freehfcm&utm_medium=banner&utm_campaign=rhltd"
350
+ target="_blank">Click here</a> to get HFCM Pro for the lowest price ever</i></b>
351
  </p>
352
  </div>
353
  <?php
839
  // Global vars
840
  global $wpdb;
841
  $table_name = $wpdb->prefix . self::$nnr_hfcm_table;
 
842
  // Get all selected posts
843
  if ( -1 === $id ) {
844
  $s_posts = array();
845
  $ex_posts = array();
846
  } else {
 
847
  // Select value to update
848
+ $script = $wpdb->get_results( $wpdb->prepare( "SELECT s_posts FROM $table_name WHERE script_id=%s", $id ) );
849
+ $s_posts = array();
850
+ if ( !empty( $script ) ) {
851
+ foreach ( $script as $s ) {
852
+ $s_posts = json_decode( $s->s_posts );
853
+ if ( !is_array( $s_posts ) ) {
854
+ $s_posts = array();
855
+ }
856
  }
857
  }
858
 
859
+ $ex_posts = array();
860
  $script_ex = $wpdb->get_results( $wpdb->prepare( "SELECT ex_posts FROM $table_name WHERE script_id=%s", $id ) );
861
+ if ( !empty( $script_ex ) ) {
862
+ foreach ( $script_ex as $s ) {
863
+ $ex_posts = json_decode( $s->ex_posts );
864
+ if ( !is_array( $ex_posts ) ) {
865
+ $ex_posts = array();
866
+ }
867
  }
868
  }
869
  }
898
  'excluded' => array(),
899
  );
900
 
901
+ if ( !empty( $posts ) ) {
902
+ foreach ( $posts as $pdata ) {
903
+ $nnr_hfcm_post_title = trim( $pdata->post_title );
904
 
905
+ if ( empty( $nnr_hfcm_post_title ) ) {
906
+ $nnr_hfcm_post_title = "(no title)";
907
+ }
908
+ if ( !empty( $ex_posts ) && in_array( $pdata->ID, $ex_posts ) ) {
909
+ $json_output['excluded'][] = $pdata->ID;
910
+ }
911
 
912
+ if ( !empty( $s_posts ) && in_array( $pdata->ID, $s_posts ) ) {
913
+ $json_output['selected'][] = $pdata->ID;
914
+ }
915
 
916
+ $json_output['posts'][] = array(
917
+ 'text' => sanitize_text_field( $nnr_hfcm_post_title ),
918
+ 'value' => $pdata->ID,
919
+ );
920
+ }
921
  }
922
 
923
  echo wp_json_encode( $json_output );
1185
  $nnr_non_script_snippets = 1;
1186
  foreach ( $nnr_hfcm_snippets->snippets as $nnr_hfcm_key => $nnr_hfcm_snippet ) {
1187
  $nnr_hfcm_snippet = (array) $nnr_hfcm_snippet;
1188
+ if ( !empty( $nnr_hfcm_snippet['snippet_type'] ) && !in_array( $nnr_hfcm_snippet['snippet_type'], array( "html",
1189
+ "css",
1190
+ "js" ) ) ) {
1191
  $nnr_non_script_snippets = 2;
1192
  continue;
1193
  }
1194
+ if ( !empty( $nnr_hfcm_snippet['location'] ) && !in_array( $nnr_hfcm_snippet['location'], array( 'header',
1195
+ 'before_content',
1196
+ 'after_content',
1197
+ 'footer' ) ) ) {
1198
  $nnr_non_script_snippets = 2;
1199
  continue;
1200
  }
1261
 
1262
  public static function hfcm_get_categories()
1263
  {
1264
+ $args = array(
1265
  'public' => true,
1266
  'hierarchical' => true
1267
  );
1268
+ $output = 'objects'; // or objects
1269
+ $operator = 'and'; // 'and' or 'or'
1270
+ $taxonomies = get_taxonomies( $args, $output, $operator );
1271
 
1272
  $nnr_hfcm_categories = [];
1273
 
1280
  'name' => $taxonomy->label,
1281
  'terms' => $nnr_hfcm_taxonomy_categories
1282
  ];
1283
+ $nnr_hfcm_categories[] = $nnr_hfcm_taxonomy_categories;
1284
  }
1285
 
1286
  return $nnr_hfcm_categories;
1288
 
1289
  public static function hfcm_get_tags()
1290
  {
1291
+ $args = array( 'hide_empty' => 0 );
1292
+ $args = array(
1293
  'public' => true,
1294
  'hierarchical' => false
1295
  );
1296
+ $output = 'objects'; // or objects
1297
+ $operator = 'and'; // 'and' or 'or'
1298
+ $taxonomies = get_taxonomies( $args, $output, $operator );
1299
 
1300
  $nnr_hfcm_tags = [];
1301
 
1308
  'name' => $taxonomy->label,
1309
  'terms' => $nnr_hfcm_taxonomy_tags
1310
  ];
1311
+ $nnr_hfcm_tags[] = $nnr_hfcm_taxonomy_tags;
1312
  }
1313
 
1314
  return $nnr_hfcm_tags;
css/style-admin.css CHANGED
@@ -17,9 +17,18 @@
17
  #nnr_newcontent {
18
  width: 75%;
19
  }
 
 
 
 
 
20
  .nnr-btnsave, .nnr-btndelete, .nnr-btn-click-to-copy {
21
  margin-top: 10px !important;
22
  }
 
 
 
 
23
  .padding20 {
24
  padding: 20px !important;
25
  }
17
  #nnr_newcontent {
18
  width: 75%;
19
  }
20
+ .nnr-btndelete {
21
+ color: #cc1818 !important;
22
+ box-shadow: inset 0 0 0 1px #cc1818 !important;
23
+ border: #cc1818 !important;
24
+ }
25
  .nnr-btnsave, .nnr-btndelete, .nnr-btn-click-to-copy {
26
  margin-top: 10px !important;
27
  }
28
+ .nnr-btn-copy-inline {
29
+ text-decoration: underline !important;
30
+ margin-left: 10px;
31
+ }
32
  .padding20 {
33
  padding: 20px !important;
34
  }
includes/hfcm-add-edit.php CHANGED
@@ -352,7 +352,16 @@ wp_enqueue_script( 'hfcm_showboxes' );
352
  <tr>
353
  <th class="hfcm-th-width"><?php esc_html_e( 'Shortcode', '99robots-header-footer-code-manager' ); ?></th>
354
  <td>
355
- <p>[hfcm id="<?php echo esc_html( $id ); ?>"]</p>
 
 
 
 
 
 
 
 
 
356
  </td>
357
  </tr>
358
  <tr>
@@ -385,11 +394,8 @@ wp_enqueue_script( 'hfcm_showboxes' );
385
  <?php if ( $update ) :
386
  $delete_nonce = wp_create_nonce( 'hfcm_delete_snippet' );
387
  ?>
388
- <a href="<?php echo esc_url( admin_url( 'admin.php?page=hfcm-list&action=delete&_wpnonce=' . $delete_nonce . '&snippet=' . $id ) ); ?>"
389
  class="button button-secondary button-large nnr-btndelete"><?php esc_html_e( 'Delete', '99robots-header-footer-code-manager' ); ?></a>
390
- <a data-shortcode='[hfcm id="<?php echo esc_html( $id ); ?>"]' href="javascript:void(0);" class="button button-secondary button-large nnr-btn-click-to-copy" id="hfcm_copy_shortcode">
391
- <?php esc_html_e( 'Copy Shortcode', '99robots-header-footer-code-manager' ); ?>
392
- </a>
393
  <?php endif; ?>
394
  </div>
395
  </div>
352
  <tr>
353
  <th class="hfcm-th-width"><?php esc_html_e( 'Shortcode', '99robots-header-footer-code-manager' ); ?></th>
354
  <td>
355
+ <p>
356
+ [hfcm id="<?php echo esc_html( $id ); ?>"]
357
+ <?php if ( $update ) :
358
+ ?>
359
+ <a data-shortcode='[hfcm id="<?php echo esc_html( $id ); ?>"]' href="javascript:void(0);" class="nnr-btn-click-to-copy nnr-btn-copy-inline" id="hfcm_copy_shortcode">
360
+ <?php esc_html_e( 'Copy', '99robots-header-footer-code-manager' ); ?>
361
+ </a>
362
+ <?php endif; ?>
363
+ </p>
364
+
365
  </td>
366
  </tr>
367
  <tr>
394
  <?php if ( $update ) :
395
  $delete_nonce = wp_create_nonce( 'hfcm_delete_snippet' );
396
  ?>
397
+ <a onclick="return nnr_confirm_delete_snippet();" href="<?php echo esc_url( admin_url( 'admin.php?page=hfcm-list&action=delete&_wpnonce=' . $delete_nonce . '&snippet=' . $id ) ); ?>"
398
  class="button button-secondary button-large nnr-btndelete"><?php esc_html_e( 'Delete', '99robots-header-footer-code-manager' ); ?></a>
 
 
 
399
  <?php endif; ?>
400
  </div>
401
  </div>
js/nnr-hfcm-showboxes.js CHANGED
@@ -50,7 +50,7 @@ function hfcm_remember_loc(new_html) {
50
  jQuery('#data_location option[value="' + tmp + '"]').prop('selected', true);
51
  }
52
 
53
- function hfmcCopyToClipboard(elem) {
54
  // create hidden text element, if it doesn't already exist
55
  var targetId = "_hiddenCopyText_";
56
  var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
@@ -67,6 +67,11 @@ function hfmcCopyToClipboard(elem) {
67
  document.body.appendChild(target);
68
  }
69
  target.textContent = elem.getAttribute('data-shortcode');
 
 
 
 
 
70
  // select the content
71
  var currentFocus = document.activeElement;
72
  target.focus();
@@ -95,6 +100,10 @@ function hfmcCopyToClipboard(elem) {
95
  return succeed;
96
  }
97
 
 
 
 
 
98
  // init selectize.js
99
  jQuery('#loader').show();
100
  jQuery(function ($) {
@@ -148,6 +157,6 @@ jQuery(function ($) {
148
  }
149
 
150
  document.getElementById("hfcm_copy_shortcode").addEventListener("click", function() {
151
- hfmcCopyToClipboard(document.getElementById("hfcm_copy_shortcode"));
152
  });
153
  });
50
  jQuery('#data_location option[value="' + tmp + '"]').prop('selected', true);
51
  }
52
 
53
+ function hfcmCopyToClipboard(elem) {
54
  // create hidden text element, if it doesn't already exist
55
  var targetId = "_hiddenCopyText_";
56
  var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
67
  document.body.appendChild(target);
68
  }
69
  target.textContent = elem.getAttribute('data-shortcode');
70
+ elem.textContent = "Copied!";
71
+
72
+ setTimeout(function () {
73
+ elem.textContent = "Copy";
74
+ }, 2000);
75
  // select the content
76
  var currentFocus = document.activeElement;
77
  target.focus();
100
  return succeed;
101
  }
102
 
103
+ function nnr_confirm_delete_snippet() {
104
+ return confirm("Are you sure you want to delete this snippet?");
105
+ }
106
+
107
  // init selectize.js
108
  jQuery('#loader').show();
109
  jQuery(function ($) {
157
  }
158
 
159
  document.getElementById("hfcm_copy_shortcode").addEventListener("click", function() {
160
+ hfcmCopyToClipboard(document.getElementById("hfcm_copy_shortcode"));
161
  });
162
  });
js/toggle.js CHANGED
@@ -23,7 +23,7 @@ jQuery('.snippets .delete > a').on('click', function () {
23
  return confirm('Snippet name: ' + name + '\n\nAre you sure you want to delete this snippet?');
24
  });
25
 
26
- function hfmcCopyToClipboard(elem) {
27
  // create hidden text element, if it doesn't already exist
28
  var targetId = "_hiddenCopyText_";
29
  var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
@@ -40,6 +40,11 @@ function hfmcCopyToClipboard(elem) {
40
  document.body.appendChild(target);
41
  }
42
  target.textContent = elem.getAttribute('data-shortcode');
 
 
 
 
 
43
  // select the content
44
  var currentFocus = document.activeElement;
45
  target.focus();
@@ -73,7 +78,7 @@ jQuery(function ($) {
73
 
74
  for (var i = 0; i < elemsCopyBtn.length; i++) {
75
  elemsCopyBtn[i].addEventListener("click", function () {
76
- hfmcCopyToClipboard(document.getElementById(this.id));
77
  });
78
  }
79
  });
23
  return confirm('Snippet name: ' + name + '\n\nAre you sure you want to delete this snippet?');
24
  });
25
 
26
+ function hfcmCopyToClipboard(elem) {
27
  // create hidden text element, if it doesn't already exist
28
  var targetId = "_hiddenCopyText_";
29
  var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
40
  document.body.appendChild(target);
41
  }
42
  target.textContent = elem.getAttribute('data-shortcode');
43
+ elem.textContent = "Copied!";
44
+
45
+ setTimeout(function () {
46
+ elem.textContent = "Copy Shortcode";
47
+ }, 2000);
48
  // select the content
49
  var currentFocus = document.activeElement;
50
  target.focus();
78
 
79
  for (var i = 0; i < elemsCopyBtn.length; i++) {
80
  elemsCopyBtn[i].addEventListener("click", function () {
81
+ hfcmCopyToClipboard(document.getElementById(this.id));
82
  });
83
  }
84
  });
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: header, footer, code manager, snippet, functions.php, tracking, google ana
4
  Requires at least: 4.9
5
  Requires PHP: 5.6.20
6
  Tested up to: 5.9.3
7
- Stable tag: 1.1.21
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://draftpress.com
@@ -114,12 +114,17 @@ A. Free plugins rely on user feedback. Therefore, the best thing you can do for
114
  A. If your script is not supported, just let us know and we'll look into it immediately. We will do our best to ensure all reputable services are supported. When requesting support for a particular script, it would be nice to get a sample of the script so that we can see its structure.
115
 
116
  == Changelog ==
 
 
 
 
 
117
  = 1.1.21 = 2022-04-21
118
  * ADDED: Copy shortcode to clipboard buttons on edit snippet page and on snippet list page
119
  * UPDATED: Compatibility with WordPress 5.9.3
120
  * UPDATED: Included Custom Taxonomies for snippets
121
  * UPDATED: Snippet code editor size
122
- * FIXED: Exclude large number of posts/pages
123
 
124
  = 1.1.20 = 2022-03-26
125
  * FIXED: MultiSite issue with subsites in network
4
  Requires at least: 4.9
5
  Requires PHP: 5.6.20
6
  Tested up to: 5.9.3
7
+ Stable tag: 1.1.22
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://draftpress.com
114
  A. If your script is not supported, just let us know and we'll look into it immediately. We will do our best to ensure all reputable services are supported. When requesting support for a particular script, it would be nice to get a sample of the script so that we can see its structure.
115
 
116
  == Changelog ==
117
+ = 1.1.22 = 2022-05-10
118
+ * FIXED: PHP warnings when adding/editing snippets
119
+ * UPDATED: Add confirmation before deleting snippets
120
+ * UPDATED: Copy shortcode button
121
+
122
  = 1.1.21 = 2022-04-21
123
  * ADDED: Copy shortcode to clipboard buttons on edit snippet page and on snippet list page
124
  * UPDATED: Compatibility with WordPress 5.9.3
125
  * UPDATED: Included Custom Taxonomies for snippets
126
  * UPDATED: Snippet code editor size
127
+ * ADDED: Increased Number of Allowed Posts/Page Exclusions to 200K+ posts.
128
 
129
  = 1.1.20 = 2022-03-26
130
  * FIXED: MultiSite issue with subsites in network