hello folks,
trying to add a custom javascript to perform Ajax parsing in the admin backend.
setup.php
add_action('admin_enqueue_scripts', function () {
$wp = array(
'env' => env('WP_ENV'),
'ajaxUrl' => admin_url('admin-ajax.php'),
'security' => Ajax::getNonce(),
);
wp_scripts()->add_data('jquery', 'group', 1);
bundle('amazon-parser')->enqueueJs(true, ['jquery'])->localize('wp', $wp);
}, 100);
bud.config.js
...
app
.entry('amazon-parser', ['@scripts/admin/amazon-parser'])
admin/amazon-parser.js
import domReady from '@roots/sage/client/dom-ready';
domReady(async () => {
console.log('Amazon parser script loaded.');
//more stuffs...
});
BUT…
even the JS is loaded (I can read the console log) the editor… EXPLODES
(white screen of dead… with errors
TypeError: undefined is not an object (evaluating ‘wp.editPost.initializeEditor’)
and many more… like the injection of my new script is generating some sort of conflicts…)
any hint/advice?