当前位置: 首页>>代码示例>>PHP>>正文


PHP mpp_get_media函数代码示例

本文整理汇总了PHP中mpp_get_media函数的典型用法代码示例。如果您正苦于以下问题:PHP mpp_get_media函数的具体用法?PHP mpp_get_media怎么用?PHP mpp_get_media使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mpp_get_media函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mpp_get_media_delete_url

/**
 * Get Media delete url
 * 
 * @param type $media
 * @return string
 */
function mpp_get_media_delete_url($media = null)
{
    $media = mpp_get_media($media);
    $link = mpp_get_media_edit_url($media) . 'delete/?mpp-action=delete-media&mpp-nonce=' . wp_create_nonce('mpp-delete-media') . '&mpp-media-id=' . $media->id;
    return $link;
    //needs improvenemt
}
开发者ID:markc,项目名称:mediapress,代码行数:13,代码来源:mpp-media-link-templates.php

示例2: mpp_get_default_media_cover_image_src

function mpp_get_default_media_cover_image_src($media, $cover_type)
{
    $media = mpp_get_media($media);
    //we need to cache the assets to avoid heavy file system read/write etc
    $key = $media->type . '-' . $cover_type;
    //let us assume a naming convention like this
    //media_type-cover_type.png? or whatever e.g video-thumbnail.png, photo-mid.png
    $default_image = $media->type . '-' . $cover_type . '.png';
    $default_image = apply_filters('mpp_default_media_cover_file_name', $default_image, $cover_type, $media);
    return mpp_get_asset_url('assets/images/' . $default_image, $key);
}
开发者ID:markc,项目名称:mediapress,代码行数:11,代码来源:mpp-media-cover-template.php

示例3: mpp_media_filter_permalink

function mpp_media_filter_permalink($link, $post_id)
{
    if (!mpp_is_valid_media($post_id)) {
        return $link;
    }
    $media = mpp_get_media($post_id);
    if ($media->component != 'sitewide') {
        return $link;
    }
    //in case of sitewide gallery, the permalink is like
    $gallery_permalink = mpp_get_gallery_permalink($media->gallery_id);
    return user_trailingslashit(untrailingslashit($gallery_permalink) . '/media/' . $media->slug);
}
开发者ID:markc,项目名称:mediapress,代码行数:13,代码来源:mpp-media-hooks.php

示例4: activity_display

 /**
  * Default view for the emdia attached to activity
  * 
  * @param int[] $media_ids
  * @return null
  */
 public function activity_display($media_ids = array())
 {
     if (!$media_ids) {
         return;
     }
     $media = $media_ids[0];
     $media = mpp_get_media($media);
     if (!$media) {
         return;
     }
     $type = $media->type;
     //we will use include to load found template file, the file will have $media_ids available
     $templates = array("buddypress/activity/views/grid-{$type}.php", 'buddypress/activity/views/grid.php');
     $located_template = mpp_locate_template($templates, false);
     include $located_template;
 }
开发者ID:enboig,项目名称:mediapress,代码行数:22,代码来源:class-mpp-gallery-view-default.php

示例5: mpp_activity_inject_media_in_comment_replies

function mpp_activity_inject_media_in_comment_replies()
{
    $activity_id = bp_get_activity_id();
    $media_id = mpp_activity_get_media_id($activity_id);
    if (empty($media_id)) {
        return;
    }
    $media = mpp_get_media($media_id);
    if (!$media) {
        return;
    }
    //	$gallery_id	= mpp_activity_get_gallery_id( $activity_id );
    //
    //	$gallery	= mpp_get_gallery( $gallery_id );
    //
    //	if( ! $gallery ) {
    //		return ;
    //	}
    $slug = $media->type;
    //media-loop-audio/media-loop-video,media-loop-photo, media-loop
    mpp_get_template_part('buddypress/activity/entry-comment', $slug);
}
开发者ID:enboig,项目名称:mediapress,代码行数:22,代码来源:mpp-activity-hooks.php

示例6: mpp_media_title

            mpp_media_title();
            ?>
</div>
					
					<?php 
            do_action('mpp_after_single_media_title');
            ?>
					
					<div class="mpp-item-entry mpp-media-entry" >
						
						<?php 
            do_action('mpp_before_single_media_content');
            ?>
						
						<?php 
            mpp_load_media_view(mpp_get_media());
            ?>
						
						<?php 
            do_action('mpp_after_single_media_content');
            ?>
						
					</div>
					
					<div class="mpp-item-meta mpp-media-meta mpp-media-meta-bottom">
						<?php 
            do_action('mpp_media_meta');
            ?>
					</div>
					
					<?php 
开发者ID:markc,项目名称:mediapress,代码行数:31,代码来源:single.php

