Version Description
- Add: Head & Footer Code column to post/page/custom post type listing to show if/what article specific custom code is defined
- Fix: in_array() expects parameter 2 to be array, null given in head-footer-code/inc/front.php on line 46, 111, and 176
Download this release
Release Info
Developer | urkekg |
Plugin | Head & Footer Code |
Version | 1.2.1 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.2.1
- assets/css/admin.css +1 -1
- assets/css/admin.css.map +1 -1
- assets/css/admin.scss +25 -0
- head-footer-code.php +3 -3
- inc/class-auhfc-meta-box.php +1 -1
- inc/helpers.php +39 -23
- inc/posts-custom-columns.php +101 -0
- inc/settings.php +1 -15
- inc/update.php +11 -0
- readme.txt +15 -7
assets/css/admin.css
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
#head_footer_code_settings .head_footer_code_wrapper{display:table;width:100%}#head_footer_code_settings .head_footer_code_wrapper .content_cell{display:table-cell}#head_footer_code_settings .head_footer_code_wrapper .sidebar_container{display:table-cell;padding:0 0 0 20px;width:25%}#head_footer_code_settings .head_footer_code_wrapper .sidebar_container .auhfc-button{display:block;background:#fff;border-radius:7px;border:1px solid rgba(0,0,0,0.1);box-shadow:0 0 0 5px rgba(0,0,0,0.1);padding:11px 15px;white-space:nowrap;line-height:18px;color:#bdbdbd;text-shadow:1px 1px #fff;text-decoration:none;position:relative;min-width:120px}#head_footer_code_settings .head_footer_code_wrapper .sidebar_container .auhfc-button:hover{color:#6796a9;background-color:#c2edff}#head_footer_code_settings .head_footer_code_wrapper .sidebar_container .auhfc-button.paypal_donate:after{content:' ';background-image:url(../img/paypal.png);background-repeat:no-repeat;background-position:center right;width:62px;height:100%;display:inline-block;position:absolute;right:15px;top:0;bottom:0}
|
2 |
/*# sourceMappingURL=admin.css.map */
|
1 |
+
#head_footer_code_settings .head_footer_code_wrapper{display:table;width:100%}#head_footer_code_settings .head_footer_code_wrapper .content_cell{display:table-cell}#head_footer_code_settings .head_footer_code_wrapper .sidebar_container{display:table-cell;padding:0 0 0 20px;width:25%}#head_footer_code_settings .head_footer_code_wrapper .sidebar_container .auhfc-button{display:block;background:#fff;border-radius:7px;border:1px solid rgba(0,0,0,0.1);box-shadow:0 0 0 5px rgba(0,0,0,0.1);padding:11px 15px;white-space:nowrap;line-height:18px;color:#bdbdbd;text-shadow:1px 1px #fff;text-decoration:none;position:relative;min-width:120px}#head_footer_code_settings .head_footer_code_wrapper .sidebar_container .auhfc-button:hover{color:#6796a9;background-color:#c2edff}#head_footer_code_settings .head_footer_code_wrapper .sidebar_container .auhfc-button.paypal_donate:after{content:' ';background-image:url(../img/paypal.png);background-repeat:no-repeat;background-position:center right;width:62px;height:100%;display:inline-block;position:absolute;right:15px;top:0;bottom:0}.fixed .column-hfc{width:14%}.fixed .column-hfc .n-a{opacity:0.5;cursor:help}.fixed .column-hfc .badge{padding:.1rem .5rem;font-weight:600;font-size:.6rem;margin:.5rem .5rem 0 0;display:inline-block;background:transparent}.fixed .column-hfc .badge.blue{border:1px solid #bfe7f3}.fixed .column-hfc .badge.blue:hover{border-color:#007cba}
|
2 |
/*# sourceMappingURL=admin.css.map */
|
assets/css/admin.css.map
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{
|
2 |
"version": 3,
|
3 |
-
"mappings": "AACI,oDAA0B,CACtB,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,CAEX,kEAAc,CACV,OAAO,CAAE,UAAU,CAGvB,uEAAmB,CACf,OAAO,CAAE,UAAU,CACnB,OAAO,CAAE,UAAU,CACnB,KAAK,CAAE,GAAG,CAEV,qFAAc,CACV,OAAO,CAAE,KAAK,CACd,UAAU,CAAE,IAAI,CAChB,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,yBAAyB,CACjC,UAAU,CAAE,yBAAyB,CACrC,OAAO,CAAE,SAAS,CAClB,WAAW,CAAE,MAAM,CACnB,WAAW,CAAE,IAAI,CACjB,KAAK,CAAE,OAAO,CACd,WAAW,CAAE,YAAY,CACzB,eAAe,CAAE,IAAI,CACrB,QAAQ,CAAE,QAAQ,CAClB,SAAS,CAAE,KAAK,CAEhB,2FAAQ,CACJ,KAAK,CAAE,OAAO,CACd,gBAAgB,CAAE,OAAO,CAG7B,yGAAsB,CAClB,OAAO,CAAE,GAAG,CACZ,gBAAgB,CAAE,sBAAsB,CACxC,iBAAiB,CAAE,SAAS,CAC5B,mBAAmB,CAAE,YAAY,CACjC,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,OAAO,CAAE,YAAY,CACrB,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,IAAI,CACX,GAAG,CAAE,CAAC,CACN,MAAM,CAAE,CAAC",
|
4 |
"sources": ["admin.scss"],
|
5 |
"names": [],
|
6 |
"file": "admin.css"
|
1 |
{
|
2 |
"version": 3,
|
3 |
+
"mappings": "AACI,oDAA0B,CACtB,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,CAEX,kEAAc,CACV,OAAO,CAAE,UAAU,CAGvB,uEAAmB,CACf,OAAO,CAAE,UAAU,CACnB,OAAO,CAAE,UAAU,CACnB,KAAK,CAAE,GAAG,CAEV,qFAAc,CACV,OAAO,CAAE,KAAK,CACd,UAAU,CAAE,IAAI,CAChB,aAAa,CAAE,GAAG,CAClB,MAAM,CAAE,yBAAyB,CACjC,UAAU,CAAE,yBAAyB,CACrC,OAAO,CAAE,SAAS,CAClB,WAAW,CAAE,MAAM,CACnB,WAAW,CAAE,IAAI,CACjB,KAAK,CAAE,OAAO,CACd,WAAW,CAAE,YAAY,CACzB,eAAe,CAAE,IAAI,CACrB,QAAQ,CAAE,QAAQ,CAClB,SAAS,CAAE,KAAK,CAEhB,2FAAQ,CACJ,KAAK,CAAE,OAAO,CACd,gBAAgB,CAAE,OAAO,CAG7B,yGAAsB,CAClB,OAAO,CAAE,GAAG,CACZ,gBAAgB,CAAE,sBAAsB,CACxC,iBAAiB,CAAE,SAAS,CAC5B,mBAAmB,CAAE,YAAY,CACjC,KAAK,CAAE,IAAI,CACX,MAAM,CAAE,IAAI,CACZ,OAAO,CAAE,YAAY,CACrB,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,IAAI,CACX,GAAG,CAAE,CAAC,CACN,MAAM,CAAE,CAAC,CAM7B,kBAAmB,CACf,KAAK,CAAE,GAAG,CACV,uBAAK,CACD,OAAO,CAAE,GAAG,CACZ,MAAM,CAAE,IAAI,CAKhB,yBAAO,CACH,OAAO,CAAE,WAAW,CACpB,WAAW,CAAE,GAAG,CAChB,SAAS,CAAE,KAAK,CAChB,MAAM,CAAE,eAAe,CACvB,OAAO,CAAE,YAAY,CACrB,UAAU,CAAE,WAAW,CAEvB,8BAAO,CACH,MAAM,CAAE,iBAAiB,CACzB,oCAAQ,CACJ,YAAY,CAAE,OAAO",
|
4 |
"sources": ["admin.scss"],
|
5 |
"names": [],
|
6 |
"file": "admin.css"
|
assets/css/admin.scss
CHANGED
@@ -49,3 +49,28 @@
|
|
49 |
}
|
50 |
}
|
51 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
}
|
51 |
}
|
52 |
+
.fixed .column-hfc {
|
53 |
+
width: 14%;
|
54 |
+
.n-a {
|
55 |
+
opacity: 0.5;
|
56 |
+
cursor: help;
|
57 |
+
}
|
58 |
+
// .label {
|
59 |
+
// cursor: pointer;
|
60 |
+
// }
|
61 |
+
.badge {
|
62 |
+
padding: .1rem .5rem;
|
63 |
+
font-weight: 600;
|
64 |
+
font-size: .6rem;
|
65 |
+
margin: .5rem .5rem 0 0;
|
66 |
+
display: inline-block;
|
67 |
+
background: transparent;
|
68 |
+
|
69 |
+
&.blue {
|
70 |
+
border: 1px solid #bfe7f3;
|
71 |
+
&:hover {
|
72 |
+
border-color: #007cba;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
head-footer-code.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
* Plugin Name: Head & Footer Code
|
9 |
* Plugin URI: https://urosevic.net/wordpress/plugins/head-footer-code/
|
10 |
* Description: Easy add site-wide and/or article specific custom code to head and/or footer sections (before the </head> or </body> or opening <body>) by hooking to <code>wp_head</code>, <code>wp_footer</code> and <code>wp_body_open</code>.
|
11 |
-
* Version: 1.2
|
12 |
* Author: Aleksandar Urosevic
|
13 |
* Author URI: https://urosevic.net/
|
14 |
* License: GPLv3
|
@@ -21,8 +21,8 @@ if ( ! defined( 'WPINC' ) ) {
|
|
21 |
die;
|
22 |
}
|
23 |
|
24 |
-
define( 'WPAU_HEAD_FOOTER_CODE_VER', '1.2' );
|
25 |
-
define( 'WPAU_HEAD_FOOTER_CODE_DB_VER', '
|
26 |
define( 'WPAU_HEAD_FOOTER_CODE_FILE', __FILE__ );
|
27 |
define( 'WPAU_HEAD_FOOTER_CODE_DIR', dirname( WPAU_HEAD_FOOTER_CODE_FILE ) . '/');
|
28 |
define( 'WPAU_HEAD_FOOTER_CODE_INC', WPAU_HEAD_FOOTER_CODE_DIR . 'inc/' );
|
8 |
* Plugin Name: Head & Footer Code
|
9 |
* Plugin URI: https://urosevic.net/wordpress/plugins/head-footer-code/
|
10 |
* Description: Easy add site-wide and/or article specific custom code to head and/or footer sections (before the </head> or </body> or opening <body>) by hooking to <code>wp_head</code>, <code>wp_footer</code> and <code>wp_body_open</code>.
|
11 |
+
* Version: 1.2.1
|
12 |
* Author: Aleksandar Urosevic
|
13 |
* Author URI: https://urosevic.net/
|
14 |
* License: GPLv3
|
21 |
die;
|
22 |
}
|
23 |
|
24 |
+
define( 'WPAU_HEAD_FOOTER_CODE_VER', '1.2.1' );
|
25 |
+
define( 'WPAU_HEAD_FOOTER_CODE_DB_VER', '6' );
|
26 |
define( 'WPAU_HEAD_FOOTER_CODE_FILE', __FILE__ );
|
27 |
define( 'WPAU_HEAD_FOOTER_CODE_DIR', dirname( WPAU_HEAD_FOOTER_CODE_FILE ) . '/');
|
28 |
define( 'WPAU_HEAD_FOOTER_CODE_INC', WPAU_HEAD_FOOTER_CODE_DIR . 'inc/' );
|
inc/class-auhfc-meta-box.php
CHANGED
@@ -81,7 +81,7 @@ abstract class AUHfc_Meta_Box {
|
|
81 |
);
|
82 |
?></p>
|
83 |
<label><?php esc_html_e( 'Behavior', 'head-footer-code' ); ?></label><br />
|
84 |
-
<select name="auhfc[behavior]" id="
|
85 |
<option value="append" <?php echo ( 'append' === auhfc_get_meta( 'behavior' ) ) ? 'selected' : ''; ?>><?php esc_html_e( 'Append to the site-wide code', 'head-footer-code' ); ?></option>
|
86 |
<option value="replace" <?php echo ( 'replace' === auhfc_get_meta( 'behavior' ) ) ? 'selected' : ''; ?>><?php esc_html_e( 'Replace the site-wide code', 'head-footer-code' ); ?></option>
|
87 |
</select>
|
81 |
);
|
82 |
?></p>
|
83 |
<label><?php esc_html_e( 'Behavior', 'head-footer-code' ); ?></label><br />
|
84 |
+
<select name="auhfc[behavior]" id="auhfc_behavior">
|
85 |
<option value="append" <?php echo ( 'append' === auhfc_get_meta( 'behavior' ) ) ? 'selected' : ''; ?>><?php esc_html_e( 'Append to the site-wide code', 'head-footer-code' ); ?></option>
|
86 |
<option value="replace" <?php echo ( 'replace' === auhfc_get_meta( 'behavior' ) ) ? 'selected' : ''; ?>><?php esc_html_e( 'Replace the site-wide code', 'head-footer-code' ); ?></option>
|
87 |
</select>
|
inc/helpers.php
CHANGED
@@ -7,6 +7,7 @@ if ( ! defined( 'WPINC' ) ) {
|
|
7 |
// Include back-end/front-end resources.
|
8 |
if ( is_admin() ) {
|
9 |
require_once WPAU_HEAD_FOOTER_CODE_INC . 'settings.php';
|
|
|
10 |
require_once WPAU_HEAD_FOOTER_CODE_INC . 'class-auhfc-meta-box.php';
|
11 |
} else {
|
12 |
require_once WPAU_HEAD_FOOTER_CODE_INC . 'front.php';
|
@@ -65,20 +66,30 @@ function auhfc_maybe_update() {
|
|
65 |
auhfc_update();
|
66 |
} // END function auhfc_maybe_update()
|
67 |
|
68 |
-
add_action( 'admin_enqueue_scripts', '
|
69 |
/**
|
70 |
-
*
|
71 |
* @param string $hook Current page hook
|
72 |
*/
|
73 |
-
function
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
-
|
78 |
-
|
79 |
-
wp_enqueue_style( 'wp-codemirror' );
|
80 |
-
wp_enqueue_script( 'wp-codemirror' );
|
81 |
-
} // END function auhfc_codemirror_enqueue_scripts( $hook )
|
82 |
|
83 |
/**
|
84 |
* Provide global defaults
|
@@ -119,30 +130,35 @@ function auhfc_settings() {
|
|
119 |
/**
|
120 |
* Get values of metabox fields
|
121 |
* @param string $field_name Post meta field key
|
|
|
122 |
* @return string Post meta field value
|
123 |
*/
|
124 |
-
function auhfc_get_meta( $field_name = '' ) {
|
125 |
|
126 |
if ( empty( $field_name ) ) {
|
127 |
return false;
|
128 |
}
|
129 |
|
130 |
-
if (
|
131 |
-
|
|
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
|
138 |
-
|
139 |
-
} else {
|
140 |
-
if ( is_singular() ) {
|
141 |
-
global $wp_the_query;
|
142 |
-
$post_id = $wp_the_query->get_queried_object_id();
|
143 |
} else {
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
|
|
|
|
146 |
}
|
147 |
|
148 |
if ( empty( $post_id ) ) {
|
7 |
// Include back-end/front-end resources.
|
8 |
if ( is_admin() ) {
|
9 |
require_once WPAU_HEAD_FOOTER_CODE_INC . 'settings.php';
|
10 |
+
require_once WPAU_HEAD_FOOTER_CODE_INC . 'posts-custom-columns.php';
|
11 |
require_once WPAU_HEAD_FOOTER_CODE_INC . 'class-auhfc-meta-box.php';
|
12 |
} else {
|
13 |
require_once WPAU_HEAD_FOOTER_CODE_INC . 'front.php';
|
66 |
auhfc_update();
|
67 |
} // END function auhfc_maybe_update()
|
68 |
|
69 |
+
add_action( 'admin_enqueue_scripts', 'auhfc_admin_enqueue_scripts' );
|
70 |
/**
|
71 |
+
* Enqueue admin styles and scripts to enable code editor in plugin settings and custom column on article listing
|
72 |
* @param string $hook Current page hook
|
73 |
*/
|
74 |
+
function auhfc_admin_enqueue_scripts( $hook ) {
|
75 |
+
// Admin Stylesheet.
|
76 |
+
if ( in_array( $hook, [ 'edit.php', 'tools_page_head_footer_code' ] ) ) {
|
77 |
+
wp_enqueue_style(
|
78 |
+
'head-footer-code-admin',
|
79 |
+
plugin_dir_url( __FILE__ ) . '../assets/css/admin.css',
|
80 |
+
[],
|
81 |
+
WPAU_HEAD_FOOTER_CODE_VER
|
82 |
+
);
|
83 |
+
}
|
84 |
+
// Codemirror Assets.
|
85 |
+
if ( 'tools_page_head_footer_code' === $hook ) {
|
86 |
+
$cm_settings['codeEditor'] = wp_enqueue_code_editor( [ 'type' => 'text/html' ] );
|
87 |
+
wp_localize_script( 'code-editor', 'cm_settings', $cm_settings );
|
88 |
+
wp_enqueue_style( 'wp-codemirror' );
|
89 |
+
wp_enqueue_script( 'wp-codemirror' );
|
90 |
}
|
91 |
+
return;
|
92 |
+
} // END function auhfc_admin_enqueue_scripts( $hook )
|
|
|
|
|
|
|
93 |
|
94 |
/**
|
95 |
* Provide global defaults
|
130 |
/**
|
131 |
* Get values of metabox fields
|
132 |
* @param string $field_name Post meta field key
|
133 |
+
* @param string $post_id Post ID (optional)
|
134 |
* @return string Post meta field value
|
135 |
*/
|
136 |
+
function auhfc_get_meta( $field_name = '', $post_id = null ) {
|
137 |
|
138 |
if ( empty( $field_name ) ) {
|
139 |
return false;
|
140 |
}
|
141 |
|
142 |
+
if ( empty( $post_id ) || $post_id != intval( $post_id ) ) {
|
143 |
+
if ( is_admin() ) {
|
144 |
+
global $post;
|
145 |
|
146 |
+
// If $post has not an object, return false
|
147 |
+
if ( empty( $post ) || ! is_object( $post ) ) {
|
148 |
+
return false;
|
149 |
+
}
|
150 |
|
151 |
+
$post_id = $post->ID;
|
|
|
|
|
|
|
|
|
152 |
} else {
|
153 |
+
if ( is_singular() ) {
|
154 |
+
global $wp_the_query;
|
155 |
+
$post_id = $wp_the_query->get_queried_object_id();
|
156 |
+
} else {
|
157 |
+
$post_id = false;
|
158 |
+
}
|
159 |
}
|
160 |
+
} else {
|
161 |
+
$post_id = (int) $post_id;
|
162 |
}
|
163 |
|
164 |
if ( empty( $post_id ) ) {
|
inc/posts-custom-columns.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// If this file is called directly, abort.
|
3 |
+
if ( ! defined( 'WPINC' ) ) {
|
4 |
+
die;
|
5 |
+
}
|
6 |
+
|
7 |
+
// Do this ONLY in admin dashboard!
|
8 |
+
if ( ! is_admin() ) {
|
9 |
+
return;
|
10 |
+
}
|
11 |
+
|
12 |
+
// And do this only for post types enabled on plugin settings page.
|
13 |
+
$auhfc_settings = auhfc_settings();
|
14 |
+
if ( isset($auhfc_settings['article']['post_types'] ) ) {
|
15 |
+
foreach ($auhfc_settings['article']['post_types'] as $post_type) {
|
16 |
+
// Add the custom column to the all post types that have enabled support for custom code.
|
17 |
+
add_filter( 'manage_' . $post_type . '_posts_columns', 'auhfc_posts_columns' );
|
18 |
+
// And make that column sortable.
|
19 |
+
add_filter( 'manage_edit-' . $post_type . '_sortable_columns', 'auhfc_posts_sortable_columns' );
|
20 |
+
// Add the data to the custom column for each enabled post types.
|
21 |
+
add_action( 'manage_' . $post_type . '_posts_custom_column' , 'auhfc_posts_custom_columns', 10, 2 );
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
function auhfc_posts_columns( $columns ) {
|
26 |
+
$columns['hfc'] = __( 'Head & Footer Code', 'head-footer-code' );
|
27 |
+
return $columns;
|
28 |
+
} // END function auhfc_posts_columns( $columns )
|
29 |
+
|
30 |
+
function auhfc_posts_sortable_columns( $columns ) {
|
31 |
+
$columns['hfc'] = 'hfc';
|
32 |
+
return $columns;
|
33 |
+
} // END function auhfc_posts_sortable_columns( $columns )
|
34 |
+
|
35 |
+
function auhfc_posts_custom_columns( $column, $post_id ) {
|
36 |
+
if ( 'hfc' !== $column ) {
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
$sections = [];
|
41 |
+
if ( !empty( auhfc_get_meta('head', $post_id) ) ) {
|
42 |
+
$sections[] = sprintf(
|
43 |
+
'<a href="post.php?post=%1$s&action=edit#auhfc_%2$s" class="badge blue %2$s" title="%3$s">%4$s</a>',
|
44 |
+
$post_id,
|
45 |
+
'head',
|
46 |
+
esc_html__( 'Article specific code is defined in HEAD section', 'head-footer-code' ),
|
47 |
+
esc_html__( 'HEAD', 'head-footer-code' )
|
48 |
+
);
|
49 |
+
}
|
50 |
+
if ( !empty( auhfc_get_meta('body', $post_id) ) ) {
|
51 |
+
$sections[] = sprintf(
|
52 |
+
'<a href="post.php?post=%1$s&action=edit#auhfc_%2$s" class="badge blue %2$s" title="%3$s">%4$s</a>',
|
53 |
+
$post_id,
|
54 |
+
'body',
|
55 |
+
esc_html__( 'Article specific code is defined in BODY section', 'head-footer-code' ),
|
56 |
+
esc_html__( 'BODY', 'head-footer-code' )
|
57 |
+
);
|
58 |
+
}
|
59 |
+
if ( !empty( auhfc_get_meta('footer', $post_id) ) ) {
|
60 |
+
$sections[] = sprintf(
|
61 |
+
'<a href="post.php?post=%1$s&action=edit#auhfc_%2$s" class="badge blue %2$s" title="%3$s">%4$s</a>',
|
62 |
+
$post_id,
|
63 |
+
'footer',
|
64 |
+
esc_html__( 'Article specific code is defined in FOOTER section', 'head-footer-code' ),
|
65 |
+
esc_html__( 'FOOTER', 'head-footer-code' )
|
66 |
+
);
|
67 |
+
}
|
68 |
+
if ( empty( $sections ) ) {
|
69 |
+
printf(
|
70 |
+
'<span class="n-a" title="%1$s">%2$s</span>',
|
71 |
+
/* translators: This is description for article without defined code */
|
72 |
+
esc_html__( 'No article specific code defined in any section', 'head-footer-code' ),
|
73 |
+
/* translators: This is label for article without defined code */
|
74 |
+
esc_html__( 'Not article code', 'head-footer-code' )
|
75 |
+
);
|
76 |
+
} else {
|
77 |
+
$mode = auhfc_get_meta( 'behavior', $post_id );
|
78 |
+
if ( 'append' == $mode ) {
|
79 |
+
printf( '<a href="post.php?post=%1$s&action=edit#auhfc_%2$s" class="label" title="%3$s">%4$s</a><br />%5$s',
|
80 |
+
$post_id,
|
81 |
+
'behavior',
|
82 |
+
/* translators: This is description for article specific mode label 'Append' */
|
83 |
+
esc_html__( 'Append article specific code to site-wide code', 'head-footer-code' ),
|
84 |
+
/* translators: This is label for article specific mode meaning 'Append to site-wide' ) */
|
85 |
+
esc_html__( 'Append', 'head-footer-code' ),
|
86 |
+
implode( '', $sections )
|
87 |
+
);
|
88 |
+
} else {
|
89 |
+
printf( '<a href="post.php?post=%1$s&action=edit#auhfc_%2$s" class="label" title="%3$s">%4$s</a><br />%5$s',
|
90 |
+
$post_id,
|
91 |
+
'behavior',
|
92 |
+
/* translators: This is description for article specific mode label 'Replace' */
|
93 |
+
esc_html__( 'Replace site-wide code with article specific code', 'head-footer-code' ),
|
94 |
+
/* translators: This is label for article specific mode meaning 'Replace site-wide with' */
|
95 |
+
esc_html__( 'Replace', 'head-footer-code' ),
|
96 |
+
implode( '', $sections )
|
97 |
+
);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
} // END function auhfc_posts_custom_columns( $column, $post_id )
|
inc/settings.php
CHANGED
@@ -16,23 +16,9 @@ add_filter( 'plugin_action_links_head-footer-code/head-footer-code.php', 'auhfc_
|
|
16 |
// Update links in plugin row on Plugins page.
|
17 |
add_filter( 'plugin_row_meta', 'auhfc_add_plugin_meta_links', 10, 2 );
|
18 |
|
19 |
-
// Load admin styles on plugin settings page
|
20 |
-
add_action( 'admin_enqueue_scripts', 'auhfc_admin_enqueue_scripts' );
|
21 |
-
|
22 |
/**
|
23 |
-
*
|
24 |
*/
|
25 |
-
function auhfc_admin_enqueue_scripts( $hook ) {
|
26 |
-
if ( 'tools_page_head_footer_code' == $hook ) {
|
27 |
-
wp_enqueue_style(
|
28 |
-
'head-footer-code-admin',
|
29 |
-
plugin_dir_url( __FILE__ ) . '../assets/css/admin.css',
|
30 |
-
[],
|
31 |
-
WPAU_HEAD_FOOTER_CODE_VER
|
32 |
-
);
|
33 |
-
}
|
34 |
-
} // END function wpau_enqueue_colour_picker()
|
35 |
-
|
36 |
function auhfc_add_admin_menu() {
|
37 |
|
38 |
// add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function )
|
16 |
// Update links in plugin row on Plugins page.
|
17 |
add_filter( 'plugin_row_meta', 'auhfc_add_plugin_meta_links', 10, 2 );
|
18 |
|
|
|
|
|
|
|
19 |
/**
|
20 |
+
* Add submenu for Head & Footer code to Tools.
|
21 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
function auhfc_add_admin_menu() {
|
23 |
|
24 |
// add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function )
|
inc/update.php
CHANGED
@@ -173,3 +173,14 @@ function auhfc_update_5() {
|
|
173 |
delete_option( 'auhfc_settings' );
|
174 |
|
175 |
} // END function auhfc_update_5()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
delete_option( 'auhfc_settings' );
|
174 |
|
175 |
} // END function auhfc_update_5()
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Fix PHP Warning: in_array() expects parameter 2 to be array, null given in head-footer-code/inc/front.php on line 46, 111, and 176
|
179 |
+
*/
|
180 |
+
function auhfc_update_6() {
|
181 |
+
$article = get_option( 'auhfc_settings_article' );
|
182 |
+
if ( is_null( $article['post_types'] ) ) {
|
183 |
+
$article['post_types'] = [];
|
184 |
+
update_option( 'auhfc_settings_article', $article );
|
185 |
+
}
|
186 |
+
} // END function auhfc_update_6()
|
readme.txt
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
=== Head & Footer Code ===
|
2 |
-
Contributors: urkekg
|
3 |
Donate link: https://urosevic.net/wordpress/donate/?donate_for=head-footer-code
|
4 |
Tags: wp_head, wp_footer, wp_body_open, head footer code, custom script
|
5 |
Requires at least: 4.9
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 1.2
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
12 |
-
Easy add site-wide and/or article specific custom code before the </head>
|
13 |
|
14 |
== Description ==
|
15 |
|
@@ -17,12 +17,14 @@ Let we say that you have been told to add some custom code (HTML, JavaScript or
|
|
17 |
|
18 |
Simply go to Tools → Head & Footer Code in your website admin dashboard, and insert custom code to HEAD, BODY or FOOTER section (depending what you have to do).
|
19 |
|
20 |
-
If your WordPress
|
21 |
|
22 |
If you have to insert some custom code specific for individual article (post, page, custom post type), then you can use Article specific metabox while you editing post/page/custom post type (check out [Screenshots](https://wordpress.org/plugins/head-footer-code/#screenshots)). There you can also set should that specific code be appended to site-wide code defined on **Tools** → **Head & Footer Code**, or should be overwritten.
|
23 |
|
24 |
Please note that taxonomies does not have own specific code but global code is added on those pages (category, tag and custom taxonomy listing, individual category, tags and custom taxonomies).
|
25 |
|
|
|
|
|
26 |
https://www.youtube.com/watch?v=Gd41Dv09UC4
|
27 |
|
28 |
**Works or broken?**
|
@@ -38,15 +40,17 @@ It is very hard to continue development and support for this and my other free p
|
|
38 |
* Set site-wide custom content for head page section (before the `</head>`)
|
39 |
* Set site-wide custom content for body section (after the `<body>`) - **Requires WordPress 5.2!**
|
40 |
* Set site-wide custom content for footer page section (before the `</body>`)
|
41 |
-
* [NEW in 1.2] Set homepage specific custom code for head, body and/or footer if Homepage mode is se to Blog Posts
|
42 |
* Set article specific custom code for head page section (before the `</head>`)
|
43 |
* Set article specific custom code for body section (after the `<body>`) - **Requires WordPress 5.2!**
|
44 |
* Set article specific custom content for footer page section (before the `</body>`)
|
45 |
* Choose priority of printed custom code to head/body/footer sections (lower number mean far from `</head>` and `</body>` and closer to `<body>`, higher number means closer to `</head>` and `</body>` and farther to `<body>`)
|
46 |
* Choose which post types will have enabled article specific head/body/footer fields
|
47 |
* Choose should article specific head/body/footer code be appended to site-wide code, or will replace site-wide code
|
|
|
48 |
* Site-wide section located under **Tools** > **Head & Footer Code**
|
49 |
* If you have set WP_DEBUG constant in `wp-config.php` to `true`, you'll see site-wide and article specific entries in page source code wrapped to comments.
|
|
|
50 |
|
51 |
General settings, including HEAD, BODY, FOOTER global code and priority, and also homepage code and behavior have been saved to WordPress option `auhfc_settings`.
|
52 |
Each post/page/custom post type specific HEAD, BODY and FOOTER code and behavior have been saved to post meta `_auhfc`.
|
@@ -92,11 +96,12 @@ Open in code editor `header.php` file from theme you use, and check if right aft
|
|
92 |
== Screenshots ==
|
93 |
|
94 |
1. Head & Footer Code box in Plugin search results
|
95 |
-
2. Site-wide
|
96 |
3. Article specific metabox
|
97 |
4. Example of custom code inserted to HEAD section (site-wide with appended article specific)
|
98 |
5. Example of custom code inserted to BODY section (site-wide with appended article specific)
|
99 |
6. Example of custom code inserted to FOOTER section (site-wide with appended article specific)
|
|
|
100 |
|
101 |
== Upgrade Notice ==
|
102 |
|
@@ -104,6 +109,9 @@ Open in code editor `header.php` file from theme you use, and check if right aft
|
|
104 |
Initial release of new plugin developed by Aleksandar Urosevic.
|
105 |
|
106 |
== Changelog ==
|
|
|
|
|
|
|
107 |
|
108 |
= 1.2 =
|
109 |
* Add: custom head, body and footer code for Homepage in Blog Posts mode.
|
1 |
=== Head & Footer Code ===
|
2 |
+
Contributors: urkekg, techwebux
|
3 |
Donate link: https://urosevic.net/wordpress/donate/?donate_for=head-footer-code
|
4 |
Tags: wp_head, wp_footer, wp_body_open, head footer code, custom script
|
5 |
Requires at least: 4.9
|
6 |
+
Tested up to: 5.6
|
7 |
+
Stable tag: 1.2.1
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
12 |
+
Easy add site-wide and/or article specific custom code before the closing </head> and </body>, or opening <body> tag.
|
13 |
|
14 |
== Description ==
|
15 |
|
17 |
|
18 |
Simply go to Tools → Head & Footer Code in your website admin dashboard, and insert custom code to HEAD, BODY or FOOTER section (depending what you have to do).
|
19 |
|
20 |
+
If your WordPress show latest blog posts on homepage, you can also add specific code only for homepage on **Tools** → **Head & Footer Code** (there will be section **Head, body and footer code on Homepage in Blog Posts mode**)
|
21 |
|
22 |
If you have to insert some custom code specific for individual article (post, page, custom post type), then you can use Article specific metabox while you editing post/page/custom post type (check out [Screenshots](https://wordpress.org/plugins/head-footer-code/#screenshots)). There you can also set should that specific code be appended to site-wide code defined on **Tools** → **Head & Footer Code**, or should be overwritten.
|
23 |
|
24 |
Please note that taxonomies does not have own specific code but global code is added on those pages (category, tag and custom taxonomy listing, individual category, tags and custom taxonomies).
|
25 |
|
26 |
+
This magic is done by hooking to WordPress hooks `wp_head`, `wp_footer` and `wp_body_open`.
|
27 |
+
|
28 |
https://www.youtube.com/watch?v=Gd41Dv09UC4
|
29 |
|
30 |
**Works or broken?**
|
40 |
* Set site-wide custom content for head page section (before the `</head>`)
|
41 |
* Set site-wide custom content for body section (after the `<body>`) - **Requires WordPress 5.2!**
|
42 |
* Set site-wide custom content for footer page section (before the `</body>`)
|
43 |
+
* **[NEW in 1.2]** Set homepage specific custom code for head, body and/or footer if Homepage mode is se to Blog Posts
|
44 |
* Set article specific custom code for head page section (before the `</head>`)
|
45 |
* Set article specific custom code for body section (after the `<body>`) - **Requires WordPress 5.2!**
|
46 |
* Set article specific custom content for footer page section (before the `</body>`)
|
47 |
* Choose priority of printed custom code to head/body/footer sections (lower number mean far from `</head>` and `</body>` and closer to `<body>`, higher number means closer to `</head>` and `</body>` and farther to `<body>`)
|
48 |
* Choose which post types will have enabled article specific head/body/footer fields
|
49 |
* Choose should article specific head/body/footer code be appended to site-wide code, or will replace site-wide code
|
50 |
+
* **[NEW in 1.2.1]** View on Posts/Pages/Custom Post Types listing if article has defined any article specific custom code
|
51 |
* Site-wide section located under **Tools** > **Head & Footer Code**
|
52 |
* If you have set WP_DEBUG constant in `wp-config.php` to `true`, you'll see site-wide and article specific entries in page source code wrapped to comments.
|
53 |
+
* Multisite is supported.
|
54 |
|
55 |
General settings, including HEAD, BODY, FOOTER global code and priority, and also homepage code and behavior have been saved to WordPress option `auhfc_settings`.
|
56 |
Each post/page/custom post type specific HEAD, BODY and FOOTER code and behavior have been saved to post meta `_auhfc`.
|
96 |
== Screenshots ==
|
97 |
|
98 |
1. Head & Footer Code box in Plugin search results
|
99 |
+
2. Plugin Settings page (Site-wide, Homepage and Article Post Types)
|
100 |
3. Article specific metabox
|
101 |
4. Example of custom code inserted to HEAD section (site-wide with appended article specific)
|
102 |
5. Example of custom code inserted to BODY section (site-wide with appended article specific)
|
103 |
6. Example of custom code inserted to FOOTER section (site-wide with appended article specific)
|
104 |
+
7. Example of Head & Footer Code column on Pages listing, to identify which pages have set custom code, which one and what mode is selected
|
105 |
|
106 |
== Upgrade Notice ==
|
107 |
|
109 |
Initial release of new plugin developed by Aleksandar Urosevic.
|
110 |
|
111 |
== Changelog ==
|
112 |
+
= 1.2.1 =
|
113 |
+
* Add: Head & Footer Code column to post/page/custom post type listing to show if/what article specific custom code is defined
|
114 |
+
* Fix: in_array() expects parameter 2 to be array, null given in head-footer-code/inc/front.php on line 46, 111, and 176
|
115 |
|
116 |
= 1.2 =
|
117 |
* Add: custom head, body and footer code for Homepage in Blog Posts mode.
|