<?php /** * @package oxford */ $post_class = 'full-width'; if (oxford_get_featured_image_ids(get_the_ID(), 'large')) { $post_class .= ' has-featured-image'; } ?> <article id="post-<?php the_ID(); ?> " <?php post_class($post_class); ?> > <header class="entry-header"> <?php get_template_part('_post', 'title'); ?> <?php get_template_part('_post', 'sticky'); ?> <?php get_template_part('_post', 'date'); ?> <?php if (!post_password_required() && comments_open() && get_comments_number() > 0) { ?>
<?php /** * @package oxford */ // Meta will be displayed vertically if the 'no-vertical-meta' theme option is false $vertical = !get_theme_mod('no-vertical-meta'); // Post classes $post_class = ''; $image_ids = oxford_get_featured_image_ids(get_the_ID()); $too_small = array_keys($image_ids, 0); if (count($image_ids) > count($too_small)) { $post_class = 'has-featured-image'; } ?> <article id="post-<?php the_ID(); ?> " <?php post_class($post_class); ?> > <div class="entry-content<?php if (oxford_get_post_char_count() >= oxford_get_post_char_threshold() && !oxford_get_post_meta('settings', get_the_ID(), 'post-single-column')) { echo ' content-columns'; } ?> "> <header class="entry-header"> <?php
/** * Set the excerpt length * * @since 1.0. * * @param int $length The excerpt length * @return int The modified excerpt length */ function oxford_excerpt_length($length) { global $post; $image_ids = oxford_get_featured_image_ids($post->ID); if (empty($image_ids)) { $length = 100; } return $length; }
/** * Render the archive view HTML markup for the first suitable featured image in the given post. * * @since 1.0. * * @param int $post_id The id of the post to get the featured image from. * @param string $size The defined image size to use for the featured image. * @return string The HTML markup. */ function oxford_get_the_archive_featured_image($post_id = 0, $size = 'oxford_medium') { $html = ''; // Sanitize and validate the post id if (0 === absint($post_id)) { $post_id = get_the_ID(); } // Get the selected image ids $image_ids = oxford_get_featured_image_ids($post_id); if (!empty($image_ids)) { $html .= '<div class="selected-images">'; // Count array items before array_shift $image_count = count($image_ids); $image_id = absint(array_shift($image_ids)); $image_html = wp_get_attachment_image($image_id, $size, false, array('class' => 'selected-images-only')); if ('' !== $image_html) { $html .= '<a href="' . esc_url(get_permalink($post_id)) . '">' . $image_html . '</a>'; } else { if (current_user_can('edit_posts')) { // Image is not wide enough $error_link = oxford_is_wpcom() ? 'http://theme.wordpress.com/themedoc/oxford/' : get_edit_post_link() . '#featured-images-help'; $error_message = sprintf(_n('<strong>Admin:</strong> The featured image for this post is not wide enough. %s', '<strong>Admin:</strong> Neither of the featured images for this post is wide enough. %s', $image_count, 'oxford'), sprintf('<br /><a href="%s">%s</a>', esc_url($error_link), __('Learn more.', 'oxford'))); $html .= '<div class="selected-images-none">'; $html .= $error_message; $html .= '</div>'; } } $html .= '</div>'; return $html; } return $html; }
<?php /** * @package oxford */ // Post classes $post_class = 'masonry-post'; if (oxford_get_featured_image_ids(get_the_ID())) { $post_class .= ' has-featured-image'; } // Insert widget(s) global $wp_query; if (2 === $wp_query->current_post && false === apply_filters('oxford_loading_more_posts', false)) { get_template_part('content', 'extra'); } ?> <article id="post-<?php the_ID(); ?> " <?php post_class($post_class); ?> > <header class="entry-header"> <?php echo oxford_get_the_archive_featured_image(); ?> <div class="post-many-meta"> <?php get_template_part('_post', 'sticky');
/** * Set the class properties related to the page's characteristics. * * If the Homepage has content or images, the properties will be based on it. * Otherwise, they will be based on the most recent post. * * @since 1.0. * * @param object $homepage The post object for the Homepage. * @param object $recent_post The post object for the recent post. */ public function set_page_props($homepage, $recent_post) { // Try Homepage first. $homepage_content = '' !== $homepage->post_content; $ids = oxford_get_featured_image_ids($homepage->ID); $homepage_images = !empty($ids); if ($homepage_content || $homepage_images) { $this->has_content = $homepage_content; $this->has_selected_image = $homepage_images; } else { $this->has_content = '' !== $recent_post->post_content || '' !== $recent_post->post_excerpt; $ids = oxford_get_featured_image_ids($recent_post->ID); $this->has_selected_image = !empty($ids); $this->content_source = 'recent_post'; } }