I have a PHP file that I call with Cron Job and I need it separately from the rest of code. So, I have a button that call AJAX request from my dashboard. The Ajax function in my Wordpress plugin includes the file (process.php), this in turn, includes another file (snippets.php).
If I call process.php directly, it works perfectly, but not from Ajax call.
Folder structure
plugin.php
plugin.js
snippets.php
processes/process.php
plugin.js
jQuery.ajax({
type: 'GET',
url: ajaxurl,
data : {
action : 'process',
}
})
plugin.php
function process(){
include_once( 'processes/process.php' );
}
add_action( 'wp_ajax_process', 'process' );
process.php
include_once('../snippets.php')
//here not includes 'snippets.php'