<?php 
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

use Elex\MultiVendor\Controller\HelpAndSupportController;
?>

System Info!!

Multisite:                <?php echo esc_html( is_multisite() ? 'Yes' : 'No' ) . "\n"; ?>

SITE_URL:                 <?php echo esc_url( get_site_url() ) . "\n"; ?>
HOME_URL:                 <?php echo esc_url( get_home_url() ) . "\n"; ?>

WordPress Version:        <?php echo esc_attr( get_bloginfo( 'version' ) ) . "\n"; ?>
Permalink Structure:      <?php echo esc_attr( get_option( 'permalink_structure' ) ) . "\n"; ?>
Active Theme:             <?php echo esc_html( $theme ) . "\n"; ?>
<?php if ( $host ) : ?>
Host:                     <?php echo esc_html( $host ) . "\n"; ?>
<?php endif; ?>

Registered Post Stati:    <?php echo esc_html( implode( ', ', get_post_stati() ) ) . "\n\n"; ?>
<?php
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI toggle context.
if ( isset( $_GET['system_info'] ) ) {

	echo '// Browser of Current Viewer //';
	echo "\r\n\r\n";
} 
?>
<?php echo esc_html( $browser ); ?>
<?php 
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only UI toggle context.
if ( isset( $_GET['system_info'] ) ) {
	echo "\r\n";
	echo '// End Browser of Current Viewer //';
	echo "\r\n\r\n";
} 
?>

PHP Version:              <?php echo esc_html( PHP_VERSION ) . "\n"; ?>
Web Server Info:          <?php echo esc_html( ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '' ) . "\n"; ?>

WordPress Memory Limit:   <?php echo esc_html( HelpAndSupportController::let_to_num( WP_MEMORY_LIMIT ) / ( 1024 ) ) . 'MB'; ?><?php echo "\n"; ?>
PHP Memory Limit:         <?php echo esc_html( ini_get( 'memory_limit' ) . "\n" ); ?>
PHP Upload Max Size:      <?php echo esc_html( ini_get( 'upload_max_filesize' ) . "\n" ); ?>
PHP Post Max Size:        <?php echo esc_html( ini_get( 'post_max_size' ) . "\n" ); ?>
PHP Upload Max Filesize:  <?php echo esc_html( ini_get( 'upload_max_filesize' ) . "\n" ); ?>
PHP Time Limit:           <?php echo esc_html( ini_get( 'max_execution_time' ) . "\n" ); ?>
PHP Max Input Vars:       <?php echo esc_html( ini_get( 'max_input_vars' ) . "\n" ); ?>
PHP Arg Separator:        <?php echo esc_html( ini_get( 'arg_separator.output' ) . "\n" ); ?>
PHP Allow URL File Open:  <?php echo esc_html( ini_get( 'allow_url_fopen' ) ? 'Yes' : 'No' ) . "\n"; ?>

WP_DEBUG:                 <?php echo esc_html( defined( 'WP_DEBUG' ) ? ( WP_DEBUG ? 'Enabled' : 'Disabled' ) : 'Not set' ) . "\n"; ?>

WP Table Prefix:          
<?php 
echo esc_html( 'Length: ' . strlen( $wpdb->prefix ) );
echo esc_html( ' Status:' );
if ( strlen( $wpdb->prefix ) > 16 ) {
echo esc_html( ' ERROR: Too Long' );
} else {
echo esc_html( ' Acceptable' );
} echo "\n"; 
?>

Show On Front:            <?php echo esc_html( get_option( 'show_on_front' ) . "\n" ); ?>
Page On Front:            
<?php 
$ids = get_option( 'page_on_front' );
echo esc_html( get_the_title( $ids ) . ' (#' . $ids . ')' ) . "\n"; 
?>
Page For Posts:           
<?php 
$ids = get_option( 'page_for_posts' );
echo esc_html( get_the_title( $ids ) . ' (#' . $ids . ')' ) . "\n"; 
?>

WP Remote Post:           <?php echo esc_html( $WP_REMOTE_POST ); ?>

Session:                  <?php echo esc_html( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n"; ?>
Session Name:             <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
Cookie Path:              <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
Save Path:                <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
Use Cookies:              <?php echo esc_html( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n"; ?>
Use Only Cookies:         <?php echo esc_html( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n"; ?>

DISPLAY ERRORS:           <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . esc_html( ini_get( 'display_errors' ) ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
FSOCKOPEN:                <?php echo esc_html( function_exists( 'fsockopen' ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.' ) . "\n"; ?>
cURL:                     <?php echo esc_html( function_exists( 'curl_init' ) ? 'Your server supports cURL.' : 'Your server does not support cURL.' ) . "\n"; ?>
SOAP Client:              <?php echo esc_html( class_exists( 'SoapClient' ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.' ) . "\n"; ?>

ACTIVE PLUGINS:

<?php 
$plugins_list   = get_plugins();
$active_plugins = get_option( 'active_plugins', array() );

foreach ( $plugins_list as $plugin_path => $plugin_name ) {
	// If the plugin isn't active, don't show it.
	if ( ! in_array( $plugin_path, $active_plugins, true ) ) {
		continue;
	}

	echo esc_html( $plugin_name['Name'] ) . ': ' . esc_html( $plugin_name['Version'] ) . "\n";
}

?>

// Generated by the WordPress Site Health //
<?php 

if ( ! class_exists( 'WP_Debug_Data' ) ) {
	require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php';
}
if ( ! class_exists( 'WP_Site_Health' ) ) {
	require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php';
}

$sitehealth_info = WP_Debug_Data::debug_data();
echo esc_html__( 'Site Health Info:', 'elex-multi-vendor-for-woocommerce' );
echo esc_attr( WP_Debug_Data::format( $sitehealth_info, 'debug' ) );

if ( is_multisite() ) : 
	?>

NETWORK ACTIVE PLUGINS:

	<?php 
	$plugins_list   = wp_get_active_network_plugins();
	$active_plugins = get_site_option( 'active_sitewide_plugins', array() );

	foreach ( $plugins_list as $plugin_path ) {
		$plugin_base = plugin_basename( $plugin_path );

		// If the plugin isn't active, don't show it.
		if ( ! array_key_exists( $plugin_base, $active_plugins ) ) {
			continue;
		}

		$plugin_name = get_plugin_data( $plugin_path, false, false );

echo esc_html( $plugin_name['Name'] ) . ' :' . esc_html( $plugin_name['Version'] ) . "\n";
	}
endif;

if ( has_action( 'elex_mv_extra_info' ) ) {
	echo "\n";
	/**
	* Fire an action hook for additional info
	*
	* @since 2.0.0
	*/
	do_action( 'elex_mv_extra_info' );
}
