Pre populate WordPress wp_media modal with image selection

Here is the script: I’m using the function loadImages in following script to load the existing attached images via AJAX and then just pass the function with the IDs of images and it opens up a pre-populated modal. var frame, selection = loadImages(images); $(‘#stag_images_upload’).on(‘click’, function(e) { e.preventDefault(); var options = { title: ‘<?php _e(“Create Featured … Read more

How exactly do automatic updates work?

PHP isn’t a permanently-running process: it only runs when requested. So as far as I can tell, WordPress can only update itself when someone loads a web page. But the update process is not instantaneous, so surely a user visiting the site would have a really slow page load. Is there a different trick they … Read more

What does extract( shortcode_atts( array( do?

shortcode_atts() works like array_merge(): It merges the second list of arguments into the first one. The difference is: It merges only keys present in the first argument ($default). extract() then takes the array keys, sets these as variable names and their values as variable values. ‘w’ => ‘500’ in your example becomes $w = ‘500’. … Read more

Can I Prevent Enumeration of Usernames?

A simple solution I use in a .htaccess: RewriteCond %{REQUEST_URI} !^/wp-admin [NC] RewriteCond %{QUERY_STRING} author=\d RewriteRule ^ – [L,R=403] It is similar to @jptsetme’s answer, but it works even when the query string is /?dummy&author=5, and the search pattern for RewriteRule is very fast: You often see a capture ([0-9]*) in regular expressions for this. … Read more

Why use if function_exists?

Checking to see if built in WordPress functions exist before calling them is for backward compatibility which IMHO is not needed. So if you see if ( function_exists( ‘register_nav_menus’ ) ) the theme author is supporting versions earlier than 3.0. You still sometimes see if ( function_exists( ‘dynamic_sidebar’ ) ) Why? I couldn’t tell you … Read more