Last active
August 29, 2015 13:56
-
-
Save ramseyp/8812180 to your computer and use it in GitHub Desktop.
Check to see if something exists before you call some function / class / method in your WordPress functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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