本文整理汇总了PHP中EM_Events::count方法的典型用法代码示例。如果您正苦于以下问题:PHP EM_Events::count方法的具体用法?PHP EM_Events::count怎么用?PHP EM_Events::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EM_Events
的用法示例。
在下文中一共展示了EM_Events::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_em_setup_nav
/**
* bp_em_setup_nav()
*
* Sets up the user profile navigation items for the component. This adds the top level nav
* item and all the sub level nav items to the navigation array. This is then
* rendered in the template.
*/
function bp_em_setup_nav()
{
global $bp;
$count = 0;
/* Add 'Events' to the main user profile navigation */
bp_core_new_nav_item(array('name' => __('Events', 'bp-em'), 'slug' => $bp->events->slug, 'position' => 80, 'screen_function' => bp_is_my_profile() ? 'bp_em_my_events' : 'bp_em_events', 'default_subnav_slug' => bp_is_my_profile() ? 'my-events' : ''));
$em_link = $bp->loggedin_user->domain . $bp->events->slug . '/';
/* Create two sub nav items for this component */
bp_core_new_subnav_item(array('name' => __('My Profile', 'dbem'), 'slug' => 'profile', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_events', 'position' => 10, 'user_has_access' => bp_is_my_profile()));
bp_core_new_subnav_item(array('name' => __('Events I\'m Attending', 'dbem'), 'slug' => 'attending', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_attending', 'position' => 20, 'user_has_access' => bp_is_my_profile()));
bp_core_new_subnav_item(array('name' => __('My Events', 'dbem'), 'slug' => 'my-events', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_events', 'position' => 30, 'user_has_access' => bp_is_my_profile()));
bp_core_new_subnav_item(array('name' => __('My Locations', 'dbem'), 'slug' => 'my-locations', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_locations', 'position' => 40, 'user_has_access' => bp_is_my_profile()));
bp_core_new_subnav_item(array('name' => __('My Event Bookings', 'dbem'), 'slug' => 'my-bookings', 'parent_slug' => $bp->events->slug, 'parent_url' => $em_link, 'screen_function' => 'bp_em_my_bookings', 'position' => 50, 'user_has_access' => bp_is_my_profile()));
/* Add a nav item for this component under the settings nav item. */
bp_core_new_subnav_item(array('name' => __('Events', 'dbem'), 'slug' => 'group-events', 'parent_slug' => $bp->groups->slug, 'parent_url' => $bp->loggedin_user->domain . $bp->groups->slug . '/', 'screen_function' => 'bp_em_my_group_events', 'position' => 60, 'user_has_access' => bp_is_my_profile()));
/* Add a nav item for this component under the settings nav item. */
bp_core_new_subnav_item(array('name' => __('Events', 'dbem'), 'slug' => 'events-settings', 'parent_slug' => $bp->settings->slug, 'parent_url' => $bp->loggedin_user->domain . $bp->settings->slug . '/', 'screen_function' => 'bp_em_screen_settings_menu', 'position' => 40, 'user_has_access' => bp_is_my_profile()));
/* Create two sub nav items for this component */
$group_link = $bp->root_domain . '/' . $bp->groups->slug . '/' . $bp->groups->current_group->slug . '/';
if ($bp->current_component == 'groups') {
$count = EM_Events::count(array('group' => $bp->groups->current_group->id));
if (empty($count)) {
$count = 0;
}
}
bp_core_new_subnav_item(array('name' => sprintf(__('Events (%s)', 'dbem'), $count), 'slug' => 'events', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->slug, 'screen_function' => 'bp_em_group_events', 'position' => 50, 'user_has_access' => $bp->groups->current_group->user_has_access, 'item_css_id' => 'forums'));
}
示例2: tag_taxonomy_workaround
/**
* Hooks in after EM_Tag_Taxonomy::template() and makes sure WPML doesn't reset $wp_query and wipe the work EM just did.
*/
public static function tag_taxonomy_workaround()
{
global $EM_Tag;
if (defined('EM_WPML_TAXONOMIES_TWEAKED') && EM_WPML_TAXONOMIES_TWEAKED) {
return;
}
//prevent endless loop
if (EM_Events::count(array('tag' => $EM_Tag->term_id)) == 0) {
self::preset_query($EM_Tag->output(get_option('dbem_tag_page_title_format')));
}
define('EM_WPML_TAXONOMIES_TWEAKED', true);
wp_reset_query();
add_filter('the_post', 'EM_Tag_Taxonomy::template', 1);
}
示例3: output
function output($format, $target = "html")
{
preg_match_all('/\\{([a-zA-Z0-9_]+)\\}([^{]+)\\{\\/[a-zA-Z0-9_]+\\}/', $format, $conditionals);
if (count($conditionals[0]) > 0) {
//Check if the language we want exists, if not we take the first language there
foreach ($conditionals[1] as $key => $condition) {
$format = str_replace($conditionals[0][$key], apply_filters('em_category_output_condition', '', $condition, $conditionals[0][$key], $this), $format);
}
}
$category_string = $format;
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders);
$replaces = array();
foreach ($placeholders[1] as $key => $result) {
$replace = '';
$full_result = $placeholders[0][$key];
switch ($result) {
case '#_CATEGORYNAME':
$replace = $this->name;
break;
case '#_CATEGORYID':
$replace = $this->term_id;
break;
case '#_CATEGORYNOTES':
case '#_CATEGORYDESCRIPTION':
$replace = $this->description;
break;
case '#_CATEGORYIMAGE':
case '#_CATEGORYIMAGEURL':
if ($this->get_image_url() != '') {
$image_url = esc_url($this->get_image_url());
if ($result == '#_CATEGORYIMAGEURL') {
$replace = $image_url;
} else {
if (empty($placeholders[3][$key])) {
$replace = "<img src='" . esc_url($this->get_image_url()) . "' alt='" . esc_attr($this->name) . "'/>";
} else {
$image_size = explode(',', $placeholders[3][$key]);
if (self::array_is_numeric($image_size) && count($image_size) > 1) {
if ($this->get_image_id()) {
//get a thumbnail
if (get_option('dbem_disable_thumbnails')) {
$image_attr = '';
$image_args = array();
if (empty($image_size[1]) && !empty($image_size[0])) {
$image_attr = 'width="' . $image_size[0] . '"';
$image_args['w'] = $image_size[0];
} elseif (empty($image_size[0]) && !empty($image_size[1])) {
$image_attr = 'height="' . $image_size[1] . '"';
$image_args['h'] = $image_size[1];
} elseif (!empty($image_size[0]) && !empty($image_size[1])) {
$image_attr = 'width="' . $image_size[0] . '" height="' . $image_size[1] . '"';
$image_args = array('w' => $image_size[0], 'h' => $image_size[1]);
}
$replace = "<img src='" . esc_url(em_add_get_params($image_url, $image_args)) . "' alt='" . esc_attr($this->name) . "' {$image_attr} />";
} else {
//since we previously didn't store image ids along with the url to the image (since taxonomies don't allow normal featured images), sometimes we won't be able to do this, which is why we check there's a valid image id first
self::ms_global_switch();
$replace = wp_get_attachment_image($this->get_image_id(), $image_size);
self::ms_global_switch_back();
}
}
} else {
$replace = "<img src='" . esc_url($this->get_image_url()) . "' alt='" . esc_attr($this->name) . "'/>";
}
}
}
}
break;
case '#_CATEGORYCOLOR':
$replace = $this->get_color();
break;
case '#_CATEGORYLINK':
case '#_CATEGORYURL':
$link = $this->get_url();
$replace = $result == '#_CATEGORYURL' ? $link : '<a href="' . $link . '">' . esc_html($this->name) . '</a>';
break;
case '#_CATEGORYICALURL':
case '#_CATEGORYICALLINK':
$replace = $this->get_ical_url();
if ($result == '#_CATEGORYICALLINK') {
$replace = '<a href="' . esc_url($replace) . '">iCal</a>';
}
break;
case '#_CATEGORYRSSURL':
case '#_CATEGORYRSSLINK':
$replace = $this->get_rss_url();
if ($result == '#_CATEGORYRSSLINK') {
$replace = '<a href="' . esc_url($replace) . '">RSS</a>';
}
break;
case '#_CATEGORYSLUG':
$replace = $this->slug;
break;
case '#_CATEGORYEVENTSPAST':
//deprecated, erroneous documentation, left for compatability
//deprecated, erroneous documentation, left for compatability
case '#_CATEGORYEVENTSNEXT':
//deprecated, erroneous documentation, left for compatability
//deprecated, erroneous documentation, left for compatability
case '#_CATEGORYEVENTSALL':
//.........这里部分代码省略.........
示例4: output
function output($format, $target = "html")
{
$location_string = $format;
//First let's do some conditional placeholder removals
for ($i = 0; $i < EM_CONDITIONAL_RECURSIONS; $i++) {
//you can add nested recursions by modifying this setting in your wp_options table
preg_match_all('/\\{([a-zA-Z0-9_]+)\\}(.+?)\\{\\/\\1\\}/s', $location_string, $conditionals);
if (count($conditionals[0]) > 0) {
//Check if the language we want exists, if not we take the first language there
foreach ($conditionals[1] as $key => $condition) {
$show_condition = false;
if ($condition == 'has_loc_image') {
//does this event have an image?
$show_condition = $this->get_image_url() != '';
} elseif ($condition == 'no_loc_image') {
//does this event have an image?
$show_condition = $this->get_image_url() == '';
}
$show_condition = apply_filters('em_location_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this);
if ($show_condition) {
//calculate lengths to delete placeholders
$placeholder_length = strlen($condition) + 2;
$replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key]) - ($placeholder_length * 2 + 1));
} else {
$replacement = '';
}
$location_string = str_replace($conditionals[0][$key], apply_filters('em_location_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $location_string);
}
}
}
//This is for the custom attributes
preg_match_all('/#_LATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $location_string, $results);
foreach ($results[0] as $resultKey => $result) {
//Strip string of placeholder and just leave the reference
$attRef = substr(substr($result, 0, strpos($result, '}')), 7);
$attString = '';
if (is_array($this->location_attributes) && array_key_exists($attRef, $this->location_attributes) && !empty($this->location_attributes[$attRef])) {
$attString = $this->location_attributes[$attRef];
} elseif (!empty($results[3][$resultKey])) {
//Check to see if we have a second set of braces;
$attString = $results[3][$resultKey];
}
$attString = apply_filters('em_location_output_placeholder', $attString, $this, $result, $target);
$location_string = str_replace($result, $attString, $location_string);
}
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $location_string, $placeholders);
$replaces = array();
foreach ($placeholders[1] as $key => $result) {
$replace = '';
$full_result = $placeholders[0][$key];
switch ($result) {
case '#_LOCATIONID':
$replace = $this->location_id;
break;
case '#_LOCATIONPOSTID':
$replace = $this->post_id;
break;
case '#_NAME':
//Depricated
//Depricated
case '#_LOCATION':
//Depricated
//Depricated
case '#_LOCATIONNAME':
$replace = $this->location_name;
break;
case '#_ADDRESS':
//Depricated
//Depricated
case '#_LOCATIONADDRESS':
$replace = $this->location_address;
break;
case '#_TOWN':
//Depricated
//Depricated
case '#_LOCATIONTOWN':
$replace = $this->location_town;
break;
case '#_LOCATIONSTATE':
$replace = $this->location_state;
break;
case '#_LOCATIONPOSTCODE':
$replace = $this->location_postcode;
break;
case '#_LOCATIONREGION':
$replace = $this->location_region;
break;
case '#_LOCATIONCOUNTRY':
$replace = $this->get_country();
break;
case '#_LOCATIONFULLLINE':
$replace = $this->location_address;
$replace .= empty($this->location_town) ? '' : ', ' . $this->location_town;
$replace .= empty($this->location_state) ? '' : ', ' . $this->location_state;
$replace .= empty($this->location_postcode) ? '' : ', ' . $this->location_postcode;
$replace .= empty($this->location_region) ? '' : ', ' . $this->location_region;
break;
case '#_LOCATIONFULLBR':
$replace = $this->location_address;
$replace .= empty($this->location_town) ? '' : '<br />' . $this->location_town;
//.........这里部分代码省略.........
示例5: em_admin_menu
function em_admin_menu()
{
global $menu, $submenu, $pagenow;
//Count pending bookings
if (get_option('dbem_rsvp_enabled')) {
$bookings_num = '';
$bookings_pending_count = apply_filters('em_bookings_pending_count', 0);
if (get_option('dbem_bookings_approval') == 1) {
$bookings_pending_count += count(EM_Bookings::get(array('status' => '0', 'blog' => get_current_blog_id()))->bookings);
}
if ($bookings_pending_count > 0) {
$bookings_num = '<span class="update-plugins count-' . $bookings_pending_count . '"><span class="plugin-count">' . $bookings_pending_count . '</span></span>';
}
} else {
$bookings_num = '';
$bookings_pending_count = 0;
}
//Count pending events
$events_num = '';
$events_pending_count = EM_Events::count(array('status' => 0, 'scope' => 'all', 'blog' => get_current_blog_id()));
//TODO Add flexible permissions
if ($events_pending_count > 0) {
$events_num = '<span class="update-plugins count-' . $events_pending_count . '"><span class="plugin-count">' . $events_pending_count . '</span></span>';
}
//Count pending recurring events
$events_recurring_num = '';
$events_recurring_pending_count = EM_Events::count(array('status' => 0, 'recurring' => 1, 'scope' => 'all', 'blog' => get_current_blog_id()));
//TODO Add flexible permissions
if ($events_recurring_pending_count > 0) {
$events_recurring_num = '<span class="update-plugins count-' . $events_recurring_pending_count . '"><span class="plugin-count">' . $events_recurring_pending_count . '</span></span>';
}
$both_pending_count = apply_filters('em_items_pending_count', $events_pending_count + $bookings_pending_count + $events_recurring_pending_count);
$both_num = $both_pending_count > 0 ? '<span class="update-plugins count-' . $both_pending_count . '"><span class="plugin-count">' . $both_pending_count . '</span></span>' : '';
// Add a submenu to the custom top-level menu:
$plugin_pages = array();
if (get_option('dbem_rsvp_enabled')) {
$plugin_pages['bookings'] = add_submenu_page('edit.php?post_type=' . EM_POST_TYPE_EVENT, __('Bookings', 'events-manager'), __('Bookings', 'events-manager') . $bookings_num, 'manage_bookings', 'events-manager-bookings', "em_bookings_page");
}
$plugin_pages['options'] = add_submenu_page('edit.php?post_type=' . EM_POST_TYPE_EVENT, __('Events Manager Settings', 'events-manager'), __('Settings', 'events-manager'), 'manage_options', "events-manager-options", 'em_admin_options_page');
$plugin_pages['help'] = add_submenu_page('edit.php?post_type=' . EM_POST_TYPE_EVENT, __('Getting Help for Events Manager', 'events-manager'), __('Help', 'events-manager'), 'manage_options', "events-manager-help", 'em_admin_help_page');
//If multisite global with locations set to be saved in main blogs we can force locations to be created on the main blog only
if (EM_MS_GLOBAL && !is_main_site() && get_site_option('dbem_ms_mainblog_locations')) {
include dirname(__FILE__) . "/em-ms-locations.php";
$plugin_pages['locations'] = add_submenu_page('edit.php?post_type=' . EM_POST_TYPE_EVENT, __('Locations', 'events-manager'), __('Locations', 'events-manager'), 'read_others_locations', "locations", 'em_admin_ms_locations');
}
$plugin_pages = apply_filters('em_create_events_submenu', $plugin_pages);
//We have to modify the menus manually
if (!empty($both_num)) {
//Main Event Menu
//go through the menu array and modify the events menu if found
foreach ((array) $menu as $key => $parent_menu) {
if ($parent_menu[2] == 'edit.php?post_type=' . EM_POST_TYPE_EVENT) {
$menu[$key][0] = $menu[$key][0] . $both_num;
break;
}
}
}
if (!empty($events_num) && !empty($submenu['edit.php?post_type=' . EM_POST_TYPE_EVENT])) {
//Submenu Event Item
//go through the menu array and modify the events menu if found
foreach ((array) $submenu['edit.php?post_type=' . EM_POST_TYPE_EVENT] as $key => $submenu_item) {
if ($submenu_item[2] == 'edit.php?post_type=' . EM_POST_TYPE_EVENT) {
$submenu['edit.php?post_type=' . EM_POST_TYPE_EVENT][$key][0] = $submenu['edit.php?post_type=' . EM_POST_TYPE_EVENT][$key][0] . $events_num;
break;
}
}
}
if (!empty($events_recurring_num) && !empty($submenu['edit.php?post_type=' . EM_POST_TYPE_EVENT])) {
//Submenu Recurring Event Item
//go through the menu array and modify the events menu if found
foreach ((array) $submenu['edit.php?post_type=' . EM_POST_TYPE_EVENT] as $key => $submenu_item) {
if ($submenu_item[2] == 'edit.php?post_type=event-recurring') {
$submenu['edit.php?post_type=' . EM_POST_TYPE_EVENT][$key][0] = $submenu['edit.php?post_type=' . EM_POST_TYPE_EVENT][$key][0] . $events_recurring_num;
break;
}
}
}
/* Hack! Add location/recurrence isn't possible atm so this is a workaround */
global $_wp_submenu_nopriv;
if ($pagenow == 'post-new.php' && !empty($_REQUEST['post_type'])) {
if ($_REQUEST['post_type'] == EM_POST_TYPE_LOCATION && !empty($_wp_submenu_nopriv['edit.php']['post-new.php']) && current_user_can('edit_locations')) {
unset($_wp_submenu_nopriv['edit.php']['post-new.php']);
}
if ($_REQUEST['post_type'] == 'event-recurring' && !empty($_wp_submenu_nopriv['edit.php']['post-new.php']) && current_user_can('edit_recurring_events')) {
unset($_wp_submenu_nopriv['edit.php']['post-new.php']);
}
}
}
示例6: setup_group_nav
function setup_group_nav()
{
global $bp;
/* Add some group subnav items */
$user_access = false;
$group_link = '';
if (bp_is_active('groups') && !empty($bp->groups->current_group)) {
$group_link = $bp->root_domain . '/' . bp_get_groups_root_slug() . '/' . $bp->groups->current_group->slug . '/';
$user_access = $bp->groups->current_group->user_has_access;
if (!empty($bp->current_component) && $bp->current_component == 'groups') {
$count = EM_Events::count(array('group' => $bp->groups->current_group->id));
if (empty($count)) {
$count = 0;
}
}
bp_core_new_subnav_item(array('name' => __('Events', 'dbem') . " <span>{$count}</span>", 'slug' => 'events', 'parent_url' => $group_link, 'parent_slug' => $bp->groups->current_group->slug, 'screen_function' => 'bp_em_group_events', 'position' => 50, 'user_has_access' => $user_access, 'item_css_id' => 'forums'));
}
}
示例7: restrict_views
/**
* Adds Future view to make things simpler, and also changes counts if user doesn't have edit_others_events permission
* @param array $views
* @return array
*/
public static function restrict_views($views)
{
global $wp_query;
//TODO alter views of locations, events and recurrences, specifically find a good way to alter the wp_count_posts method to force user owned posts only
$post_type = get_current_screen()->post_type;
if (in_array($post_type, array(EM_POST_TYPE_EVENT, 'event-recurring'))) {
//get counts for future events
$num_posts = wp_count_posts($post_type, 'readable');
//prepare to alter cache if neccessary
if (!isset($num_posts->em_future)) {
$cache_key = $post_type;
$user = wp_get_current_user();
if (is_user_logged_in() && !current_user_can('read_private_events')) {
$cache_key .= '_readable_' . $user->ID;
//as seen on wp_count_posts
}
$args = array('scope' => 'future', 'status' => 'all');
if ($post_type == 'event-recurring') {
$args['recurring'] = 1;
}
$num_posts->em_future = EM_Events::count($args);
wp_cache_set($cache_key, $num_posts, 'counts');
}
$class = '';
//highlight the 'Future' status if necessary
if (empty($_REQUEST['post_status']) && !empty($wp_query->query_vars['scope']) && $wp_query->query_vars['scope'] == 'future') {
$class = ' class="current"';
foreach ($views as $key => $view) {
$views[$key] = str_replace(' class="current"', '', $view);
}
}
//change the 'All' status to have scope=all
$views['all'] = str_replace('edit.php?', 'edit.php?scope=all&', $views['all']);
//merge new custom status into views
$old_views = $views;
$views = array('em_future' => "<a href='edit.php?post_type={$post_type}'{$class}>" . sprintf(_nx('Future <span class="count">(%s)</span>', 'Future <span class="count">(%s)</span>', $num_posts->em_future, 'events', 'events-manager'), number_format_i18n($num_posts->em_future)) . '</a>');
$views = array_merge($views, $old_views);
}
return $views;
}
示例8: em_admin_events_page
/**
* Determines whether to show event page or events page, and saves any updates to the event or events
* @return null
*/
function em_admin_events_page()
{
//TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc)
global $wpdb, $EM_Notices, $EM_Event;
$action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
$order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC';
$limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20;
//Default limit
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
$offset = $page > 1 ? ($page - 1) * $limit : 0;
$search = !empty($_REQUEST['em_search']) ? $_REQUEST['em_search'] : '';
$scope_names = em_get_scopes();
$scope = !empty($_REQUEST['scope']) && array_key_exists($_REQUEST['scope'], $scope_names) ? $_REQUEST['scope'] : 'future';
$selectedEvents = !empty($_REQUEST['events']) ? $_REQUEST['events'] : '';
$args = array('scope' => $scope, 'limit' => 0, 'order' => $order, 'search' => $search);
if (!current_user_can('edit_others_events')) {
$args['owner'] = get_current_user_id();
}
//Figure out what status to search for
$args['status'] = isset($_REQUEST['status']) && is_numeric($_REQUEST['status']) ? $_REQUEST['status'] : false;
$events = EM_Events::get($args);
$events_count = count($events);
$pending_count = EM_Events::count(array('status' => 0, 'scope' => $scope));
$approved_count = EM_Events::count(array('status' => 1, 'scope' => $scope));
$total_count = EM_Events::count(array('status' => false, 'scope' => $scope));
$use_events_end = get_option('dbem_use_event_end');
echo $EM_Notices;
?>
<div class="wrap">
<div id="icon-events" class="icon32"><br />
</div>
<h2>
<?php
echo $scope_names[$scope];
?>
<a href="admin.php?page=events-manager-event" class="button add-new-h2"><?php
_e('Add New', 'dbem');
?>
</a>
</h2>
<?php
$link = array();
$link['past'] = "<a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&scope=past&order=desc'>" . __('Past events', 'dbem') . "</a>";
$link['all'] = " <a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&scope=all&order=desc'>" . __('All events', 'dbem') . "</a>";
$link['future'] = " <a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=events-manager&scope=future'>" . __('Future events', 'dbem') . "</a>";
?>
<?php
if (!empty($_REQUEST['error'])) {
?>
<div id='message' class='error'>
<p><?php
echo $_REQUEST['error'];
?>
</p>
</div>
<?php
}
?>
<?php
if (!empty($_REQUEST['message'])) {
?>
<div id='message' class='updated fade'>
<p><?php
echo $_REQUEST['message'];
?>
</p>
</div>
<?php
}
?>
<form id="posts-filter" action="" method="get"><input type='hidden' name='page' value='events-manager' />
<ul class="subsubsub">
<li><a href='<?php
bloginfo('wpurl');
?>
/wp-admin/admin.php?page=events-manager&scope=<?php
echo $scope;
?>
' <?php
echo !isset($_REQUEST['status']) ? 'class="current"' : '';
?>
><?php
_e('Total', 'dbem');
?>
<span class="count">(<?php
echo $total_count;
?>
)</span></a></li>
<?php
if (current_user_can('publish_events')) {
?>
<li>| <a href='<?php
bloginfo('wpurl');
?>
/wp-admin/admin.php?page=events-manager&scope=<?php
//.........这里部分代码省略.........
示例9: em_events_admin
/**
* Outputs table of events belonging to user
* Additional search arguments:
* * show_add_new - passes argument to template as $show_add_new whether to show the add new event button
* @param array $args
*/
function em_events_admin($args = array())
{
global $EM_Event, $bp;
if (is_user_logged_in() && current_user_can('edit_events')) {
if (!empty($_GET['action']) && $_GET['action'] == 'edit') {
if (empty($_REQUEST['redirect_to'])) {
$_REQUEST['redirect_to'] = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => null, 'event_id' => null));
}
em_event_form();
} else {
if (get_option('dbem_css_editors')) {
echo '<div class="css-events-admin">';
}
//template $args for different views
$args_views['pending'] = array('status' => 0, 'owner' => get_current_user_id(), 'scope' => 'all', 'recurring' => 'include');
$args_views['draft'] = array('status' => null, 'owner' => get_current_user_id(), 'scope' => 'all', 'recurring' => 'include');
$args_views['past'] = array('status' => 'all', 'owner' => get_current_user_id(), 'scope' => 'past');
$args_views['future'] = array('status' => '1', 'owner' => get_current_user_id(), 'scope' => 'future');
//get listing options for $args
$limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20;
//Default limit
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
$offset = $page > 1 ? ($page - 1) * $limit : 0;
$order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC';
$search = !empty($_REQUEST['em_search']) ? $_REQUEST['em_search'] : '';
//deal with view or scope/status combinations
$show_add_new = isset($args['show_add_new']) ? $args['show_add_new'] : true;
$args = array('order' => $order, 'search' => $search, 'owner' => get_current_user_id());
if (!empty($_REQUEST['view']) && in_array($_REQUEST['view'], array('future', 'draft', 'past', 'pending'))) {
$args = array_merge($args, $args_views[$_REQUEST['view']]);
} else {
$scope_names = em_get_scopes();
$args['scope'] = !empty($_REQUEST['scope']) && array_key_exists($_REQUEST['scope'], $scope_names) ? $_REQUEST['scope'] : 'future';
if (array_key_exists('status', $_REQUEST)) {
$status = $_REQUEST['status'] ? 1 : 0;
if ($_REQUEST['status'] == 'all') {
$status = 'all';
}
if ($_REQUEST['status'] == 'draft') {
$status = null;
}
} else {
$status = false;
}
$args['status'] = $status;
}
$events_count = EM_Events::count($args);
//count events without limits for pagination
$args['limit'] = $limit;
$args['offset'] = $offset;
$EM_Events = EM_Events::get($args);
//now get the limited events to display
$future_count = EM_Events::count($args_views['future']);
$pending_count = EM_Events::count($args_views['pending']);
$draft_count = EM_Events::count($args_views['draft']);
$past_count = EM_Events::count($args_views['past']);
em_locate_template('tables/events.php', true, array('args' => $args, 'EM_Events' => $EM_Events, 'events_count' => $events_count, 'future_count' => $future_count, 'pending_count' => $pending_count, 'draft_count' => $draft_count, 'past_count' => $past_count, 'page' => $page, 'limit' => $limit, 'offset' => $offset, 'show_add_new' => $show_add_new));
if (get_option('dbem_css_editors')) {
echo '</div>';
}
}
} elseif (!is_user_logged_in() && get_option('dbem_events_anonymous_submissions')) {
em_event_form($args);
} else {
if (get_option('dbem_css_editors')) {
echo '<div class="css-events-admin">';
}
echo '<div class="css-events-admin-login">' . apply_filters('em_event_submission_login', __("You must log in to view and manage your events.", 'dbem')) . '</div>';
if (get_option('dbem_css_editors')) {
echo '</div>';
}
}
}
示例10: output
function output($format, $target = "html")
{
preg_match_all('/\\{([a-zA-Z0-9_]+)\\}([^{]+)\\{\\/[a-zA-Z0-9_]+\\}/', $format, $conditionals);
if (count($conditionals[0]) > 0) {
//Check if the language we want exists, if not we take the first language there
foreach ($conditionals[1] as $key => $condition) {
$format = str_replace($conditionals[0][$key], apply_filters('em_category_output_condition', '', $condition, $conditionals[0][$key], $this), $format);
}
}
$category_string = $format;
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders);
foreach ($placeholders[1] as $key => $result) {
$replace = '';
$full_result = $placeholders[0][$key];
switch ($result) {
case '#_CATEGORYNAME':
$replace = $this->name;
break;
case '#_CATEGORYID':
$replace = $this->term_id;
break;
case '#_CATEGORYNOTES':
case '#_CATEGORYDESCRIPTION':
$replace = $this->description;
break;
case '#_CATEGORYIMAGE':
case '#_CATEGORYIMAGEURL':
if ($this->get_image_url() != '') {
if ($result == '#_CATEGORYIMAGEURL') {
$replace = $this->get_image_url();
} else {
if (empty($placeholders[3][$key])) {
$replace = "<img src='" . esc_url($this->get_image_url()) . "' alt='" . esc_attr($this->name) . "'/>";
} else {
$image_size = explode(',', $placeholders[3][$key]);
if ($this->array_is_numeric($image_size) && count($image_size) > 1) {
if (get_option('dbem_disable_timthumb') && $this->get_image_id()) {
//since we previously didn't store image ids along with the url to the image (since taxonomies don't allow normal featured images), sometimes we won't be able to do this, which is why we check there's a valid image id first
$this->ms_global_switch();
$replace = wp_get_attachment_image($this->get_image_id(), $image_size);
$this->ms_global_switch_back();
} else {
$replace = "<img src='" . em_get_thumbnail_url($this->get_image_url(), $image_size[0], $image_size[1]) . "' alt='" . esc_attr($this->name) . "' width='{$image_size[0]}' height='{$image_size[1]}'/>";
}
} else {
$replace = "<img src='" . esc_url($this->get_image_url()) . "' alt='" . esc_attr($this->name) . "'/>";
}
}
}
}
break;
case '#_CATEGORYCOLOR':
$replace = $this->get_color();
break;
case '#_CATEGORYLINK':
case '#_CATEGORYURL':
$link = $this->get_url();
$replace = $result == '#_CATEGORYURL' ? $link : '<a href="' . $link . '">' . esc_html($this->name) . '</a>';
break;
case '#_CATEGORYSLUG':
$replace = $this->slug;
break;
case '#_CATEGORYEVENTSPAST':
//depreciated, erroneous documentation, left for compatability
//depreciated, erroneous documentation, left for compatability
case '#_CATEGORYEVENTSNEXT':
//depreciated, erroneous documentation, left for compatability
//depreciated, erroneous documentation, left for compatability
case '#_CATEGORYEVENTSALL':
//depreciated, erroneous documentation, left for compatability
//depreciated, erroneous documentation, left for compatability
case '#_CATEGORYPASTEVENTS':
case '#_CATEGORYNEXTEVENTS':
case '#_CATEGORYALLEVENTS':
//convert depreciated placeholders for compatability
$result = $result == '#_CATEGORYEVENTSPAST' ? '#_CATEGORYPASTEVENTS' : $result;
$result = $result == '#_CATEGORYEVENTSNEXT' ? '#_CATEGORYNEXTEVENTS' : $result;
$result = $result == '#_CATEGORYEVENTSALL' ? '#_CATEGORYALLEVENTS' : $result;
//forget it ever happened? :/
if ($result == '#_CATEGORYPASTEVENTS') {
$scope = 'past';
} elseif ($result == '#_CATEGORYNEXTEVENTS') {
$scope = 'future';
} else {
$scope = 'all';
}
$events_count = EM_Events::count(array('category' => $this->term_id, 'scope' => $scope));
if ($events_count > 0) {
$args = array('category' => $this->term_id, 'scope' => $scope, 'pagination' => 1);
$args['format_header'] = get_option('dbem_category_event_list_item_header_format');
$args['format_footer'] = get_option('dbem_category_event_list_item_footer_format');
$args['format'] = get_option('dbem_category_event_list_item_format');
$args['limit'] = get_option('dbem_category_event_list_limit');
$args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
$replace = EM_Events::output($args);
} else {
$replace = get_option('dbem_category_no_events_message', '</ul>');
}
break;
default:
//.........这里部分代码省略.........
示例11: em_create_events_submenu
function em_create_events_submenu()
{
if (function_exists('add_submenu_page')) {
//Count pending bookings
$bookings_num = '';
$bookings_pending_count = 0;
if (get_option('dbem_bookings_approval') == 1) {
$bookings_pending_count = count(EM_Bookings::get(array('status' => 0))->bookings);
//TODO Add flexible permissions
if ($bookings_pending_count > 0) {
$bookings_num = '<span class="update-plugins count-' . $bookings_pending_count . '"><span class="plugin-count">' . $bookings_pending_count . '</span></span>';
}
}
//Count pending events
$events_num = '';
$events_pending_count = EM_Events::count(array('status' => 0, 'scope' => 'all'));
//TODO Add flexible permissions
if ($events_pending_count > 0) {
$events_num = '<span class="update-plugins count-' . $events_pending_count . '"><span class="plugin-count">' . $events_pending_count . '</span></span>';
}
$both_pending_count = $events_pending_count + $bookings_pending_count;
$both_num = $both_pending_count > 0 ? '<span class="update-plugins count-' . $both_pending_count . '"><span class="plugin-count">' . $both_pending_count . '</span></span>' : '';
add_object_page(__('Events', 'dbem'), __('Events', 'dbem') . $both_num, 'edit_events', 'events-manager', 'em_admin_events_page', '../wp-content/plugins/events-manager/includes/images/calendar-16.png');
// Add a submenu to the custom top-level menu:
$plugin_pages = array();
$plugin_pages[] = add_submenu_page('events-manager', __('Edit'), __('Edit') . $events_num, 'edit_events', 'events-manager', 'em_admin_events_page');
$plugin_pages[] = add_submenu_page('events-manager', __('Add new', 'dbem'), __('Add new', 'dbem'), 'edit_events', 'events-manager-event', "em_admin_event_page");
$plugin_pages[] = add_submenu_page('events-manager', __('Locations', 'dbem'), __('Locations', 'dbem'), 'edit_locations', 'events-manager-locations', "em_admin_locations_page");
$plugin_pages[] = add_submenu_page('events-manager', __('Bookings', 'dbem'), __('Bookings', 'dbem') . $bookings_num, 'manage_bookings', 'events-manager-bookings', "em_bookings_page");
$plugin_pages[] = add_submenu_page('events-manager', __('Event Categories', 'dbem'), __('Categories', 'dbem'), 'edit_categories', "events-manager-categories", 'em_admin_categories_page');
$plugin_pages[] = add_submenu_page('events-manager', __('Events Manager Settings', 'dbem'), __('Settings', 'dbem'), 'activate_plugins', "events-manager-options", 'em_admin_options_page');
$plugin_pages[] = add_submenu_page('events-manager', __('Getting Help for Events Manager', 'dbem'), __('Help', 'dbem'), 'activate_plugins', "events-manager-help", 'em_admin_help_page');
$plugin_pages = apply_filters('em_create_events_submenu', $plugin_pages);
foreach ($plugin_pages as $plugin_page) {
add_action('admin_print_scripts-' . $plugin_page, 'em_admin_load_scripts');
add_action('admin_head-' . $plugin_page, 'em_admin_general_script');
add_action('admin_print_styles-' . $plugin_page, 'em_admin_load_styles');
}
}
}
示例12: em_events_admin
/**
* Outputs table of events belonging to user
* @param array $args
*/
function em_events_admin($args = array())
{
global $EM_Event, $bp;
if (is_user_logged_in() && current_user_can('edit_events')) {
if (!empty($_GET['action']) && $_GET['action'] == 'edit') {
if (empty($_REQUEST['redirect_to'])) {
$_REQUEST['redirect_to'] = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => null, 'event_id' => null));
}
em_event_form();
} else {
$limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20;
//Default limit
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
$offset = $page > 1 ? ($page - 1) * $limit : 0;
$order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC';
$scope_names = em_get_scopes();
$scope = !empty($_REQUEST['scope']) && array_key_exists($_REQUEST['scope'], $scope_names) ? $_REQUEST['scope'] : 'future';
if (array_key_exists('status', $_REQUEST)) {
$status = $_REQUEST['status'] ? 1 : 0;
} else {
$status = false;
}
$search = !empty($_REQUEST['em_search']) ? $_REQUEST['em_search'] : '';
$args = array('scope' => $scope, 'order' => $order, 'search' => $search, 'owner' => get_current_user_id(), 'status' => $status);
$events_count = EM_Events::count($args);
//count events without limits for pagination
$args['limit'] = $limit;
$args['offset'] = $offset;
$EM_Events = EM_Events::get($args);
if ($scope != 'future') {
$future_count = EM_Events::count(array('status' => 1, 'owner' => get_current_user_id(), 'scope' => 'future'));
} else {
$future_count = $events_count;
}
$pending_count = EM_Events::count(array('status' => 0, 'owner' => get_current_user_id(), 'scope' => 'all'));
em_locate_template('tables/events.php', true, array('args' => $args, 'EM_Events' => $EM_Events, 'events_count' => $events_count, 'future_count' => $future_count, 'pending_count' => $pending_count, 'page' => $page, 'limit' => $limit, 'offset' => $offset, 'show_add_new' => true));
}
} elseif (!is_user_logged_in() && get_option('dbem_events_anonymous_submissions')) {
em_event_form($args);
} else {
echo apply_filters('em_event_submission_login', __("You must log in to view and manage your events.", 'dbem'));
}
}
示例13: output
function output($format, $target = "html")
{
preg_match_all('/\\{([a-zA-Z0-9_]+)\\}([^{]+)\\{\\/[a-zA-Z0-9_]+\\}/', $format, $conditionals);
if (count($conditionals[0]) > 0) {
foreach ($conditionals[1] as $key => $condition) {
$format = str_replace($conditionals[0][$key], apply_filters('em_tag_output_condition', '', $condition, $conditionals[0][$key], $this), $format);
}
}
$tag_string = $format;
preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders);
$replaces = array();
foreach ($placeholders[1] as $key => $result) {
$match = true;
$replace = '';
$full_result = $placeholders[0][$key];
switch ($result) {
case '#_TAGNAME':
$replace = $this->name;
break;
case '#_TAGID':
$replace = $this->term_id;
break;
case '#_TAGLINK':
case '#_TAGURL':
$link = $this->get_url();
$replace = $result == '#_TAGURL' ? $link : '<a href="' . $link . '">' . esc_html($this->name) . '</a>';
break;
case '#_TAGICALURL':
case '#_TAGICALLINK':
$replace = $this->get_ical_url();
if ($result == '#_TAGICALLINK') {
$replace = '<a href="' . esc_url($replace) . '">iCal</a>';
}
break;
case '#_TAGRSSURL':
case '#_TAGRSSLINK':
$replace = $this->get_rss_url();
if ($result == '#_TAGRSSLINK') {
$replace = '<a href="' . esc_url($replace) . '">RSS</a>';
}
break;
case '#_TAGNOTES':
$replace = $this->description;
break;
case '#_TAGEVENTSPAST':
//depreciated, erroneous documentation, left for compatability
//depreciated, erroneous documentation, left for compatability
case '#_TAGEVENTSNEXT':
//depreciated, erroneous documentation, left for compatability
//depreciated, erroneous documentation, left for compatability
case '#_TAGEVENTSALL':
//depreciated, erroneous documentation, left for compatability
//depreciated, erroneous documentation, left for compatability
case '#_TAGPASTEVENTS':
case '#_TAGNEXTEVENTS':
case '#_TAGALLEVENTS':
//convert depreciated placeholders for compatability
$result = $result == '#_TAGEVENTSPAST' ? '#_TAGPASTEVENTS' : $result;
$result = $result == '#_TAGEVENTSNEXT' ? '#_TAGNEXTEVENTS' : $result;
$result = $result == '#_TAGEVENTSALL' ? '#_TAGALLEVENTS' : $result;
//forget it ever happened? :/
if ($result == '#_TAGPASTEVENTS') {
$scope = 'past';
} elseif ($result == '#_TAGNEXTEVENTS') {
$scope = 'future';
} else {
$scope = 'all';
}
$events_count = EM_Events::count(array('tag' => $this->term_id, 'scope' => $scope));
if ($events_count > 0) {
$args = array('tag' => $this->term_id, 'scope' => $scope, 'pagination' => 1, 'ajax' => 0);
$args['format_header'] = get_option('dbem_tag_event_list_item_header_format');
$args['format_footer'] = get_option('dbem_tag_event_list_item_footer_format');
$args['format'] = get_option('dbem_tag_event_list_item_format');
$args['limit'] = get_option('dbem_tag_event_list_limit');
$args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
$replace = EM_Events::output($args);
} else {
$replace = get_option('dbem_tag_no_events_message');
}
break;
case '#_TAGNEXTEVENT':
$events = EM_Events::get(array('tag' => $this->term_id, 'scope' => 'future', 'limit' => 1, 'orderby' => 'event_start_date,event_start_time'));
$replace = get_option('dbem_tag_no_event_message');
foreach ($events as $EM_Event) {
$replace = $EM_Event->output(get_option('dbem_tag_event_single_format'));
}
break;
default:
$replace = $full_result;
break;
}
$replaces[$full_result] = apply_filters('em_tag_output_placeholder', $replace, $this, $full_result, $target);
}
krsort($replaces);
foreach ($replaces as $full_result => $replacement) {
$tag_string = str_replace($full_result, $replacement, $tag_string);
}
return apply_filters('em_tag_output', $tag_string, $this, $format, $target);
}
示例14: count
<?php
/* WARNING! This file may change in the near future as we intend to add features to BuddyPress - 2012-02-14 */
global $bp, $EM_Notices;
echo $EM_Notices;
$url = $bp->events->link . 'my-events/';
//url to this page
$order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC';
$limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20;
//Default limit
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
$offset = $page > 1 ? ($page - 1) * $limit : 0;
$EM_Events = EM_Events::get(array('group' => 'my', 'scope' => 'future', 'limit' => 0, 'order' => $order));
$events_count = count($EM_Events);
$future_count = EM_Events::count(array('status' => 1, 'owner' => get_current_user_id(), 'scope' => 'future'));
$pending_count = EM_Events::count(array('status' => 0, 'owner' => get_current_user_id(), 'scope' => 'all'));
$use_events_end = get_option('dbem_use_event_end');
echo $EM_Notices;
?>
<div class="tablenav">
<?php
if ($events_count >= $limit) {
$events_nav = em_admin_paginate($events_count, $limit, $page);
echo $events_nav;
}
?>
<br class="clear" />
</div>
<?php
if (empty($EM_Events)) {
示例15: array
<?php
/*
* Default Calendar day
* This page displays a list of events or single event for a specific calendar day, called during the em_content() if this is an calendar day page.
* You can override the default display settings pages by copying this file to yourthemefolder/plugins/events-manager/templates/ and modifying it however you need.
* You can display events however you wish, there are a few variables made available to you:
*
* $args - the args passed onto EM_Events::output()
*
*/
$args['scope'] = $_REQUEST['calendar_day'];
$events_count = EM_Events::count(apply_filters('em_content_calendar_day_args', $args));
//Get events first, so we know how many there are in advance
if ($events_count > 1 || get_option('dbem_display_calendar_day_single') == 1) {
em_locate_template('templates/events-list.php', true, array('args' => apply_filters('em_content_calendar_day_output_args', $args)));
} elseif ($events_count == 1) {
$args['format'] = get_option('dbem_single_event_format');
echo EM_Events::output(apply_filters('em_content_calendar_day_output_args', $args));
} else {
echo get_option('dbem_no_events_message');
}