示例7: setup_single_media_query

 /**
  * Set up query for fetching single media
  * 
  * @param type $media_id
  */
 public function setup_single_media_query($media)
 {
     $mp = mediapress();
     if (!is_null($this->single_media_query)) {
         $mp->the_media_query = $this->single_media_query;
     } else {
         $mp->the_media_query = new MPP_Media_Query(array('id' => $media->ID));
     }
     $mp->current_media = mpp_get_media($media);
     //now check if we are on edit page nor not?
     $this->current_action = isset($this->action_variables[2]) ? $this->action_variables[2] : '';
     if ($this->current_action == 'edit') {
         $mp->set_editing('media');
         //it is single media edit
         $mp->set_action('edit');
         $edit_action = isset($this->action_variables[3]) ? $this->action_variables[3] : 'edit';
         $mp->set_edit_action($edit_action);
     }
 }
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:24,代码来源:mpp-core-component.php

示例8: mpp_group_check_media_permission

function mpp_group_check_media_permission($can, $media, $gallery, $user_id)
{
    $media = mpp_get_media($media);
    //if it is not a group gallery, we  should not be worried
    if ($media->component != 'groups') {
        return $can;
    }
    $group_id = $media->component_id;
    if (groups_is_user_admin($user_id, $group_id) || groups_is_user_mod($user_id, $group_id)) {
        $can = true;
    }
    return $can;
}
开发者ID:enboig,项目名称:mediapress,代码行数:13,代码来源:mpp-bp-groups-hooks.php

示例9: mpp_activity_mark_attached_media

/**
 * When an activity is saved, check if there exists a media attachment cookie,
 *  if yes, mark it as non orphaned and store in the activity meta
 * 
 */
function mpp_activity_mark_attached_media($activity_id)
{
    if (!is_user_logged_in()) {
        return;
    }
    if (empty($_COOKIE['_mpp_activity_attached_media_ids'])) {
        return;
    }
    //don't do anything
    //let us process
    $media_ids = $_COOKIE['_mpp_activity_attached_media_ids'];
    $media_ids = explode(',', $media_ids);
    //make an array
    foreach ($media_ids as $media_id) {
        //should we verify the logged in user & owner of media is same?
        mpp_delete_media_meta($media_id, '_mpp_is_orphan');
        //or should we delete the key?
    }
    mpp_activity_update_attached_media_ids($activity_id, $media_ids);
    //store the media ids in the activity meta
    //also add the activity to gallery & gallery to activity link
    $media = mpp_get_media($media_id);
    if ($media->gallery_id) {
        mpp_activity_update_gallery_id($activity_id, $media->gallery_id);
    }
    //also update this activity and set its action to be mpp_media_upload
    $activity = new BP_Activity_Activity($activity_id);
    // $activity->component = buddypress()->mediapress->id;
    $activity->type = 'mpp_media_upload';
    $activity->save();
    mpp_activity_clear_attached_media_cookie();
    //clear cookies
    //reset the cookie
}
开发者ID:baden03,项目名称:mediapress,代码行数:39,代码来源:functions.php

示例10: mpp_format_activity_action_media_upload

/**
 * Format activity action for 'mpp_media_upload' activity type.
 *
 * 
 * @param string $action  activity action.
 * @param object $activity Activity object.
 * @return string
 */
