* @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 '
';
// sticky post ------------->
if ( is_sticky() && is_home() && ! is_paged() ) {
echo '
'.esc_html__( 'Featured', 'canary' ).'
';
}
// post format ------------->
$format = get_post_format();
$formats_class=array(
'aside'=>'file-text',
'image'=>'image',
'video'=>'video-camera',
'quote'=>'quote-left',
'link'=>'link',
'gallery'=>'image',
'status'=>'thumb-tack',
'audio'=>'music',
'chat'=>'commenting-o',
);
if ( current_theme_supports( 'post-formats', $format ) ) {
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 '