2019-08-15 20:41:25 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Child Theme Functions and definitions
|
|
|
|
*
|
|
|
|
* @link https://developer.wordpress.org/themes/basics/theme-functions/
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Rivington
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ! function_exists( 'rivington_setup' ) ) :
|
|
|
|
/**
|
|
|
|
* 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 rivington_setup() {
|
|
|
|
// Add child theme editor styles, compiled from `style-child-theme-editor.scss`.
|
|
|
|
add_editor_style( 'style-editor.css' );
|
|
|
|
|
2019-08-24 04:28:10 +00:00
|
|
|
add_theme_support( 'editor-styles' );
|
|
|
|
|
2019-08-15 20:41:25 +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', 'rivington' ),
|
|
|
|
'shortName' => __( 'S', 'rivington' ),
|
2019-08-24 04:28:10 +00:00
|
|
|
'size' => 14.4,
|
2019-08-15 20:41:25 +00:00
|
|
|
'slug' => 'small',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => __( 'Normal', 'rivington' ),
|
|
|
|
'shortName' => __( 'M', 'rivington' ),
|
2019-08-24 04:28:10 +00:00
|
|
|
'size' => 18,
|
2019-08-15 20:41:25 +00:00
|
|
|
'slug' => 'normal',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => __( 'Large', 'rivington' ),
|
|
|
|
'shortName' => __( 'L', 'rivington' ),
|
2019-08-24 04:28:10 +00:00
|
|
|
'size' => 28.12,
|
2019-08-15 20:41:25 +00:00
|
|
|
'slug' => 'large',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => __( 'Huge', 'rivington' ),
|
|
|
|
'shortName' => __( 'XL', 'rivington' ),
|
2019-08-24 04:28:10 +00:00
|
|
|
'size' => 35.15,
|
2019-08-15 20:41:25 +00:00
|
|
|
'slug' => 'huge',
|
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2020-05-20 20:39:25 +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'] : '#CAAB57'; // $config-global--color-primary-default;
|
|
|
|
$secondary = is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) ? $colors_array['colors']['fg1'] : '#EE4266'; // $config-global--color-secondary-default;
|
|
|
|
$background = is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) ? $colors_array['colors']['bg'] : '#060f29'; // $config-global--color-background-default;
|
|
|
|
$foreground = is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) ? $colors_array['colors']['txt'] : '#F2F2F2'; // $config-global--color-foreground-default;
|
|
|
|
$foreground_light = ( is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) && $colors_array['colors']['txt'] != '#F2F2F2' ) ? $colors_array['colors']['txt'] : '#FFFFFF'; // $config-global--color-foreground-light-default;
|
|
|
|
$foreground_dark = ( is_array( $colors_array ) && array_key_exists( 'colors', $colors_array ) && $colors_array['colors']['txt'] != '#F2F2F2' ) ? $colors_array['colors']['txt'] : '#8F8F8F'; // $config-global--color-foreground-dark-default;
|
2020-05-20 20:39:25 +00:00
|
|
|
|
|
|
|
// Editor color palette.
|
2019-08-15 20:41:25 +00:00
|
|
|
add_theme_support(
|
|
|
|
'editor-color-palette',
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'name' => __( 'Primary', 'rivington' ),
|
|
|
|
'slug' => 'primary',
|
2020-05-21 16:41:36 +00:00
|
|
|
'color' => $primary,
|
2019-08-15 20:41:25 +00:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => __( 'Secondary', 'rivington' ),
|
|
|
|
'slug' => 'secondary',
|
2020-05-21 16:41:36 +00:00
|
|
|
'color' => $secondary,
|
2019-08-15 20:41:25 +00:00
|
|
|
),
|
2020-06-02 19:58:31 +00:00
|
|
|
array(
|
|
|
|
'name' => __( 'Background', 'rivington' ),
|
|
|
|
'slug' => 'background',
|
|
|
|
'color' => $background,
|
|
|
|
),
|
2019-08-15 20:41:25 +00:00
|
|
|
array(
|
2020-05-20 20:39:25 +00:00
|
|
|
'name' => __( 'Foreground', 'rivington' ),
|
2019-08-15 20:41:25 +00:00
|
|
|
'slug' => 'foreground',
|
2020-05-21 16:41:36 +00:00
|
|
|
'color' => $foreground,
|
2019-08-15 20:41:25 +00:00
|
|
|
),
|
|
|
|
array(
|
2020-06-02 19:58:31 +00:00
|
|
|
'name' => __( 'Foreground Light', 'rivington' ),
|
|
|
|
'slug' => 'foreground-light',
|
|
|
|
'color' => $foreground_light,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => __( 'Foreground Dark', 'rivington' ),
|
|
|
|
'slug' => 'foreground-dark',
|
|
|
|
'color' => $foreground_dark,
|
2019-08-15 20:41:25 +00:00
|
|
|
),
|
|
|
|
)
|
|
|
|
);
|
2020-05-20 20:39:25 +00:00
|
|
|
|
2019-08-28 22:48:49 +00:00
|
|
|
// Remove footer menu
|
|
|
|
unregister_nav_menu( 'menu-2' );
|
2020-12-04 22:50:08 +00:00
|
|
|
|
2020-12-16 19:33:53 +00:00
|
|
|
// Setup nav on side toggle support.
|
|
|
|
if ( function_exists( 'varia_mobile_nav_on_side_setup' ) ) {
|
|
|
|
varia_mobile_nav_on_side_setup();
|
2020-12-09 06:46:12 +00:00
|
|
|
}
|
2019-08-15 20:41:25 +00:00
|
|
|
}
|
|
|
|
endif;
|
|
|
|
add_action( 'after_setup_theme', 'rivington_setup', 12 );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter the content_width in pixels, based on the child-theme's design and stylesheet.
|
|
|
|
*/
|
|
|
|
function rivington_content_width() {
|
|
|
|
return 750;
|
|
|
|
}
|
|
|
|
add_filter( 'varia_content_width', 'rivington_content_width' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add Google webfonts, if necessary
|
|
|
|
*
|
|
|
|
* - See: http://themeshaper.com/2014/08/13/how-to-add-google-fonts-to-wordpress-themes/
|
|
|
|
*/
|
|
|
|
function rivington_fonts_url() {
|
|
|
|
|
|
|
|
$fonts_url = '';
|
|
|
|
|
|
|
|
/* Translators: If there are characters in your language that are not
|
2019-12-20 13:26:30 +00:00
|
|
|
* supported by Poppins, translate this to 'off'. Do not translate
|
2019-08-15 20:41:25 +00:00
|
|
|
* into your own language.
|
|
|
|
*/
|
2019-12-20 13:26:30 +00:00
|
|
|
$poppins = esc_html_x( 'on', 'Poppins font: on or off', 'rivington' );
|
2019-08-15 20:41:25 +00:00
|
|
|
|
2019-12-20 13:26:30 +00:00
|
|
|
if ( 'off' !== $poppins ) {
|
2019-08-15 20:41:25 +00:00
|
|
|
$font_families = array();
|
|
|
|
|
2019-12-20 13:26:30 +00:00
|
|
|
$font_families[] = 'Poppins:400,400i,600,600i';
|
2019-08-15 20:41:25 +00:00
|
|
|
|
2021-02-18 15:20:38 +00:00
|
|
|
/**
|
|
|
|
* A filter to enable child themes to add/change/omit font families.
|
2021-08-06 08:51:12 +00:00
|
|
|
*
|
2021-02-18 15:20:38 +00:00
|
|
|
* @param array $font_families An array of font families to be imploded for the Google Font API
|
|
|
|
*/
|
|
|
|
$font_families = apply_filters( 'included_google_font_families', $font_families );
|
|
|
|
|
2019-08-15 20:41:25 +00:00
|
|
|
$query_args = array(
|
|
|
|
'family' => urlencode( implode( '|', $font_families ) ),
|
|
|
|
'subset' => urlencode( 'latin,latin-ext' ),
|
|
|
|
);
|
|
|
|
|
|
|
|
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
|
|
|
|
}
|
|
|
|
|
|
|
|
return esc_url_raw( $fonts_url );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enqueue scripts and styles.
|
|
|
|
*/
|
|
|
|
function rivington_scripts() {
|
|
|
|
|
|
|
|
// enqueue Google fonts, if necessary
|
|
|
|
// wp_enqueue_style( 'rivington-fonts', rivington_fonts_url(), array(), null );
|
|
|
|
|
|
|
|
// dequeue parent styles
|
|
|
|
wp_dequeue_style( 'varia-style' );
|
|
|
|
|
|
|
|
// enqueue child styles
|
2021-02-12 21:06:40 +00:00
|
|
|
wp_enqueue_style( 'rivington-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) );
|
2019-08-15 20:41:25 +00:00
|
|
|
|
|
|
|
// enqueue child RTL styles
|
|
|
|
wp_style_add_data( 'rivington-style', 'rtl', 'replace' );
|
|
|
|
|
|
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'rivington_scripts', 99 );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enqueue theme styles for the block editor.
|
|
|
|
*/
|
|
|
|
function rivington_editor_styles() {
|
|
|
|
|
|
|
|
// Enqueue Google fonts in the editor, if necessary
|
|
|
|
wp_enqueue_style( 'rivington-editor-fonts', rivington_fonts_url(), array(), null );
|
2020-07-13 18:38:59 +00:00
|
|
|
|
|
|
|
// Hide duplicate palette colors
|
2021-02-12 21:06:40 +00:00
|
|
|
$colors_array = get_theme_mod( 'colors_manager', array( 'colors' => true ) ); // color annotations array()
|
2020-07-13 18:38:59 +00:00
|
|
|
if ( ! empty( $colors_array ) && $colors_array['colors']['txt'] != '#F2F2F2' ) { // $config-global--color-foreground-light-default;
|
2020-11-04 22:14:37 +00:00
|
|
|
$inline_palette_css = '.components-circular-option-picker__option-wrapper:nth-child(5),
|
|
|
|
.components-circular-option-picker__option-wrapper:nth-child(6) {
|
2020-07-13 18:38:59 +00:00
|
|
|
display: none;
|
|
|
|
}';
|
|
|
|
wp_add_inline_style( 'wp-edit-blocks', $inline_palette_css );
|
|
|
|
}
|
2019-08-15 20:41:25 +00:00
|
|
|
}
|
|
|
|
add_action( 'enqueue_block_editor_assets', 'rivington_editor_styles' );
|