How to add GET variable after script url?

Filter script_loader_src and use add_query_arg(). You can use parse_url() or the second argument $handle to target specific scripts… I have included multiple redundant options here: add_filter( ‘script_loader_src’, ‘wpse_99842_add_get_var_to_url’, 10, 2 ); function wpse_99842_add_get_var_to_url( $url, $handle ) { if ( ‘my_handle’ !== $handle ) return $url; if ( empty ( $_GET[‘myvar’] ) ) return $url; $parts … Read more

How to connect rating to individual comments?

This is almost entirely an HTML and/or Javascript question. You just need to make proper forms and have some PHP to process it. function additional_fields ($below) { global $comment; $ratsec=”<form action=””.get_permalink().'” method=”get” class=”comment-form-rating”>’; $ratsec .= ‘<input type=”hidden” name=”p” value=”‘.get_the_ID().'”‘; $ratsec .= ‘<label for=”rating”>’. __(‘Rating’) . ‘<span class=”required”>*</span></label>’; $ratsec .= ‘<span class=”commentratingbox”>’; //Current rating scale is … Read more

Register Script in Plugin Widget

There are 3 issues. Firstly, you’re calling do_action, triggering the action: do_action( ‘wp_print_footer_scripts’, ‘tab_widget_scripts’ ); When actually, you want to add your function to it, not trigger it. You should be doing this: add_action( ‘wp_print_footer_scripts’, ‘tab_widget_scripts’ ); Secondly, you’re registering this script: tabs Then enqueuing this script: tabs.js Clearly they don’t match, in the same … Read more

Scripts not loading when using the wp_enqueue_scripts action

get_stylesheet_uri() loads the main stylesheet of the theme. If you need to load additional stylesheets, you need to use get_template_directory_uri() for parent themes and get_stylesheet_directory_uri() for child themes. If you have stylesheet called custom.css in the root in a child theme, you will use get_stylesheet_directory_uri()’ . /custom.css’ You should also make sure that you have … Read more

Hardening uploads folder in IIS breaks images

I don’t know if that is the right way but the last time I worked with IIS, I used this code to prevent the loading of an PHP script in the uploads folder. <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <location path=”wp-content/uploads”> <system.webServer> <security> <requestFiltering> <fileExtensions> <add fileExtension=”.php” allowed=”false” /> </fileExtensions> </requestFiltering> </security> </system.webServer> </location> </configuration> If you … Read more

Need to put a script above tag in header.php – WP 5.7.1

As @Buttered_Toest mentioned, this snippet works well. (This code goes to functions.php) function futy_widget_footer(){ ?> <script> window.Futy = { key: ‘0000000000’ }; (function (e, t) { var n = e.createElement(t); n.async = true; n.src=”https://v1.widget.futy.io/js/futy-widget.js”; var r = e.getElementsByTagName(t)[0]; r.parentNode.insertBefore(n, r); })(document, ‘script’); </script> <?php } add_action(‘wp_footer’,’futy_widget_footer’);

Custom PHP script throws critical error ONLY when editing page

When you’re editing the page, you’re in the directory wp-admin, and wp-admin doesn’t contain wp-content (they’re both children of your site’s root directory). Instead of ‘wp-content/uploads/cams/’, I’d recommend ABSPATH . ‘wp-content/uploads/cams/’ which should work wherever you might be in the WordPress environment.