PluginProbe
Plugin Check (PCP) / 1.3.1
Plugin Check (PCP) v1.3.1
2.1.0 trunk 0.1 0.2.0 0.2.1 0.2.2 0.2.3 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 ci-artifacts
plugin-check / plugin.php

plugin.php in Plugin Check (PCP) 1.3.1, at plugin.php

83 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Plugin Check (PCP)
4 * Plugin URI: https://github.com/WordPress/plugin-check
5 * Description: Plugin Check is a WordPress.org tool which provides checks to help plugins meet the directory requirements and follow various best practices.
6 * Requires at least: 6.3
7 * Requires PHP: 7.4
8 * Version: 1.3.1
9 * Author: WordPress Performance Team and Plugin Review Team
10 * License: GPLv2 or later
11 * License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
12 * Text Domain: plugin-check
13 *
14 * @package plugin-check
15 */
16
17 use WordPress\Plugin_Check\Plugin_Main;
18
19 define( 'WP_PLUGIN_CHECK_VERSION', '1.3.1' );
20 define( 'WP_PLUGIN_CHECK_MINIMUM_PHP', '7.4' );
21 define( 'WP_PLUGIN_CHECK_MAIN_FILE', __FILE__ );
22 define( 'WP_PLUGIN_CHECK_PLUGIN_DIR_PATH', plugin_dir_path( WP_PLUGIN_CHECK_MAIN_FILE ) );
23 define( 'WP_PLUGIN_CHECK_PLUGIN_DIR_URL', plugin_dir_url( WP_PLUGIN_CHECK_MAIN_FILE ) );
24
25 /**
26 * Checks basic requirements and loads the plugin.
27 *
28 * @since 1.0.0
29 */
30 function wp_plugin_check_load() {
31 // Check for supported PHP version.
32 if ( version_compare( phpversion(), WP_PLUGIN_CHECK_MINIMUM_PHP, '<' ) ) {
33 add_action( 'admin_notices', 'wp_plugin_check_display_php_version_notice' );
34 return;
35 }
36
37 // Check Composer autoloader exists.
38 if ( ! file_exists( WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'vendor/autoload.php' ) ) {
39 add_action( 'admin_notices', 'wp_plugin_check_display_composer_autoload_notice' );
40 return;
41 }
42
43 // Load the Composer autoloader.
44 require_once WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'vendor/autoload.php';
45
46 // Setup the plugin.
47 $instance = new Plugin_Main( WP_PLUGIN_CHECK_MAIN_FILE );
48 $instance->add_hooks();
49 }
50
51 /**
52 * Displays admin notice about unmet PHP version requirement.
53 *
54 * @since 1.0.0
55 */
56 function wp_plugin_check_display_php_version_notice() {
57 echo '<div class="notice notice-error"><p>';
58 printf(
59 /* translators: 1: required version, 2: currently used version */
60 esc_html__( 'Plugin Check requires at least PHP version %1$s. Your site is currently running on PHP %2$s.', 'plugin-check' ),
61 esc_html( WP_PLUGIN_CHECK_MINIMUM_PHP ),
62 esc_html( phpversion() )
63 );
64 echo '</p></div>';
65 }
66
67 /**
68 * Displays admin notice about missing Composer autoload files.
69 *
70 * @since 1.0.0
71 */
72 function wp_plugin_check_display_composer_autoload_notice() {
73 echo '<div class="notice notice-error"><p>';
74 printf(
75 /* translators: composer command. */
76 esc_html__( 'Your installation of the Plugin Check plugin is incomplete. Please run %s.', 'plugin-check' ),
77 '<code>composer install</code>'
78 );
79 echo '</p></div>';
80 }
81
82 wp_plugin_check_load();
83