tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// Custom logo
$defaults = array(
'flex-height' => true,
'flex-width' => true,
);
add_theme_support( 'custom-logo', $defaults );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'the-m-x' ),
'social' => esc_html__( 'Social Profiles', 'the-m-x' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
/*
* Enable support for Post Formats.
* See https://developer.wordpress.org/themes/functionality/post-formats/
*/
add_theme_support( 'post-formats', array(
'aside',
'audio',
'gallery',
'image',
'link',
'quote',
'video',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'the_mx_custom_background_args', array(
'default-color' => 'efebe9',
'default-image' => '',
) ) );
// Custom image sizes
add_image_size( 'the-mx-gallery-thumb', 300, 300, array( 'center', 'center' ) );
// Support for Gutenberg
add_theme_support( 'align-wide' );
add_theme_support(
'editor-color-palette', array(
array(
'name' => esc_html__( 'White', 'the-m-x' ),
'slug' => 'white',
'color' => '#ffffff',
),
array(
'name' => esc_html__( 'Black', 'the-m-x' ),
'slug' => 'black',
'color' => '#000000',
),
array(
'name' => esc_html__( 'Primary Color', 'the-m-x' ),
'slug' => 'primary-1',
'color' => esc_html( get_theme_mod( 'the_mx_primary_1' ) ),
),
array(
'name' => esc_html__( 'Primary Color Dark Variant', 'the-m-x' ),
'slug' => 'primary-2',
'color' => esc_html( get_theme_mod( 'the_mx_primary_2' ) ),
),
array(
'name' => esc_html__( 'Primary Color Darker Variant', 'the-m-x' ),
'slug' => 'primary-3',
'color' => esc_html( get_theme_mod( 'the_mx_primary_3' ) ),
),
array(
'name' => esc_html__( 'Primary Color Light Variant', 'the-m-x' ),
'slug' => 'primary-4',
'color' => esc_html( get_theme_mod( 'the_mx_primary_4' ) ),
),
array(
'name' => esc_html__( 'Accent Color', 'the-m-x' ),
'slug' => 'accent-1',
'color' => esc_html( get_theme_mod( 'the_mx_accent_1' ) ),
),
array(
'name' => esc_html__( 'Accent Color Dark Variant', 'the-m-x' ),
'slug' => 'accent-2',
'color' => esc_html( get_theme_mod( 'the_mx_accent_2' ) ),
),
array(
'name' => esc_html__( 'Accent Color Darker Variant', 'the-m-x' ),
'slug' => 'accent-3',
'color' => esc_html( get_theme_mod( 'the_mx_accent_3' ) ),
),
)
);
}
endif;
add_action( 'after_setup_theme', 'the_mx_setup' );
/* Function that adds custom colors to front end from Gutenberg colors */
function the_mx_gutenberg_colors() {
$primary_1 = get_theme_mod( 'the_mx_primary_1', '#795548' );
$primary_2 = get_theme_mod( 'the_mx_primary_2', '#5d4037' );
$primary_3 = get_theme_mod( 'the_mx_primary_3', '#3e2723' );
$primary_4 = get_theme_mod( 'the_mx_primary_4', '#bcaaa4' );
$accent_1 = get_theme_mod( 'the_mx_accent_1', '#ffc107' );
$accent_2 = get_theme_mod( 'the_mx_accent_2', '#ffa000' );
$accent_3 = get_theme_mod( 'the_mx_accent_3', '#ff6f00' );
$css = '';
$css .= '.has-white-color { color: rgba(255, 255, 255, 0.87); }';
$css .= '.has-white-background-color { background-color: #ffffff; }';
$css .= '';
$css .= '.has-black-color { color: rgba(0, 0, 0, 0.87); }';
$css .= '.has-black-background-color { background-color: #000000; }';
$css .= '';
$css .= '.has-primary-1-color { color: ' . esc_attr( $primary_1 ) . '; }';
$css .= '.has-primary-1-background-color { background-color: ' . esc_attr( $primary_1 ) . '; }';
$css .= '';
$css .= '.has-primary-2-color { color: ' . esc_attr( $primary_2 ) . '; }';
$css .= '.has-primary-2-background-color { background-color: ' . esc_attr( $primary_2 ) . '; }';
$css .= '';
$css .= '.has-primary-3-color { color: ' . esc_attr( $primary_3 ) . '; }';
$css .= '.has-primary-3-background-color { background-color: ' . esc_attr( $primary_3 ) . '; }';
$css .= '';
$css .= '.has-primary-4-color { color: ' . esc_attr( $primary_4 ) . '; }';
$css .= '.has-primary-4-background-color { background-color: ' . esc_attr( $primary_4 ) . '; }';
$css .= '';
$css .= '.has-accent-1-color { color: ' . esc_attr( $accent_1 ) . '; }';
$css .= '.has-accent-1-background-color { background-color: ' . esc_attr( $accent_1 ) . '; }';
$css .= '';
$css .= '.has-accent-2-color { color: ' . esc_attr( $accent_2 ) . '; }';
$css .= '.has-accent-2-background-color { background-color: ' . esc_attr( $accent_2 ) . '; }';
$css .= '';
$css .= '.has-accent-3-color { color: ' . esc_attr( $accent_3 ) . '; }';
$css .= '.has-accent-3-background-color { background-color: ' . esc_attr( $accent_3 ) . '; }';
return wp_strip_all_tags( $css );
}
function the_mx_image_sizes( $sizes ) {
$addsizes = array(
'the-mx-gallery-thumb' => esc_html__( 'Gallery Thumbnail (300 x 300, hard cropped)', 'the-m-x' ),
);
$newsizes = array_merge( $sizes, $addsizes );
return $newsizes;
}
add_filter( 'image_size_names_choose', 'the_mx_image_sizes' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function the_mx_content_width() {
$GLOBALS['content_width'] = apply_filters( 'the_mx_content_width', 960 );
}
add_action( 'after_setup_theme', 'the_mx_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function the_mx_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'the-m-x' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets to the Sidebar.', 'the-m-x' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Hero Image Widget', 'the-m-x' ),
'id' => 'hero-image-widget',
'description' => esc_html__( 'Add widget to be displayed above Hero (header) Image.', 'the-m-x' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Widgets', 'the-m-x' ),
'id' => 'footer-widget-area',
'description' => esc_html__( 'Add widgets to the Footer.', 'the-m-x' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'the_mx_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function the_mx_enqueue_scripts() {
// Shared variables
$mx_animate = get_theme_mod( 'the_mx_animate_css', 1 );
$mx_colorbox = get_theme_mod( 'the_mx_enable_colorbox', 0 );
// Styles
wp_enqueue_style( 'the-mx-style', get_template_directory_uri() . '/style.min.css' );
// Add Gutenberg custom colors to the front end
wp_add_inline_style( 'the-mx-style', the_mx_gutenberg_colors() );
wp_enqueue_style( 'the-mx-sup-style', get_template_directory_uri() . '/css/minfiles/supporting-styles.min.css', array( 'the-mx-style' ) );
// Enqueue this for now; may be added to the Customizer later
wp_enqueue_style( 'the-mx-right-sidebar-overlay', get_template_directory_uri() . '/css/layouts/content-sidebar-overlay.css', array( 'the-mx-style' ) );
// Icon fonts
wp_enqueue_style( 'the-mx-fonts', 'https://fonts.googleapis.com/css?family=Raleway:400,500,300', false );
wp_enqueue_style( 'material-icons', 'https://fonts.googleapis.com/icon?family=Material+Icons', false );
// Conditionally loaded
if ( $mx_colorbox == 1 && shortcode_exists( 'gallery' ) ) {
wp_enqueue_style( 'the-mx-colorbox-styles', get_template_directory_uri() . '/css/minfiles/the-mx-colorbox.min.css' );
}
if( $mx_animate == 1 ) {
wp_enqueue_style( 'animate', get_template_directory_uri() . '/css/minfiles/animation-styles.min.css' );
}
// Scripts
if ( get_theme_mod( 'the_mx_skrollr_animations' ) == 1 ) {
wp_enqueue_script( 'the-mx-skrollr-data-atts', get_template_directory_uri() . '/js/minfiles/add-skrollr-data-attributes.min.js', array(), '', true );
$parameters = array(
'layout_type' => get_theme_mod( 'the_mx_layout', 'centered' ),
);
wp_localize_script( 'the-mx-skrollr-data-atts', 'mxSkrollrParams', $parameters );
wp_enqueue_script( 'skrollr', get_template_directory_uri() . '/js/minfiles/skrollr.min.js', array(), '', true );
wp_add_inline_script( 'skrollr',
'function skrollrInit() {
var s = skrollr.init({
forceHeight: false
});
//console.log("Skrollr initialized.");
}
document.addEventListener( "DOMContentLoaded", skrollrInit );'
);
wp_enqueue_script( 'the-mx-skrollr-init', get_template_directory_uri() . '/js/minfiles/mx-skrollr-init.min.js', array(), '', true );
}
wp_enqueue_script( 'the-mx-scripts', get_template_directory_uri() . '/js/minfiles/scripts.min.js', array( 'jquery' ), '', true );
$parameters = array(
'layouts' => get_theme_mod( 'the_mx_layout', 'centered' ),
);
wp_localize_script( 'the-mx-scripts', 'jgdGridParams', $parameters );
$parameters = array(
'link_to' => get_theme_mod( 'the_mx_media_link_to', 'attachment' ),
);
wp_localize_script( 'the-mx-scripts', 'colorboxParams', $parameters );
$parameters = array(
'layouts' => get_theme_mod( 'the_mx_layout', 'centered' ),
);
wp_localize_script( 'the-mx-scripts', 'restoreJSParams', $parameters );
$parameters = array(
'sliderControl' => get_theme_mod( 'the_mx_single_slider', 0 ),
);
wp_localize_script( 'the-mx-scripts', 'mxScriptParams', $parameters );
wp_localize_script( 'the-mx-scripts', 'colorScheme',
array(
'headerTextColor' => get_header_textcolor(),
'primaryColor3' => esc_html( get_theme_mod( 'the_mx_primary_3', '#3e2723' ) ),
) );
wp_enqueue_script( 'throttle-debounce', get_template_directory_uri() . '/js/minfiles/ba-throttle-debounce.min.js', array(), '', true );
// Conditionally loaded
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( $mx_colorbox == 1 && shortcode_exists( 'gallery' ) ) {
wp_enqueue_script( 'colorbox', get_template_directory_uri() . '/js/minfiles/jquery.colorbox-min.js', array( 'jquery' ), '', false );
}
if ( get_theme_mod( 'the_mx_single_slider' ) == 1 && is_single() ) {
wp_dequeue_script( 'colorbox' );
wp_dequeue_style( 'the-mx-colorbox-styles' );
}
if( $mx_animate ) {
wp_enqueue_script( 'ripple', get_template_directory_uri() . '/js/minfiles/ripple.min.js', array( 'jquery' ), '', true );
}
if( is_page_template( 'page-templates/template-landing.php' ) ) {
wp_enqueue_script( 'the-mx-headroom', get_template_directory_uri() . '/js/minfiles/headroom.min.js', array(), '20180530', true );
}
}
add_action( 'wp_enqueue_scripts', 'the_mx_enqueue_scripts' );
// Additional scripts enqueued in inc/jetpack.php
/* Add