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


PHP mpp_get_gallery函数代码示例

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


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

示例1: mpp_gallery_show_publish_gallery_activity_button

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 
}
开发者ID:enboig,项目名称:mediapress,代码行数:35,代码来源:mpp-gallery-template.php

示例2: display

 public function display($gallery)
 {
     $gallery = mpp_get_gallery($gallery);
     $type = $gallery->type;
     $templates = array("gallery/views/grid-{$type}.php", 'gallery/views/grid.php');
     mpp_locate_template($templates, true);
 }
开发者ID:enboig,项目名称:mediapress,代码行数:7,代码来源:class-mpp-gallery-view-default.php

示例3: mpp_shortcode_uploader

function mpp_shortcode_uploader($atts = array(), $content = '')
{
    $default = array('gallery_id' => 0, 'component' => mpp_get_current_component(), 'component_id' => mpp_get_current_component_id(), 'type' => '', 'status' => mpp_get_default_status(), 'view' => '', 'selected' => 0, 'label_empty' => __('Please select a gallery', 'mediapress'), 'show_error' => 1);
    $atts = shortcode_atts($default, $atts);
    //dropdown list of galleries to sllow userselect one
    $view = 'list';
    if (!empty($atts['gallery_id']) && is_numeric($atts['gallery_id'])) {
        $view = 'single';
        //single gallery uploader
        //override component and $component id
        $gallery = mpp_get_gallery($atts['gallery_id']);
        if (!$gallery) {
            return __('Nonexistent gallery should not be used', 'mediapress');
        }
        //reset
        $atts['component'] = $gallery->component;
        $atts['component_id'] = $gallery->component_id;
        $atts['type'] = $gallery->type;
    }
    //the user must be able to upload to current component or galler
    $can_upload = false;
    if (mpp_user_can_upload($atts['component'], $atts['component_id'], $atts['gallery_id'])) {
        $can_upload = true;
    }
    if (!$can_upload && $atts['show_error']) {
        return __('Sorry, you are not allowed to upload here.', 'mediapress');
    }
    //if we are here, the user can upload
    //we still have one issue, what if the user has not created any gallery and the admin intends to allow the user to upload to their created gallery
    $atts['context'] = 'shortcode';
    //from where it is being uploaded,
    $atts['view'] = $view;
    //passing the 2nd arg makes all these variables available to the loaded file
    mpp_get_template('shortcodes/uploader.php', $atts);
}
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:35,代码来源:mpp-shortcode-media-uploader.php

