Dabin Kim
Dabin Kim

Reputation: 11

WordPress eventbrite embedded checkout plugin users, this phrase pops up on the 404 page

Notice: Trying to get property 'post_content' of non-object in /www/wp-content/plugins/wp-eventbrite-embedded-checkout/lib/embed-functions.php on line 41

An error message is displayed at the top of the site. I saw this phrase and checked the 41st line, but this is the only content. What should I use instead of post_content? I'm using modal popup now.

function wpeec_external_js(){
    if(has_shortcode($post->post_content, 'wp-eventbrite-checkout')):
        wp_enqueue_script( 'wpeec_eb_widgets', 'https://www.eventbrite.com/static/widgets/eb_widgets.js', true );
    endif;
}
add_action( 'wp_enqueue_scripts', 'wpeec_external_js' );

Upvotes: 0

Views: 53

Answers (1)

Dabin Kim
Dabin Kim

Reputation: 11

I added this lines

global $post;
if( null == $post ) {
    return;
}

like this and it works.

function wpeec_external_js(){
    global $post;
    if( null == $post ) {
        return;
    }
    if(has_shortcode($post->post_content, 'wp-eventbrite-checkout')):
        wp_enqueue_script( 'wpeec_eb_widgets', 'https://www.eventbrite.com/static/widgets/eb_widgets.js', true );
    endif;
}

Upvotes: 0

Related Questions