Version Description
2022-04-21 * ADDED: Copy shortcode to clipboard buttons on edit snippet page and on snippet list page * UPDATED: Compatibility with WordPress 5.9.3 * UPDATED: Included Custom Taxonomies for snippets * UPDATED: Snippet code editor size * FIXED: Exclude large number of posts/pages
Download this release
Release Info
Developer | 99robots |
Plugin | Header Footer Code Manager |
Version | 1.1.21 |
Comparing to | |
See all releases |
Code changes from version 1.1.20 to 1.1.21
- 99robots-header-footer-code-manager.php +67 -15
- css/style-admin.css +7 -1
- includes/class-hfcm-snippets-list.php +1 -0
- includes/hfcm-add-edit.php +22 -16
- js/nnr-hfcm-showboxes.js +49 -0
- js/toggle.js +74 -19
- readme.txt +9 -2
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.
|
7 |
* Requires at least: 4.9
|
8 |
* Requires PHP: 5.6.20
|
9 |
* Author: 99robots
|
@@ -41,10 +41,9 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
41 |
|
42 |
class NNR_HFCM
|
43 |
{
|
44 |
-
public static $nnr_hfcm_db_version = "1.
|
45 |
public static $nnr_hfcm_table = "hfcm_scripts";
|
46 |
|
47 |
-
|
48 |
/*
|
49 |
* hfcm init function
|
50 |
*/
|
@@ -79,10 +78,10 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
79 |
`location` varchar(100) NOT NULL,
|
80 |
`display_on` enum('All','s_pages', 's_posts','s_categories','s_custom_posts','s_tags', 's_is_home', 's_is_search', 's_is_archive','latest_posts','manual') NOT NULL DEFAULT 'All',
|
81 |
`lp_count` int(10) DEFAULT NULL,
|
82 |
-
`s_pages`
|
83 |
-
`ex_pages`
|
84 |
-
`s_posts`
|
85 |
-
`ex_posts`
|
86 |
`s_custom_posts` varchar(300) DEFAULT NULL,
|
87 |
`s_categories` varchar(300) DEFAULT NULL,
|
88 |
`s_tags` varchar(300) DEFAULT NULL,
|
@@ -99,7 +98,6 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
99 |
add_option( 'hfcm_db_version', self::$nnr_hfcm_db_version );
|
100 |
}
|
101 |
|
102 |
-
|
103 |
/*
|
104 |
* function to check if plugin is being updated
|
105 |
*/
|
@@ -156,13 +154,15 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
156 |
|
157 |
$nnr_alter_sql = "ALTER TABLE `$table_name` CHANGE `display_on` `display_on` ENUM('All','s_pages','s_posts','s_categories','s_custom_posts','s_tags','s_is_home','s_is_archive','s_is_search','latest_posts','manual') DEFAULT 'All' NOT NULL";
|
158 |
$wpdb->query( $nnr_alter_sql );
|
|
|
|
|
|
|
159 |
}
|
160 |
self::hfcm_options_install();
|
161 |
}
|
162 |
update_option( 'hfcm_db_version', self::$nnr_hfcm_db_version );
|
163 |
}
|
164 |
|
165 |
-
|
166 |
/*
|
167 |
* Enqueue style-file, if it exists.
|
168 |
*/
|
@@ -207,7 +207,6 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
207 |
load_plugin_textdomain( '99robots-header-footer-code-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
208 |
}
|
209 |
|
210 |
-
|
211 |
/*
|
212 |
* function to create menu page, and submenu pages.
|
213 |
*/
|
@@ -301,7 +300,6 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
301 |
add_action( 'admin_notices', array( 'NNR_HFCM', 'hfcm_static_notices' ) );
|
302 |
}
|
303 |
|
304 |
-
|
305 |
/*
|
306 |
* function to create the Admin Notice
|
307 |
*/
|
@@ -339,7 +337,7 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
339 |
'hfcm_page_hfcm-create',
|
340 |
'admin_page_hfcm-update',
|
341 |
);
|
342 |
-
$screen
|
343 |
|
344 |
if ( in_array( $screen, $allowed_pages_notices ) ) {
|
345 |
?>
|
@@ -396,7 +394,6 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
396 |
}
|
397 |
}
|
398 |
|
399 |
-
|
400 |
/*
|
401 |
* Function to json_decode array and check if empty
|
402 |
*/
|
@@ -1188,7 +1185,7 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
1188 |
continue;
|
1189 |
}
|
1190 |
$nnr_hfcm_sanitizes_snippet = [];
|
1191 |
-
$nnr_hfcm_keys
|
1192 |
"name", "snippet", "snippet_type", "device_type", "location",
|
1193 |
"display_on", "lp_count", "s_pages", "ex_pages", "s_posts",
|
1194 |
"ex_posts", "s_custom_posts", "s_categories", "s_tags", "status",
|
@@ -1196,7 +1193,7 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
1196 |
);
|
1197 |
foreach ( $nnr_hfcm_snippet as $nnr_key => $nnr_item ) {
|
1198 |
$nnr_key = sanitize_text_field( $nnr_key );
|
1199 |
-
if( in_array( $nnr_key, $nnr_hfcm_keys ) ) {
|
1200 |
if ( $nnr_key == "lp_count" ) {
|
1201 |
$nnr_item = absint( $nnr_item );
|
1202 |
} elseif ( $nnr_key != "snippet" ) {
|
@@ -1247,6 +1244,61 @@ if ( !class_exists( 'NNR_HFCM' ) ) :
|
|
1247 |
|
1248 |
return false;
|
1249 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1250 |
}
|
1251 |
|
1252 |
endif;
|
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
|
41 |
|
42 |
class NNR_HFCM
|
43 |
{
|
44 |
+
public static $nnr_hfcm_db_version = "1.5";
|
45 |
public static $nnr_hfcm_table = "hfcm_scripts";
|
46 |
|
|
|
47 |
/*
|
48 |
* hfcm init function
|
49 |
*/
|
78 |
`location` varchar(100) NOT NULL,
|
79 |
`display_on` enum('All','s_pages', 's_posts','s_categories','s_custom_posts','s_tags', 's_is_home', 's_is_search', 's_is_archive','latest_posts','manual') NOT NULL DEFAULT 'All',
|
80 |
`lp_count` int(10) DEFAULT NULL,
|
81 |
+
`s_pages` MEDIUMTEXT DEFAULT NULL,
|
82 |
+
`ex_pages` MEDIUMTEXT DEFAULT NULL,
|
83 |
+
`s_posts` MEDIUMTEXT DEFAULT NULL,
|
84 |
+
`ex_posts` MEDIUMTEXT DEFAULT NULL,
|
85 |
`s_custom_posts` varchar(300) DEFAULT NULL,
|
86 |
`s_categories` varchar(300) DEFAULT NULL,
|
87 |
`s_tags` varchar(300) DEFAULT NULL,
|
98 |
add_option( 'hfcm_db_version', self::$nnr_hfcm_db_version );
|
99 |
}
|
100 |
|
|
|
101 |
/*
|
102 |
* function to check if plugin is being updated
|
103 |
*/
|
154 |
|
155 |
$nnr_alter_sql = "ALTER TABLE `$table_name` CHANGE `display_on` `display_on` ENUM('All','s_pages','s_posts','s_categories','s_custom_posts','s_tags','s_is_home','s_is_archive','s_is_search','latest_posts','manual') DEFAULT 'All' NOT NULL";
|
156 |
$wpdb->query( $nnr_alter_sql );
|
157 |
+
|
158 |
+
$nnr_alter_sql = "ALTER TABLE `$table_name` CHANGE `s_pages` `s_pages` MEDIUMTEXT NULL, CHANGE `ex_pages` `ex_pages` MEDIUMTEXT NULL, CHANGE `s_posts` `s_posts` MEDIUMTEXT NULL, CHANGE `ex_posts` `ex_posts` MEDIUMTEXT NULL";
|
159 |
+
$wpdb->query( $nnr_alter_sql );
|
160 |
}
|
161 |
self::hfcm_options_install();
|
162 |
}
|
163 |
update_option( 'hfcm_db_version', self::$nnr_hfcm_db_version );
|
164 |
}
|
165 |
|
|
|
166 |
/*
|
167 |
* Enqueue style-file, if it exists.
|
168 |
*/
|
207 |
load_plugin_textdomain( '99robots-header-footer-code-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
208 |
}
|
209 |
|
|
|
210 |
/*
|
211 |
* function to create menu page, and submenu pages.
|
212 |
*/
|
300 |
add_action( 'admin_notices', array( 'NNR_HFCM', 'hfcm_static_notices' ) );
|
301 |
}
|
302 |
|
|
|
303 |
/*
|
304 |
* function to create the Admin Notice
|
305 |
*/
|
337 |
'hfcm_page_hfcm-create',
|
338 |
'admin_page_hfcm-update',
|
339 |
);
|
340 |
+
$screen = get_current_screen()->id;
|
341 |
|
342 |
if ( in_array( $screen, $allowed_pages_notices ) ) {
|
343 |
?>
|
394 |
}
|
395 |
}
|
396 |
|
|
|
397 |
/*
|
398 |
* Function to json_decode array and check if empty
|
399 |
*/
|
1185 |
continue;
|
1186 |
}
|
1187 |
$nnr_hfcm_sanitizes_snippet = [];
|
1188 |
+
$nnr_hfcm_keys = array(
|
1189 |
"name", "snippet", "snippet_type", "device_type", "location",
|
1190 |
"display_on", "lp_count", "s_pages", "ex_pages", "s_posts",
|
1191 |
"ex_posts", "s_custom_posts", "s_categories", "s_tags", "status",
|
1193 |
);
|
1194 |
foreach ( $nnr_hfcm_snippet as $nnr_key => $nnr_item ) {
|
1195 |
$nnr_key = sanitize_text_field( $nnr_key );
|
1196 |
+
if ( in_array( $nnr_key, $nnr_hfcm_keys ) ) {
|
1197 |
if ( $nnr_key == "lp_count" ) {
|
1198 |
$nnr_item = absint( $nnr_item );
|
1199 |
} elseif ( $nnr_key != "snippet" ) {
|
1244 |
|
1245 |
return false;
|
1246 |
}
|
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 |
+
|
1260 |
+
foreach ( $taxonomies as $taxonomy ) {
|
1261 |
+
$nnr_hfcm_taxonomy_categories = get_categories( [
|
1262 |
+
'taxonomy' => $taxonomy->name,
|
1263 |
+
'hide_empty' => 0
|
1264 |
+
] );
|
1265 |
+
$nnr_hfcm_taxonomy_categories = [
|
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;
|
1273 |
+
}
|
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 |
+
|
1288 |
+
foreach ( $taxonomies as $taxonomy ) {
|
1289 |
+
$nnr_hfcm_taxonomy_tags = get_tags( [
|
1290 |
+
'taxonomy' => $taxonomy->name,
|
1291 |
+
'hide_empty' => 0
|
1292 |
+
] );
|
1293 |
+
$nnr_hfcm_taxonomy_tags = [
|
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;
|
1301 |
+
}
|
1302 |
}
|
1303 |
|
1304 |
endif;
|
css/style-admin.css
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
#nnr_newcontent {
|
18 |
width: 75%;
|
19 |
}
|
20 |
-
.nnr-btnsave, .nnr-btndelete {
|
21 |
margin-top: 10px !important;
|
22 |
}
|
23 |
.padding20 {
|
@@ -92,6 +92,12 @@ input.round-toggle-round-flat:checked + label:hover {
|
|
92 |
.nnr-wraptext {
|
93 |
width: -moz-available;
|
94 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
@media (max-width: 782px) {
|
96 |
.hfcm-form-width select {
|
97 |
min-width: auto;
|
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 {
|
92 |
.nnr-wraptext {
|
93 |
width: -moz-available;
|
94 |
}
|
95 |
+
.nnr-hfcm-codeeditor-box .CodeMirror.CodeMirror-wrap {
|
96 |
+
height: 500px !important;
|
97 |
+
}
|
98 |
+
.nnr-mt-20 {
|
99 |
+
margin-top: 20px;
|
100 |
+
}
|
101 |
@media (max-width: 782px) {
|
102 |
.hfcm-form-width select {
|
103 |
min-width: auto;
|
includes/class-hfcm-snippets-list.php
CHANGED
@@ -318,6 +318,7 @@ class Hfcm_Snippets_List extends WP_List_Table
|
|
318 |
}
|
319 |
$actions = array(
|
320 |
'edit' => sprintf( '<a href="?page=%s&action=%s&id=%s&_wpnonce=%s">' . esc_html__( 'Edit', '99robots-header-footer-code-manager' ) . '</a>', esc_attr( 'hfcm-update' ), 'edit', absint( $item['script_id'] ), $edit_nonce ),
|
|
|
321 |
'delete' => sprintf( '<a href="?page=%s&action=%s&snippet=%s&_wpnonce=%s">' . esc_html__( 'Delete', '99robots-header-footer-code-manager' ) . '</a>', $page, 'delete', absint( $item['script_id'] ), $delete_nonce ),
|
322 |
);
|
323 |
|
318 |
}
|
319 |
$actions = array(
|
320 |
'edit' => sprintf( '<a href="?page=%s&action=%s&id=%s&_wpnonce=%s">' . esc_html__( 'Edit', '99robots-header-footer-code-manager' ) . '</a>', esc_attr( 'hfcm-update' ), 'edit', absint( $item['script_id'] ), $edit_nonce ),
|
321 |
+
'copy' => sprintf( '<a href="javascript:void(0);" data-shortcode=\'[hfcm id="%s"]\' class="hfcm_copy_shortcode" id="hfcm_copy_shortcode_%s">' . esc_html__( 'Copy Shortcode', '99robots-header-footer-code-manager' ) . '</a>', absint( $item['script_id'] ), absint( $item['script_id'] ) ),
|
322 |
'delete' => sprintf( '<a href="?page=%s&action=%s&snippet=%s&_wpnonce=%s">' . esc_html__( 'Delete', '99robots-header-footer-code-manager' ) . '</a>', $page, 'delete', absint( $item['script_id'] ), $delete_nonce ),
|
323 |
);
|
324 |
|
includes/hfcm-add-edit.php
CHANGED
@@ -189,9 +189,8 @@ wp_enqueue_script( 'hfcm_showboxes' );
|
|
189 |
</td>
|
190 |
</tr>
|
191 |
<?php
|
192 |
-
$
|
193 |
-
$
|
194 |
-
$nnr_hfcm_tags = get_tags( $args );
|
195 |
|
196 |
$nnr_hfcm_categories_style = 's_categories' === $display_on ? '' : 'display:none;';
|
197 |
$nnr_hfcm_tags_style = 's_tags' === $display_on ? '' : 'display:none;';
|
@@ -218,11 +217,13 @@ wp_enqueue_script( 'hfcm_showboxes' );
|
|
218 |
<td>
|
219 |
<select name="data[s_categories][]" multiple>
|
220 |
<?php
|
221 |
-
foreach ( $nnr_hfcm_categories as $
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
226 |
}
|
227 |
}
|
228 |
?>
|
@@ -234,11 +235,13 @@ wp_enqueue_script( 'hfcm_showboxes' );
|
|
234 |
<td>
|
235 |
<select name="data[s_tags][]" multiple>
|
236 |
<?php
|
237 |
-
foreach (
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
|
|
|
|
242 |
}
|
243 |
}
|
244 |
?>
|
@@ -368,12 +371,12 @@ wp_enqueue_script( 'hfcm_showboxes' );
|
|
368 |
</tr>
|
369 |
<?php endif; ?>
|
370 |
</table>
|
371 |
-
<div class="
|
372 |
<h1><?php esc_html_e( 'Snippet', '99robots-header-footer-code-manager' ); ?>
|
373 |
/ <?php esc_html_e( 'Code', '99robots-header-footer-code-manager' ) ?></h1>
|
374 |
-
<div class="
|
375 |
<textarea name="data[snippet]" aria-describedby="nnr-newcontent-description" id="nnr_newcontent"
|
376 |
-
rows="
|
377 |
<div class="wp-core-ui">
|
378 |
<input type="submit"
|
379 |
name="<?php echo $update ? 'update' : 'insert'; ?>"
|
@@ -384,6 +387,9 @@ wp_enqueue_script( 'hfcm_showboxes' );
|
|
384 |
?>
|
385 |
<a href="<?php echo esc_url( admin_url( 'admin.php?page=hfcm-list&action=delete&_wpnonce=' . $delete_nonce . '&snippet=' . $id ) ); ?>"
|
386 |
class="button button-secondary button-large nnr-btndelete"><?php esc_html_e( 'Delete', '99robots-header-footer-code-manager' ); ?></a>
|
|
|
|
|
|
|
387 |
<?php endif; ?>
|
388 |
</div>
|
389 |
</div>
|
189 |
</td>
|
190 |
</tr>
|
191 |
<?php
|
192 |
+
$nnr_hfcm_categories = NNR_HFCM::hfcm_get_categories();
|
193 |
+
$nnr_hfcm_tags = NNR_HFCM::hfcm_get_tags();
|
|
|
194 |
|
195 |
$nnr_hfcm_categories_style = 's_categories' === $display_on ? '' : 'display:none;';
|
196 |
$nnr_hfcm_tags_style = 's_tags' === $display_on ? '' : 'display:none;';
|
217 |
<td>
|
218 |
<select name="data[s_categories][]" multiple>
|
219 |
<?php
|
220 |
+
foreach ( $nnr_hfcm_categories as $nnr_key_cat => $nnr_item_cat ) {
|
221 |
+
foreach($nnr_item_cat['terms'] as $nnr_item_cat_key => $nnr_item_cat_term) {
|
222 |
+
if ( in_array( $nnr_item_cat_term->term_id, $s_categories ) ) {
|
223 |
+
echo "<option value='" . esc_attr( $nnr_item_cat_term->term_id ) . "' selected>" . esc_attr( $nnr_item_cat['name'] ) . " - " . esc_attr( $nnr_item_cat_term->name ) . "</option>";
|
224 |
+
} else {
|
225 |
+
echo "<option value='" . esc_attr( $nnr_item_cat_term->term_id ) . "'>" . esc_attr( $nnr_item_cat['name'] ) . " - " . esc_attr( $nnr_item_cat_term->name ) . "</option>";
|
226 |
+
}
|
227 |
}
|
228 |
}
|
229 |
?>
|
235 |
<td>
|
236 |
<select name="data[s_tags][]" multiple>
|
237 |
<?php
|
238 |
+
foreach ($nnr_hfcm_tags as $nnr_key_cat => $nnr_item_tag) {
|
239 |
+
foreach ( $nnr_item_tag['terms'] as $nnr_item_tag_key => $nnr_item_tag_term ) {
|
240 |
+
if ( in_array( $nnr_item_tag_term->term_id, $s_tags ) ) {
|
241 |
+
echo "<option value='" . esc_attr( $nnr_item_tag_term->term_id ) . "' selected>" . esc_attr( $nnr_item_tag['name'] ) . " - " . esc_attr( $nnr_item_tag_term->name ) . "</option>";
|
242 |
+
} else {
|
243 |
+
echo "<option value='" . esc_attr( $nnr_item_tag_term->term_id ) . "'>" . esc_attr( $nnr_item_tag['name'] ) . " - " . esc_attr( $nnr_item_tag_term->name ) . "</option>";
|
244 |
+
}
|
245 |
}
|
246 |
}
|
247 |
?>
|
371 |
</tr>
|
372 |
<?php endif; ?>
|
373 |
</table>
|
374 |
+
<div class="nnr-mt-20">
|
375 |
<h1><?php esc_html_e( 'Snippet', '99robots-header-footer-code-manager' ); ?>
|
376 |
/ <?php esc_html_e( 'Code', '99robots-header-footer-code-manager' ) ?></h1>
|
377 |
+
<div class="nnr-mt-20 nnr-hfcm-codeeditor-box">
|
378 |
<textarea name="data[snippet]" aria-describedby="nnr-newcontent-description" id="nnr_newcontent"
|
379 |
+
rows="20"><?php echo html_entity_decode( $snippet ); ?></textarea>
|
380 |
<div class="wp-core-ui">
|
381 |
<input type="submit"
|
382 |
name="<?php echo $update ? 'update' : 'insert'; ?>"
|
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>
|
js/nnr-hfcm-showboxes.js
CHANGED
@@ -50,6 +50,51 @@ function hfcm_remember_loc(new_html) {
|
|
50 |
jQuery('#data_location option[value="' + tmp + '"]').prop('selected', true);
|
51 |
}
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
// init selectize.js
|
54 |
jQuery('#loader').show();
|
55 |
jQuery(function ($) {
|
@@ -101,4 +146,8 @@ jQuery(function ($) {
|
|
101 |
);
|
102 |
var editor = wp.codeEditor.initialize($('#nnr_newcontent'), editorSettings);
|
103 |
}
|
|
|
|
|
|
|
|
|
104 |
});
|
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";
|
57 |
+
var origSelectionStart, origSelectionEnd;
|
58 |
+
|
59 |
+
// must use a temporary form element for the selection and copy
|
60 |
+
target = document.getElementById(targetId);
|
61 |
+
if (!target) {
|
62 |
+
var target = document.createElement("textarea");
|
63 |
+
target.style.position = "absolute";
|
64 |
+
target.style.left = "-9999px";
|
65 |
+
target.style.top = "0";
|
66 |
+
target.id = targetId;
|
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();
|
73 |
+
target.setSelectionRange(0, target.value.length);
|
74 |
+
|
75 |
+
// copy the selection
|
76 |
+
var succeed;
|
77 |
+
try {
|
78 |
+
succeed = document.execCommand("copy");
|
79 |
+
} catch (e) {
|
80 |
+
succeed = false;
|
81 |
+
}
|
82 |
+
// restore original focus
|
83 |
+
if (currentFocus && typeof currentFocus.focus === "function") {
|
84 |
+
currentFocus.focus();
|
85 |
+
}
|
86 |
+
|
87 |
+
if (isInput) {
|
88 |
+
// restore prior selection
|
89 |
+
elem.setSelectionRange(origSelectionStart, origSelectionEnd);
|
90 |
+
} else {
|
91 |
+
// clear temporary content
|
92 |
+
target.textContent = "";
|
93 |
+
}
|
94 |
+
target.remove();
|
95 |
+
return succeed;
|
96 |
+
}
|
97 |
+
|
98 |
// init selectize.js
|
99 |
jQuery('#loader').show();
|
100 |
jQuery(function ($) {
|
146 |
);
|
147 |
var editor = wp.codeEditor.initialize($('#nnr_newcontent'), editorSettings);
|
148 |
}
|
149 |
+
|
150 |
+
document.getElementById("hfcm_copy_shortcode").addEventListener("click", function() {
|
151 |
+
hfmcCopyToClipboard(document.getElementById("hfcm_copy_shortcode"));
|
152 |
+
});
|
153 |
});
|
js/toggle.js
CHANGED
@@ -1,24 +1,79 @@
|
|
1 |
// Toggle switch
|
2 |
-
jQuery('.nnr-switch input').on('click', function() {
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
});
|
19 |
|
20 |
// Delete confirmation
|
21 |
-
jQuery('.snippets .delete > a').on('click', function() {
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
});
|
1 |
// Toggle switch
|
2 |
+
jQuery('.nnr-switch input').on('click', function () {
|
3 |
+
var t = jQuery(this),
|
4 |
+
togvalue = t.is(':checked') ? 'on' : 'off',
|
5 |
+
scriptid = t.data('id'),
|
6 |
+
data = {
|
7 |
+
action: 'hfcm-request',
|
8 |
+
toggle: true,
|
9 |
+
id: scriptid,
|
10 |
+
togvalue: togvalue,
|
11 |
+
security: hfcm_ajax.security
|
12 |
+
};
|
13 |
+
|
14 |
+
jQuery.post(
|
15 |
+
ajaxurl,
|
16 |
+
data
|
17 |
+
);
|
18 |
});
|
19 |
|
20 |
// Delete confirmation
|
21 |
+
jQuery('.snippets .delete > a').on('click', function () {
|
22 |
+
var name = jQuery(this).parents('.name').find('> strong').text();
|
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";
|
30 |
+
var origSelectionStart, origSelectionEnd;
|
31 |
+
|
32 |
+
// must use a temporary form element for the selection and copy
|
33 |
+
target = document.getElementById(targetId);
|
34 |
+
if (!target) {
|
35 |
+
var target = document.createElement("textarea");
|
36 |
+
target.style.position = "absolute";
|
37 |
+
target.style.left = "-9999px";
|
38 |
+
target.style.top = "0";
|
39 |
+
target.id = targetId;
|
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();
|
46 |
+
target.setSelectionRange(0, target.value.length);
|
47 |
+
|
48 |
+
// copy the selection
|
49 |
+
var succeed;
|
50 |
+
try {
|
51 |
+
succeed = document.execCommand("copy");
|
52 |
+
} catch (e) {
|
53 |
+
succeed = false;
|
54 |
+
}
|
55 |
+
// restore original focus
|
56 |
+
if (currentFocus && typeof currentFocus.focus === "function") {
|
57 |
+
currentFocus.focus();
|
58 |
+
}
|
59 |
+
|
60 |
+
if (isInput) {
|
61 |
+
// restore prior selection
|
62 |
+
elem.setSelectionRange(origSelectionStart, origSelectionEnd);
|
63 |
+
} else {
|
64 |
+
// clear temporary content
|
65 |
+
target.textContent = "";
|
66 |
+
}
|
67 |
+
target.remove();
|
68 |
+
return succeed;
|
69 |
+
}
|
70 |
+
|
71 |
+
jQuery(function ($) {
|
72 |
+
var elemsCopyBtn = document.getElementsByClassName('hfcm_copy_shortcode');
|
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 |
});
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: DraftPress, 99robots, charliepatel
|
|
3 |
Tags: header, footer, code manager, snippet, functions.php, tracking, google analytics, adsense, verification, pixel
|
4 |
Requires at least: 4.9
|
5 |
Requires PHP: 5.6.20
|
6 |
-
Tested up to: 5.9.
|
7 |
-
Stable tag: 1.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
Donate link: https://draftpress.com
|
@@ -114,6 +114,13 @@ 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.20 = 2022-03-26
|
118 |
* FIXED: MultiSite issue with subsites in network
|
119 |
|
3 |
Tags: header, footer, code manager, snippet, functions.php, tracking, google analytics, adsense, verification, pixel
|
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 |
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
|
126 |
|