100, 'width' => 100, 'flex-height' => true, 'flex-width' => true, 'header-text' => array( 'site-title', 'site-description' ), ) ); /* Nav Menu options */ register_nav_menu( 'primary', esc_html__( 'Header Navigation Menu', 'breeze' ) ); register_nav_menu( 'secondary', esc_html__( 'BlogHeader Navigation Menu', 'breeze' ) ); register_nav_menu( 'secondary-1', esc_html__( 'Footer Navigation Menu', 'breeze' ) ); register_nav_menus( array('offcanvas' => esc_html__( 'offcanvas-menu', 'breeze' ),) ); } endif; add_action( 'after_setup_theme', 'breeze_setup' ); /** * Set the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width */ function breeze_content_width() { $GLOBALS['content_width'] = apply_filters( 'breeze_content_width', 640 ); } add_action( 'after_setup_theme', 'breeze_content_width', 0 ); /* Registers an editor stylesheet for the theme */ function breeze_add_editor_styles() { add_editor_style( 'css/breeze-custom-editor-style.css' ); } add_action( 'admin_init', 'breeze_add_editor_styles' ); function breeze_enqueue_comments_reply() { if( get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'comment_form_before', 'breeze_enqueue_comments_reply' ); // Add sticky class to sticky post function breeze_post_classes( $classes ){ if ( is_sticky() ) { $classes[] = 'sticky'; } return $classes; } add_filter('post_class', 'breeze_post_classes'); /* ============================ SIDEBAR FUNCTIONS ============================ */ function breeze_sidebar_init(){ register_sidebar( array( 'name' => esc_html__( 'Search Sidebar', 'breeze' ), 'id' => 'blog-sidebar-1', 'description' => esc_html__('Dynamic Blog Sidebar', 'breeze' ), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => "

" ) ); register_sidebar( array( 'name' => esc_html__( 'homepage-sidebar1', 'breeze' ), 'id' => 'sidebar-1', 'description' => esc_html__( 'home sidebar' ,'breeze'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => "

" ) ); register_sidebar( array( 'name' => esc_html__( 'homepage-sidebar2', 'breeze' ), 'id' => 'sidebar-2', 'description' => esc_html__( 'home sidebar' ,'breeze'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => "

" ) ); register_sidebar( array( 'name' => esc_html__( 'homepage-sidebar3', 'breeze' ), 'id' => 'sidebar-3', 'description' => esc_html__( 'home sidebar' ,'breeze'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => "

" ) ); register_sidebar( array( 'name' => esc_html__( 'homepage-sidebar4', 'breeze' ), 'id' => 'sidebar-4', 'description' => esc_html__( 'home sidebar' ,'breeze'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => "

" ) ); register_sidebar( array( 'name' => esc_html__( 'homepage-sidebar5', 'breeze' ), 'id' => 'sidebar-5', 'description' => esc_html__( 'home sidebar' ,'breeze'), 'before_widget' => '
', 'after_widget' => "
", 'before_title' => '

', 'after_title' => "

" ) ); } add_action( 'widgets_init', 'breeze_sidebar_init' ); /* BLOG LOOP CUSTOM FUNCTIONS */ function breeze_excerpt_length( $length ) { return 15; } add_filter( 'excerpt_length', 'breeze_excerpt_length', 999 ); /* ============================ FOOTER FUNCTIONS ============================ */ function breeze_footer(){ $comments_num = get_comments_number(); if( comments_open() ){ if( $comments_num == 0 ){ $comments = esc_html__('No Comments', 'breeze' ); } elseif( $comments_num > 1 ){ $comments = $comments_num . esc_html__(' Comments', 'breeze' ); } else{ $comments = esc_html__('1 Comment', 'breeze' ); } $comments = ''. $comments . ' '; } else{ $comments = esc_html__('Comments are closed', 'breeze' ); } return '
'. get_the_tag_list('
', ' ', '
') .'
'. $comments .'
'; } /* ============================ NUMERIC PAGINATION ============================ */ function breeze_pagination_bar() { if( is_singular() ) return; global $wp_query; /** Stop execution if there's only 1 page */ if( $wp_query->max_num_pages <= 1 ) return; $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; $max = intval( $wp_query->max_num_pages ); /** Add current page to the array */ if ( $paged >= 1 ) $links[] = $paged; /** Add the pages around the current page to the array */ if ( $paged >= 3 ) { $links[] = $paged - 1; $links[] = $paged - 2; } if ( ( $paged + 2 ) <= $max ) { $links[] = $paged + 2; $links[] = $paged + 1; } echo '
' . "\n"; } /* ------------------- Grab current uri ------------------- */ function breeze_grab_current_uri(){ $http = ( isset( $_SERVER["HTTPS"] ) ? 'https://' : 'http://' ); $referer = $http . $_SERVER["HTTP_HOST"]; $archive_url = $referer . $_SERVER["REQUEST_URI"]; return $archive_url; } /* ================================ SINGLE POST CUSTOM FUNCTIONS ================================ */ function breeze_post_navigation(){ $nav = '
'; $prev = get_previous_post_link( '
%link
', '%title' ); $nav .= '
' . $prev . '
'; $next = get_next_post_link( '
%link
', '%title' ); $nav .= '
' . $next . '
'; $nav .= '
'; return $nav; } /* ============================ POST META ============================ */ function breeze_posted_meta(){ /* Get the year, month, and day of the current post. */ $year = get_the_time( 'Y' ); $month = get_the_time( 'm' ); $day = get_the_time( 'd' ); $posted_on = ''; /* Add a link to the monthly archive. */ $posted_on .= '' . get_the_time( 'F' ) . ''; /* Add a link to the daily archive. */ $posted_on .= ' ' . $day . ''; /* Add a link to the yearly archive. */ $posted_on .= ', ' . $year . ''; $categories = get_the_category(); $seperator = ", "; $output = ''; $i = 1; if( !empty($categories) ): foreach ($categories as $category) : if( $i > 1 ): $output .= $seperator; endif; $output .= '' . esc_html( $category->name ) . ''; $i++; endforeach; endif; $comments_num = get_comments_number(); if( comments_open() ){ if( $comments_num == 0 ){ $comments = esc_html__('No Comments', 'breeze' ); } elseif( $comments_num > 1 ){ $comments = $comments_num . esc_html__(' Comments', 'breeze' ); } else{ $comments = esc_html__('1 Comment', 'breeze' ); } $comments = ''. $comments . ''; } else{ $comments = esc_html__('Comments are closed', 'breeze' ); } if(has_tag()){ $tag_list = get_the_tag_list('', ', ', ''); } else{ $tag_list = get_the_tag_list('', ', ', ''); } return ' ' . get_the_author_posts_link() .' ' . $posted_on . ' ' .$output. ' '. $comments .' '. $tag_list .''; } /* ============================ POSTED FUNCTIONS ============================ */ if ( ! function_exists( 'breeze_posted_on' ) ) : /** * Prints HTML with meta information for the current post-date/time and author. */ function breeze_posted_on() { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); $byline = sprintf( esc_html_x( ' %s ', 'post author', 'breeze' ), '' . esc_html( get_the_author() ) . '' ); $posted_on = sprintf( esc_html_x( ' %s ', 'post date', 'breeze' ), '' . $time_string . '' ); //post format icons` echo ''.$byline. ''.'' . $posted_on . ''; $categories_list = get_the_category_list( esc_html__( ' , ' , 'breeze' ) ); if ( $categories_list && breeze_categorized_blog() ) { printf( '' . esc_html__( ' %1$s ', 'breeze' ) . '', $categories_list ); // WPCS: XSS OK. } /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__( ' , ', 'breeze' ) ); if ( $tags_list ) { printf( ' ' . esc_html__( ' %1$s ' , 'breeze' ) . '', $tags_list ); // WPCS: XSS OK. } // WPCS: XSS OK. } endif; if ( ! function_exists( 'breeze_entry_footer' ) ) : /** * Prints HTML with meta information for the categories, tags and comments. */ function breeze_entry_footer() { // Hide category and tag text for pages. if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { echo ''; /* translators: %s: post title */ comments_popup_link( sprintf( wp_kses( __( 'Leave a Comment on %s', 'breeze' ), array( 'span' => array( 'class' => array() ) ) ), get_the_title() ) ); echo ''; } edit_post_link( sprintf( /* translators: %s: Name of current post */ esc_html__( 'Edit %s', 'breeze' ), the_title( '"', '"', false ) ), '', '' ); } endif; /* ======================================= THEME REQUIRED AND RECOMMENDED PLUGINS ======================================= */ /** * Include the TGM_Plugin_Activation class. */ require_once get_template_directory() . '/inc/class-tgm-plugin-activation.php'; add_action( 'tgmpa_register', 'breeze_register_required_plugins' ); /** * Register the required plugins for this theme. */ function breeze_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 from the WordPress Plugin Repository. array( 'name' => esc_html__('Newsletter', 'breeze'), 'slug' => 'newsletter', 'required' => false, // If false, the plugin is only 'recommended' instead of required. ), array( 'name' => esc_html__('Simplicity Save for Later', 'breeze'), // The plugin name. 'slug' => 'rs-save-for-later', // The plugin slug (typically the folder name). 'source' => 'http://demo.themeparrot.com/plugins/rs-save-for-later.zip', // The plugin source. 'required' => true, // If false, the plugin is only 'recommended' instead of required. 'version' => '1.0.8', // 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' => true, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. 'external_url' => '', // If set, overrides default API URL and points to an external URL. 'is_callable' => '', // If set, this callable will be be checked for availability to determine if a plugin is active. ), ); /* * 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' => 'breeze', // 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 ); } //post formats// /* ------------------------ GALLERY POST FORMAT ------------------------ */ function breeze_get_attachment( $num = 1 ){ $output = ''; if( has_post_thumbnail() && $num == 1 ): $output = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ); else: $attachments = get_posts( array ( 'post_type' => 'attachment', 'posts_per_page' => $num, 'post_parent' => get_the_ID() )); if($attachments && $num == 1): foreach ($attachments as $attachment) : $output = wp_get_attachment_url($attachment->ID); endforeach; elseif ($attachments && $num > 1) : $output = $attachments; endif; wp_reset_postdata(); endif; return $output; } function breeze_get_bs_slides( $attachments ){ $output = array(); $count = count($attachments)-1; for( $i=0; $i <= $count; $i++ ): $active = ($i == 0 ? ' active' : ''); $n = ( $i == $count ? 0 : $i+1 ); $nxtImg = wp_get_attachment_thumb_url( $attachments[$n]->ID ); $p = ( $i == 0 ? $count : $i-1 ); $prevImg = wp_get_attachment_thumb_url( $attachments[$p]->ID ); $output[$i] = array( 'class' => $active, 'url' => wp_get_attachment_url( $attachments[$i]->ID ), 'next_img' => $nxtImg, 'prev_img' => $prevImg, 'caption' => $attachments[$i]->post_excerpt ); endfor; return $output; } /* ---------------------- LINK POST FORMAT ---------------------- */ function breeze_grab_url(){ if( ! preg_match('/]*?href=[\'"](.+?)[\'"]/i', get_the_content(), $links ) ){ return false; } return esc_url_raw( $links[1] ); } /* --------------------------------- AUDIO AND VIDEO POST FORMAT --------------------------------- */ function breeze_get_embedded_media( $type = array() ){ $content = do_shortcode( apply_filters('the_content', get_the_content() ) ); $embed = get_media_embedded_in_content( $content, $type ); if( in_array( 'audio', $type) ): $output = str_replace('?visual=true','?visual=false',$embed[0]); else: if(isset($embed[0])){ $output = $embed[0]; } else { $output = ''; } endif; return $output; } /* ------------------ CHAT POST FORMAT ------------------ */ function breeze_format_chat_content( $content ) { global $_post_format_chat_ids; /* If this is not a 'chat' post, return the content. */ if ( !has_post_format( 'chat' ) ) return $content; /* Set the global variable of speaker IDs to a new, empty array for this chat. */ $_post_format_chat_ids = array(); /* Allow the separator (separator for speaker/text) to be filtered. */ $separator = apply_filters( 'breeze_post_format_chat_separator', ':' ); /* Open the chat transcript div and give it a unique ID based on the post ID. */ $chat_output = "\n\t\t\t" . '
'; /* Split the content to get individual chat rows. */ $chat_rows = preg_split( "/(\r?\n)+|(\s*)+/", $content ); /*Just to make sure we don't have any undefined variables*/ $chat_author=''; $speaker_id=0; /* Loop through each row and format the output. */ foreach ( $chat_rows as $chat_row ) { /* If a speaker is found, create a new chat row with speaker and text. */ if ( strpos( $chat_row, $separator ) ) { /* Split the chat row into author/text. */ $chat_row_split = explode( $separator, trim( $chat_row ), 2 ); /* Get the chat author and strip tags. */ $chat_author = strip_tags( trim( $chat_row_split[0] ) ); /* Get the chat text. */ $chat_text = trim( $chat_row_split[1] ); /* Get the chat row ID (based on chat author) to give a specific class to each row for styling. */ $speaker_id = breeze_format_chat_row_id( $chat_author ); /* Open the chat row. */ $chat_output .= "\n\t\t\t\t" . '
'; /* Add the chat row author. */ $chat_output .= "\n\t\t\t\t\t" . '
' . apply_filters( 'breeze_post_format_chat_author', $chat_author, $speaker_id ) . '' . $separator . '
'; /* Add the chat row text. */ $chat_output .= "\n\t\t\t\t\t" . '
' . str_replace( array( "\r", "\n", "\t" ), '', apply_filters( 'breeze_post_format_chat_text', $chat_text, $chat_author, $speaker_id ) ) . '
'; /* Close the chat row. */ $chat_output .= "\n\t\t\t\t" . '
'; } /** * If no author is found, assume this is a separate paragraph of text that belongs to the * previous speaker and label it as such, but let's still create a new row. */ else { /* Make sure we have text. */ if ( !empty( $chat_row ) ) { /* Open the chat row. */ $chat_output .= "\n\t\t\t\t" . '
'; /* Don't add a chat row author. The label for the previous row should suffice. */ /* Add the chat row text. */ $chat_output .= "\n\t\t\t\t\t" . '
' . str_replace( array( "\r", "\n", "\t" ), '', apply_filters( 'breeze_post_format_chat_text', $chat_row, $chat_author, $speaker_id ) ) . '
'; /* Close the chat row. */ $chat_output .= "\n\t\t\t
"; } } } /* Close the chat transcript div. */ $chat_output .= "\n\t\t\t
\n"; /* Return the chat content and apply filters for developers. */ return apply_filters( 'breeze_post_format_chat_content', $chat_output ); } add_filter( 'the_content', 'breeze_format_chat_content' ); add_filter( 'breeze_post_format_chat_text', 'wpautop' ); function breeze_format_chat_row_id( $chat_author ) { global $_post_format_chat_ids; /* Let's sanitize the chat author to avoid craziness and differences like "John" and "john". */ $chat_author = strtolower( strip_tags( $chat_author ) ); /* Add the chat author to the array. */ $_post_format_chat_ids[] = $chat_author; /* Make sure the array only holds unique values. */ $_post_format_chat_ids = array_unique( $_post_format_chat_ids ); /* Return the array key for the chat author and add "1" to avoid an ID of "0". */ return absint( array_search( $chat_author, $_post_format_chat_ids ) ) + 1; } //span class for categories and archive function breeze_list_categories_output_change( $links ) { if($links == ' ' ){ return; } else{ $links = str_replace('(', '', $links); $links = str_replace(')', '', $links); } return $links; } add_filter( 'wp_list_categories', 'breeze_list_categories_output_change' ); function breeze_archive_postcount_filter ($links) { if (strpos($links, '', $links); $links = str_replace(')', '', $links); } return $links; } add_filter('get_archives_link', 'breeze_archive_postcount_filter'); /** * Returns true if a blog has more than 1 category. * * @return bool */ function breeze_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'breeze_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( 'breeze_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so breeze_categorized_blog should return true. return true; } else { // This blog has only 1 category so breeze_categorized_blog should return false. return false; } } /** * Flush out the transients used in breeze_categorized_blog. */ function breeze_category_transient_flusher() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } // Like, beat it. Dig? delete_transient( 'breeze_categories' ); } add_action( 'edit_category', 'breeze_category_transient_flusher' ); add_action( 'save_post', 'breeze_category_transient_flusher' ); // Add our function to the post content filter function breeze_author_info_box() { global $post; $author_details = ''; $user_content = ''; $content = get_post_field( 'post_content', $post->ID ); $word_count = str_word_count( strip_tags( $content ) ); $readingtime = ceil($word_count / 200); // Get author's display name $display_name = get_the_author_meta( 'display_name', $post->post_author ); // If display name is not available then use nickname as display name if ( empty( $display_name ) ) $display_name = get_the_author_meta( 'nickname', $post->post_author ); // Get author's biographical information or description $user_description = get_the_author_meta( 'user_description', $post->post_author ); // Get author's website URL $user_website = get_the_author_meta('url', $post->post_author); // Get link to the author archive page $user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author)); $user_image = get_avatar( get_the_author_meta('user_email') , 40 ); $display_date = get_the_date(); // Detect if it is a single post with a post author if ($readingtime == 1) { $timer = " min read"; } else { $timer = " min read"; } $totalreadingtime = $readingtime . $timer; // Detect if it is a single post with a post author if (isset( $post->post_author ) ) { if ( ! empty( $user_image ) ) { // Author avatar and bio $author_details = '
' . $user_image . '
'; $author_details .= '
' . $display_name . '
'; $author_details .= '

' . nl2br( $user_description ). '

'; $author_details .= ''.$display_date." . ".$totalreadingtime.''; // Check if author has a website in their profile if ( ! empty( $user_website ) ) { // Display author website link $author_details .= ' | ' . esc_html__('Website ', 'breeze') . '
'; } else { // if there is no author website then just close the paragraph $author_details .= ''; } // Pass all this info to post content $user_content = '
' . $author_details . '
'; } } return $user_content; } function breeze_author_box() { global $post; $author_details = ''; $user_content = ''; $content = get_post_field( 'post_content', $post->ID ); $word_count = str_word_count( strip_tags( $content ) ); $readingtime = ceil($word_count / 200); // Get author's display name $display_name = get_the_author_meta( 'display_name', $post->post_author ); // If display name is not available then use nickname as display name if ( empty( $display_name ) ) $display_name = get_the_author_meta( 'nickname', $post->post_author ); // Get author's biographical information or description $user_description = get_the_author_meta( 'user_description', $post->post_author ); // Get author's website URL $user_website = get_the_author_meta('url', $post->post_author); // Get link to the author archive page $user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author)); $user_image = get_avatar( get_the_author_meta('user_email') , 40 ); $display_date = get_the_date(); $bookmark = apply_filters( 'save_for_later_button', get_the_ID()); // Detect if it is a single post with a post author if ($readingtime == 1) { $timer = " min read"; } else { $timer = " min read"; } $totalreadingtime = $readingtime . $timer; if (isset( $post->post_author ) ) { if ( ! empty( $user_image ) ) { // Author avatar and bio $author_details = '
' . $user_image . '
'; $author_details .= '
' . $display_name . '
'; $author_details .= ''.$display_date." . ".$totalreadingtime.'
'; $author_details .= '
'.$bookmark.''; // Check if author has a website in their profile if ( ! empty( $user_website ) ) { // Display author website link $author_details .= ' | ' . esc_html__('Website ', 'breeze') . '
'; } else { // if there is no author website then just close the paragraph $author_details .= ''; } // Pass all this info to post content $user_content = '
' . $author_details . '
'; } } return $user_content; } //reading_time function reading_time() { global $post; $content = get_post_field( 'post_content', $post->ID ); $word_count = str_word_count( strip_tags( $content ) ); $readingtime = ceil($word_count / 200); if ($readingtime == 1) { $timer = " min read"; } else { $timer = " min read"; } $totalreadingtime = $readingtime . $timer; return $totalreadingtime; } //comment-form /** * Changing the view for user viewing comment form */ function breeze_comments_defaults( $defaults ) { global $post; $defaults = array( 'title_reply' => '' . esc_html__( 'Responses', 'breeze' ) . '', 'cancel_reply_link' => esc_html__( 'Cancel Reply', 'breeze' ), 'label_submit' => esc_html__( 'Submit Comment', 'breeze' ), 'comment_field' => '

', ); return $defaults; } add_filter( 'comment_form_defaults', 'breeze_comments_defaults' ); function breeze_share_posted(){ global $post; // Get current page URL $permalink = urlencode(get_permalink($post->ID)); // Get current page title $title = str_replace( ' ', '%20', get_the_title()); $twitterHandler = ( get_option('twitter_handler') ? '&via=' . esc_attr( get_option('twitter_handler') ) : '' ); $twitter = esc_url_raw('https://twitter.com/intent/tweet?text=').$title.'&url='.$permalink.$twitterHandler; $facebook = esc_url_raw('https://www.facebook.com/sharer/sharer.php?u=') . $permalink; $googleplus = esc_url_raw('https://plus.google.com/share?url=') . $permalink; if(!is_feed() && !is_home() && !is_page()) { $output = ' '; } return '
'; }