How to use "if_fuction_exists" to prevent fatal errors

Home Forums Ticket Products Event Tickets Plus How to use "if_fuction_exists" to prevent fatal errors

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #986169
    Caroline
    Participant

    Because we’ve integrated the Events Calendar and WooTickets into our WordPress theme, when we turn off them off, it causes our entire site to stop working.

    How can we use “if_fuction_exists” in our functions.php to check if these plugins are present, and if not, display a message in the admin instead of crashing the entire website?

    Thanks in advance.

    #986254
    Brian
    Keymaster

    Hi,

    Thanks for using our plugins I can help out here.

    You can us if class exists to wrap coding for the Events Calendar or WooCommerce tickets and it will only run then if the plugin is active.

    This code checks for The Events Calendar and Pro to be active:

    if ( class_exists( 'Tribe__Events__Main' ) && class_exists( 'Tribe__Events__Pro__Main' ) ) {
    //coding here
    }

    This code checks for WooCommerce Tickets to be active:

    if ( class_exists( 'Tribe__Events__Tickets__Woo__Main' ) ) {
    //coding here
    }

    Let me know if that works for you.

    Thanks

    #986316
    Caroline
    Participant

    Awesome – Thank you!

    #986325
    Brian
    Keymaster

    Great glad it helps.

    I am going to close this ticket, but if you need anything else related to this topic or another please post a new topic on the forum and we can help you out.

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘How to use "if_fuction_exists" to prevent fatal errors’ is closed to new replies.