Skip to content

Commit

Permalink
Load tool descriptions later
Browse files Browse the repository at this point in the history
  • Loading branch information
akirk committed Nov 18, 2024
1 parent cbaa556 commit 6a56d16
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 24 deletions.
9 changes: 6 additions & 3 deletions HealthCheck/Tools/class-health-check-beta-features.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@
*/
class Health_Check_Beta_Features extends Health_Check_Tool {

public function __construct() {
$this->label = __( 'Beta features', 'health-check' );
$this->description = __( 'The plugin may contain beta features, which you as the site owner can enable or disable as you wish.', 'health-check' );

public function __construct() {
parent::__construct();

add_action( 'admin_init', array( $this, 'toggle_beta_features' ) );
}

public function set_description() {
$this->label = __( 'Beta features', 'health-check' );
$this->description = __( 'The plugin may contain beta features, which you as the site owner can enable or disable as you wish.', 'health-check' );
}

public function toggle_beta_features() {
if ( ! isset( $_GET['health-check-beta-features'] ) || ! current_user_can( 'view_site_health_checks' ) ) {
return;
Expand Down
4 changes: 1 addition & 3 deletions HealthCheck/Tools/class-health-check-debug-log-viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

class Health_Check_Debug_Log_Viewer extends Health_Check_Tool {

public function __construct() {
public function set_description() {
$this->label = __( 'Debug logs', 'health-check' );
$this->description = __( 'The details below are gathered from your <code>debug.log</code> file, and is displayed because the <code>WP_DEBUG_LOG</code> constant has been set to allow logging of warnings and errors.', 'health-check' );

parent::__construct();
}

private function read_debug_log() {
Expand Down
7 changes: 5 additions & 2 deletions HealthCheck/Tools/class-health-check-files-integrity.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
class Health_Check_Files_Integrity extends Health_Check_Tool {

public function __construct() {
$this->label = __( 'File integrity', 'health-check' );
$this->description = __( 'The File Integrity checks all the core files with the <code>checksums</code> provided by the WordPress API to see if they are intact. If there are changes you will be able to make a Diff between the files hosted on WordPress.org and your installation to see what has been changed.', 'health-check' );

add_action( 'wp_ajax_health-check-files-integrity-check', array( $this, 'run_files_integrity_check' ) );
add_action( 'wp_ajax_health-check-view-file-diff', array( $this, 'view_file_diff' ) );

parent::__construct();
}

public function set_description() {
$this->label = __( 'File integrity', 'health-check' );
$this->description = __( 'The File Integrity checks all the core files with the <code>checksums</code> provided by the WordPress API to see if they are intact. If there are changes you will be able to make a Diff between the files hosted on WordPress.org and your installation to see what has been changed.', 'health-check' );
}

/**
* Gathers checksums from WordPress API and cross checks the core files in the current installation.
*
Expand Down
4 changes: 1 addition & 3 deletions HealthCheck/Tools/class-health-check-htaccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
*/
class Health_Check_Htaccess extends Health_Check_Tool {

public function __construct() {
public function set_description() {
$this->label = __( '.htaccess Viewer', 'health-check' );
$this->description = __( 'The <code>.htaccess</code> file tells your server (if supported) how to handle links and file requests. This file usually requires direct server access to view, but if your system supports these files, you can verify its content here.', 'health-check' );

parent::__construct();
}

public function tab_content() {
Expand Down
8 changes: 5 additions & 3 deletions HealthCheck/Tools/class-health-check-mail-check.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ class Health_Check_Mail_Check extends Health_Check_Tool {
private $mail_error = null;

public function __construct() {
$this->label = __( 'Mail Check', 'health-check' );
$this->description = __( 'The Mail Check will invoke the <code>wp_mail()</code> function and check if it succeeds. We will use the E-mail address you have set up, but you can change it below if you like.', 'health-check' );

add_action( 'wp_ajax_health-check-mail-check', array( $this, 'run_mail_check' ) );

parent::__construct();
}

public function set_description() {
$this->label = __( 'Mail Check', 'health-check' );
$this->description = __( 'The Mail Check will invoke the <code>wp_mail()</code> function and check if it succeeds. We will use the E-mail address you have set up, but you can change it below if you like.', 'health-check' );
}

/**
* Checks if wp_mail() works.
*
Expand Down
10 changes: 6 additions & 4 deletions HealthCheck/Tools/class-health-check-phpinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
class Health_Check_Phpinfo extends Health_Check_Tool {

public function __construct() {
add_action( 'site_health_tab_content', array( $this, 'add_site_health_tab_content' ) );

parent::__construct();
}

public function set_description() {
$this->label = __( 'PHP Info', 'health-check' );

if ( ! function_exists( 'phpinfo' ) ) {
$this->description = __( 'The phpinfo() function has been disabled by your host. Please contact the host if you need more information about your setup.', 'health-check' );
} else {
$this->description = __( 'Some scenarios require you to look up more detailed server configurations than what is normally required. The PHP Info page allows you to view all available configuration options for your PHP setup. Please be advised that WordPress does not guarantee that any information shown on that page may not be considered sensitive.', 'health-check' );
}

add_action( 'site_health_tab_content', array( $this, 'add_site_health_tab_content' ) );

parent::__construct();
}

/**
Expand Down
9 changes: 6 additions & 3 deletions HealthCheck/Tools/class-health-check-plugin-compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
class Health_Check_Plugin_Compatibility extends Health_Check_Tool {

public function __construct() {
add_action( 'rest_api_init', array( $this, 'register_plugin_compat_rest_route' ) );

parent::__construct();
}

public function set_description() {
$this->label = __( 'Plugin compatibility', 'health-check' );
$this->description = sprintf(
'%s<br>%s',
__( 'Attempt to identify the compatibility of your plugins before upgrading PHP, note that a compatibility check may not always be accurate, and you may want to contact the plugin author to confirm that things will continue working.', 'health-check' ),
__( 'The compatibility check will need to send requests to the <a href="https://wptide.org">WPTide</a> project to fetch the test results for each of your plugins.', 'health-check' )
);

add_action( 'rest_api_init', array( $this, 'register_plugin_compat_rest_route' ) );

parent::__construct();
}

public function register_plugin_compat_rest_route() {
Expand Down
4 changes: 1 addition & 3 deletions HealthCheck/Tools/class-health-check-robotstxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
*/
class Health_Check_Robotstxt extends Health_Check_Tool {

public function __construct() {
public function set_description() {
$this->label = __( 'robots.txt Viewer', 'health-check' );
$this->description = __( 'The <code>robots.txt</code> file tells search engines which directories are allowed to be crawled and which not. WordPress generates a virtual file if there is no physical file. If there is a non-virtual file, the content will be displayed here.', 'health-check' );

parent::__construct();
}

public function tab_content() {
Expand Down
3 changes: 3 additions & 0 deletions HealthCheck/Tools/class-health-check-tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public function __construct() {
add_filter( 'health_check_tools_tab', array( $this, 'tab_setup' ) );
}

abstract public function set_description();

public function tab_setup( $tabs ) {
$this->set_description();
if ( ! isset( $this->label ) || empty( $this->label ) ) {
return $tabs;
}
Expand Down

0 comments on commit 6a56d16

Please sign in to comment.