function bp_checkins_single_place_check_access() { if (bp_checkins_if_single_place()) { global $wp_query, $bp; $redirect = bp_get_checkins_places_home(); $check_places = wp_cache_get('single_query', 'bp_checkins_single'); if (false === $check_places) { $check_places = new BP_Checkins_Place(); $check_places->get(array('p' => bp_action_variable(0))); } $place_id = $check_places->query->post->ID; if (empty($place_id)) { bp_core_add_message(__('OOps, looks like this place does not exist ! You can try to search for it or browse categories', 'bp-checkins'), 'error'); bp_core_redirect($redirect); } else { if (bp_is_active('groups')) { // 1. check for group access !! $group_id = get_post_meta($place_id, '_bpci_group_id', true); $bp->groups->current_group = new BP_Groups_Group($group_id); if (isset($bp->groups->current_group->status) && 'public' != $bp->groups->current_group->status) { if (!is_user_logged_in() || !groups_is_user_member($bp->loggedin_user->id, $group_id)) { bp_core_add_message(__('OOps, looks like this place is private ! You can try to search for another one or browse categories', 'bp-checkins'), 'error'); bp_core_redirect($redirect); } } } // 2. check for live type to load the timer on the client side ! if ("live" == get_post_meta($place_id, 'bpci_places_is_live', true)) { $start = get_post_meta($place_id, 'bpci_places_live_start', true); $end = get_post_meta($place_id, 'bpci_places_live_end', true); $start = strtotime($start); $end = strtotime($end); $now = current_time('timestamp'); if ($end >= $now && $now >= $start) { add_filter('bp_get_the_body_class', 'bp_checkins_body_class_is_live'); } } add_filter('bp_get_the_body_class', 'bp_checkins_body_class_is_single_place'); // 3. Check for notifications if (isset($_GET['n'])) { bp_core_delete_notifications_by_item_id($bp->loggedin_user->id, $place_id, 'checkins', 'new_comment'); } } } }
function bp_checkins_browser_header($title_and_sep, $title, $sep, $seplocation) { if (bp_checkins_if_single_place()) { $place_title = ucfirst(bp_get_checkins_slug()) . ' ' . $sep . ' Place' . $title_and_sep; $place = wp_cache_get('single_query', 'bp_checkins_single'); if (false === $place || is_null($place->query->post->ID)) { $place = new BP_Checkins_Place(); $place->get(array('p' => bp_action_variable(0))); } $place_title = apply_filters('get_the_title', $place->query->post->post_title) . ' ' . $sep . ' Place' . $title_and_sep; return $place_title; } elseif (bp_checkins_if_category_place()) { return ucfirst(bp_get_checkins_places_term_info('name', bp_action_variable(1))) . $title_and_sep; } elseif (bp_checkins_if_place_home()) { return __('Browse or Search Places', 'bp-checkins') . $title_and_sep; } elseif (bp_checkins_is_directory()) { return ucfirst(bp_get_checkins_slug()) . ' & Places ' . $sep . ' '; } else { return $title_and_sep; } }
function bp_checkins_has_places($args = '') { global $bp, $places_template; $place_in_cache = false; // This keeps us from firing the query more than once if (empty($places_template)) { /*** * Set the defaults for the parameters you are accepting via the "bp_checkins_has_places()" * function call */ $defaults = array('id' => false, 'p' => false, 'group_id' => false, 'user_id' => false, 'per_page' => 10, 'paged' => 1, 'type' => false, 'places_category' => false, 'src' => false); $r = wp_parse_args($args, $defaults); extract($r, EXTR_SKIP); if (bp_checkins_is_group_places_area()) { $group_id = $bp->groups->current_group->id; } else { if (bp_action_variable(0) && bp_action_variable(0) != "category") { $p = bp_action_variable(0); $place = wp_cache_get('single_query', 'bp_checkins_single'); if (false !== $place && $place->query->post->post_name == $p) { $place_in_cache = $place; } } else { if (false !== wp_cache_get('single_query', 'bp_checkins_single')) { wp_cache_delete('single_query', 'bp_checkins_single'); } } if (bp_action_variable(0) && bp_action_variable(0) == "category" && bp_action_variable(1)) { $places_category = bp_action_variable(1); } if (bp_checkins_is_user_area() && bp_is_current_action('places-area')) { $user_id = $bp->displayed_user->id; } } if (empty($place_in_cache)) { $places_template = new BP_Checkins_Place(); if (!empty($src)) { $places_template->get(array('per_page' => $per_page, 'search' => $src)); } else { $places_template->get(array('id' => $id, 'p' => $p, 'group_id' => $group_id, 'user_id' => $user_id, 'per_page' => $per_page, 'paged' => $paged, 'type' => $type, 'places_category' => $places_category)); } } else { $places_template = $place_in_cache; } } return $places_template->have_posts(); }
/** * Update the global $post with directory data * * @since BuddyPress (1.7) */ public function single_place_dummy_post() { $place = wp_cache_get('single_query', 'bp_checkins_single'); if (false === $place) { $place = new BP_Checkins_Place(); $place->get(array('p' => bp_action_variable(0))); } bp_theme_compat_reset_post(array('ID' => 0, 'post_title' => $place->query->post->post_title, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => 'bp_checkins', 'post_status' => 'publish', 'is_archive' => false, 'comment_status' => 'closed', 'is_single' => true)); }