Skip to Content
Menu

initialization_email_prev_settings()

Emails the previous settings to admins prior to initializing, so they can be recovered if needed.

PHP April 27, 2017

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.

Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /libs/Admin/Automation.php on line 319.

    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;
                }
    
                $current_user = wp_get_current_user();
    
                $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>' . $current_user->display_name . ' <' . $current_user->user_email . '></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);
            }
    

    Override

    This function can not be short-circuited with an override filter. Request one?