Commit realizado el 12:13:52 08-04-2024
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
/*!
|
||||
* Plugin: Rank Math - Status & Tools
|
||||
* URL: https://rankmath.com/wordpress/plugin/seo-suite/
|
||||
* Name: status.css
|
||||
*/@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(-360deg)}}@keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(-360deg)}}@keyframes bounce{from{-webkit-transform:translateY(0px);transform:translateY(0px)}to{-webkit-transform:translateY(-5px);transform:translateY(-5px)}}@-webkit-keyframes bounce{from{-webkit-transform:translateY(0px);transform:translateY(0px)}to{-webkit-transform:translateY(-5px);transform:translateY(-5px)}}@-webkit-keyframes loading{0%{background-size:20% 50% ,20% 50% ,20% 50%}20%{background-size:20% 20% ,20% 50% ,20% 50%}40%{background-size:20% 100%,20% 20% ,20% 50%}60%{background-size:20% 50% ,20% 100%,20% 20%}80%{background-size:20% 50% ,20% 50% ,20% 100%}100%{background-size:20% 50% ,20% 50% ,20% 50%}}@keyframes loading{0%{background-size:20% 50% ,20% 50% ,20% 50%}20%{background-size:20% 20% ,20% 50% ,20% 50%}40%{background-size:20% 100%,20% 20% ,20% 50%}60%{background-size:20% 50% ,20% 100%,20% 20%}80%{background-size:20% 50% ,20% 50% ,20% 100%}100%{background-size:20% 50% ,20% 50% ,20% 50%}}:root{--rankmath-wp-adminbar-height: 0}.rank-math-status-table{margin-top:20px}.rank-math-status-table tr th,.rank-math-status-table tr td{padding:10px}.rank-math-status-table thead tr th{color:#32373c}.rank-math-status-table thead tr th h2{font-size:14px;margin:0}.rank-math-status-table tbody tr td:first-child{width:33%}.rank-math-status-table .update_all_scores{display:block;font-size:13px;margin-top:10px;line-height:1.3}.rank-math-status-table .update_all_scores input{vertical-align:middle}.rank-math-tools-table.widefat{padding:0;border-color:#b5bfc9}.rank-math-tools-table.widefat tr:first-of-type th{border-radius:6px 0 0 0}.rank-math-tools-table.widefat tr:first-of-type td{border-radius:0 6px 0 0}.rank-math-tools-table.widefat tr:nth-child(odd){background:#f8f9fa}.rank-math-tools-table.widefat tr th,.rank-math-tools-table.widefat tr td{font-size:1.1em;font-weight:400;padding:2em;border-bottom:1px solid #b5bfc9}.rank-math-tools-table.widefat tr:last-of-type th,.rank-math-tools-table.widefat tr:last-of-type td{border-bottom:0}.rank-math-tools-table.widefat h4{margin:0 0 .825rem}.rank-math-modal{position:fixed;z-index:9999;top:0;right:0;bottom:0;left:0;display:none;background-color:rgba(0,0,0,0.35)}.rank-math-modal.show{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.rank-math-modal .rank-math-modal-content{width:100%;max-width:680px;padding:40px;border-radius:3px;background-color:#fff;-webkit-box-shadow:0 5px 30px 0 rgba(0,0,0,0.2);box-shadow:0 5px 30px 0 rgba(0,0,0,0.2)}.rank-math-modal .rank-math-modal-content h3{margin:0}.rank-math-modal .rank-math-modal-content p{font-size:1rem}.rank-math-modal .rank-math-modal-content .rank-math-modal-header{margin-bottom:1.25rem}.rank-math-modal .rank-math-modal-content .rank-math-modal-header h3{font-size:1.5rem}.rank-math-modal .rank-math-modal-content .rank-math-modal-body .count{margin-bottom:5px;font-size:1rem;opacity:0.7}.rank-math-modal .rank-math-modal-content .rank-math-modal-body .progress-bar{width:100%;height:40px;border:1px solid #418441;border-radius:4px}.rank-math-modal .rank-math-modal-content .rank-math-modal-body .progress-bar>span{display:block;width:5px;height:100%;-webkit-transition:all .5s;transition:all .5s;background-color:#52a652;border-radius:3px}body.rank-math_page_rank-math-status.rank-math-start-update-score{overflow:hidden}body.rank-math_page_rank-math-status.rank-math-start-update-score #wpadminbar{display:none}body.rank-math_page_rank-math-status.rank-math-start-update-score .rank-math-modal{background-color:#fff}
|
File diff suppressed because one or more lines are too long
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* Locate, retrieve, and display the server's error log.
|
||||
*
|
||||
* @since 1.0.33
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Status
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Status;
|
||||
|
||||
use RankMath\Helper;
|
||||
use RankMath\Helpers\Str;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Error_Log class.
|
||||
*/
|
||||
class Error_Log {
|
||||
|
||||
/**
|
||||
* Log path.
|
||||
*
|
||||
* @var string|bool
|
||||
*/
|
||||
private $log_path = null;
|
||||
|
||||
/**
|
||||
* File content.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $contents = null;
|
||||
|
||||
/**
|
||||
* Display Database/Tables Details.
|
||||
*/
|
||||
public function display() {
|
||||
?>
|
||||
<div class="rank-math-system-status rank-math-box">
|
||||
<header>
|
||||
<h3><?php esc_html_e( 'Error Log', 'rank-math' ); ?></h3>
|
||||
</header>
|
||||
|
||||
<p class="description">
|
||||
<?php
|
||||
printf(
|
||||
// Translators: placeholder is a link to WP_DEBUG documentation.
|
||||
esc_html__( 'If you have %s enabled, errors will be stored in a log file. Here you can find the last 100 lines in reversed order so that you or the Rank Math support team can view it easily. The file cannot be edited here.', 'rank-math' ),
|
||||
'<a href="https://wordpress.org/support/article/debugging-in-wordpress/" target=_blank" >WP_DEBUG_LOG</a>'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
if ( $this->can_load() ) {
|
||||
$this->display_copy_button();
|
||||
$this->display_textarea();
|
||||
$this->display_info();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show copy button.
|
||||
*/
|
||||
private function display_copy_button() {
|
||||
?>
|
||||
<div class="site-health-copy-buttons">
|
||||
<div class="copy-button-wrapper">
|
||||
<button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( $this->get_error_log_rows( 100 ) ); ?>">
|
||||
<?php esc_html_e( 'Copy Log to Clipboard', 'rank-math' ); ?>
|
||||
</button>
|
||||
<span class="success hidden" aria-hidden="true"><?php esc_html_e( 'Copied!', 'rank-math' ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show information about the error log file.
|
||||
*/
|
||||
private function display_info() {
|
||||
?>
|
||||
<div class="error-log-info" style="margin-top: 1rem;">
|
||||
<code><?php echo esc_html( basename( $this->get_log_path() ) ); ?></code>
|
||||
<em>(<?php echo esc_html( Str::human_number( strlen( join( '', $this->contents ) ) ) ); ?>)</em>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the textarea with the error log.
|
||||
*/
|
||||
private function display_textarea() {
|
||||
?>
|
||||
<div id="error-log-wrapper">
|
||||
<textarea name="name" rows="16" cols="80" class="code large-text rank-math-code-box" disabled="disabled" id="rank-math-status-error-log"><?php echo esc_textarea( $this->get_error_log_rows( 100 ) ); ?></textarea>
|
||||
<script>var textarea = document.getElementById('rank-math-status-error-log'); textarea.scrollTop = textarea.scrollHeight;</script>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last x rows from the error log.
|
||||
*
|
||||
* @param integer $limit Max number of rows to return.
|
||||
*
|
||||
* @return string[] Array of rows of text.
|
||||
*/
|
||||
private function get_error_log_rows( $limit = -1 ) {
|
||||
if ( is_null( $this->contents ) ) {
|
||||
$wp_filesystem = Helper::get_filesystem();
|
||||
$this->contents = $wp_filesystem->get_contents_array( $this->get_log_path() );
|
||||
}
|
||||
|
||||
if ( -1 === $limit ) {
|
||||
return join( '', $this->contents );
|
||||
}
|
||||
|
||||
return is_array( $this->contents ) ? join( '', array_slice( $this->contents, -$limit ) ) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Show error if the log cannot be loaded.
|
||||
*/
|
||||
private function can_load() {
|
||||
$log_file = $this->get_log_path();
|
||||
$wp_filesystem = Helper::get_filesystem();
|
||||
|
||||
if (
|
||||
empty( $log_file ) ||
|
||||
is_null( $wp_filesystem ) ||
|
||||
! Helper::is_filesystem_direct() ||
|
||||
! $wp_filesystem->exists( $log_file ) ||
|
||||
! $wp_filesystem->is_readable( $log_file )
|
||||
) {
|
||||
?>
|
||||
<strong class="error-log-cannot-display">
|
||||
<?php esc_html_e( 'The error log cannot be retrieved.', 'rank-math' ); ?>
|
||||
</strong>
|
||||
<?php
|
||||
return false;
|
||||
}
|
||||
|
||||
// Error log must be smaller than 100 MB.
|
||||
$size = $wp_filesystem->size( $log_file );
|
||||
if ( $size > 100000000 ) {
|
||||
?>
|
||||
<strong class="error-log-cannot-display">
|
||||
<?php esc_html_e( 'The error log cannot be retrieved: Error log file is too large.', 'rank-math' ); ?>
|
||||
</strong>
|
||||
<?php
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get error log file location.
|
||||
*
|
||||
* @return string Path to log file.
|
||||
*/
|
||||
private function get_log_path() {
|
||||
if ( is_null( $this->log_path ) ) {
|
||||
$this->log_path = ini_get( 'error_log' );
|
||||
}
|
||||
|
||||
return $this->log_path;
|
||||
}
|
||||
}
|
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* The Status & Tools internal module.
|
||||
*
|
||||
* @since 1.0.33
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Status
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Status;
|
||||
|
||||
use RankMath\Helper;
|
||||
use RankMath\Helpers\Param;
|
||||
use RankMath\Module\Base;
|
||||
use RankMath\Traits\Hooker;
|
||||
use RankMath\Admin\Page;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* Status class.
|
||||
*/
|
||||
class Status extends Base {
|
||||
|
||||
use Hooker;
|
||||
|
||||
/**
|
||||
* Module ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id = '';
|
||||
|
||||
/**
|
||||
* Module directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $directory = '';
|
||||
|
||||
/**
|
||||
* Module page.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $page;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
if ( Helper::is_heartbeat() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$directory = dirname( __FILE__ );
|
||||
$this->config(
|
||||
[
|
||||
'id' => 'status',
|
||||
'directory' => $directory,
|
||||
]
|
||||
);
|
||||
|
||||
$this->filter( 'rank_math/tools/pages', 'add_status_page', 12 );
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register admin page.
|
||||
*/
|
||||
public function register_admin_page() {
|
||||
$uri = untrailingslashit( plugin_dir_url( __FILE__ ) );
|
||||
|
||||
$this->page = new Page(
|
||||
'rank-math-status',
|
||||
esc_html__( 'Status & Tools', 'rank-math' ),
|
||||
[
|
||||
'position' => 70,
|
||||
'parent' => 'rank-math',
|
||||
'classes' => [ 'rank-math-page' ],
|
||||
'render' => $this->directory . '/views/main.php',
|
||||
'assets' => [
|
||||
'styles' => [
|
||||
'rank-math-common' => '',
|
||||
'rank-math-status' => $uri . '/assets/css/status.css',
|
||||
],
|
||||
'scripts' => [
|
||||
'lodash' => '',
|
||||
'rank-math-analyzer' => rank_math()->plugin_url() . 'assets/admin/js/analyzer.js',
|
||||
'rank-math-dashboard' => '',
|
||||
'rank-math-status' => $uri . '/assets/js/status.js',
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display dashboard tabs.
|
||||
*/
|
||||
public function display_nav() {
|
||||
$default_tab = $this->do_filter( 'tools/default_tab', 'status' );
|
||||
?>
|
||||
<div class="rank-math-tab-nav" role="tablist" aria-orientation="horizontal">
|
||||
<?php
|
||||
foreach ( $this->get_views() as $id => $link ) :
|
||||
if ( isset( $link['cap'] ) && ! current_user_can( $link['cap'] ) ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<a class="rank-math-tab<?php echo Param::get( 'view', $default_tab ) === sanitize_html_class( $id ) ? ' is-active' : ''; ?>" href="<?php echo esc_url( Helper::get_admin_url( $link['url'], $link['args'] ) ); ?>" title="<?php echo esc_attr( $link['title'] ); ?>"><?php echo esc_html( $link['title'] ); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Display view body.
|
||||
*
|
||||
* @param string $view Current view.
|
||||
*/
|
||||
public function display_body( $view ) {
|
||||
$hash = $this->get_views();
|
||||
$hash = new $hash[ $view ]['class']();
|
||||
$hash->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add subpage to Status & Tools screen.
|
||||
*
|
||||
* @param array $pages Pages.
|
||||
* @return array New pages.
|
||||
*/
|
||||
public function add_status_page( $pages ) {
|
||||
$pages['status'] = [
|
||||
'url' => 'status',
|
||||
'args' => 'view=status',
|
||||
'cap' => 'manage_options',
|
||||
'title' => __( 'System Status', 'rank-math' ),
|
||||
'class' => '\\RankMath\\Status\\System_Status',
|
||||
];
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dashbaord navigation links
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_views() {
|
||||
return $this->do_filter( 'tools/pages', [] );
|
||||
}
|
||||
}
|
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
/**
|
||||
* This class handles the content in Status & Tools > System Status.
|
||||
*
|
||||
* @since 1.0.33
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Status
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
*/
|
||||
|
||||
namespace RankMath\Status;
|
||||
|
||||
use RankMath\Helper;
|
||||
use RankMath\Google\Authentication;
|
||||
use RankMath\Admin\Admin_Helper;
|
||||
use RankMath\Google\Permissions;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* System_Status class.
|
||||
*/
|
||||
class System_Status {
|
||||
|
||||
/**
|
||||
* WP Info.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $wp_info = [];
|
||||
|
||||
/**
|
||||
* Display Database/Tables Details.
|
||||
*/
|
||||
public function display() {
|
||||
$this->prepare_info();
|
||||
|
||||
$this->display_system_info();
|
||||
( new Error_Log() )->display(); // phpcs:ignore
|
||||
}
|
||||
|
||||
/**
|
||||
* Display system details.
|
||||
*/
|
||||
private function display_system_info() {
|
||||
?>
|
||||
<div class="rank-math-system-status rank-math-box">
|
||||
<header>
|
||||
<h3><?php esc_html_e( 'System Info', 'rank-math' ); ?></h3>
|
||||
</header>
|
||||
|
||||
<div class="site-health-copy-buttons">
|
||||
<div class="copy-button-wrapper">
|
||||
<button type="button" class="button copy-button" data-clipboard-text="<?php echo esc_attr( \WP_Debug_Data::format( $this->wp_info, 'debug' ) ); ?>">
|
||||
<?php esc_html_e( 'Copy System Info to Clipboard', 'rank-math' ); ?>
|
||||
</button>
|
||||
<span class="success hidden" aria-hidden="true"><?php esc_html_e( 'Copied!', 'rank-math' ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="health-check-debug" class="health-check-accordion">
|
||||
<?php $this->display_system_info_list(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Display list for system info.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function display_system_info_list() {
|
||||
$directory = dirname( __FILE__ );
|
||||
foreach ( $this->wp_info as $section => $details ) {
|
||||
if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
include $directory . '/views/system-status-accordion.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display individual fields for the system info.
|
||||
*
|
||||
* @param array $fields Fields array.
|
||||
* @return void
|
||||
*/
|
||||
protected function display_system_info_fields( $fields ) {
|
||||
foreach ( $fields as $field_name => $field ) {
|
||||
$values = $this->system_info_value( $field_name, $field['value'] );
|
||||
printf( '<tr><td>%s</td><td>%s</td></tr>', esc_html( $field['label'] ), wp_kses_post( $values ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get individual values for the system info.
|
||||
*
|
||||
* @param string $field_name Field name.
|
||||
* @param mixed $field_value Field value.
|
||||
* @return string Output HTML.
|
||||
*/
|
||||
private function system_info_value( $field_name, $field_value ) {
|
||||
if ( is_array( $field_value ) ) {
|
||||
$values = '<ul>';
|
||||
foreach ( $field_value as $name => $value ) {
|
||||
$values .= sprintf( '<li>%s: %s</li>', esc_html( $name ), esc_html( $value ) );
|
||||
}
|
||||
$values .= '</ul>';
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
return esc_html( $field_value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Database information.
|
||||
*/
|
||||
private function prepare_info() {
|
||||
global $wpdb;
|
||||
|
||||
$plan = Admin_Helper::get_registration_data();
|
||||
$tokens = Authentication::tokens();
|
||||
$modules = Helper::get_active_modules();
|
||||
|
||||
$rankmath = [
|
||||
'label' => esc_html__( 'Rank Math', 'rank-math' ),
|
||||
'fields' => [
|
||||
'version' => [
|
||||
'label' => esc_html__( 'Version', 'rank-math' ),
|
||||
'value' => get_option( 'rank_math_version' ),
|
||||
],
|
||||
'database_version' => [
|
||||
'label' => esc_html__( 'Database version', 'rank-math' ),
|
||||
'value' => get_option( 'rank_math_db_version' ),
|
||||
],
|
||||
'plugin_plan' => [
|
||||
'label' => esc_html__( 'Plugin subscription plan', 'rank-math' ),
|
||||
'value' => isset( $plan['plan'] ) ? \ucwords( $plan['plan'] ) : esc_html__( 'Free', 'rank-math' ),
|
||||
],
|
||||
'active_modules' => [
|
||||
'label' => esc_html__( 'Active modules', 'rank-math' ),
|
||||
'value' => empty( $modules ) ? esc_html__( '(none)', 'rank-math' ) : join( ', ', $modules ),
|
||||
],
|
||||
'refresh_token' => [
|
||||
'label' => esc_html__( 'Google Refresh token', 'rank-math' ),
|
||||
'value' => empty( $tokens['refresh_token'] ) ? esc_html__( 'No token', 'rank-math' ) : esc_html__( 'Token exists', 'rank-math' ),
|
||||
],
|
||||
'permissions' => [
|
||||
'label' => esc_html__( 'Google Permission', 'rank-math' ),
|
||||
'value' => Permissions::get_status(),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$database_tables = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT
|
||||
table_name AS 'name'
|
||||
FROM information_schema.TABLES
|
||||
WHERE table_schema = %s
|
||||
AND table_name LIKE %s
|
||||
ORDER BY name ASC;",
|
||||
DB_NAME,
|
||||
'%rank\\_math%'
|
||||
)
|
||||
);
|
||||
|
||||
$tables = [];
|
||||
foreach ( $database_tables as $table ) {
|
||||
$name = \str_replace( $wpdb->prefix, '', $table->name );
|
||||
$tables[ $name ] = true;
|
||||
}
|
||||
|
||||
$should_exist = [
|
||||
'rank_math_404_logs' => esc_html__( 'Database Table: 404 Log', 'rank-math' ),
|
||||
'rank_math_redirections' => esc_html__( 'Database Table: Redirection', 'rank-math' ),
|
||||
'rank_math_redirections_cache' => esc_html__( 'Database Table: Redirection Cache', 'rank-math' ),
|
||||
'rank_math_internal_links' => esc_html__( 'Database Table: Internal Link', 'rank-math' ),
|
||||
'rank_math_internal_meta' => esc_html__( 'Database Table: Internal Link Meta', 'rank-math' ),
|
||||
'rank_math_analytics_gsc' => esc_html__( 'Database Table: Google Search Console', 'rank-math' ),
|
||||
'rank_math_analytics_objects' => esc_html__( 'Database Table: Flat Posts', 'rank-math' ),
|
||||
'rank_math_analytics_ga' => esc_html__( 'Database Table: Google Analytics', 'rank-math' ),
|
||||
'rank_math_analytics_adsense' => esc_html__( 'Database Table: Google AdSense', 'rank-math' ),
|
||||
'rank_math_analytics_keyword_manager' => esc_html__( 'Database Table: Keyword Manager', 'rank-math' ),
|
||||
'rank_math_analytics_inspections' => esc_html__( 'Database Table: Inspections', 'rank-math' ),
|
||||
];
|
||||
|
||||
if ( ! defined( 'RANK_MATH_PRO_FILE' ) ) {
|
||||
unset(
|
||||
$should_exist['rank_math_analytics_ga'],
|
||||
$should_exist['rank_math_analytics_adsense'],
|
||||
$should_exist['rank_math_analytics_keyword_manager']
|
||||
);
|
||||
}
|
||||
|
||||
foreach ( $should_exist as $name => $label ) {
|
||||
$rankmath['fields'][ $name ] = [
|
||||
'label' => $label,
|
||||
'value' => isset( $tables[ $name ] ) ? $this->get_table_size( $name ) : esc_html__( 'Not found', 'rank-math' ),
|
||||
];
|
||||
}
|
||||
|
||||
// Core debug data.
|
||||
if ( ! class_exists( 'WP_Debug_Data' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-debug-data.php';
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'site-health' );
|
||||
wp_enqueue_script( 'site-health' );
|
||||
|
||||
$rankmath_data = apply_filters( 'rank_math/status/rank_math_info', $rankmath );
|
||||
$core_data = \WP_Debug_Data::debug_data();
|
||||
|
||||
// Keep only relevant data.
|
||||
$core_data = array_intersect_key(
|
||||
$core_data,
|
||||
array_flip(
|
||||
[
|
||||
'wp-core',
|
||||
'wp-dropins',
|
||||
'wp-active-theme',
|
||||
'wp-parent-theme',
|
||||
'wp-mu-plugins',
|
||||
'wp-plugins-active',
|
||||
'wp-server',
|
||||
'wp-database',
|
||||
'wp-constants',
|
||||
'wp-filesystem',
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
$this->wp_info = [ 'rank-math' => $rankmath_data ] + $core_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Table size.
|
||||
*
|
||||
* @param string $table Table name.
|
||||
*
|
||||
* @return int Table size.
|
||||
*/
|
||||
public function get_table_size( $table ) {
|
||||
global $wpdb;
|
||||
$size = (int) $wpdb->get_var( "SELECT SUM((data_length + index_length)) AS size FROM information_schema.TABLES WHERE table_schema='" . $wpdb->dbname . "' AND (table_name='" . $wpdb->prefix . $table . "')" ); // phpcs:ignore
|
||||
return size_format( $size );
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden.
|
@@ -0,0 +1 @@
|
||||
<?php // Silence is golden.
|
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Status & Tools main view file.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Status
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
* @license GPL-2.0+
|
||||
* @link https://rankmath.com/wordpress/plugin/seo-suite/
|
||||
* @copyright 2019 Rank Math
|
||||
*/
|
||||
|
||||
use RankMath\Helper;
|
||||
use RankMath\Helpers\Param;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
$default_tab = apply_filters( 'rank_math/tools/default_tab', 'status' );
|
||||
$module = Helper::get_module( 'status' );
|
||||
$current = Param::get( 'view', $default_tab );
|
||||
|
||||
if ( ! in_array( $current, array_keys( apply_filters( 'rank_math/tools/pages', [] ) ), true ) ) {
|
||||
Helper::redirect( Helper::get_admin_url( 'status' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// Header.
|
||||
rank_math()->admin->display_admin_header();
|
||||
?>
|
||||
<div class="wrap rank-math-wrap rank-math-tools-wrap dashboard">
|
||||
|
||||
<span class='wp-header-end'></span>
|
||||
|
||||
<?php $module->display_nav(); ?>
|
||||
|
||||
<div class="rank-math-ui dashboard-wrapper container <?php echo esc_attr( $current ); ?>">
|
||||
<?php $module->display_body( $current ); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* System Status - debug data accordion section.
|
||||
*
|
||||
* @package RankMath
|
||||
* @subpackage RankMath\Status
|
||||
* @author Rank Math <support@rankmath.com>
|
||||
* @license GPL-2.0+
|
||||
* @link https://rankmath.com/wordpress/plugin/seo-suite/
|
||||
* @copyright 2019 Rank Math
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
?>
|
||||
<h3 class="health-check-accordion-heading">
|
||||
<button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
|
||||
<span class="title">
|
||||
<?php echo esc_html( $details['label'] ); ?>
|
||||
<?php
|
||||
|
||||
if ( isset( $details['show_count'] ) && $details['show_count'] ) {
|
||||
printf( '(%d)', count( $details['fields'] ) );
|
||||
}
|
||||
|
||||
?>
|
||||
</span>
|
||||
<span class="icon"></span>
|
||||
</button>
|
||||
</h3>
|
||||
|
||||
<div id="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" class="health-check-accordion-panel" hidden="hidden">
|
||||
<?php
|
||||
|
||||
if ( isset( $details['description'] ) && ! empty( $details['description'] ) ) {
|
||||
printf( '<p>%s</p>', esc_html( $details['description'] ) );
|
||||
}
|
||||
|
||||
?>
|
||||
<table class="widefat striped health-check-table" role="presentation">
|
||||
<tbody>
|
||||
<?php $this->display_system_info_fields( $details['fields'] ); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
Reference in New Issue
Block a user