/** * 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; } }
?> </div> <div class="mpp-item-entry mpp-gallery-entry"> <a href="<?php mpp_gallery_permalink(); ?> " <?php mpp_gallery_html_attributes(array('class' => 'mpp-item-thumbnail mpp-gallery-cover')); ?> > <img src="<?php mpp_gallery_cover_src('thumbnail'); ?> " alt ="<?php echo esc_attr(mpp_get_gallery_title()); ?> " /> </a> </div> <?php do_action('mpp_before_gallery_title'); ?> <a href="<?php mpp_gallery_permalink(); ?> " class="mpp-gallery-title"><?php mpp_gallery_title(); ?>
public function publish_gallery_media() { //verify nonce if (!wp_verify_nonce($_POST['_wpnonce'], 'publish')) { //should we return or show error? return; } $gallery_id = absint($_POST['gallery_id']); if (!mpp_gallery_has_unpublished_media($gallery_id)) { wp_send_json(array('message' => __('No media to publish.', 'mediapress'), 'error' => 1)); exit(0); } //check if user has permission if (!mpp_user_can_publish_gallery_activity($gallery_id)) { wp_send_json(array('message' => __("You don't have sufficient permission.", 'mediapress'), 'error' => 1)); exit(0); } $media_ids = mpp_gallery_get_unpublished_media($gallery_id); $media_count = count($media_ids); $gallery = mpp_get_gallery($gallery_id); $type = $gallery->type; $type_name = _n($type, $type . 's', $media_count); $user_link = mpp_get_user_link(get_current_user_id()); $gallery_url = mpp_get_gallery_permalink($gallery); $gallery_link = '<a href="' . esc_url($gallery_url) . '" title="' . esc_attr($gallery->title) . '">' . mpp_get_gallery_title($gallery) . '</a>'; //has media, has permission, so just publish now // $activity_id = mpp_gallery_record_activity(array('gallery_id' => $gallery_id, 'media_ids' => $media_ids, 'type' => 'media_publish', 'action' => sprintf(__('%s shared %d %s to %s ', 'mediapress'), $user_link, $media_count, $type_name, $gallery_link), 'content' => '')); if ($activity_id) { mpp_gallery_delete_unpublished_media($gallery_id); wp_send_json(array('message' => __("Published to activity successfully.", 'mediapress'), 'success' => 1)); exit(0); } else { wp_send_json(array('message' => __("There was a problem. Please try again later.", 'mediapress'), 'error' => 1)); exit(0); } //we are good, let us check if there are actually unpublished media //$unpublished_media = //get unpublished media ids //call _mpp_record_activity //how about success/failure exit(0); }
/** * Generate/Display breadcrumb * @param array $args * @return string|null */ function mpp_gallery_breadcrumb($args = null) { $default = array('separator' => '/', 'before' => '', 'after' => '', 'show_home' => false); $args = wp_parse_args($args, $default); extract($args); $crumbs = array(); $component = mpp_get_current_component(); $component_id = mpp_get_current_component_id(); if (mediapress()->is_bp_active() && bp_is_active('groups') && bp_is_group()) { $name = bp_get_group_name(groups_get_current_group()); } elseif (mediapress()->is_bp_active() && bp_is_user()) { $name = bp_get_displayed_user_fullname(); } elseif ($component == 'sitewide') { $name = ''; } $my_or_his_gallery = ''; if ($name) { $my_or_his_gallery = sprintf(__("%s's gallery", 'mediapress'), $name); } if (function_exists('bp_is_my_profile') && bp_is_my_profile()) { $my_or_his_gallery = __('Your Galleries', 'mediapress'); } if (mpp_is_media_management()) { $crumbs[] = ucwords(mediapress()->get_edit_action()); } if (mpp_is_single_media()) { $media = mpp_get_current_media(); if (mpp_is_media_management()) { $crumbs[] = sprintf('<a href="%s">%s</a>', mpp_get_media_permalink($media), mpp_get_media_title($media)); } else { $crumbs[] = sprintf('<span>%s</span>', mpp_get_media_title($media)); } } if (mpp_is_gallery_management()) { $crumbs[] = ucwords(mediapress()->get_edit_action()); } if (mpp_is_single_gallery()) { $gallery = mpp_get_current_gallery(); if (mpp_is_gallery_management() || mpp_is_single_media()) { $crumbs[] = sprintf('<a href="%s">%s</a>', mpp_get_gallery_permalink($gallery), mpp_get_gallery_title($gallery)); } else { $crumbs[] = sprintf('<span>%s</span>', mpp_get_gallery_title($gallery)); } } if ($my_or_his_gallery) { $crumbs[] = sprintf('<a href="%s">%s</a>', mpp_get_gallery_base_url($component, $component_id), $my_or_his_gallery); } if (count($crumbs) <= 1 && !$show_home) { return; } $crumbs = array_reverse($crumbs); echo join($separator, $crumbs); }
function mpp_action_publish_gallery_media_to_activity() { if (!mediapress()->is_bp_active() || !is_user_logged_in() || !mpp_is_gallery_management() || !bp_is_action_variable('publish', 1)) { return; } $gallery_id = absint($_GET['gallery_id']); if (!$gallery_id) { return; } //$referrer = wp_get_referer(); //if( empty( $referrer ) ) { $referrer = mpp_get_gallery_edit_media_url($gallery_id); //} //verify nonce if (!wp_verify_nonce($_GET['_wpnonce'], 'publish')) { mpp_add_feedback(__('Unauthorized action.', 'mediapress'), 'error'); mpp_redirect($referrer); } //all is good check for permission if (!mpp_user_can_publish_gallery_activity($gallery_id)) { mpp_add_feedback(__("You don't have sufficient permission.", 'mediapress'), 'error'); mpp_redirect($referrer); } if (!mpp_gallery_has_unpublished_media($gallery_id)) { mpp_add_feedback(__('Nothing to publish.', 'mediapress'), 'error'); mpp_redirect($referrer); } //now we can safely publish $media_ids = mpp_gallery_get_unpublished_media($gallery_id); $media_count = count($media_ids); $gallery = mpp_get_gallery($gallery_id); $type = $gallery->type; $type_name = _n($type, $type . 's', $media_count); $user_link = mpp_get_user_link(get_current_user_id()); $gallery_url = mpp_get_gallery_permalink($gallery); $gallery_link = '<a href="' . esc_url($gallery_url) . '" title="' . esc_attr($gallery->title) . '">' . mpp_get_gallery_title($gallery) . '</a>'; //has media, has permission, so just publish now // $activity_id = mpp_gallery_record_activity(array('gallery_id' => $gallery_id, 'media_ids' => $media_ids, 'type' => 'media_publish', 'action' => sprintf(__('%s shared %d %s to %s ', 'mediaprses'), $user_link, $media_count, $type_name, $gallery_link), 'content' => '')); if ($activity_id) { mpp_gallery_delete_unpublished_media($gallery_id); mpp_add_feedback(__("Published to activity successfully.", 'mediapress')); } else { mpp_add_feedback(__("There was a problem. Please try again later.", 'mediapress'), 'error'); } mpp_redirect($referrer); }