Stop a plugin in the activation process when a certain WP version is not met then show error message in admin_notices action hook

I may be late to this party, but to stop plugin activation and have WordPress show an error message where the admin notices go, I simply output an error message and terminate execution. This has the added advantage of playing nice with wp-cli: Example: class testPlugin() { … static function activate() { //[do some stuff … Read more

How do I improve this admin query snippet to avoid generating duplicate results on non-meta searches?

A GROUP BY statement can group your posts after the JOIN. For WordPress you can use the posts_groupby filter. add_filter( ‘posts_groupby’, ‘my_post_limits’ ); function my_post_limits($groupby) { global $pagenow, $wpdb; if ( is_admin() && $pagenow == ‘edit.php’ && $_GET[‘post_type’]==’listings’ && $_GET[‘s’] != ” ) { $groupby = “$wpdb->posts.ID”; } return $groupby; }

WP_Query leaking absurd amounts of memory

Excellent responses on WP Hackers: http://lists.automattic.com/pipermail/wp-hackers/2012-June/043213.html What you’re doing with that query, is loading EVERY matching post into memory, including the full post contents. As you can imagine, this is probably quite a lot of items. You can pass ‘fields’ => ‘ids’ into WP_Query to simply return a list of matching post_ids instead, which should … Read more

Custom media upload content for inserting custom post shortcode

Have a look at my guide here – http://www.wpexplorer.com/wordpress-tinymce-tweaks/ – so you can see how to create a popup window where you can select your options than insert a shortcode. If you download my Free Symple Shortcodes plugin you can see a live implementation as well. Instead of having the user select the posts to … Read more

Is it necessary to bump a plug-in’s version if you’re just updating the “Tested up to” attribute?

I would only increase the version number if users needed to download the plugin again. The “Tested up to” variable is not used when the plugin is installed, only when people want to install it or want to upgrade. In that case, the information comes from the server anyway, so you don’t need to force … Read more

No Error Log File, no debug info

Insert this into your wp-config.php // Enable WP_DEBUG mode define(‘WP_DEBUG’, true); // Enable Debug logging to the /wp-content/debug.log file define(‘WP_DEBUG_LOG’, true); // Disable display of errors and warnings define(‘WP_DEBUG_DISPLAY’, false); @ini_set(‘display_errors’,0); Before /* That’s all, stop editing! Happy blogging. */

File not found.