Current File : /home/kelaby89/iluxelectrical.com.au/wp-content/themes/strnix/functions.php |
<?php
/**
* strnix functions and definitions [STRNIX]
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package strnix
*/
defined('STRNIX_THEME_URI') or define('STRNIX_THEME_URI', get_template_directory_uri());
define('STRNIX_THEME_DRI', get_template_directory());
define('STRNIX_IMG_URL', STRNIX_THEME_URI . '/assets/images/');
define('STRNIX_CSS_URL', STRNIX_THEME_URI . '/assets/css/');
define('STRNIX_JS_URL', STRNIX_THEME_URI . '/assets/js/');
define('STRNIX_FRAMEWORK_DRI', STRNIX_THEME_DRI . '/framework/');
require_once STRNIX_FRAMEWORK_DRI . 'plugin-list.php';
require_once STRNIX_FRAMEWORK_DRI . 'styles/index.php';
require_once STRNIX_FRAMEWORK_DRI . 'styles/daynamic-style.php';
require_once STRNIX_FRAMEWORK_DRI . 'scripts/index.php';
require_once STRNIX_FRAMEWORK_DRI . 'redux/redux-config.php';
require_once STRNIX_FRAMEWORK_DRI . 'meta-box/config-meta-box.php';
require_once STRNIX_FRAMEWORK_DRI . "tgm/class-tgm-plugin-activation.php";
require_once STRNIX_FRAMEWORK_DRI . "tgm/config-tgm.php";
require_once STRNIX_FRAMEWORK_DRI . "classes/strnix-int.php";
require_once STRNIX_FRAMEWORK_DRI . "classes/strnix-act.php";
require_once STRNIX_FRAMEWORK_DRI . "dashboard/class-dashboard.php";
/**
* Theme option compatibility.
*/
if ( ! function_exists( 'strnix_get_options' ) ) :
function strnix_get_options( $key ) {
global $strnix_options;
$opt_pref = 'strnix_';
if ( empty( $strnix_options ) ) {
$strnix_options = get_option( $opt_pref . 'options' );
}
$index = $opt_pref . $key;
if(!isset($strnix_options[ $index ])) {
return false;
}
return $strnix_options[ $index ];
}
endif;
if ( ! function_exists( 'strnix_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 strnix_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on love us, use a find and replace
* to change 'strnix' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'strnix', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> 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' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'strnix' ),
) );
/*
* 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',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'strnix_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
) );
}
endif;
add_action( 'after_setup_theme', 'strnix_setup' );
/**
* 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 strnix_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( 'strnix_content_width', 640 );
}
add_action( 'after_setup_theme', 'strnix_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function strnix_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Blog Sidebar', 'strnix' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'strnix' ),
'before_widget' => '<div id="%1$s" class="sidebar-widget %2$s"><div class="widget-content">',
'after_widget' => '</div></div>',
'before_title' => '<div class="sidebar-title"><h3>',
'after_title' => '</h3><div class="bottom-dots clearfix"><span class="dot line-dot"></span><span class="dot"></span><span class="dot"></span><span class="dot"></span></div></div>',
) );
}
add_action( 'widgets_init', 'strnix_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function strnix_scripts() {
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'strnix_scripts' );
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* google font compatibility.
*/
function strnix_google_font() {
$protocol = is_ssl() ? 'https' : 'http';
$subsets = 'latin,cyrillic-ext,latin-ext,cyrillic,greek-ext,greek,vietnamese';
$variants = ':300,400,400i,600,600i,700,700i,800,800i';
$query_args = array(
'family' => 'Hind|Merriweather' . $variants,
'family' => 'Hind' . $variants.'%7CMerriweather' . $variants,
'subset' => $subsets,
);
$font_url = add_query_arg($query_args, $protocol . "://fonts.googleapis.com/css");
wp_enqueue_style('strnix-google-fonts', $font_url, array(), NULL);
}
add_action('init', 'strnix_google_font');
/**
* is_blog compatibility.
*/
function is_blog() {
if ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) {
return true;
} else {
return false;
}
}
/**
* excerpt_length compatibility.
*/
function custom_excerpt_length( $length ) {
return 9;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
function get_elementor_library() {
$pageslist = get_posts(array(
'post_type' => 'elementor_library',
'posts_per_page' => -1
));
$pagearray = array();
if(!empty($pageslist)) {
foreach ($pageslist as $page) {
$pagearray[$page->ID] = $page->post_title;
}
}
return $pagearray;
}
function strnix_add_query_vars_filter($vars) {
$vars[] = "header_type";
return $vars;
}
add_filter('query_vars', 'strnix_add_query_vars_filter');