I've got a realy hair pulling problem here.
I've started cleaning up a plugin i've made and sort some of the functions in diffrent files.
but i've got a problem with wp_enqueue_scripts.
when i place the function where i register and enqueue in the main php file and try to enqueue my script from there it works as it should
however if i move the function to a diffrent php file and try to enqueue it from that file and include this php file from the main php file nothing happens however all other funtions from this php file works as they should
do i need to call a wordpress function from my other php file to be able to unqueue it from there or?
EDIT:
If if place and call the function in my main php file like below it works like a charm and and the js file is shown in the head when i look for it with firefox
function scripts() {
wp_register_script( 'load_table', plugins_url( 'path/js/load_table.js', __FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'load_table' );
}
add_action( 'wp_enqueue_scripts', 'scripts' );
However if i try to write it like below nothing happens and it cant be found in the head either
main.php:
include'path/to/other.php';
other.php:
function scripts() {
wp_register_script( 'load_table', plugins_url( 'vagt_oversigt/js/load_table.js', __FILE__ ), array( 'jquery' ) );
wp_enqueue_script( 'load_table' );
}
add_action( 'wp_enqueue_scripts', 'scripts' );
The problems seems to be happening when i use hooks with functions on other.php
just echo "hello world";
in other.php it works like a charm.
But if i try calling echo with in a function by init nothing happens either.
other.php:
function test() {
echo "hello world";
}
add_action('init', 'test');
BTW! yes i did try changing the path without sucsess. any ideas? :(
plugins_url
in codex, particularly the 2nd argument.