Ejemplo n.º 1
0
function admin_menu()
{
    add_options_page('dbug Settings', 'dbug', 'manage_options', 'dbug', __NAMESPACE__ . '\\route');
    // update settings $_POST
    if (isset($_GET['page']) && $_GET['page'] == 'dbug' && isset($_POST['submit'])) {
        // remove empty posts
        $allowed = array('dbug_error_level', 'dbug_logging', 'dbug_log_path');
        foreach ($allowed as $allow) {
            if (!isset($_POST[$allow])) {
                delete_option($allow);
            }
        }
        // update dbug_log_path
        if (isset($_POST['dbug_error_level'])) {
            update_option('dbug_error_level', $_POST['dbug_error_level']);
        }
        // update screen or logs
        if (isset($_POST['dbug_logging'])) {
            update_option('dbug_logging', $_POST['dbug_logging']);
        }
        // update dbug_log_path
        if (isset($_POST['dbug_log_path'])) {
            //make sure the path exists and is writable.
            $dir = $_POST['dbug_log_path'];
            $dir = check_log_dir($dir);
            update_option('dbug_log_path', $dir);
        }
        // update log filesize
        if (isset($_POST['dbug_log_filesize'])) {
            $megabytes = (double) $_POST['dbug_log_filesize'];
            $bytes = $megabytes * 1024 * 1024;
            update_option('dbug_log_filesize', $bytes);
        }
    }
}
Ejemplo n.º 2
0
function get_log_path()
{
    $path = get_option('dbug_log_path');
    return check_log_dir($path);
}