Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // this caused the issue
- function new_em_get_event_shortcode( $atts, $format = '' ) {
- global $EM_Event, $post;
- $return = '';
- $the_event = is_object( $EM_Event ) ? clone( $EM_Event ) : null; // save global temporarily
- $atts = (array) $atts;
- $atts['format'] = ( $format != '' || empty( $atts['format'] ) ) ? $format : $atts['format'];
- $atts['format'] = html_entity_decode( $atts['format'] ); // shorcode doesn't accept html
- if ( ! empty( $atts['event'] ) && is_numeric( $atts['event'] ) ) {
- $EM_Event = em_get_event( $atts['event'] );
- $return = ( ! empty( $atts['format'] ) ) ? $EM_Event->output( $atts['format'] ) : $EM_Event->output_single();
- } elseif ( ! empty( $atts['post_id'] ) && is_numeric( $atts['post_id'] ) ) {
- $EM_Event = em_get_event( $atts['post_id'], 'post_id' );
- $return = ( ! empty( $atts['format'] ) ) ? $EM_Event->output( $atts['format'] ) : $EM_Event->output_single();
- }
- // no specific event or post id supplied, check globals
- if ( ! empty( $EM_Event ) ) {
- $return = ( ! empty( $atts['format'] ) ) ? $EM_Event->output( $atts['format'] ) : $EM_Event->output_single();
- } elseif ( $post->post_type == EM_POST_TYPE_EVENT ) {
- $EM_Event = em_get_event( $post->ID, 'post_id' );
- $return = ( ! empty( $atts['format'] ) ) ? $EM_Event->output( $atts['format'] ) : $EM_Event->output_single();
- }
- $EM_Event = is_object( $the_event ) ? $the_event : $EM_Event; //reset global
- return do_shortcode( $return );
- }
- add_shortcode( 'event', 'new_em_get_event_shortcode' );
- // this fixed the issue
- function new_em_get_event_shortcode( $atts, $format = '' ) {
- global $post;
- $return = '';
- $atts = (array) $atts;
- $atts[ 'format' ] = ( $format != '' || empty( $atts[ 'format' ] ) ) ? $format : $atts[ 'format' ];
- $atts[ 'format' ] = html_entity_decode( $atts[ 'format' ] ); //shorcode doesn't accept html
- if ( ! empty( $atts[ 'event' ] ) && is_numeric( $atts[ 'event' ] ) ) {
- $EM_Event = em_get_event( $atts[ 'event' ] );
- $return = ( ! empty( $atts[ 'format' ] ) ) ? $EM_Event->output( $atts[ 'format' ] ) : $EM_Event->output_single();
- } elseif ( ! empty( $atts[ 'post_id' ] ) && is_numeric( $atts[ 'post_id' ] ) ) {
- $EM_Event = em_get_event( $atts[ 'post_id' ], 'post_id' );
- $return = ( ! empty( $atts[ 'format' ] ) ) ? $EM_Event->output( $atts[ 'format' ] ) : $EM_Event->output_single();
- }
- //no specific event or post id supplied, check globals
- if ( ! empty( $EM_Event ) ) {
- $return = ( ! empty( $atts[ 'format' ] ) ) ? $EM_Event->output( $atts[ 'format' ] ) : $EM_Event->output_single();
- } elseif ( $post->post_type == EM_POST_TYPE_EVENT ) {
- $EM_Event = em_get_event( $post->ID, 'post_id' );
- $return = ( ! empty( $atts[ 'format' ] ) ) ? $EM_Event->output( $atts[ 'format' ] ) : $EM_Event->output_single();
- }
- return do_shortcode( $return );
- }
- add_shortcode( 'event', 'new_em_get_event_shortcode' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement