__('Header Menu', 'variantlp'), 'footer_menu' => __('Footer Menu', 'variantlp'), )); /** * Support exerpt on page */ add_post_type_support('page', 'excerpt'); // Enable support for HTML5 markup. add_theme_support('html5', array( 'comment-list', 'search-form', 'comment-form', 'gallery', 'caption', )); } endif; /* landing_page_theme_setup */ add_action('after_setup_theme', 'variantlp_theme_setup'); if (!isset($content_width)) $content_width = 1150; /** * Enqueue styles */ function variantlp_styles() { if (!is_front_page() || !is_home()) { wp_enqueue_style('variantlp-bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css'); wp_enqueue_style('variantlp-raleway-font', 'http://fonts.googleapis.com/css?family=Raleway:500,600,700,100,800,900,400,200,300'); wp_register_style('variantlp-style', get_stylesheet_uri()); wp_enqueue_style('variantlp-style', get_stylesheet_uri()); } } add_action('wp_enqueue_scripts', 'variantlp_styles'); /** * Default nav fallback */ function variantlp_nav_fallback() { ?> 'header_menu', 'container_id' => 'menu', 'menu_class' => 'variantmenu', 'fallback_cb' => 'variantlp_nav_fallback')); } function variantlp_footer_nav() { wp_nav_menu(array('theme_location' => 'footer_menu', 'container_id' => 'footer_menu',)); } /** * For attachment page */ if (!function_exists('variantlp_posted_in')) : /** * Prints HTML with meta information for the current post (category, tags and permalink). * */ function variantlp_posted_in() { // Retrieves tag list of current post, separated by commas. $tag_list = get_the_tag_list('', ', '); if ($tag_list) { $posted_in = __('This entry was posted in %1$s and tagged %2$s. Bookmark the permalink.', 'variantlp'); } elseif (is_object_in_taxonomy(get_post_type(), 'category')) { $posted_in = __('This entry was posted in %1$s. Bookmark the permalink.', 'variantlp'); } else { $posted_in = __('Bookmark the permalink.', 'variantlp'); } // Prints the string, replacing the placeholders. printf( $posted_in, get_the_category_list(', '), $tag_list, get_permalink(), the_title_attribute('echo=0') ); } endif; /** * Pagination */ function variantlp_pagination($pages = '', $range = 2) { $showitems = ($range * 2) + 1; global $paged; if (empty($paged)) $paged = 1; if ($pages == '') { global $wp_query; $pages = $wp_query->max_num_pages; if (!$pages) { $pages = 1; } } echo paginate_links(array('total' => $pages, 'prev_text' => '«', 'next_text' => '»', 'type' => 'list')); } /** * Breadcrumbs * @global type $post * @global type $wp_query * @global type $author */ function variantlp_breadcrumbs() { $delimiter = '»'; $home = 'Home'; // text for the 'Home' link $before = ''; // tag before the current crumb $after = ''; // tag after the current crumb echo '
'; global $post; $homeLink = home_url(); echo '' . $home . ' ' . $delimiter . ' '; if (is_category()) { global $wp_query; $cat_obj = $wp_query->get_queried_object(); $thisCat = $cat_obj->term_id; $thisCat = get_category($thisCat); $parentCat = get_category($thisCat->parent); if ($thisCat->parent != 0) echo(get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' ')); echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after; } elseif (is_day()) { echo '' . get_the_time('Y') . ' ' . $delimiter . ' '; echo '' . get_the_time('F') . ' ' . $delimiter . ' '; echo $before . get_the_time('d') . $after; } elseif (is_month()) { echo '' . get_the_time('Y') . ' ' . $delimiter . ' '; echo $before . get_the_time('F') . $after; } elseif (is_year()) { echo $before . get_the_time('Y') . $after; } elseif (is_single() && !is_attachment()) { if (get_post_type() != 'post') { $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; echo '' . $post_type->labels->singular_name . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } else { $cat = get_the_category(); $cat = $cat[0]; echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); echo $before . get_the_title() . $after; } } elseif (!is_single() && !is_page() && get_post_type() != 'post') { $post_type = get_post_type_object(get_post_type()); echo $before . $post_type->labels->singular_name . $after; } elseif (is_attachment()) { $parent = get_post($post->post_parent); $cat = get_the_category($parent->ID); $cat = $cat[0]; echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); echo '' . $parent->post_title . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } elseif (is_page() && !$post->post_parent) { echo $before . get_the_title() . $after; } elseif (is_page() && $post->post_parent) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '' . get_the_title($page->ID) . ''; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); foreach ($breadcrumbs as $crumb) echo $crumb . ' ' . $delimiter . ' '; echo $before . get_the_title() . $after; } elseif (is_search()) { echo $before . 'Search results for "' . get_search_query() . '"' . $after; } elseif (is_tag()) { echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after; } elseif (is_author()) { global $author; $userdata = get_userdata($author); echo $before . 'Articles posted by ' . $userdata->display_name . $after; } elseif (is_404()) { echo $before . 'Error 404' . $after; } if (get_query_var('paged')) { if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) echo ' ('; echo __('Page', 'swiftray') . ' ' . get_query_var('paged'); if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) echo ')'; } echo '
'; } /** * This function thumbnail id and * returns thumbnail image * @param type $iw * @param type $ih */ function variantlp_get_thumbnail($iw, $ih) { global $post; $permalink = get_permalink(); $thumb = get_post_thumbnail_id(); $image = variantlp_thumbnail_resize($thumb, '', $iw, $ih, true, 90); if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail())) { print "" . get_the_title($post->ID) . ""; } } /** * This function gets image width and height and * Prints attached images from the post */ function variantlp_get_image($width, $height) { $w = $width; $h = $height; global $post, $posts; //This is required to set to Null $img_source = ''; $permalink = get_permalink(); ob_start(); ob_end_clean(); $output = preg_match_all('//i', $post->post_content, $matches); if (isset($matches [1] [0])) { $img_source = $matches [1] [0]; } $img_path = variantlp_image_resize($img_source, $w, $h); if (!empty($img_path['url'])) { print "Post Image"; } } /** * Portfolio Image */ function variantlp_blog_image($imgwh, $imght) { global $post, $posts; //This is required to set to Null $id = ''; $the_title = ''; // Till Here $permalink = get_permalink(); $homeLink = get_template_directory_uri(); $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('//i', $post->post_content, $matches); if (isset($matches [1] [0])) { $first_img = $matches [1] [0]; } if (!empty($first_img)) { //Defines a default image print "$the_title"; } } /** * Alter default excerpt length */ function variantlp_excerpt_length($length) { return 160; } add_filter('excerpt_length', 'variantlp_excerpt_length'); /** * Enqueue scripts and styles. */ function variantlp_scripts() { if (!is_front_page() || !is_home()) { wp_enqueue_script('variantlp-menu', get_template_directory_uri() . '/assets/js/variantmenu.js', array('variantlp-scripts'), '1.0', true); wp_register_script('variantlp-scripts', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), '1.0', true); wp_enqueue_script('variantlp-scripts-init', get_template_directory_uri() . '/assets/js/init.js', array('variantlp-scripts'), '1.0', true); if (is_singular() && get_option('thread_comments')) wp_enqueue_script('comment-reply'); } } add_action('wp_enqueue_scripts', 'variantlp_scripts'); /** * Custom excerpt */ function variantlp_trim_excerpt($length) { global $post; $explicit_excerpt = $post->post_excerpt; if ('' == $explicit_excerpt) { $text = get_the_content(''); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); } else { $text = apply_filters('the_content', '

' . $explicit_excerpt . '

'); } if ('' == $explicit_excerpt) { $text = strip_tags($text); } $text = strip_shortcodes($text); // optional $excerpt_length = $length; $words = explode(' ', $text, $excerpt_length + 1); if (count($words) > $excerpt_length) { array_pop($words); array_push($words, '[…]'); $text = implode(' ', $words); $text = apply_filters('the_excerpt', $text); } return $text; }