Conditionally display homepage template

This commit is contained in:
Tiago Noronha 2018-04-03 16:39:29 +01:00
parent 3f01e9ddcf
commit 35a575c4ab

View file

@ -243,6 +243,7 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
'section' => 'storefront_typography', 'section' => 'storefront_typography',
'settings' => 'storefront_hero_heading_color', 'settings' => 'storefront_hero_heading_color',
'priority' => 50, 'priority' => 50,
'active_callback' => array( $this, 'is_homepage_template' ),
) ) ); ) ) );
/** /**
@ -258,6 +259,7 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
'section' => 'storefront_typography', 'section' => 'storefront_typography',
'settings' => 'storefront_hero_text_color', 'settings' => 'storefront_hero_text_color',
'priority' => 60, 'priority' => 60,
'active_callback' => array( $this, 'is_homepage_template' ),
) ) ); ) ) );
$wp_customize->add_control( new Arbitrary_Storefront_Control( $wp_customize, 'storefront_header_image_heading', array( $wp_customize->add_control( new Arbitrary_Storefront_Control( $wp_customize, 'storefront_header_image_heading', array(
@ -976,6 +978,22 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
public function get_site_description() { public function get_site_description() {
return get_bloginfo( 'description', 'display' ); return get_bloginfo( 'description', 'display' );
} }
/**
* Check if current page is using the Homepage template.
*
* @since 2.3.0
* @return bool
*/
public function is_homepage_template() {
$template = get_post_meta( get_the_ID(), '_wp_page_template', true );
if ( ! $template || 'template-homepage.php' !== $template ) {
return false;
}
return true;
}
} }
endif; endif;