示例4: display_cols

 /**
  * 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;
     }
 }
开发者ID:markc,项目名称:mediapress,代码行数:35,代码来源:class-mpp-admin-gallery-list-helper.php

示例5: display_cols

 public function display_cols($col, $post_id)
 {
     $allowed = array('type', 'status', 'component', 'user_id', 'media_count');
     if (!in_array($col, $allowed)) {
         return $col;
     }
     $gallery = mpp_get_gallery(get_post($post_id));
     switch ($col) {
         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 bp_core_get_userlink($gallery->user_id);
             break;
     }
 }
开发者ID:baden03,项目名称:mediapress,代码行数:25,代码来源:class-mpp-gallery-list-helper.php

示例6: mpp_shortcode_show_gallery

function mpp_shortcode_show_gallery($atts = null, $content = '')
{
    $defaults = array('id' => false, 'in' => false, 'exclude' => false, 'slug' => false, 'per_page' => false, 'offset' => false, 'page' => isset($_REQUEST['mpage']) ? absint($_REQUEST['mpage']) : false, 'nopaging' => false, 'order' => 'DESC', 'orderby' => 'date', 'user_id' => false, 'include_users' => false, 'exclude_users' => false, 'user_name' => false, 'scope' => false, 'search_terms' => '', 'meta_key' => '', 'meta_value' => '', 'column' => 4, 'view' => '', 'show_pagination' => 1);
    $defaults = apply_filters('mpp_shortcode_show_gallery_defaults', $defaults);
    $atts = shortcode_atts($defaults, $atts);
    if (!$atts['id']) {
        return '';
    }
    $gallery_id = absint($atts['id']);
    global $wpdb;
    $attachments = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND post_type = %s ", $gallery_id, 'attachment'));
    array_push($attachments, $gallery_id);
    _prime_post_caches($attachments, true, true);
    $gallery = mpp_get_gallery($gallery_id);
    //if gallery does not exist, there is no proint in further proceeding
    if (!$gallery) {
        return '';
    }
    if (!$atts['meta_key']) {
        unset($atts['meta_key']);
        unset($atts['meta_value']);
    }
    $view = $atts['view'];
    unset($atts['id']);
    unset($atts['view']);
    $atts['gallery_id'] = $gallery_id;
    $shortcode_column = $atts['column'];
    mpp_shortcode_save_media_data('column', $shortcode_column);
    mpp_shortcode_save_media_data('shortcode_args', $atts);
    unset($atts['column']);
    $show_pagination = $atts['show_pagination'];
    unset($atts['show_pagination']);
    $atts = array_filter($atts);
    $atts = apply_filters('mpp_shortcode_show_gallery_query_args', $atts, $defaults);
    $query = new MPP_Media_Query($atts);
    mpp_shortcode_save_media_data('query', $query);
    $content = apply_filters('mpp_shortcode_mpp_show_gallery_content', '', $atts, $view);
    if (!$content) {
        $templates = array('shortcodes/grid.php');
        if ($view) {
            $type = $gallery->type;
            $preferred_templates = array("shortcodes/{$view}-{$type}.php", "shortcodes/{$view}.php");
            //audio-playlist, video-playlist
            $templates = array_merge($preferred_templates, $templates);
            //array_unshift( $templates, $preferred_template );
        }
        ob_start();
        $located = mpp_locate_template($templates, false);
        //load
        if ($located) {
            require $located;
        }
        $content = ob_get_clean();
    }
    mpp_shortcode_reset_media_data('column');
    mpp_shortcode_reset_media_data('query');
    mpp_shortcode_reset_media_data('shortcode_args');
    return $content;
}
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:59,代码来源:mpp-shortcode-gallery-list.php

示例7: mpp_filter_gallery_permalink

/**
 * Filter get_permalink for mediapress gallery post type( mpp-gallery)
 * aand make it like site.com/members/username/mediapressslug/gallery-name or site.com/{component-page}/{single-component}/mediapress-slug/gallery-name
 * It allows us to get the permalink to gallery by using the_permalink/get_permalink functions
 */
function mpp_filter_gallery_permalink($permalink, $post, $leavename, $sample)
{
    if (mpp_get_gallery_post_type() != $post->post_type) {
        return $permalink;
    }
    $gallery = mpp_get_gallery($post);
    $slug = $gallery->slug;
    $base_url = mpp_get_gallery_base_url($gallery->component, $gallery->component_id);
    return apply_filters('mpp_get_gallery_permalink', $base_url . '/' . $slug, $gallery);
}
开发者ID:baden03,项目名称:mediapress,代码行数:15,代码来源:hooks.php

示例8: mpp_get_default_gallery_cover_image_src

/**
 * If there is no cover set for a gallery, use the default cover image
 * 
 * @param type $gallery
 * @param type $cover_type
 * @return type
 */
function mpp_get_default_gallery_cover_image_src($gallery, $cover_type)
{
    $gallery = mpp_get_gallery($gallery);
    //we need to cache the assets to avoid heavy file system read/write etc
    $key = $gallery->type . '-' . $cover_type;
    //let us assume a naming convention like this
    //gallery_type-cover_type.png? or whatever e.g video-thumbnail.png, photo-mid.png
    $default_image = $gallery->type . '-' . $cover_type . '.png';
    $default_image = apply_filters('mpp_default_cover_file_name', $default_image, $cover_type, $gallery);
    return mpp_get_asset_url('assets/images/' . $default_image, $key);
}
开发者ID:enboig,项目名称:mediapress,代码行数:18,代码来源:mpp-gallery-cover-templates.php

示例9: mpp_group_check_gallery_permission

