Exemplo n.º 1
0
/**
 * Creates a set of classes for each site entry upon display. Each entry is given the class of
 * 'hentry'. Posts are given category, tag, and author classes. Alternate post classes of odd,
 * even, and alt are added.
 *
 * @param string|array $class One or more classes to add to the class list.
 * @param int $post_id An optional post ID.
 * @return array
 * @since 1.1
 */
function momtaz_get_post_class($class = '', $post_id = 0)
{
    $classes = array();
    // Get post object
    $post = get_post($post_id);
    if (empty($post)) {
        return $classes;
    }
    // hAtom compliance.
    $classes[] = 'hentry';
    // Get post context.
    $context = momtaz_get_post_context($post_id);
    // Merge the classes array with post context.
    $classes = array_merge($classes, (array) $context);
    // Post taxonomies
    $post_taxonomies = get_post_taxonomies($post);
    if (!empty($post_taxonomies)) {
        foreach ($post_taxonomies as $taxonomy) {
            $terms = get_the_terms($post->ID, $taxonomy);
            if (!empty($terms)) {
                foreach ($terms as $term) {
                    $classes[] = 'term-' . sanitize_html_class($term->slug, $term->term_id);
                }
            }
        }
    }
    // Sticky posts.
    if (is_home() && !is_paged() && is_sticky($post->ID)) {
        $classes[] = 'sticky';
    }
    // Is this post protected by a password?
    if (post_password_required($post)) {
        $classes[] = 'post-password-required';
    }
    // Post alt class.
    if (!momtaz_is_the_single($post)) {
        static $post_alt = 0;
        $classes[] = 'set-' . ++$post_alt;
        $classes[] = $post_alt % 2 ? 'odd' : 'even';
    }
    // Has a custom excerpt?
    if (has_excerpt($post)) {
        $classes[] = 'has-excerpt';
    }
    // Custom classes.
    if (!empty($class)) {
        if (!is_array($class)) {
            $class = preg_split('#\\s+#', $class);
        }
        $classes = array_merge($classes, $class);
    }
    // Apply the WordPress filters.
    $classes = apply_filters('post_class', $classes, $class, $post->ID);
    // Apply the Momtaz FW filters.
    $classes = apply_filters('momtaz_get_post_class', $classes, $post);
    // Removes any duplicate and empty classes.
    $classes = array_unique(array_filter($classes));
    return $classes;
}
Exemplo n.º 2
0
/**
 * Add attributes for the entry element.
 *
 * @return array
 * @since 1.3
 */
function momtaz_atts_entry($atts)
{
    $post = get_post();
    if (empty($post)) {
        return $atts;
    }
    $post_id = get_the_ID();
    $atts['id'] = "post-{$post_id}";
    if (!isset($atts['class'])) {
        $atts['class'] = momtaz_get_post_class();
    } else {
        $atts['class'] = momtaz_get_post_class($atts['class']);
    }
    // HTML5 Microdata
    $atts['itemscope'] = 'itemscope';
    // Blog posts microdata
    if ('post' === $post->post_type) {
        $atts['itemtype'] = 'http://schema.org/BlogPosting';
        if (momtaz_is_the_single($post_id)) {
            $atts['itemprop'] = 'blogPost';
        }
    } elseif ('attachment' === $post->post_type) {
        if (wp_attachment_is_image($post_id)) {
            $atts['itemtype'] = 'http://schema.org/ImageObject';
        }
    } else {
        $atts['itemtype'] = 'http://schema.org/CreativeWork';
    }
    return $atts;
}
Exemplo n.º 3
0
momtaz_template_part('entry-header');
?>

	<div class="entry-body">

		<?php 
Momtaz_Zones::call('entry_content:before');
?>

		<div<?php 
momtaz_atts('entry-content', array('class' => 'entry-content'));
?>
>

			<?php 
if (momtaz_is_the_single(get_the_ID(), 'attachment')) {
    ?>

				<?php 
    if (wp_attachment_is_image()) {
        ?>

					<div class="entry-attachment">

						<div class="attachment attachment-image">

							<figure class="wp-caption">

								<a href="<?php 
        echo esc_url(wp_get_attachment_url());
        ?>
Exemplo n.º 4
0
    ?>
>

					<?php 
    printf(__('<span class="prep entry-utility-prep">By:</span> %s', 'momtaz'), sprintf('<a class="url fn n" href="%1$s" rel="author">%2$s</a>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_html(get_the_author())));
    $show_sep = true;
    ?>

				</span> <!-- .by-author -->

			<?php 
}
?>

			<?php 
if (!momtaz_is_the_single(get_the_ID()) && post_type_supports(get_post_type(), 'comments')) {
    ?>

					<?php 
    if ($show_sep) {
        echo '<span class="sep">' . _x(' | ', 'entry-meta-sep', 'momtaz') . '</span>';
    }
    ?>

					<span class="comments-link">
						<?php 
    comments_popup_link('<span class="leave-reply">' . __('Leave a comment', 'momtaz') . '</span>', __('1 Comment', 'momtaz'), __('<b>%</b> Comments', 'momtaz'));
    ?>
					</span> <!-- .comments-links -->

			<?php