*/ 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' ); ?>
get_views() as $id => $link ) : if ( isset( $link['cap'] ) && ! current_user_can( $link['cap'] ) ) { continue; } ?>
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', [] ); } }