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.

What’s a good way to unenqueue all scripts for a single template page?

I haven’t tried it, but this might do it: global $wp_scripts; if (is_a($wp_scripts, ‘WP_Scripts’)) { $wp_scripts->queue = array(); } Basically just resetting the scripts queue to blank. Should work, I think. You’d want this right at the top of your attachment template, probably. From an optimization perspective, it would be faster to use the is_attachment() … Read more

Generate featured images old posts

You can look into this post: http://ken.ph/first-image-of-wordpress-post-as-thumbnail/ Or if you’re comfortable with MySql try using this (obviously check it on local database first): INSERT into wp_postmeta (meta_value, meta_key, post_id) SELECT DISTINCT(ID), post_type , post_parent FROM wp_posts WHERE post_type=”attachment” AND post_parent !=0 AND post_status=”inherit”; UPDATE wp_postmeta set meta_key = ‘_thumbnail_id’ WHERE meta_key=’attachment’

How to Access Script Tags in Header

If done right there should be a callback hooked to wp_enqueue_scripts which has either wp_enqueue_script or both wp_register_script and wp_enqueue_script in it. Something like the following from the Codex: function themeslug_enqueue_script() { wp_enqueue_script( ‘my-js’, ‘filename.js’, false ); } add_action( ‘wp_enqueue_scripts’, ‘themeslug_enqueue_script’ ); You will need to find that callback function in your theme or in … Read more

Add script into front from my plugin

Use wp_enqueue_scripts and admin_enqueue_scripts actions to enqueue your scripts: // for front end add_action(‘wp_enqueue_scripts’, array(&$this, ‘load_my_scripts’)); // for back end add_action(‘admin_enqueue_scripts’, array(&$this, ‘load_my_scripts’)); Also pay attention that it is bad practice to load your scripts on all pages of the site. Load your script only if need be: // … function load_my_scripts() { if ( … Read more

why quotes shown in WordPress?

I am not sure about the extra quotes. The best way to include a java script file is with wp_enqueue_script() as indicated here in the codex. The safe and recommended method of adding JavaScript to a WordPress generated page and WordPress Theme or Plugin is by using wp_enqueue_script(). This function includes the script if it … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)