File: /home/awaldron/_domains/waldroninteractive.com/wp-content/themes/minione/functions.php
<?php
/**
* functions.php
* @package WordPress
* @subpackage Minione
* @since Minione 1.6.9
*
*/
/*************************************************
## Admin style and scripts
*************************************************/
function minione_admin_styles() {
wp_enqueue_style('minione-klbtheme', get_template_directory_uri().'/assets/css/admin/klbtheme.css');
wp_enqueue_style('minione-elegant-style', get_template_directory_uri() . '/assets/icons/elegant/style.css', false, '1.0');
wp_enqueue_style('minione-linea-styles', get_template_directory_uri() . '/assets/icons/linea/styles.css', false, '1.0');
wp_enqueue_script('minione-init', get_template_directory_uri() .'/assets/js/init.js', array('jquery','media-upload','thickbox'));
}
add_action('admin_enqueue_scripts', 'minione_admin_styles');
/*************************************************
## MiniOne Fonts
*************************************************/
function minione_fonts_url_poppins() {
$fonts_url = '';
$poppins = _x( 'on', 'Poppins: on or off', 'minione' );
if ( 'off' !== $poppins ) {
$font_families = array();
if ( 'off' !== $poppins ) {
$font_families[] = 'Poppins:400,300,500,600,700';
}
$query_args = array(
'family' => rawurldecode( implode( '|', $font_families ) ),
'subset' => rawurldecode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
}
return esc_url_raw( $fonts_url );
}
function minione_fonts_url_lora() {
$fonts_url = '';
$lora = _x( 'on', 'Lora: on or off', 'minione' );
if ( 'off' !== $lora ) {
$font_families = array();
if ( 'off' !== $lora ) {
$font_families[] = 'Lora:400,400italic,700,700italic';
}
$query_args = array(
'family' => rawurldecode( implode( '|', $font_families ) ),
'subset' => rawurldecode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
}
return esc_url_raw( $fonts_url );
}
/*************************************************
## Mini Styles and Scripts
*************************************************/
function minione_scripts() {
if ( is_admin_bar_showing() ) {
wp_enqueue_style( 'minione-klbtheme', get_template_directory_uri() . '/assets/css/admin/klbtheme.css', false, '1.0');
}
if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css', false, '1.0');
wp_enqueue_style( 'animate', get_template_directory_uri() . '/assets/css/animate.css', false, '1.0');
wp_enqueue_style( 'magnific-popup', get_template_directory_uri() . '/assets/css/magnific-popup.css', false, '1.0');
wp_enqueue_style( 'minione-blog-style', get_template_directory_uri() . '/assets/css/blog-style.css', false, '1.0');
wp_enqueue_style( 'minione-linea-styles', get_template_directory_uri() . '/assets/icons/linea/styles.css', false, '1.0');
wp_enqueue_style( 'minione-elegant-style', get_template_directory_uri() . '/assets/icons/elegant/style.css', false, '1.0');
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/assets/icons/fontawesome/font-awesome.min.css', false, '1.0');
wp_enqueue_style( 'minione-custom', get_template_directory_uri() . '/assets/css/custom.css', false, '1.0');
wp_register_style( 'minione-linea-styles', get_template_directory_uri() . '/assets/icons/linea/styles.css', false, '1.0');
wp_register_style( 'minione-elegant-style', get_template_directory_uri() . '/assets/icons/elegant/style.css', false, '1.0');
wp_enqueue_style( 'minione-font-poppins', minione_fonts_url_poppins(), array(), null );
wp_enqueue_style( 'minione-font-lora', minione_fonts_url_lora(), array(), null );
wp_enqueue_style( 'minione-style', get_stylesheet_uri() );
$mapkey = ot_get_option('minione_mapapi');
wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/assets/js/modernizr.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'bootsrap', get_template_directory_uri() . '/assets/js/bootstrap.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'modernizr-custom', get_template_directory_uri() . '/assets/js/modernizr.custom.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'minione-menu-top', get_template_directory_uri() . '/assets/js/menu-top.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'classie', get_template_directory_uri() . '/assets/js/classie.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'jquery-easing', get_template_directory_uri() . '/assets/js/jquery.easing.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'jquery-magnific-popup', get_template_directory_uri() . '/assets/js/jquery.magnific-popup.min.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'minione-googlemap', 'https://maps.googleapis.com/maps/api/js?key='.$mapkey.'', array('jquery'), '1.0', true);
wp_enqueue_script( 'wow', get_template_directory_uri() . '/assets/js/wow.min.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'jquery-parallax', get_template_directory_uri() . '/assets/js/jquery-parallax.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'minione-scripts', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), '1.0', true);
wp_register_script( 'isotope-pkgd', get_template_directory_uri() . '/assets/js/isotope.pkgd.min.js', array('jquery'), '1.0', true);
wp_register_script( 'isotope-jquery', get_template_directory_uri() . '/assets/js/isotope-jquery.js', array('jquery'), '1.0', true);
wp_register_script( 'minione-custom-isotope', get_template_directory_uri() . '/assets/js/custom/custom-isotope.js', array('jquery'), '1.0', true);
}
add_action( 'wp_enqueue_scripts', 'minione_scripts' );
/*************************************************
## Mini Theme Setup
*************************************************/
if ( ! isset( $content_width ) ) $content_width = 960;
function minione_theme_setup() {
add_theme_support( 'title-tag' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'post-formats', array('gallery', 'audio', 'video'));
load_theme_textdomain( 'minione', get_template_directory() . '/languages' );
remove_theme_support( 'widgets-block-editor' );
}
add_action( 'after_setup_theme', 'minione_theme_setup' );
/*************************************************
## Excerpt More
*************************************************/
function minione_excerpt_more($more) {
global $post;
return '<div class="text-center"><a class="btnread" href="'. esc_url(get_permalink($post->ID)) . '" >' . '' . esc_html__('READ MORE', 'minione') . '</a></div>';
}
add_filter('excerpt_more', 'minione_excerpt_more');
/*************************************************
## Widgets
*************************************************/
function minione_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Blog Sidebar', 'minione' ),
'id' => 'blog-sidebar',
'description' => esc_html__( 'These are widgets for the Blog page.','minione' ),
'before_widget' => '<div class="blog-item">',
'after_widget' => '</div>',
'before_title' => '<h1>',
'after_title' => '</h1>'
) );
}
add_action( 'widgets_init', 'minione_widgets_init' );
/*************************************************
## Mini Register Menu
*************************************************/
function minione_register_menus() {
register_nav_menus( array( 'main-menu' => esc_html__('Primary Navigation Menu','minione')) );
}
add_action('init', 'minione_register_menus');
/*************************************************
## Minione Menu
*************************************************/
class minione_description_walker extends Walker_Nav_Menu {
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output )
{
$id_field = $this->db_fields['id'];
if ( is_object( $args[0] ) ) {
$args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
}
return parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
}
function start_el(&$output, $object, $depth = 0, $args = Array() , $current_object_id = 0) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $object->classes ) ? array() : (array) $object->classes;
$icon_class = $classes[0];
$classes = array_slice($classes,1);
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $object ) );
$class_names = ' class="'. esc_attr( $class_names ) . '"';
$attributes = ! empty( $object->attr_title ) ? ' title="' . esc_attr( $object->attr_title ) .'"' : '';
$attributes .= ! empty( $object->target ) ? ' target="' . esc_attr( $object->target ) .'"' : '';
$attributes .= ! empty( $object->xfn ) ? ' rel="' . esc_attr( $object->xfn ) .'"' : '';
if($object->object == 'page')
{
$varpost = get_post($object->object_id);
$separate_page = get_post_meta($object->object_id, "klb_separate_page", true);
$disable_menu = get_post_meta($object->object_id, "klb_disable_section_from_menu", true);
$current_page_id = get_option('page_on_front');
if ( ( $disable_menu != true ) && ( $varpost->ID != $current_page_id ) ) {
$output .= $indent . '<li ' . $value . $class_names .'>';
if ( function_exists( 'klbshortcode' ) ) {
if ( $separate_page == true )
$attributes .= ! empty( $object->url ) ? ' href="' . esc_url( $object->url ) .'" class="external"' : '';
else{
if (is_front_page())
$attributes .= ' href="#' . $varpost->post_name . '" class="internal" ';
else
$attributes .= ' href="' . ''.esc_url( home_url( '/' ) ).'#' . $varpost->post_name . '" class="external" ';
}
} else {
$attributes .= ! empty( $object->url ) ? ' href="' . esc_url( $object->url ) .'" class="external"' : '';
}
$object_output = $args->before;
$object_output .= '<a'. $attributes .' >';
$object_output .= $args->link_before . apply_filters( 'the_title', $object->title, $object->ID ) . '';
$object_output .= $args->link_after;
$object_output .= '</a>';
$object_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $object_output, $object, $depth, $args );
}
}
else{
$output .= $indent . '<li ' . $value . $class_names .'>';
$attributes .= ! empty( $object->url ) ? ' href="' . esc_url( $object->url ) .'"' : '';
$object_output = $args->before;
$object_output .= '<a'. $attributes .'>';
$object_output .= $args->link_before . apply_filters( 'the_title', $object->title, $object->ID ) . '';
$object_output .= $args->link_after;
$object_output .= '</a>';
$object_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $object_output, $object, $depth, $args );
}
}
}
/*************************************************
## Include the TGM_Plugin_Activation class.
*************************************************/
require_once get_template_directory() . '/includes/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'minione_register_required_plugins' );
function minione_register_required_plugins() {
$url = 'http://klbtheme.com/minione/plugins/';
$mainurl = 'http://klbtheme.com/plugins/';
$plugins = array(
array(
'name' => esc_html__('Meta Box','minione'),
'slug' => 'meta-box',
),
array(
'name' => esc_html__('Portfolio Post Type','minione'),
'slug' => 'portfolio-post-type',
),
array(
'name' => esc_html__('Contact Form 7','minione'),
'slug' => 'contact-form-7',
),
array(
'name' => esc_html__('Theme Options','minione'),
'slug' => 'option-tree',
'source' => $url . 'option-tree.zip',
'required' => false,
'version' => '2.6.0',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => '',
),
array(
'name' => esc_html__('WPBakery Page Builder','minione'),
'slug' => 'js-composer',
'source' => $mainurl . 'js-composer.zip',
'required' => false,
'version' => '6.9.0',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => '',
),
array(
'name' => esc_html__('Klb Shortcode','minione'),
'slug' => 'klb-shortcode',
'source' => $url . 'klb-shortcode.zip',
'required' => false,
'version' => '1.2',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => '',
),
array(
'name' => esc_html__('Envato Market Master','minione'),
'slug' => 'envato-market',
'source' => $mainurl . 'envato-market.zip',
'required' => true,
'version' => '2.0.7',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => '',
),
array(
'name' => esc_html__('Revolution Slider','minione'),
'slug' => 'revslider',
'source' => $mainurl . 'revslider.zip',
'required' => false,
'version' => '6.5.25',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => '',
),
);
$config = array(
'id' => 'minione', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'themes.php', // Parent menu slug.
'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
/*************************************************
## Mini Comment
*************************************************/
if ( ! function_exists( 'minione_comment' ) ) :
function minione_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
<article class="post pingback">
<p><?php esc_html_e( 'Pingback:', 'minione' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( esc_html__( '(Edit)', 'minione' ), ' ' ); ?></p>
<?php
break;
default :
?>
<li class="comment-area">
<div class="comment-list-comment">
<div class="comment-list-comment-image">
<img src="<?php echo get_avatar_url( $comment, 80 ); ?>);">
</div>
<div class="comment-right">
<div class="comment-list-header">
<h4><?php comment_author(); ?></h4>
<span><?php comment_date(); ?> <?php esc_html('at','minione'); ?> <?php comment_time(); ?></span>
</div>
<div class="comment-list-comment-text">
<div class="klb-post"><?php comment_text(); ?></div>
</div>
</div>
<span class="media-reply pull-right"><?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?></span>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em><?php esc_html_e( 'Your comment is awaiting moderation.', 'minione' ); ?></em>
<?php endif; ?>
<article class="clearfix" id="comment-<?php comment_ID(); ?>"></article>
</div>
</li>
<?php
break;
endswitch;
}
endif;
/*************************************************
## Mini Comment Placeholder
*************************************************/
add_filter( 'comment_form_default_fields', 'minione_comment_placeholders' );
function minione_comment_placeholders( $fields ){
$fields['author'] = str_replace(
'<input',
'<input placeholder="'.esc_html__('Name','minione').'"',
$fields['author']
);
$fields['email'] = str_replace(
'<input',
'<input placeholder="'.esc_html__('Email','minione').'"',
$fields['email']
);
$fields['url'] = str_replace(
'<input',
'<input placeholder="'.esc_html__('Website','minione').'"',
$fields['url']
);
return $fields;
}
add_filter( 'comment_form_defaults', 'minione_textarea_placeholder' );
function minione_textarea_placeholder( $fields ){
$fields['comment_field'] = str_replace(
'<textarea',
'<textarea placeholder="'.esc_html__('Comment','minione').'"',
$fields['comment_field']
);
return $fields;
}
/*************************************************
## Pingback url auto-discovery header for single posts, pages, or attachments
*************************************************/
function minione_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
}
}
add_action( 'wp_head', 'minione_pingback_header' );
/*************************************************
## Mini Theme options
*************************************************/
require_once get_template_directory() . '/includes/metaboxes.php';
require_once get_template_directory() . '/includes/merlin/setup-wizard.php';
require_once get_template_directory() . '/includes/sanitize.php';
add_filter( 'ot_show_pages', '__return_false' );
add_filter( 'ot_show_new_layout', '__return_false' );
require_once get_template_directory() . '/includes/theme-options.php';
if(function_exists('vc_set_as_theme')) {
require_once get_template_directory() . '/includes/js_composer/shortcodes.php';
require_once get_template_directory() . '/includes/js_composer/klbicon.php';
}