function mpp_gallery_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, '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' => '', 'fields' => false, 'column' => 4); $atts = shortcode_atts($defaults, $atts); if (!$atts['meta_key']) { unset($atts['meta_key']); unset($atts['meta_value']); } $shortcode_column = $atts['column']; mpp_shortcode_save_gallery_data('column', $shortcode_column); unset($atts['column']); $query = new MPP_Gallery_Query($atts); ob_start(); echo '<div class="mpp-container mpp-shortcode-wrapper mpp-shortcode-gallery-wrapper"><div class="mpp-g mpp-item-list mpp-gallery-list mpp-shortcode-item-list mpp-shortcode-gallery-list"> '; while ($query->have_galleries()) { $query->the_gallery(); mpp_get_template_part('shortcodes/gallery', 'entry'); //shortcodes/gallery-entry.php } mpp_reset_gallery_data(); echo '</div></div>'; $content = ob_get_clean(); mpp_shortcode_reset_gallery_data('column'); return $content; }
function mpp_delete_galleries_for_user($user_id) { $query = new MPP_Gallery_Query(array('user_id' => $user_id, 'fields' => 'ids')); $ids = $query->get_ids(); //Delete all galleries foreach ($ids as $gallery_id) { mpp_delete_gallery($gallery_id); } }
function mpp_delete_galleries_for_group($group_id) { //DELETE ALL Galleries $query = new MPP_Gallery_Query(array('component_id' => $group_id, 'fields' => 'ids', 'component' => 'groups')); $ids = $query->get_ids(); //Delete all galleries foreach ($ids as $gallery_id) { mpp_delete_gallery($gallery_id); } }
/** * List galleries drop down * * @param type $args * @return string */ function mpp_list_galleries_dropdown($args = null) { $default = array('name' => 'mpp-gallery-list', 'id' => 'mpp-gallery-list', 'selected' => 0, 'type' => '', 'status' => '', 'component' => '', 'component_id' => '', 'posts_per_page' => -1, 'echo' => 1, 'label_empty' => ''); $args = wp_parse_args($args, $default); extract($args); if (!$component || !$component_id) { return; } $mppq = new MPP_Gallery_Query($args); $html = ''; $selected_attr = ''; if ($label_empty) { $html .= "<option value='0'" . selected(0, $selected, false) . ">" . $label_empty . "</option>"; } while ($mppq->have_galleries()) { $mppq->the_gallery(); $selected_attr = selected($selected, mpp_get_gallery_id(), false); $html .= "<option value='" . mpp_get_gallery_id() . "'" . $selected_attr . " data-mpp-type='" . mpp_get_gallery_type() . "'>" . mpp_get_gallery_title() . "</option>"; } //reset current gallery mpp_reset_gallery_data(); if (!empty($html)) { $html = "<select name='{$name}' id='{$id}'>" . $html . "</select>"; } if (!$echo) { return $html; } else { echo $html; } }
/** * Setup Sitewide/root Galleries * @todo Make it work in 1.1 when we introduce site galleries * */ public function setup_sitewide_gallery() { global $wp_query; //this is our single gallery page if (mpp_is_sitewide_gallery_component()) { $gallery_id = get_queried_object_id(); //setup gallery query mediapress()->the_gallery_query = MPP_Gallery_Query::build_from_wp_query($wp_query); mediapress()->current_gallery = mpp_get_gallery($gallery_id); //check for end points to edit if (get_query_var('manage')) { $action = get_query_var('manage'); $this->current_action = 'manage'; $this->current_manage_action = $action; } elseif (get_query_var('media')) { $action = $this->parse_media_action(get_query_var('media')); $this->action_variables = $action; $this->current_action = $action[0]; $this->current_manage_action = ''; //$action; //push mpty string at top to make compatible with bp returned action variables array array_unshift($this->action_variables, ''); } elseif (get_query_var('paged')) { $this->mpage = absint(get_query_var('paged')); } } elseif (is_post_type_archive(mpp_get_gallery_post_type())) { mediapress()->the_gallery_query = new MPP_Gallery_Query(array('status' => 'public')); } }