nspace, __CLASS__, $this ); // Fetch the Slug $slug = $this->get_shortcode_slug(); $tag = sanitize_title_with_dashes( $nspace ) . ':' . sanitize_title_with_dashes( $slug ); /** * Use this hook to filter the final tag of the Shortcode * * @since 4.1 * * @param string The complete Tag * @param string Static Class Name * @param object Instance of this class */ $tag = apply_filters( 'tribe_events_shortcode_tag', $tag, __CLASS__, $this ); return $tag; } /** * Gets the Shortcode slug allowing it to be filtered * * @since 4.1 * @return string */ public function get_shortcode_slug() { /** * Use this hook to filter the slug of shortcodes * * @since 4.1 * * @param string The Slug * @param string Static Class Name * @param object Instance of this class */ $slug = apply_filters( 'tribe_events_shortcode_slug', $this->slug, __CLASS__, $this ); return $slug; } /** * This will be called at hook "init" to allow other plugins and themes to hook to shortcode easily * * @since 4.1 * @return void */ public function add_shortcode() { $tag = $this->get_shortcode_tag(); add_shortcode( $tag, array( $this, 'do_shortcode' ) ); } /** * Actually create the shortcode output * * @since 4.1 * * @param array $args The Shortcode arguments * * @return string */ public function do_shortcode( $args ) { $tag = $this->get_shortcode_tag(); $slug = $this->get_shortcode_slug(); $args = (object) shortcode_atts( array( 'align' => 'left', 'id' => null, ), $args, $tag ); if ( ! is_null( $args->id ) && is_numeric( $args->id ) ) { $event = get_post( $args->id ); // Then If Event was fetch correctly we set the global if ( $event ) { global $post; // Store the Original we will restore it later $original_event = $post; // Set the new Event for now $post = $event; // Use WP to config the Post Data setup_postdata( $post ); } } // Set the Container Classes $classes = array( 'tribe-shortcode', 'tribe-events-single-section', 'tribe-events-event-meta', 'tribe-clearfix', ); // Add Alignment if ( in_array( $args->align, array( 'center', 'left', 'right' ) ) ) { $classes[] = 'tribe-shortcode-align-' . $args->align; } /** * Use this hook to filter the classes for this shortcode container * * @since 4.1 * * @param array Array of classes used on the Container * @param object Arguments set on the shortcode * @param string Shortcode tag */ $classes = apply_filters( 'tribe_events_shortcode_' . $slug . '_container_classes', $classes, $args, $tag ); // Ensure the expected CSS is available to style the shortcode output (this will // happen automatically in event views, but not elsewhere) tribe_asset_enqueue_group( 'events-styles' ); // Start to record the Output ob_start(); echo '
'; // Print the Actual HTML tribe_get_template_part( 'modules/meta/details' ); echo '
'; // Save it to a variable $html = ob_get_clean(); if ( isset( $original_event ) ) { $post = $original_event; // Use WP method to restore it back to original setup_postdata( $post ); } return $html; } }