/**
 * Update the list of unpublished media
 * 
 * @param int $gallery_id
 * @param int|array $media_ids single media id or an array of media ids
 */
function mpp_gallery_update_unpublished_media($gallery_id, $media_ids)
{
    $media_ids = (array) $media_ids;
    // one or more media is given
    if (empty($media_ids)) {
        return;
    }
    //delete all existing media in the list
    mpp_gallery_delete_unpublished_media($gallery_id);
    //add the new list
    mpp_gallery_add_unpublished_media($gallery_id, $media_ids);
}
示例#2
0
function mpp_action_hide_unpublished_media()
{
    if (!is_user_logged_in() || !mpp_is_gallery_management() || !bp_is_action_variable('delete-unpublished', 1)) {
        return;
    }
    $gallery_id = absint($_GET['gallery_id']);
    if (!$gallery_id) {
        return;
    }
    //verify nonce
    if (!wp_verify_nonce($_GET['_wpnonce'], 'delete-unpublished')) {
        //should we return or show error?
        return;
    }
    $referrer = mpp_get_gallery_edit_media_url($gallery_id);
    if (!mpp_gallery_has_unpublished_media($gallery_id)) {
        mpp_add_feedback(__('Nothing to hide.', 'mediapress'), 'error');
        bp_core_redirect($referrer);
    }
    //check if user has permission
    if (!mpp_user_can_publish_gallery_activity($gallery_id)) {
        mpp_add_feedback(__("You don't have sufficient permission.", 'mediapress'), 'error');
        bp_core_redirect($referrer);
    }
    mpp_gallery_delete_unpublished_media($gallery_id);
    mpp_add_feedback(__("Successfully hidden!", 'mediapress'));
    bp_core_redirect($referrer);
}
示例#3
0
 public function hide_unpublished_media()
 {
     //verify nonce
     if (!wp_verify_nonce($_POST['_wpnonce'], 'delete-unpublished')) {
         //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' => __('Nothing to hide.', '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);
     }
     mpp_gallery_delete_unpublished_media($gallery_id);
     wp_send_json(array('message' => __("Successfully hidden!", 'mediapress'), 'success' => 1));
     exit(0);
 }