'', 'width' => 1080, 'height' => 300, 'flex-height' => false, 'flex-width' => false, 'uploads' => true, 'random-default' => false, 'header-text' => true, 'default-text-color' => '', 'wp-head-callback' => '', 'admin-head-callback' => '', 'admin-preview-callback' => '', ); add_theme_support( 'custom-header', $defaults ); } add_theme_support( 'post-thumbnails' ); function achilles_register_nav_menu() { register_nav_menu( 'primary', 'Header Navigation Menu' ); $second_menu = get_option( 'secondary_menu' ); if(@$second_menu == 1){ register_nav_menu( 'below_content', 'Menu Below Content' ); } } add_action( 'after_setup_theme', 'achilles_register_nav_menu' ); /* ======================== BLOG LOOP CUSTOM FUNCTIONS ======================== */ function achilles_posted_meta(){ $posted_on = human_time_diff( get_the_time('U') , current_time('timestamp') ); $author = ''. get_the_author() .''; $avatar = '' . get_avatar(get_the_author_meta("ID"), 15) . ''; $categories = get_the_category(); $separator = ', '; $output = ''; $i = 1; if( !empty($categories) ): foreach( $categories as $category ): if( $i > 1 ): $output .= $separator; endif; $output .= '' . esc_html( $category->name ) .''; $i++; endforeach; endif; //check output for / at the end without anything else $checkFooterSlash = $author . $avatar . ' / ' . $output; if($output == ''){ $slash = ''; }else{ $slash = ' / '; } //Check if home posts meta are enabled $enabled_posts_home = esc_attr( get_option( 'meta_text_posts_home') ); $checked_home = (@$enabled_posts_home == '1' ? 'checked' : ''); if($checked_home){ if(is_single() || is_page()){ return; }else{ return 'Posted ' . $posted_on . ' ago by '.$author.' ' . $avatar . $slash .' ' . $output . ''; } } //Check if posts meta are enabled $enabled_posts = esc_attr( get_option( 'meta_text_posts') ); $checked = (@$enabled_posts == '1' ? 'checked' : ''); if($checked){ return 'Posted ' . $posted_on . ' ago by '.$author.' ' . $avatar . $slash .' ' . $output . ''; }else{ return; } } function achilles_posted_footer(){ $comments_num = get_comments_number(); if( comments_open() ){ if( $comments_num == 0 ){ $comments = __('No Comments' , 'achilles'); } elseif ( $comments_num > 1 ){ $comments= $comments_num . __(' Comments' , 'achilles'); } else { $comments = __('1 Comment' , 'achilles'); } $comments = ''. $comments .' '; } else { $comments = __('Comments are closed' , 'achilles'); } return '
'; } function achilles_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_status' => null, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => $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 achilles_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: $output = $embed[0]; endif; return $output; } function achilles_grab_url(){ $regex = '/]*?href=[\'"](.+?)[\'"]/i'; if( !preg_match($regex, get_the_content(), $links )){ return false; } return esc_url_raw( $links[1] ); } function achilles_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 ); $nextImg = 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' => $nextImg, 'prev_img' => $prevImg, 'caption' => $attachments[$i]->post_excerpt ); endfor; return $output; } function achilles_has_shortcode(){ $post_to_check = get_post(get_the_ID()); $found = false; $pattern = '/^\[[a-z]*/i'; if(preg_match($pattern, get_the_content() ) ){ $found = true; } return $found; } //Theme share social buttons function share_social_links(){ ?>