2024-07-08 08:47:14 +00:00
|
|
|
<?php declare( strict_types = 1 ); ?>
|
2019-07-17 14:04:17 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Child Theme Functions and definitions
|
|
|
|
*
|
|
|
|
* @link https://developer.wordpress.org/themes/basics/theme-functions/
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
|
|
|
|
2020-08-25 20:02:23 +00:00
|
|
|
if ( ! function_exists( 'redhill_theme_setup' ) ) :
|
2019-07-17 14:04:17 +00:00
|
|
|
/**
|
|
|
|
* Sets up theme defaults and registers support for various WordPress features.
|
|
|
|
*
|
|
|
|
* Note that this function is hooked into the after_setup_theme hook, which
|
|
|
|
* runs before the init hook. The init hook is too late for some features, such
|
|
|
|
* as indicating support for post thumbnails.
|
|
|
|
*/
|
|
|
|
function redhill_theme_setup() {
|
|
|
|
// Add child theme editor styles, compiled from `style-child-theme-editor.scss`.
|
|
|
|
add_editor_style( 'style-editor.css' );
|
|
|
|
|
|
|
|
// Remove parent theme font sizes
|
|
|
|
remove_theme_support( 'editor-font-sizes' );
|
2019-07-18 14:50:16 +00:00
|
|
|
|
2019-07-17 14:04:17 +00:00
|
|
|
// Add child theme editor font sizes to match Sass-map variables in `_config-child-theme-deep.scss`.
|
|
|
|
add_theme_support(
|
|
|
|
'editor-font-sizes',
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'name' => __( 'Small', 'redhill' ),
|
|
|
|
'shortName' => __( 'S', 'redhill' ),
|
2019-07-18 08:06:07 +00:00
|
|
|
'size' => 16.66,
|
2019-07-17 14:04:17 +00:00
|
|
|
'slug' => 'small',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => __( 'Normal', 'redhill' ),
|
2019-07-18 08:06:07 +00:00
|
|
|
'shortName' => __( 'N', 'redhill' ),
|
|
|
|
'size' => 20,
|
2019-07-17 14:04:17 +00:00
|
|
|
'slug' => 'normal',
|
|
|
|
),
|
2019-07-18 08:06:07 +00:00
|
|
|
array(
|
|
|
|
'name' => __( 'Medium', 'redhill' ),
|
|
|
|
'shortName' => __( 'M', 'redhill' ),
|
|
|
|
'size' => 24,
|
|
|
|
'slug' => 'medium',
|
|
|
|
),
|
2019-07-17 14:04:17 +00:00
|
|
|
array(
|
|
|
|
'name' => __( 'Large', 'redhill' ),
|
|
|
|
'shortName' => __( 'L', 'redhill' ),
|
2019-07-18 08:06:07 +00:00
|
|
|
'size' => 28.8,
|
2019-07-17 14:04:17 +00:00
|
|
|
'slug' => 'large',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => __( 'Huge', 'redhill' ),
|
|
|
|
'shortName' => __( 'XL', 'redhill' ),
|
2019-07-18 08:06:07 +00:00
|
|
|
'size' => 34.56,
|
2019-07-17 14:04:17 +00:00
|
|
|
'slug' => 'huge',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-05-20 20:04:44 +00:00
|
|
|
/*
|
|
|
|
* Get customizer colors and add them to the editor color palettes
|
|
|
|
*
|
|
|
|
* - if the customizer color is empty, use the default
|
|
|
|
*/
|
2021-02-12 21:06:40 +00:00
|
|
|
$colors_array = get_theme_mod( 'colors_manager' ); // color annotations array()
|
|
|
|
$primary = is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) ? $colors_array['colors']['link'] : '#CA2017'; // $config-global--color-primary-default;
|
|
|
|
$secondary = is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) ? $colors_array['colors']['fg1'] : '#007FDB'; // $config-global--color-secondary-default;
|
|
|
|
$background = is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) ? $colors_array['colors']['bg'] : '#FFFFFF'; // $config-global--color-background-default;
|
|
|
|
$foreground = is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) ? $colors_array['colors']['txt'] : '#222222'; // $config-global--color-foreground-default;
|
|
|
|
$foreground_light = ( is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) && $colors_array['colors']['txt'] != '#222222' ) ? $colors_array['colors']['txt'] : '#666666'; // $config-global--color-foreground-light-default;
|
|
|
|
$foreground_dark = ( is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) && $colors_array['colors']['txt'] != '#222222' ) ? $colors_array['colors']['txt'] : '#111111'; // $config-global--color-foreground-dark-default;
|
2020-05-20 20:04:44 +00:00
|
|
|
|
|
|
|
// Editor color palette.
|
2019-07-17 14:04:17 +00:00
|
|
|
add_theme_support(
|
|
|
|
'editor-color-palette',
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'name' => __( 'Primary', 'redhill' ),
|
|
|
|
'slug' => 'primary',
|
2020-08-25 19:47:40 +00:00
|
|
|
'color' => $primary,
|
2019-07-17 14:04:17 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => __( 'Secondary', 'redhill' ),
|
|
|
|
'slug' => 'secondary',
|
2020-08-25 19:47:40 +00:00
|
|
|
'color' => $secondary,
|
2019-07-17 14:04:17 +00:00
|
|
|
),
|
2020-08-24 16:48:37 +00:00
|
|
|
array(
|
|
|
|
'name' => __( 'Background', 'redhill' ),
|
|
|
|
'slug' => 'background',
|
|
|
|
'color' => $background,
|
|
|
|
),
|
2019-07-17 14:04:17 +00:00
|
|
|
array(
|
2020-05-20 20:04:44 +00:00
|
|
|
'name' => __( 'Foreground', 'redhill' ),
|
2019-07-17 14:04:17 +00:00
|
|
|
'slug' => 'foreground',
|
2020-08-25 19:47:40 +00:00
|
|
|
'color' => $foreground,
|
2019-07-30 08:53:39 +00:00
|
|
|
),
|
2019-07-17 14:04:17 +00:00
|
|
|
array(
|
2020-08-24 16:48:37 +00:00
|
|
|
'name' => __( 'Foreground Light', 'redhill' ),
|
|
|
|
'slug' => 'foreground-light',
|
|
|
|
'color' => $foreground_light,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => __( 'Foreground Dark', 'redhill' ),
|
|
|
|
'slug' => 'foreground-dark',
|
|
|
|
'color' => $foreground_dark,
|
2019-07-17 14:04:17 +00:00
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
2019-07-18 15:16:34 +00:00
|
|
|
|
|
|
|
// Add child theme support for core custom logo.
|
|
|
|
add_theme_support(
|
|
|
|
'custom-logo',
|
|
|
|
array(
|
|
|
|
'height' => 120,
|
|
|
|
'width' => 100,
|
|
|
|
'flex-width' => true,
|
2019-12-10 22:06:29 +00:00
|
|
|
'flex-height' => true,
|
2019-07-18 15:16:34 +00:00
|
|
|
'header-text' => array( 'site-title', 'site-description' ),
|
|
|
|
)
|
|
|
|
);
|
2019-07-17 14:04:17 +00:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
add_action( 'after_setup_theme', 'redhill_theme_setup', 12 );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the content width in pixels, based on the child-theme's design and stylesheet.
|
|
|
|
*
|
|
|
|
* Priority 0 to make it available to lower priority callbacks.
|
|
|
|
*
|
|
|
|
* @global int $content_width Content width.
|
|
|
|
*/
|
|
|
|
function redhill_theme_content_width() {
|
|
|
|
// This variable is intended to be overruled from themes.
|
|
|
|
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
|
|
|
|
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
|
|
|
|
$GLOBALS['content_width'] = apply_filters( 'redhill_theme_content_width', 740 );
|
|
|
|
}
|
|
|
|
add_action( 'after_setup_theme', 'redhill_theme_content_width', 0 );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enqueue scripts and styles.
|
|
|
|
*/
|
|
|
|
function redhill_theme_scripts() {
|
|
|
|
|
|
|
|
// dequeue parent styles
|
2019-07-19 04:15:29 +00:00
|
|
|
wp_dequeue_style( 'varia-style' );
|
2019-07-17 14:04:17 +00:00
|
|
|
|
|
|
|
// enqueue child styles
|
2021-02-12 21:06:40 +00:00
|
|
|
wp_enqueue_style( 'redhill-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) );
|
2019-07-17 14:04:17 +00:00
|
|
|
|
|
|
|
// enqueue child RTL styles
|
|
|
|
wp_style_add_data( 'redhill-style', 'rtl', 'replace' );
|
|
|
|
|
|
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'redhill_theme_scripts', 99 );
|
2020-08-24 16:48:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enqueue theme styles for the block editor.
|
|
|
|
*/
|
|
|
|
function redhill_editor_styles() {
|
|
|
|
|
|
|
|
// Hide duplicate palette colors
|
|
|
|
$colors_array = get_theme_mod( 'colors_manager' );
|
|
|
|
if ( ! empty( $colors_array ) && $colors_array['colors']['txt'] != '#666666' ) { // $config-global--color-foreground-light-default;
|
2020-11-04 22:13:51 +00:00
|
|
|
$inline_palette_css = '.components-circular-option-picker__option-wrapper:nth-child(5),
|
|
|
|
.components-circular-option-picker__option-wrapper:nth-child(6) {
|
2020-08-24 16:48:37 +00:00
|
|
|
display: none;
|
|
|
|
}';
|
|
|
|
wp_add_inline_style( 'wp-edit-blocks', $inline_palette_css );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
add_action( 'enqueue_block_editor_assets', 'redhill_editor_styles' );
|