override pluggable.php functions

The short answer to your question is yes; however, the methods to do this are a little bit hacky and generally I would recommend against all of them unless absolutely necessary. Since pluggable functions actually replace the stock function by way of function_exists() whichever plugin that “plugs” the function first will win. What you want … Read more

Redeclare theme’s function in a plugin

You can only declare a function once. My reccomendation is that you put the functions in the plugin, then use filters to override in the theme, e.g. In the plugins: function my_awesome_function() { return apply_filters( ‘my_awesome_function’, “plugin” ); } In your theme: add_filter( ‘my_awesome_function’, function( $value ) { return “theme”; } ); Now every call … Read more

Where does function_exists() look to decide whether a function exists? [closed]

function_exists(‘f’) will check if a function f was declared before the call to function_exists. Therefor the direct answer to your question is – in the functions section of the interpreter memory. The result of function_exists do not only depend on the file in which the function is declared and the file in which the call … Read more

if custom post type exist

You typed “mobiles” when you said you wanted to check for post type “mobile”. So simply remove the s ;). <? if( post_type_exists( ‘mobiles’ ) ) { echo ‘The Products post type exists’;} ?> Should be: <? if( post_type_exists( ‘mobile’ ) ) { echo ‘The Mobile post type exists’;} ?> If it’s still not working, … Read more

Is calling function_exists() faster or slower that apply_filters()

I don’t know if one is faster or slower than the other, but I would suggest that using apply_filters() is the better approach, because it is cleaner, and more intuitive (in the sense of doing things the “WordPress way”). EDIT If you’re doing comparison tests, shouldn’t you compare the time required to execute the following: … Read more