getMethods(), function($method) { return strpos($method->name, 'shortcode_') === 0; }); foreach ($shortcodes as $shortcode) { $shortcode_name = str_replace('shortcode_', '', $shortcode->name); Shortcodes::add($shortcode_name, function($content = '', $atts, $shortcode_name, $import_id) { $method_name = 'shortcode_' . str_replace('arlo_', '', $shortcode_name); return self::$method_name($content, $atts, $shortcode_name, $import_id); }); } Shortcodes::add('event_list', function($content = '', $atts, $shortcode_name, $import_id) { return $content; }); } private static function shortcode_event_filters($content = '', $atts = [], $shortcode_name = '', $import_id = '') { global $post, $wpdb; extract(shortcode_atts(array( 'filters' => 'location', 'resettext' => __('Reset', 'arlo-for-wordpress'), 'buttonclass' => 'button' ), $atts, $shortcode_name, $import_id)); $filters_array = explode(',',$filters); $arlo_region = \Arlo_For_Wordpress::get_region_parameter(); $settings = get_option('arlo_settings'); $page_link = get_permalink(get_post($post)); $filter_html = ''; foreach($filters_array as $filter_key): if (!array_key_exists($filter_key, \Arlo_For_Wordpress::$available_filters['event']['filters'])) continue; $items = \Arlo\Shortcodes\Filters::get_filter_options($filter_key, $import_id, $post->ID); $filter_html .= Shortcodes::create_filter($filter_key, $items, __(\Arlo_For_Wordpress::$filter_labels[$filter_key], 'arlo-for-wordpress'), 'generic', null, 'event'); endforeach; if (!empty($filter_html)) { return '
' . $filter_html . '
' . htmlentities($resettext, ENT_QUOTES, "UTF-8") . '
'; } } private static function shortcode_event_tags($content = '', $atts = [], $shortcode_name = '', $import_id = '') { if(!isset($GLOBALS['arlo_event_list_item']['e_id']) && !isset($GLOBALS['arlo_event_session_list_item']['e_id'])) return ''; $id = isset($GLOBALS['arlo_event_session_list_item']['e_id']) ? $GLOBALS['arlo_event_session_list_item']['e_id'] : $GLOBALS['arlo_event_list_item']['e_id']; global $wpdb; $output = ''; $tags = []; // merge and extract attributes extract(shortcode_atts(array( 'layout' => '', 'prefix' => 'arlo-', ), $atts, $shortcode_name, $import_id)); $items = $wpdb->get_results(" SELECT tag FROM {$wpdb->prefix}arlo_tags AS t LEFT JOIN {$wpdb->prefix}arlo_events_tags AS et ON tag_id = id WHERE et.e_id = {$id} AND t.import_id = " . $import_id . " AND et.import_id = " . $import_id . " ", ARRAY_A); foreach ($items as $t) { $tags[] = $t['tag']; } if (count($tags)) { switch($layout) { case 'list': $output = ''; break; case 'class': $classes = []; foreach($tags as $tag) { $classes[] = htmlentities(sanitize_title($prefix . $tag), ENT_QUOTES, "UTF-8"); } $output = implode(' ', $classes); break; default: $output = '
' . implode(', ', array_map(function($tag) { return htmlentities($tag, ENT_QUOTES, "UTF-8"); }, $tags)) . '
'; break; } } return $output; } private static function shortcode_event_list_item($content = '', $atts = [], $shortcode_name = '', $import_id = '') { global $post, $wpdb; $sql = self::generate_events_list_sql($atts, $import_id); $items = $wpdb->get_results($sql, ARRAY_A); $output = ''; if (is_array($items) && count($items)) { unset($GLOBALS['no_event']); foreach($items as $key => $item) { $GLOBALS['arlo_event_list_item'] = $item; if (strpos($content, '[arlo_venue_') !== false) { $conditions = array( 'id' => $item['v_id'] ); $GLOBALS['arlo_venue_list_item'] = \Arlo\Entities\Venues::get($conditions, null, null, $import_id); } if (!empty($atts['show']) && $key == $atts['show']) { $output .= '