'; $delimiter = ' » '; $homeLink = home_url(); if (is_home() || is_front_page()) { // no need for breadcrumbs in homepage } else { echo '
'; // main breadcrumbs lead to homepage if (!is_single()) { echo 'You are here: '; } echo '' . '' . $home . '' . '' . $delimiter . ' '; // if blog page exists if (get_page_by_path('blog')) { if (!is_page('blog')) { echo '' . 'Blog' . $delimiter . ' '; } } if (is_category()) { $thisCat = get_category(get_query_var('cat'), false); if ($thisCat->parent != 0) { $category_link = get_category_link($thisCat->parent); echo '' . '' . get_cat_name($thisCat->parent) . '' . '' . $delimiter . ' '; } $category_id = get_cat_ID(single_cat_title('', false)); $category_link = get_category_link($category_id); echo '' . '' . single_cat_title('', false) . '' . ''; } 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 . '' . ''; echo ' ' . $delimiter . ' ' . get_the_title(); } else { $category = get_the_category(); if ($category) { foreach ($category as $cat) { echo '' . '' . $cat->name . '' . '' . $delimiter . ' '; } } echo get_the_title(); } } elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) { $post_type = get_post_type_object(get_post_type()); echo $post_type->labels->singular_name; } 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 . '' . ''; echo ' ' . $delimiter . ' ' . get_the_title(); } elseif (is_page() && !$post->post_parent) { $get_post_slug = $post->post_name; $post_slug = str_replace('-', ' ', $get_post_slug); echo '' . '' . ucfirst($post_slug) . '' . ''; } 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); for ($i = 0; $i < count($breadcrumbs); $i++) { echo $breadcrumbs[$i]; if ($i != count($breadcrumbs) - 1) echo ' ' . $delimiter . ' '; } echo $delimiter . '' . '' . the_title_attribute('echo=0') . '' . ''; } elseif (is_tag()) { $tag_id = get_term_by('name', single_cat_title('', false), 'post_tag'); if ($tag_id) { $tag_link = get_tag_link($tag_id->term_id); } echo '' . '' . single_cat_title('', false) . '' . ''; } elseif (is_author()) { global $author; $userdata = get_userdata($author); echo '' . '' . $userdata->display_name . '' . ''; } elseif (is_404()) { echo 'Error 404'; } elseif (is_search()) { echo 'Search results for "' . get_search_query() . '"'; } elseif (is_day()) { echo '' . '' . get_the_time('Y') . '' . '' . $delimiter . ' '; echo '' . '' . get_the_time('F') . '' . '' . $delimiter . ' '; echo '' . '' . get_the_time('d') . '' . ''; } elseif (is_month()) { echo '' . '' . get_the_time('Y') . '' . '' . $delimiter . ' '; echo '' . '' . get_the_time('F') . '' . ''; } elseif (is_year()) { echo '' . '' . get_the_time('Y') . '' . ''; } if (get_query_var('paged')) { if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) echo ' ('; echo __('Page' , 'blunk') . ' ' . get_query_var('paged'); if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author()) echo ')'; } echo '
'; } } // Add title tag backwards compatibility if ( ! function_exists( '_wp_render_title_tag' ) ) { function blunk_theme_slug_render_title() { ?> <?php wp_title('|', true, 'right'); ?> 'click', 'container' => 'posts', 'footer' => false, ) ); // Add navigation menu register_nav_menu( 'primary', __('Primary Menu','blunk') ); // Translation load_theme_textdomain('blunk', get_template_directory() . '/languages'); $locale = get_locale(); $locale_file = get_template_directory() . "/languages/$locale.php"; if ( is_readable($locale_file) ) require_once($locale_file); } // Register and enqueue Javascript files & supports add_action( 'wp_enqueue_scripts', 'blunk_load_javascript_files' ); function blunk_load_javascript_files() { if ( !is_admin() ) { wp_enqueue_script( 'blunk_doubletap', get_template_directory_uri().'/js/doubletaptogo.js', array('jquery'), '', true ); wp_enqueue_script( 'blunk_global', get_template_directory_uri().'/js/global.js', array('jquery'), '', true ); if ( is_singular() ) wp_enqueue_script( "comment-reply" ); } } // Register and enqueue styles and supports add_action('wp_enqueue_scripts', 'blunk_load_style'); function blunk_load_style() { if ( !is_admin() ) { wp_enqueue_style( 'blunk_googleFonts', '//fonts.googleapis.com/css?family=Lato:400,700,900|Playfair+Display:400,700,400italic' ); wp_enqueue_style( 'blunk_genericons', get_template_directory_uri() . '/genericons/genericons.css' ); wp_enqueue_style( 'blunk_style', get_stylesheet_uri() ); } } // Add editor styles, please! add_action( 'init', 'blunk_add_editor_styles' ); function blunk_add_editor_styles() { add_editor_style( 'blunk-editor-styles.css' ); $font_url = '//fonts.googleapis.com/css?family=Lato:400,700,900|Playfair+Display:400,700,400italic'; add_editor_style( str_replace( ',', '%2C', $font_url ) ); } // Add footer widget area add_action( 'widgets_init', 'blunk_sidebar_reg' ); function blunk_sidebar_reg() { register_sidebar(array( 'name' => __( 'Footer One', 'blunk' ), 'id' => 'footer-one', 'description' => __( 'Widgets in this area will be shown in the left footer column.', 'blunk' ), 'before_title' => '

