* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License * @link https://linesh.com/projects/canary/ * */ // Page nvaigation template -----------> add_filter('navigation_markup_template','canary_navigation_template'); function canary_navigation_template(){ return $template = ' '; } // checking for active sidebar -----------> function canary_active_sidebars(){ foreach(canary_sidebars() as $sidebar){ if ( is_active_sidebar($sidebar['id']) ) { return true ; }else{ continue; } } return false; } // Adding body class ---------------> add_filter( 'body_class', 'canary_body_classes' ); function canary_body_classes( $classes ) { if ( get_background_image() ) { // Adds a class of custom-background-image to sites with a custom background image. $classes[] = 'custom-background-image'; } if ( is_multi_author() ) { // Adds a class of group-blog to sites with more than 1 published author. $classes[] = 'group-blog'; } if ( ! is_active_sidebar( 'sidebar-1' ) ) {// Adds a class of no-sidebar to sites without active sidebar. $classes[] = 'no-sidebar'; } if ( ! is_singular() ) {// Adds a class of hfeed to non-singular pages. $classes[] = 'hfeed'; } return $classes; } // Handles JavaScript detection.Adds a `js` class to the root `` element when JavaScript is detected. ---------------> add_action( 'wp_head', 'canary_javascript_detection', 0 ); function canary_javascript_detection() { echo "\n"; } // Add a `screen-reader-text` class to the search form's submit button. ---------------> add_filter( 'get_search_form', 'canary_search_form_modify' ); function canary_search_form_modify( $html ) { return str_replace( 'class="search-submit"', 'class="search-submit screen-reader-text"', $html ); } // Post entery metas ---------------> function canary_entry_meta() { echo ''; } function canary_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'canary_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, 'number' => 2, )); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'canary_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so canary_categorized_blog should return true. return true; } else { // This blog has only 1 category so canary_categorized_blog should return false. return false; } } function canary_category_transient_flusher() { delete_transient( 'canary_categories' ); } add_action( 'edit_category', 'canary_category_transient_flusher' ); add_action( 'save_post', 'canary_category_transient_flusher' ); // Post featured image ---------------> function canary_post_thumbnail( $size='',$id='') { if( !($size=trim($size)) ){ $size='medium'; } if( !($id=trim($id)) ){ $id=get_the_ID(); } if(has_post_thumbnail($id)){ echo '
'.get_the_post_thumbnail( $id, $size, array( 'alt' => get_the_title() ) ).'
'; } } // Excerpt more ---------------> add_filter( 'excerpt_more', 'canary_excerpt_more' ); function canary_excerpt_more( $more ) { if(! is_admin()){ /* translators: %s: Name of current post */ $link = sprintf( '%2$s',esc_url( get_permalink( get_the_ID() ) ),sprintf( esc_html__( 'Continue Reading %s', 'canary' ), ''.get_the_title( get_the_ID() ).'' )); return '… ' . $link; } } // Home page validation ---------------> function canary_is_home_page(){ if ( is_home() && is_front_page()) { return true; }else{ return false; } } // Displays the optional custom logo ---------------> function canary_the_custom_logo() { if ( function_exists( 'the_custom_logo' ) && has_custom_logo() ) { echo '
'; the_custom_logo(); }else{ echo '
'; if(canary_is_home_page()){ echo '

'.esc_html(get_bloginfo( 'name' )).'

'; } else{ echo '

'.esc_html(get_bloginfo( 'name' )).'

'; } } if ( $description = get_bloginfo( 'description', 'display' )){ /*if( !is_customize_preview()){ $class="says"; }*/ echo '

'.esc_html($description).'

'; } echo '
'; } // Author's meta ----------------> function canary_author_metas($author_id) { echo '
'; if($post_count=count_user_posts($author_id)) { echo ''.esc_html($post_count).''; } if($website=esc_url(get_the_author_meta('url',$author_id)) ){ echo ''; } echo ''; echo '
'; } // Archive title -----------------------> add_filter('get_the_archive_title','canary_filter_archive_title'); function canary_filter_archive_title($title ) { $rss=''; if (is_search()){ $title = ''. esc_html__( 'Searching for:','canary' ).'"'.get_search_query().'"' ; }elseif ( is_category() ) { $title = ''.single_cat_title( '', false ).''. esc_html__( 'Category','canary' ).'' ; $rss=get_category_feed_link(get_query_var('cat')); } elseif ( is_tag() ) { $title = ''.single_tag_title( '', false ).''. esc_html__( 'Tag Archive','canary' ).'' ; $rss=get_tag_feed_link(get_query_var('tag_id')); } elseif ( is_author() ) { $title = '' . get_the_author() . ''. esc_html__( 'Author','canary' ).'' ; $rss= get_author_feed_link(get_the_author_meta('ID')); } elseif ( is_year() ) { $title = '' .get_the_date( __( 'Y', 'canary' ) ) . ''. esc_html__( 'Yearly Archives','canary' ).'' ; } elseif ( is_month() ) { $title = '' .get_the_date( __( 'F Y', 'canary' ) ) . ''. esc_html__( 'Monthly Archives ','canary' ).'' ; } elseif ( is_day() ) { $title = '' .get_the_date( __( 'F j, Y', 'canary' ) ) . ''. esc_html__( 'Daily Archives','canary' ).'' ; } elseif ( is_post_type_archive() ) { $title = '' .post_type_archive_title( '', false ) . '' ; $rss=get_post_type_archive_feed_link(get_query_var('post_type')); } elseif ( is_tax() ) { $tax = get_taxonomy( get_queried_object()->taxonomy ); $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $title = ''.single_term_title('', false ).''.$tax->labels->singular_name.'' ; $rss=get_term_feed_link($term->term_id, get_query_var( 'taxonomy' )); } else { $title =''.esc_html__( 'All Posts' ,'canary').' '.esc_html__( 'Blog Archives:' ,'canary').''; $rss=get_bloginfo('rss2_url'); } if($title && $rss){ $title=$title.''.esc_html__('Subscribe','canary').' '; } return $title; } ?>