Ejemplo n.º 1
0
function mpp_get_all_media_ids($args = null)
{
    $component = mpp_get_current_component();
    $component_id = mpp_get_current_component_id();
    $default = array('gallery_id' => mpp_get_current_gallery_id(), 'component' => $component, 'component_id' => $component_id, 'per_page' => -1, 'status' => mpp_get_accessible_statuses($component, $component_id, get_current_user_id()), 'nopaging' => true, 'fields' => 'ids');
    $args = wp_parse_args($args, $default);
    $ids = new MPP_Media_Query($args);
    return $ids->get_ids();
}
    public function fetch_gallery_media()
    {
        //do we need nonce validation for this request too? no
        $items = array();
        $gallery_id = absint($_POST['gallery_id']);
        $gallery = mpp_get_gallery($gallery_id);
        if (!$gallery_id || empty($gallery)) {
            exit(0);
        }
        $statuses = mpp_get_accessible_statuses($gallery->component, $gallery->component_id, get_current_user_id());
        $media_query = new MPP_Media_Query(array('gallery_id' => $gallery_id, 'posts_per_page' => -1, 'status' => $statuses));
        if ($media_query->have_media()) {
            ?>


			<?php 
            while ($media_query->have_media()) {
                $media_query->the_media();
                ?>

				<?php 
                $items[] = array('src' => $this->get_media_lightbox_entry());
                ?>

			<?php 
            }
            ?>

		<?php 
        }
        ?>
		<?php 
        mpp_reset_media_data();
        ?>
		<?php 
        wp_send_json(array('items' => $items));
        exit(0);
    }
 /**
  * Check and get single media id else false
  * 
  * @param type $slug
  * @param type $component
  * @param type $component_id
  * @return type
  */
 public function get_media_id($slug, $component, $component_id)
 {
     if (!$component_id || !$slug || !$component) {
         return false;
     }
     //on single post, why bother about the component etc, that makes our query slow, just do a simple post query instead
     global $wpdb;
     $post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_name = %s and post_type = %s ", $slug, mpp_get_media_post_type()));
     return $post;
     $query = new MPP_Media_Query(array('slug' => $slug, 'component' => $component, 'component_id' => $component_id));
     $posts = $query->get_media();
     $this->single_media_query = $query;
     if (!empty($posts)) {
         return array_pop($posts);
     }
     return false;
     //return mpp_media_exists( $slug, $component, $component_id );
 }
Ejemplo n.º 4
0
    public function fetch_activity_media()
    {
        //do we need nonce validation for this request too? no
        $items = array();
        $activity_id = $_POST['activity_id'];
        if (!$activity_id) {
            exit(0);
        }
        $media_ids = mpp_activity_get_attached_media_ids($activity_id);
        if (empty($media_ids)) {
            array_push($items, __('Sorry, Nothing found!', 'mediapress'));
            wp_send_json(array('items' => $items));
            exit(0);
        }
        $gallery_id = mpp_activity_get_gallery_id($activity_id);
        $gallery = mpp_get_gallery($gallery_id);
        //in case we are using oembed or other storage method
        $storage_method = mpp_get_media_meta($gallery->id, '_mpp_storage_method', true);
        //should we check for 'local' instead of default?
        if ($storage_method == mpp_get_default_storage_method()) {
            $storage_method = '';
        }
        $slug = $gallery->type;
        if (!empty($storage_method)) {
            $slug = $slug . '-' . $storage_method;
            //eg. video-oembed
        }
        $media_query = new MPP_Media_Query(array('in' => $media_ids));
        if ($media_query->have_media()) {
            ?>


			<?php 
            while ($media_query->have_media()) {
                $media_query->the_media();
                ?>

				<?php 
                $items[] = array('src' => $this->get_activity_media_lightbox_entry());
                ?>
			<?php 
            }
            ?>

		<?php 
        }
        ?>
		<?php 
        mpp_reset_media_data();
        ?>
		<?php 
        //media-loop-audio/media-loop-video,media-loop-photo, media-loop
        //mpp_get_template_part( 'gallery/activity/loop', $slug );
        wp_send_json(array('items' => $items));
        exit(0);
    }
Ejemplo n.º 5
0
<?php

// Exit if the file is accessed directly over web
if (!defined('ABSPATH')) {
    exit;
}
/**
 * Bulk Edit Media template for single gallery bulk media edit page
 * action:mediapress/gallery/galleryname/manage/edit/
 * 
 */
