/** * Display the column data * * @param string $col * @param int $post_id * @return string */ public function display_cols($col, $post_id) { $allowed = array('type', 'status', 'component', 'user_id', 'media_count', 'cover'); if (!in_array($col, $allowed)) { return $col; } $gallery = mpp_get_gallery(get_post($post_id)); switch ($col) { case 'cover': echo "<img src='" . mpp_get_gallery_cover_src('thumbnail', $post_id) . "' height='100px' width='100px'/>"; break; case 'type': echo $gallery->type; break; case 'status': echo $gallery->status; break; case 'component': echo $gallery->component; break; case 'media_count': echo $gallery->media_count; break; case 'user_id': echo mpp_get_user_link($gallery->user_id); break; } }
/** * Print the absolute url of the cover image * * @param type $type (thumbnail|mid|large or any registerd size) * @param mixed $gallery id or object */ function mpp_gallery_cover_src($type = 'thumbnail', $gallery = null) { echo mpp_get_gallery_cover_src($type, $gallery); }
public function delete_gallery_cover() { //verify nonce if (!wp_verify_nonce($_POST['_wpnonce'], 'mpp-manage-gallery')) { wp_send_json(array('message' => __('Invalid action.', 'mediapress'), 'error' => 1)); exit(0); } $gallery = mpp_get_gallery(absint($_REQUEST['gallery_id'])); if (!$gallery) { wp_send_json(array('message' => __('Invalid action.', 'mediapress'), 'error' => 1)); exit(0); } //we may want to allow passing of component from the form in future! if (!mpp_user_can_delete_gallery($gallery)) { wp_send_json(array('message' => __("You don't have permission to delete this cover!", 'mediapress'), 'error' => 1)); exit(0); } //we always need to delete this $cover_id = mpp_get_gallery_cover_id($gallery->id); mpp_delete_gallery_cover_id($gallery->id); mpp_delete_media($cover_id); wp_send_json(array('message' => __("Cover deleted", 'mediapress'), 'success' => 1, 'cover' => mpp_get_gallery_cover_src('thumbnail', $gallery->id))); exit(0); }