Usage
This function runs automatically, so it is not called manually. Is this incorrect?
Additional Notes
This function will not email admins more than once in a 15 minute period, so multiple initializations will not cause emails within that time.
Source File
Located in /libs/Admin/Automation.php on line 342.
No Hooks
This function does not have any filters or actions available. Request one?
PHP
public function initialization_email_prev_settings(){
if ( !$this->is_initialized_before() ){
return;
}
$this->cli_output('Emailing previous settings backup file to administrators');
$user_output = '';
if ( $this->is_cli() ){
$user_output = 'WP-CLI';
} else {
$current_user = wp_get_current_user();
$user_output = $current_user->display_name . ' <' . $current_user->user_email . '>';
}
$subject = 'Wordpress theme settings reset for ' . get_bloginfo('name');
$message = '<p>Wordpress settings have been re-initialized for <strong>' . get_bloginfo('name') . '</strong> by <strong>' . $user_output . '</strong> on <strong>' . date('F j, Y') . '</strong> at <strong> ' . date('g:ia') . '</strong>.</p>';
global $wpdb;
$query_result = $wpdb->query('SELECT * FROM ' . $wpdb->options, ARRAY_A); //DB Query - Query all WP Options and return as an associative array
$options_backup_file = get_template_directory() . '/inc/data/options_backup_' . date('Y-m-d\TH:i:s') . '.csv';
$fp = fopen($options_backup_file, 'w');
foreach ( $query_result as $row ){ //Loop through the array and write each row to the CSV file
fputcsv($fp, $row);
}
fclose($fp);
$attachments = array($options_backup_file);
send_email_to_admins($subject, $message, $attachments);
unlink($options_backup_file); //Delete the backup file after emailing
}
Override
This function can not be short-circuited with an override filter. Request one?