Where’s The Best Place to use Register_Shutdown_Function()?

WordPress core register a shutdown function on its own (source) the function shutdown_action_hook registered to be ran on shutdown, call do_action( ‘shutdown’ ); and little more (source). So, if you want to register a shutdown function in WordPress way just add your function on ‘shutdown’ hook: add_action( ‘shutdown’, ‘my_shutdown_callback’ ); function my_shutdown_callback() { error_log(‘Goodbye’); } … Read more

Intercepting wp_mail() to view contents

The first link on Google is to https://developer.wordpress.org/reference/functions/wp_mail/ which says that wp_mail is in wp-includes/pluggable.php It also has the full function source code showing that the first active line of the function is: $atts = apply_filters( ‘wp_mail’, compact( ‘to’, ‘subject’, ‘message’, ‘headers’, ‘attachments’ ) ); … which suggests that if you hook into the filter … Read more

Disable Debug Log Programmatically

@Wyck was right, ( well sorta 😛 ) you can set error logs but 1) You need to enable debugging 2) ini_set(‘log_errors’, 1); or 0 for false 3) You need to set a log location via ini_set(‘error_log, $location) Once you have that set you can then if need be test if said file exists via … Read more

How can I determine what php files are being called by a given WP page?

There’s a native PHP function get_included_files() for that. Simply attach it to an action on the hook from where you want to know it. The first one is muplugins_loaded and the last accessible on is shutdown. add_action( ‘muplugins_loaded’, function() { $files = get_included_files(); foreach ( $files as $f ) echo $f.'<br>’; // or… var_dump( $files … Read more

How to make debug.log timestamps local time?

What is the time zone setup in your admin -> settings -> general page? WordPress overrides & kind of disregards php’s timezone & uses this own settings , if haven’t set this – default is UTC+0 Update: according to https://core.trac.wordpress.org/ticket/39595 – wordpress has forced this to be UTC

Nginx – Prevent Access to Debug file [closed]

I’ve frequently seen this used in Apache 2.2: <Files “debug.log”> Order allow,deny Deny from all </Files> but that’s deprecated in Apache 2.4: The Allow, Deny, and Order directives, provided by mod_access_compat, are deprecated and will go away in a future version. You should avoid using them, and avoid outdated tutorials recommending their use. I just … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)