WordPress opens js files as a catalog. Path is right [closed]

You should solve your problem while moving toward a best practice while you’re at it by using wp_enqueue_script(). This will likely solve your issues because it’s domain agnostic. Start by moving your JS file(s) to a /js/ folder in your [child] theme or custom plugin. Then load your script like this… (snippets copied and adpated … Read more

TinyMCE Javascript URL Question

I think the best way is to use the before_wp_tiny_mce() hook. Then, you can define the url in PHP; and pass it to the page so it is available to TinyMCE. function sgp_before_wp_tiny_mce() { ?> <script type=”text/javscript”> var sgp_plugin_url = “<?php echo plugins_url(‘shortcode_generator_popup.php’, __FILE__); ?>”; </script> <?php } add_action(‘before_wp_tiny_mce’, ‘sgp_before_wp_tiny_mce’); You may need to change … Read more

Custom JS text area in customizer is being formatted wrong in document

@sam-skirrow just posting here what we did to fix this… WordPress 4.1 requires us to use a sanitize_callback filter when creating settings for the customizer (with good reason). Since you’re using the kirki framework to create these customizer settings, kirki detects that this is a textarea field and so it automatically applies the esc_textarea filter. … Read more

Conditional custom redirect

It should not be tough. As you suggested you can use ACF to add a custom field in post/page and then use the template_redirect action hook to check if the current page’s custom field is a valid URL as well as $_GET[‘redirect’] is true, wp_redirect to that URL. function my_page_template_redirect() { if( is_url(GET_ACF_FIELD_VALUE( ‘CUSTOM_FIELD’ )) … Read more

php variable inside javascript code

This should work: <?php $script = “<script type=”text/javascript”> jQuery( document ).ready( function($) { $(document).ready(function() { $(‘#particles’).particleground({ dotColor: ” . json_encode($dotcolor) . “, lineColor: ‘#5cb9bd’, }); }); } ); </script>”; ?> Note: Its a better practice to enqueue Javascripts with wp_enqueue_script() and include dynamic strings via wp_localize_script(). Docs: https://codex.wordpress.org/Function_Reference/wp_enqueue_script https://codex.wordpress.org/Function_Reference/wp_localize_script

Custom JS on a specific page

First of all, you should declare your scripts using wp_enque_script. Second, jQuery is loaded automatically in WordPress and is set to no conflict mode. See the documentation for how to link a script that depends on jQuery. Lastly, if you want it to appear on just one page you have two options In your functions.php … Read more