I'm creating a wordpress plugin and getting 404 not found on css files. Heres the code (it's in the main php file for the plugin)
function callback_for_setting_up_scripts() {
wp_enqueue_style('bootstrap', 'https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css', ver:null);
wp_enqueue_style('main-sincoe-style', __DIR__.'/css/main.css', ver:null);
echo readfile(__DIR__.'/css/main.css');
}
add_action('wp_enqueue_scripts', 'callback_for_setting_up_scripts');
So two things:
So i'm stuck a bit here - thanks for any help (I'm on Mac if that changes anything - just moved so maybe those are some write/read permissions that i have not put up yet)
Thanks in advance
Thanks @Moshe Gross
plugin_dir_url() worked - the working code:
function callback_for_setting_up_scripts() {
wp_enqueue_style('bootstrap', 'https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css', ver:null);
wp_enqueue_style('main-sincoe-style',plugin_dir_url(__FILE__).'/css/main.css', ver:null);
}
add_action('wp_enqueue_scripts', 'callback_for_setting_up_scripts');