function mpp_gallery_show_publish_gallery_activity_button()
{
    if (!mediapress()->is_bp_active()) {
        return;
    }
    $gallery_id = mpp_get_current_gallery_id();
    //if not a valid gallery id or no unpublished media exists, just don't show it
    if (!$gallery_id || !mpp_gallery_has_unpublished_media($gallery_id)) {
        return;
    }
    $gallery = mpp_get_gallery($gallery_id);
    $unpublished_media = mpp_gallery_get_unpublished_media($gallery_id);
    //unpublished media count
    $unpublished_media_count = count($unpublished_media);
    $type = $gallery->type;
    $type_name = _n($type, $type . 's', $unpublished_media_count);
    //if we are here, there are unpublished media
    ?>
	<div id="mpp-unpublished-media-info">
		<p> <?php 
    printf(__('You have %d %s not published to actvity.', 'mediapress'), $unpublished_media_count, $type_name);
    ?>
			<span class="mpp-gallery-publish-activity"><?php 
    mpp_gallery_publish_activity_link($gallery_id);
    ?>
</span>
			<span class="mpp-gallery-unpublish-activity"><?php 
    mpp_gallery_unpublished_media_delete_link($gallery_id);
    ?>
</span>
		</p>
	</div>

	<?php 
}
示例#2
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);
 }
示例#3
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);
}
示例#4
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);
}