Guest User

Untitled

a guest
Nov 9th, 2018
281
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Represents individual [tribe_events] shortcodes.
  4.  *
  5.  * Notice that we look for (and set) the "tribe_events_display" URL parameter in preference
  6.  * to "eventDisplay". This is because "eventDisplay" is registered as a public query var in
  7.  * Tribe__Events__Main::eventQueryVars(). When used on a static homepage, the result can be
  8.  * incorrect parsing of the query.
  9.  */
  10. class Tribe__Events__Pro__Shortcodes__Tribe_Events {
  11.     /**
  12.      * Container for the shortcode attributes.
  13.      *
  14.      * @var array
  15.      */
  16.     protected $atts = array();
  17.  
  18.     /**
  19.      * Container for the relevant template manager. This may not always be needed
  20.      * and so may be empty.
  21.      *
  22.      * @var object|null
  23.      */
  24.     protected $template_object;
  25.  
  26.     /**
  27.      * @var object|null
  28.      */
  29.     protected $view_handler;
  30.  
  31.     /**
  32.      * @var string
  33.      */
  34.     protected $output = '';
  35.  
  36.     /**
  37.      * Query arguments required to setup the requested view.
  38.      *
  39.      * @var array
  40.      */
  41.     protected $query_args = array();
  42.  
  43.     /**
  44.      * The strings that the shortcode considers to be "truthy" in the context of
  45.      * various attributes.
  46.      *
  47.      * @var array
  48.      */
  49.     protected $truthy_values = array();
  50.  
  51.     /**
  52.      * Generates output for the [tribe_events] shortcode.
  53.      *
  54.      * @param $atts
  55.      */
  56.     public function __construct( $atts ) {
  57.         $this->setup( $atts );
  58.         $this->prepare();
  59.         $this->render();
  60.     }
  61.  
  62.     /**
  63.      * Parse the provided attributes and hook into the shortcode processes.
  64.      *
  65.      * @param $atts
  66.      */
  67.     protected function setup( $atts ) {
  68.         $defaults = array(
  69.             'date'          => '',
  70.             'tribe-bar'     => 'true',
  71.             'view'          => '',
  72.             'category'      => '',
  73.             'cat'           => '',
  74.             'featured'      => 'false',
  75.             'main-calendar' => 'false',
  76.             'venue' => '',
  77.         );
  78.  
  79.         $this->atts = shortcode_atts( $defaults, $atts, 'tribe_events' );
  80.  
  81.         // reassign 'cat' to 'category'
  82.         if ( ! empty( $this->atts['cat'] ) ) {
  83.             $this->atts['category'] = $this->atts['cat'];
  84.         }
  85.  
  86.         $this->set_view_attribute();
  87.  
  88.         add_action( 'tribe_events_pro_tribe_events_shortcode_prepare', array( $this, 'prepare_assets' ) );
  89.         add_action( 'tribe_events_pro_tribe_events_shortcode_prepare', array( $this, 'prepare_query' ) );
  90.         add_action( 'tribe_events_pro_tribe_events_shortcode_prepare_day', array( $this, 'prepare_day' ) );
  91.         add_action( 'tribe_events_pro_tribe_events_shortcode_prepare_list', array( $this, 'prepare_list' ) );
  92.         add_action( 'tribe_events_pro_tribe_events_shortcode_prepare_map', array( $this, 'prepare_map' ) );
  93.         add_action( 'tribe_events_pro_tribe_events_shortcode_prepare_month', array( $this, 'prepare_month' ) );
  94.         add_action( 'tribe_events_pro_tribe_events_shortcode_prepare_photo', array( $this, 'prepare_photo' ) );
  95.         add_action( 'tribe_events_pro_tribe_events_shortcode_prepare_week', array( $this, 'prepare_week' ) );
  96.         add_action( 'tribe_events_pro_tribe_events_shortcode_post_render', array( $this, 'reset_query' ) );
  97.     }
  98.  
  99.     /**
  100.      * Sets the view attribute.
  101.      *
  102.      * In priority order, will use one of the following to set the view attribute:
  103.      *
  104.      *     1) The value of "eventDisplay" in the URL query, if set and if valid
  105.      *     2) The value of the "view" attribute provided to the shortcode, if set and if valid
  106.      *     3) The value of the "Default Value" option, if valid.
  107.      *     4) The first view that is available
  108.      *     5) Month view
  109.      */
  110.     protected function set_view_attribute() {
  111.         $valid_views = wp_list_pluck( tribe_events_get_views(), 'displaying' );
  112.         $url_view    = $this->get_url_param( 'tribe_event_display' );
  113.         $view_attr   = $this->get_attribute( 'view' );
  114.  
  115.         // If tribe_event_display is "past", we need to grab the view from the action parameter
  116.         if ( 'past' === $url_view ) {
  117.             $url_view = str_replace( 'tribe_', '', $this->get_url_param( 'action' ) );
  118.  
  119.             // Convert the "geosearch" portion of "tribe_geosearch" to "map" so Map view can properly be initialized
  120.             // @TODO: restructure map view to use tribe_map rather than tribe_geosearch
  121.             if ( 'geosearch' === $url_view ) {
  122.                 $url_view = 'map';
  123.             }
  124.         }
  125.  
  126.         // Look first of all at the URL query for a valid view
  127.         if ( in_array( $url_view, $valid_views ) ) {
  128.             $this->atts['view'] = $url_view;
  129.             return;
  130.         }
  131.  
  132.         // Else fallback on the view attribute supplied to the shortcode
  133.         if ( in_array( $view_attr, $valid_views ) ) {
  134.             $this->atts['view'] = $view_attr;
  135.             return;
  136.         }
  137.  
  138.         // Else fallback on the default value from the settings
  139.         $view_option = tribe_get_option( 'viewOption', 'month' );
  140.         if ( in_array( $view_option, $valid_views ) ) {
  141.             $this->atts['view'] = $view_option;
  142.             return;
  143.         }
  144.  
  145.         // Otherwise, use the first view that *is* available
  146.         if ( ! empty( $valid_views ) ) {
  147.             $this->atts['view'] = current( $valid_views );
  148.             return;
  149.         }
  150.  
  151.         // If all else fails, we'll try to use month view even if not currently activated
  152.         $this->atts['view'] = 'month';
  153.     }
  154.  
  155.     /**
  156.      * Facilitates preparation of template classes and anything else required to setup
  157.      * a given view or support particular attributes that have been set.
  158.      */
  159.     protected function prepare() {
  160.         /**
  161.          * Provides an early opportunity for setup work to be performed.
  162.          *
  163.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  164.          */
  165.         do_action( 'tribe_events_pro_tribe_events_shortcode_prepare', $this );
  166.  
  167.         /**
  168.          * Provides an opportunity for template classes to be instantiated and/or
  169.          * any other required setup to be performed, for a specific view.
  170.          *
  171.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  172.          */
  173.         do_action( 'tribe_events_pro_tribe_events_shortcode_prepare_' . $this->atts[ 'view' ], $this );
  174.  
  175.         /**
  176.          * Provides an opportunity for template classes to be instantiated and/or
  177.          * any other required setup to be performed for views in general.
  178.          *
  179.          * @param string $view
  180.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  181.          */
  182.         do_action( 'tribe_events_pro_tribe_events_shortcode_prepare_view', $this->atts[ 'view' ], $this );
  183.     }
  184.  
  185.     /**
  186.      * Ensures supporting assets are available to the embedded views.
  187.      */
  188.     public function prepare_assets() {
  189.         // Scripts to support PRO views
  190.         Tribe__Events__Pro__Main::instance()->enqueue_pro_scripts( true, true );
  191.     }
  192.  
  193.     /**
  194.      * Prepares day view.
  195.      *
  196.      */
  197.     public function prepare_day() {
  198.         if ( ! class_exists( 'Tribe__Events__Template__Day' ) ) {
  199.             return;
  200.         }
  201.  
  202.         $this->view_handler = new Tribe__Events__Pro__Shortcodes__Tribe_Events__Day( $this );
  203.     }
  204.  
  205.     /**
  206.      * Prepares list view.
  207.      */
  208.     public function prepare_list() {
  209.         if ( ! class_exists( 'Tribe__Events__Template__List' ) ) {
  210.             return;
  211.         }
  212.  
  213.         $this->view_handler = new Tribe__Events__Pro__Shortcodes__Tribe_Events__List( $this );
  214.     }
  215.  
  216.     /**
  217.      * Prepares map view.
  218.      *
  219.      */
  220.     public function prepare_map() {
  221.         if ( ! class_exists( 'Tribe__Events__Pro__Templates__Map' ) ) {
  222.             return;
  223.         }
  224.  
  225.         $this->view_handler = new Tribe__Events__Pro__Shortcodes__Tribe_Events__Map( $this );
  226.     }
  227.  
  228.     /**
  229.      * Prepares month view.
  230.      */
  231.     public function prepare_month() {
  232.         if ( ! class_exists( 'Tribe__Events__Template__Month' ) ) {
  233.             return;
  234.         }
  235.  
  236.         $this->view_handler = new Tribe__Events__Pro__Shortcodes__Tribe_Events__Month( $this );
  237.     }
  238.  
  239.     /**
  240.      * Prepares photo view.
  241.      *
  242.      */
  243.     public function prepare_photo() {
  244.         if ( ! class_exists( 'Tribe__Events__Pro__Templates__Photo' ) ) {
  245.             return;
  246.         }
  247.  
  248.         $this->view_handler = new Tribe__Events__Pro__Shortcodes__Tribe_Events__Photo( $this );
  249.     }
  250.  
  251.     /**
  252.      * Prepares week view.
  253.      *
  254.      */
  255.     public function prepare_week() {
  256.         if ( ! class_exists( 'Tribe__Events__Pro__Templates__Week' ) ) {
  257.             return;
  258.         }
  259.  
  260.         $this->view_handler = new Tribe__Events__Pro__Shortcodes__Tribe_Events__Week( $this );
  261.     }
  262.  
  263.     /**
  264.      * Sets up the basic properties for an event view query.
  265.      */
  266.     public function prepare_query() {
  267.  
  268.         $eventDate_param = $this->get_attribute( 'date', $this->get_url_param( 'date' ) );
  269.  
  270.         // If the Tribe Bar is active, then we can (and should) use the date from that.
  271.         if ( $this->is_attribute_truthy( 'tribe-bar' ) ) {
  272.             $eventDate_param = $this->get_attribute( 'date', $this->get_url_param( 'tribe-bar-date' ) );
  273.         }
  274.  
  275.         $this->update_query( array(
  276.             'post_type'         => Tribe__Events__Main::POSTTYPE,
  277.             'eventDate'         => $eventDate_param,
  278.             'eventDisplay'      => $this->get_attribute( 'view' ),
  279.             'tribe_events_cat'  => $this->atts[ 'category' ],
  280.             'venue'             => $this->get_attribute( 'venue' ),
  281.             'featured'          => $this->is_attribute_truthy( 'featured' ),
  282.         ) );
  283.     }
  284.  
  285.     /**
  286.      * Take care of common setup needs including enqueing various assets required by the default views.
  287.      */
  288.     public function prepare_default() {
  289.         /**
  290.          * We overwrite the global $wp_query object to facilitate embedding the requested view (the
  291.          * original will be restored during tribe_events_pro_tribe_events_shortcode_post_render):
  292.          * this isn't ideal, but further restructuring of our template classes and event views would
  293.          * be needed to avoid it.
  294.          *
  295.          * @see $this->reset_query()
  296.          * @todo revise in a future release
  297.          */
  298.         global $wp_query;
  299.  
  300.         $wp_query = new WP_Query( $this->query_args );
  301.  
  302.         // Assets required by all our supported views
  303.         tribe_asset_enqueue_group( 'events-styles' );
  304.         tribe_asset_enqueue( 'tribe-events-calendar-script' );
  305.  
  306.         tribe_asset_enqueue_group( 'events-pro-styles' );
  307.  
  308.         // Tribe Events Bar support
  309.         if ( $this->is_attribute_truthy( 'tribe-bar', true ) ) {
  310.             add_filter( 'tribe_get_option', array( $this, 'filter_tribe_disable_bar' ), 10, 2 );
  311.  
  312.             // Make sure the filters have been initialized
  313.             tribe_events_get_filters();
  314.  
  315.             add_filter( 'tribe-events-bar-should-show', array( $this, 'enable_tribe_bar' ) );
  316.  
  317.             remove_action( 'tribe_events_bar_before_template', tribe_callback( 'tec.bar', 'disabled_bar_before' ) );
  318.             remove_action( 'tribe_events_bar_after_template', tribe_callback( 'tec.bar', 'disabled_bar_after' ) );
  319.  
  320.             tribe_asset_enqueue( 'tribe-events-pro-geoloc' );
  321.  
  322.             add_action( 'tribe_events_bar_before_template', tribe_callback( 'tec.bar', 'disabled_bar_before' ) );
  323.             add_action( 'tribe_events_bar_after_template', tribe_callback( 'tec.bar', 'disabled_bar_after' ) );
  324.  
  325.             remove_filter( 'tribe_get_option', array( $this, 'filter_tribe_disable_bar' ) );
  326.         }
  327.  
  328.         // Add the method responsible for rendering each of the default supported views
  329.         add_filter( 'tribe_events_pro_tribe_events_shortcode_output', array( $this, 'render_view' ) );
  330.  
  331.         // View selector URLs will need to be adjusted (so that the user is not taken to /events/new-view/)
  332.         add_filter( 'tribe-events-bar-views', array( $this, 'modify_view_urls' ), 100 );
  333.     }
  334.  
  335.     /**
  336.      * Filters the tribeDisableTribeBar value to make sure tribe bar filters initialized
  337.      *
  338.      * @param string $value Option value
  339.      * @param string $option_name Option name
  340.      *
  341.      * @return boolean
  342.      */
  343.     public function filter_tribe_disable_bar( $value, $option_name ) {
  344.         if ( 'tribeDisableTribeBar' !== $option_name ) {
  345.             return $value;
  346.         }
  347.  
  348.         return false;
  349.     }
  350.  
  351.     /**
  352.      * Expects to be called during "tribe-events-bar-should-show" - will unhook itself
  353.      * and return true.
  354.      *
  355.      * @return bool true
  356.      */
  357.     public function enable_tribe_bar() {
  358.         remove_filter( 'tribe-events-bar-should-show', array( $this, 'enable_tribe_bar' ) );
  359.         return true;
  360.     }
  361.  
  362.     /**
  363.      * Sets the query arguments needed to facilitate a custom request.
  364.      *
  365.      * @param array $arguments
  366.      */
  367.     public function update_query( array $arguments ) {
  368.         $this->query_args = array_merge( $this->query_args, $arguments );
  369.     }
  370.  
  371.     /**
  372.      * Returns the currently configured query arguments for the current embedded view.
  373.      *
  374.      * @return array
  375.      */
  376.     public function get_query_args() {
  377.         return $this->query_args;
  378.     }
  379.  
  380.     /**
  381.      * @internal
  382.      *
  383.      * @param string $param
  384.      * @param mixed  $default = null
  385.      *
  386.      * @return mixed
  387.      */
  388.     public function get_url_param( $param, $default = null ) {
  389.         return isset( $_GET[ $param ] ) ? $_GET[ $param ] : $default;
  390.     }
  391.  
  392.     /**
  393.      * Once the view has been rendered, restore the origin WP_Query object.
  394.      */
  395.     public function reset_query() {
  396.         remove_action( 'tribe_events_pro_tribe_events_shortcode_post_render', array( $this, 'reset_query' ) );
  397.         wp_reset_query();
  398.     }
  399.  
  400.     /**
  401.      * Returns the currently set shortcode attributes.
  402.      *
  403.      * @return array
  404.      */
  405.     public function get_attributes() {
  406.         return $this->atts;
  407.     }
  408.  
  409.     /**
  410.      * Returns the value of the specified shortcode attribute or else returns
  411.      * $default if $name is not set.
  412.      *
  413.      * @param string $name
  414.      * @param mixed  $default = null
  415.      *
  416.      * @return mixed
  417.      */
  418.     public function get_attribute( $name, $default = null ) {
  419.         return ! empty( $this->atts[ $name ] ) ? trim( $this->atts[ $name ] ) : $default;
  420.     }
  421.  
  422.     /**
  423.      * Sets the current state of the shortcode based on URL parameters
  424.      */
  425.     public function set_current_page() {
  426.         $paged   = $this->get_url_param( 'tribe_paged' );
  427.         $display = $this->get_url_param( 'tribe_event_display' );
  428.  
  429.         if ( ! $paged && ! $display ) {
  430.             return;
  431.         }
  432.  
  433.         $this->update_query( array(
  434.             'paged' => $paged,
  435.         ) );
  436.  
  437.         if ( 'past' === $display ) {
  438.             $this->update_query( array(
  439.                 'eventDisplay' => 'past',
  440.                 'order'        => 'DESC',
  441.             ) );
  442.         }
  443.     }
  444.  
  445.     /**
  446.      * Tests to see if the specified attribute has a truthy value (typically "on",
  447.      * "true", "yes" or "1").
  448.      *
  449.      * In cases where the attribute is not set, it will return false unless
  450.      * $true_by_default is set to true.
  451.      *
  452.      * @param string $name
  453.      * @param bool   $true_by_default = false
  454.      *
  455.      * @return bool
  456.      */
  457.     public function is_attribute_truthy( $name, $true_by_default = false ) {
  458.         // If the attribute is not set, return the default
  459.         if ( ! isset( $this->atts[ $name ] ) ) {
  460.             return (bool) $true_by_default;
  461.         }
  462.  
  463.         $value = strtolower( $this->get_attribute( $name ) );
  464.         return in_array( $value, $this->get_truthy_values() );
  465.     }
  466.  
  467.     /**
  468.      * Returns an array of strings that can be regarded as "truthy".
  469.      *
  470.      * @return array
  471.      */
  472.     protected function get_truthy_values() {
  473.         if ( empty( $this->truthy_values ) ) {
  474.             /**
  475.              * Allows the set of strings regarded as truthy (in the context of the [tribe_events]
  476.              * shortcode attributes) to be altered.
  477.              *
  478.              * These should generally be lowercase strings for those languages where such a thing
  479.              * makes sense.
  480.              *
  481.              * @param array $truthy_values
  482.              */
  483.             $this->truthy_values = (array) apply_filters( 'tribe_events_pro_tribe_events_shortcode_truthy_values', array(
  484.                 '1',
  485.                 'on',
  486.                 'yes',
  487.                 'true',
  488.             ) );
  489.         }
  490.  
  491.         return $this->truthy_values;
  492.     }
  493.  
  494.     /**
  495.      * Returns the current template class object, if one has been found and loaded.
  496.      *
  497.      * @return object|null
  498.      */
  499.     public function get_template_object() {
  500.         return $this->template_object;
  501.     }
  502.  
  503.     /**
  504.      * Sets the template object being used to generate the embedded view.
  505.      *
  506.      * @param object $template_object
  507.      */
  508.     public function set_template_object( $template_object ) {
  509.         if ( ! is_object( $template_object ) ) {
  510.             _doing_it_wrong( __METHOD__, __( '$template_object is expected to be an actual object', 'tribe-events-calendar-pro' ), '4.3' );
  511.             return;
  512.         }
  513.  
  514.         $this->template_object = $template_object;
  515.     }
  516.  
  517.     /**
  518.      * Returns the object responsible for handling the current view, if one is needed
  519.      * and has been set.
  520.      *
  521.      * @return null|object
  522.      */
  523.     public function get_view_handler() {
  524.         return $this->view_handler;
  525.     }
  526.  
  527.     /**
  528.      * Triggers rendering of the currently requested view.
  529.      */
  530.     protected function render() {
  531.         /**
  532.          * Triggers the rendering of the requested view.
  533.          *
  534.          * @param string $html
  535.          * @param string $view
  536.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  537.          */
  538.         $this->output = (string) apply_filters( 'tribe_events_pro_tribe_events_shortcode_output', '', $this->atts[ 'view' ], $this );
  539.     }
  540.  
  541.     /**
  542.      * For default supported views, performs rendering and returns the result.
  543.      */
  544.     public function render_view() {
  545.         $attributes = array();
  546.         $events_label_plural = tribe_get_event_label_plural();
  547.  
  548.         /**
  549.          * Fires before the embedded view is rendered.
  550.          *
  551.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  552.          */
  553.         do_action( 'tribe_events_pro_tribe_events_shortcode_pre_render', $this );
  554.  
  555.         ob_start();
  556.  
  557.         /**
  558.          * Fires before the render of the markup starts
  559.          *
  560.          * @since 4.4.26
  561.          *
  562.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  563.          */
  564.         do_action( 'tribe_events_pro_tribe_events_shortcode_before_render', $this );
  565.  
  566.         $this->get_template_object()->add_input_hash();
  567.         $attributes[] = 'id="tribe-events"';
  568.         $attributes[] = 'class="' . $this->get_wrapper_classes() . '"';
  569.         $attributes[] = 'data-live_ajax="' . absint( tribe_get_option( 'liveFiltersUpdate', true ) ) . '"';
  570.         $attributes[] = 'data-datepicker_format="' . tribe_get_option( 'datepickerFormat' ) . '"';
  571.  
  572.         if ( ! empty( $this->query_args['tribe_events_cat'] ) ) {
  573.             $attributes[] = 'data-category="' . esc_attr( $this->query_args['tribe_events_cat'] ) . '"';
  574.         }
  575.  
  576.         ?>
  577.         <span class="tribe-events-ajax-loading">
  578.             <img class="tribe-events-spinner-medium" src="<?php echo esc_url( tribe_events_resource_url( 'images/tribe-loading.gif' ) ); ?>" alt="<?php printf( esc_attr__( 'Loading %s', 'tribe-events-calendar-pro' ), $events_label_plural ); ?>" />
  579.         </span>
  580.         <?php
  581.  
  582.         // Creates id='tribe-events' container
  583.         echo '<div ' . implode( ' ', $attributes ) . '>';
  584.  
  585.         /**
  586.          * Conditionally add the before HTML to shortcode-generated calendars
  587.          *
  588.          * @since 4.4.27
  589.          */
  590.         if ( tribe_get_option( 'tribeEventsShortcodeBeforeHTML', false ) ) {
  591.             echo wp_kses_post( tribe_events_before_html() );
  592.         }
  593.  
  594.         /**
  595.          * Hook to add Title Bar to Shortcode Display
  596.          *
  597.          * @since 4.4.31
  598.          *
  599.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  600.          */
  601.         do_action( 'tribe_events_pro_tribe_events_shortcode_title_bar', $this );
  602.  
  603.         // Include the tribe bar HTML if required
  604.         if ( $this->is_attribute_truthy( 'tribe-bar', true ) ) {
  605.             tribe( 'tec.bar' )->load_script();
  606.             tribe_get_template_part( 'modules/bar' );
  607.         }
  608.  
  609.         tribe_get_view( $this->get_template_object()->view_path );
  610.  
  611.         /**
  612.          * Conditionally add the after HTML to shortcode-generated calendars
  613.          *
  614.          * @since 4.4.27
  615.          */
  616.         if ( tribe_get_option( 'tribeEventsShortcodeAfterHTML', false ) ) {
  617.             echo wp_kses_post( tribe_events_after_html() );
  618.         }
  619.  
  620.         echo '</div>';
  621.  
  622.         /**
  623.          * Fires just before the markup is completed
  624.          *
  625.          * @since 4.4.26
  626.          *
  627.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  628.          */
  629.         do_action( 'tribe_events_pro_tribe_events_shortcode_after_render', $this );
  630.  
  631.         $html = ob_get_clean();
  632.  
  633.         /**
  634.          * Fires after the embedded view is rendered.
  635.          *
  636.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  637.          */
  638.         do_action( 'tribe_events_pro_tribe_events_shortcode_post_render', $this );
  639.  
  640.         return $html;
  641.     }
  642.  
  643.     /**
  644.      * @param array $views
  645.      *
  646.      * @return array
  647.      */
  648.     public function modify_view_urls( array $views ) {
  649.         $embed_url = get_home_url( null, $GLOBALS['wp']->request );
  650.  
  651.         foreach ( $views as &$view_data ) {
  652.             $view_data['url'] = add_query_arg( 'tribe_event_display', $view_data[ 'displaying' ], $embed_url );
  653.         }
  654.  
  655.         return $views;
  656.     }
  657.  
  658.     /**
  659.      * Returns a set of (already escaped) CSS class names intended for use in the div
  660.      * wrapping the shortcode output.
  661.      *
  662.      * @return string
  663.      */
  664.     protected function get_wrapper_classes() {
  665.         $category = '';
  666.         $view = '';
  667.         $venue = '';
  668.         if ( isset( $this->atts[ 'view' ] ) ) {
  669.             $view = 'view-' . esc_attr( $this->atts[ 'view' ] );
  670.         }
  671.  
  672.         if ( isset( $this->atts[ 'category' ] ) ) {
  673.             $category = 'category-' . $this->atts[ 'category' ];
  674.         }
  675.         $classes = array(
  676.             'tribe-events-shortcode',
  677.             'tribe-events-view-wrapper',
  678.             esc_attr( $view ),
  679.             esc_attr( $category ),
  680.             esc_attr( $venue ),
  681.             $this->is_attribute_truthy( 'tribe-bar', true ) ? 'tribe-bar' : 'tribe-bar-hidden',
  682.         );
  683.  
  684.         /**
  685.          * Sets the CSS classes applied to the [tribe_events] wrapper div.
  686.          *
  687.          * @param array $classes
  688.          * @param Tribe__Events__Pro__Shortcodes__Tribe_Events $shortcode
  689.          */
  690.         $classes = (array) apply_filters( 'tribe_events_pro_tribe_events_shortcode_wrapper_classes', $classes, $this );
  691.  
  692.         $classes = implode( ' ', array_filter( $classes ) );
  693.         return esc_attr( $classes );
  694.     }
  695.  
  696.     /**
  697.      * Returns the output of this shortcode.
  698.      *
  699.      * @return string
  700.      */
  701.     public function output() {
  702.         return $this->output;
  703.     }
  704. }
RAW Paste Data