/**
 * Check if given post is a valid MediaPress media
 * Checks for post type + mpp_is_mpp_media meta
 * 
 * @param int $media_id
 */
function mpp_is_valid_media($media_id)
{
    if (mpp_get_media_meta($media_id, '_mpp_is_mpp_media', true) && get_post_type($media_id) == mpp_get_media_post_type()) {
        return true;
    }
    return false;
}
Beispiel #2
0
/**
 * Show the list of attached media in an activity
 * Should we add a link to view gallery too?
 * 
 * @return type
 */
function mpp_activity_inject_attached_media_html()
{
    $media_list = mpp_activity_get_attached_media_ids(bp_get_activity_id());
    if (empty($media_list)) {
        return;
    }
    $activity_id = bp_get_activity_id();
    $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);
    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-loop-audio/media-loop-video,media-loop-photo, media-loop
    mpp_get_template_part('gallery/activity/loop', $slug);
}
/**
 * Get associated activity Id for Media
 * 
 * @param type $media_id
 * @return type
 */
function mpp_media_get_activity_id($media_id)
{
    return mpp_get_media_meta($media_id, '_mpp_activity_id', true);
}
Beispiel #4
0
 public function __get($key)
 {
     if (isset($this->data[$key])) {
         return $this->data[$key];
     }
     if ('component' == $key) {
         $this->set($key, mpp_get_object_component($this->id));
         return $this->data[$key];
     } elseif ('type' == $key) {
         $this->set($key, mpp_get_object_type($this->id));
         return $this->data[$key];
     } elseif ('status' == $key) {
         $this->set($key, mpp_get_object_status($this->id));
         return $this->data[$key];
     }
     $value = mpp_get_media_meta($this->id, '_mpp_' . $key, true);
     return $value;
 }
Beispiel #5
0
/**
 * Get the upload context
 * 
 * @param string $context
 * @return type
 */
function mpp_get_upload_context($media_id = null, $context = null)
{
    $current_context = '';
    if ($media_id) {
        $current_context = mpp_get_media_meta($media_id, '_mpp_context', true);
    }
    //if the media upload context is not known, let us see if a default is given
    if (!$current_context && $context) {
        $current_context = $context;
    }
    if (!$current_context) {
        $current_context = 'profile';
    }
    return apply_filters('mpp_get_upload_context', $current_context, $media_id, $context);
}
/**
 * Get media cover id
 * 
 * @param type $media_id
 * @return type
 */
function mpp_get_media_cover_id($media_id)
{
    return mpp_get_media_meta($media_id, '_mpp_cover_id', true);
}
Beispiel #7
0
 public function __get($key)
 {
     if ('status' == $key) {
         return mpp_get_object_status($this->id);
     }
     if ('type' == $key) {
         return mpp_get_object_type($this->id);
     }
     if ('component' == $key) {
         return mpp_get_object_component($this->id);
     }
     $value = mpp_get_media_meta($this->id, '_mpp_' . $key, true);
     return $value;
 }
Beispiel #8
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);
    }