SELECT col, COUNT(col) FROM table_name GROUP BY col HAVING COUNT(col) > 1; …
Delete orphaned post meta in WordPress database
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL …
Simple plugin header
Error log file by date with hash
// Get stored hashes. $error_log_hashes = get_option( 'error_log_hashes' ); // Get today's date. $date = date('Y-m-d'); // Check if …
Error log files by date name
ini_set( 'error_log', WP_CONTENT_DIR . '/debug-' . date('Y-m-d') . '.log' ); …
Run WordPress in debug mode without access to wp-config
add_action( 'template_redirect', 'my_enable_debug_mode' ); function my_enable_debug_mode() { // Turn on error reporting. …
Compare versions in WordPress
/** * Use PHP's version_compare() to check the version * of WordPress (or a plugin or theme for that matter). * * Get currently …
Enable error logging in wp-config.php
/** * The WP debug constants. * * These are used in wp-config.php to enable debugging. * * NOTE all of these MUST be inserted in …
Error log utility function
/** * Writes string, array, and object data to the WP error log. * * To use, pass the result to write to the log as follows: * …