Exemple #1
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);
 }
Exemple #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);
}
Exemple #3
0
function mpp_gallery_get_unpublished_media_delete_link($gallery_id, $label = '')
{
    if (!function_exists('bp_is_active') || !bp_is_active('activity') || !mpp_gallery_has_unpublished_media($gallery_id) || !mpp_user_can_publish_gallery_activity($gallery_id)) {
        return '';
    }
    //this gallery has unpublished media and the user can publish the media to activity
    if (empty($label)) {
        $label = _x('Hide', 'Clear unpublished media notification', 'mediapress');
    }
    $title = __('Clear unpublished media notification', 'mediapress');
    $url = mpp_gallery_get_unpublished_media_delete_url($gallery_id);
    return sprintf("<a href='%s' title ='%s' class='button mpp-button mpp-action-button mpp-delete-unpublished-media-button'>%s</a>", $url, $title, $label);
}