Reputation: 301
I am trying to load javascript files for my plugin and it worked until I changed my theme to a child theme and then updated the original theme... any ideas why the javascript has stopped firing? All I have included in the child theme folder is a style.css file.
The javascript line that is not firing apparently is:
wp_enqueue_script('watchlist',THT_WATCHLIST_DIR.'assets/js/watchlist.js',array('jquery','jquery-ui-1','jquery-ui-tabs1','jquery-ui-datepicker1','jquery-ui-dialog1','jquery-ui-button1',), '1.0.0', 1 );
Thanks!
----main plugin file-----
function tht_add_javascript_files() {
if (!is_admin()) {
wp_enqueue_style('watchlist-css',THT_WATCHLIST_DIR.'assets/css/watchlist.css' );
wp_enqueue_script( 'jquery-ui-datepicker1', '/wp-includes/js/jquery/ui/jquery.ui.datepicker.min.js', array('jquery-ui-core'), '1.10.3', 1 );
wp_enqueue_script( 'jquery-ui-position', '/wp-includes/js/jquery/ui/jquery.ui.position.min.js', array('jquery'), '1.10.3', 1 );
wp_enqueue_script( 'jquery-ui-dialog1', '/wp-includes/js/jquery/ui/jquery.ui.dialog.min.js', array('jquery','jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position','jquery-ui-button1'), '1.10.3', 1 );
wp_enqueue_script( 'jquery-ui-button1', '/wp-includes/js/jquery/ui/jquery.ui.button.min.js', array('jquery','jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position'), '1.10.3', 1 );
wp_enqueue_script( 'jquery-ui-tabs1', '/wp-includes/js/jquery/ui/jquery.ui.tabs.min.js', array('jquery-ui-widget'), '1.10.3', 1 );
wp_enqueue_script( 'jquery-ui-menu', '/wp-includes/js/jquery/ui/jquery.ui.menu.min.js', array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.10.3', 1 );
wp_enqueue_script( 'jquery-ui-1', '/wp-includes/js/jquery/ui/jquery.ui.autocomplete.min.js', array('jquery-ui-core', 'jquery-ui-widget'), '1.10.3', 1 );
wp_enqueue_script('watchlist',THT_WATCHLIST_DIR.'assets/js/watchlist.js',array('jquery','jquery-ui-1','jquery-ui-tabs1','jquery-ui-datepicker1','jquery-ui-dialog1','jquery-ui-button1',), '1.0.0', 1 );
}
}
add_action('wp_enqueue_scripts', 'tht_add_javascript_files');
Upvotes: 0
Views: 529
Reputation: 5937
id say offhand somewhere in the parent theme will be
define(THT_WATCHLIST_DIR, get_stylesheet_directory() );
it needs to be:
define(THT_WATCHLIST_DIR, get_template_directory() );
so you can use child themes. Either change in the theme and let the developer know about this or copy your js folder over to the child theme!
update
I am getting a 404 error for all your js files and pages as well. There may be a few things that are causing this. Dealing with your 404 issues first
flush your permalinks, copy your .htaccess file and save somewhere replace the contents of your .htaccess file with this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
undo the theme change you made.
For your files 1. check the folder js actually exists in your theme 2. check folder permissions for js file ->should be 755 for the directories in your theme. 3. try the 2014 theme -> check your browser console (right click on a page element->inspect element and click on console in the pop up window) is there any errors? If not check your theme urls to js folder again, if there is errors, contact your hosting or check your apache settings again.
Upvotes: 1