Skip to content

Commit

Permalink
Merge pull request #552 from equalizedigital/release/1.10.1
Browse files Browse the repository at this point in the history
Release/v1.10.1
  • Loading branch information
pattonwebz authored Mar 27, 2024
2 parents 869b61d + 37915b9 commit 79d72c3
Show file tree
Hide file tree
Showing 29 changed files with 721 additions and 166 deletions.
6 changes: 2 additions & 4 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.10.0
* Version: 1.10.1
* Author: Equalize Digital
* Author URI: https://equalizedigital.com
* License: GPL-2.0+
Expand Down Expand Up @@ -41,7 +41,7 @@

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

// Current database version.
Expand Down Expand Up @@ -123,13 +123,11 @@
require_once plugin_dir_path( __FILE__ ) . 'includes/activation.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/deactivation.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/helper-functions.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/meta-boxes.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/options-page.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/validate.php';
/**
* Filters and Actions
*/
add_action( 'add_meta_boxes', 'edac_register_meta_boxes' );
add_action( 'admin_menu', 'edac_add_options_page' );
add_action( 'admin_init', 'edac_register_setting' );
add_action( 'admin_head', 'edac_post_on_load' );
Expand Down
22 changes: 18 additions & 4 deletions admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,29 @@
class Admin {

/**
* Class constructor.
* Meta boxes instance.
*
* @since 1.10.0
*
* @var Meta_Boxes
*/
public function __construct() {
private Meta_Boxes $meta_boxes;

/**
* Class constructor for injecting dependencies.
*
* @param Meta_Boxes|null $meta_boxes Meta boxes instance.
*/
public function __construct( Meta_Boxes $meta_boxes = null ) {
$this->meta_boxes = $meta_boxes;
}

/**
* Initialize.
*
* @return void
*/
public function init() {
public function init(): void {

$update_database = new Update_Database();
$update_database->init_hooks();
Expand All @@ -44,14 +56,16 @@ public function init() {
$site_health_info->init_hooks();

$this->init_ajax();

$this->meta_boxes->init_hooks();
}

/**
* Initialize ajax.
*
* @return void
*/
private function init_ajax() {
private function init_ajax(): void {
if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
return;
}
Expand Down
44 changes: 27 additions & 17 deletions admin/class-enqueue-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public static function enqueue() {
*/
public static function enqueue_styles() {
wp_enqueue_style( 'edac', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/admin.css', array(), EDAC_VERSION, 'all' );
}
}

/**
* Enqueue the admin and editorApp scripts.
*
Expand All @@ -57,13 +57,23 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
'accessibility_checker_ignored',
);

if ( is_array( $post_types ) && count( $post_types ) && ( in_array( $current_post_type, $post_types, true ) || in_array( $page, $enabled_pages, true ) ) || ( 'site-editor.php' !== $pagenow ) ) {
if (
(
is_array( $post_types ) &&
count( $post_types ) &&
(
in_array( $current_post_type, $post_types, true ) ||
in_array( $page, $enabled_pages, true )
)
) ||
'site-editor.php' !== $pagenow
) {

global $post;
$post_id = is_object( $post ) ? $post->ID : null;
wp_enqueue_script( 'edac', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/admin.bundle.js', array( 'jquery' ), EDAC_VERSION, false );


wp_localize_script(
'edac',
'edac_script_vars',
Expand All @@ -74,26 +84,26 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
'restNonce' => wp_create_nonce( 'wp_rest' ),
)
);


if ( 'post.php' === $pagenow ) {


// Is this posttype setup to be checked?
$post_types = get_option( 'edac_post_types' );
$current_post_type = get_post_type();
$active = ( is_array( $post_types ) && in_array( $current_post_type, $post_types, true ) );

$pro = is_plugin_active( 'accessibility-checker-pro/accessibility-checker-pro.php' ) && EDAC_KEY_VALID;

if ( EDAC_DEBUG || strpos( EDAC_VERSION, '-beta' ) !== false ) {
$debug = true;
} else {
$debug = false;
}

wp_enqueue_script( 'edac-editor-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/editorApp.bundle.js', false, EDAC_VERSION, false );

wp_localize_script(
'edac-editor-app',
'edac_editor_app',
Expand All @@ -107,13 +117,13 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
'authOk' => false === (bool) get_option( 'edac_password_protected', false ),
'debug' => $debug,
'scanUrl' => get_preview_post_link(
$post_id,
$post_id,
array( 'edac_pageScanner' => 1 )
),
)
);
}

}
}
}

Expand All @@ -125,13 +135,13 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
public static function maybe_enqueue_email_opt_in_script() {

$page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display only.
if ( 'accessibility_checker' === $page
&& true !== (bool) get_user_meta( get_current_user_id(), 'edac_email_optin', true )
if ( 'accessibility_checker' === $page
&& true !== (bool) get_user_meta( get_current_user_id(), 'edac_email_optin', true )
) {

wp_enqueue_style( 'email-opt-in-form', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/emailOptIn.css', false, EDAC_VERSION, 'all' );
wp_enqueue_script( 'email-opt-in-form', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/emailOptIn.bundle.js', false, EDAC_VERSION, true );

wp_localize_script(
'email-opt-in-form',
'edac_email_opt_in_form',
Expand All @@ -140,7 +150,7 @@ public static function maybe_enqueue_email_opt_in_script() {
'ajaxurl' => admin_url( 'admin-ajax.php' ),
)
);

}
}
}
61 changes: 61 additions & 0 deletions admin/class-meta-boxes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* Class for handling the editor meta box.
*
* @package Accessibility_Checker
*/

namespace EDAC\Admin;

/**
* Class Meta_Box
*
* Handles the editor meta box registration and rendering.
*/
class Meta_Boxes {

/**
* Initialize the hooks for the editor meta box.
*
* @return void
*/
public function init_hooks(): void {
add_action( 'add_meta_boxes', array( $this, 'register_meta_boxes' ) );
}

/**
* Register custom meta boxes for each post type.
*
* @since 1.10.0
*
* @return void
*/
public function register_meta_boxes(): void {
$post_types = get_option( 'edac_post_types' );
if ( $post_types ) {
foreach ( $post_types as $post_type ) {
add_meta_box(
'edac-meta-box',
__( 'Accessibility Checker', 'accessibility-checker' ),
array( $this, 'render' ),
$post_type,
'normal',
'high'
);
}
}
}

/**
* Render the custom meta box html.
*
* @since 1.10.0
*
* @return void
*/
public function render(): void {
do_action( 'edac_before_meta_box' );
include_once plugin_dir_path( __DIR__ ) . 'partials/custom-meta-box.php';
do_action( 'edac_after_meta_box' );
}
}
19 changes: 12 additions & 7 deletions includes/classes/class-enqueue-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,25 @@ public function __construct() {
public static function enqueue() {
self::maybe_enqueue_frontend_highlighter();
}

/**
* Enqueue the frontend highlighter.
*
* @return void
*/
public static function maybe_enqueue_frontend_highlighter() {

// This loads on all pages, so bail as early as possible. Do checks that don't require DB calls first.


// Don't load on admin pages in iframe that is running a pageScan.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( is_admin() || isset( $_GET['edac_pageScanner'] ) && '1' === $_GET['edac_pageScanner'] ) {
if (
is_admin() ||
(
isset( $_GET['edac_pageScanner'] ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
'1' === $_GET['edac_pageScanner'] // phpcs:ignore WordPress.Security.NonceVerification.Recommended
)
) {
return;
}

Expand All @@ -55,17 +60,17 @@ public static function maybe_enqueue_frontend_highlighter() {
if ( is_customize_preview() || ! ( $post_id && current_user_can( 'edit_post', $post_id ) ) ) {
return;
}


// Don't load if this pagetype is not setup to be scanned.
$post_types = get_option( 'edac_post_types' );
$current_post_type = get_post_type();
$active = ( is_array( $post_types ) && in_array( $current_post_type, $post_types, true ) );


if ( $active ) {


wp_enqueue_style( 'edac-frontend-highlighter-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/frontendHighlighterApp.css', false, EDAC_VERSION, 'all' );
wp_enqueue_script( 'edac-frontend-highlighter-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/frontendHighlighterApp.bundle.js', false, EDAC_VERSION, false );

Expand Down
8 changes: 5 additions & 3 deletions includes/classes/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace EDAC\Inc;

use EDAC\Admin\Admin;
use EDAC\Admin\Meta_Boxes;

/**
* Main plugin functionality class.
Expand All @@ -19,7 +20,8 @@ class Plugin {
*/
public function __construct() {
if ( \is_admin() ) {
$admin = new Admin();
$meta_boxes = new Meta_Boxes();
$admin = new Admin( $meta_boxes );
$admin->init();
} else {
$this->init();
Expand All @@ -36,9 +38,9 @@ public function __construct() {
* @return void
*/
private function init() {

add_action( 'wp_enqueue_scripts', array( 'EDAC\Inc\Enqueue_Frontend', 'enqueue' ) );

$accessibility_statement = new Accessibility_Statement();
$accessibility_statement->init_hooks();

Expand Down
Loading

0 comments on commit 79d72c3

Please sign in to comment.