diff --git a/includes/classes/Settings.php b/includes/classes/Settings.php index e6b2f51..3d275e6 100644 --- a/includes/classes/Settings.php +++ b/includes/classes/Settings.php @@ -37,14 +37,14 @@ public function __construct() { public function fields() { add_settings_section( 'debug', - __( 'Debug', 'debug-bar-for-sophi' ), + __( 'Debug Bar Settings', 'debug-bar-for-sophi' ), '', SETTINGS_GROUP ); add_settings_field( 'enable_debug_log', - __( 'Debug log', 'debug-bar-for-sophi' ), + __( 'Debug logging', 'debug-bar-for-sophi' ), array( $this, 'render_debug_log_field' ), SETTINGS_GROUP, 'debug' @@ -65,9 +65,17 @@ public function fields() { * @return void */ public function logs_menu() { + $settings = $this->get_settings(); + $is_writable = wp_is_writable( SOPHI_DEBUG_BAR_LOG_PATH ); + + // Don't add link if logs are disabled or directory not writable. + if ( 'yes' !== $settings['enable_debug_log'] || ! $is_writable ) { + return; + } + add_management_page( - __( 'Sophi Logs', 'debug-bar-for-sophi' ), - __( 'Sophi Logs', 'debug-bar-for-sophi' ), + __( 'Sophi.io Logs', 'debug-bar-for-sophi' ), + __( 'Sophi.io Logs', 'debug-bar-for-sophi' ), 'manage_options', 'sophi-logs', array( $this, 'logs_page' ) @@ -110,7 +118,7 @@ public function logs_page() { ?>