enqueue script won’t work (enqueue style does work)

You’re using the wrong hook. wp_enqueue_scripts is the correct hook for both: add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ ); add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_scripts’ ); But since they’re the same hook you can just enqueue both files in the same callback: function my_theme_enqueue_assets() { wp_enqueue_style( ‘parent-style’, get_parent_theme_file_uri( ‘style.css’ ) ); wp_enqueue_script( ‘behavior’, get_theme_file_uri( ‘behavior.js’ ), array(), null, true ); } … Read more

HTML escaping data with ajax requests

If it is not HTML, it does not need HTML escaping, if it is not JS, it does not need JS escaping. All escaping is context based. In general You should probably just avoid sending “text” in response and focus on sending data which is “converted” into whatever is the relevant DOM structures, either directly … Read more

Don’t allow JavaScript in the content area

You could use the_content filter: add_filter( ‘the_content’, ‘remove_script_tag’ ); function remove_script_tag( $content ) { return strip_tags( $content, ‘<script>’ ); } When you also want the content of the tag to be removed you could use this one: add_filter( ‘the_content’, ‘remove_script_tag_and_content’ ); function remove_script_tag_and_content( $content ) { $striped_text = preg_replace(‘@<script>.*?<\/script>@si’, ”, $content); return $striped_text; }

Making an AJAX call to refresh a table

The action in the Ajax call must be the name of the action on the add_action without the wp_ajax_nopriv.* for example: var data = { action: ‘fmsapi_refresh_hybrid_schedule’, year: ‘2017’, event: ‘ONOSH’, team: ‘4783’ }; You are targeting a class named select_team but this isn’t anywhere in your code. This is why your Js code cannot … Read more

I have problems with loading javascripts

You seem to be loading both file/folder names into the queue. get_template_directory_uri() . ‘http://fitclaw.com/wp-content/themes/Coming%20Soon/js/jquery.js should only be: get_template_directory_uri() . ‘/js/jquery.js’ And so-on and so-forth. because get_template_directory_uri returns, or should be returning this string for you: ‘http://fitclaw.com/wp-content/themes/Coming%20Soon/’ And you should always try to use those relative paths versus hard-coding them.

Javascript code doesn’t work in my wordpress theme

First – set jquery in dependencies array. And if you are using libraries – include them. All libraries must be registered, not enqueue. Use wp_register_script();. And set libs in dependencies array. wp_register_script(‘my-masonry’, ‘path to lib’, array(), null, true); wp_enqueue_script( ‘scripts’, get_template_directory_uri() . ‘/assets/js/scripts.js’, array(‘jquery’, ‘my-masonry’), null, true ); Code like this must fix your issue. … Read more