%2$s', esc_url( get_permalink( get_the_ID() ) ), /* translators: %s: Name of current post */ sprintf( __( 'Continue reading %s', 'begro' ), '' . get_the_title( get_the_ID() ) . '' ) ); return ' … ' . $link; } add_filter( 'excerpt_more', 'begro_excerpt_more' ); endif; function custom_excerpt_length( $length ) { return 50; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); add_theme_support( 'title-tag' ); // Enqueue editor styles. add_editor_style( 'style-editor.css' ); load_theme_textdomain( "begro", get_template_directory() . '/languages' ); /* Activate Nav Menu Option */ function mi_register_nav_menu(){ //add_theme_support( 'menus' ); register_nav_menus( array( 'primary' => __( 'Header Navigation Menu', "begro" ), 'full-screen-menu' => __( 'Full Screen Navigation Menu', "begro" ), 'footer-menu' => __( 'Footer Navigation Menu', "begro" ) ) ); } add_action( 'after_setup_theme','mi_register_nav_menu' ); /* Activate HTML5 features */ add_theme_support('html5', array('comment-list', 'comment-form', 'search-form', 'gallery', 'caption')); /* ======================== BLOG LOOP CUSTOM FUNCTIONS ======================== */ function mi_posted_meta() { $posted_on = human_time_diff(get_the_time('U'), current_time('timestamp')); $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; echo 'Posted '.$posted_on.' ago / '.$output.''; } function mi_posted_footer($onlyComments = false) { $comments_num = get_comments_number(); if (comments_open()) { if ($comments_num == 0) { $comments = __('No Comments',"begro"); } elseif ($comments_num > 1) { $comments = $comments_num.__(' Comments',"begro"); } else { $comments = __('1 Comment',"begro"); } $comments = ''.$comments.' '; } else { $comments = __('Comments are closed',"begro"); } if ($onlyComments) { echo $comments; } echo '
'; } function mi_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 mi_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: echo $output = (($embed[0])?$embed[0]:''); endif; return $output; } function mi_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 mi_grab_url() { /* if (!preg_match('/]*?href=[\'"](.+?)[\'"]/i', get_the_content(), $links)) { return false; } //var_dump($links); return $links[1];*/ } function mi_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 mi_post_navigation() { $nav = '' . __( 'Pages:', "begro" ), 'after' => '
', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __( 'Next page', "begro"), 'previouspagelink' => __( 'Previous page', "begro" ), 'pagelink' => '%', 'echo' => 1 ); wp_link_pages( $defaults ); ?> $minLength); } } // Replaces the excerpt "Read More" text by a link if (!function_exists('mi_excerpt_more')) { function mi_excerpt_more($more) { global $post; return ' Read the full article...'; } add_filter('excerpt_more', 'mi_excerpt_more'); }