add_action( 'init', function() { $ip = ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) ? $_SERVER['HTTP_CLIENT_IP'] : …
Override the WP random password generator with custom generator
// Override the WP random password generator with a custom random password. add_filter( 'random_password', 'my_random_password' ); …
Get user role
/** * Gets WordPress user role. * * @see: https://core.trac.wordpress.org/ticket/22624 * @see: …
Promote your RSS feed on every post
/* * This demo uses the_content filter to add an RSS * link to the end of every post. * * @uses the_content * @uses is_single() …
MySQL UPDATE and REPLACE
UPDATE wp_posts SET post_content = REPLACE( post_content, 'http://mysite.com', 'https://mysite.com' ), guid = REPLACE( guid, …
Restrict WordPress login by IP address
/** * The following will restrict login to a * specific IP address. * * Change "111.111.111.111" to the actual IP. */ add_action( …
Add cc and bcc to wp_mail() headers
$headers[] = 'From: Some One '; $headers[] = 'Cc: cc_number_1@email.com'; $headers[] = 'Cc: cc_number_2@email.com'; $headers[] = …
Random Number Generator
/** * Generates a random number of a fixed number of digits. * * The use of STR_PAD_LEFT allows the result to ALWAYS be the given …
Remove WP emoji scripts from header
/** * This snippet removes the WP emoji code from the WP header. */ remove_action( 'wp_head', …