コード例 #1
0
/**
 * Handles the shortcode used for single feed items.
 *
 * @since 4.6.6
 */
function wprss_shortcode_single($atts = array())
{
    if (empty($atts)) {
        return;
    }
    $id = empty($atts['id']) ? FALSE : $atts['id'];
    if ($id === FALSE || get_post_type($id) !== 'wprss_feed_item' || ($item = get_post($id)) === FALSE) {
        return '';
    }
    //Enqueue scripts / styles
    wp_enqueue_script('jquery.colorbox-min', WPRSS_JS . 'jquery.colorbox-min.js', array('jquery'));
    wp_enqueue_script('wprss_custom', WPRSS_JS . 'custom.js', array('jquery', 'jquery.colorbox-min'));
    $general_settings = get_option('wprss_settings_general');
    if (!$general_settings['styles_disable'] == 1) {
        wp_enqueue_style('colorbox', WPRSS_CSS . 'colorbox.css', array(), '1.4.33');
        wp_enqueue_style('styles', WPRSS_CSS . 'styles.css', array(), '');
    }
    setup_postdata($item);
    $output = wprss_render_feed_item($id);
    $output = apply_filters('wprss_shortcode_single_output', $output);
    wp_reset_postdata();
    return $output;
}
コード例 #2
0
/**
 * Default template for feed items display
 *
 * @since 3.0
 * @param $args       array    The shortcode arguments
 * @param $feed_items WP_Query The feed items to display
 */
function wprss_default_display_template($args, $feed_items)
{
    global $wp_query;
    global $paged;
    // Swap the current WordPress Query with our own
    $old_wp_query = $wp_query;
    $wp_query = $feed_items;
    // Prepare the output
    $output = '';
    // Check if our current query returned any feed items
    if ($feed_items->have_posts()) {
        // PRINT LINKS BEFORE LIST OF FEED ITEMS
        $output .= $args['links_before'];
        // FOR EACH ITEM
        while ($feed_items->have_posts()) {
            // Get the item
            $feed_items->the_post();
            // Add the output
            $output .= wprss_render_feed_item(NULL, '', $args);
        }
        // OUTPUT LINKS AFTER LIST OF FEED ITEMS
        $output .= $args['links_after'];
        // Add pagination if needed
        if (!isset($args['pagination']) || !in_array($args['pagination'], array('off', 'false', '0', 0))) {
            $output = apply_filters('wprss_pagination', $output);
        }
        // Filter the final output, and print it
        echo apply_filters('feed_output', $output);
    } else {
        // No items found message
        echo apply_filters('no_feed_items_found', __('No feed items found.', WPRSS_TEXT_DOMAIN));
    }
    // Reset the WordPress query
    $wp_query = $old_wp_query;
    wp_reset_postdata();
}