'Grid Masonry',
'small' => 'Small Left Thumbnail',
'standard' => 'Standard',
);
$kleo_config['blog_meta_elements'] = array(
'avatar' => 'Author Avatar',
'date' => 'Date',
'archive' => 'Archive Link',
'profile' => 'Profile Icon',
'author_link' => 'Profile Link',
'message' => 'Message Link',
'categories' => 'Categories',
'tags' => 'Tags',
'comments' => 'Comments',
);
$kleo_config['blog_meta_defaults'] = array( 'author_link', 'date', 'categories', 'tags', 'comments' );
//define dynamic styles path
$upload_dir = wp_upload_dir();
if ( is_ssl() ) {
if ( strpos( $upload_dir['baseurl'], 'https://' ) === false ) {
$upload_dir['baseurl'] = str_ireplace( 'http', 'https', $upload_dir['baseurl'] );
}
}
$kleo_config['upload_basedir'] = $upload_dir['basedir'];
$kleo_config['custom_style_path'] = $upload_dir['basedir'] . '/custom_styles';
$kleo_config['custom_style_url'] = $upload_dir['baseurl'] . '/custom_styles';
$kleo_config['image_overlay'] = '+';
//define site style sets
$kleo_config['style_sets'] = array( 'header', 'main', 'alternate', 'side', 'footer', 'socket' );
$kleo_config['font_sections'] = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'body', 'header' );
//physical file template mapping
$kleo_config['tpl_map'] = array(
'page-templates/left-sidebar.php' => 'left',
'page-templates/right-sidebar.php' => 'right',
'page-templates/full-width.php' => 'no',
'page-templates/left-right-sidebars.php' => '3lr',
'page-templates/left-two-sidebars.php' => '3ll',
'page-templates/right-two-sidebars.php' => '3rr',
);
/***************************************************
* :: Framework initialization with required plugins
***************************************************/
//instance of our theme framework
global $kleo_theme;
/**
* @return Kleo
*/
function sq_kleo() {
return Kleo::instance();
}
$kleo_theme = sq_kleo();
if ( is_admin() ) {
require_once KLEO_LIB_DIR . '/required-plugins.php';
}
/***************************************************
* :: Load Theme functions
***************************************************/
add_action( 'after_setup_theme', 'kleo_theme_functions', 12 );
function kleo_theme_functions() {
/* Plugins and functionality */
// BuddyPress compatibility
if ( function_exists( 'bp_is_active' ) ) {
require_once( KLEO_LIB_DIR . '/plugin-buddypress/config.php' ); //compatibility with buddypress plugin
}
// bbPress compatibility
if ( class_exists( 'bbPress' ) ) {
require_once( KLEO_LIB_DIR . '/plugin-bbpress/config.php' ); //compatibility with bbpress plugin
}
/* Woocommerce compatibility */
if ( class_exists( 'WooCommerce' ) ) {
require_once( KLEO_LIB_DIR . '/plugin-woocommerce/config.php' );
}
// Paid memberships Pro compatibility
if ( function_exists( 'pmpro_url' ) ) {
require_once( KLEO_LIB_DIR . '/plugin-pmpro/config.php' );
}
// Visual composer compatibility
if ( function_exists( 'vc_set_as_theme' ) ) {
require_once( KLEO_LIB_DIR . '/plugin-vc/config.php' );
}
// Compatibility with GeoDirectory plugin
if ( defined( 'GEODIRECTORY_VERSION' ) ) {
require_once( KLEO_LIB_DIR . '/plugin-geodirectory/config.php' );
}
// Compatibility with Sensei plugin
if ( class_exists( 'WooThemes_Sensei' ) ) {
require_once( KLEO_LIB_DIR . '/plugin-sensei/config.php' );
}
// Compatibility Bp Profile Search
if ( defined( 'BPS_VERSION' ) ) {
require_once( KLEO_LIB_DIR . '/plugin-bp-profile-search/config.php' );
}
// Posts likes
if ( sq_option( 'likes_status', 1 ) == 1 ) {
require_once( KLEO_LIB_DIR . '/item-likes.php' );
}
// Resize on the fly
require_once( KLEO_LIB_DIR . '/aq_resizer.php' );
// menu-items-visibility-control plugin compatibility
if ( class_exists( 'Boom_Walker_Nav_Menu_Edit' ) ) {
require_once( KLEO_LIB_DIR . '/plugin-menu-items-visibility-control/config.php' );
}
/* Custom menu */
require_if_theme_supports( 'kleo-mega-menu', KLEO_LIB_DIR . '/menu-custom.php' );
/* Custom menu items */
require_if_theme_supports( 'kleo-menu-items', KLEO_LIB_DIR . '/menu-items.php' );
/* Portfolio module */
if ( sq_option( 'module_portfolio', 1 ) == 1 ) {
require KLEO_LIB_DIR . '/portfolio.php';
}
/* Include admin customizations */
if ( is_admin() ) {
//Metaboxes
require_once( KLEO_LIB_DIR . '/metaboxes.php' );
}
if ( is_admin() || is_customize_preview() ) {
require_once( KLEO_LIB_DIR . '/options.php' );
}
//Modules
require_once( KLEO_LIB_DIR . '/modules.php' );
}
/***************************************************
* :: Theme panel
***************************************************/
if ( is_admin() ) {
require_once( KLEO_LIB_DIR . '/theme-panel/init.php' );
}
/***************************************************
* :: 1 Click Install
***************************************************/
if ( is_admin() ) {
require_once( KLEO_LIB_DIR . '/importer/import.php' );
}
/***************************************************
* :: Load post types class
***************************************************/
require_once KLEO_LIB_DIR . '/post-types.php';
/* Testimonials module */
if ( sq_option( 'module_testimonials', 1 ) == 1 ) {
require KLEO_LIB_DIR . '/testimonials.php';
}
/* Clients module */
if ( sq_option( 'module_clients', 1 ) == 1 ) {
require KLEO_LIB_DIR . '/clients.php';
}
/***************************************************
* :: Theme options
***************************************************/
if ( is_admin() || is_customize_preview() ) {
//Options panel
if ( ! class_exists( 'ReduxFramework' ) && file_exists( KLEO_DIR . '/options/framework.php' ) ) {
require_once( KLEO_DIR . '/options/framework.php' );
}
}
/***************************************************
* :: Modules Class
***************************************************/
if ( sq_option( 'performance', 0 ) == 1 ) {
require_once( KLEO_DIR . '/modules.php' );
}
/***************************************************
* :: Include widgets
***************************************************/
$kleo_widgets = array(
'recent_posts.php'
);
$kleo_widgets = apply_filters( 'kleo_widgets', $kleo_widgets );
foreach ( $kleo_widgets as $widget ) {
$file_path = trailingslashit( KLEO_LIB_DIR ) . 'widgets/' . $widget;
if ( file_exists( $file_path ) ) {
require_once( $file_path );
}
}
if ( ! function_exists( 'kleo_title_section' ) ) {
/**
* Return the breadcrumb area
* @global object $wp_query
*
* @param array $args
*
* @return string
*/
function kleo_title_section( $args = false ) {
$defaults = array(
'title' => get_the_title(),
'show_title' => true,
'show_breadcrumb' => true,
'link' => '',
'output' => "",
'class' => 'container-wrap main-title alternate-color ',
'extra' => '
' . do_shortcode( sq_option( 'title_info', '' ) ) . '
',
'heading' => 'h1'
);
// Parse incoming $args into an array and merge it with $defaults
$args = wp_parse_args( $args, $defaults );
$args = apply_filters( 'kleo_title_args', $args );
// OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before.
extract( $args, EXTR_SKIP );
if ( ! empty( $link ) ) {
$title = "" . $title . "";
}
$breadcrumb_data = '';
if ( $show_breadcrumb ) {
$breadcrumb_data = kleo_breadcrumb( array(
'show_browse' => false,
'separator' => ' ',
'show_home' => __( 'Home', 'kleo_framework' ),
'echo' => false
) );
}
$title_data = '';
if ( $show_title ) {
$title_data = '<{heading} class="page-title">{title}{heading}>';
}
if ( ! $show_breadcrumb && $extra == '' ) {
$class .= ' title-single';
}
$title_layout = sq_option( 'title_layout', 'normal' );
if ( is_singular() && get_cfield( 'title_layout' ) && get_cfield( 'title_layout' ) != '' ) {
$title_layout = get_cfield( 'title_layout' );
}
if ( $title_layout == 'center' ) {
$class .= ' main-center-title';
} elseif ( $title_layout == 'right_breadcrumb' ) {
$class .= ' main-right-breadcrumb';
}
$output = str_replace( '{title_data}', $title_data, $output );
$output = str_replace( '{class}', $class, $output );
$output = str_replace( '{title}', $title, $output );
$output = str_replace( '{breadcrumb_data}', $breadcrumb_data, $output );
$output = str_replace( '{extra}', $extra, $output );
$output = str_replace( '{heading}', $heading, $output );
return $output;
}
}
/**
* Prepare the title/breadcrumb area using hide/show site options
*
* @param integer $post_id
*
* @return array
*/
function kleo_prepare_title( $post_id = null ) {
$title_arr = array();
$title_arr['title'] = kleo_title();
//hide title?
$title_arr['show_title'] = true;
if ( get_cfield( 'title_checkbox', $post_id ) == 1 ) {
$title_arr['show_title'] = false;
}
if ( sq_option( 'title_location', 'breadcrumb' ) == 'main' ) {
$title_arr['show_title'] = false;
}
//hide breadcrumb?
$title_arr['show_breadcrumb'] = true;
if ( sq_option( 'breadcrumb_status', 1 ) == 0 ) {
$title_arr['show_breadcrumb'] = false;
}
if ( get_cfield( 'hide_breadcrumb', $post_id ) == 1 ) {
$title_arr['show_breadcrumb'] = false;
} else if ( get_cfield( 'hide_breadcrumb', $post_id ) === '0' ) {
$title_arr['show_breadcrumb'] = true;
}
//hide extra info?
if ( get_cfield( 'hide_info', $post_id ) == 1 ) {
$title_arr['extra'] = '';
}
return $title_arr;
}
/***************************************************
* TOP TOOLBAR - ADMIN BAR
* Enable or disable the bar, depending of the theme option setting
***************************************************/
if ( sq_option( 'admin_bar', 1 ) == '0' ):
remove_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
add_filter( 'show_admin_bar', '__return_false' );
endif;
/***************************************************
* :: MAINTENANCE MODE
***************************************************/
if ( ! function_exists( 'kleo_maintenance_mode' ) ) {
function kleo_maintenance_mode() {
$logo_path = apply_filters( 'kleo_logo', sq_option_url( 'logo' ) );
$logo_img = '
';
if ( sq_option( 'maintenance_mode', 0 ) == 1 ) {
/* Theme My Login compatibility */
if ( class_exists( 'Theme_My_Login' ) && Theme_My_Login::is_tml_page( 'login' ) ) {
return;
}
if ( ! current_user_can( 'edit_themes' ) || ! is_user_logged_in() ) {
wp_die(
$logo_img
. ''
. sq_option( 'maintenance_msg', '' )
. '
',
get_bloginfo( 'name' )
);
}
}
}
add_action( 'get_header', 'kleo_maintenance_mode' );
}
/***************************************************
* :: Get social profiles
***************************************************/
if ( ! function_exists( 'kleo_get_social_profiles' ) ):
function kleo_get_social_profiles( $args = false ) {
$output = '';
$icons = '';
$all_options = get_option( "kleo_" . KLEO_DOMAIN );
$defaults = array(
'container' => 'ul',
'item_tag' => 'li',
'target' => '_blank'
);
// Parse incomming $args into an array and merge it with $defaults
$args = wp_parse_args( $args, $defaults );
$args = apply_filters( 'kleo_get_social_profiles_args', $args );
//get social data from theme options
if ( ! empty( $all_options ) ) {
foreach ( $all_options as $k => $opt ) {
if ( substr( $k, 0, 7 ) === 'social_' && ! empty( $opt ) ) {
$k = str_replace( 'social_', '', $k );
$title = str_replace(
array( 'gplus', 'vimeo-squared', 'pinterest-circled', 'instagramm' ),
array( 'Google+', 'Vimeo', 'Pinterest', 'Instagram' ),
$k
);
$icons .= '<' . $args['item_tag'] . '>';
$icons .= '' . ucfirst( $title ) . '
';
$icons .= '' . $args['item_tag'] . '>';
}
}
}
$icons = apply_filters( 'kleo_get_social_profiles', $icons );
if ( $icons != '' ) {
$output .= '<' . $args['container'] . ' class="kleo-social-icons">';
$output .= $icons;
$output .= '' . $args['container'] . '>';
}
return $output;
}
add_shortcode( 'kleo_social_icons', 'kleo_get_social_profiles' );
endif;
/***************************************************
* :: Ajax search in header main menu
***************************************************/
//if set from admin to show search
if ( sq_option( 'ajax_search', 1 ) == 1 || sq_option( 'ajax_search', 1 ) == 'logged_in' ) {
add_filter( 'wp_nav_menu_items', 'kleo_search_menu_item', 200, 2 );
}
if ( ! function_exists( 'kleo_search_menu_item' ) ) {
/**
* Add search to menu
*
* @param string $items
* @param object $args
*
* @return string
*/
function kleo_search_menu_item( $items, $args ) {
if ( sq_option( 'ajax_search', 1 ) == 'logged_in' && ! is_user_logged_in() ) {
return $items;
}
$location = sq_option( 'menu_search_location', 'primary' );
if ( $args->theme_location == $location ) {
$form = kleo_get_search_menu_item();
$items .= '';
}
return $items;
}
}
/* Custom search form */
if ( sq_option( 'header_custom_search', 0 ) == 1 && sq_option( 'header_search_form', '' ) != '' ) {
add_filter( 'body_class', 'kleo_gsb_body_class' );
if ( ! function_exists( 'kleo_get_search_menu_item' ) ) {
function kleo_get_search_menu_item() {
$output = '';
$output .= '';
$output .= '';
$output .= '
';
$output .= sq_option( 'header_search_form', '' );
$output .= '
';
return $output;
}
}
}
function kleo_gsb_body_class( $classes ) {
$classes[] = 'has-google-search-box';
return $classes;
}
if ( ! function_exists( 'kleo_get_search_menu_item' ) ) {
function kleo_get_search_menu_item() {
$context = sq_option( 'search_context', '' );
if ( is_array( $context ) ) {
$context = implode( ',', $context );
}
//Defaults
$action = home_url( '/' );
$hidden = '';
$input_name = 's';
if ( function_exists( 'bp_is_active' ) && $context == 'members' ) {
//Buddypress members form link
$action = bp_get_members_directory_permalink();
} elseif ( function_exists( 'bp_is_active' ) && bp_is_active( 'groups' ) && $context == 'groups' ) {
//Buddypress group directory link
$action = bp_get_groups_directory_permalink();
} elseif ( class_exists( 'bbPress' ) && $context == 'forum' ) {
$action = bbp_get_search_url();
$input_name = 'bbp_search';
} elseif ( $context == 'product' ) {
$hidden .= '';
$action = home_url( '/' ) . '?post_type=product';
}
ob_start();
$value = isset( $_REQUEST['s'] ) ? esc_attr( $_REQUEST['s'] ) : '';
$placeholder = esc_html__( "Start typing to search...", "kleo_framework" );
?>
4,
'posts_per_page' => 20,
'post_type' => 'any',
'post_status' => array('publish','inherit'),
'post_password' => '',
'suppress_filters' => false,
's' => $_REQUEST['s'],
);
if ( isset( $_REQUEST['context'] ) && '' != $_REQUEST['context'] ) {
$context = explode( ',', $_REQUEST['context'] );
$defaults['post_type'] = $context;
}
//Remove forum since it is handled with a different function
if ( ! empty( $defaults['post_type'] ) && is_array( $defaults['post_type'] ) ) {
foreach ( $defaults['post_type'] as $ptk => $ptv ) {
if ( 'forum' == $ptv ) {
unset( $defaults['post_type'][ $ptk ] );
break;
}
}
}
if ( empty( $defaults['post_type'] ) ) {
$posts = null;
} else {
$defaults = apply_filters( 'kleo_ajax_query_args', $defaults );
$the_query = new WP_Query( $defaults );
$posts = $the_query->get_posts();
}
$members = array();
$members['total'] = 0;
$groups = array();
$groups['total'] = 0;
$forums = false;
if ( function_exists( 'bp_is_active' ) && ( $context == "any" || in_array( "members", $context ) ) ) {
$members = bp_core_get_users( array(
'search_terms' => $search_string,
'per_page' => $defaults['numberposts'],
'populate_extras' => false,
) );
}
if ( function_exists( 'bp_is_active' ) && bp_is_active( "groups" ) && ( $context == "any" || in_array( "groups", $context ) ) ) {
$groups = groups_get_groups( array(
'search_terms' => $search_string,
'per_page' => $defaults['numberposts'],
'populate_extras' => false,
) );
}
if ( class_exists( 'bbPress' ) && ( $context == "any" || in_array( "forum", $context ) ) ) {
$forums = kleo_bbp_get_replies( $search_string );
}
//if there are no posts, groups nor members
if ( empty( $posts ) && $members['total'] == 0 && $groups['total'] == 0 && ! $forums ) {
$output = "";
$output .= "
";
$output .= " ";
$output .= __( "Sorry, we haven't found anything based on your criteria.", 'kleo_framework' );
$output .= "
";
$output .= __( "Please try searching by different terms.", 'kleo_framework' );
$output .= "
";
$output .= "
";
echo $output;
die();
}
//if there are members
if ( $members['total'] != 0 ) {
$output .= '';
$output .= '
' . __( "Members", 'kleo_framework' ) . '
';
foreach ( (array) $members['users'] as $member ) {
$image = '
 ) . ')
';
if ( $update = bp_get_user_meta( $member->ID, 'bp_latest_update', true ) ) {
$latest_activity = char_trim( trim( strip_tags( bp_create_excerpt( $update['content'], 50, "..." ) ) ) );
} else {
$latest_activity = '';
}
$output .= "
";
$output .= "
$image
";
$output .= "
";
$output .= "
";
$output .= $member->display_name;
$output .= "";
$output .= "
";
$output .= $latest_activity;
$output .= "";
$output .= "
";
$output .= "
";
}
$output .= "
" . __( 'View member results', 'kleo_framework' ) . "";
$output .= "
";
}
//if there are groups
if ( $groups['total'] != 0 ) {
$output .= '';
$output .= '
' . __( "Groups", 'kleo_framework' ) . '
';
foreach ( (array) $groups['groups'] as $group ) {
$image = '
 ) . ')
';
$output .= "
";
$output .= "
$image
";
$output .= "
";
$output .= "
";
}
$output .= "
" . __( 'View group results', 'kleo_framework' ) . "";
$output .= "
";
}
//if there are posts
if ( ! empty( $posts ) ) {
$post_type_str = array();
$post_types = array();
$post_type_obj = array();
foreach ( $posts as $post ) {
$post_types[ $post->post_type ][] = $post;
if ( empty( $post_type_obj[ $post->post_type ] ) ) {
$post_type_obj[ $post->post_type ] = get_post_type_object( $post->post_type );
}
}
foreach ( $post_types as $ptype => $post_type ) {
$output .= '';
if ( isset( $post_type_obj[ $ptype ]->labels->name ) ) {
$output .= "
" . $post_type_obj[ $ptype ]->labels->name . "
";
} else {
$output .= "
";
}
$count = 0;
foreach ( $post_type as $post ) {
$post_type_str[$post->post_type] = $post->post_type;
$count ++;
if ( $count > 4 ) {
continue;
}
$format = get_post_format( $post->ID );
if( $post->post_type == 'attachment') {
$img_url = wp_get_attachment_thumb_url( $post->ID );
$image = '
.')
';
} else {
if ($img_url = kleo_get_post_thumbnail_url($post->ID)) {
$image = aq_resize($img_url, 44, 44, true, true, true);
if (!$image) {
$image = $img_url;
}
$image = '

';
} else {
if ($format == 'video') {
$image = "
";
} elseif ($format == 'image' || $format == 'gallery') {
$image = "
";
} else {
$image = "
";
}
}
}
$excerpt = "";
if ( ! empty( $post->post_content ) ) {
$excerpt = $post->post_content;
$excerpt = preg_replace( "/\[(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?/s", '', $excerpt );
$excerpt = wp_strip_all_tags($excerpt); //added to remove gogole adsense code from search excerpt
$excerpt = char_trim( trim( strip_tags( $excerpt ) ), 40, "..." );
}
$link = apply_filters( 'kleo_custom_url', get_permalink( $post->ID ) );
$classes = "format-" . $format;
$output .= "
";
$output .= "
$image
";
$output .= "
";
$output .= "
";
$output .= get_the_title( $post->ID );
$output .= "";
$output .= "
";
$output .= $excerpt;
$output .= "";
$output .= "
";
$output .= "
";
}
$output .= '
';
}
if ( ! empty( $post_type_str ) ) {
if ( count( $post_type_str ) > 1 ) {
$search_str_posts = '&post_type[]=' . implode( ',', $post_type_str );
} else {
$search_str_posts = '&post_type=' . implode( ',', $post_type_str );
}
} else {
$search_str_posts = '';
}
$output .= "" . __( 'View all results', 'kleo_framework' ) . "";
}
/* Forums topics search */
if ( ! empty( $forums ) ) {
$output .= '";
}
echo $output;
die();
}
}
if ( ! function_exists( 'kleo_bbp_get_replies' ) ) {
function kleo_bbp_get_replies( $title = '' ) {
global $wpdb;
$topic_matches = array();
/* First do a title search */
$topics = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->posts . ' WHERE post_title LIKE "%' . esc_sql( trim( $title ) ) . '%" AND post_type="topic" AND post_status="publish"' );
/* do a tag search if title search doesn't have results */
if ( ! $topics ) {
$topic_tags = get_terms( 'topic-tag' );
if ( empty( $topic_tags ) ) {
return $topic_matches;
}
foreach ( $topic_tags as $tid => $tag ) {
$tags[ $tag->term_id ] = $tag->name;
}
$tag_matches = kleo_bbp_stristr_array( $title, $tags );
$args = array(
'post_type' => 'topic',
'showposts' => - 1,
'tax_query' => array(
array(
'taxonomy' => 'topic-tag',
'field' => 'term_id',
'terms' => $tag_matches
)
)
);
$topics = get_posts( $args );
}
/* Compile results into array*/
foreach ( $topics as $topic ) {
$topic_matches[ $topic->ID ]['name'] = $topic->post_title;
$topic_matches[ $topic->ID ]['url'] = get_post_permalink( $topic->ID );
}
return $topic_matches;
}
}
function kleo_bbp_stristr_array( $haystack, $needles ) {
$elements = array();
foreach ( $needles as $id => $needle ) {
if ( stristr( $haystack, $needle ) ) {
$elements[] = $id;
}
}
return $elements;
}
/***************************************************
* :: WPML language switch
***************************************************/
if ( ! function_exists( 'kleo_wpml_wp_nav_menu_items_filter' ) && function_exists( 'icl_get_languages' ) ) {
function kleo_wpml_wp_nav_menu_items_filter( $items, $args ) {
if ( $args->theme_location == 'primary' ) {
$items = str_replace( '', '', $items );
$items = str_replace( '