', 'after_title' => '

', 'before_widget' => '
', 'after_widget' => '
' )); register_sidebar(array( 'name' => __( 'Footer Two', 'blunk' ), 'id' => 'footer-two', 'description' => __( 'Widgets in this area will be shown in the middle footer column.', 'blunk' ), 'before_title' => '

', 'after_title' => '

', 'before_widget' => '
', 'after_widget' => '
' )); register_sidebar(array( 'name' => __( 'Footer Three', 'blunk' ), 'id' => 'footer-three', 'description' => __( 'Widgets in this area will be shown in the right footer column.', 'blunk' ), 'before_title' => '

', 'after_title' => '

', 'before_widget' => '
', 'after_widget' => '
' )); } // Does the browser support JavaScript? Check! add_action( 'wp_head', 'html_js_class', 1 ); function html_js_class () { echo ''. "\n"; } // Archive navigation function here function blunk_archive_navigation() { global $wp_query; global $paged; if ( $wp_query->max_num_pages > 1 ) : ?>

max_num_pages ); ?>

' . __( 'Read More ' , 'your-text-domain' ) . ''; } add_filter( 'excerpt_more', 'new_excerpt_more' ); // Conditional tags for Excerpt if ( is_category() || is_archive() || is_search() || is_home() && is_front_page() ) { the_excerpt(); } else { the_content(); } // Excerpt Length function custom_excerpt_length( $length ) { return 70; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); // Add body class if is_single and has_featured_image with conditional tag add_filter('body_class','blunk_is_single_featured_image'); function blunk_is_single_featured_image( $classes ){ if ( is_single() && has_post_thumbnail() ){ $classes[] = 'has-featured-image'; } return $classes; } // Get comment excerpt length here function blunk_get_comment_excerpt($comment_ID = 0, $num_words = 20) { $comment = get_comment( $comment_ID ); $comment_text = strip_tags($comment->comment_content); $blah = explode(' ', $comment_text); if (count($blah) > $num_words) { $k = $num_words; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } $excerpt = ''; for ($i=0; $i<$k; $i++) { $excerpt .= $blah[$i] . ' '; } $excerpt .= ($use_dotdotdot) ? '...' : ''; return apply_filters('get_comment_excerpt', $excerpt); } // Let's style the admin area add_action('admin_head', 'blunk_admin_area_style'); function blunk_admin_area_style() { echo ' '; } // Blunk comment function if ( ! function_exists( 'blunk_comment' ) ) : function blunk_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : ?>
  • id="comment-"> ', '' ); ?>
  • id="li-comment-">
    user_id === $post->post_author ) : ?>

      
    ', '' ); ?>
    comment_approved ) : ?>
    __('Reply','blunk'), 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '
    ', 'after' => '
    ' ) ); ?>
    add_section( 'blunk_options', array( 'title' => __( 'Options for blunk', 'blunk' ), //Visible title of section 'priority' => 35, //Determines what order this appears in 'capability' => 'edit_theme_options', //Capability needed to tweak 'description' => __('Allows you to customize theme settings for blunk.', 'blunk'), //Descriptive tooltip ) ); $wp_customize->add_section( 'blunk_logo_section' , array( 'title' => __( 'Branding', 'blunk' ), 'priority' => 30, 'description' => __('Upload a logo and favicon to replace the default site title in the header and site icon.', 'blunk'), ) ); //2. Register new settings to the WordPress database... $wp_customize->add_setting( 'accent_color', //No need to use a SERIALIZED name, as `theme_mod` settings already live under one db record array( 'default' => '#CA2017', //Default setting/value to save 'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? 'transport' => 'postMessage', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? 'sanitize_callback' => 'sanitize_hex_color' ) ); $wp_customize->add_setting( 'blunk_logo', array( 'sanitize_callback' => 'esc_url_raw' ) ); //3. Let's define the control itself $wp_customize->add_control( new WP_Customize_Color_Control( //Instantiate the color control class $wp_customize, //Pass the $wp_customize object (required) 'blunk_accent_color', //Set a unique ID for the control array( 'label' => __( 'Accent Color', 'blunk' ), //Admin-visible name of the control 'section' => 'colors', //ID of the section this control should render in (can be one of yours, or a WordPress default section) 'settings' => 'accent_color', //Which setting to load and manipulate (serialized is okay) 'priority' => 80, //Determines the order this control appears in for the specified section ) ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'blunk_logo', array( 'label' => __( 'Logo', 'blunk' ), 'section' => 'blunk_logo_section', 'settings' => 'blunk_logo', ) ) ); // Add Favicon Setting $wp_customize->add_setting( 'favicon' , array( 'default' => '' , 'sanitize_callback' => '__return_false', )); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'favicon', array( 'label' => __( 'Custom Favicon', 'blunk' ), 'section' => 'blunk_logo_section', 'settings' => 'favicon' ) ) ); function blunk_favicon() { $favicon=get_theme_mod('favicon'); if ($favicon){ echo ''."\n"; } else{ ?> get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; } public static function blunk_header_output() { ?> add_section("extend", array( "title" => __("Trackcode & Styling", "customizer_analytics_sections"), "priority" => 80, ) ); $wp_customize->add_setting("analytics_code", array( "default" => "", "transport" => "refresh", 'sanitize_callback' => '__return_false', ) ); $wp_customize->add_control(new WP_Customize_Control( $wp_customize, "analytics_code", array( "label" => __("Google Analytics Tracking Code", "customizer_analytics_code_label"), "section" => "extend", "settings" => "analytics_code", "description" => "Paste Your Google Analytics Code Without < script > and < /script > tag", "type" => "textarea", ) ) ); // Add Custom Css $wp_customize->add_setting("css_style", array( "default" => "", "transport" => "refresh", 'sanitize_callback' => '__return_false', ) ); $wp_customize->add_control(new WP_Customize_Control( $wp_customize, "css_style", array( "label" => __("Custom CSS", "customizer_css_style_label"), "section" => "extend", "settings" => "css_style", "description" => "Enter your custom CSS Style here.", "type" => "textarea", ) ) ); } add_action("customize_register","blunk_customize_register"); // Rock & Roll with Fontawesome Icons function enqueue_our_required_stylesheets(){ wp_enqueue_style('font-awesome', get_stylesheet_directory_uri() . '/css/font-awesome.css'); } add_action('wp_enqueue_scripts','enqueue_our_required_stylesheets'); // No Self-Ping & Self-Trackback, Please! function no_self_ping( &$links ) { $home = home_url(); foreach ( $links as $l => $link ) if ( 0 === strpos( $link, $home ) ) unset($links[$l]); } add_action( 'pre_ping', 'no_self_ping' ); // Shortcode in Widget Area Roll On! add_filter( 'widget_text', array( $wp_embed, 'run_shortcode' ), 8 ); add_filter( 'widget_text', array( $wp_embed, 'autoembed'), 8 ); // Change 'Howdy' into 'Welcome' function howdy_message($translated_text, $text, $domain) { $new_message = str_replace('Howdy', 'Welcome', $text); return $new_message; } add_filter('gettext', 'howdy_message', 10, 3); // Function for Schema org Markup function html_tag_schema() { $schema = 'http://schema.org/'; // Is single post if(is_single()) { $type = "Article"; } // Is author page elseif( is_author() ) { $type = 'ProfilePage'; } // Is search results page elseif( is_search() ) { $type = 'SearchResultsPage'; } else { $type = 'WebPage'; } echo 'itemscope="itemscope" itemtype="' . $schema . $type . '"'; } // Enqueue Scripts/Styles for our Lightbox function blunk_add_lightbox() { wp_enqueue_script( 'fancybox', get_template_directory_uri() . '/inc/lightbox/js/jquery.fancybox.pack.js', array( 'jquery' ), false, true ); wp_enqueue_script( 'lightbox', get_template_directory_uri() . '/inc/lightbox/js/lightbox.js', array( 'fancybox' ), false, true ); wp_enqueue_style( 'lightbox-style', get_template_directory_uri() . '/inc/lightbox/css/jquery.fancybox.css' ); } add_action( 'wp_enqueue_scripts', 'blunk_add_lightbox' ); // Post Like add_action('wp_ajax_nopriv_post-like', 'post_like'); add_action('wp_ajax_post-like', 'post_like'); wp_enqueue_script('like_post', get_template_directory_uri().'/js/post-like.js', array('jquery'), '1.0', true ); wp_localize_script('like_post', 'ajax_var', array( 'url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('ajax-nonce') )); function post_like() { // Check for nonce security $nonce = $_POST['nonce']; if ( ! wp_verify_nonce( $nonce, 'ajax-nonce' ) ) die ( 'Busted!'); if(isset($_POST['post_like'])) { // Retrieve user IP address $ip = $_SERVER['REMOTE_ADDR']; $post_id = $_POST['post_id']; // Get voters'IPs for the current post $meta_IP = get_post_meta($post_id, "voted_IP"); $voted_IP = $meta_IP[0]; if(!is_array($voted_IP)) $voted_IP = array(); // Get votes count for the current post $meta_count = get_post_meta($post_id, "votes_count", true); // Use has already voted ? if(!hasAlreadyVoted($post_id)) { $voted_IP[$ip] = time(); // Save IP and increase votes count update_post_meta($post_id, "voted_IP", $voted_IP); update_post_meta($post_id, "votes_count", ++$meta_count); // Display count (ie jQuery return value) echo $meta_count; } else echo "already"; } exit; } function hasAlreadyVoted($post_id) { global $timebeforerevote; // Retrieve post votes IPs $meta_IP = get_post_meta($post_id, "voted_IP"); $voted_IP = $meta_IP[0]; if(!is_array($voted_IP)) $voted_IP = array(); // Retrieve current user IP $ip = $_SERVER['REMOTE_ADDR']; // If user has already voted if(in_array($ip, array_keys($voted_IP))) { $time = $voted_IP[$ip]; $now = time(); // Compare between current time and vote time if(round(($now - $time) / 60) > $timebeforerevote) return false; return true; } return false; } function getPostLikeLink($post_id) { $themename = "blunk"; $vote_count = get_post_meta($post_id, "votes_count", true); $output = '

    '; if(hasAlreadyVoted($post_id)) $output .= ' '; else $output .= ' '; $output .= ''.$vote_count.'

    '; return $output; } // Custom Sharing Buttons function blunk_social_sharing_buttons($content) { // Show this on post and page only. Add filter is_home() for home page if(is_singular()){ // Get current page URL $shortURL = get_permalink(); // Get current page title $shortTitle = get_the_title(); // Construct sharing URL without using any script $twitterURL = 'https://twitter.com/intent/tweet?text='.$shortTitle.'&url='.$shortURL.'&'; $facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$shortURL; $googleURL = 'https://plus.google.com/share?url='.$shortURL; $linkedinURL = 'http://www.linkedin.com/shareArticle?url='.$shortURL; // Add sharing button at the end of page/page content $content .= '
    '; $content .= '
    SHARE ON
     Twitter'; $content .= ' Facebook'; $content .= ' Google+'; $content .= ' Linkedin'; $content .= '
    '; return $content; }else{ // if not post/page then don't include sharing button return $content; } }; add_filter( 'the_content', 'blunk_social_sharing_buttons'); function __return_false_value($value) { return $value; } add_filter('__return_false', '__return_false_value'); ?>