' . cyberchimps_get_option( 'search_post_read_more' ) . '
'; return $more; } else { $more = '' . __( 'Read More...', 'cyberchimps_core' ) . '
'; return $more; } } // excerpt length for search results function cyberchimps_search_excerpt_length( $length ) { global $post; if( cyberchimps_get_option( 'search_post_excerpt_length' ) != '' ) { $length = cyberchimps_get_option( 'search_post_excerpt_length' ); return $length; } else { $length = 55; return $length; } } //For archive posts function cyberchimps_archive_excerpt_more( $more ) { global $post; return '' . cyberchimps_blog_read_more_text() . '
'; } if( cyberchimps_get_option( 'archive_post_excerpts', 0 ) != 0 ) { add_filter( 'excerpt_more', 'cyberchimps_blog_excerpt_more', 999 ); } // Set value for blog read more text option. function cyberchimps_blog_read_more_text() { // Get the value of blog read more text option. $read_more = esc_html(cyberchimps_get_option( 'blog_read_more_text' )); // Check whether any not null value supplied and set the value accordingly. if( '' != $read_more ) { return $read_more; } else { return __( 'Read More...', 'cyberchimps_core' ); } } //For blog posts function cyberchimps_blog_excerpt_more( $more ) { global $post; return '' . cyberchimps_blog_read_more_text() . '
'; } if( cyberchimps_get_option( 'post_excerpts', 0 ) != 0 ) { add_filter( 'excerpt_more', 'cyberchimps_blog_excerpt_more', 10 ); } /** * Set custom post excerpt link if excerpt is supplied manually. */ function manual_excerpt_read_more_link( $output ) { global $post; $linktext = cyberchimps_blog_read_more_text(); if( !empty( $post->post_excerpt ) ) { return $output . ''; } else { return $output; } } add_filter( 'the_excerpt', 'manual_excerpt_read_more_link' ); function cyberchimps_blog_excerpt_length( $length ) { global $post; if( cyberchimps_get_option( 'blog_excerpt_length' ) != '' ) { $length = cyberchimps_get_option( 'blog_excerpt_length' ); return $length; } else { $length = 55; return $length; } } if( cyberchimps_get_option( 'post_excerpts', 0 ) != 0 ) { add_filter( 'excerpt_length', 'cyberchimps_blog_excerpt_length', 999 ); } /* gets post views */ function cyberchimps_getPostViews( $postID ) { $count_key = 'post_views_count'; $count = get_post_meta( $postID, $count_key, true ); if( $count == '' ) { delete_post_meta( $postID, $count_key ); add_post_meta( $postID, $count_key, '0' ); return "0 View"; } return $count . ' Views'; } /* Sets post views */ function cyberchimps_setPostViews( $postID ) { $count_key = 'post_views_count'; $count = get_post_meta( $postID, $count_key, true ); if( $count == '' ) { $count = 0; delete_post_meta( $postID, $count_key ); add_post_meta( $postID, $count_key, '0' ); } else { $count++; update_post_meta( $postID, $count_key, $count ); } } /* To correct issue: adjacent_posts_rel_link_wp_head causes meta to be updated multiple times */ remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); // Set up half slide for iFeature pro slider, adds it before post/page content function cyberchimps_half_slider() { global $post; if( is_page() ) { $page_section_order = get_post_meta( $post->ID, 'cyberchimps_page_section_order', true ); //if page_section_order is empty sets page as default $page_section_order = ( $page_section_order == '' ) ? array( 'page_section' ) : $page_section_order; if( in_array( 'page_slider', $page_section_order, true ) ) { $slider_size = get_post_meta( $post->ID, 'cyberchimps_slider_size', true ); if( $slider_size == 'half' ) { do_action( 'page_slider' ); } } } else { $blog_section_order = cyberchimps_get_option( 'blog_section_order' ); //select default in case options are empty $blog_section_order = ( $blog_section_order == '' ) ? array( 'blog_post_page' ) : $blog_section_order; if( in_array( 'page_slider', $blog_section_order, true ) ) { $slider_size = cyberchimps_get_option( 'blog_slider_size' ); if( $slider_size == 'half' ) { do_action( 'page_slider' ); } } } } // Hook action to after/before content hook depending upon slider order. function cyberchimps_add_half_slider_action( $slider_order ) { add_action( 'cyberchimps_' . $slider_order . '_content', 'cyberchimps_half_slider' ); } // Help text function cyberchimps_options_help_text() { $text = ''; $instruction_img = get_template_directory_uri() . '/cyberchimps/options/lib/images/document.png'; $support_img = get_template_directory_uri() . '/cyberchimps/options/lib/images/questionsupport.png'; $text .= '' . __( 'For even more amazing new features, upgrade to %1$s which includes a slider with customizable features, an image carousel, widgetized boxes, a callout section, expanded typography (including Google Fonts), additional color skins, and many more powerful new features. Visit %2$s to learn more!', 'cyberchimps_core' ) . '
', '' . $pro_title . '', 'CyberChimps.com' ); } //text for pro themes else { $text .= ''; } return $text; } add_filter( 'cyberchimps_help_description', 'cyberchimps_options_help_text' ); // upgrade bar for free themes function cyberchimps_upgrade_bar() { $current_theme_name = apply_filters( 'cyberchimps_current_theme_name', 'CyberChimps' ); $upgrade_link = apply_filters( 'cyberchimps_upgrade_link', 'http://cyberchimps.com' ); $pro_title = apply_filters( 'cyberchimps_upgrade_pro_title', 'CyberChimps Pro' ); ?>' . $pro_title . ' ' ); ?>
' . $utm_text . ' '); ?>
#view-post-btn,#post-preview{display: none;}'; } } add_action( 'admin_head', 'cyberchimps_posttype_admin_css' ); /** * Add link to theme options in Admin bar. */ function cyberchimps_admin_link() { global $wp_admin_bar; $wp_admin_bar->add_menu( array( 'id' => 'cyberchimps', 'title' => apply_filters( 'cyberchimps_current_theme_name', 'CyberChimps ' . __( 'Options', 'cyberchimps_core' ) ) . __( 'Options', 'cyberchimps_core' ), 'href' => admin_url( 'themes.php?page=cyberchimps-theme-options' ) ) ); } // Include link to theme option in the admin header bar in pro theme only, as it is ruled out in free themes by WPORG. if( 'free' != cyberchimps_theme_check() ) { add_action( 'admin_bar_menu', 'cyberchimps_admin_link', 113 ); } function cyberchimps_google_analytics() { $code = cyberchimps_get_option( 'google_analytics', '' ); if( $code != '' ) { echo ''; } } if( 'pro' == cyberchimps_theme_check() ) { add_action( 'wp_head', 'cyberchimps_google_analytics', 9999 ); } // Add an array to an existing array in a certain position, used by options function cyberchimps_heading_filter( $orig, $new ) { foreach( $new as $key => $value ) { array_splice( $orig, $key, 0, $value ); } return $orig; } // the following 2 functions help retrieve the starting key number of the whole array of sections. There by allowing you to select the position of the custom section within that heading. 2 array's are passed to cyberchimps_array_section_organizer(). The initial array and the array of new sections. The array of new sections should have the format: $new_section[][10] = array( field-data ). 10 being the position within that heading. //this function finds the initial key number where the heading name exists in the original array. If it does not yet exist then this must be a new heading and it returns the last key number of the array. function cyberchimps_section_start_no( $heading, $orig ) { foreach( $orig as $key => $value ) { if( $value['heading'] == $heading ) { $first_key_value = $key; break; } else { end( $orig ); $first_key_value = key( $orig ) + 1; //this counter acts the minus 1 from the organizer so the last element doesn't get built in front of } } return $first_key_value; } //this function takes the new and old array and combines them adding the new array elements in the position indicated by their key function cyberchimps_array_section_organizer( $orig, $new ) { foreach( $new as $value ) { foreach( $value as $key => $val ) { $section_start_no = cyberchimps_section_start_no( $val['heading'], $orig ); $position = $section_start_no + ( $key - 1 ); $position = intval( $position ); array_splice( $orig, $position, 0, $value ); } } return $orig; } // the following 2 functions help retrieve the starting key number of the whole array of fields. There by allowing you to select the position of the custom field within that section. 2 array's are passed to cyberchimps_array_field_organizer(). The initial array and the array of new fields. The array of new fields should have the format: $new_field[][10] = array( field-data ). 10 being the position within that section. //this function finds the initial key number wherethe section name exists in the original array. If it does not yet exist then this must be a new section and it returns the last key number of the array. function cyberchimps_field_start_no( $section, $orig ) { foreach( $orig as $key => $value ) { if( $value['section'] == $section ) { $first_key_value = $key; break; } else { end( $orig ); $first_key_value = key( $orig ) + 1; } } return $first_key_value; } //this function takes the new and old array and combines them adding the new array elements in the position indicated by their key function cyberchimps_array_field_organizer( $orig, $new ) { foreach( $new as $value ) { foreach( $value as $key => $val ) { $section_start_no = cyberchimps_field_start_no( $val['section'], $orig ); $position = $section_start_no + ( $key - 1 ); $position = intval( $position ); array_splice( $orig, $position, 0, $value ); } } return $orig; } /**** Remove sections/fields from core theme options *****/ function cyberchimps_remove_options( $orig, $removes ) { foreach( $removes as $remove ) { foreach( $orig as $key => $value ) { if( $value['id'] == $remove ) { unset( $orig[$key] ); } } } return $orig; } /* Container width fix for IE8 */ function cyberchimps_ie8_responsive() { echo ''; } add_action( 'wp_head', 'cyberchimps_ie8_responsive' ); /* Removing the unused page option from the woocommerce shop edit page */ function cyberchimps_woocommerce_shop_style() { if( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { global $pagenow; if( $pagenow == 'post.php' && $_GET['post'] == wc_get_page_id( 'shop' ) ) { echo ''; } } } add_action( 'admin_head', 'cyberchimps_woocommerce_shop_style' ); /** * The Events Calendar Add On */ // Add Ons Heading for Theme Options function cyberchimps_addons_headings( $headings_list ) { $headings_list[] = array( 'id' => 'cyberchimps_addons_heading', 'title' => __( 'Add Ons', 'cyberchimps_core' ), ); return $headings_list; } add_filter( 'cyberchimps_headings_filter', 'cyberchimps_addons_headings', 20, 1 ); // Addon Section function cyberchimps_addon_sections( $sections_list ) { $sections_list[] = array( 'id' => 'cyberchimps_slidedeck_lite_options', 'label' => __( 'SlideDeck Lite', 'cyberchimps_core' ), 'heading' => 'cyberchimps_addons_heading' ); $sections_list[] = array( 'id' => 'cyberchimps_wpforms_lite_options', 'label' => __( 'WPForms Lite', 'cyberchimps_core' ), 'heading' => 'cyberchimps_addons_heading' ); return $sections_list; } add_filter( 'cyberchimps_section_list', 'cyberchimps_addon_sections', 20, 1 ); // Addon Fields function cyberchimps_addon_fields( $fields_list ) { $fields_list[] = array( 'name' => __( 'SlideDeck Lite', 'cyberchimps_core' ), 'id' => 'slidedeck_lite', 'type' => 'info', 'callback' => 'cyberchimps_slidedeck_lite_callback', 'section' => 'cyberchimps_slidedeck_lite_options', 'heading' => 'cyberchimps_addons_heading' ); $fields_list[] = array( 'name' => __( 'WPForms Lite', 'cyberchimps_core' ), 'id' => 'wpforms_lite', 'type' => 'info', 'callback' => 'cyberchimps_wpforms_lite_callback', 'section' => 'cyberchimps_wpforms_lite_options', 'heading' => 'cyberchimps_addons_heading' ); return $fields_list; } add_filter( 'cyberchimps_field_list', 'cyberchimps_addon_fields', 20, 1 ); // The SlideDeck text function cyberchimps_slidedeck_lite_callback( $value ) { $output = ''; $plugin = 'slidedeck/slidedeck.php'; $icon = ''; $icon_neg = ''; $installed_plugins = get_plugins(); if( isset( $installed_plugins[$plugin] ) ) { if( is_plugin_active( $plugin ) ) { $output .= $icon . '' . __( 'SlideDeck Settings', 'cyberchimps_core' ) . ''; } else { $output .= $icon_neg . '' . __( 'Please activate the "SlideDeck Lite" plugin', 'cyberchimps_core' ) . ''; } } else { $output .= $icon_neg . '' . __( 'Install the "SlideDeck Lite" plugin', 'cyberchimps_core' ) . ''; } echo $output; } // The WPForms text function cyberchimps_wpforms_lite_callback( $value ) { $output = ''; $plugin = 'wpforms-lite/wpforms.php'; $icon = ''; $icon_neg = ''; $installed_plugins = get_plugins(); if( isset( $installed_plugins[$plugin] ) ) { if( is_plugin_active( $plugin ) ) { $output .= $icon . '' . __( 'WPForms Settings', 'cyberchimps_core' ) . ''; } else { $output .= $icon_neg . '' . __( 'Please activate the "WPForms Lite" plugin', 'cyberchimps_core' ) . ''; } } else { $output .= $icon_neg . '' . __( 'Install the "WPForms Lite" plugin', 'cyberchimps_core' ) . ''; } echo $output; } // return a nonced installation link for the plugin. function cyberchimps_slidedeck_install_link() { include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $slug = 'slidedeck'; return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug ); } // return a nonced installation link for the plugin. function cyberchimps_wpforms_install_link() { include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $slug = 'wpforms-lite'; return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug ); } // Add class cc-responsive if responisve design is on. add_filter( 'body_class', 'cyberchimps_add_responsive_class' ); function cyberchimps_add_responsive_class( $classes ) { // Check if responisve design is on. if( cyberchimps_get_option( 'responsive_design', 'checked' ) ) { $classes[] = 'cc-responsive'; } return $classes; } if ( 'mp6' === get_user_option( 'admin_color' ) || version_compare( $GLOBALS['wp_version'], '3.8-alpha', '>' ) ) { function cyberchimps_load_custom_admin_styles() { wp_enqueue_style( 'cc-admin', get_template_directory_uri() . '/cyberchimps/options/lib/css/custom-post-icons.css', false, '1.0.0' ); } add_action( 'admin_enqueue_scripts', 'cyberchimps_load_custom_admin_styles' ); } // FOR IE compatiblilty mode. add_action( 'send_headers', 'cyberchimps_add_header_xua' ); function cyberchimps_add_header_xua() { if (!headers_sent()) { header( 'X-UA-Compatible: IE=edge,chrome=1' ); } } // For Author Bio on Single Posts Page if(!function_exists('cyberchimps_posts_author_bio')) { function cyberchimps_posts_author_bio() { global $post; if( is_single() ) { $show = ( cyberchimps_get_option( 'single_post_author_bio', 1 ) ) ? cyberchimps_get_option( 'single_post_author_bio', 1 ) : false; if($show){ $user_description = get_the_author_meta( 'user_description', $post->post_author ); if($user_description) { ?>