function mpp_format_activity_action_media_upload($action, $activity)
{
    $userlink = mpp_get_user_link($activity->user_id);
    $media_ids = array();
    $media_id = 0;
    $media_id = mpp_activity_get_media_id($activity->id);
    if (!$media_id) {
        $media_ids = mpp_activity_get_attached_media_ids($activity->id);
        if (!empty($media_ids)) {
            $media_id = $media_ids[0];
        }
    }
    $gallery_id = mpp_activity_get_gallery_id($activity->id);
    if (!$media_id && !$gallery_id) {
        return $action;
        //not a gallery activity, no need to proceed further
    }
    $media = mpp_get_media($media_id);
    $gallery = mpp_get_gallery($gallery_id);
    if (!$media && !$gallery) {
        return $action;
    }
    $activity_type = mpp_activity_get_activity_type($activity->id);
    //is a type specified
    $skip = false;
    if ($activity_type) {
        if (in_array($activity_type, array('edit_gallery', 'add_media'))) {
            //'create_gallery',
            $skip = true;
        }
    }
    //there us still a chance for improvement, we should dynamically generate the action instead for the above actions too
    if ($skip) {
        return $action;
    }
    if ($activity_type == 'media_upload') {
        $media_count = count($media_ids);
        $media_id = current($media_ids);
        $type = $gallery->type;
        //we need the type plural in case of mult
        $type = _n($type, $type . 's', $media_count);
        //photo vs photos etc
        $action = sprintf(__('%s uploaded %d new %s', 'mediapress'), $userlink, $media_count, $type);
        //allow modules to filter the action and change the message
        $action = apply_filters('mpp_activity_action_media_upload', $action, $activity, $media_id, $media_ids, $gallery);
    } elseif ($activity_type == 'media_comment') {
        if (mpp_is_single_media()) {
            $action = sprintf(__('%s', 'mediapress'), $userlink);
        } else {
            $action = sprintf(__("%s commented on %s's %s", 'mediapress'), $userlink, mpp_get_user_link($media->user_id), $media->type);
            //brajesh singh commented on @mercime's photo
        }
    } elseif ($activity_type == 'gallery_comment') {
        if (mpp_is_single_gallery()) {
            $action = sprintf('%s', $userlink);
        } else {
            $action = sprintf(__("%s commented on %s's <a href='%s'>%s gallery</a>", 'mediapress'), $userlink, mpp_get_user_link($gallery->user_id), mpp_get_gallery_permalink($gallery), $gallery->type);
        }
    } elseif ($activity_type == 'create_gallery') {
        $action = sprintf(__('%s created a %s <a href="%s">gallery</a>', 'mediapress'), $userlink, $gallery->type, mpp_get_gallery_permalink($gallery));
    } else {
        $action = sprintf(__('%s', 'mediapress'), $userlink);
    }
    return apply_filters('mpp_format_activity_action_media_upload', $action, $activity, $media_id, $media_ids);
}
开发者ID:markc,项目名称:mediapress,代码行数:73,代码来源:mpp-activity-template.php

示例11: delete

 /**
  * Delete all the files associated with a Media
  * 
  * @global type $wpdb
  * @param type $id
  * @return boolean
  */
 public function delete($media_id)
 {
     $media = mpp_get_media($media_id);
     $meta = wp_get_attachment_metadata($media_id);
     $backup_sizes = get_post_meta($media_id, '_wp_attachment_backup_sizes', true);
     $file = get_attached_file($media_id);
     //relatiev path from uploads directory to the current directory
     $rel_path = str_replace(wp_basename($file), '', $file);
     ///echo "Rel path: $rel_path <br><br>";
     //$media = mpp_get_media( $media_id );
     //$upload_dir		 = wp_upload_dir();
     //$base_upload_dir = trailingslashit( $upload_dir['basedir'] ); //
     $gallery_dir = trailingslashit($rel_path);
     //get the file system path to current gallery upload dir
     //if ( is_multisite() )
     delete_transient('dirsize_cache');
     do_action('mpp_before_media_files_delete', $media_id);
     delete_metadata('post', null, '_thumbnail_id', $media_id, true);
     // delete all for any posts.
     $sizes = isset($meta['sizes']) ? $meta['sizes'] : array();
     // remove intermediate and backup images if there are any
     foreach ($sizes as $size) {
         /** This filter is documented in wp-admin/custom-header.php */
         $media_file = apply_filters('mpp_delete_file', $size['file']);
         @unlink(path_join($gallery_dir, $media_file));
     }
     $file = apply_filters('mpp_delete_file', $file);
     if (!empty($file)) {
         @unlink($base_upload_dir . $file);
     }
     $this->invalidate_transient($media->component, $media->component_id);
     return true;
 }
开发者ID:baden03,项目名称:mediapress,代码行数:40,代码来源:local-storage.php

示例12: mpp_media_menu

/**
 * Render media admin tabs
 * 
 * @param type $media
 */
function mpp_media_menu($media)
{
    $media = mpp_get_media($media);
    mediapress()->get_menu('media')->render($media);
}
开发者ID:baden03,项目名称:mediapress,代码行数:10,代码来源:nav-functions.php

