1

I use a Ajax query to show some content, but I can't use any of my plugins functions.

Javascript :

$('#load_more').click(function() {
    var data = {
        action: 'load_more',
        id: $("input#id").val()
    };
    jQuery.post(ajaxurl, data, function(response) {
        $("#content").append(response);
    });
});

PHP in functions.php :

function load_more(){
    $id = intval($_POST['id']);

    if(!isset($id) or !is_numeric($id)){
        echo "Error";}
    else {
        $works = plugin_function($id);
        wordpress_function_works($id, $works);}
    die;
}
add_action('wp_ajax_load_more', 'load_more');
add_action('wp_ajax_nopriv_load_more', 'load_more');

The Ajax works fine, it can call & work with any of my wordperss functions. But when I call a plugin function, it returns an error Call undefined function plugin_function() line...

PS: ajaxurl = /wp-admin/admin-ajax.php

  • Is your plugin a class? – s_ha_dum May 11 '13 at 14:49
  • Yes it is. BTW I can call my plugin function in my theme pages – hawkidoki May 11 '13 at 14:54
  • Do you have helper functions? That is not correct syntax for access class methods. – s_ha_dum May 11 '13 at 14:57
  • The function i'm trying to call is outside of the plugin class. It's just a function. – hawkidoki May 11 '13 at 15:00
  • The function itself is a helper that access the plugin class. What is weird is that I can't even call this function, it's just like the plugin wasn't loaded... – hawkidoki May 11 '13 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.