<span class="entry-title-meta-author"><?php 
                    independent_publisher_posted_author();
                    ?>
</span> <?php 
                    echo independent_publisher_entry_meta_category_prefix();
                    ?>
 <?php 
                    echo independent_publisher_post_categories('', true);
                    ?>
													<span class="entry-title-meta-post-date">
														<span class="sep"> <?php 
                    echo apply_filters('independent_publisher_entry_meta_separator', '|');
                    ?>
 </span>
														<?php 
                    independent_publisher_posted_on_date();
                    ?>
													</span>
													<?php 
                    do_action('independent_publisher_entry_title_meta', $separator = ' | ');
                    ?>
												</h2>
											<?php 
                }
                ?>
											<h1 class="entry-title">
												<a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                echo esc_attr(sprintf(__('Permalink to %s', 'independent-publisher'), the_title_attribute('echo=0')));
Example #2
0
/**
 * Show Full Width Featured Image on single pages if post has full width featured image selected
 * or if Auto-Set Featured Image as Post Cover option is enabled
 */
function independent_publisher_full_width_featured_image()
{
    if (true || independent_publisher_has_full_width_featured_image()) {
        while (have_posts()) {
            the_post();
            if (true || has_post_thumbnail()) {
                if (true || independent_publisher_post_has_post_cover_title()) {
                    //tevkori_get_srcset_array( $id, $size = 'thumbnail' ) {
                    //global $wpdb;
                    $postCoverTitleWrapperExtraClass = "postCoverTitleAlwaysBelow";
                    $showPostCover = false;
                    echo "<style>\n";
                    if (independent_publisher_has_full_width_featured_image() && has_post_thumbnail()) {
                        $showPostCover = true;
                        $tempSources = tevkori_get_srcset_array(get_post_thumbnail_id(), 'full');
                        //sources aren't automatically in numeric order.  ksort does the trick.
                        ksort($tempSources);
                        $counter = 0;
                        $prevWidth = 0;
                        // Let's prevent any images with width > 1200px from being an output as part of responsive post cover
                        foreach ($tempSources as $key => $tempSource) {
                            if ($key > 1900) {
                                unset($tempSources[$key]);
                            }
                        }
                        foreach ($tempSources as $key => $tempSource) {
                            //we're working with an array of sourceset entries ... gotta get rid of the width part
                            $counter++;
                            $tempSource = preg_replace('/(.*)\\s(.*)/', '$1', $tempSource);
                            if ($counter == 1) {
                                echo "\t.postCoverResponsive { background-image: url({$tempSource}) !important; }\n";
                            } elseif ($counter < count($tempSources)) {
                                echo "\t@media (min-width: " . ($prevWidth + 1) . "px) and (max-width: " . $key . "px) {\n";
                                echo "\t\t.postCoverResponsive { background-image: url({$tempSource}) !important; }\n";
                                echo "\t}\n";
                            } else {
                                echo "\t@media (min-width: " . ($prevWidth + 1) . "px) {\n";
                                echo "\t\t.postCoverResponsive { background-image: url({$tempSource}) !important; }\n";
                                echo "\t}\n";
                            }
                            $prevWidth = $key;
                        }
                        $featured_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), apply_filters('independent_publisher_full_width_featured_image_size', 'independent_publisher_post_thumbnail'));
                        $featured_image_url = $featured_image_url[0];
                        $post_has_cover_title_rize = get_post_meta(get_the_ID(), 'post_cover_overlay_post_title_rize', true);
                        if ($post_has_cover_title_rize === '1' || $post_has_cover_title_rize === 'true') {
                            $postCoverTitleWrapperExtraClass = "";
                        }
                    }
                    echo "</style>\n";
                    $featuredImageCaptionRaw = "";
                    $featuredImageCaption = "";
                    $featuredImageAltCaption = "";
                    $featuredImageCredit = "";
                    $featuredImageCreditLink = "";
                    $featured_image_data = get_post(get_post_thumbnail_id());
                    /* var_dump($featured_image_data); */
                    if ($featured_image_data) {
                        $featuredImageCaptionRaw = $featured_image_data->post_excerpt;
                        $featuredImageCredit = get_post_meta(get_post_thumbnail_id(), '_wp_attachment_source_name', true);
                        $featuredImageCreditLink = get_post_meta(get_post_thumbnail_id(), '_wp_attachment_source_url', true);
                        /** if we have either a caption or a credit, we're going to show the <p> **/
                        if ($featuredImageCaptionRaw != "" || $featuredImageCredit != "") {
                            $featuredImageCaption = "<p id='featuredCutline' class='wp-caption-text'>";
                            $featuredImageAltCaption = "<p id='featuredAltCutline' class='wp-caption-text'>";
                            if ($featuredImageCaptionRaw != "") {
                                $featuredImageCaption .= $featuredImageCaptionRaw;
                                $featuredImageAltCaption .= $featuredImageCaptionRaw;
                            }
                            if ($featuredImageCredit != "") {
                                if ($featuredImageCreditLink != "") {
                                    $featuredImageCaption .= " <a class='featuredCutlineCredit' href='{$featuredImageCreditLink}'>{$featuredImageCredit}</a>";
                                    $featuredImageAltCaption .= " <a class='featuredAltCutlineCredit' href='{$featuredImageCreditLink}'>{$featuredImageCredit}</a>";
                                } else {
                                    $featuredImageCaption .= " <span class='featuredCutlineCredit'>{$featuredImageCredit}</span>";
                                    $featuredImageAltCaption .= " <span class='featuredAltCutlineCredit'>{$featuredImageCredit}</span>";
                                }
                            }
                            $featuredImageCaption .= "</p>";
                            $featuredImageAltCaption .= "</p>";
                        }
                    }
                    /*** PREPARE TWITTER AND FB SHARE URLS ****/
                    $shareLink = get_permalink();
                    global $pageBodyID;
                    if ($pageBodyID == "newsletter") {
                        global $newsletterPostPermalink;
                        $shareLink = $newsletterPostPermalink;
                    }
                    /* remove html tags, smart quotes and trailing ellipses from description */
                    $ogDescription = independent_publisher_first_sentence_excerpt();
                    $ogDescription = wp_strip_all_tags($ogDescription);
                    $ogDescription = iconv('UTF-8', 'ASCII//TRANSLIT', $ogDescription);
                    //smart quotes
                    $ogDescription = str_replace("[&hellip;]", "...", $ogDescription);
                    //the title/headline field, followed by the URL and the author's twitter handle
                    $twitterText = "";
                    $twitterText .= html_entity_decode(get_the_title());
                    $twitterHandle = get_the_author_meta('twitterHandle');
                    $twitterHandle = str_replace("@", "", $twitterHandle);
                    if ($twitterHandle && $twitterHandle != '') {
                        $twitterText .= " by @" . $twitterHandle;
                    } else {
                        $authorDisplayName = get_the_author();
                        if ($authorDisplayName && $authorDisplayName != '') {
                            $twitterText .= " by " . $authorDisplayName;
                        }
                    }
                    $twitterText .= " " . $shareLink;
                    $hashtags = "";
                    //$hashtags="testhashtag1,testhashtag2";
                    ///$twitterURL="//twitter.com/intent/tweet?url=" . urlencode(get_permalink()) . "&text=" . urlencode($ogDescription) . "&hashtags=" . urlencode($hashtags);
                    $twitterURL = "//twitter.com/intent/tweet?text=" . rawurlencode($twitterText);
                    $fbUrl = "//www.facebook.com/sharer/sharer.php?u=" . urlencode($shareLink);
                    ?>
						<div class="post-cover-title-wrapper <?php 
                    echo $postCoverTitleWrapperExtraClass;
                    ?>
">
							<?php 
                    if ($showPostCover) {
                        ?>
							<div class="post-cover-title-image postCoverResponsive" ></div>
							<?php 
                    }
                    ?>

							<?php 
                    if (independent_publisher_categorized_blog()) {
                        echo independent_publisher_series_category('', false);
                    }
                    ?>
								<div class="post-cover-title-head">
									<header class="post-cover-title">
										<?php 
                    if (independent_publisher_categorized_blog()) {
                        ?>
										
										<?php 
                        if (independent_publisher_has_full_width_featured_image()) {
                            echo $featuredImageCaption;
                        }
                        ?>

		
										<?php 
                        if (true || $pageBodyID != "newsletter") {
                            ?>
											<?php 
                            echo independent_publisher_post_categories('', false);
                            ?>
										<?php 
                        }
                        ?>

										<div id='socialPost'>
											<ul>
												<li class='facebook'><a class="share" id="facebook" href="<?php 
                        echo $fbUrl;
                        ?>
"></a></li>
												<li class='twitter'><a class="share" id="twitter" href="<?php 
                        echo $twitterURL;
                        ?>
"></a></li>
											</ul>
										</div>

										<?php 
                    }
                    ?>

										<?php 
                    if (true || $pageBodyID != "newsletter") {
                        ?>
											<h1 class="entry-title" itemprop="name">
												<?php 
                        echo get_the_title();
                        ?>
											</h1>
										<?php 
                    }
                    ?>
										
										<?php 
                    $subtitle = get_post_meta(get_the_id(), 'independent_publisher_post_cover_subtitle', true);
                    ?>
										<?php 
                    if ($subtitle) {
                        ?>
											<h2 class="entry-subtitle">
												<?php 
                        echo $subtitle;
                        ?>
											</h2>
										<?php 
                    }
                    ?>
										<?php 
                    if ($pageBodyID == "newsletter" || !is_page()) {
                        ?>
											<h3 class="entry-title-meta">
												<span class="entry-title-meta-author">
													<a class="author-avatar" href="<?php 
                        echo get_author_posts_url(get_the_author_meta('ID'));
                        ?>
">
														<?php 
                        echo get_avatar(get_the_author_meta('ID'), 32);
                        ?>
													</a>
													<?php 
                        if (!independent_publisher_categorized_blog()) {
                            echo independent_publisher_entry_meta_author_prefix() . ' ';
                        }
                        independent_publisher_posted_author();
                        ?>
												</span>
												<?php 
                        /* if ( independent_publisher_categorized_blog() ) {
                        				echo independent_publisher_entry_meta_category_prefix() . ' ' . independent_publisher_post_categories( '', true );
                        			} */
                        ?>
												<span class="entry-title-meta-post-date">
													<span class="sep"> <?php 
                        echo apply_filters('independent_publisher_entry_meta_separator', '|');
                        ?>
 </span>
													<?php 
                        independent_publisher_posted_on_date();
                        ?>
 
												</span>
												<?php 
                        do_action('independent_publisher_entry_title_meta', $separator = ' | ');
                        ?>
											</h3>
										<?php 
                    }
                    ?>
									</header>
								</div>

							</div>
							<?php 
                    /*Add second caption below the header div for tablet 500 - 1200px widths  views*/
                    if (independent_publisher_has_full_width_featured_image() && $postCoverTitleWrapperExtraClass != "postCoverTitleAlwaysBelow") {
                        echo $featuredImageAltCaption;
                    }
                    ?>
					<?php 
                } else {
                    the_post_thumbnail(apply_filters('independent_publisher_full_width_featured_image_size', 'independent_publisher_post_thumbnail'), array('class' => 'full-width-featured-image'));
                }
            }
        }
        // end of the loop.
    }
}
    /**
     * Show Full Width Featured Image on single pages if post has full width featured image selected
     * or if Auto-Set Featured Image as Post Cover option is enabled
     */
    function independent_publisher_full_width_featured_image()
    {
        if (independent_publisher_has_full_width_featured_image()) {
            while (have_posts()) {
                the_post();
                if (has_post_thumbnail()) {
                    if (independent_publisher_post_has_post_cover_title()) {
                        $featured_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), apply_filters('independent_publisher_full_width_featured_image_size', 'independent_publisher_post_thumbnail'));
                        $featured_image_url = $featured_image_url[0];
                        ?>
						<div class="post-cover-title-wrapper">
							<div class="post-cover-title-image" style="background-image:url('<?php 
                        echo $featured_image_url;
                        ?>
');"></div>
								<div class="post-cover-title-head">
									<header class="post-cover-title">
										<h1 class="entry-title" itemprop="name">
											<?php 
                        echo get_the_title();
                        ?>
										</h1>
										<?php 
                        $subtitle = get_post_meta(get_the_id(), 'independent_publisher_post_cover_subtitle', true);
                        ?>
										<?php 
                        if ($subtitle) {
                            ?>
											<h2 class="entry-subtitle">
												<?php 
                            echo $subtitle;
                            ?>
											</h2>
										<?php 
                        }
                        ?>
										<?php 
                        if (!is_page()) {
                            ?>
											<h3 class="entry-title-meta">
												<span class="entry-title-meta-author">
													<a class="author-avatar" href="<?php 
                            echo get_author_posts_url(get_the_author_meta('ID'));
                            ?>
">
														<?php 
                            echo get_avatar(get_the_author_meta('ID'), 32);
                            ?>
													</a>
													<?php 
                            if (!independent_publisher_categorized_blog()) {
                                echo independent_publisher_entry_meta_author_prefix() . ' ';
                            }
                            independent_publisher_posted_author();
                            ?>
												</span>
												<?php 
                            if (independent_publisher_categorized_blog()) {
                                echo independent_publisher_entry_meta_category_prefix() . ' ' . independent_publisher_post_categories('', true);
                            }
                            ?>
												<span class="entry-title-meta-post-date">
													<span class="sep"> <?php 
                            echo apply_filters('independent_publisher_entry_meta_separator', '|');
                            ?>
 </span>
													<?php 
                            independent_publisher_posted_on_date();
                            ?>
												</span>
												<?php 
                            do_action('independent_publisher_entry_title_meta', $separator = ' | ');
                            ?>
											</h3>
										<?php 
                        }
                        ?>
									</header>
								</div>
							</div>
					<?php 
                    } else {
                        the_post_thumbnail(apply_filters('independent_publisher_full_width_featured_image_size', 'independent_publisher_post_thumbnail'), array('class' => 'full-width-featured-image'));
                    }
                }
            }
            // end of the loop.
        }
    }
