function mpp_shortcode_media_list($atts = null, $content = '')
{
    //allow everything that can be done to be passed via this shortcode
    $defaults = array('view' => 'grid', 'type' => false, 'id' => false, 'in' => false, 'exclude' => false, 'slug' => false, 'status' => false, 'component' => false, 'component_id' => false, 'gallery_id' => false, 'galleries' => false, 'galleries_exclude' => false, 'per_page' => false, 'offset' => false, 'page' => false, 'nopaging' => false, 'order' => 'DESC', 'orderby' => 'date', 'user_id' => false, 'include_users' => false, 'exclude_users' => false, 'user_name' => false, 'scope' => false, 'search_terms' => '', 'year' => false, 'month' => false, 'week' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => '', 'yearmonth' => false, 'meta_key' => '', 'meta_value' => '', 'column' => 4, 'playlist' => 0, 'fields' => false);
    $atts = shortcode_atts($defaults, $atts);
    if (!$atts['meta_key']) {
        unset($atts['meta_key']);
        unset($atts['meta_value']);
    }
    $cols = $atts['column'];
    $view = $atts['view'];
    $type = $atts['type'];
    unset($atts['column']);
    unset($atts['view']);
    mpp_shortcode_save_media_data('column', $cols);
    $query = new MPP_Media_Query($atts);
    mpp_shortcode_save_media_data('query', $query);
    $content = apply_filters('mpp_shortcode_mpp_media_content', '', $args, $view);
    if (!$content) {
        $templates = array("shortcodes/{$view}-{$type}.php", "shortcodes/{$view}.php", "shortcodes/grid.php");
        ob_start();
        mpp_locate_template($templates, true);
        $content = ob_get_clean();
    }
    mpp_shortcode_reset_media_data('query');
    mpp_shortcode_reset_media_data('column');
    return $content;
}
Example #2
0
function mpp_media_shortcode($atts = null, $content = '')
{
    //allow everything that can be done to be passed via this shortcode
    $defaults = array('type' => false, 'id' => false, 'in' => false, 'exclude' => false, 'slug' => false, 'status' => false, 'component' => false, 'component_id' => false, 'gallery_id' => false, 'galleries' => false, 'galleries_exclude' => false, 'per_page' => false, 'offset' => false, 'page' => false, 'nopaging' => false, 'order' => 'DESC', 'orderby' => 'date', 'user_id' => false, 'include_users' => false, 'exclude_users' => false, 'user_name' => false, 'scope' => false, 'search_terms' => '', 'year' => false, 'month' => false, 'week' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => '', 'yearmonth' => false, 'meta_key' => '', 'meta_value' => '', 'column' => 4, 'playlist' => 0, 'fields' => false);
    $atts = shortcode_atts($defaults, $atts);
    if (!$atts['meta_key']) {
        unset($atts['meta_key']);
        unset($atts['meta_value']);
    }
    $cols = $atts['column'];
    $playlist = $atts['playlist'];
    $type = $atts['type'];
    unset($atts['column']);
    unset($atts['playlist']);
    $slug = '';
    if ($type && $playlist) {
        $slug = "{$type}-playlist";
    } elseif ($type) {
        $slug = $type;
    }
    mpp_shortcode_save_media_data('column', $cols);
    $query = new MPP_Media_Query($atts);
    mpp_shortcode_save_media_data('query', $query);
    ob_start();
    echo '<div class="mpp-container mpp-shortcode-media-wrapper"><div class="mpp-g mpp-item-list mpp-media-list mpp-media-shortcode-list"> ';
    mpp_get_template_part('shortcodes/loop', $slug);
    //shortcodes/gallery-entry.php
    echo '</div></div>';
    $content = ob_get_clean();
    mpp_shortcode_reset_media_data('query');
    mpp_shortcode_reset_media_data('column');
    return $content;
}
function mpp_shortcode_show_gallery($atts = null, $content = '')
{
    $defaults = array('id' => false, 'in' => false, 'exclude' => false, 'slug' => false, 'per_page' => false, 'offset' => false, 'page' => false, 'nopaging' => false, 'order' => 'DESC', 'orderby' => 'date', 'user_id' => false, 'include_users' => false, 'exclude_users' => false, 'user_name' => false, 'scope' => false, 'search_terms' => '', 'meta_key' => '', 'meta_value' => '', 'column' => 4, 'view' => '');
    $defaults = apply_filters('mpp_shortcode_show_gallery_defaults', $defaults);
    $atts = shortcode_atts($defaults, $atts);
    if (!$atts['id']) {
        return '';
    }
    $gallery_id = absint($atts['id']);
    global $wpdb;
    $attachments = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_type = %s ", $gallery_id, 'attachment'));
    array_push($attachments, $gallery_id);
    _prime_post_caches($attachments, true, true);
    $gallery = mpp_get_gallery($gallery_id);
    //if gallery does not exist, there is no proint in further proceeding
    if (!$gallery) {
        return '';
    }
    if (!$atts['meta_key']) {
        unset($atts['meta_key']);
        unset($atts['meta_value']);
    }
    $view = $atts['view'];
    unset($atts['id']);
    unset($atts['view']);
    $atts['gallery_id'] = $gallery_id;
    $shortcode_column = $atts['column'];
    mpp_shortcode_save_media_data('column', $shortcode_column);
    mpp_shortcode_save_media_data('shortcode_args', $atts);
    unset($atts['column']);
    $atts = array_filter($atts);
    $query = new MPP_Media_Query($atts);
    mpp_shortcode_save_media_data('query', $query);
    $content = apply_filters('mpp_shortcode_mpp_show_gallery_content', '', $atts, $view);
    if (!$content) {
        $templates = array('shortcodes/grid.php');
        if ($view) {
            $type = $gallery->type;
            $preferred_templates = array("shortcodes/{$view}-{$type}.php", "shortcodes/{$view}.php");
            //audio-playlist, video-playlist
            $templates = array_merge($preferred_templates, $templates);
            //array_unshift( $templates, $preferred_template );
        }
        ob_start();
        mpp_locate_template($templates, true);
        //load
        $content = ob_get_clean();
    }
    mpp_shortcode_reset_media_data('column');
    mpp_shortcode_reset_media_data('query');
    mpp_shortcode_reset_media_data('shortcode_args');
    return $content;
}