I am trying to use a plugin function ( wp-bannerize()
) inside my custom plugin. but when i write:
if( function_exists('wp_bannerize') ){
echo "exist";
}else{
echo "not exist";
}
The output is not exists
How can i get this function inside my custom plugin?
UPDATE:
Here the code of my plugin:
class Infinite_posts{
public function __construct() {
add_action('wp_ajax_is_bannerize', 'load_plugins');
//when plugin receive an AJAX call with 'is_bannerize'parameter load_plugins() is triggered
}
public function load_plugins(){
add_action( 'plugins_loaded', 'show_bannerize' );
//when all plugin are loaded show_bannerize() is triggered
}
public function show_bannerize(){
if( function_exists( 'wp_bannerize' ) ) {
echo "exist";
} else {
echo "not exist";
}
}
}
if( !is_admin() )
$infinitePosts = new Infinite_posts();
here my javascript too:
$('.gallerie h2').on('click', function(){
jQuery.post(
'http://localhost/~sdibenedetto/d-art/htdocs/wp-content/plugins/infinite-posts/infinite-posts.php',
{
'action': 'is_bannerize',
'data': 'foobarid'
},
function(response){
alert('The server responded: ' + response);
}
);
});
Is this correct? How to make the AJAX call and pass the parameter "is_bannerize" to trigger the plugin? With this javascript i have this error in the alert:
<b>Fatal error</b>: Call to undefined function add_action() in <b>/Users/sdibenedetto/Sites/d-art/htdocs/wp-content/plugins/infinite-posts/infinite-posts.php</b> on line <b>44</b><br />
Pls help. Thanks
function_exists()
is returning false.