|
@@ -16,9 +16,12 @@ function varia_wpcom_setup() {
|
|
global $themecolors;
|
|
global $themecolors;
|
|
|
|
|
|
// Disable automatically generated color palettes.
|
|
// Disable automatically generated color palettes.
|
|
- add_theme_support( 'wpcom-colors', array(
|
|
|
|
- 'only-featured-palettes' => true,
|
|
|
|
- ) );
|
|
|
|
|
|
+ add_theme_support(
|
|
|
|
+ 'wpcom-colors',
|
|
|
|
+ array(
|
|
|
|
+ 'only-featured-palettes' => true,
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
|
|
// Set theme colors for third party services.
|
|
// Set theme colors for third party services.
|
|
if ( ! isset( $themecolors ) ) {
|
|
if ( ! isset( $themecolors ) ) {
|
|
@@ -37,53 +40,47 @@ add_action( 'after_setup_theme', 'varia_wpcom_setup' );
|
|
* Add setting for hiding page title on the homepage.
|
|
* Add setting for hiding page title on the homepage.
|
|
*/
|
|
*/
|
|
function varia_wpcom_customize_update( $wp_customize ) {
|
|
function varia_wpcom_customize_update( $wp_customize ) {
|
|
- $wp_customize->add_setting( 'hide_front_page_title', array(
|
|
|
|
- 'default' => false,
|
|
|
|
- 'type' => 'theme_mod',
|
|
|
|
- 'transport' => 'postMessage',
|
|
|
|
- 'sanitize_callback' => 'varia_sanitize_checkbox',
|
|
|
|
- ) );
|
|
|
|
-
|
|
|
|
- $wp_customize->add_control( 'hide_front_page_title', array(
|
|
|
|
- 'label' => esc_html__( 'Hide Homepage Title', 'varia' ),
|
|
|
|
- 'description' => esc_html__( 'Check to hide the page title, if your homepage is set to display a static page.', 'varia' ),
|
|
|
|
- 'section' => 'static_front_page',
|
|
|
|
- 'priority' => 10,
|
|
|
|
- 'type' => 'checkbox',
|
|
|
|
- 'settings' => 'hide_front_page_title',
|
|
|
|
- ) );
|
|
|
|
-
|
|
|
|
- $wp_customize->add_setting( 'color_a11y_warning' );
|
|
|
|
- $wp_customize->add_control( 'color_a11y_warning', array(
|
|
|
|
- 'id' => 'id',
|
|
|
|
- 'label' => esc_html__( 'Color Accessibility Warning', 'varia' ),
|
|
|
|
- 'description' => sprintf(
|
|
|
|
- __( 'In order to ensure people can read your site, try to maintain a strong contrast ratio between the colors you choose here. <a href="%s" target="_blank">Learn more about color contrast</a>.', 'varia' ),
|
|
|
|
- esc_url( 'https://a11yproject.com/posts/what-is-color-contrast/' )
|
|
|
|
- ),
|
|
|
|
- 'section' => 'colors_manager_tool',
|
|
|
|
- 'priority' => 10,
|
|
|
|
- 'type' => 'hidden',
|
|
|
|
- ) );
|
|
|
|
|
|
+ $wp_customize->add_setting(
|
|
|
|
+ 'hide_front_page_title',
|
|
|
|
+ array(
|
|
|
|
+ 'default' => false,
|
|
|
|
+ 'type' => 'theme_mod',
|
|
|
|
+ 'transport' => 'postMessage',
|
|
|
|
+ 'sanitize_callback' => 'varia_sanitize_checkbox',
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $wp_customize->add_control(
|
|
|
|
+ 'hide_front_page_title',
|
|
|
|
+ array(
|
|
|
|
+ 'label' => esc_html__( 'Hide Homepage Title', 'varia' ),
|
|
|
|
+ 'description' => esc_html__( 'Check to hide the page title, if your homepage is set to display a static page.', 'varia' ),
|
|
|
|
+ 'section' => 'static_front_page',
|
|
|
|
+ 'priority' => 10,
|
|
|
|
+ 'type' => 'checkbox',
|
|
|
|
+ 'settings' => 'hide_front_page_title',
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $wp_customize->add_setting( 'color_a11y_warning' );
|
|
|
|
+ $wp_customize->add_control(
|
|
|
|
+ 'color_a11y_warning',
|
|
|
|
+ array(
|
|
|
|
+ 'id' => 'id',
|
|
|
|
+ 'label' => esc_html__( 'Color Accessibility Warning', 'varia' ),
|
|
|
|
+ 'description' => sprintf(
|
|
|
|
+ __( 'In order to ensure people can read your site, try to maintain a strong contrast ratio between the colors you choose here. <a href="%s" target="_blank">Learn more about color contrast</a>.', 'varia' ),
|
|
|
|
+ esc_url( 'https://a11yproject.com/posts/what-is-color-contrast/' )
|
|
|
|
+ ),
|
|
|
|
+ 'section' => 'colors_manager_tool',
|
|
|
|
+ 'priority' => 10,
|
|
|
|
+ 'type' => 'hidden',
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
|
|
}
|
|
}
|
|
add_action( 'customize_register', 'varia_wpcom_customize_update' );
|
|
add_action( 'customize_register', 'varia_wpcom_customize_update' );
|
|
|
|
|
|
-/**
|
|
|
|
-* Sanitize the checkbox.
|
|
|
|
-*
|
|
|
|
-* @param boolean $input.
|
|
|
|
-*
|
|
|
|
-* @return boolean true if is 1 or '1', false if anything else
|
|
|
|
-*/
|
|
|
|
-function varia_sanitize_checkbox( $input ) {
|
|
|
|
- if ( 1 == $input ) {
|
|
|
|
- return true;
|
|
|
|
- } else {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Bind JS handlers to instantly live-preview changes.
|
|
* Bind JS handlers to instantly live-preview changes.
|
|
*/
|
|
*/
|
|
@@ -146,8 +143,8 @@ add_filter( 'body_class', 'varia_wpcom_body_classes' );
|
|
function varia_wpcom_admin_body_classes( $classes ) {
|
|
function varia_wpcom_admin_body_classes( $classes ) {
|
|
global $post;
|
|
global $post;
|
|
$is_block_editor_screen = ( function_exists( 'get_current_screen' ) && get_current_screen() && get_current_screen()->is_block_editor() );
|
|
$is_block_editor_screen = ( function_exists( 'get_current_screen' ) && get_current_screen() && get_current_screen()->is_block_editor() );
|
|
- $hide = get_theme_mod( 'hide_front_page_title', false );
|
|
|
|
- $front_page = (int) get_option( 'page_on_front' );
|
|
|
|
|
|
+ $hide = get_theme_mod( 'hide_front_page_title', false );
|
|
|
|
+ $front_page = (int) get_option( 'page_on_front' );
|
|
|
|
|
|
if ( $is_block_editor_screen && $front_page === $post->ID && true === $hide ) {
|
|
if ( $is_block_editor_screen && $front_page === $post->ID && true === $hide ) {
|
|
$classes .= ' hide-homepage-title';
|
|
$classes .= ' hide-homepage-title';
|
|
@@ -168,7 +165,7 @@ add_action( 'enqueue_block_editor_assets', 'varia_wpcom_editor_scripts' );
|
|
/**
|
|
/**
|
|
* Enqueue CSS for customizer a11y warning.
|
|
* Enqueue CSS for customizer a11y warning.
|
|
*/
|
|
*/
|
|
-function varia_enqueue_message_scripts() {
|
|
|
|
|
|
+function varia_wpcom_enqueue_message_scripts() {
|
|
wp_enqueue_style( 'varia-customize-message-wpcom-style', get_template_directory_uri() . '/inc/customize-message-wpcom.css', array(), wp_get_theme()->get( 'Version' ) );
|
|
wp_enqueue_style( 'varia-customize-message-wpcom-style', get_template_directory_uri() . '/inc/customize-message-wpcom.css', array(), wp_get_theme()->get( 'Version' ) );
|
|
}
|
|
}
|
|
-add_action( 'customize_controls_enqueue_scripts', 'varia_enqueue_message_scripts' );
|
|
|
|
|
|
+add_action( 'customize_controls_enqueue_scripts', 'varia_wpcom_enqueue_message_scripts' );
|