hello i’ve been dealing with this all day and i just can’t figure out what is causing this problem please help me.
I have called a php file using ajax through the wordpress editor with a button.
This code is in my tinymce button file calling the php function

jQuery(document).ready( function($) {   
    var dir1 = "../wp-content/plugins/Midnight Image-Slider/MDslider.php";
    $.ajax({
        url: dir1,
        success: function(data) {
            $('.mce-window-body').append(data);
        }
    })
})

And when it calls the php file it gives me this error
wordpress Uncaught Error: Call to undefined function
unless i write the require wp-config.php part at the top of the php file then the error goes away but it is still not loading any wordpress hook.

    require_once(dirname(__FILE__).'../../../../wp-config.php');
add_action('init','loadFile');
function loadFile(){
echo 'hello world';
}

hello world is being displayed only when it is not in a function but i need to be able to use the wp hooks i think that some files are not being loaded.

Read more here: wordpress fails to load my hooks


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: