This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,96 @@
<?php
/**
* Information about debugging displayed in server configuration widget.
*
* @var string[] $errors_codes List of server configuration errors.
* @var string $size_png_path Size of file.
* @var string $size_png2_path Size of file.
* @var string $size_png_url Size of file.
* @var string $size_png2_url Size of file.
* @var string $size_png_as_webp_url Size of file.
* @var string $size_png2_as_webp_url Size of file.
* @var mixed[] $plugin_settings Option keys with values.
*
* @package Converter for Media
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use WebpConverter\Error\Notice\AccessTokenInvalidNotice;
use WebpConverter\Service\FileLoader;
use WebpConverter\Service\OptionsAccessManager;
use WebpConverter\Service\TokenValidator;
?>
<h4>Errors debug</h4>
<table>
<tbody>
<tr>
<td class="e">Size of PNG <em>(by server path)</em></td>
<td class="v">
<?php echo esc_html( $size_png_path ); ?>
</td>
</tr>
<tr>
<td class="e">Size of PNG2 <em>(by server path)</em></td>
<td class="v">
<?php echo esc_html( $size_png2_path ); ?>
</td>
</tr>
<tr>
<td class="e">Size of PNG as WEBP <em>(by URL)</em></td>
<td class="v">
<?php echo esc_html( $size_png_as_webp_url ); ?>
</td>
</tr>
<tr>
<td class="e">Size of PNG as PNG <em>(by URL)</em></td>
<td class="v">
<?php echo esc_html( $size_png_url ); ?>
</td>
</tr>
<tr>
<td class="e">Size of PNG2 as WEBP <em>(by URL)</em></td>
<td class="v">
<?php echo esc_html( $size_png2_as_webp_url ); ?>
</td>
</tr>
<tr>
<td class="e">Size of PNG2 as PNG2 <em>(by URL)</em></td>
<td class="v">
<?php echo esc_html( $size_png2_url ); ?>
</td>
</tr>
<tr>
<td class="e">Plugin settings</td>
<td class="v">
<?php echo esc_html( json_encode( $plugin_settings ) ?: '-' ); ?>
</td>
</tr>
<tr>
<td class="e">Error codes</td>
<td class="v">
<?php echo esc_html( json_encode( $errors_codes ) ?: '-' ); ?>
</td>
</tr>
<?php if ( in_array( AccessTokenInvalidNotice::ERROR_KEY, $errors_codes ) ) : ?>
<tr>
<td class="e">Token validation request</td>
<td class="v">
<?php echo esc_html( json_encode( OptionsAccessManager::get_option( TokenValidator::REQUEST_INFO_OPTION ) ) ?: '-' ); ?>
</td>
</tr>
<?php endif; ?>
</tbody>
<tr>
<td class="e">Error detection logs</td>
<td class="v">
<?php foreach ( $GLOBALS[ FileLoader::GLOBAL_LOGS_VARIABLE ] ?? [] as $log_data ) : ?>
<?php echo esc_html( json_encode( $log_data ) ?: '-' ); ?>
<br>
<?php endforeach; ?>
</td>
</tr>
</table>

View File

@ -0,0 +1,79 @@
<?php
/**
* Information about using filters displayed in server configuration widget.
*
* @package Converter for Media
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use WebpConverter\Service\PathsGenerator;
?>
<h4>Filters</h4>
<table>
<tbody>
<tr>
<td class="e">webpc_site_url</td>
<td class="v">
<?php echo esc_html( apply_filters( 'webpc_site_url', ( defined( 'WP_HOME' ) ) ? WP_HOME : get_site_url() ) ); ?>
</td>
</tr>
<tr>
<td class="e">webpc_site_root</td>
<td class="v">
<?php echo esc_html( PathsGenerator::get_wordpress_root_path() ); ?>
</td>
</tr>
<tr>
<td class="e">webpc_dir_path <em>(plugins)</em></td>
<td class="v">
<?php echo esc_html( apply_filters( 'webpc_dir_path', '', 'plugins' ) ); ?>
</td>
</tr>
<tr>
<td class="e">webpc_dir_path <em>(themes)</em></td>
<td class="v">
<?php echo esc_html( apply_filters( 'webpc_dir_path', '', 'themes' ) ); ?>
</td>
</tr>
<tr>
<td class="e">webpc_dir_path <em>(uploads)</em></td>
<td class="v">
<?php echo esc_html( apply_filters( 'webpc_dir_path', '', 'uploads' ) ); ?>
</td>
</tr>
<tr>
<td class="e">webpc_dir_path <em>(webp)</em></td>
<td class="v">
<?php echo esc_html( apply_filters( 'webpc_dir_path', '', 'webp' ) ); ?>
</td>
</tr>
<tr>
<td class="e">webpc_source_directories</td>
<td class="v">
<?php echo esc_html( json_encode( apply_filters( 'webpc_source_directories', [] ) ) ?: '-' ); ?>
</td>
</tr>
<tr>
<td class="e">webpc_htaccess_rewrite_root</td>
<td class="v">
<?php echo esc_html( PathsGenerator::get_rewrite_root() ); ?>
</td>
</tr>
<tr>
<td class="e">webpc_htaccess_rewrite_path</td>
<td class="v">
<?php echo esc_html( PathsGenerator::get_rewrite_path() ); ?>
</td>
</tr>
<tr>
<td class="e">webpc_htaccess_rewrite_output</td>
<td class="v">
<?php echo esc_html( apply_filters( 'webpc_htaccess_rewrite_output', PathsGenerator::get_rewrite_path(), PathsGenerator::get_rewrite_root() ) ); ?>
</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,18 @@
<?php
/**
* Information about GD library displayed in server configuration widget.
*
* @package Converter for Media
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<h4>gd</h4>
<?php if ( ! extension_loaded( 'gd' ) ) : ?>
<p>-</p>
<?php else : ?>
<?php ( new \ReflectionExtension( 'gd' ) )->info(); ?>
<?php endif; ?>

View File

@ -0,0 +1,18 @@
<?php
/**
* Information about Imagick library displayed in server configuration widget.
*
* @package Converter for Media
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<h4>imagick</h4>
<?php if ( ! extension_loaded( 'imagick' ) ) : ?>
<p>-</p>
<?php else : ?>
<?php ( new \ReflectionExtension( 'imagick' ) )->info(); ?>
<?php endif; ?>

View File

@ -0,0 +1,122 @@
<?php
/**
* Information about plugin options displayed in server configuration widget.
*
* @package Converter for Media
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use WebpConverter\Conversion\Cron\CronStatusManager;
use WebpConverter\Notice\CloudflareNotice;
use WebpConverter\Notice\ThanksNotice;
use WebpConverter\Notice\UpgradeNotice;
use WebpConverter\Notice\WelcomeNotice;
use WebpConverter\Service\CloudflareConfigurator;
use WebpConverter\Service\OptionsAccessManager;
use WebpConverter\Service\StatsManager;
?>
<h4>Options</h4>
<table>
<tbody>
<tr>
<td class="e"><?php echo esc_html( WelcomeNotice::NOTICE_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( WelcomeNotice::NOTICE_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( ThanksNotice::NOTICE_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( ThanksNotice::NOTICE_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( CloudflareNotice::NOTICE_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( CloudflareNotice::NOTICE_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( UpgradeNotice::NOTICE_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( UpgradeNotice::NOTICE_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( CronStatusManager::CRON_PATHS_TRANSIENT ); ?></td>
<td class="v">
<?php echo count( get_site_transient( CronStatusManager::CRON_PATHS_TRANSIENT ) ?: [] ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( CronStatusManager::CRON_PATHS_SKIPPED_TRANSIENT ); ?></td>
<td class="v">
<?php echo esc_html( get_site_transient( CronStatusManager::CRON_PATHS_SKIPPED_TRANSIENT ) ?: '-' ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( CronStatusManager::CRON_STATUS_LOCKED_TRANSIENT ); ?></td>
<td class="v">
<?php echo esc_html( get_site_transient( CronStatusManager::CRON_STATUS_LOCKED_TRANSIENT ) ?: '-' ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( CronStatusManager::CRON_REQUEST_ID_TRANSIENT ); ?></td>
<td class="v">
<?php echo esc_html( get_site_transient( CronStatusManager::CRON_REQUEST_ID_TRANSIENT ) ?: '-' ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( CronStatusManager::CRON_REQUEST_RESPONSE_TRANSIENT ); ?></td>
<td class="v">
<?php echo esc_html( json_encode( get_site_transient( CronStatusManager::CRON_REQUEST_RESPONSE_TRANSIENT ) ) ?: '' ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( CloudflareConfigurator::REQUEST_CACHE_CONFIG_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( CloudflareConfigurator::REQUEST_CACHE_CONFIG_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( CloudflareConfigurator::REQUEST_CACHE_PURGE_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( CloudflareConfigurator::REQUEST_CACHE_PURGE_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( StatsManager::STATS_REGENERATION_IMAGES_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( StatsManager::STATS_REGENERATION_IMAGES_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( StatsManager::STATS_IMAGES_WEBP_ALL_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( StatsManager::STATS_IMAGES_WEBP_ALL_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( StatsManager::STATS_IMAGES_WEBP_UNCONVERTED_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( StatsManager::STATS_IMAGES_WEBP_UNCONVERTED_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( StatsManager::STATS_IMAGES_AVIF_ALL_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( StatsManager::STATS_IMAGES_AVIF_ALL_OPTION, '-' ) ); ?>
</td>
</tr>
<tr>
<td class="e"><?php echo esc_html( StatsManager::STATS_IMAGES_AVIF_UNCONVERTED_OPTION ); ?></td>
<td class="v">
<?php echo esc_html( OptionsAccessManager::get_option( StatsManager::STATS_IMAGES_AVIF_UNCONVERTED_OPTION, '-' ) ); ?>
</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,47 @@
<?php
/**
* Information about PHP configuration displayed in server configuration widget.
*
* @package Converter for Media
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<h4>PHP</h4>
<table>
<tbody>
<tr>
<td class="e">Version</td>
<td class="v">
<?php echo esc_html( phpversion() ?: '-' ); ?>
</td>
</tr>
<tr>
<td class="e">memory_limit</td>
<td class="v">
<?php echo esc_html( ini_get( 'memory_limit' ) ?: '-' ); ?>
</td>
</tr>
<tr>
<td class="e">max_execution_time</td>
<td class="v">
<?php echo esc_html( ini_get( 'max_execution_time' ) ?: '-' ); ?>
</td>
</tr>
<tr>
<td class="e">disable_functions</td>
<td class="v">
<?php echo esc_html( ini_get( 'disable_functions' ) ?: '-' ); ?>
</td>
</tr>
<tr>
<td class="e">SERVER_SOFTWARE</td>
<td class="v">
<?php echo esc_html( $_SERVER['SERVER_SOFTWARE'] ?? '-' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput ?>
</td>
</tr>
</tbody>
</table>

View File

@ -0,0 +1,34 @@
<?php
/**
* Information about registered image sub-sizes.
*
* @package Converter for Media
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$image_sizes = ( function_exists( 'wp_get_registered_image_subsizes' ) )
? wp_get_registered_image_subsizes()
: wp_get_additional_image_sizes();
?>
<h4>
<?php
echo esc_html(
__( 'Registered image sub-sizes for generating images in additional sizes by WordPress', 'webp-converter-for-media' )
);
?>
</h4>
<table>
<tbody>
<?php foreach ( $image_sizes as $size_name => $size_data ) : ?>
<tr>
<td class="e"><?php echo esc_html( $size_name ); ?></td>
<td class="v">
<?php echo esc_html( json_encode( $size_data ) ?: '-' ); ?>
</td>
</tr>
<?php endforeach; ?>
</table>

View File

@ -0,0 +1,65 @@
<?php
/**
* Information about WordPress config displayed in server configuration widget.
*
* @package Converter for Media
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<h4>WordPress</h4>
<table>
<tbody>
<tr>
<td class="e">ABSPATH</td>
<td class="v">
<?php echo esc_html( ABSPATH ); ?>
</td>
</tr>
<tr>
<td class="e">DOCUMENT_ROOT</td>
<td class="v">
<?php echo esc_html( $_SERVER['DOCUMENT_ROOT'] ?? '-' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput ?>
</td>
</tr>
<tr>
<td class="e">DOCUMENT_ROOT <em>(realpath)</em></td>
<td class="v">
<?php echo esc_html( realpath( $_SERVER['DOCUMENT_ROOT'] ?? '-' ) ?: '' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput ?>
</td>
</tr>
<tr>
<td class="e">WP_CONTENT_DIR</td>
<td class="v">
<?php echo esc_html( WP_CONTENT_DIR ); ?>
</td>
</tr>
<tr>
<td class="e">UPLOADS</td>
<td class="v">
<?php echo esc_html( defined( 'UPLOADS' ) ? UPLOADS : '-' ); ?>
</td>
</tr>
<tr>
<td class="e">wp_upload_dir <em>(basedir)</em></td>
<td class="v">
<?php echo esc_html( wp_upload_dir()['basedir'] ); ?>
</td>
</tr>
<tr>
<td class="e">home_url</td>
<td class="v">
<?php echo esc_html( get_home_url() ); ?>
</td>
</tr>
<tr>
<td class="e">site_url</td>
<td class="v">
<?php echo esc_html( get_site_url() ); ?>
</td>
</tr>
</tbody>
</table>