I am writing some code in the functions.php of my theme, now what I need to do is execute a function from inside another plugin and im wondering if its possible.
The plugin is wooevents pro and the function I need is as follows:
function order_contains_tickets( $order ) {
// Function code is in here
}
So my code will look something like this
if ( order_contains_tickets( $order ) ) {
// Execute code
}
Technically, the exact code you have would work, but it’s also unsafe. In the event that the wooevents pro plugin were ever disabled, the code you added would be referencing a function that no longer exists. Thus, a better option would be to add a check to ensure that the function exists like so…
It should also be noted that this is dependent on the load order of the two functions. The wooevents pro function must be loaded prior to your function for it to work.