//fetch all media in the gallery
$items = new MPP_Media_Query(array('gallery_id' => mpp_get_current_gallery_id(), 'per_page' => -1, 'nopaging' => true));
if ($items->have_media()) {
    ?>

	<form action="" method="post" id="mpp-media-bulkedit-form" class="mpp-form mpp-form-stacked mpp-form-bulkedit-media ">
		
		<?php 
    do_action('mpp_before_bulkedit_media_form');
    ?>
		
		<div class="mpp-g mpp-bulk-edit-media-action-row">
			<div class="mpp-u-2-24 mpp-bulk-edit-media-checkbox">
				<?php 
    //allow to check/uncheck
    ?>
				<input type="checkbox" name="mpp-check-all" value="1" id="mpp-check-all" />
			</div>

			<div class="mpp-u-17-24 mpp-bulk-edit-media-action">
Ejemplo n.º 6
0
    public function fetch_activity_media()
    {
        //do we need nonce validation for this request too? no
        $items = array();
        $activity_id = $_POST['activity_id'];
        if (!$activity_id) {
            exit(0);
        }
        $media_ids = mpp_activity_get_attached_media_ids($activity_id);
        if (empty($media_ids)) {
            array_push($items, __('Sorry, Nothing found!', 'mediapress'));
            wp_send_json(array('items' => $items));
            exit(0);
        }
        $gallery_id = mpp_activity_get_gallery_id($activity_id);
        $gallery = mpp_get_gallery($gallery_id);
        if ($gallery->component == 'groups' && function_exists('bp_is_active') && bp_is_active('groups')) {
            //if( empty( buddypress()->groups))
        }
        $media_query = new MPP_Media_Query(array('in' => $media_ids));
        if ($media_query->have_media()) {
            ?>


			<?php 
            while ($media_query->have_media()) {
                $media_query->the_media();
                ?>

				<?php 
                $items[] = array('src' => $this->get_activity_media_lightbox_entry());
                ?>
			<?php 
            }
            ?>

		<?php 
        }
        ?>
		<?php 
        mpp_reset_media_data();
        ?>
		<?php 
        wp_send_json(array('items' => $items));
        exit(0);
    }
Ejemplo n.º 7
0
    public function generate_upload_meta_box($post)
    {
        ?>

		<!-- append uploaded media here -->
		<div id="mpp-gallery-media-admin-list" class="mpp-uploading-media-list">
			<ul> 
				<?php 
        $gallery_id = $post->ID;
        $mppq = new MPP_Media_Query(array('gallery_id' => $gallery_id, 'per_page' => -1, 'nopaging' => true));
        ?>
	
				<?php 
        while ($mppq->have_media()) {
            $mppq->the_media();
            ?>
				
					<li id="mpp-uploaded-media-item-<?php 
            mpp_media_id();
            ?>
" class="<?php 
            mpp_media_class('mpp-uploaded-media-item');
            ?>
">
						<img src="<?php 
            mpp_media_src('thumbnail');
            ?>
">
					</li>
				<?php 
        }
        ?>
				<?php 
        mpp_reset_media_data();
        ?>
			</ul>
		</div>
		<!-- drop files here for uploading -->
		<div id="mpp-gallery-admin-dropzone" class="mpp-dropzone">
			<button id="mpp-add-gallery-admin-media">Add media</button>
		</div>
		<!-- show any feedback here -->
		<div id="mpp-gallery-upload-admin-feedback" class="mpp-feedback">
			<ul> </ul>
		</div>


	<?php 
    }
Ejemplo n.º 8
0
// Exit if the file is accessed directly over web
if (!defined('ABSPATH')) {
    exit;
}
?>
<form action="" method="post" id="mpp-media-reorder-form" class="mpp-form mpp-form-stacked mpp-form-reorder-media ">

	
<?php 
do_action('mpp_before_sortable_media_form');
?>
	
<div id="mpp-sortable" class='mpp-g'>
	
	<?php 
$items = new MPP_Media_Query(array('gallery_id' => mpp_get_current_gallery_id(), 'per_page' => -1, 'nopaging' => true));
?>

	<?php 
while ($items->have_media()) {
    $items->the_media();
    ?>

		<div class='mpp-u-1-4 mpp-reorder-media ' id="mpp-reorder-media-<?php 
    mpp_media_id();
    ?>
">
			
			<div class='mpp-reorder-media-cover'>
				<?php 
    do_action('mpp_before_sortable_media_item');