PluginProbe
Theme Check / trunk
Theme Check vtrunk
trunk 20190208.1 20190801.1 20200612.1 20200731.1 20200922.1 20210617 20210921 20211203 20220929 20230412 20230417 20231220 20260821
theme-check / theme-check.php

theme-check.php in Theme Check trunk, at theme-check.php

79 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Theme Check
4 * Plugin URI: https://github.com/WordPress/theme-check/
5 * Description: A simple and easy way to test your theme for all the latest WordPress standards and practices. A great theme development tool!
6 * Author: Themes Team
7 * Version: 20260901
8 * Text Domain: theme-check
9 * License: GPLv2
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 */
12
13 class ThemeCheckMain {
14 function __construct() {
15 add_action( 'admin_init', array( $this, 'tc_i18n' ) );
16 add_action( 'admin_menu', array( $this, 'themecheck_add_page' ) );
17
18 if ( defined( 'WP_CLI' ) && WP_CLI ) {
19 include 'wp-cli/class-theme-check-cli.php';
20 }
21 }
22
23 function tc_i18n() {
24 load_plugin_textdomain( 'theme-check', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
25 }
26
27 function load_styles() {
28 wp_enqueue_style( 'style', plugins_url( 'assets/style.css', __FILE__ ), array(), '1', 'screen' );
29 }
30
31 function themecheck_add_page() {
32 $page = add_theme_page( 'Theme Check', 'Theme Check', 'manage_options', 'themecheck', array( $this, 'themecheck_do_page' ) );
33 add_action( 'admin_print_styles-' . $page, array( $this, 'load_styles' ) );
34 }
35
36 function tc_add_headers( $extra_headers ) {
37 $extra_headers = array( 'License', 'License URI', 'Template Version' );
38 return $extra_headers;
39 }
40
41 function themecheck_do_page() {
42 if ( ! current_user_can( 'manage_options' ) ) {
43 wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'theme-check' ) );
44 }
45
46 add_filter( 'extra_theme_headers', array( $this, 'tc_add_headers' ) );
47
48 include 'checkbase.php';
49 include 'main.php';
50
51 ?>
52 <div id="theme-check" class="wrap">
53 <h1><?php echo esc_html_x( 'Theme Check', 'title of the main page', 'theme-check' ); ?></h1>
54 <div class="theme-check">
55 <?php
56 tc_form();
57 if ( ! isset( $_POST['themename'] ) ) {
58 tc_intro();
59 }
60
61 if ( isset( $_POST['themename'] ) ) {
62 check_admin_referer( 'themecheck-nonce' );
63
64 if ( isset( $_POST['trac'] ) ) {
65 define( 'TC_TRAC', true );
66 }
67
68 wp_raise_memory_limit();
69
70 check_main( wp_unslash( $_POST['themename'] ) );
71 }
72 ?>
73 </div> <!-- .theme-check-->
74 </div>
75 <?php
76 }
77 }
78 new ThemeCheckMain();
79