Site health – in an external PHP file.

  • Unknown's avatar
    <?php
    $csv_output = true;  // Set to false for html style.
    
    define('WP_USE_THEMES', false);
    
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    
    // Check if get_plugins() function exists. This is required on the front end of the
    // site, since it is in a file that is normally only loaded in the admin.
    if ( ! function_exists( 'get_plugins' ) ) {
    	require_once ABSPATH . 'wp-admin/includes/plugin.php';
    }
    
    $all_plugins = get_plugins();
    $active_plugins = get_option('active_plugins');
    
    if ( $csv_output ) { echo '<pre>'; }
    foreach ( $active_plugins as $index => $plugin ) {
    	if ( array_key_exists( $plugin, $all_plugins ) ) {
    		//var_export( $all_plugins[ $plugin ] );
            if ( $csv_output ) {
                echo join( "t", array( $all_plugins[ $plugin ][ 'Name' ], $all_plugins[ $plugin ][ 'Version' ], $all_plugins[ $plugin ][ 'Description' ] ) ), "n";
            } else {
                echo '<h2>', $all_plugins[ $plugin ][ 'Name' ], ' ('. $all_plugins[ $plugin ][ 'Version' ] .')</h2>';
                echo '<p>', $all_plugins[ $plugin ][ 'Description' ], '</p>';
            }
        }
    }
    if ( $csv_output ) { echo '</pre>'; }
    ?>

    I created a test.php file and added the code in it as in the example.
    It displays information about active plugins.

    I would like to know if it is possible to add additional information output for the “site health” section.
    So that the information can be seen without going into the admin panel, but simply in an external PHP file.

    I found this information on the Internet, but I couldn’t figure out how to use it.
    Tell me how to do this, and if possible, an example of code. #

    List of standard tests and their identifiers

    Direct
    Those that are executed immediately when the page is generated in PHP.

    wordpress_version – WordPress version,
    plugin_version – Plugin versions,
    theme_version – Theme versions
    php_version – PHP version,
    php_extensions – PHP extensions,
    php_default_timezone – PHP default time zone,
    sql_server – DBMS software version,
    utf8mb4_support – MySQL support for utf8mb4 encoding,
    https_status – HTTPS status,
    ssl_support – Secure connection,
    scheduled_events – Scheduled WP_Cron events,
    http_requests – HTTP requests,
    debug_enabled – Debugging is enabled (meaning WP_DEBUG in wp-config.php),
    rest_availability – REST API availability;

    Asynchronous
    As you can already guess if you read the next paragraph, asynchronous checks take much more time, which is why they are performed via AJAX, so that you don’t get too sad when you wait for the Site Health page to load.

    dotorg_communication – Connection to WordPress.org,
    background_updates – Background updates,
    loopback_requests – Loopback request; #

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    Hello!

    Thank you for reaching out to the free support forums for websites hosted on WordPress.com. While your site is not hosted with us, we’re here to guide you in the right direction for assistance.

    Since you’re using the open-source version of the WordPress platform, which operates differently from what we provide on WordPress.com, you can find help at the community forums here:

    https://wordpress.org/support/forum/how-to-and-troubleshooting/

    The community members in the open-source forum are well-versed in these matters and are in the best position to offer support.

    I hope this information helps guide you in the right direction. Feel free to ask if you have any further questions or need more assistance.

  • The topic ‘Site health – in an external PHP file.’ is closed to new replies.