本文整理汇总了PHP中tribe_get_view函数的典型用法代码示例。如果您正苦于以下问题:PHP tribe_get_view函数的具体用法?PHP tribe_get_view怎么用?PHP tribe_get_view使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tribe_get_view函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tribe_show_month
/**
* Display a month
*
* Inline example:
* < code >
* <?php
* // output the events in May 2016 using the full month view template
* tribe_show_month( array( 'eventDate' => '2016-05-01' ) )
* ?>
* </ code >
*
* @param array $args query args to pass to the month view
* @param string $template_path template to use, defaults to the full month view
* @return void
* @author Jessica Yazbek
* @since 3.0
**/
function tribe_show_month($args = array(), $template_path = 'month/content')
{
// temporarily unset the tribe bar params so they don't apply
$hold_tribe_bar_args = array();
foreach ($_REQUEST as $key => $value) {
if ($value && strpos($key, 'tribe-bar-') === 0) {
$hold_tribe_bar_args[$key] = $value;
unset($_REQUEST[$key]);
}
}
do_action('tribe_events_before_show_month');
new Tribe_Events_Month_Template($args);
tribe_get_view($template_path);
do_action('tribe_events_after_show_month');
// reinstate the tribe bar params
if (!empty($hold_tribe_bar_args)) {
foreach ($hold_tribe_bar_args as $key => $value) {
$_REQUEST[$key] = $value;
}
}
}
示例2: load_ecp_into_page_template
/**
* Loads the contents into the page template
*
* @return string Page content
*/
public static function load_ecp_into_page_template()
{
// only run once!!!
remove_filter('the_content', array(__CLASS__, 'load_ecp_into_page_template'));
self::restoreQuery();
ob_start();
echo tribe_events_before_html();
tribe_get_view();
echo tribe_events_after_html();
$contents = ob_get_contents();
ob_end_clean();
// make sure the loop ends after our template is included
if (!is_404()) {
self::endQuery();
}
return $contents;
}
示例3: ajax_response
/**
* AJAX handler for Week view
* This loads up the week view shard with all the appropriate events for the week
*
* @return void
*/
public function ajax_response()
{
if (isset($_POST['eventDate']) && $_POST['eventDate']) {
Tribe__Events__Query::init();
$post_status = array('publish');
if (is_user_logged_in()) {
$post_status[] = 'private';
}
$args = array('post_status' => $post_status, 'eventDate' => $_POST['eventDate'], 'eventDisplay' => 'week');
if (isset($_POST['tribe_event_category'])) {
$args[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category'];
}
global $wp_query;
$wp_query = Tribe__Events__Query::getEvents($args, true);
Tribe__Events__Main::instance()->setDisplay();
$response = array('html' => '', 'success' => true, 'view' => 'week');
add_filter('tribe_is_week', '__return_true');
// simplest way to declare that this is a week view
ob_start();
tribe_get_view('pro/week/content');
$response['html'] .= ob_get_clean();
apply_filters('tribe_events_ajax_response', $response);
header('Content-type: application/json');
echo json_encode($response);
die;
}
}
示例4: tribe_include_view_list
/**
* Include the List view
*
* Accepts an array of query arguments, retrieves them, and returns the html for those events in list view
*
* Optional inline example:
* < code >
* <?php
* echo myfunction();
* ?>
* </ code >
*
* @category Events
*
* @param array $args Args to be passed to Tribe__Events__Query::getEvents()
* @param bool $initialize Whether the list view template class needs to be included and initialized
*
* @return string
**/
function tribe_include_view_list($args = null, $initialize = true)
{
global $wp_query;
// hijack the main query to load the events via provided $args
if (!is_null($args) || !($wp_query->tribe_is_event || $wp_query->tribe_is_event_category)) {
$reset_q = $wp_query;
$wp_query = Tribe__Events__Query::getEvents($args, true);
}
// single-event notices are jumping in on this init when loading as a module
Tribe__Events__Main::removeNotice('event-past');
// get the list view template
ob_start();
if ($initialize) {
tribe_initialize_view('Tribe__Events__Template__List');
}
tribe_get_view('list/content');
$list_view_html = ob_get_clean();
// fix the error of our ways
if (!empty($reset_q)) {
$wp_query = $reset_q;
}
// return the parsed template
return $list_view_html;
}
示例5: ajax_response
/**
* AJAX handler for the Map view
*/
public function ajax_response()
{
$tribe_paged = !empty($_POST['tribe_paged']) ? $_POST['tribe_paged'] : 1;
Tribe__Events__Query::init();
$post_status = array('publish');
if (is_user_logged_in()) {
$post_status[] = 'private';
}
$defaults = array('post_type' => Tribe__Events__Main::POSTTYPE, 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'paged' => $tribe_paged, 'post_status' => $post_status, 'eventDisplay' => 'map', 'tribe_geoloc' => true);
$view_state = 'map';
/* if past view */
if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
$view_state = 'past';
$defaults['eventDisplay'] = 'past';
$defaults['order'] = 'DESC';
}
if (isset($_POST['tribe_event_category'])) {
$defaults[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category'];
}
if (isset($_POST[Tribe__Events__Main::TAXONOMY])) {
$defaults[Tribe__Events__Main::TAXONOMY] = $_POST[Tribe__Events__Main::TAXONOMY];
}
$query = Tribe__Events__Query::getEvents($defaults, true);
$have_events = 0 < $query->found_posts;
if ($have_events && Tribe__Events__Pro__Geo_Loc::instance()->is_geoloc_query()) {
$lat = isset($_POST['tribe-bar-geoloc-lat']) ? $_POST['tribe-bar-geoloc-lat'] : 0;
$lng = isset($_POST['tribe-bar-geoloc-lng']) ? $_POST['tribe-bar-geoloc-lng'] : 0;
Tribe__Events__Pro__Geo_Loc::instance()->assign_distance_to_posts($query->posts, $lat, $lng);
} elseif (!$have_events && isset($_POST['tribe-bar-geoloc'])) {
Tribe__Notice::set_notice('event-search-no-results', sprintf(__('No results were found for events in or near <strong>"%s"</strong>.', 'tribe-events-calendar-pro'), esc_html($_POST['tribe-bar-geoloc'])));
} elseif (!$have_events && isset($_POST['tribe_event_category'])) {
Tribe__Notice::set_notice('events-not-found', sprintf(__('No matching events listed under %s. Please try viewing the full calendar for a complete list of events.', 'tribe-events-calendar-pro'), esc_html($_POST['tribe_event_category'])));
} elseif (!$have_events) {
Tribe__Notice::set_notice('event-search-no-results', __('There were no results found.', 'tribe-events-calendar-pro'));
}
$response = array('html' => '', 'markers' => array(), 'success' => true, 'tribe_paged' => $tribe_paged, 'max_pages' => $query->max_num_pages, 'total_count' => $query->found_posts, 'view' => $view_state);
// @TODO: clean this up / refactor the following conditional
if ($have_events) {
global $wp_query, $post;
$data = $query->posts;
$post = $query->posts[0];
$wp_query = $query;
Tribe__Events__Main::instance()->displaying = 'map';
ob_start();
tribe_get_view('pro/map/content');
$response['html'] .= ob_get_clean();
$response['markers'] = Tribe__Events__Pro__Geo_Loc::instance()->generate_markers($data);
} else {
global $wp_query;
$wp_query = $query;
Tribe__Events__Main::instance()->setDisplay();
ob_start();
tribe_get_view('pro/map/content');
$response['html'] .= ob_get_clean();
}
$response = apply_filters('tribe_events_ajax_response', $response);
header('Content-type: application/json');
echo json_encode($response);
exit;
}
示例6: ajax_response
/**
* List view ajax handler
*
*/
public function ajax_response()
{
Tribe__Events__Query::init();
$tribe_paged = !empty($_POST['tribe_paged']) ? intval($_POST['tribe_paged']) : 1;
$post_status = array('publish');
if (is_user_logged_in()) {
$post_status[] = 'private';
}
$args = array('eventDisplay' => 'list', 'post_type' => Tribe__Events__Main::POSTTYPE, 'post_status' => $post_status, 'paged' => $tribe_paged);
// check & set display
if (isset($_POST['tribe_event_display'])) {
if ($_POST['tribe_event_display'] == 'past') {
$args['eventDisplay'] = 'past';
$args['order'] = 'DESC';
} elseif ('all' == $_POST['tribe_event_display']) {
$args['eventDisplay'] = 'all';
}
}
// check & set event category
if (isset($_POST['tribe_event_category'])) {
$args[Tribe__Events__Main::TAXONOMY] = $_POST['tribe_event_category'];
}
$args = apply_filters('tribe_events_listview_ajax_get_event_args', $args, $_POST);
$query = tribe_get_events($args, true);
// $hash is used to detect whether the primary arguments in the query have changed (i.e. due to a filter bar request)
// if they have, we want to go back to page 1
$hash = $query->query_vars;
$hash['paged'] = null;
$hash['start_date'] = null;
$hash['end_date'] = null;
$hash_str = md5(maybe_serialize($hash));
if (!empty($_POST['hash']) && $hash_str !== $_POST['hash']) {
$tribe_paged = 1;
$args['paged'] = 1;
$query = Tribe__Events__Query::getEvents($args, true);
}
$response = array('html' => '', 'success' => true, 'max_pages' => $query->max_num_pages, 'hash' => $hash_str, 'tribe_paged' => $tribe_paged, 'total_count' => $query->found_posts, 'view' => 'list');
global $wp_query, $post, $paged;
$wp_query = $query;
if (!empty($query->posts)) {
$post = $query->posts[0];
}
$paged = $tribe_paged;
Tribe__Events__Main::instance()->displaying = apply_filters('tribe_events_listview_ajax_event_display', 'list', $args);
if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
$response['view'] = 'past';
}
ob_start();
tribe_get_view('list/content');
$response['html'] .= ob_get_clean();
apply_filters('tribe_events_ajax_response', $response);
header('Content-type: application/json');
echo json_encode($response);
die;
}
示例7: render_view
/**
* For default supported views, performs rendering and returns the result.
*/
public function render_view()
{
/**
* Fires before the embedded view is rendered.
*
* @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
*/
do_action('tribe_events_pro_tribe_events_shortcode_pre_render', $this);
ob_start();
$this->get_template_object()->add_input_hash();
echo '<div id="tribe-events" class="' . $this->get_wrapper_classes() . '">';
// Include the tribe bar HTML if required
if ($this->is_attribute_truthy('tribe-bar', true)) {
Tribe__Events__Bar::instance()->load_script();
tribe_get_template_part('modules/bar');
}
tribe_get_view($this->get_template_object()->view_path);
echo '</div>';
$html = ob_get_clean();
/**
* Fires after the embedded view is rendered.
*
* @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
*/
do_action('tribe_events_pro_tribe_events_shortcode_post_render', $this);
return $html;
}
示例8: die
*
* Override this template in your own theme by creating a file at [your-theme]/tribe-events/default-template.php
*
* @package TribeEventsCalendar
*
*/
if (!defined('ABSPATH')) {
die('-1');
}
get_header();
?>
<div id="tribe-events-pg-template">
<?php
dimox_breadcrumbs();
?>
<?php
tribe_events_before_html();
?>
<?php
tribe_get_view();
?>
<?php
tribe_events_after_html();
?>
</div> <!-- #tribe-events-pg-template -->
<?php
get_footer();
示例9: ajax_tribe_geosearch
/**
* AJAX handler for the Map view
*/
function ajax_tribe_geosearch()
{
$tribe_paged = !empty($_POST["tribe_paged"]) ? $_POST["tribe_paged"] : 1;
TribeEventsQuery::init();
$defaults = array('post_type' => TribeEvents::POSTTYPE, 'orderby' => 'event_date', 'order' => 'ASC', 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'paged' => $tribe_paged, 'post_status' => array('publish'), 'eventDisplay' => 'map');
$view_state = 'map';
/* if past view */
if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
$view_state = 'past';
}
if (isset($_POST['tribe_event_category'])) {
$defaults[TribeEvents::TAXONOMY] = $_POST['tribe_event_category'];
}
$query = TribeEventsQuery::getEvents($defaults, true);
$have_events = 0 < $query->found_posts;
if ($have_events && $this->is_geoloc_query()) {
$lat = isset($_POST['tribe-bar-geoloc-lat']) ? $_POST['tribe-bar-geoloc-lat'] : 0;
$lng = isset($_POST['tribe-bar-geoloc-lng']) ? $_POST['tribe-bar-geoloc-lng'] : 0;
$this->order_posts_by_distance($query->posts, $lat, $lng);
} elseif (!$have_events && isset($_POST['tribe-bar-geoloc'])) {
TribeEvents::setNotice('event-search-no-results', sprintf(__('No results were found for events in or near <strong>"%s"</strong>.', 'tribe-events-calendar-pro'), esc_html($_POST['tribe-bar-geoloc'])));
} elseif (!$have_events) {
TribeEvents::setNotice('event-search-no-results', __('There were no results found.', 'tribe-events-calendar-pro'));
}
$response = array('html' => '', 'markers' => array(), 'success' => true, 'tribe_paged' => $tribe_paged, 'max_pages' => $query->max_num_pages, 'total_count' => $query->found_posts, 'view' => $view_state);
if ($have_events) {
global $wp_query, $post;
$data = $query->posts;
$post = $query->posts[0];
$wp_query = $query;
TribeEvents::instance()->displaying = 'map';
ob_start();
tribe_get_view('pro/map/content');
$response['html'] .= ob_get_clean();
$response['markers'] = $this->generate_markers($data);
} else {
global $wp_query;
$wp_query = $query;
TribeEvents::instance()->setDisplay();
ob_start();
tribe_get_view('pro/map/content');
$response['html'] .= ob_get_clean();
}
apply_filters('tribe_events_ajax_response', $response);
header('Content-type: application/json');
echo json_encode($response);
exit;
}
示例10: ajax_response
/**
* AJAX handler for Photo view
*
* @return void
*/
function ajax_response()
{
$tec = TribeEvents::instance();
TribeEventsQuery::init();
$tribe_paged = !empty($_POST['tribe_paged']) ? intval($_POST['tribe_paged']) : 1;
$args = array('eventDisplay' => 'list', 'post_type' => TribeEvents::POSTTYPE, 'post_status' => 'publish', 'paged' => $tribe_paged);
$view_state = 'photo';
if (isset($_POST['tribe_event_category'])) {
$args[TribeEvents::TAXONOMY] = $_POST['tribe_event_category'];
}
/* if past view */
if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
$view_state = 'past';
$args['eventDisplay'] = 'past';
}
$query = TribeEventsQuery::getEvents($args, true);
$hash = $query->query_vars;
$hash['paged'] = null;
$hash['start_date'] = null;
$hash_str = md5(maybe_serialize($hash));
if (!empty($_POST['hash']) && $hash_str !== $_POST['hash']) {
$tribe_paged = 1;
$args['paged'] = 1;
$query = TribeEventsQuery::getEvents($args, true);
}
$response = array('html' => '', 'success' => true, 'max_pages' => $query->max_num_pages, 'hash' => $hash_str, 'tribe_paged' => $tribe_paged, 'view' => $view_state);
global $wp_query, $post;
$wp_query = $query;
if (!empty($query->posts)) {
$post = $query->posts[0];
}
add_filter('tribe_events_list_pagination', array('TribeEvents', 'clear_module_pagination'), 10);
$tec->displaying = 'photo';
ob_start();
tribe_get_view('pro/photo/content');
$response['html'] .= ob_get_clean();
apply_filters('tribe_events_ajax_response', $response);
header('Content-type: application/json');
echo json_encode($response);
die;
}
示例11: calendar_ajax_call
/**
* The Calendar View AJAX Handler.
*
* @return void
* @since 3.0
*/
function calendar_ajax_call()
{
if (isset($_POST["eventDate"]) && $_POST["eventDate"]) {
TribeEventsQuery::init();
global $wp_query;
// set the global query var for eventDisplay
$wp_query->set('eventDisplay', 'month');
if (!empty($_REQUEST['eventDate'])) {
$wp_query->set('eventDate', $_REQUEST['eventDate']);
}
if (isset($_POST['tribe_event_category'])) {
$wp_query->set(TribeEvents::TAXONOMY, $_POST['tribe_event_category']);
}
if (class_exists('TribeEventsFilterView')) {
TribeEventsFilterView::instance()->createFilters(null, true);
}
$wp_query->tribe_is_event_query = true;
$this->setDisplay();
ob_start();
tribe_get_view('month/content');
$response = array('html' => ob_get_clean(), 'success' => true, 'view' => 'month');
apply_filters('tribe_events_ajax_response', $response);
header('Content-type: application/json');
echo json_encode($response);
die;
}
}
示例12: ajax_tribe_geosearch
/**
* AJAX handler for the Map view
*/
function ajax_tribe_geosearch()
{
if (class_exists('TribeEventsFilterView')) {
TribeEventsFilterView::instance()->createFilters(null, true);
$this->setup_geoloc_filter_in_filters();
}
$tribe_paged = !empty($_POST["tribe_paged"]) ? $_POST["tribe_paged"] : 1;
TribeEventsQuery::init();
$defaults = array('post_type' => TribeEvents::POSTTYPE, 'orderby' => 'event_date', 'order' => 'ASC', 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'paged' => $tribe_paged, 'post_status' => array('publish'), 'eventDisplay' => 'map');
$view_state = 'map';
/* if past view */
if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') {
$view_state = 'past';
add_filter('tribe_events_pre_get_posts', array($this, 'set_past_events_query'));
}
$query = TribeEventsQuery::getEvents($defaults, true);
if ($this->is_geoloc_query() && $query->found_posts > 0) {
$lat = isset($_POST['tribe-bar-geoloc-lat']) ? $_POST['tribe-bar-geoloc-lat'] : 0;
$lng = isset($_POST['tribe-bar-geoloc-lng']) ? $_POST['tribe-bar-geoloc-lng'] : 0;
$this->order_posts_by_distance($query->posts, $lat, $lng);
}
$response = array('html' => '', 'markers' => array(), 'success' => true, 'tribe_paged' => $tribe_paged, 'max_pages' => $query->max_num_pages, 'total_count' => $query->found_posts, 'view' => $view_state);
if ($query->found_posts > 0) {
global $wp_query, $post;
$data = $query->posts;
$post = $query->posts[0];
$wp_query = $query;
TribeEvents::instance()->setDisplay();
ob_start();
tribe_get_view('map/content');
$response['html'] .= ob_get_clean();
$response['markers'] = $this->generate_markers($data);
} else {
global $wp_query;
$wp_query = $query;
TribeEvents::instance()->setDisplay();
ob_start();
tribe_get_view('map/content');
$response['html'] .= ob_get_clean();
}
apply_filters('tribe_events_ajax_response', $response);
header('Content-type: application/json');
echo json_encode($response);
exit;
}
示例13: die
* This is the template for the output of the mini calendar widget.
*
* Override this template in your own theme by creating a file at [your-theme]/tribe-events/widgets/mini-calendar-widget.php
*
* @package TribeEventsCalendarPro
* @since 3.0
* @author Modern Tribe Inc.
*
*/
if (!defined('ABSPATH')) {
die('-1');
}
?>
<?php
$args = tribe_events_get_mini_calendar_args();
?>
<div class="tribe-mini-calendar-wrapper">
<!-- Grid -->
<?php
tribe_show_month(array('tax_query' => $args['tax_query'], 'eventDate' => $args['eventDate']), 'widgets/mini-calendar/grid');
?>
<!-- List -->
<?php
tribe_get_view('widgets/mini-calendar/list');
?>
</div>
示例14: do_calendar
/**
*
* returns the full markup for the AJAX Calendar
*
* @static
*
* @param array $args
* -----> eventDate: date What month-year to print
* count: int # of events in the list (doesn't affect the calendar).
* tax_query: array For the events list (doesn't affect the calendar).
* Same format as WP_Query tax_queries. See sample below.
*
*
* tax_query sample:
*
* array( 'relation' => 'AND',
* array( 'taxonomy' => 'tribe_events_cat',
* 'field' => 'slug',
* 'terms' => array( 'featured' ),
* array( 'taxonomy' => 'post_tag',
* 'field' => 'id',
* 'terms' => array( 103, 115, 206 ),
* 'operator' => 'NOT IN' ) ) );
*
*
*/
public function do_calendar($args = array())
{
$this->args = $args;
if (!isset($this->args['eventDate'])) {
$this->args['eventDate'] = $this->get_month();
}
// don't show the list if they set it the widget option to show 0 events in the list
if ($this->args['count'] == 0) {
$this->show_list = false;
}
// enqueue the widget js
self::styles_and_scripts();
// widget setting for count is not 0
if (!$this->show_list) {
add_filter('tribe_events_template_widgets/mini-calendar/list.php', '__return_false');
}
tribe_get_view('widgets/mini-calendar-widget');
}
示例15: ajax_response
/**
* AJAX handler for tribe_event_day (dayview navigation)
* This loads up the day view shard with all the appropriate events for the day
*
* @return void
*/
function ajax_response()
{
if (isset($_POST['eventDate']) && $_POST['eventDate']) {
TribeEventsQuery::init();
$states[] = 'publish';
if (0 < get_current_user_id()) {
$states[] = 'private';
}
$args = array('post_status' => $states, 'eventDate' => $_POST["eventDate"], 'eventDisplay' => 'day');
TribeEvents::instance()->displaying = 'day';
if (isset($_POST['tribe_event_category'])) {
$args[TribeEvents::TAXONOMY] = $_POST['tribe_event_category'];
}
$query = TribeEventsQuery::getEvents($args, true);
global $wp_query, $post;
$wp_query = $query;
add_filter('tribe_is_day', '__return_true');
// simplest way to declare that this is a day view
ob_start();
tribe_get_view('day/content');
$response = array('html' => ob_get_clean(), 'success' => true, 'total_count' => $query->found_posts, 'view' => 'day');
apply_filters('tribe_events_ajax_response', $response);
header('Content-type: application/json');
echo json_encode($response);
die;
}
}