Header Footer Elementor - Version 1.0.6

Version Description

  • New: Option to display the header/footer on the pages using Elementor Canvas Template.
Download this release

Release Info

Developer Nikschavan
Plugin Icon Header Footer Elementor
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

admin/class-hfe-admin.php CHANGED
@@ -121,19 +121,28 @@ class HFE_Admin {
121
* @param POST $post Currennt post object which is being displayed.
122
*/
123
function efh_metabox_render( $post ) {
124
- $values = get_post_custom( $post->ID );
125
- $selected = isset( $values['ehf_template_type'] ) ? esc_attr( $values['ehf_template_type'][0] ) : '';
126
// We'll use this nonce field later on when saving.
127
wp_nonce_field( 'ehf_meta_nounce', 'ehf_meta_nounce' );
128
?>
129
<p>
130
<label for="ehf_template_type">Select the type of template this is</label>
131
<select name="ehf_template_type" id="ehf_template_type">
132
- <option value="" <?php selected( $selected, '' ); ?>>Select Option</option>
133
- <option value="type_header" <?php selected( $selected, 'type_header' ); ?>>Header</option>
134
- <option value="type_footer" <?php selected( $selected, 'type_footer' ); ?>>Footer</option>
135
</select>
136
</p>
137
<?php
138
}
139
@@ -165,6 +174,12 @@ class HFE_Admin {
165
update_post_meta( $post_id, 'ehf_template_type', esc_attr( $_POST['ehf_template_type'] ) );
166
}
167
168
}
169
170
/**
121
* @param POST $post Currennt post object which is being displayed.
122
*/
123
function efh_metabox_render( $post ) {
124
+ $values = get_post_custom( $post->ID );
125
+ $template_type = isset( $values['ehf_template_type'] ) ? esc_attr( $values['ehf_template_type'][0] ) : '';
126
+ $display_on_canvas = isset( $values['display-on-canvas-template'] ) ? true : false;
127
+
128
// We'll use this nonce field later on when saving.
129
wp_nonce_field( 'ehf_meta_nounce', 'ehf_meta_nounce' );
130
?>
131
<p>
132
<label for="ehf_template_type">Select the type of template this is</label>
133
<select name="ehf_template_type" id="ehf_template_type">
134
+ <option value="" <?php selected( $template_type, '' ); ?>>Select Option</option>
135
+ <option value="type_header" <?php selected( $template_type, 'type_header' ); ?>>Header</option>
136
+ <option value="type_footer" <?php selected( $template_type, 'type_footer' ); ?>>Footer</option>
137
</select>
138
</p>
139
+ <p>
140
+ <label for="display-on-canvas-template">
141
+ <input type="checkbox" id="display-on-canvas-template" name="display-on-canvas-template" value="1" <?php checked( $display_on_canvas, true ); ?> />
142
+ <?php _e( 'Display Layout on Elementor Canvas Template?', 'header-footer-elementor' ); ?>
143
+ </label>
144
+ </p>
145
+ <p class="description"><?php _e( 'Enabling this option will display this layout on pages using Elementor Canvas Template.', 'header-footer-elementor' ); ?></p>
146
<?php
147
}
148
174
update_post_meta( $post_id, 'ehf_template_type', esc_attr( $_POST['ehf_template_type'] ) );
175
}
176
177
+ if ( isset( $_POST['display-on-canvas-template'] ) ) {
178
+ update_post_meta( $post_id, 'display-on-canvas-template', esc_attr( $_POST['display-on-canvas-template'] ) );
179
+ } else {
180
+ delete_post_meta( $post_id, 'display-on-canvas-template' );
181
+ }
182
+
183
}
184
185
/**
assets/js/hfe-sites-notices.js ADDED
@@ -0,0 +1,21 @@
1
+ jQuery(document).ready(function ($) {
2
+
3
+ jQuery( '.hfe-notice.is-dismissible .notice-dismiss' ).on( 'click', function() {
4
+ var $id = jQuery( this ).attr( 'id' ) || '';
5
+ var $time = jQuery( this ).attr( 'dismissible-time' ) || '';
6
+ var $meta = jQuery( this ).attr( 'dismissible-meta' ) || '';
7
+
8
+ jQuery.ajax({
9
+ url: ajaxurl,
10
+ type: 'POST',
11
+ data: {
12
+ action : 'hfe-notices',
13
+ id : $id,
14
+ meta : $meta,
15
+ time : $time,
16
+ },
17
+ });
18
+
19
+ });
20
+
21
+ });
header-footer-elementor.php CHANGED
@@ -7,12 +7,12 @@
7
* Author URI: https://www.brainstormforce.com/
8
* Text Domain: header-footer-elementor
9
* Domain Path: /languages
10
- * Version: 1.0.5
11
*
12
* @package header-footer-elementor
13
*/
14
15
- define( 'HFE_VER', '1.0.5' );
16
define( 'HFE_DIR', plugin_dir_path( __FILE__ ) );
17
define( 'HFE_URL', plugins_url( '/', __FILE__ ) );
18
define( 'HFE_PATH', plugin_basename( __FILE__ ) );
7
* Author URI: https://www.brainstormforce.com/
8
* Text Domain: header-footer-elementor
9
* Domain Path: /languages
10
+ * Version: 1.0.6
11
*
12
* @package header-footer-elementor
13
*/
14
15
+ define( 'HFE_VER', '1.0.6' );
16
define( 'HFE_DIR', plugin_dir_path( __FILE__ ) );
17
define( 'HFE_URL', plugins_url( '/', __FILE__ ) );
18
define( 'HFE_PATH', plugin_basename( __FILE__ ) );
inc/class-header-footer-elementor.php CHANGED
@@ -59,12 +59,14 @@ class Header_Footer_Elementor {
59
// Scripts and styles.
60
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
61
add_filter( 'body_class', array( $this, 'body_class' ) );
62
63
} else {
64
65
add_action( 'admin_notices', array( $this, 'elementor_not_available' ) );
66
add_action( 'network_admin_notices', array( $this, 'elementor_not_available' ) );
67
}
68
}
69
70
/**
@@ -91,6 +93,12 @@ class Header_Footer_Elementor {
91
require_once HFE_DIR . 'admin/class-hfe-admin.php';
92
93
require_once HFE_DIR . 'inc/hfe-functions.php';
94
}
95
96
/**
@@ -162,6 +170,37 @@ class Header_Footer_Elementor {
162
printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
163
}
164
165
/**
166
* Prints the Header content.
167
*/
59
// Scripts and styles.
60
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
61
add_filter( 'body_class', array( $this, 'body_class' ) );
62
+ add_action( 'admin_init', array( $this, 'setup_notices' ) );
63
64
} else {
65
66
add_action( 'admin_notices', array( $this, 'elementor_not_available' ) );
67
add_action( 'network_admin_notices', array( $this, 'elementor_not_available' ) );
68
}
69
+
70
}
71
72
/**
93
require_once HFE_DIR . 'admin/class-hfe-admin.php';
94
95
require_once HFE_DIR . 'inc/hfe-functions.php';
96
+
97
+ // Load Elementor Canvas Compatibility.
98
+ require_once HFE_DIR . 'inc/class-hfe-elementor-canvas-compat.php';
99
+
100
+ // Load the Admin Notice Class.
101
+ require_once HFE_DIR . 'inc/class-hfe-notices.php';
102
}
103
104
/**
170
printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
171
}
172
173
+ /**
174
+ * Setup admin notice
175
+ */
176
+ public function setup_notices() {
177
+
178
+ $url = add_query_arg(
179
+ array(
180
+ 'utm_source' => 'hfe-notice',
181
+ 'utm_campaign' => 'header-footer-elementor',
182
+ 'utm_medium' => 'blackfriday-notice',
183
+ 'bsf' => '162',
184
+ ), 'https://www.brainstormforce.com/deals/2017-black-friday-cyber-monday-wordpress-deals/'
185
+ );
186
+
187
+ HFE_Notices::add_notice(
188
+ array(
189
+ 'id' => 'hfe-blackfriday-sale',
190
+ 'type' => 'info',
191
+ 'show_if' => true,
192
+ 'message' => sprintf(
193
+ /* translators: 1: Link to the blackfriday deals */
194
+ __( 'Thanks for updating Header Footer Elementor. Black Friday is here with huge savings! See our hand curated list of <a href="%1$s">Best WordPress Deals</a>!', 'header-footer-elementor' ),
195
+ esc_url( $url )
196
+ ),
197
+ 'dismissible' => true,
198
+ 'dismissible-time' => WEEK_IN_SECONDS,
199
+ )
200
+ );
201
+
202
+ }
203
+
204
/**
205
* Prints the Header content.
206
*/
inc/class-hfe-elementor-canvas-compat.php ADDED
@@ -0,0 +1,87 @@
1
+ <?php
2
+ /**
3
+ * HFE_Elementor_Canvas_Compat setup
4
+ *
5
+ * @package header-footer-elementor
6
+ */
7
+
8
+ /**
9
+ * Astra theme compatibility.
10
+ */
11
+ class HFE_Elementor_Canvas_Compat {
12
+
13
+ /**
14
+ * Instance of HFE_Elementor_Canvas_Compat.
15
+ *
16
+ * @var HFE_Elementor_Canvas_Compat
17
+ */
18
+ private static $instance;
19
+
20
+ /**
21
+ * Initiator
22
+ */
23
+ public static function instance() {
24
+
25
+ if ( ! isset( self::$instance ) ) {
26
+ self::$instance = new HFE_Elementor_Canvas_Compat();
27
+
28
+ self::$instance->hooks();
29
+ }
30
+
31
+ return self::$instance;
32
+ }
33
+
34
+ /**
35
+ * Run all the Actions / Filters.
36
+ */
37
+ public function hooks() {
38
+
39
+ if ( hfe_header_enabled() ) {
40
+ add_action( 'wp_head', array( $this, 'render_header' ) );
41
+ }
42
+
43
+ if ( hfe_footer_enabled() ) {
44
+ add_action( 'wp_footer', array( $this, 'render_footer' ) );
45
+ }
46
+
47
+ }
48
+
49
+ /**
50
+ * Render the header if display template on elementor canvas is enabled
51
+ * and current template is Elementor Canvas
52
+ */
53
+ public function render_header() {
54
+
55
+ // bail if current page template is not Elemenntor Canvas.
56
+ if ( 'elementor_canvas' !== get_page_template_slug() ) {
57
+ return;
58
+ }
59
+
60
+ $override_cannvas_template = get_post_meta( get_hfe_header_id(), 'display-on-canvas-template', true );
61
+
62
+ if ( '1' == $override_cannvas_template ) {
63
+ hfe_render_header();
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Render the footer if display template on elementor canvas is enabled
69
+ * and current template is Elementor Canvas
70
+ */
71
+ public function render_footer() {
72
+
73
+ // bail if current page template is not Elemenntor Canvas.
74
+ if ( 'elementor_canvas' !== get_page_template_slug() ) {
75
+ return;
76
+ }
77
+
78
+ $override_cannvas_template = get_post_meta( get_hfe_footer_id(), 'display-on-canvas-template', true );
79
+
80
+ if ( '1' == $override_cannvas_template ) {
81
+ hfe_render_footer();
82
+ }
83
+ }
84
+
85
+ }
86
+
87
+ HFE_Elementor_Canvas_Compat::instance();
inc/class-hfe-notices.php ADDED
@@ -0,0 +1,218 @@
1
+ <?php
2
+ /**
3
+ * HFE Sites Notices
4
+ *
5
+ * @package HFE Sites
6
+ * @since 1.0.8
7
+ */
8
+
9
+ if ( ! class_exists( 'HFE_Notices' ) ) :
10
+
11
+ /**
12
+ * HFE_Notices
13
+ *
14
+ * @since 1.0.8
15
+ */
16
+ class HFE_Notices {
17
+
18
+ /**
19
+ * Notices
20
+ *
21
+ * @access private
22
+ * @var array Notices.
23
+ * @since 1.0.8
24
+ */
25
+ private static $notices = array();
26
+
27
+ /**
28
+ * Instance
29
+ *
30
+ * @access private
31
+ * @var object Class object.
32
+ * @since 1.0.8
33
+ */
34
+ private static $instance;
35
+
36
+ /**
37
+ * Initiator
38
+ *
39
+ * @since 1.0.8
40
+ * @return object initialized object of class.
41
+ */
42
+ public static function get_instance() {
43
+ if ( ! isset( self::$instance ) ) {
44
+ self::$instance = new self;
45
+ }
46
+ return self::$instance;
47
+ }
48
+
49
+ /**
50
+ * Constructor
51
+ *
52
+ * @since 1.0.8
53
+ */
54
+ public function __construct() {
55
+
56
+ add_action( 'admin_notices', array( $this, 'show_notices' ) );
57
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
58
+ add_action( 'wp_ajax_hfe-notices', array( $this, 'dismiss' ) );
59
+
60
+ }
61
+
62
+ /**
63
+ * Add Notice.
64
+ *
65
+ * @since 1.0.8
66
+ * @param array $args Notice arguments.
67
+ * @return void
68
+ */
69
+ public static function add_notice( $args = array() ) {
70
+ if ( is_array( $args ) ) {
71
+ self::$notices[] = $args;
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Dismiss Notice.
77
+ *
78
+ * @since 1.0.8
79
+ * @return void
80
+ */
81
+ function dismiss() {
82
+
83
+ $id = ( isset( $_POST['id'] ) ) ? $_POST['id'] : '';
84
+ $time = ( isset( $_POST['time'] ) ) ? $_POST['time'] : '';
85
+ $meta = ( isset( $_POST['meta'] ) ) ? $_POST['meta'] : '';
86
+
87
+ // Valid inputs?
88
+ if ( ! empty( $id ) ) {
89
+
90
+ if ( 'user' === $meta ) {
91
+ update_user_meta( get_current_user_id(), $id, true );
92
+ } else {
93
+ set_transient( $id, true, $time );
94
+ }
95
+
96
+ wp_send_json_success();
97
+ }
98
+
99
+ wp_send_json_error();
100
+ }
101
+
102
+ /**
103
+ * Enqueue Scripts.
104
+ *
105
+ * @since 1.0.8
106
+ * @return void
107
+ */
108
+ function enqueue_scripts() {
109
+ wp_register_script( 'hfe-sites-notices', HFE_URL . 'assets/js/hfe-sites-notices.js', array( 'jquery' ), HFE_VER, true );
110
+ }
111
+
112
+ /**
113
+ * Notice Types
114
+ *
115
+ * @since 1.0.8
116
+ * @return void
117
+ */
118
+ function show_notices() {
119
+
120
+ $defaults = array(
121
+ 'id' => '',
122
+ 'type' => 'info',
123
+ 'show_if' => true,
124
+ 'message' => '',
125
+ 'class' => 'hfe-active-notice',
126
+ 'dismissible' => false,
127
+ 'dismissible-meta' => 'user',
128
+ 'dismissible-time' => WEEK_IN_SECONDS,
129
+
130
+ 'data' => '',
131
+ );
132
+
133
+ foreach ( self::$notices as $key => $notice ) {
134
+
135
+ $notice = wp_parse_args( $notice, $defaults );
136
+
137
+ $classes = array( 'hfe-notice', 'notice' );
138
+
139
+ $classes[] = $notice['class'];
140
+ if ( isset( $notice['type'] ) ) {
141
+ $classes[] = 'notice-' . $notice['type'];
142
+ }
143
+
144
+ // Is notice dismissible?
145
+ if ( true === $notice['dismissible'] ) {
146
+ $classes[] = 'is-dismissible';
147
+
148
+ // Dismissable time.
149
+ $notice['data'] = ' dismissible-time=' . esc_attr( $notice['dismissible-time'] ) . ' ';
150
+ }
151
+
152
+ // Notice ID.
153
+ $notice_id = 'hfe-sites-notices-id-' . $key;
154
+ $notice['id'] = $notice_id;
155
+ if ( ! isset( $notice['id'] ) ) {
156
+ $notice_id = 'hfe-sites-notices-id-' . $key;
157
+ $notice['id'] = $notice_id;
158
+ } else {
159
+ $notice_id = $notice['id'];
160
+ }
161
+
162
+ $notice['classes'] = implode( ' ', $classes );
163
+
164
+ // User meta.
165
+ $notice['data'] .= ' dismissible-meta=' . esc_attr( $notice['dismissible-meta'] ) . ' ';
166
+ if ( 'user' === $notice['dismissible-meta'] ) {
167
+ $expired = get_user_meta( get_current_user_id(), $notice_id, true );
168
+ } elseif ( 'transient' === $notice['dismissible-meta'] ) {
169
+ $expired = get_transient( $notice_id );
170
+ }
171
+
172
+ // Notices visible after transient expire.
173
+ if ( isset( $notice['show_if'] ) ) {
174
+
175
+ if ( true === $notice['show_if'] ) {
176
+
177
+ // Is transient expired?
178
+ if ( false === $expired || empty( $expired ) ) {
179
+ self::markup( $notice );
180
+ }
181
+ }
182
+ } else {
183
+
184
+ // No transient notices.
185
+ self::markup( $notice );
186
+ }
187
+ }
188
+
189
+ }
190
+
191
+ /**
192
+ * Markup Notice.
193
+ *
194
+ * @since 1.0.8
195
+ * @param array $notice Notice markup.
196
+ * @return void
197
+ */
198
+ public static function markup( $notice = array() ) {
199
+
200
+ wp_enqueue_script( 'hfe-sites-notices' );
201
+
202
+ ?>
203
+ <div id="<?php echo esc_attr( $notice['id'] ); ?>" class="<?php echo esc_attr( $notice['classes'] ); ?>" <?php echo $notice['data']; ?>>
204
+ <p>
205
+ <?php echo $notice['message']; ?>
206
+ </p>
207
+ </div>
208
+ <?php
209
+ }
210
+
211
+ }
212
+
213
+ /**
214
+ * Kicking this off by calling 'get_instance()' method
215
+ */
216
+ HFE_Notices::get_instance();
217
+
218
+ endif;
languages/header-footer-elementor.pot CHANGED
@@ -2,10 +2,10 @@
2
# This file is distributed under the same license as the Header Footer Elementor package.
3
msgid ""
4
msgstr ""
5
- "Project-Id-Version: Header Footer Elementor 1.0.0\n"
6
"Report-Msgid-Bugs-To: "
7
"https://wordpress.org/support/plugin/header-footer-elementor\n"
8
- "POT-Creation-Date: 2017-06-08 05:20:36+00:00\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=utf-8\n"
11
"Content-Transfer-Encoding: 8bit\n"
@@ -77,23 +77,33 @@ msgstr ""
77
msgid "Header Footer Builder"
78
msgstr ""
79
80
- #: admin/class-hfe-admin.php:110
81
msgid "Elementor Header Footer options"
82
msgstr ""
83
84
- #: admin/class-hfe-admin.php:193
85
#. Translators: Post title, Template Location
86
msgid "Template %1$s is already assigned to the location %2$s"
87
msgstr ""
88
89
- #: class-header-footer-elementor.php:83
90
#. Translators: URL to install or activate Elementor plugin.
91
msgid ""
92
"The <strong>Header Footer Elementor</strong> plugin requires <strong><a "
93
"href=\"%s\">Elementor</strong></a> plugin installed & activated."
94
msgstr ""
95
96
- #: class-header-footer-elementor.php:139
97
msgid ""
98
"Hey, your current theme is not supported by Header Footer Elementor, click "
99
"<a "
@@ -101,12 +111,20 @@ msgid ""
101
"are-supported-by-this-plugin\">here</a> to check out the supported themes."
102
msgstr ""
103
104
#. Plugin Name of the plugin/theme
105
msgid "Header Footer Elementor"
106
msgstr ""
107
108
#. Plugin URI of the plugin/theme
109
- msgid "https://github.com/Nikschavan/header-footer-elemento"
110
msgstr ""
111
112
#. Description of the plugin/theme
2
# This file is distributed under the same license as the Header Footer Elementor package.
3
msgid ""
4
msgstr ""
5
+ "Project-Id-Version: Header Footer Elementor 1.0.6\n"
6
"Report-Msgid-Bugs-To: "
7
"https://wordpress.org/support/plugin/header-footer-elementor\n"
8
+ "POT-Creation-Date: 2017-11-22 15:26:39+00:00\n"
9
"MIME-Version: 1.0\n"
10
"Content-Type: text/plain; charset=utf-8\n"
11
"Content-Transfer-Encoding: 8bit\n"
77
msgid "Header Footer Builder"
78
msgstr ""
79
80
+ #: admin/class-hfe-admin.php:111
81
msgid "Elementor Header Footer options"
82
msgstr ""
83
84
+ #: admin/class-hfe-admin.php:142
85
+ msgid "Display Layout on Elementor Canvas Template?"
86
+ msgstr ""
87
+
88
+ #: admin/class-hfe-admin.php:145
89
+ msgid ""
90
+ "Enabling this option will display this layout on pages using Elementor "
91
+ "Canvas Template."
92
+ msgstr ""
93
+
94
+ #: admin/class-hfe-admin.php:210
95
#. Translators: Post title, Template Location
96
msgid "Template %1$s is already assigned to the location %2$s"
97
msgstr ""
98
99
+ #: inc/class-header-footer-elementor.php:85
100
#. Translators: URL to install or activate Elementor plugin.
101
msgid ""
102
"The <strong>Header Footer Elementor</strong> plugin requires <strong><a "
103
"href=\"%s\">Elementor</strong></a> plugin installed & activated."
104
msgstr ""
105
106
+ #: inc/class-header-footer-elementor.php:168
107
msgid ""
108
"Hey, your current theme is not supported by Header Footer Elementor, click "
109
"<a "
111
"are-supported-by-this-plugin\">here</a> to check out the supported themes."
112
msgstr ""
113
114
+ #: inc/class-header-footer-elementor.php:194
115
+ #. translators: 1: Link to the blackfriday deals
116
+ msgid ""
117
+ "Thanks for updating Header Footer Elementor. Black Friday is here with huge "
118
+ "savings! See our hand curated list of <a href=\"%1$s\">Best WordPress "
119
+ "Deals</a>!"
120
+ msgstr ""
121
+
122
#. Plugin Name of the plugin/theme
123
msgid "Header Footer Elementor"
124
msgstr ""
125
126
#. Plugin URI of the plugin/theme
127
+ msgid "https://github.com/Nikschavan/header-footer-elementor"
128
msgstr ""
129
130
#. Description of the plugin/theme
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
Contributors: brainstormforce, Nikschavan
3
Tags: elementor, header footer builder, header, footer, page builder, template builder, landing page builder, front-end editor
4
Donate link: https://www.paypal.me/BrainstormForce
5
- Requires at least: 3.6
6
- Tested up to: 4.9
7
- Stable tag: 1.0.5
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -72,6 +72,9 @@ If you are a theme developer <a href="https://github.com/Nikschavan/header-foote
72
73
== Changelog ==
74
75
= 1.0.5 =
76
- Fix: Correctly check if Elementor actually is active before using its methods. This fixes errors for sites using older versions of PHP where Elementor does not actually get activated.
77
2
Contributors: brainstormforce, Nikschavan
3
Tags: elementor, header footer builder, header, footer, page builder, template builder, landing page builder, front-end editor
4
Donate link: https://www.paypal.me/BrainstormForce
5
+ Requires at least: 4.4
6
+ Tested up to: 4.9.0
7
+ Stable tag: 1.0.6
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
72
73
== Changelog ==
74
75
+ = 1.0.6 =
76
+ - New: Option to display the header/footer on the pages using Elementor Canvas Template.
77
+
78
= 1.0.5 =
79
- Fix: Correctly check if Elementor actually is active before using its methods. This fixes errors for sites using older versions of PHP where Elementor does not actually get activated.
80