get_template_directory_uri() . '/img/breadcrumbs.png', 'width' => 165, 'height' => 51, 'flex-height' => true, 'flex-width' => true, 'uploads' => true, 'random-default' => false, 'header-text' => true, ); add_theme_support( 'custom-header', $args ); /* Activate Custom Background */ add_theme_support( 'custom-background' ); /* Activate Custom Logo */ add_theme_support( 'custom-logo' ); /* Activate Post thumbnails */ add_theme_support( 'post-thumbnails' ); add_image_size( 'amaaaze-category-thumb', 300, 9999 ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* Add default posts and comments RSS feed links to head.*/ add_theme_support( 'automatic-feed-links' ); /* Activate Html5 features */ add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) ); /*enables Selective Reamaaaze for Widgets being managed within the Customizer */ add_theme_support( 'customize-selective-reamaaaze-widgets' ); /* Set the content width in pixels, based on the theme's design and stylesheet */ if ( ! isset( $content_width ) ) { $content_width = 600; } /* Activate woocommerce */ add_theme_support( 'woocommerce' ); } endif; add_action( 'after_setup_theme', 'amaaaze_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 amaaaze_content_width() { $GLOBALS['content_width'] = apply_filters( 'amaaaze_content_width', 640 ); } add_action( 'after_setup_theme', 'amaaaze_content_width', 0 ); /** * Registers an editor stylesheet for the theme. */ function amaaaze_theme_add_editor_styles() { add_editor_style( 'css/amaaaze-custom-editor-style.css' ); } add_action( 'admin_init', 'amaaaze_theme_add_editor_styles' ); /* ============================ SIDEBAR FUNCTIONS ============================ */ function amaaaze_sidebar_init(){ register_sidebar( array( 'name' => esc_html__( 'amaaaze Sidebar', 'amaaaze' ), 'id' => 'sidebar-1', 'description' => esc_html__('Dynamic amaaaze Sidebar', 'amaaaze' ), 'before_widget' => '<section id="%1$s" class="amaaaze-widget %2$s">', 'after_widget' => "</section>", 'before_title' => '<h2 class="amaaaze-widget-title">', 'after_title' => "</h2>" ) ); register_sidebar( array( 'name' => esc_html__( 'Top Side Bar', 'amaaaze' ), 'id' => 'top-side-bar', 'description' => esc_html__('Dynamic Top Side Bar', 'amaaaze' ), 'before_widget' => '<section id="%1$s" class="amaaaze-widget amaaaze-topsidebar-widget %2$s">', 'after_widget' => "</section>", 'before_title' => '<h2 class="amaaaze-widget-title">', 'after_title' => "</h2>" ) ); register_sidebar( array( 'name' => esc_html__( 'Home footer', 'amaaaze' ), 'id' => 'home-footer', 'description' => esc_html__('Dynamic Home Footer', 'amaaaze' ), 'before_widget' => '<section id="%1$s" class="amaaaze-widget amaaaze-widget %2$s">', 'after_widget' => "</section>", 'before_title' => '<h2 class="amaaaze-widget-title">', 'after_title' => "</h2>" ) ); register_sidebar( array( 'name' => esc_html__( 'Footer 1', 'amaaaze' ), 'id' => 'footer-sidebar-1', 'description' => esc_html__('Footer Sidebar 1', 'amaaaze' ), 'before_widget' => '<section id="%1$s" class="amaaaze-widget %2$s">', 'after_widget' => "</section>", 'before_title' => '<h2 class="amaaaze-widget-title">', 'after_title' => "</h2>" ) ); register_sidebar( array( 'name' => esc_html__( 'Footer 2', 'amaaaze' ), 'id' => 'footer-sidebar-2', 'description' => esc_html__('Footer Sidebar 2', 'amaaaze' ), 'before_widget' => '<section id="%1$s" class="amaaaze-widget %2$s">', 'after_widget' => "</section>", 'before_title' => '<h2 class="amaaaze-widget-title">', 'after_title' => "</h2>" ) ); register_sidebar( array( 'name' => esc_html__( 'Footer 3', 'amaaaze' ), 'id' => 'footer-sidebar-3', 'description' => esc_html__('Footer Sidebar 3', 'amaaaze' ), 'before_widget' => '<section id="%1$s" class="amaaaze-widget %2$s">', 'after_widget' => "</section>", 'before_title' => '<h2 class="amaaaze-widget-title">', 'after_title' => "</h2>" ) ); register_sidebar( array( 'name' => esc_html__( 'Footer 4', 'amaaaze' ), 'id' => 'footer-sidebar-4', 'description' => esc_html__('Footer Sidebar 4', 'amaaaze' ), 'before_widget' => '<section id="%1$s" class="amaaaze-widget %2$s">', 'after_widget' => "</section>", 'before_title' => '<h2 class="amaaaze-widget-title">', 'after_title' => "</h2>" ) ); } add_action( 'widgets_init', 'amaaaze_sidebar_init' ); /* ============================ BLOG LOOP CUSTOM FUNCTIONS ============================ */ // Filter the except length to 20 characters. function amaaaze_custom_excerpt_length( $length ) { if ( is_admin() ) return $length; return 45; } add_filter( 'excerpt_length', 'amaaaze_custom_excerpt_length', 999 ); function amaaaze_posted_meta(){ /* Get the year, month, and day of the current post. */ $archive_year = get_the_time('Y'); $archive_month = get_the_time('M'); $archive_day = get_the_time('d'); $posted_on = '<a href="'. esc_url(get_day_link( $archive_month, $archive_year, $archive_day)) .'">'. get_the_date('d M Y') .'</a>'; $comments_num = get_comments_number(); if( comments_open() ){ if( $comments_num == 0 ){ $comments = esc_html__('0', 'amaaaze' ); } elseif( $comments_num > 1 ){ $comments = $comments_num . esc_html__(' Comments', 'amaaaze' ); } else{ $comments = esc_html__('1 ', 'amaaaze' ); } $comments = '<a class="comments-link" href="' . esc_url(get_comments_link()) . '"> <span class="amaaaze-icon fa fa-comments"></span> '. $comments . '</a>'; }else{ $comments = esc_html__('Comments are closed', 'amaaaze' ); } $categories = get_the_category(); $seperator = ", "; $output = ''; $i = 1; if( !empty($categories) ): foreach ($categories as $category) : if( $i > 1 ): $output .= $seperator; endif; $output .= '<a href="'. esc_url( get_category_link( $category->term_id ) ) .'"> <span class="fa fa-flag-o"></span> ' . esc_html( $category->name ) . '</a>'; $i++; endforeach; endif; return '<span class="posted-by">' . get_the_author_posts_link() .'</span> <span class="posted-on">' . $posted_on . '</span> <span class="posted-in">' .$output. '</span><span>'.get_the_tag_list('<span class="tags-list">', ', ', '</span>').'</span>'; } function amaaaze_post_date(){ $archive_year = get_the_time('Y'); $archive_month = get_the_time('m'); $archive_day = get_the_time('d'); $posted_on = '<a href="'. esc_url(get_day_link( $archive_year, $archive_month, $archive_day)) .'">'. get_the_date() .'</a>'; echo $posted_on; } function amaaaze_post_category(){ $output = ''; $i = 1; $seperator = ", "; $categories = get_the_category(); if( !empty($categories) ): foreach ($categories as $category) : if( $i > 1 ): $output .= $seperator; endif; $output .= '<span><a href="'. esc_url( get_category_link( $category->term_id ) ) .'">' . esc_html( $category->name ) . '</span></a>'; $i++; endforeach; endif; echo $output; } function amaaaze_posted_footer(){ $comments_num = get_comments_number(); if( comments_open() ){ if( $comments_num == 0 ){ $comments = esc_html__('No Comments', 'amaaaze' ); } elseif( $comments_num > 1 ){ $comments = $comments_num . esc_html__(' Comments', 'amaaaze' ); } else{ $comments = esc_html__('1 Comment', 'amaaaze' ); } $comments = '<a class="comments-link" href="' . esc_url(get_comments_link()) . '">'. $comments . '</a>'; }else{ $comments = esc_html__('Comments are closed', 'amaaaze' ); } return '<div class="post-footer-container"> <div class="row"> <div class="col-xs-12 text-left"><div class="comments-counter-list"> '. $comments .' </div></div> </div> </div>'; } function amaaaze_single_posted_meta(){ /* Get the year, month, and day of the current post. */ $archive_year = get_the_time('Y'); $archive_month = get_the_time('m'); $archive_day = get_the_time('d'); $posted_on = '<a href="'. get_day_link( $archive_year, $archive_month, $archive_day) .'">'. get_the_date() .'</a>'; $categories = get_the_category(); $seperator = ", "; $output = ''; $i = 1; if( !empty($categories) ): foreach ($categories as $category) : if( $i > 1 ): $output .= $seperator; endif; $output .= '<a href="'. esc_url( get_category_link( $category->term_id ) ) .'" alt="'. esc_attr( 'View all post in%s', $category->name ) .'">' . esc_html( $category->name ) . '</a>'; $i++; endforeach; endif; $comments_num = get_comments_number(); if( comments_open() ){ if( $comments_num == 0 ){ $comments = esc_html__('No Comments', 'amaaaze' ); } elseif( $comments_num > 1 ){ $comments = $comments_num . esc_html__(' Comments', 'amaaaze' ); } else{ $comments = esc_html__('1 Comment', 'amaaaze' ); } $comments = '<a class="comments-link" href="' . get_comments_link() . '">'. $comments . '</a>'; }else{ $comments = esc_html__('Comments are closed', 'amaaaze' ); } return '<span class="posted-on"> <a href="'. esc_url( get_permalink() ) .'">' . $posted_on . '</a></span><span class="posted-by">' . get_the_author_posts_link() .'</span><span class="comments-counter-list">'. $comments .'</span><span class="posted-in">' .$output. '</span> '. get_the_tag_list('<span class="tags-list">', ', ', '</span>'); } //Post formats /* ------------------- GALLERY POST FORMAT ------------------- */ function amaaaze_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 amaaaze_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; } /* ------------------- AUDIO AND VIDEO POST FORMAT ------------------- */ function amaaaze_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 amaaaze_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( 'amaaaze_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" . '<div id="chat-transcript-' . esc_attr( get_the_ID() ) . '" class="chat-transcript">'; /* Split the content to get individual chat rows. */ $chat_rows = preg_split( "/(\r?\n)+|(<br\s*\/?>\s*)+/", $content ); /* 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 = amaaaze_format_chat_row_id( $chat_author ); /* Open the chat row. */ $chat_output .= "\n\t\t\t\t" . '<div class="chat-row ' . sanitize_html_class( "chat-speaker-{$speaker_id}" ) . '">'; /* Add the chat row author. */ $chat_output .= "\n\t\t\t\t\t" . '<div class="chat-author ' . sanitize_html_class( strtolower( "chat-author-{$chat_author}" ) ) . ' vcard"><cite class="fn">' . apply_filters( 'amaaaze_post_format_chat_author', $chat_author, $speaker_id ) . '</cite>' . $separator . '</div>'; /* Add the chat row text. */ $chat_output .= "\n\t\t\t\t\t" . '<div class="chat-text">' . str_replace( array( "\r", "\n", "\t" ), '', apply_filters( 'amaaaze_post_format_chat_text', $chat_text, $chat_author, $speaker_id ) ) . '</div>'; /* Close the chat row. */ $chat_output .= "\n\t\t\t\t" . '</div><!-- .chat-row -->'; } /** * 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" . '<div class="chat-row ' . sanitize_html_class( "chat-speaker-{$speaker_id}" ) . '">'; /* 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" . '<div class="chat-text">' . str_replace( array( "\r", "\n", "\t" ), '', apply_filters( 'amaaaze_post_format_chat_text', $chat_row, $chat_author, $speaker_id ) ) . '</div>'; /* Close the chat row. */ $chat_output .= "\n\t\t\t</div><!-- .chat-row -->"; } } } /* Close the chat transcript div. */ $chat_output .= "\n\t\t\t</div><!-- .chat-transcript -->\n"; /* Return the chat content and apply filters for developers. */ return apply_filters( 'amaaaze_post_format_chat_content', $chat_output ); } add_filter( 'the_content', 'amaaaze_format_chat_content' ); add_filter( 'amaaaze_post_format_chat_text', 'wpautop' ); function amaaaze_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; } /* ------------------- LINK POST FORMAT ------------------- */ function amaaaze_grab_url(){ if( ! preg_match('/<a\s[^>]*?href=[\'"](.+?)[\'"]/i', get_the_content(), $links ) ){ return false; } return esc_url_raw( $links[1] ); } /* ------------------- Grab current uri ------------------- */ function amaaaze_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 amaaaze_post_navigation(){ $nav = '<div class="post-navigation"><div class="row">'; $prev = get_previous_post_link( '<div class="post-link-nav"><span class="previous">%link</span></div>', '%title' ); $nav .= '<div class="col-xs-12 col-sm-6">' . $prev . '</div>'; $next = get_next_post_link( '<div class="post-link-nav"><span class="next">%link</span></div>', '%title' ); $nav .= '<div class="col-xs-12 col-sm-6 text-right">' . $next . '</div>'; $nav .= '</div></div>'; return $nav; } function amaaaze_get_post_navigation(){ if( get_comment_pages_count() > 1 && get_option('page_comments') ): require get_template_directory() . '/inc/templates/amaaaze-comment-nav.php'; endif; } // Add our function to the post content filter function amaaaze_author_info_box() { global $post; // Detect if it is a single post with a post author if ( is_single() && isset( $post->post_author ) ) { $author_details = ''; $user_content = ''; // 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)); if ( ! empty( $user_description ) ) { // Author avatar and bio $author_details = '<div class="amaaaze-author-image">' . get_avatar( get_the_author_meta('user_email') , 90 ) . '</div>'; $author_details .= '<div class="amaaaze-author-description">' . nl2br( $user_description ). '</div>'; $author_details .= '<div class="amaaaze-author-name"><a href="'. $user_posts .'">' . $display_name . '</a>'; // Check if author has a website in their profile if ( ! empty( $user_website ) ) { // Display author website link $author_details .= ' | <a href="' . $user_website .'" target="_blank" rel="nofollow">' . esc_html__('Website ', 'amaaaze') . '</a></div>'; } else { // if there is no author website then just close the paragraph $author_details .= '</div>'; } // Pass all this info to post content $user_content = '<div class="amaaaze-author-block text-center"><footer class="author_bio_section" >' . $author_details . '</footer></div>'; } } return $user_content; }