/**
 * Show Full Width Featured Image on single pages if post has full width featured image selected
 * or if Auto-Set Featured Image as Post Cover option is enabled
 */
function independent_publisher_full_width_featured_image()
{
    if (independent_publisher_has_full_width_featured_image()) {
        while (have_posts()) {
            the_post();
            if (has_post_thumbnail()) {
                if (independent_publisher_post_has_post_cover_title()) {
                    //tevkori_get_srcset_array( $id, $size = 'thumbnail' ) {
                    //global $wpdb;
                    $tempSources = tevkori_get_srcset_array(get_post_thumbnail_id(), 'full');
                    //sources aren't automatically in numeric order.  ksort does the trick.
                    ksort($tempSources);
                    echo "<style>\n";
                    $counter = 0;
                    $prevWidth = 0;
                    foreach ($tempSources as $key => $tempSource) {
                        //we're workign with an array of sourceset entries ... gotta get rid of the width part
                        $counter++;
                        $tempSource = preg_replace('/(.*)\\s(.*)/', '$1', $tempSource);
                        if ($counter == 1) {
                            echo "\t.postCoverResponsive { background-image: url({$tempSource}) !important; }\n";
                        } elseif ($counter < count($tempSources)) {
                            echo "\t@media (min-width: " . ($prevWidth + 1) . "px) and (max-width: " . $key . "px) {\n";
                            echo "\t\t.postCoverResponsive { background-image: url({$tempSource}) !important; }\n";
                            echo "\t}\n";
                        } else {
                            echo "\t@media (min-width: " . ($prevWidth + 1) . "px) {\n";
                            echo "\t\t.postCoverResponsive { background-image: url({$tempSource}) !important; }\n";
                            echo "\t}\n";
                        }
                        $prevWidth = $key;
                    }
                    echo "</style>\n";
                    $featured_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), apply_filters('independent_publisher_full_width_featured_image_size', 'independent_publisher_post_thumbnail'));
                    $featured_image_url = $featured_image_url[0];
                    ?>
						<div class="post-cover-title-wrapper">
							<div class="post-cover-title-image postCoverResponsive" ></div>
								<div class="post-cover-title-head">
									<header class="post-cover-title">
										<h1 class="entry-title" itemprop="name">
											<?php 
                    echo get_the_title();
                    ?>
										</h1>
										<?php 
                    $subtitle = get_post_meta(get_the_id(), 'independent_publisher_post_cover_subtitle', true);
                    ?>
										<?php 
                    if ($subtitle) {
                        ?>
											<h2 class="entry-subtitle">
												<?php 
                        echo $subtitle;
                        ?>
											</h2>
										<?php 
                    }
                    ?>
										<?php 
                    if (!is_page()) {
                        ?>
											<h3 class="entry-title-meta">
												<span class="entry-title-meta-author">
													<a class="author-avatar" href="<?php 
                        echo get_author_posts_url(get_the_author_meta('ID'));
                        ?>
">
														<?php 
                        echo get_avatar(get_the_author_meta('ID'), 32);
                        ?>
													</a>
													<?php 
                        if (!independent_publisher_categorized_blog()) {
                            echo independent_publisher_entry_meta_author_prefix() . ' ';
                        }
                        independent_publisher_posted_author();
                        ?>
												</span>
												<?php 
                        if (independent_publisher_categorized_blog()) {
                            echo independent_publisher_entry_meta_category_prefix() . ' ' . independent_publisher_post_categories('', true);
                        }
                        ?>
												<span class="entry-title-meta-post-date">
													<span class="sep"> <?php 
                        echo apply_filters('independent_publisher_entry_meta_separator', '|');
                        ?>
 </span>
													<?php 
                        independent_publisher_posted_on_date();
                        ?>
												</span>
												<?php 
                        do_action('independent_publisher_entry_title_meta', $separator = ' | ');
                        ?>
											</h3>
										<?php 
                    }
                    ?>
									</header>
								</div>
							</div>
					<?php 
                } else {
                    the_post_thumbnail(apply_filters('independent_publisher_full_width_featured_image_size', 'independent_publisher_post_thumbnail'), array('class' => 'full-width-featured-image'));
                }
            }
        }
        // end of the loop.
    }
}