Check to see if something exists before you call some function / class / method in your WordPress functions.php
<?php | |
if ( function_exists( 'function_name' ) ) { | |
//... do something ... | |
} | |
if ( class_exists( 'Class_Name' ) ) { | |
//... do something ... | |
} | |
// You can also use the negative ! | |
if ( !function_exists( 'function_name' ) ) { | |
//... do something ... | |
} | |
if ( !class_exists( 'Class_Name' ) ) { | |
//... do something ... | |
} | |
/** | |
* Example: Manually load Jetpack's Sharing buttons in your theme | |
* | |
*/ | |
if ( class_exists( 'Sharing_Service' ) ) { | |
echo sharing_display(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment