Skip to content

Commit

Permalink
Added: check for WordPress Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveJonesDev committed Oct 6, 2023
1 parent 3e7eb71 commit 86a941c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: equalizedigital, alh0319, stevejonesdev
Tags: accessibility, accessible, wcag, ada, WP accessibility, section 508, aoda, a11y, audit, readability, content analysis
Requires at least: 5.0.0
Tested up to: 6.3.1
Stable tag: 1.6.1
Stable tag: 1.6.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -171,6 +171,9 @@ No, Accessibility Checker runs completely on your server and does not require yo

== Changelog ==

= 1.6.2 =
Added: check for WordPress Playground

= 1.6.1 =
Updated: passed percentage calculation
Updated: frontend highlighting disable styles to be compatible with optimization plugins
Expand Down
11 changes: 9 additions & 2 deletions accessibility-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Accessibility Checker
* Plugin URI: https://a11ychecker.com
* Description: Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.
* Version: 1.6.1
* Version: 1.6.2
* Author: Equalize Digital
* Author URI: https://equalizedigital.com
* License: GPL-2.0+
Expand All @@ -24,6 +24,13 @@
die;
}

// Check for WordPress Playground.
require_once plugin_dir_path( __FILE__ ) . 'includes/classes/class-playground-check.php';
$plugin_check = new EDAC\Playground_Check();
if ( ! $plugin_check->should_load ) {
return;
}

// Include plugin dependency.
require_once ABSPATH . 'wp-admin/includes/plugin.php';

Expand All @@ -38,7 +45,7 @@

// Current plugin version.
if ( ! defined( 'EDAC_VERSION' ) ) {
define( 'EDAC_VERSION', '1.6.1' );
define( 'EDAC_VERSION', '1.6.2' );
}

// Current database version.
Expand Down
46 changes: 46 additions & 0 deletions includes/classes/class-playground-check.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Class file for Plugin Check
*
* @package Accessibility_Checker
*/

namespace EDAC;

class Playground_Check {

public $should_load = true;

/**
* Initialize the class and set its properties.
*/
public function __construct() {
$this->check_site_url_and_maybe_exit();
}

/**
* Check the site's URL and set the should_load property accordingly.
*/
private function check_site_url_and_maybe_exit() {
$site_url = get_site_url();

if ( strpos( $site_url, 'playground.wordpress.net' ) !== false ) {
// This is the playground site, show an admin notice.
add_action( 'admin_notices', array( $this, 'show_playground_notice' ) );

// Set should_load to false.
$this->should_load = false;
}
}

/**
* Display an admin notice for the playground site.
*/
public function show_playground_notice() {
?>
<div class="notice notice-error">
<p><?php esc_html_e( 'Unable to load live preview. WordPress Playground is not compatible with the Accessibility Checker Plugin.', 'accessibility-checker' ); ?></p>
</div>
<?php
}
}

0 comments on commit 86a941c

Please sign in to comment.