ID ); ?>
__('Featured', 'blogshare')]); }); add_action('manage_post_posts_custom_column', function($column_key, $post_id) { if ($column_key == 'blogshare-featured') { $blogshare_featured = get_post_meta($post_id, 'blogshare-featured', 'yes'); if ($blogshare_featured == 'yes') { echo ''; } else { echo ''; } } }, 10, 2); add_filter('manage_edit-post_sortable_columns', function($columns) { $columns['blogshare-featured'] = 'blogshare-featured'; return $columns; }); add_action('pre_get_posts', function($query) { if (!is_admin()) { return; } $orderby = $query->get('orderby'); if ($orderby == 'blogshare-featured') { $query->set('meta_key', 'blogshare-featured'); $query->set('meta_value', 'yes'); $query->set('orderby', 'date'); $query->set('order', 'DESC'); } }); /** * Search Filter */ if ( ! function_exists( 'blogshare_search_filter' ) && ( ! is_admin() ) ) : function blogshare_search_filter($query) { if ($query->is_search) { $query->set('post_type', 'post'); } return $query; } add_filter('pre_get_posts','blogshare_search_filter'); endif; /** * Filter the except length to 40 characters. * * @param int $length Excerpt length. * @return int (Maybe) modified excerpt length. */ if ( ! function_exists( 'blogshare_custom_excerpt_length' ) ) : function blogshare_custom_excerpt_length( $length ) { if ( is_admin() ) { return $length; } else { return '40'; } } add_filter( 'excerpt_length', 'blogshare_custom_excerpt_length', 999 ); endif; /** * Customize excerpt more. */ if ( ! function_exists( 'blogshare_excerpt_more' ) ) : function blogshare_excerpt_more( $more ) { if ( is_admin() ) { return $more; } else { return '... '; } } add_filter( 'excerpt_more', 'blogshare_excerpt_more' ); endif; /** * Display the first (single) category of post. */ if ( ! function_exists( 'blogshare_first_category' ) ) : function blogshare_first_category() { $category = get_the_category(); if ($category) { echo '' . esc_html( $category[0]->name ) .' '; } } endif; /** * Returns true if a blog has more than 1 category. * * @return bool */ if ( ! function_exists( 'blogshare_categorized_blog' ) ) : function blogshare_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'blogshare_categories' ) ) ) { // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories( array( 'fields' => 'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, ) ); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'blogshare_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so blogshare_categorized_blog should return true. return true; } else { // This blog has only 1 category so blogshare_categorized_blog should return false. return false; } } endif; /** * Flush out the transients used in blogshare_categorized_blog. */ if ( ! function_exists( 'blogshare_category_transient_flusher' ) ) : function blogshare_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'blogshare_categories' ); } add_action( 'edit_category', 'blogshare_category_transient_flusher' ); add_action( 'save_post', 'blogshare_category_transient_flusher' ); endif; /** * Fix skip link focus in IE11. * * This does not enqueue the script because it is tiny and because it is only for IE11, * thus it does not warrant having an entire dedicated blocking script being loaded. * * @link https://git.io/vWdr2 */ function blogshare_skip_link_focus_fix() { // The following is minified via `terser --compress --mangle -- js/skip-link-focus-fix.js`. ?> array( 'class' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true, 'aria-hidden' => true, 'role' => true, 'focusable' => true, ), 'path' => array( 'fill' => true, 'fill-rule' => true, 'd' => true, 'transform' => true, ), 'polygon' => array( 'fill' => true, 'fill-rule' => true, 'points' => true, 'transform' => true, 'focusable' => true, ), ) ); if ( ! $svg ) { return false; } return $svg; } } /** * Miscellaneous */ /** * Toggles animation duration in milliseconds. * * @return int Duration in milliseconds */ function blogshare_toggle_duration() { /** * Filters the animation duration/speed used usually for submenu toggles. * * @since BlogShare 1.0 * * @param int $duration Duration in milliseconds. */ $duration = apply_filters( 'blogshare_toggle_duration', 250 ); return $duration; } /** * Menus */ /** * Filters classes of wp_list_pages items to match menu items. * * Filter the class applied to wp_list_pages() items with children to match the menu class, to simplify. * styling of sub levels in the fallback. Only applied if the match_menu_classes argument is set. * * @param string[] $css_class An array of CSS classes to be applied to each list item. * @param WP_Post $page Page data object. * @param int $depth Depth of page, used for padding. * @param array $args An array of arguments. * @param int $current_page ID of the current page. * @return array CSS class names. */ function blogshare_filter_wp_list_pages_item_classes( $css_class, $page, $depth, $args, $current_page ) { // Only apply to wp_list_pages() calls with match_menu_classes set to true. $match_menu_classes = isset( $args['match_menu_classes'] ); if ( ! $match_menu_classes ) { return $css_class; } // Add current menu item class. if ( in_array( 'current_page_item', $css_class, true ) ) { $css_class[] = 'current-menu-item'; } // Add menu item has children class. if ( in_array( 'page_item_has_children', $css_class, true ) ) { $css_class[] = 'menu-item-has-children'; } return $css_class; } add_filter( 'blogshare_page_css_class', 'blogshare_filter_wp_list_pages_item_classes', 10, 5 ); /** * Adds a Sub Nav Toggle to the Expanded Menu and Mobile Menu. * * @param stdClass $args An object of wp_nav_menu() arguments. * @param WP_Post $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @return stdClass An object of wp_nav_menu() arguments. */ function blogshare_add_sub_toggles_to_main_menu( $args, $item, $depth ) { // Add sub menu toggles to the Expanded Menu with toggles. if ( isset( $args->show_toggles ) && $args->show_toggles ) { // Wrap the menu item link contents in a div, used for positioning. $args->before = '
'. esc_html('Thank you for installing the BlogShare theme!','blogshare') . '
' . esc_html( 'Theme Demo', 'blogshare' ) . ' '. ' ' . ' ' . esc_html( 'Documentation', 'blogshare' ) . '