Example #1
0
<article id="post-<?php 
the_ID();
?>
" <?php 
post_class();
?>
>
	<?php 
/*
 * If our posts have featured images, we'll show them in the grid.
 * Otherwise, we'll fall back to a grey box with an icon representing the post format.
 */
if (get_the_post_thumbnail()) {
    // Use a larger image if the post is featured.
    if (true === apostrophe_is_featured()) {
        $apostrophe_post_thumbnail = get_the_post_thumbnail($post->ID, 'apostrophe-featured');
    } else {
        $apostrophe_post_thumbnail = get_the_post_thumbnail();
    }
    $apostrophe_has_thumbnail = 'apostrophe-thumb';
} else {
    $apostrophe_post_thumbnail = '<span></span>';
    $apostrophe_has_thumbnail = 'apostrophe-nothumb';
}
// check for post thumbnail
/*
 * If the post format is a link, we want to link directly to that link, rather than to the post itself
 */
if ('link' === get_post_format()) {
    $apostrophe_permalink = apostrophe_get_url();
Example #2
0
/**
 * Add a class to all Featured Content posts.
 * This allows us to style them slightly differently in the CSS.
 */
function apostrophe_post_class($classes, $class, $post_id)
{
    if (apostrophe_is_featured($post_id)) {
        $classes[] = 'apostrophe-featured';
    }
    return $classes;
}
Example #3
0
/**
 * Fires during init, looks for a apostrophe_action.
 */
function apostrophe_inline_controls_handler()
{
    if (empty($_GET['apostrophe_action']) || !is_user_logged_in()) {
        return;
    }
    $action = strtolower(esc_html($_GET['apostrophe_action']));
    if (!in_array($action, array('toggle_featured'))) {
        return;
    }
    // Powered by Jetpack's Featured Content.
    if ('toggle_featured' === $action) {
        if (empty($_GET['apostrophe_post_id'])) {
            return;
        }
        $post_id = absint($_GET['apostrophe_post_id']);
        $post = get_post($post_id);
        if (!current_user_can('edit_post', $post->ID)) {
            return;
        }
        // Only if the featured content tag has been set.
        $term_id = apostrophe_get_jetpack_featured_content_term_id();
        if (!$term_id) {
            return;
        }
        // Toggle the featured content tag.
        if (apostrophe_is_featured($post->ID)) {
            wp_remove_object_terms($post->ID, $term_id, 'post_tag');
        } else {
            wp_set_object_terms($post->ID, $term_id, 'post_tag', true);
        }
        if (method_exists('Featured_Content', 'delete_transient')) {
            Featured_Content::delete_transient();
        }
        $redirect_url = remove_query_arg(array('apostrophe_action', 'apostrophe_post_id'));
        $redirect_url .= sprintf('#apostrophe-post-%d', $post->ID);
        wp_safe_redirect(esc_url_raw($redirect_url));
    }
}