O
O
ostup172022-04-19 07:30:55
PHP
ostup17, 2022-04-19 07:30:55

How to fix GET "link" net::ERR_ABORTED 404 (Not Found) error?

Wrote a plugin for wordpress, in which I connect scripts

wp_enqueue_script('drawing', WP_PLUGIN_DIR . '/japanese-candlestick-chart' . '/script.js');

I see an error only when activating the plugin.

The mistake itself
GET http://golda/var/www/golda/wp-content/plugins/japanese-candlestick-chart/script.js?ver=5.9.2 net::ERR_ABORTED 404 (Not Found)


full code -
if(!defined('ABSPATH')){ //Защита от злоумышлинников
     die; 
 }

add_action('wp_enqueue_scripts', 'jcc_graph');

function jcc_graph() {
    wp_enqueue_script('drawing', WP_PLUGIN_DIR . '/japanese-candlestick-chart' . '/script.js');
}


In theory, the path is correct - screen625e3acc78cec029817152.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton, 2022-04-19
@ostup17

Apparently, the WP_PLUGIN_DIR constant contains the physical path to the plugin folder, and you need the url - i.e. path that is relative to the site.
https://wp-kama.ru/function/plugin_dir_url - try this function

N
Nikolay, 2022-04-19
@iNickolay

Instead of a variable WP_PLUGIN_DIR, use the path /wp-content/plugins
A is better something like

site_url('/wp-content/plugins/japanese-candlestick-chart')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question