function testGetUserIDBy() { $user_id = $this->factory->user->create(array('user_login' => 'theusername', 'user_email' => '*****@*****.**')); $this->assertEquals($user_id, eo_get_user_id_by('id', $user_id)); $this->assertEquals($user_id, eo_get_user_id_by('slug', 'theusername')); $this->assertEquals($user_id, eo_get_user_id_by('email', '*****@*****.**')); $this->assertEquals(0, eo_get_user_id_by('slug', 'doesnotexist')); }
/** * Returns HTML mark-up for the fullCalendar * * It also (indirectly) triggers the enquing of the necessary scripts and styles. The `$args` array * accepts exactly the same arguments as the shortcode, they are * * * **headerleft** (string) What appears on the left of the calendar header. Default 'title'. * * **headercenter** (string) What appears on the left of the calendar header. Default ''. * * **headerright** (string) What appears on the left of the calendar header. Default 'prev next today'. * * **defaultview** (string) The view the calendar loads on. Default 'month', * * **event-category** (string|array) Restrict calendar to specified category(ues) (by slug). Default all categories. * * **event-venue** (string|array) Restrict calendar to specified venue(s) (by slug). Default all venues. * * **timeformat** (string) Time format for calendar. Default 'G:i'. * * **axisformat** (string) Axis time format (for day/week views). WP's time format option. * * **key** (bool) Whether to show a category key. Default false. * * **tooltip** (bool) Whether to show a tooltips. Default true. Content is filtered by [`eventorganiser_event_tooltip`](http://codex.wp-event-organiser.com/hook-eventorganiser_event_tooltip.html) * * **users_events** - (bool) True to show only eents for which the current user is attending * * **weekends** (bool) Whether to include weekends in the calendar. Default true. * * **mintime** (string) Earliest time to show on week/day views. Default '0', * * **maxtime** (string) Latest time to show on week/day views. Default '24', * * **alldayslot** (bool) Whether to include an all day slot (week / day views) in the calendar. Default true. * * **alldaytext** (string) Text to display in all day slot. Default 'All Day'. * * **titleformatmonth** (string) Date format (PHP) for title for month view. Default 'l, M j, Y' * * **titleformatweek** (string) Date format (PHP) for title for week view. Default 'M j[ Y]{ '—'[ M] j Y}. * * **titleformatday** (string) Date format (PHP) for title for day view. Default 'F Y' * * **columnformatmonth** (string) Dateformat for month columns. Default 'D'. * * **columnformatweek** (string) Dateformat for month columns. Default 'D n/j'. * * **columnformatday** (string) Dateformat for month columns. Default 'l n/j', * * **year** The year the calendar should start on (e.g. 2013) * * **month** The month the calendar should start on (1=Jan, 12=Dec) * * **date** The calendar the date should start on * * @link http://arshaw.com/fullcalendar/ The fullCalendar (jQuery plug-in) * @link http://arshaw.com/fullcalendar/docs/utilities/formatDates/ (Range formats). * @link https://github.com/stephenharris/fullcalendar Event Organiser version of fullCalendar * @since 1.7 * @param array $args An array of attributes for the calendar * @return string HTML mark-up. */ function eo_get_event_fullcalendar($args = array()) { global $wp_locale; $defaults = array('headerleft' => 'title', 'headercenter' => '', 'headerright' => 'prev next today', 'defaultview' => 'month', 'event-category' => '', 'event_category' => '', 'event-venue' => '', 'event_venue' => '', 'event-tag' => '', 'author' => false, 'author_name' => false, 'timeformat' => get_option('time_format'), 'axisformat' => get_option('time_format'), 'key' => false, 'tooltip' => true, 'weekends' => true, 'mintime' => '0', 'maxtime' => '24', 'alldayslot' => true, 'alldaytext' => __('All Day', 'eventorganiser'), 'columnformatmonth' => 'D', 'columnformatweek' => 'D n/j', 'columnformatday' => 'l n/j', 'titleformatmonth' => 'F Y', 'titleformatweek' => "M j[ Y]{ '—'[ M] j, Y}", 'titleformatday' => 'l, M j, Y', 'year' => false, 'month' => false, 'date' => false, 'users_events' => false, 'event_occurrence__in' => array(), 'theme' => true, 'isrtl' => $wp_locale->is_rtl()); $args = shortcode_atts($defaults, $args, 'eo_fullcalendar'); $key = $args['key']; unset($args['key']); //Support 'event-category' and 'event-venue'. Backwards compat with 'event_category'/'event_venue' $args['event-category'] = empty($args['event_category']) ? $args['event-category'] : $args['event_category']; $args['event-venue'] = empty($args['event_venue']) ? $args['event-venue'] : $args['event_venue']; //Convert event_category / event_venue to comma-delimitered strings $args['event_category'] = is_array($args['event-category']) ? implode(',', $args['event-category']) : $args['event-category']; $args['event_venue'] = is_array($args['event-venue']) ? implode(',', $args['event-venue']) : $args['event-venue']; $args['event_tag'] = is_array($args['event-tag']) ? implode(',', $args['event-tag']) : $args['event-tag']; //Get author ID from author/author_name $args['event_organiser'] = $args['author'] ? (int) $args['author'] : eo_get_user_id_by('slug', $args['author_name']); //Convert php time format into xDate time format $date_attributes = array('timeformat', 'axisformat', 'columnformatday', 'columnformatweek', 'columnformatmonth', 'titleformatmonth', 'titleformatday', 'titleformatweek'); $args['timeformatphp'] = $args['timeformat']; foreach ($date_attributes as $date_attribute) { $args[$date_attribute] = str_replace('((', '[', $args[$date_attribute]); $args[$date_attribute] = str_replace('))', ']', $args[$date_attribute]); $args[$date_attribute . 'php'] = $args[$date_attribute]; $args[$date_attribute] = eventorganiser_php2xdate($args[$date_attribute]); } //Month expects 0-11, we ask for 1-12. $args['month'] = $args['month'] ? $args['month'] - 1 : false; EventOrganiser_Shortcodes::$calendars[] = array_merge($args); EventOrganiser_Shortcodes::$add_script = true; $id = count(EventOrganiser_Shortcodes::$calendars); $html = '<div id="eo_fullcalendar_' . $id . '_loading" style="background:white;position:absolute;z-index:5" >'; $html .= sprintf('<img src="%1$s" style="vertical-align:middle; padding: 0px 5px 5px 0px;" alt="%2$s" /> %2$s', esc_url(EVENT_ORGANISER_URL . 'css/images/loading-image.gif'), esc_html__('Loading…', 'eventorganiser')); $html .= '</div>'; $html .= '<div class="eo-fullcalendar eo-fullcalendar-shortcode" id="eo_fullcalendar_' . $id . '"></div>'; if ($key) { $args = array('orderby' => 'name', 'show_count' => 0, 'hide_empty' => 0); $html .= eventorganiser_category_key($args, $id); } return $html; }