first commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Author bio template
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Only display for standard posts.
|
||||
if ( 'post' !== get_post_type() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get author data.
|
||||
$author = get_the_author();
|
||||
$description = get_the_author_meta( 'description' );
|
||||
$url = esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) );
|
||||
|
||||
// Only display if author has a description.
|
||||
if ( ! $description ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php do_action( 'ocean_before_single_post_author_bio' ); ?>
|
||||
|
||||
<section id="author-bio" class="clr">
|
||||
|
||||
<div id="author-bio-inner">
|
||||
|
||||
<div class="author-bio-avatar">
|
||||
|
||||
<a href="<?php echo esc_url( $url ); ?>" title="<?php esc_attr_e( 'Visit Author Page', 'oceanwp' ); ?>" rel="author" >
|
||||
<?php
|
||||
// Display author avatar.
|
||||
echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'ocean_author_bio_avatar_size', 100 ) );
|
||||
?>
|
||||
</a>
|
||||
|
||||
</div><!-- .author-bio-avatar -->
|
||||
|
||||
<div class="author-bio-content clr">
|
||||
|
||||
<h4 class="author-bio-title">
|
||||
<a href="<?php echo esc_url( $url ); ?>" title="<?php esc_attr_e( 'Visit Author Page', 'oceanwp' ); ?>">
|
||||
<?php echo esc_html( wp_strip_all_tags( $author ) ); ?>
|
||||
</a>
|
||||
</h4><!-- .author-bio-title -->
|
||||
|
||||
<?php
|
||||
// Outputs the author description if one exists.
|
||||
if ( $description ) :
|
||||
?>
|
||||
|
||||
<div class="author-bio-description clr">
|
||||
<?php echo wp_kses_post( $description ); ?>
|
||||
</div><!-- author-bio-description -->
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div><!-- #author-bio-inner -->
|
||||
|
||||
</section><!-- #author-bio -->
|
||||
|
||||
<?php do_action( 'ocean_after_single_post_author_bio' ); ?>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Post single content
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php do_action( 'ocean_before_single_post_content' ); ?>
|
||||
|
||||
<div class="entry-content clr"<?php oceanwp_schema_markup( 'entry_content' ); ?>>
|
||||
<?php
|
||||
the_content();
|
||||
|
||||
wp_link_pages(
|
||||
array(
|
||||
'before' => '<div class="page-links">' . __( 'Pages:', 'oceanwp' ),
|
||||
'after' => '</div>',
|
||||
'link_before' => '<span class="page-number">',
|
||||
'link_after' => '</span>',
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
</div><!-- .entry -->
|
||||
|
||||
<?php do_action( 'ocean_after_single_post_content' ); ?>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Displays the post header
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return if quote format.
|
||||
if ( 'quote' === get_post_format() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Heading tag.
|
||||
$heading = get_theme_mod( 'ocean_single_post_heading_tag', 'h2' );
|
||||
$heading = $heading ? $heading : 'h2';
|
||||
$heading = apply_filters( 'ocean_single_post_heading', $heading );
|
||||
|
||||
?>
|
||||
|
||||
<?php do_action( 'ocean_before_single_post_title' ); ?>
|
||||
|
||||
<header class="entry-header clr">
|
||||
<<?php echo esc_attr( $heading ); ?> class="single-post-title entry-title"<?php oceanwp_schema_markup( 'headline' ); ?>><?php the_title(); ?></<?php echo esc_attr( $heading ); ?>><!-- .single-post-title -->
|
||||
</header><!-- .entry-header -->
|
||||
|
||||
<?php do_action( 'ocean_after_single_post_title' ); ?>
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Single post layout
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<article id="post-<?php the_ID(); ?>">
|
||||
|
||||
<?php
|
||||
// Get posts format.
|
||||
$format = get_post_format();
|
||||
|
||||
// Get elements.
|
||||
$elements = oceanwp_blog_single_elements_positioning();
|
||||
|
||||
// Loop through elements.
|
||||
foreach ( $elements as $element ) {
|
||||
|
||||
// Featured Image.
|
||||
if ( 'featured_image' === $element
|
||||
&& ! post_password_required() ) {
|
||||
|
||||
$format = $format ? $format : 'thumbnail';
|
||||
|
||||
get_template_part( 'partials/single/media/blog-single', $format );
|
||||
|
||||
}
|
||||
|
||||
// Title.
|
||||
if ( 'title' === $element ) {
|
||||
|
||||
get_template_part( 'partials/single/header' );
|
||||
|
||||
}
|
||||
|
||||
// Meta.
|
||||
if ( 'meta' === $element ) {
|
||||
|
||||
get_template_part( 'partials/single/meta' );
|
||||
|
||||
}
|
||||
|
||||
// Content.
|
||||
if ( 'content' === $element ) {
|
||||
|
||||
get_template_part( 'partials/single/content' );
|
||||
|
||||
}
|
||||
|
||||
// Tags.
|
||||
if ( 'tags' === $element ) {
|
||||
|
||||
get_template_part( 'partials/single/tags' );
|
||||
|
||||
}
|
||||
|
||||
// Social Share.
|
||||
if ( 'social_share' === $element
|
||||
&& OCEAN_EXTRA_ACTIVE ) {
|
||||
|
||||
do_action( 'ocean_social_share' );
|
||||
|
||||
}
|
||||
|
||||
// Next/Prev.
|
||||
if ( 'next_prev' === $element ) {
|
||||
|
||||
get_template_part( 'partials/single/next-prev' );
|
||||
|
||||
}
|
||||
|
||||
// Author Box.
|
||||
if ( 'author_box' === $element ) {
|
||||
|
||||
get_template_part( 'partials/single/author-bio' );
|
||||
|
||||
}
|
||||
|
||||
// Related Posts.
|
||||
if ( 'related_posts' === $element ) {
|
||||
|
||||
get_template_part( 'partials/single/related-posts' );
|
||||
|
||||
}
|
||||
|
||||
// Comments.
|
||||
if ( 'single_comments' === $element ) {
|
||||
|
||||
comments_template();
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
</article>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog single audio format media
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return if Ocean Extra is not active.
|
||||
if ( ! OCEAN_EXTRA_ACTIVE ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get audio html.
|
||||
$audio = oceanwp_get_post_audio_html();
|
||||
|
||||
// Display audio if audio exists and the post isn't protected.
|
||||
if ( $audio && ! post_password_required() ) :
|
||||
?>
|
||||
|
||||
<div id="post-media" class="thumbnail clr">
|
||||
<div class="blog-post-audio clr"><?php echo $audio; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// Else display post thumbnail.
|
||||
else :
|
||||
|
||||
get_template_part( 'partials/single/media/blog-single' );
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog single gallery format media
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return if Ocean Extra is not active.
|
||||
if ( ! OCEAN_EXTRA_ACTIVE ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get attachments.
|
||||
$attachments = oceanwp_get_gallery_ids( get_the_ID() );
|
||||
|
||||
// Return standard entry style if password protected or there aren't any attachments.
|
||||
if ( post_password_required() || empty( $attachments ) ) {
|
||||
get_template_part( 'partials/single/media/blog-single' );
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="thumbnail">
|
||||
|
||||
<div class="gallery-format clr">
|
||||
|
||||
<?php
|
||||
// Loop through each attachment ID.
|
||||
foreach ( $attachments as $attachment ) :
|
||||
|
||||
// Get attachment data.
|
||||
$attachment_title = get_the_title( $attachment );
|
||||
$attachment_alt = get_post_meta( $attachment, '_wp_attachment_image_alt', true );
|
||||
$attachment_alt = $attachment_alt ? $attachment_alt : $attachment_title;
|
||||
|
||||
// Get image output.
|
||||
$attachment_html = wp_get_attachment_image(
|
||||
$attachment,
|
||||
'full',
|
||||
'',
|
||||
array(
|
||||
'alt' => $attachment_alt,
|
||||
'itemprop' => 'image',
|
||||
)
|
||||
);
|
||||
|
||||
// Display with lightbox.
|
||||
if ( oceanwp_gallery_is_lightbox_enabled() === 'on' ) :
|
||||
?>
|
||||
|
||||
<a href="<?php echo esc_url( wp_get_attachment_url( $attachment ) ); ?>" title="<?php echo esc_attr( $attachment_alt ); ?>" class="gallery-lightbox">
|
||||
<?php echo wp_kses_post( $attachment_html ); ?>
|
||||
</a>
|
||||
|
||||
<?php
|
||||
// Display single image.
|
||||
else :
|
||||
|
||||
echo wp_kses_post( $attachment_html );
|
||||
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog single link format media
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return if there isn't a thumbnail defined.
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Image args.
|
||||
$img_args = array(
|
||||
'alt' => get_the_title(),
|
||||
);
|
||||
|
||||
if ( oceanwp_get_schema_markup( 'image' ) ) {
|
||||
$img_args['itemprop'] = 'image';
|
||||
}
|
||||
|
||||
// Caption.
|
||||
$caption = get_the_post_thumbnail_caption();
|
||||
|
||||
?>
|
||||
|
||||
<div class="thumbnail">
|
||||
|
||||
<?php
|
||||
// Display post thumbnail.
|
||||
the_post_thumbnail( 'full', $img_args );
|
||||
|
||||
// Caption.
|
||||
if ( $caption ) {
|
||||
?>
|
||||
<div class="thumbnail-caption">
|
||||
<?php echo wp_kses_post( $caption ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="link-entry clr">
|
||||
|
||||
<a href="<?php echo esc_url( get_post_meta( get_the_ID(), 'ocean_link_format', true ) ); ?>" target="_<?php echo esc_attr( get_post_meta( get_the_ID(), 'ocean_link_format_target', true ) ); ?>"><i class="icon-link"></i></a>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog single quote format
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return if Ocean Extra is not active.
|
||||
if ( ! OCEAN_EXTRA_ACTIVE ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="post-quote-wrap">
|
||||
|
||||
<div class="post-quote-content">
|
||||
|
||||
<?php echo wp_kses_post( get_post_meta( get_the_ID(), 'ocean_quote_format', true ) ); ?>
|
||||
|
||||
<span class="post-quote-icon icon-speech"></span>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="post-quote-author"><?php the_title(); ?></div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog single video format media
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return if Ocean Extra is not active.
|
||||
if ( ! OCEAN_EXTRA_ACTIVE ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get post video.
|
||||
$video = oceanwp_get_post_video_html();
|
||||
|
||||
// Display video if one exists and it's not a password protected post.
|
||||
if ( $video && ! post_password_required() ) :
|
||||
|
||||
?>
|
||||
<div id="post-media" class="thumbnail clr">
|
||||
|
||||
<div class="blog-post-video">
|
||||
|
||||
<?php echo $video; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
|
||||
</div><!-- .blog-post-video -->
|
||||
|
||||
</div><!-- #post-media -->
|
||||
<?php
|
||||
|
||||
// Else display post thumbnail.
|
||||
else :
|
||||
|
||||
get_template_part( 'partials/single/media/blog-single' );
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Displays the post single thumbmnail
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Return if there isn't a thumbnail defined.
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// LLMS Integration.
|
||||
if ( OCEANWP_LIFTERLMS_ACTIVE ) {
|
||||
$details = get_theme_mod( 'ocean_llms_course_details', array( 'image', 'description', 'meta', 'author', 'progress', 'syllabus' ) );
|
||||
|
||||
if ( is_course() && ! in_array( 'image', $details, true ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_membership() && ! ( get_theme_mod( 'ocean_llms_membership_image', false ) ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Image args.
|
||||
$img_args = array(
|
||||
'alt' => get_the_title(),
|
||||
);
|
||||
|
||||
if ( oceanwp_get_schema_markup( 'image' ) ) {
|
||||
$img_args['itemprop'] = 'image';
|
||||
}
|
||||
|
||||
// Caption.
|
||||
$caption = get_the_post_thumbnail_caption();
|
||||
|
||||
?>
|
||||
|
||||
<div class="thumbnail">
|
||||
|
||||
<?php
|
||||
// Display post thumbnail.
|
||||
the_post_thumbnail( 'full', $img_args );
|
||||
|
||||
// Caption.
|
||||
if ( $caption ) {
|
||||
?>
|
||||
<div class="thumbnail-caption">
|
||||
<?php echo wp_kses_post( $caption ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div><!-- .thumbnail -->
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Post single meta
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get meta sections.
|
||||
$sections = oceanwp_blog_single_meta();
|
||||
|
||||
// Return if sections are empty.
|
||||
if ( empty( $sections )
|
||||
|| 'post' !== get_post_type() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Return if quote format.
|
||||
if ( 'quote' === get_post_format() ) {
|
||||
return;
|
||||
} ?>
|
||||
|
||||
<?php do_action( 'ocean_before_single_post_meta' ); ?>
|
||||
|
||||
<ul class="meta clr">
|
||||
|
||||
<?php
|
||||
// Loop through meta sections.
|
||||
foreach ( $sections as $section ) {
|
||||
?>
|
||||
|
||||
<?php if ( 'author' === $section ) { ?>
|
||||
<li class="meta-author"<?php oceanwp_schema_markup( 'author_name' ); ?>><span class="screen-reader-text"><?php esc_html_e( 'Post author:', 'oceanwp' ); ?></span><i class="icon-user" aria-hidden="true"></i><?php echo esc_html( the_author_posts_link() ); ?></li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( 'date' === $section ) { ?>
|
||||
<li class="meta-date"<?php oceanwp_schema_markup( 'publish_date' ); ?>><span class="screen-reader-text"><?php esc_html_e( 'Post published:', 'oceanwp' ); ?></span><i class="icon-clock" aria-hidden="true"></i><?php echo get_the_date(); ?></li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( 'mod-date' === $section ) { ?>
|
||||
<li class="meta-mod-date"<?php oceanwp_schema_markup( 'modified_date' ); ?>><span class="screen-reader-text"><?php esc_html_e( 'Post last modified:', 'oceanwp' ); ?></span><i class="icon-note" aria-hidden="true"></i><?php echo esc_html( get_the_modified_date() ); ?></li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( 'categories' === $section ) { ?>
|
||||
<li class="meta-cat"><span class="screen-reader-text"><?php esc_html_e( 'Post category:', 'oceanwp' ); ?></span><i class="icon-folder" aria-hidden="true"></i><?php the_category( ' <span class="owp-sep">/</span> ', get_the_ID() ); ?></li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( 'reading-time' === $section ) { ?>
|
||||
<li class="meta-cat"><span class="screen-reader-text"><?php esc_html_e( 'Reading time:', 'oceanwp' ); ?></span><i class="icon-cup" aria-hidden="true"></i><?php echo esc_attr( ocean_reading_time() ); ?></li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( 'comments' === $section && comments_open() && ! post_password_required() ) { ?>
|
||||
<li class="meta-comments"><span class="screen-reader-text"><?php esc_html_e( 'Post comments:', 'oceanwp' ); ?></span><i class="icon-bubble" aria-hidden="true"></i><?php comments_popup_link( esc_html__( '0 Comments', 'oceanwp' ), esc_html__( '1 Comment', 'oceanwp' ), esc_html__( '% Comments', 'oceanwp' ), 'comments-link' ); ?></li>
|
||||
<?php } ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</ul>
|
||||
|
||||
<?php do_action( 'ocean_after_single_post_meta' ); ?>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* The next/previous links to go to another post.
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Only display for standard posts.
|
||||
if ( 'post' !== get_post_type() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Term.
|
||||
$term_tax = get_theme_mod( 'ocean_single_post_next_prev_taxonomy', 'post_tag' );
|
||||
$term_tax = $term_tax ? $term_tax : 'post_tag';
|
||||
|
||||
// Vars.
|
||||
$prev_text = '<span class="title"><i class="fas fa-long-arrow-alt-left" aria-hidden="true"></i>' . oceanwp_theme_strings( 'owp-string-single-prev-post', false, 'oceanwp' ) . '</span><span class="post-title">%title</span>';
|
||||
$next_text = '<span class="title"><i class="fas fa-long-arrow-alt-right" aria-hidden="true"></i>' . oceanwp_theme_strings( 'owp-string-single-next-post', false, 'oceanwp' ) . '</span><span class="post-title">%title</span>';
|
||||
$screen_rt = oceanwp_theme_strings( 'owp-string-single-screen-reader-rm', false, 'oceanwp' );
|
||||
|
||||
// Args.
|
||||
if ( 'pub-date' === $term_tax ) {
|
||||
$args = array(
|
||||
'prev_text' => $prev_text,
|
||||
'next_text' => $next_text,
|
||||
'in_same_term' => false,
|
||||
'screen_reader_text' => $screen_rt,
|
||||
);
|
||||
} else {
|
||||
$args = array(
|
||||
'prev_text' => $prev_text,
|
||||
'next_text' => $next_text,
|
||||
'in_same_term' => true,
|
||||
'taxonomy' => $term_tax,
|
||||
'screen_reader_text' => $screen_rt,
|
||||
);
|
||||
}
|
||||
|
||||
// Display Next/Prev navigation.
|
||||
$args = apply_filters( 'ocean_single_post_next_prev_args', $args ); ?>
|
||||
|
||||
<?php do_action( 'ocean_before_single_post_next_prev' ); ?>
|
||||
|
||||
<?php the_post_navigation( $args ); ?>
|
||||
|
||||
<?php
|
||||
|
||||
do_action( 'ocean_after_single_post_next_prev' );
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/**
|
||||
* Single related posts
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Only display for standard posts.
|
||||
if ( 'post' !== get_post_type() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Number of columns for entries.
|
||||
$oceanwp_columns = apply_filters( 'ocean_related_blog_posts_columns', absint( get_theme_mod( 'ocean_blog_related_columns', '3' ) ) );
|
||||
|
||||
// Term.
|
||||
$term_tax = get_theme_mod( 'ocean_blog_related_taxonomy', 'category' );
|
||||
$term_tax = $term_tax ? $term_tax : 'category';
|
||||
|
||||
// Create an array of current term ID's.
|
||||
$terms = wp_get_post_terms( get_the_ID(), $term_tax );
|
||||
$terms_ids = array();
|
||||
foreach ( $terms as $termkey ) {
|
||||
$terms_ids[] = $termkey->term_id;
|
||||
}
|
||||
|
||||
// Query args.
|
||||
$args = array(
|
||||
'posts_per_page' => apply_filters( 'ocean_related_blog_posts_count', absint( get_theme_mod( 'ocean_blog_related_count', '3' ) ) ),
|
||||
'orderby' => 'rand',
|
||||
'post__not_in' => array( get_the_ID() ),
|
||||
'no_found_rows' => true,
|
||||
'tax_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'taxonomy' => 'post_format',
|
||||
'field' => 'slug',
|
||||
'terms' => array( 'post-format-quote', 'post-format-link' ),
|
||||
'operator' => 'NOT IN',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// If category.
|
||||
if ( 'category' === $term_tax ) {
|
||||
$args['category__in'] = $terms_ids;
|
||||
}
|
||||
|
||||
// If tags.
|
||||
if ( 'post_tag' === $term_tax ) {
|
||||
$args['tag__in'] = $terms_ids;
|
||||
}
|
||||
|
||||
// Args.
|
||||
$args = apply_filters( 'ocean_blog_post_related_query_args', $args );
|
||||
|
||||
do_action( 'ocean_before_single_post_related_posts' );
|
||||
|
||||
// Related query arguments.
|
||||
$oceanwp_related_query = new WP_Query( $args );
|
||||
|
||||
// If the custom query returns post display related posts section.
|
||||
if ( $oceanwp_related_query->have_posts() ) :
|
||||
|
||||
// Wrapper classes.
|
||||
$classes = 'clr';
|
||||
if ( 'full-screen' === oceanwp_post_layout() ) {
|
||||
$classes .= ' container';
|
||||
} ?>
|
||||
|
||||
<section id="related-posts" class="<?php echo esc_attr( $classes ); ?>">
|
||||
|
||||
<h3 class="theme-heading related-posts-title">
|
||||
<span class="text"><?php oceanwp_theme_strings( 'owp-string-single-related-posts', 'oceanwp' ); ?></span>
|
||||
</h3>
|
||||
|
||||
<div class="oceanwp-row clr">
|
||||
|
||||
<?php $oceanwp_count = 0; ?>
|
||||
|
||||
<?php
|
||||
foreach ( $oceanwp_related_query->posts as $post ) :
|
||||
setup_postdata( $post );
|
||||
?>
|
||||
|
||||
<?php
|
||||
$oceanwp_count++;
|
||||
|
||||
// Disable embeds.
|
||||
$show_embeds = apply_filters( 'ocean_related_blog_posts_embeds', false );
|
||||
|
||||
// Get post format.
|
||||
$format = get_post_format();
|
||||
|
||||
// Add classes.
|
||||
$classes = array( 'related-post', 'clr', 'col' );
|
||||
$classes[] = oceanwp_grid_class( $oceanwp_columns );
|
||||
$classes[] = 'col-' . $oceanwp_count;
|
||||
?>
|
||||
|
||||
<article <?php post_class( $classes ); ?>>
|
||||
|
||||
<?php
|
||||
// Display post video.
|
||||
if ( $show_embeds && 'video' === $format && oceanwp_get_post_video_html() === $video ) :
|
||||
?>
|
||||
|
||||
<div class="related-post-video">
|
||||
<?php echo $video; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div><!-- .related-post-video -->
|
||||
|
||||
<?php
|
||||
// Display post audio.
|
||||
elseif ( $show_embeds && 'audio' === $format && oceanwp_get_post_audio_html() === $audio ) :
|
||||
?>
|
||||
|
||||
<div class="related-post-video">
|
||||
<?php echo $audio; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div><!-- .related-post-audio -->
|
||||
|
||||
<?php
|
||||
// Display post thumbnail.
|
||||
elseif ( has_post_thumbnail() ) :
|
||||
?>
|
||||
|
||||
<figure class="related-post-media clr">
|
||||
|
||||
<a href="<?php the_permalink(); ?>" class="related-thumb">
|
||||
|
||||
<?php
|
||||
// Image width.
|
||||
$img_width = apply_filters( 'ocean_related_blog_posts_img_width', absint( get_theme_mod( 'ocean_blog_related_img_width' ) ) );
|
||||
$img_height = apply_filters( 'ocean_related_blog_posts_img_height', absint( get_theme_mod( 'ocean_blog_related_img_height' ) ) );
|
||||
|
||||
// Images attr.
|
||||
$img_id = get_post_thumbnail_id( get_the_ID(), 'full' );
|
||||
$img_url = wp_get_attachment_image_src( $img_id, 'full', true );
|
||||
if ( OCEAN_EXTRA_ACTIVE
|
||||
&& function_exists( 'ocean_extra_image_attributes' ) ) {
|
||||
$img_atts = ocean_extra_image_attributes( $img_url[1], $img_url[2], $img_width, $img_height );
|
||||
}
|
||||
|
||||
// If Ocean Extra is active and has a custom size.
|
||||
if ( OCEAN_EXTRA_ACTIVE
|
||||
&& function_exists( 'ocean_extra_resize' )
|
||||
&& ! empty( $img_atts ) ) {
|
||||
?>
|
||||
|
||||
<img src="<?php echo ocean_extra_resize( $img_url[0], $img_atts['width'], $img_atts['height'], $img_atts['crop'], true, $img_atts['upscale'] ); ?>" alt="<?php the_title_attribute(); ?>" width="<?php echo esc_attr( $img_width ); ?>" height="<?php echo esc_attr( $img_height ); ?>"<?php oceanwp_schema_markup( 'image' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> />
|
||||
|
||||
<?php
|
||||
} else {
|
||||
|
||||
// Images size.
|
||||
if ( 'full-width' === oceanwp_post_layout()
|
||||
|| 'full-screen' === oceanwp_post_layout() ) {
|
||||
$size = 'medium_large';
|
||||
} else {
|
||||
$size = 'medium';
|
||||
}
|
||||
|
||||
// Image args.
|
||||
$img_args = array(
|
||||
'alt' => get_the_title(),
|
||||
);
|
||||
if ( oceanwp_get_schema_markup( 'image' ) ) {
|
||||
$img_args['itemprop'] = 'image';
|
||||
}
|
||||
|
||||
// Display post thumbnail.
|
||||
the_post_thumbnail( $size, $img_args );
|
||||
|
||||
}
|
||||
?>
|
||||
</a>
|
||||
|
||||
</figure>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<h3 class="related-post-title">
|
||||
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a>
|
||||
</h3><!-- .related-post-title -->
|
||||
|
||||
<time class="published" datetime="<?php echo esc_html( get_the_date( 'c' ) ); ?>"><i class="icon-clock" aria-hidden="true"></i><?php echo esc_html( get_the_date() ); ?></time>
|
||||
|
||||
</article><!-- .related-post -->
|
||||
|
||||
<?php
|
||||
if ( $oceanwp_columns === $oceanwp_count ) {
|
||||
$oceanwp_count = 0;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div><!-- .oceanwp-row -->
|
||||
|
||||
</section><!-- .related-posts -->
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php wp_reset_postdata(); ?>
|
||||
|
||||
<?php do_action( 'ocean_after_single_post_related_posts' ); ?>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog single tags
|
||||
*
|
||||
* @package OceanWP WordPress theme
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Display tags. ?>
|
||||
<div class="post-tags clr">
|
||||
<?php the_tags( '<span class="owp-tag-text">' . esc_attr__( 'Tags: ', 'oceanwp' ) . '</span>', '<span class="owp-sep">,</span> ', '' ); ?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user