File: //backups/73incnz/wp-content/themes/ovation/functions.php
<?php
/**
* Ovation functions and definitions.
*
* Sets up the theme and provides some helper functions, which are used in the
* theme as custom template tags. Others are attached to action and filter
* hooks in WordPress to change core functionality.
*
* When using a child theme (see https://codex.wordpress.org/Theme_Development
* and https://codex.wordpress.org/Child_Themes), you can override certain
* functions (those wrapped in a function_exists() call) by defining them first
* in your child theme's functions.php file. The child theme's functions.php
* file is included before the parent theme's file, so the child theme
* functions would be used.
*
* Functions that are not pluggable (not wrapped in function_exists()) are
* instead attached to a filter or action hook.
*
* For more information on hooks, actions, and filters,
* see https://codex.wordpress.org/Plugin_API
*
* @package Ovation
* @since 1.0.0
*/
/**
* Load helper functions and libraries.
*/
require get_parent_theme_file_path( '/includes/customizer.php' );
require get_parent_theme_file_path( '/includes/hooks.php' );
require get_parent_theme_file_path( '/includes/styles.php' );
require get_parent_theme_file_path( '/includes/template-helpers.php' );
require get_parent_theme_file_path( '/includes/template-tags.php' );
require get_parent_theme_file_path( '/includes/vendor/cedaro-theme/autoload.php' );
ovation_theme()->load();
/**
* Set up theme defaults and register support for various WordPress features.
*
* @since 1.0.0
*/
function ovation_setup() {
// Set the default content width.
$GLOBALS['content_width'] = 800;
// Add support for translating strings in this theme.
load_theme_textdomain( 'ovation', get_template_directory() . '/languages' );
// This theme styles the visual editor to resemble the theme style.
add_editor_style( array(
is_rtl() ? 'assets/css/editor-style-rtl.css' : 'assets/css/editor-style.css',
ovation_fonts_icon_url(),
) );
// Add support for default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
// Add support for the title tag.
add_theme_support( 'title-tag' );
// Add support for post thumbnails.
add_theme_support( 'post-thumbnails' );
add_image_size( 'ovation-banner-image', 1400, 600 );
add_image_size( 'ovation-featured-image', 960, 960 );
add_image_size( 'ovation-fullscreen-image', 2000, 1200 );
add_image_size( 'ovation-landscape', 620, 350, array( 'center', 'top' ) );
set_post_thumbnail_size( 620, 620, array( 'center', 'top' ) );
// Add support for a logo.
add_theme_support( 'custom-logo', array(
'width' => 800,
'height' => 280,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( 'site-title', 'site-description' ),
) );
// Add support to allow widgets to use selective refresh in the Customizer.
add_theme_support( 'customize-selective-refresh-widgets' );
// Add support for custom background functionality.
add_theme_support( 'custom-background', array(
'default-color' => 'ffffff',
) );
// Add support for custom header functionality.
add_theme_support( 'custom-header', array(
'default-image' => '',
'random-default' => false,
'width' => 1440,
'height' => 500,
'flex-width' => true,
'flex-height' => true,
'default-text-color' => 'ffffff',
'header-text' => false,
'uploads' => true,
'video' => true,
) );
// Add HTML5 markup for the comment forms, search forms and comment lists.
add_theme_support( 'html5', array(
'caption',
'comment-form',
'comment-list',
'gallery',
'search-form',
) );
// Add support for block styles.
add_theme_support( 'wp-block-styles' );
// Add support for full and wide alignment.
add_theme_support( 'align-wide' );
// Add support for responsive embedded content.
add_theme_support( 'responsive-embeds' );
// Register default nav menus.
register_nav_menus( array(
'menu-1' => esc_html__( 'Header Menu', 'ovation' ),
'social' => esc_html__( 'Social Links Menu', 'ovation' ),
) );
// Register support for page type templates.
ovation_theme()->page_types->add_support()->register( 'grid', array(
'archive_template' => 'templates/grid-page.php',
'single_template' => 'templates/grid-page-child.php',
) );
}
add_action( 'after_setup_theme', 'ovation_setup' );
/**
* Register widget area.
*
* @since 1.0.0
*/
function ovation_register_sidebars() {
register_sidebar( array(
'id' => 'sidebar-1',
'name' => esc_html__( 'Sidebar', 'ovation' ),
'description' => esc_html__( 'Add widgets here to appear in your sidebar.', 'ovation' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'ovation_register_sidebars' );
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ovation_enqueue_assets() {
// Add Themicons font, used in the main stylesheet.
wp_enqueue_style( 'themicons', ovation_fonts_icon_url(), array(), '2.3.1' );
// Load main style sheet.
wp_enqueue_style( 'ovation-style', get_stylesheet_uri() );
// Load RTL style sheet.
wp_style_add_data( 'ovation-style', 'rtl', 'replace' );
// Register scripts for enqueueing on demand.
wp_register_script(
'jquery-cue',
get_theme_file_uri( '/assets/js/vendor/jquery.cue.js' ),
array( 'jquery', 'mediaelement' ),
'1.2.4',
true
);
// Load theme scripts.
wp_enqueue_script(
'appendaround',
get_theme_file_uri( '/assets/js/vendor/appendaround.js' ),
array( 'jquery' ),
'20161216',
true
);
wp_enqueue_script(
'fitie',
get_theme_file_uri( '/assets/js/vendor/fitie.js' ),
array(),
'1.0.0'
);
wp_enqueue_script(
'wp-nav-menus',
get_theme_file_uri( '/assets/js/vendor/wp-nav-menus.js' ),
array(),
'1.0.0',
true
);
wp_localize_script( 'wp-nav-menus', '_cedaroNavMenuL10n', array(
'collapseSubmenu' => esc_html__( 'Collapse submenu', 'ovation' ),
'expandSubmenu' => esc_html__( 'Expand submenu', 'ovation' ),
) );
wp_enqueue_script(
'ovation-script',
get_theme_file_uri( '/assets/js/main.js' ),
array( 'jquery', 'appendaround', 'wp-nav-menus' ),
'20161216',
true
);
/*
* Enqueue the script to make the site navigation sticky.
*
* If the first section is the navigation, it will always be sticky, so the
* script is necessary. The body class is applied in ovation_body_class().
*/
$sections = ovation_get_site_header_sections();
if ( get_theme_mod( 'enable_sticky_navigation', '1' ) && 'site-navigation' !== key( $sections ) ) {
wp_enqueue_script(
'ovation-header',
get_theme_file_uri( '/assets/js/header.js' ),
array(),
'20161216',
true
);
}
// Load script to support comment threading when it's enabled.
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'ovation_enqueue_assets' );
/**
* Enqueue block editor assets.
*
* @since 2.0.0
*/
function ovation_enqueue_block_editor_assets() {
wp_enqueue_style(
'ovation-block-editor',
get_theme_file_uri( 'assets/css/block-editor.css' ),
array( 'wp-edit-blocks' )
);
}
add_action( 'enqueue_block_editor_assets', 'ovation_enqueue_block_editor_assets' );
/**
* Print CSS to update the sidebar toggle button label.
*
* @since 1.0.0
* @deprecated 1.3.0 Styles are now output in ovation_get_sidebar_toggle_css()
* to allow for customization.
* @see ovation_get_sidebar_toggle_css()
*/
function ovation_sidebar_toggle_css() {}
/**
* JavaScript detection.
*
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
*
* @since 1.0.0
*/
function ovation_javascript_detection() {
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
}
add_action( 'wp_head', 'ovation_javascript_detection', 0 );
/**
* Configure MediaElement.js elements to aid styling.
*
* Extends the core _wpmejsSettings object to add a new feature via the
* MediaElement.js plugin API.
*
* @since 1.0.0
*/
function ovation_mejs_setup() {
if ( ! wp_script_is( 'mediaelement', 'done' ) ) {
return;
}
?>
<script>
(function() {
var settings = window._wpmejsSettings || {};
settings.features = settings.features || mejs.MepDefaults.features;
settings.features.push( 'ovationtheme' );
MediaElementPlayer.prototype.buildovationtheme = function( player ) {
var container = player.container[0] || player.container;
if ( 'AUDIO' === player.node.nodeName ) {
player.options.setDimensions = false;
container.classList.add( 'ovation-mejs-container' );
container.style.height = '';
container.style.width = '';
}
};
})();
</script>
<?php
}
add_action( 'wp_print_footer_scripts', 'ovation_mejs_setup' );
/**
* Retrieve the icon font style sheet URL.
*
* @since 1.0.0
*
* @return string Font stylesheet.
*/
function ovation_fonts_icon_url() {
return get_theme_file_uri( '/assets/css/themicons.css' );
}
/**
* Wrapper for accessing the Cedaro_Theme instance.
*
* @since 1.0.0
*
* @return Cedaro_Theme
*/
function ovation_theme() {
static $instance;
if ( null === $instance ) {
Cedaro_Theme_Autoloader::register();
$instance = new Cedaro_Theme( array( 'prefix' => 'ovation' ) );
}
return $instance;
}
/**
* Load support for WordPress.com and Jetpack Pro sites.
*/
if ( file_exists( get_parent_theme_file_path( '/includes/plugins/jetpack-pro/front-page-sections.php' ) ) ) {
require get_parent_theme_file_path( '/includes/plugins/jetpack-pro/front-page-sections.php' );
}
if ( file_exists( get_parent_theme_file_path( '/includes/plugins/jetpack-pro/page-types.php' ) ) ) {
require get_parent_theme_file_path( '/includes/plugins/jetpack-pro/page-types.php' );
}