示例13: post_comment

 /**
  * Post a gallery or media Main comment on single page
  * 
  * @return type
  */
 public function post_comment()
 {
     //this is BuddyPress dependent
     if (!function_exists('buddypress')) {
         exit(0);
     }
     // Bail if not a POST action
     if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
         return;
     }
     // Check the nonce
     check_admin_referer('post_update', '_wpnonce_post_update');
     if (!is_user_logged_in()) {
         exit('-1');
     }
     $mpp_type = $_POST['mpp-type'];
     $mpp_id = $_POST['mpp-id'];
     if (empty($_POST['content'])) {
         exit('-1<div id="message" class="error"><p>' . __('Please enter some content to post.', 'mediapress') . '</p></div>');
     }
     $activity_id = 0;
     if (empty($_POST['object']) && bp_is_active('activity')) {
         //we are preventing this comment to be set as the user's lastes_update
         $user_id = bp_loggedin_user_id();
         $old_latest_update = bp_get_user_meta($user_id, 'bp_latest_update', true);
         $activity_id = bp_activity_post_update(array('content' => $_POST['content']));
         //restore
         if (!empty($old_latest_update)) {
             bp_update_user_meta($user_id, 'bp_latest_update', $old_latest_update);
         }
     } elseif ($_POST['object'] == 'groups') {
         if (!empty($_POST['item_id']) && bp_is_active('groups')) {
             $activity_id = groups_post_update(array('content' => $_POST['content'], 'group_id' => $_POST['item_id']));
         }
     } else {
         $activity_id = apply_filters('bp_activity_custom_update', $_POST['object'], $_POST['item_id'], $_POST['content']);
     }
     if (empty($activity_id)) {
         exit('-1<div id="message" class="error"><p>' . __('There was a problem posting your update, please try again.', 'mediapress') . '</p></div>');
     }
     $status = '';
     //if we have got activity id, let us add a meta key
     if ($mpp_type == 'gallery') {
         mpp_activity_update_gallery_id($activity_id, $mpp_id);
         mpp_activity_update_activity_type($activity_id, 'gallery_comment');
         mpp_activity_update_context($activity_id, 'gallery');
         $status = mpp_get_gallery_status($mpp_id);
     } elseif ($mpp_type == 'media') {
         $media = mpp_get_media($mpp_id);
         if (!$media) {
             die('-1');
         }
         mpp_activity_update_gallery_id($activity_id, $media->gallery_id);
         mpp_activity_update_media_id($activity_id, $mpp_id);
         mpp_activity_update_activity_type($activity_id, 'media_comment');
         mpp_activity_update_context($activity_id, 'media');
         //also we need to keep the parent gallery id for caching
         $status = mpp_get_media_status($media);
     }
     $activity = new BP_Activity_Activity($activity_id);
     // $activity->component = buddypress()->mediapress->id;
     $activity->type = 'mpp_media_upload';
     $activity->save();
     //save activity privacy
     if ($status) {
         $status_object = mpp_get_status_object($status);
         if ($status_object) {
             bp_activity_update_meta($activity->id, 'activity-privacy', $status_object->activity_privacy);
         }
     }
     //create a shadow comment
     mpp_activity_create_comment_for_activity($activity_id);
     if (bp_has_activities('include=' . $activity_id)) {
         while (bp_activities()) {
             bp_the_activity();
             mpp_locate_template(array('buddypress/activity/entry.php'), true);
         }
     }
     exit;
 }
开发者ID:markc,项目名称:mediapress,代码行数:85,代码来源:class-mpp-ajax-comment-helper.php

示例14: mpp_get_current_media

<?php

// Exit if the file is accessed directly over web
if (!defined('ABSPATH')) {
    exit;
}
$media = mpp_get_current_media();
?>
<div class="mpp-lightbox-content mpp-clearfix">
	<?php 
$media = mpp_get_media();
?>
	<div class="mpp-lightbox-media-container">
		
		<?php 
do_action('mpp_before_lightbox_media', $media);
?>
		
		<div class="mpp-item-meta mpp-media-meta mpp-lightbox-media-meta mpp-lightbox-media-meta-top">
			<?php 
do_action('mpp_lightbox_media_meta_top', $media);
?>
 
		</div>
		
		
		<a href="<?php 
mpp_media_permalink();
?>
" title="<?php 
echo esc_attr(mpp_get_media_title());
开发者ID:enboig,项目名称:mediapress,代码行数:31,代码来源:lightbox-comment.php

示例15: mpp_user_can_delete_media

/**
 * Check if the media can be deleted by the user
 * 
 * @param type $media_id
 * @param type $user_id
 * @return boolean true if allowed false otherwise
 */
function mpp_user_can_delete_media($media_id, $user_id = null)
{
    if (!$user_id) {
        $user_id = get_current_user_id();
    }
    $media = mpp_get_media($media_id);
    if (!$media) {
        return false;
    }
    $gallery = mpp_get_gallery($media->gallery_id);
    $allow = false;
    //do not alow editing by default
    //if the user is gallery creator, allow him to delete media
    if ($gallery->user_id == $user_id) {
        //should we consider context here like members gallery or groups gallery?
        $allow = true;
    } elseif ($user_id == $media->user_id) {
        //since current user is uploader/contributor
        //let us check if the gallery allows deleting for contributor
        $allow_deleting = mpp_get_gallery_meta($gallery->id, '_mpp_contributors_can_delete', true);
        if ($allow_deleting == 'yes') {
            $allow = true;
        } elseif ($allow_deleting != 'no' && mpp_get_option('contributors_can_delete')) {
            //check for global settings & make sure it is not overridden in the local settings
            $allow = true;
        }
    }
    return apply_filters('mpp_user_can_delete_media', $allow, $media, $gallery, $user_id);
}
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:36,代码来源:mpp-permissions.php


注:本文中的mpp_get_media函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。