Skip to content

Commit

Permalink
Tweak: Added customizer control to enable/disable <h1> page title
Browse files Browse the repository at this point in the history
  • Loading branch information
rami-elementor committed Jul 23, 2023
1 parent d59ff29 commit d32e306
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 43 deletions.
35 changes: 8 additions & 27 deletions assets/scss/customizer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
* Customizer editor styling
*/

#accordion-section-hello_theme_options .accordion-section-title {
#accordion-section-hello_elementor .accordion-section-title {
color: #c36;

&:after {
color: #c36;
}
}

#sub-accordion-section-hello_theme_options.accordion-section-content {
#sub-accordion-section-hello_elementor.accordion-section-content {
background: #fff;
}

#customize-control-hello-elementor-header-footer {
margin-top: 10px;
border-top: 1px solid #ddd;
padding-top: 20px;
#customize-control-hello_elementor_header_footer {
margin-block-start: 10px;
padding-block-start: 20px;
border-block-start: 1px solid #ddd;

.customize-control-header-footer-holder {
margin: 12px auto 12px;
margin: 12px auto;
max-width: 300px;
text-align: center;
}
Expand All @@ -31,25 +31,6 @@
}

.elementor-section-body {
margin: .1em 0 1.3em;
}
}

.create-logo-desc {
margin-block-start: 10px;
padding: 10px;
background: white;
font-style: italic;

+ .actions {
background: white;
padding: 0 10px 10px;
margin-block-end: 15px;

.button {
margin-block-start: 0;
width: 100%;
text-align: center;
}
margin: 0 0 16px;
}
}
10 changes: 7 additions & 3 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,24 @@ function hello_register_customizer_functions() {

if ( ! function_exists( 'hello_elementor_check_hide_title' ) ) {
/**
* Check hide title.
* Check whether to display the page title.
*
* @param bool $val default value.
*
* @return bool
*/
function hello_elementor_check_hide_title( $val ) {
if ( '1' === get_option( 'hello_elementor_disable_page_title' ) ) {
$val = false;
}

if ( defined( 'ELEMENTOR_VERSION' ) ) {
$current_doc = Elementor\Plugin::instance()->documents->get( get_the_ID() );
if ( $current_doc && 'yes' === $current_doc->get_settings( 'hide_title' ) ) {
$val = false;
}
}

return $val;
}
}
Expand All @@ -207,8 +212,7 @@ function hello_elementor_check_hide_title( $val ) {
* @return void
*/
function hello_elementor_add_description_meta_tag() {
$enable_description_meta_tag = get_theme_mod( 'hello_elementor_description_meta_tag' );
if ( true !== $enable_description_meta_tag ) {
if ( '1' === get_option( 'hello_elementor_disable_description_meta_tag' ) ) {
return;
}

Expand Down
51 changes: 38 additions & 13 deletions includes/customizer-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,62 @@ function hello_customizer_register( $wp_customize ) {
require get_template_directory() . '/includes/customizer/elementor-upsell.php';

$wp_customize->add_section(
'hello_theme_options',
'hello_elementor',
[
'title' => esc_html__( 'Theme Settings', 'hello-elementor' ),
'description' => esc_html__( 'Customize your Hello Elementor theme settings.', 'hello-elementor' ),
'description_hidden' => false,
'capability' => 'edit_theme_options',
]
);

// Description meta tag

$wp_customize->add_setting(
'hello_elementor_description_meta_tag',
'hello_elementor_disable_description_meta_tag',
[
'sanitize_callback' => false,
'transport' => 'refresh',
'type' => 'option',
'capability' => 'edit_theme_options',
'default' => '',
'sanitize_callback' => 'hello_customizer_sanitize_checkbox',
]
);

$wp_customize->add_control(
'hello_elementor_description_meta_tag_control',
'hello_elementor_disable_description_meta_tag',
[
'label' => esc_html__( 'Enable description meta tag', 'hello-elementor' ),
'default' => true,
'label' => esc_html__( 'Disable description meta tag', 'hello-elementor' ),
'type' => 'checkbox',
'section' => 'hello_theme_options',
'settings' => 'hello_elementor_description_meta_tag',
'section' => 'hello_elementor',
'settings' => 'hello_elementor_disable_description_meta_tag',
]
);

// Page titles

$wp_customize->add_setting(
'hello_elementor_disable_page_title',
[
'type' => 'option',
'capability' => 'edit_theme_options',
'default' => '',
'sanitize_callback' => 'hello_customizer_sanitize_checkbox',
]
);

$wp_customize->add_control(
'hello_elementor_disable_page_title',
[
'label' => esc_html__( 'Disable page title', 'hello-elementor' ),
'type' => 'checkbox',
'section' => 'hello_elementor',
'settings' => 'hello_elementor_disable_page_title',
]
);

// Header & Footer promotion

$wp_customize->add_setting(
'hello-elementor-header-footer',
'hello_elementor_header_footer',
[
'sanitize_callback' => false,
'transport' => 'refresh',
Expand All @@ -60,15 +82,18 @@ function hello_customizer_register( $wp_customize ) {
$wp_customize->add_control(
new HelloElementor\Includes\Customizer\Elementor_Upsell(
$wp_customize,
'hello-elementor-header-footer',
'hello_elementor_header_footer',
[
'section' => 'hello_theme_options',
'section' => 'hello_elementor',
'priority' => 20,
]
)
);
}

function hello_customizer_sanitize_checkbox( $checked ) {
return $checked == '1' ? '1' : '';
}

/**
* Enqueue Customiser CSS
Expand Down
4 changes: 4 additions & 0 deletions template-parts/archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

<div class="page-content">
<?php
var_dump( get_option( 'hello_elementor_description_meta_tag' ) );
var_dump( get_option( 'hello_elementor_page_title' ) );
echo 'descr' . get_option( 'hello_elementor_description_meta_tag' ) . '<br>';
echo 'title' . get_option( 'hello_elementor_page_title' ) . '<br>';
while ( have_posts() ) {
the_post();
$post_link = get_permalink();
Expand Down

0 comments on commit d32e306

Please sign in to comment.