Skip to content

Commit 9141eba

Browse files
author
Felix Arntz
committed
Use global constants instead of class constants for PHP 5.2 compatibility.
1 parent bd15b48 commit 9141eba

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

wpengine-phpcompat.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@
1212
// Exit if this file is directly accessed
1313
if ( ! defined( 'ABSPATH' ) ) { exit; }
1414

15+
define( 'WPEPHPCOMPAT_CAPABILITY', 'manage_options' );
16+
define( 'WPEPHPCOMPAT_ADMIN_PAGE_SLUG', 'php-compatibility-checker' );
17+
1518
require_once dirname( __FILE__ ) . '/load-files.php';
1619

1720
/**
1821
* This handles hooking into WordPress.
1922
*/
2023
class WPEngine_PHPCompat {
2124

22-
/* Capability required to run the scanner and access the admin page */
23-
const CAPABILITY = 'manage_options';
24-
25-
/* Slug for the admin page */
26-
const ADMIN_PAGE_SLUG = 'php-compatibility-checker';
27-
2825
/* Define and register singleton */
2926
private static $instance = false;
3027

@@ -113,7 +110,7 @@ function get_phpversions() {
113110
* @return null
114111
*/
115112
function start_test() {
116-
if ( current_user_can( self::CAPABILITY ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
113+
if ( current_user_can( WPEPHPCOMPAT_CAPABILITY ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
117114
global $wpdb;
118115

119116
$wpephpc = new WPEPHPCompat( dirname( __FILE__ ) );
@@ -157,7 +154,7 @@ function start_test() {
157154
* @return null
158155
*/
159156
function check_status() {
160-
if ( current_user_can( self::CAPABILITY ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
157+
if ( current_user_can( WPEPHPCOMPAT_CAPABILITY ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
161158
$scan_status = get_option( 'wpephpcompat.status' );
162159
$count_jobs = wp_count_posts( 'wpephpcompat_jobs' );
163160
$total_jobs = get_option( 'wpephpcompat.numdirs' );
@@ -243,7 +240,7 @@ function fork_scan( $test_version, $only_active ) {
243240
* @action wp_ajax_wpephpcompat_clean_up
244241
*/
245242
function clean_up() {
246-
if ( current_user_can( self::CAPABILITY ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
243+
if ( current_user_can( WPEPHPCOMPAT_CAPABILITY ) || ( defined( 'DOING_CRON' ) && DOING_CRON ) ) {
247244
$wpephpc = new WPEPHPCompat( dirname( __FILE__ ) );
248245
$wpephpc->clean_after_scan();
249246
delete_option( 'wpephpcompat.scan_results' );
@@ -320,7 +317,7 @@ function admin_enqueue( $hook ) {
320317
*/
321318
function create_menu() {
322319
// Create Tools sub-menu.
323-
$this->page = add_submenu_page( 'tools.php', __( 'PHP Compatibility', 'php-compatibility-checker' ), __( 'PHP Compatibility', 'php-compatibility-checker' ), self::CAPABILITY, self::ADMIN_PAGE_SLUG, array( self::instance(), 'settings_page' ) );
320+
$this->page = add_submenu_page( 'tools.php', __( 'PHP Compatibility', 'php-compatibility-checker' ), __( 'PHP Compatibility', 'php-compatibility-checker' ), WPEPHPCOMPAT_CAPABILITY, WPEPHPCOMPAT_ADMIN_PAGE_SLUG, array( self::instance(), 'settings_page' ) );
324321
}
325322

326323
/**
@@ -503,11 +500,11 @@ function maybe_show_activation_notice() {
503500

504501
delete_option( 'wpephpcompat.show_notice' );
505502

506-
if ( ! current_user_can( self::CAPABILITY ) ) {
503+
if ( ! current_user_can( WPEPHPCOMPAT_CAPABILITY ) ) {
507504
return;
508505
}
509506

510-
$url = add_query_arg( 'page', self::ADMIN_PAGE_SLUG, admin_url( 'tools.php' ) );
507+
$url = add_query_arg( 'page', WPEPHPCOMPAT_ADMIN_PAGE_SLUG, admin_url( 'tools.php' ) );
511508

512509
?>
513510
<div class="notice updated is-dismissible">
@@ -533,8 +530,8 @@ function maybe_show_activation_notice() {
533530
* @return array Modified plugin action links.
534531
*/
535532
function filter_plugin_links( $links ) {
536-
if ( current_user_can( self::CAPABILITY ) ) {
537-
$url = add_query_arg( 'page', self::ADMIN_PAGE_SLUG, admin_url( 'tools.php' ) );
533+
if ( current_user_can( WPEPHPCOMPAT_CAPABILITY ) ) {
534+
$url = add_query_arg( 'page', WPEPHPCOMPAT_ADMIN_PAGE_SLUG, admin_url( 'tools.php' ) );
538535

539536
array_unshift( $links, '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Start Scan', 'php-compatibility-checker' ) . '</a>' );
540537
}

0 commit comments

Comments
 (0)