Skip to content

Commit

Permalink
Tweak: Add the option to disable header & footer
Browse files Browse the repository at this point in the history
  • Loading branch information
rami-elementor committed Nov 14, 2023
1 parent dd41999 commit c3ca702
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 9 deletions.
6 changes: 5 additions & 1 deletion assets/dev/js/admin/hello-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@

.code-example {
display: inline-block;
margin-block-end: 1.5rem;
margin-block-end: 0.25rem;
border-radius: 4px;
font-size: 10px;

+ *:not(.code-example) {
margin-block-start: 1.25rem;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions assets/dev/js/admin/pages/settings-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const Notices = () => {
const SETTINGS = {
DESCRIPTION_META_TAG: '_description_meta_tag',
SKIP_LINK: '_skip_link',
HEADER_FOOTER: '_header_footer',
PAGE_TITLE: '_page_title',
HELLO_STYLE: '_hello_style',
HELLO_THEME: '_hello_theme',
Expand Down
9 changes: 9 additions & 0 deletions assets/dev/js/admin/panels/settings-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export const SettingsPanel = ( { SETTINGS, settingsData, updateSettings } ) => {
/>
<code className="code-example"> &lt;a class=&quot;skip-link screen-reader-text&quot; href=&quot;#content&quot;&gt; Skip to content &lt;/a&gt; </code>

<ToggleControl
label={ __( 'Disable header & footer', 'hello-elementor' ) }
help={ __( 'Remove the site header and site footer sections from the page.', 'hello-elementor' ) }
checked={ !! settingsData[ SETTINGS.HEADER_FOOTER ] || false }
onChange={ ( value ) => updateSettings( SETTINGS.HEADER_FOOTER, value ) }
/>
<code className="code-example"> &lt;header id=&quot;site-header&quot; class=&quot;site-header&quot;&gt; ... &lt;/header&gt; </code>
<code className="code-example"> &lt;footer id=&quot;site-footer&quot; class=&quot;site-footer&quot;&gt; ... &lt;/footer&gt; </code>

<ToggleControl
label={ __( 'Disable page title', 'hello-elementor' ) }
help={ __( 'Remove the section above the content that contains the main heading of the page.', 'hello-elementor' ) }
Expand Down
10 changes: 6 additions & 4 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
}

if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'footer' ) ) {
if ( did_action( 'elementor/loaded' ) && hello_header_footer_experiment_active() ) {
get_template_part( 'template-parts/dynamic-footer' );
} else {
get_template_part( 'template-parts/footer' );
if ( apply_filters( 'hello_elementor_header_footer', true ) ) {
if ( did_action( 'elementor/loaded' ) && hello_header_footer_experiment_active() ) {
get_template_part( 'template-parts/dynamic-footer' );
} else {
get_template_part( 'template-parts/footer' );
}
}
}
?>
Expand Down
2 changes: 2 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ function hello_elementor_scripts_styles() {
[],
HELLO_ELEMENTOR_VERSION
);
}

if ( apply_filters( 'hello_elementor_header_footer', true ) ) {
wp_enqueue_style(
'hello-elementor-header-footer',
get_template_directory_uri() . '/header-footer' . $min_suffix . '.css',
Expand Down
10 changes: 6 additions & 4 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@

<?php
if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'header' ) ) {
if ( did_action( 'elementor/loaded' ) && hello_header_footer_experiment_active() ) {
get_template_part( 'template-parts/dynamic-header' );
} else {
get_template_part( 'template-parts/header' );
if ( apply_filters( 'hello_elementor_header_footer', true ) ) {
if ( did_action( 'elementor/loaded' ) && hello_header_footer_experiment_active() ) {
get_template_part( 'template-parts/dynamic-header' );
} else {
get_template_part( 'template-parts/header' );
}
}
}
5 changes: 5 additions & 0 deletions includes/settings-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function hello_elementor_tweak_settings() {
$settings = [
'DESCRIPTION_META_TAG' => '_description_meta_tag',
'SKIP_LINK' => '_skip_link',
'HEADER_FOOTER' => '_header_footer',
'PAGE_TITLE' => '_page_title',
'HELLO_STYLE' => '_hello_style',
'HELLO_THEME' => '_hello_theme',
Expand Down Expand Up @@ -133,6 +134,10 @@ function hello_elementor_render_tweaks( $settings_group, $settings ) {
add_filter( 'hello_elementor_enable_skip_link', '__return_false' );
} );

hello_elementor_do_tweak( $settings_group . $settings['HEADER_FOOTER'], function() {
add_filter( 'hello_elementor_header_footer', '__return_false' );
} );

hello_elementor_do_tweak( $settings_group . $settings['PAGE_TITLE'], function() {
add_filter( 'hello_elementor_page_title', '__return_false' );
} );
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Source: https://stocksnap.io/photo/4B83RD7BV9
== Changelog ==

= 3.0.0 =
* New: Option to disable header & footer.
* Tweak: Update `Requires PHP 7.3`
* Tweak: Update `Tested up to 6.4`
* Tweak: Move header-footer styles to a separate CSS file.
Expand Down

0 comments on commit c3ca702

Please sign in to comment.