本文整理汇总了PHP中mpp_locate_template函数的典型用法代码示例。如果您正苦于以下问题:PHP mpp_locate_template函数的具体用法?PHP mpp_locate_template怎么用?PHP mpp_locate_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mpp_locate_template函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mpp_shortcode_media_list
function mpp_shortcode_media_list($atts = null, $content = '')
{
//allow everything that can be done to be passed via this shortcode
$defaults = array('view' => 'grid', 'type' => false, 'id' => false, 'in' => false, 'exclude' => false, 'slug' => false, 'status' => false, 'component' => false, 'component_id' => false, 'gallery_id' => false, 'galleries' => false, 'galleries_exclude' => false, 'per_page' => false, 'offset' => false, 'page' => false, 'nopaging' => false, 'order' => 'DESC', 'orderby' => 'date', 'user_id' => false, 'include_users' => false, 'exclude_users' => false, 'user_name' => false, 'scope' => false, 'search_terms' => '', 'year' => false, 'month' => false, 'week' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => '', 'yearmonth' => false, 'meta_key' => '', 'meta_value' => '', 'column' => 4, 'playlist' => 0, 'fields' => false);
$atts = shortcode_atts($defaults, $atts);
if (!$atts['meta_key']) {
unset($atts['meta_key']);
unset($atts['meta_value']);
}
$cols = $atts['column'];
$view = $atts['view'];
$type = $atts['type'];
unset($atts['column']);
unset($atts['view']);
mpp_shortcode_save_media_data('column', $cols);
$query = new MPP_Media_Query($atts);
mpp_shortcode_save_media_data('query', $query);
$content = apply_filters('mpp_shortcode_mpp_media_content', '', $args, $view);
if (!$content) {
$templates = array("shortcodes/{$view}-{$type}.php", "shortcodes/{$view}.php", "shortcodes/grid.php");
ob_start();
mpp_locate_template($templates, true);
$content = ob_get_clean();
}
mpp_shortcode_reset_media_data('query');
mpp_shortcode_reset_media_data('column');
return $content;
}
示例2: activity_display
/**
* Display audio playlist for activity
*
* @param int[] $media_ids
* @return null
*/
public function activity_display($media_ids = array())
{
if (!$media_ids) {
return;
}
//we will use include to load found template file, the file will have $media_ids available
$templates = array('buddypress/activity/views/playlist-audio.php');
$located_template = mpp_locate_template($templates, false);
if ($located_template) {
include $located_template;
}
}
示例3: 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' => 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' => '');
$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']);
$atts = array_filter($atts);
$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();
mpp_locate_template($templates, true);
//load
$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;
}
示例4: mpp_get_template
/**
* Get other templates
*
* @access public
* @param string $template_name
* @param array $args (default: array()) Use it to pass variables to the local scope of the included file if you need
* @param string $default_path (default: '')
* @return void
*/
function mpp_get_template($template_name, $args = array(), $default_path = '')
{
if ($args && is_array($args)) {
extract($args);
}
$located = mpp_locate_template(array($template_name), false, $default_path);
if (!file_exists($located)) {
_doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $template_name), '1.0');
return;
}
do_action('mpp_before_template_part', $template_name, $located, $args);
include $located;
do_action('mpp_after_template_part', $template_name, $located, $args);
}
示例5: 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;
}
示例6: do_action
<?php
do_action('mpp_after_single_gallery');
?>
<?php
mpp_media_pagination();
?>
<?php
do_action('mpp_after_single_gallery_pagination');
?>
<?php
mpp_locate_template(array('buddypress/members/gallery/activity.php'), true);
?>
<?php
do_action('mpp_after_single_gallery_activity');
?>
<?php
} else {
?>
<div class="mpp-notice mpp-gallery-prohibited">
<p><?php
printf(__('The privacy policy does not allow you to view this.', 'mediapress'));
?>
示例7: mpp_locate_sub_template
function mpp_locate_sub_template($sub_dir, $template, $default)
{
$templates = array($sub_dir . $template, $sub_dir . $default);
mpp_locate_template($templates, true);
//load
}
示例8: post_comment
/**
* Post a gallery or media Main comment on single page
*
* @return type
*/
public function post_comment()
{
// 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>');
}
//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);
} elseif ($mpp_type == 'media') {
mpp_activity_update_media_id($activity_id, $mpp_id);
}
$activity = new BP_Activity_Activity($activity_id);
// $activity->component = buddypress()->mediapress->id;
$activity->type = 'mpp_media_upload';
$activity->save();
if (bp_has_activities('include=' . $activity_id)) {
while (bp_activities()) {
bp_the_activity();
mpp_locate_template(array('activity/entry.php'), true);
}
}
exit;
}
示例9: do_action
</div>
<?php
do_action('mpp_after_single_gallery');
?>
<?php
mpp_media_pagination();
?>
<?php
do_action('mpp_after_single_gallery_pagination');
?>
<?php
mpp_locate_template(array('gallery/single/activity.php'), true);
?>
<?php
do_action('mpp_after_single_gallery_activity');
?>
<?php
} else {
?>
<div class="mpp-notice mpp-gallery-prohibited">
<p><?php
printf(__('The privacy policy does not allow you to view this.', 'mediapress'));
?>
示例10: while
if (empty($_POST['page'])) {
?>
<ul id="mpp-activity-stream" class="mpp-activity-list item-list">
<?php
}
?>
<?php
while (bp_activities()) {
bp_the_activity();
?>
<?php
mpp_locate_template(array('activity/entry.php'), true, false);
?>
<?php
}
?>
<?php
if (bp_activity_has_more_items()) {
?>
<li class="load-more">
<a href="#more"><?php
_e('Load More', 'mediapress');
?>
</a>
示例11: bp_core_get_userlink
</a>
</div>
<div class="mpp-lightbox-uploader-upload-details">
<div class="mpp-lightbox-uploader-link">
<?php
echo bp_core_get_userlink(mpp_get_media_creator_id());
?>
</div>
</div>
</div><!--end of the top row -->
<div class="mpp-item-description mpp-media-description mpp-lightbox-media-description mpp-clearfix">
<?php
mpp_media_description();
?>
</div>
<?php
do_action('mpp_before_lightbox_media_activity', $media);
?>
<?php
mpp_locate_template(array('gallery/media/views/lightbox/activity.php'), true);
?>
<?php
do_action('mpp_after_lightbox_media_activity', $media);
?>
</div>
</div>
示例12: mpp_activity_recurse_comments
/**
* Loops through a level of activity comments and loads the template for each.
*
* It is a copy of bp_activity_recurse_comments, since bp dioes not allow using custom template for activity comment, It acts as a filler
*
*/
function mpp_activity_recurse_comments($comment)
{
global $activities_template;
if (empty($comment)) {
return false;
}
if (empty($comment->children)) {
return false;
}
/**
* Filters the opening tag for the template that lists activity comments.
* @param string $value Opening tag for the HTML markup to use.
*/
echo apply_filters('bp_activity_recurse_comments_start_ul', '<ul>');
$template = mpp_locate_template(array('buddypress/activity/comment.php'), false, false);
// Backward compatibility. In older versions of BP, the markup was
// generated in the PHP instead of a template. This ensures that
// older themes (which are not children of bp-default and won't
// have the new template) will still work.
if (!$template) {
$template = buddypress()->plugin_dir . '/bp-themes/bp-default/activity/comment.php';
}
foreach ((array) $comment->children as $comment_child) {
// Put the comment into the global so it's available to filters
$activities_template->activity->current_comment = $comment_child;
load_template($template, false);
unset($activities_template->activity->current_comment);
}
/**
* Filters the closing tag for the template that list activity comments.
*
* @param string $value Closing tag for the HTML markup to use.
*/
echo apply_filters('bp_activity_recurse_comments_end_ul', '</ul>');
}