'primary', 'name' => _x( 'Primary', 'sidebar', 'envince' ), 'description' => __( 'Main Sidebar used in both two column and three column layout. Generally present in Right section.', 'envince' ) ) ); hybrid_register_sidebar( array( 'id' => 'secondary', 'name' => _x( 'Secondary', 'sidebar', 'envince' ), 'description' => __( 'Secondary Sidebar used in three column layout only.', 'envince' ) ) ); hybrid_register_sidebar( array( 'id' => 'header', 'name' => _x( 'Header', 'sidebar', 'envince' ), 'description' => __( 'Header Sidebar located in the right section beside the site title and above the menu.', 'envince' ) ) ); hybrid_register_sidebar( array( 'id' => 'subsidiary', 'name' => _x( 'Subsidiary', 'sidebar', 'envince' ), 'description' => __( 'Footer Sidebar. Optimized for one, two and three column layout.', 'envince' ) ) ); // Registers widgets register_widget( 'envince_728x90_advertisement_widget' ); register_widget( 'envince_featured_posts_slider_widget' ); register_widget( 'envince_twocol_posts' ); register_widget( 'envince_onecol_posts' ); register_widget( 'envince_imagegrid_posts' ); } /** * Load scripts for the front end. * * @since 1.0.0 * @access public * @return void */ function envince_enqueue_scripts() { $suffix = hybrid_get_min_suffix(); /* Register bxslider js */ wp_register_script( 'envince-bxslider', trailingslashit( get_template_directory_uri() ) . "js/jquery.bxslider{$suffix}.js", array( 'jquery' ), null, false ); wp_enqueue_script( 'envince-bxslider' ); /* Loads theme specific js file */ wp_register_script( 'envince', trailingslashit( get_template_directory_uri() ) . "js/theme{$suffix}.js", array( 'jquery' ), null, true ); wp_enqueue_script( 'envince' ); } /** * Load stylesheets for the front end. * * @since 1.0.0 * @access public * @return void */ function envince_enqueue_styles() { /* Gets ".min" suffix. */ $suffix = hybrid_get_min_suffix(); /* Load gallery style if 'cleaner-gallery' is active. */ if ( current_theme_supports( 'cleaner-gallery' ) ) { wp_enqueue_style( 'gallery', trailingslashit( HYBRID_CSS ) . "gallery{$suffix}.css" ); } /* Load parent theme stylesheet if child theme is active. */ if ( is_child_theme() ) { wp_enqueue_style( 'parent', trailingslashit( get_template_directory_uri() ) . "style{$suffix}.css" ); } /* Load active theme stylesheet. */ wp_enqueue_style( 'style', get_stylesheet_uri() ); } /** * Adds a custom excerpt length. * * @since 1.0.0 * @access public * @param int $length * @return int */ function envince_excerpt_length( $length ) { return 30; } /** * Removes the [..] sign/symbol for excerpt. * * @since 1.0.0 * @access public * @param string $text * @return string */ function envince_trim_excerpt($text) { return ''; } add_filter('excerpt_more', 'envince_trim_excerpt'); /** * Adds a custom class to the 'footer' sidebar. This is used to determine the number of columns used to * display the sidebar's widgets. This optimizes for 1, 2, and 3 columns or multiples of those values. * * Note that we're using the global $sidebars_widgets variable here. This is because core has marked * wp_get_sidebars_widgets() as a private function. Therefore, this leaves us with $sidebars_widgets for * figuring out the widget count. * @link http://codex.wordpress.org/Function_Reference/wp_get_sidebars_widgets * * @since 1.0.0 * @access public * @param array $attr * @param string $context * @return array */ function envince_sidebar_footer_class( $attr, $context ) { if ( 'subsidiary' === $context ) { global $sidebars_widgets; if ( is_array( $sidebars_widgets ) && !empty( $sidebars_widgets[ $context ] ) ) { $count = count( $sidebars_widgets[ $context ] ); if ( 1 === $count ) $attr['class'] .= ' sidebar-col-1'; elseif ( !( $count % 3 ) || $count % 2 ) $attr['class'] .= ' sidebar-col-3'; elseif ( !( $count % 2 ) ) $attr['class'] .= ' sidebar-col-2'; } } return $attr; } /** * Turns the IDs into classes for the calendar. * * @since 1.0.0 * @access public * @param string $calendar * @return string */ function envince_get_calendar( $calendar ) { return preg_replace( '/id=([\'"].*?[\'"])/i', 'class=$1', $calendar ); } /** * Checks the values of theme_mod andd metabox to generate class for the main section. * * @since 1.0.0 */ function envince_main_layout_class() { $layout_global = get_theme_mod('envince_sidebar','content-sidebar'); if(is_singular()){ $layout = get_post_meta( get_the_ID(), 'envince_sidebarlayout', 'default', true ); if(($layout == "default") || (empty($layout))){ $layout = $layout_global; } } else { $layout = $layout_global; } /* Adds class according to the sidebar layout */ if ($layout == "sidebar-content" || $layout == "content-sidebar") { echo "col-md-8"; } elseif ($layout == "full-width"){ echo "col-md-12"; } else { echo "col-md-6"; } } /** * Checks the values of theme_mod andd metabox to generate class for the main section. * * @since 1.0.0 */ function envince_sidebar_layout_class() { $layout_global = get_theme_mod('envince_sidebar','content-sidebar'); if(is_singular()){ $layout = get_post_meta( get_the_ID(), 'envince_sidebarlayout', 'default', true ); if(($layout == "default") || (empty($layout))){ $layout = $layout_global; } } else { $layout = $layout_global; } /* Adds class according to the sidebar layout */ if ($layout == "sidebar-content" || $layout == "content-sidebar") { echo "col-md-4"; } else { echo "col-md-3"; } } /** * Add Bootstrap thumbnail styling to images with captions * Use
and
* * @since 1.0.0 * @link http://justintadlock.com/archives/2011/07/01/captions-in-wordpress */ function envince_caption($output, $attr, $content) { if (is_feed()) { return $output; } $defaults = array( 'id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '' ); $attr = shortcode_atts($defaults, $attr); // If the width is less than 1 or there is no caption, return the content wrapped between the [caption] tags if ($attr['width'] < 1 || empty($attr['caption'])) { return $content; } // Set up the attributes for the caption
$attributes = (!empty($attr['id']) ? ' id="' . esc_attr($attr['id']) . '"' : '' ); $attributes .= ' class="thumbnail wp-caption ' . esc_attr($attr['align']) . '"'; $attributes .= ' style="width: ' . (esc_attr($attr['width']) + 10) . 'px"'; $output = ''; $output .= do_shortcode($content); $output .= '
' . $attr['caption'] . '
'; $output .= '
'; return $output; } /** * Handles the array for wp_nav_menu mobile menu * * @since 1.0.0 */ function envince_select_mobile_nav_menu() { $mobnav = wp_nav_menu( array( 'container' => false, // remove nav container 'container_class' => 'menu clearfix', // class of container (should you choose to use it) 'menu_class' => 'clearfix', // adding custom nav class 'theme_location' => 'primary', // where it's located in the theme 'before' => '', 'echo' => false, // echo 'after' => '', // after the menu 'link_before' => '', // before each link 'link_after' => '', // after each link 'depth' => 3, // limit the depth of the nav 'items_wrap' => '', 'walker' => new select_mobile_Walker_Nav_Menu(), // 'show_home' => true, 'fallback_cb' => 'eo_mobile_nav_fallback' // fallback function )); echo strip_tags($mobnav, '
' ); } /** * Get color from theme option for colored category * * @since 1.0.1 */ if ( ! function_exists( 'envince_category_color' ) ) : function envince_category_color( $wp_category_id ) { $args = array( 'orderby' => 'id', 'hide_empty' => 0 ); $category = get_categories( $args ); foreach ($category as $category_list ) { $color = get_theme_mod('envince_category_color_'.$wp_category_id); return $color; } } endif; /** * Uses theme customizer to generate colored category * * @since 1.01 */ if ( ! function_exists( 'envince_colored_category' ) ) : function envince_colored_category() { global $post; $categories1 = get_the_category(); $category = $categories1[0]; $output = ''; $output .= ''; echo trim($output); } endif; /** * Small Fix to display post title properly when no featured image is present in homepage. * @return string * * @since 1.0.1 */ function envince_home_img_status() { $image = get_the_image( array( 'size' => 'full', 'format' => 'array', 'echo' => false ) ); if( !$image ){ return 'no-image'; } else { return ''; } } /** * Register the required plugins for this theme. * * 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 envince_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 bundled with a theme. array( 'name' => 'Page Builder by SiteOrigin', // The plugin name. 'slug' => 'siteorigin-panels', // The plugin slug (typically the folder name). 'required' => false, // If false, the plugin is only 'recommended' instead of required. 'version' => '2.3', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. ), ); /* * Array of configuration settings. Amend each line as needed. * * TGMPA will start providing localized text strings soon. If you already have translations of our standard * strings available, please help us make TGMPA even better by giving us access to these translations or by * sending in a pull-request with .po file(s) with the translations. * * Only uncomment the strings in the config array if you want to customize the strings. */ $config = array( 'id' => 'envince', // Unique ID for hashing notices for multiple instances of TGMPA. 'default_path' => '', // Default absolute path to bundled 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. ); tgmpa( $plugins, $config ); }