示例#1
0
/**
 * save debug setting from UI
 */
function debug_save_setting()
{
    if (isset($_POST['debugsetting']) && !empty($_POST['debugsetting'])) {
        $is_update = 1;
        $enable_notification = isset($_POST['enable_notification']) ? trim($_POST['enable_notification']) : '0';
        $email_notification = isset($_POST['email_notification']) ? trim($_POST['email_notification']) : '';
        $error_reporting = isset($_POST['error_reporting']) ? trim($_POST['error_reporting']) : '0';
        $error_log = isset($_POST['error_log']) ? trim($_POST['error_log']) : '0';
        $display_error = isset($_POST['display_error']) ? trim($_POST['display_error']) : '0';
        $error_script = isset($_POST['error_script']) ? trim($_POST['error_script']) : '0';
        $error_savequery = isset($_POST['error_savequery']) ? trim($_POST['error_savequery']) : '0';
        if ($enable_notification == '1') {
            $error_reporting = $error_log = $error_script = $error_savequery = '1';
            if (!is_email($email_notification)) {
                $is_update = 0;
            }
        }
        $fileName = 'wp-config.php';
        $fileContent = debug_file_read($fileName);
        $fileContent = debug_add_option($error_reporting, 'WP_DEBUG', $fileContent);
        $fileContent = debug_add_option($error_log, 'WP_DEBUG_LOG', $fileContent);
        $fileContent = debug_add_option($display_error, 'WP_DEBUG_DISPLAY', $fileContent);
        $fileContent = debug_add_option($error_script, 'SCRIPT_DEBUG', $fileContent);
        $fileContent = debug_add_option($error_savequery, 'SAVEQUERIES', $fileContent);
        if (debug_file_write($fileContent, $fileName)) {
            update_option('debug_notification', array('enable' => $enable_notification, 'email' => $email_notification));
            ?>
            <script>
                window.location = '<?php 
            echo admin_url('admin.php?page=' . trim($_GET['page']) . '&update=' . $is_update);
            ?>
';
            </script>
            <?php 
        } else {
            echo '<div class="error settings-error">';
            echo '<p><strong>' . __('Your wp-config file not updated. Copy and paste following code in your wp-config.php file.', 'debug') . '</strong></p>';
            echo '</div>';
            echo '<textarea style="width:100%; height:400px">' . htmlentities($fileContent) . '</textarea>';
        }
    } elseif (isset($_GET['update']) && $_GET['page'] == 'debug_settings') {
        $output['status'] = 'updated';
        $output['message'] = 'setting saved successfully.';
        if ($_GET['update'] == 0) {
            $output['status'] = 'error';
            $output['message'] = 'Please enter Email Address.';
        }
        ?>
        <div class="<?php 
        echo $output['status'];
        ?>
 settings-error"> 
            <p><strong><?php 
        _e($output['message'], 'debug');
        ?>
</strong></p>
        </div>
        <?php 
    }
}
示例#2
0
function debug_save_setting()
{
    if (isset($_POST['debugsetting']) && !empty($_POST['debugsetting'])) {
        $error_reporting = isset($_POST['error_reporting']) ? trim($_POST['error_reporting']) : '0';
        $error_log = isset($_POST['error_log']) ? trim($_POST['error_log']) : '0';
        $display_error = isset($_POST['display_error']) ? trim($_POST['display_error']) : '0';
        $error_script = isset($_POST['error_script']) ? trim($_POST['error_script']) : '0';
        $error_savequery = isset($_POST['error_savequery']) ? trim($_POST['error_savequery']) : '0';
        $fileName = 'wp-config.php';
        $fileContent = debug_file_read($fileName);
        $fileContent = debug_add_option($error_reporting, 'WP_DEBUG', $fileContent);
        $fileContent = debug_add_option($error_log, 'WP_DEBUG_LOG', $fileContent);
        $fileContent = debug_add_option($display_error, 'WP_DEBUG_DISPLAY', $fileContent);
        $fileContent = debug_add_option($error_script, 'SCRIPT_DEBUG', $fileContent);
        $fileContent = debug_add_option($error_savequery, 'SAVEQUERIES', $fileContent);
        if (debug_file_write($fileContent, $fileName)) {
            ?>
            <script>
                window.location = '<?php 
            echo admin_url('admin.php?page=' . trim($_GET['page']) . '&update=1');
            ?>
';
            </script>
            <?php 
        } else {
            echo '<div class="error settings-error">';
            echo '<p><strong>' . __('Your wp-config file not updated. Copy and paste following code in your wp-config.php file.', 'debug') . '</strong></p>';
            echo '</div>';
            echo '<textarea style="width:100%; height:400px">' . htmlentities($fileContent) . '</textarea>';
        }
    } elseif (isset($_GET['update']) && $_GET['update'] == 1 && $_GET['page'] == 'debug_settings') {
        ?>
        <div class="updated settings-error"> 
            <p><strong><?php 
        _e('wp-config.php file update successfully.', 'debug');
        ?>
</strong></p>
        </div>
        <?php 
    }
}