function mpp_group_check_gallery_permission($can, $gallery, $user_id)
{
    $gallery = mpp_get_gallery($gallery);
    //if it is not a group gallery, we  should not be worried
    if ($gallery->component != 'groups') {
        return $can;
    }
    $group_id = $gallery->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

示例10: mpp_custom_restrict_group_upload

function mpp_custom_restrict_group_upload($can_do, $component, $component_id, $gallery)
{
    if ($component != 'groups') {
        return $can_do;
    }
    //we only care about group upload
    $gallery = mpp_get_gallery($gallery);
    if (!$gallery || $gallery->user_id != get_current_user_id()) {
        return false;
        //do not allow if gallery is not given
    }
    return true;
    //the user had created this gallery
}
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:14,代码来源:bp-custom.php

示例11: mpp_filter_current_component_for_sitewide

function mpp_filter_current_component_for_sitewide($component)
{
    if (!mediapress()->is_bp_active()) {
        return $component;
    }
    if (mpp_admin_is_add_gallery() || mpp_admin_is_edit_gallery()) {
        global $post;
        $gallery = mpp_get_gallery($post);
        if ($gallery && $gallery->component) {
            $component = $gallery->component;
        } else {
            $component = 'sitewide';
        }
    }
    return $component;
}
开发者ID:markc,项目名称:mediapress,代码行数:16,代码来源:mpp-hooks.php

示例12: mpp_activity_inject_attached_media_html

/**
 * 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_ids = mpp_activity_get_attached_media_ids(bp_get_activity_id());
    if (empty($media_ids)) {
        return;
    }
    $activity_id = bp_get_activity_id();
    $gallery_id = mpp_activity_get_gallery_id($activity_id);
    $gallery = mpp_get_gallery($gallery_id);
    if (!$gallery) {
        return;
    }
    $type = $gallery->type;
    $view = mpp_get_activity_view($type);
    $view->activity_display($media_ids);
}
开发者ID:enboig,项目名称:mediapress,代码行数:22,代码来源:mpp-activity-hooks.php

示例13: map_before_delete_post_action

 /**
  * Maps the before_delete_post action to mpp_before_gallery_delete action
  * It also does the cleanup of attachments as wp_delete_post() does not delete attachments
  * 
  * @param int $gallery_id post id
  * @return unknown
  */
 public function map_before_delete_post_action($gallery_id)
 {
     //is this called or a valid gallery?
     if (!$gallery_id || !mpp_is_valid_gallery($gallery_id)) {
         return;
     }
     $gallery = mpp_get_gallery($gallery_id);
     //we are certain that it is called for gallery
     //fire the MediaPress gallery delete action
     if ($this->is_queued($gallery_id)) {
         //this action is already being executed for the current gallery, no need to do that again
         return;
     }
     $this->add_item($gallery_id, 'gallery');
     do_action('mpp_before_gallery_delete', $gallery_id);
     //after that action, we delete all attachment
     global $wpdb;
     //1// delete all media
     $storage_manager = null;
     $media_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d", $gallery_id));
     //we need the storage manager to notify it that it do do any final cleanup after the gallery delete
     //should we keep a reference to the storage manager for each gallery? what will happen for a gallery that contains local/remote media?
     //for the time being we are not keeping a reference but this method is doing exactly the same and I am not sure which approach will be fbetter for futuer
     if (!empty($media_ids)) {
         $mid = $media_ids[0];
         $storage_manager = mpp_get_storage_manager($mid);
     }
     //delete all media
     foreach ($media_ids as $media_id) {
         wp_delete_attachment($media_id);
         //delete all media
     }
     if (mediapress()->is_bp_active()) {
         //delete all gallery activity
         mpp_gallery_delete_activity($gallery_id);
         //delete all associated activity meta
         //mpp_gallery_delete_activity_meta( $gallery_id );
     }
     //Delete wall gallery meta
     mpp_delete_wall_gallery_id(array('component' => $gallery->component, 'component_id' => $gallery->component_id, 'gallery_id' => $gallery->id, 'media_type' => $gallery->type));
     //do any final cleanup, deletegate to the storage manager
     if ($storage_manager) {
         $storage_manager->delete_gallery($gallery);
     }
     return;
 }
开发者ID:enboig,项目名称:mediapress,代码行数:53,代码来源:class-mpp-deletion-actions-mapper.php

示例14: mpp_activity_inject_attached_media_html

/**
 * 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);
}
开发者ID:baden03,项目名称:mediapress,代码行数:28,代码来源:hooks.php

示例15: fetch_gallery_media

    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);
    }
开发者ID:enboig,项目名称:mediapress,代码行数:38,代码来源:class-mpp-ajax-lightbox-helper.php


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