Ejemplo n.º 1
0
/**
 * Filter for titles when on event pages
 * @param $data
 * @return string
 */
function em_events_page_title($content)
{
    global $EM_Event;
    global $post;
    $events_page_id = get_option('dbem_events_page');
    if ($post->ID == $events_page_id && $events_page_id != 0) {
        if (isset($_REQUEST['calendar_day']) && $_REQUEST['calendar_day'] != '') {
            $events = EM_Events::get(array('limit' => 2, 'scope' => $_REQUEST['calendar_day'], 'owner' => false));
            if (count($events) != 1 || get_option('dbem_display_calendar_day_single') == 1) {
                //We only support dates for the calendar day list title, so we do a simple filter for the supplied calendar_day
                $content = get_option('dbem_list_date_title');
                preg_match_all("/#[A-Za-z0-9]+/", $content, $placeholders);
                foreach ($placeholders[0] as $placeholder) {
                    // matches all PHP date and time placeholders
                    if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $placeholder)) {
                        $content = str_replace($placeholder, mysql2date(ltrim($placeholder, "#"), $_REQUEST['calendar_day']), $content);
                    }
                }
            } else {
                $event = array_shift($events);
                $content = $event->output(get_option('dbem_event_page_title_format'));
            }
        } elseif (isset($_REQUEST['location_id']) && ($_REQUEST['location_id'] |= '')) {
            $location = new EM_Location(EM_Object::sanitize($_REQUEST['location_id']));
            $content = $location->output(get_option('dbem_location_page_title_format'));
        } elseif (isset($_REQUEST['event_id']) && $_REQUEST['event_id'] != '') {
            // single event page
            $content = $EM_Event->output(get_option('dbem_event_page_title_format'));
        } else {
            // Multiple events page
            $content = get_option('dbem_events_page_title');
        }
        //TODO FILTER - filter titles before em output
    }
    return apply_filters('em_events_page_title', $content);
}
Ejemplo n.º 2
0
/**
 * Filter for titles when on event pages
 * @param $data
 * @return string
 */
function em_content_page_title($content)
{
    global $EM_Event, $EM_Location, $EM_Category, $wp_query, $post;
    $events_page_id = get_option('dbem_events_page');
    if ($post->ID == $events_page_id && $events_page_id != 0) {
        $content = apply_filters('em_content_page_title_pre', '', $content);
        if (empty($content)) {
            if (!empty($_REQUEST['calendar_day'])) {
                $events = EM_Events::get(array('limit' => 2, 'scope' => $_REQUEST['calendar_day'], 'owner' => false));
                if (count($events) != 1 || get_option('dbem_display_calendar_day_single') == 1) {
                    //We only support dates for the calendar day list title, so we do a simple filter for the supplied calendar_day
                    $content = get_option('dbem_list_date_title');
                    preg_match_all("/#[A-Za-z0-9]+/", $content, $placeholders);
                    foreach ($placeholders[0] as $placeholder) {
                        // matches all PHP date and time placeholders
                        if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $placeholder)) {
                            $content = str_replace($placeholder, mysql2date(ltrim($placeholder, "#"), $_REQUEST['calendar_day']), $content);
                        }
                    }
                } else {
                    $event = array_shift($events);
                    $content = $event->output(get_option('dbem_event_page_title_format'));
                }
            } elseif (is_object($EM_Location)) {
                $location = new EM_Location(EM_Object::sanitize($_REQUEST['location_id']));
                $content = $location->output(get_option('dbem_location_page_title_format'));
            } elseif (is_object($EM_Category)) {
                //Just a single location
                $content = $EM_Category->output(get_option('dbem_category_page_title_format'));
            } elseif ($wp_query->get('bookings_page')) {
                //Bookings Page
                $content = sprintf(__('My %s', 'dbem'), __('Bookings', 'dbem'));
            } elseif (is_object($EM_Event) && !empty($_REQUEST['book'])) {
                //bookings page
                $content = $EM_Event->output(get_option('dbem_bookings_page_title'));
            } elseif (is_object($EM_Event)) {
                // single event page
                if ($EM_Event->status == 1) {
                    $content = $EM_Event->output(get_option('dbem_event_page_title_format'));
                } else {
                    $content = get_option('dbem_events_page_title');
                }
            } elseif (!empty($_REQUEST['event_categories'])) {
                $content = get_option('dbem_categories_page_title');
            } elseif (!empty($_REQUEST['event_locations'])) {
                $content = get_option('dbem_locations_page_title');
            } else {
                // Multiple events page
                $content = get_option('dbem_events_page_title');
            }
        }
        return apply_filters('em_content_page_title', $content);
    }
    return $content;
}