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 there is a hash for today. If not, create one. if ( isset( $error_log_hashes[ $date ] ) ) { $hash = $error_log_hashes[ $date ]; } else { // Generate a random value with NO special characters. […]

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. error_reporting( E_ALL ); // Sets to display errors on screen. Use 0 to turn off. ini_set( ‘display_errors’, 1 ); // Sets to log errors. Use 0 (or omit) to not log errors. ini_set( ‘log_errors’, 1 ); // Sets a log file path you […]

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 installed version of WP either using * get_bloginfo( ‘version’ ) OR use the global $wp_version. * Either is OK. */ global $wp_version; // alternate method // $wp_version = get_bloginfo( ‘version’ ) […]

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 wp-config.php * before the following line: * /* That’s all, stop editing! Happy blogging. */ // Turns on general debugging define( ‘WP_DEBUG’, true ); /* * WP_DEBUG_DISPLAY is optional. […]

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: * write_log( $value_to_write ); * * @param string|array|object $log */ function write_log( $log ) { if ( is_array( $log ) || is_object( $log ) ) { error_log( print_r( […]

Call a shortcode function by tag name

/** * Call a shortcode function by its tag name. * * Directly executes a shortcode’s callback function using the shortcode’s * tag name. Can execute a function even if it’s in an object class. * Simply pass the shortcode’s tag and an array of any attributes. * * @global array $shortcode_tags * @param string […]

Display a WordPress login form

$args = array( ‘echo’ => true, ‘redirect’ => ‘https://wpbitz.com’, ‘form_id’ => ‘loginform’, ‘label_username’ => __( ‘Username’ ), ‘label_password’ => __( ‘Password’ ), ‘label_remember’ => __( ‘Remember Me’ ), ‘label_log_in’ => __( ‘Log In’ ), ‘id_username’ => ‘user_login’, ‘id_password’ => ‘user_pass’, ‘id_remember’ => ‘rememberme’, ‘id_submit’ => ‘wp-submit’, ‘remember’ => true, ‘value_username’ => NULL, ‘value_remember’ => false […]