File: /home/awaldron/_domains/waldroninteractive.com/wp-content/themes/whoiam/functions.php
<?php
/**
*
* @package WordPress
* @subpackage Who I Am
* @since Who I Am 2.0
*
*/
/* Translation */
load_theme_textdomain( 'whoiam', get_template_directory() . '/languages' );
$locale = get_locale();
$wc_posts_perpage = '';
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable($locale_file) )
require_once($locale_file);
/*************************************************
## Post Type
*************************************************/
if (is_admin() ){
function whoiam_admin_scripts(){
wp_register_script('klbmetajs', get_template_directory_uri() .'/assets/theme/js/init.js', array('jquery','media-upload','thickbox'));
wp_enqueue_script('klbmetajs');
}
}
if(!is_admin()) {
add_action('wp_enqueue_scripts', 'whoiam_jq_scripts');
}
function whoiam_jq_scripts(){
wp_deregister_script('jquery');
wp_register_script('jquery', get_template_directory_uri() . '/assets/theme/js/jquery.min.js', false);
wp_enqueue_script('jquery');
}
add_action('admin_enqueue_scripts', 'whoiam_admin_scripts');
add_theme_support( 'post-formats', array('gallery', 'audio', 'video'));
/*************************************************
## Styles and Scripts
*************************************************/
define('WHOIAM_INDEX_JS', get_template_directory_uri() . '/js');
define('WHOIAM_INDEX_CSS', get_template_directory_uri() . '/css');
function whoiam_scripts() {
if ( is_admin_bar_showing() ) {
wp_enqueue_style( 'whoiamadmin', get_template_directory_uri() . '/assets/theme/css/whoiam.css', false, '1.0');
}
if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
wp_enqueue_style( 'pace', get_template_directory_uri() . '/assets/plugins/pace/pace.css', false, '1.0');
wp_enqueue_style( 'boostrap', get_template_directory_uri() . '/assets/plugins/bootstrap-3.3.1/css/bootstrap.min.css', false, '1.0');
wp_enqueue_style( 'font', get_template_directory_uri() . '/assets/plugins/font-awesome-4.2.0/css/font-awesome.min.css', false, '1.0');
wp_enqueue_style( 'type', get_template_directory_uri() . '/assets/plugins/typed/typed.css', false, '1.0');
wp_enqueue_style( 'magnific', get_template_directory_uri() . '/assets/plugins/magnific-popup/magnific-popup.css', false, '1.0');
wp_enqueue_style( 'owlcarousel', get_template_directory_uri() . '/assets/theme/css/style.css', false, '1.0');
wp_enqueue_style( 'flexcss', get_template_directory_uri() . '/assets/flexslider/flexslider.css', false, '1.0');
if( get_option_tree( 'skintype' ) == 'black_version') {
wp_enqueue_style( 'owlcarousel1', get_template_directory_uri() . '/assets/skin-black.css', false, '1.0');
}
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_script( 'jquerymin', get_template_directory_uri() . '/assets/plugins/pace/pace.min.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'jquery', get_template_directory_uri() . '/assets/plugins/jquery.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'boostrap', get_template_directory_uri() . '/assets/plugins/bootstrap-3.3.1/js/bootstrap.min.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'google-map','https://maps.googleapis.com/maps/api/js?key=AIzaSyDdG7gyZmzXbpuDpCrAe0Lk823f8hY8PLs', array('jquery'), '1.0', true);
wp_enqueue_script( 'map', get_template_directory_uri() . '/assets/plugins/jquery.ui.map.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'easing', get_template_directory_uri() . '/assets/plugins/jquery.easing-1.3.pack.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'parallax', get_template_directory_uri() . '/assets/plugins/jquery.parallax-1.1.3.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'magnific', get_template_directory_uri() . '/assets/plugins/magnific-popup/jquery.magnific-popup.min.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'type', get_template_directory_uri() . '/assets/plugins/typed/typed.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'piechart', get_template_directory_uri() . '/assets/plugins/easypiechart/jquery.easypiechart.min.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'theme', get_template_directory_uri() . '/assets/theme/js/theme.js', array('jquery'), '1.0', true);
wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/assets/flexslider/jquery.flexslider.js', array('jquery'), '1.0', true);
}
add_action( 'wp_enqueue_scripts', 'whoiam_scripts' );
/*************************************************
## Google Font
*************************************************/
function whoiam_fonts()
{
$protocol = is_ssl() ? 'https' : 'http';
wp_enqueue_style( 'uccelli-roboto', "$protocol://fonts.googleapis.com/css?family=Open+Sans:400italic,400,700, 800" );
}
add_action( 'wp_enqueue_scripts', 'whoiam_fonts' );
/*************************************************
## Theme option
*************************************************/
require('includes/metaboxes.php');
require('includes/metaboxes/meta-box.php');
require('includes/portfolio-post-type.php');
require('includes/whoiamshortcodes/whoiam/whoiam-shortcodes.php');
require('includes/whoiamshortcodes/shortcodes.php');
add_filter( 'ot_show_pages', '__return_false' );
add_filter( 'ot_show_new_layout', '__return_false' );
add_filter( 'ot_theme_mode', '__return_true' );
include_once( 'option-tree/ot-loader.php' );
include_once( 'option-tree/theme-options.php' );
/*************************************************
## Theme Title Option
*************************************************/
function whoiam_wp_title( $title, $sep ) {
global $page, $paged;
if ( is_feed() )
return $title;
// Add the blog name
$title .= get_bloginfo( 'name' );
// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title .= " $sep $site_description";
// Add a page number if necessary:
if ( $paged >= 2 || $page >= 2 )
$title .= " $sep " . sprintf( __( 'Page %s', 'whoiam' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'whoiam_wp_title', 10, 2 );
/*************************************************
## Register Menu
*************************************************/
function register_menus() {
register_nav_menus( array( 'main-menu' => 'Primary Navigation Menu') );
}
add_action('init', 'register_menus');
class description_walker extends Walker_Nav_Menu
{
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( $icon_class != '' ) {
$icon_classes = '';
}
else{
$icon_classes = '';
}
if($object->object == 'page')
{
$varpost = get_post($object->object_id);
$separate_page = get_post_meta($object->object_id, "rnr_separate_page", true);
$disable_menu = get_post_meta($object->object_id, "rnr_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>';
if ( $separate_page == true )
$attributes .= ! empty( $object->url ) ? ' href="' . esc_attr( $object->url ) .'"' : '';
else{
if (is_front_page())
$attributes .= ' href="#' . $varpost->post_name . '"';
else
$attributes .= ' href="' . ''.home_url().'/#' . $varpost->post_name . '"';
}
$object_output = $args->before;
$object_output .= '<a'. $attributes .' class="link-inpage">';
$object_output .= $args->link_before . $icon_classes . 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>';
$attributes .= ! empty( $object->url ) ? ' href="' . esc_attr( $object->url ) .'"' : '';
$object_output = $args->before;
$object_output .= '<a'. $attributes .' class="link-inpage">';
$object_output .= $args->link_before . $icon_classes . apply_filters( 'the_title', $object->title, $object->ID ) . '</span>';
$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 );
}
}
}
/*************************************************
## Theme Setup
*************************************************/
if ( ! isset( $content_width ) ) $content_width = 960;
function whoiam_theme_setup() {
add_editor_style();
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
}
add_action( 'after_setup_theme', 'whoiam_theme_setup' );
/*************************************************
## Word Limiter
*************************************************/
function whoiam_limit_words($string, $limit) {
$words = explode(' ', $string);
return implode(' ', array_slice($words, 0, $limit));
}
/*************************************************
## Excerpt More
*************************************************/
function whoiam_excerpt_more($more) {
global $post;
return '…<div class="text-left"><a href="'. get_permalink($post->ID) . '" class="btn btn-xs btn-flat-solid primary-btn">' . '' . __('Read More', 'whoiam') . '</a></div>';
}
add_filter('excerpt_more', 'whoiam_excerpt_more');
/*************************************************
## Pagination Function
*************************************************/
function whoiam_pagination($pages = '', $range = 4) {
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '') {
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages) {
$pages = 1;
}
}
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<li><a class'button button-small' href='".get_pagenum_link(1)."'>« " . __('First', 'whoiam') . "</a></li>";
if($paged > 1 && $showitems < $pages) echo "<li><a class=\"active\" href='".get_pagenum_link($paged - 1)."'>‹ " . __('Previous', 'whoiam') . "</a></li>";
for ($i=1; $i <= $pages; $i++) {
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
echo ($paged == $i)? "<li ><a class=\"active\">".$i."</a></li>":"<li><a href='".get_pagenum_link($i)."' >".$i."</a></li>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<a class=\"active\" href=\"".get_pagenum_link($paged + 1)."\">" . __('Next', 'whoiam') . " ›</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<li><a class=\"active\" href='".get_pagenum_link($pages)."'>" . __('Last', 'whoiam') . " »</a></li>";
}
/*************************************************
## Widgets
*************************************************/
function whoiam_widgets_init() {
register_sidebar( array(
'name' => __( 'Blog Sidebar', 'whoiam' ),
'id' => 'sidebar-1',
'description' => __( 'These are widgets for the Blog page.','whoiam' ),
'before_widget' => '<div class="box-widget">',
'after_widget' => '</div>',
'before_title' => '<h5 class="color-dark text-bold text-uppercase">',
'after_title' => '</h5>'
) );
}
add_action( 'widgets_init', 'whoiam_widgets_init' );
/*************************************************
## Include the TGM_Plugin_Activation class.
*************************************************/
require_once dirname( __FILE__ ) . '/includes/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'whoiam_register_required_plugins' );
/**
* Register the required plugins for this theme.
*
* In this example, we register two plugins - one included with the TGMPA library
* and one from the .org repo.
*
* The variable passed to tgmpa_register_plugins() should be an array of plugin
* arrays.
*
* This function is hooked into tgmpa_init, which is fired within the
* TGM_Plugin_Activation class constructor.
*/
function whoiam_register_required_plugins() {
/**
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
// This is an example of how to include a plugin pre-packaged with a theme.
array(
'name' => 'Envato WordPress Toolkit',
'slug' => 'envato-wordpress-toolkit-master',
'source' => get_template_directory() . '/plugins/envato-wordpress-toolkit-master.zip',
'required' => true,
'version' => '1.7.1',
'force_activation' => true,
'force_deactivation' => false,
'external_url' => '',
),
array(
'name' => 'Contact Form 7',
'slug' => 'contact-form-7',
'source' => get_template_directory() . '/plugins/contact-form-7.4.0.2.zip',
'required' => false,
'version' => '4.0.2',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => '',
),
array(
'name' => 'Revolution Slider',
'slug' => 'revslider',
'source' => get_template_directory() . '/plugins/revslider.zip',
'required' => false,
'version' => '4.6.5',
'force_activation' => false,
'force_deactivation' => false,
'external_url' => '',
),
);
/**
* Array of configuration settings. Amend each line as needed.
* If you want the default strings to be available under your own theme domain,
* leave the strings uncommented.
* Some of the strings are added into a sprintf, so see the comments at the
* end of each line for what each argument will be.
*/
$config = array(
'default_path' => '', // Default absolute path to pre-packaged plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'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.
'strings' => array(
'page_title' => __( 'Install Required Plugins', 'tgmpa' ),
'menu_title' => __( 'Install Plugins', 'tgmpa' ),
'installing' => __( 'Installing Plugin: %s', 'tgmpa' ), // %s = plugin name.
'oops' => __( 'Something went wrong with the plugin API.', 'tgmpa' ),
'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s).
'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.' ), // %1$s = plugin name(s).
'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s).
'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s).
'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s).
'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s).
'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s).
'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s).
'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins' ),
'return' => __( 'Return to Required Plugins Installer', 'tgmpa' ),
'plugin_activated' => __( 'Plugin activated successfully.', 'tgmpa' ),
'complete' => __( 'All plugins installed and activated successfully. %s', 'tgmpa' ), // %s = dashboard link.
'nag_type' => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
)
);
tgmpa( $plugins, $config );
}
/*************************************************
## Who I Am Comment
*************************************************/
if ( ! function_exists( 'whoiam_comment' ) ) :
function whoiam_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
?>
<div class="comments">
<article class="post pingback">
<p><?php _e( 'Pingback:', 'whoiam' ); ?> <?php comment_author_link(); ?><?php edit_comment_link( __( '(Edit)', 'whoiam' ), ' ' ); ?></p>
<?php
break;
default :
?>
<ol class="comments">
<li>
<div class="post-comment-block">
<div class="img-thumbnail">
<?php echo get_avatar( $comment, 80 ); ?>
</div>
<?php edit_comment_link( __( '<i class="fa fa-pencil"></i> Edit', 'whoiam' ), ' ' ); ?>
<a href="#" class="comment-author"><?php comment_author(); ?></a>
<i class="fa fa-ccw"></i> <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
<span class="meta-data" style="display:block;"><time class="comment-date" pubdate datetime="<?php comment_time( 'c' ); ?>"><?php comment_date(); ?> at <?php comment_time(); ?></time></span>
<div class="clearfix white-space-10"></div>
<p><?php comment_text(); ?></p>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em><?php _e( 'Your comment is awaiting moderation.', 'whoiam' ); ?></em>
<?php endif; ?>
</div>
<article class="clearfix" id="comment-<?php comment_ID(); ?>">
</li>
</ol>
<?php
break;
endswitch;
}
endif;
/*************************************************
## Who I Am Color Picker
*************************************************/
function whoiam_custom_styling() { ?>
<style type="text/css">
/* Define the base color */
.menu-area .nav-white-bg {
border-bottom: 1px solid <?php echo ot_get_option( 'menuborderbottom_color' ); ?>;
background: <?php echo ot_get_option( 'menu_color' ); ?>;
}
.menu-area.nav-fixed {
background: <?php echo ot_get_option( 'menu_color' ); ?>;
border-bottom: 1px solid <?php echo ot_get_option( 'menuborderbottom_color' ); ?>;
}
.shape-bottom .bg-secondary {
background-color: <?php echo ot_get_option( 'titlebackground_color' ); ?>;
}
.block-section {
background: <?php echo ot_get_option( 'background_color' ); ?>;
}
.main-footer {
background: <?php echo ot_get_option( 'footer_color' ); ?>;
}
.color-dark {
color: <?php echo ot_get_option( 'title_color' ); ?>;
}
<?php $tipigrof = ot_get_option( 'tipigrof', array() ); ?>
body
{
color:<?php if($tipigrof['font-color']){echo $tipigrof['font-color'] ; }else{ echo '';} ?>;
font-family:<?php if($tipigrof['font-family']){echo $tipigrof['font-family'] ; }else{ echo '';} ?>;
font-size:<?php if($tipigrof['font-size']){echo $tipigrof['font-size'] ; }else{ echo '';} ?>;
font-style:<?php if($tipigrof['font-style']){echo $tipigrof['font-style'] ; }else{ echo '';} ?>;
font-variant:<?php if($tipigrof['font-variant']){echo $tipigrof['font-variant'] ; }else{ echo '';} ?> ;
font-weight:<?php if($tipigrof['font-weight']){echo $tipigrof['font-weight'] ; }else{ echo '';} ?> ;
letter-spacing:<?php if($tipigrof['letter-spacing']){echo $tipigrof['letter-spacing'] ; }else{ echo '';} ?> ;
line-height:<?php if($tipigrof['line-height']){echo $tipigrof['line-height'] ; }else{ echo '';} ?> ;
text-decoration:<?php if($tipigrof['text-decoration']){echo $tipigrof['text-decoration'] ; }else{ echo '';} ?> ;
text-transform:<?php if($tipigrof['text-transform']){echo $tipigrof['text-transform'] ; }else{ echo '';} ?> ;
}
</style>
<?php }
add_action('wp_head','whoiam_custom_styling');