Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ dist
.phpunit.result.cache

# Exclude coverage reports
coverage/
coverage/
4 changes: 2 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.32.0
* Version: 1.33.0
* Requires PHP: 7.4
* Author: Equalize Digital
* Author URI: https://equalizedigital.com
Expand All @@ -36,7 +36,7 @@

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

// Current database version.
Expand Down
8 changes: 8 additions & 0 deletions includes/classes/WPCLI/BootstrapCLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ public function register() {
$command,
$command::get_args()
);
// For ease of typing on cli there's a shortname too in some commands.
if ( method_exists( $command, 'get_shortname' ) ) {
$this->wp_cli::add_command(
$command::get_shortname(),
$command,
$command::get_args()
);
}
Comment thread
pattonwebz marked this conversation as resolved.
} catch ( Exception $e ) {
$this->wp_cli::warning(
sprintf(
Expand Down
49 changes: 30 additions & 19 deletions includes/classes/WPCLI/Command/CleanupOrphanedIssues.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CleanupOrphanedIssues implements CLICommandInterface {
* @param mixed|WP_CLI $wp_cli The WP-CLI instance.
*/
public function __construct( $wp_cli = null ) {
$this->wp_cli = $wp_cli ?? new WP_CLI();
$this->wp_cli = $wp_cli ?? new WP_CLI();
}

/**
Expand All @@ -43,7 +43,18 @@ public function __construct( $wp_cli = null ) {
* @return string
*/
public static function get_name(): string {
return 'accessibility-checker cleanup-orphaned-issues';
return 'accessibility-checker cleanup-orphaned-issues';
}

/**
* Get the short name of the command.
*
* @since 1.33.0
*
* @return string
*/
public static function get_shortname(): string {
return 'edac cleanup-orphaned-issues';
}

/**
Expand All @@ -54,24 +65,24 @@ public static function get_name(): string {
* @return array
*/
public static function get_args(): array {
return [
'synopsis' => [
[
'type' => 'assoc',
'name' => 'batch',
'description' => __( 'Number of orphaned posts to process in one batch.', 'accessibility-checker' ),
'optional' => true,
'default' => null,
],
[
'type' => 'assoc',
'name' => 'sleep',
'description' => __( 'Seconds to sleep between deletions (default: 0).', 'accessibility-checker' ),
'optional' => true,
'default' => 0,
],
return [
'synopsis' => [
[
'type' => 'assoc',
'name' => 'batch',
'description' => __( 'Number of orphaned posts to process in one batch.', 'accessibility-checker' ),
'optional' => true,
'default' => null,
],
[
'type' => 'assoc',
'name' => 'sleep',
'description' => __( 'Seconds to sleep between deletions (default: 0).', 'accessibility-checker' ),
'optional' => true,
'default' => 0,
],
];
],
];
}

/**
Expand Down
11 changes: 11 additions & 0 deletions includes/classes/WPCLI/Command/DeleteStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ public static function get_name(): string {
return 'accessibility-checker delete-stats';
}

/**
* Get the short name of the command.
*
* @since 1.33.0
*
* @return string
*/
public static function get_shortname(): string {
return 'edac delete-stats';
}

/**
* Get the arguments for the command
*
Expand Down
11 changes: 11 additions & 0 deletions includes/classes/WPCLI/Command/GetSiteStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ public static function get_name(): string {
return 'accessibility-checker get-site-stats';
}

/**
* Get the short name of the command.
*
* @since 1.33.0
*
* @return string
*/
public static function get_shortname(): string {
return 'edac get-site-stats';
}

/**
* Get the arguments for the command
*
Expand Down
11 changes: 11 additions & 0 deletions includes/classes/WPCLI/Command/GetStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ public static function get_name(): string {
return 'accessibility-checker get-stats';
}

/**
* Get the short name of the command.
*
* @since 1.33.0
*
* @return string
*/
public static function get_shortname(): string {
return 'edac get-stats';
}

/**
* Get the arguments for the command
*
Expand Down
9 changes: 7 additions & 2 deletions includes/classes/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ public function __construct() {

// When WP CLI is enabled, load the CLI commands.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
$cli = new BootstrapCLI();
$cli->register();
add_action(
'init',
function () {
$cli = new BootstrapCLI();
$cli->register();
}
);
}
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "accessibility-checker",
"version": "1.32.0",
"version": "1.33.0",
"description": "Audit and check your website for accessibility before you hit publish. In-post accessibility scanner and guidance.",
"author": "Equalize Digital",
"license": "GPL-2.0+",
Expand Down
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
Requires at least: 6.6
Tested up to: 6.8
Stable tag: 1.32.0
Stable tag: 1.33.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -210,6 +210,9 @@ You can report security bugs through the Patchstack Vulnerability Disclosure Pro
10. Accessibility Checker automated fix settings.

== Changelog ==
= 1.33.0 =
* Added: WP-CLI commands can now be run with short names: `wp edac <command>` or using long name `wp accessibility-checker <command>`.
* Improved: Made it easier to register custom commands through filter.

= 1.32.0 =
* Fixed: Improved highlighter behavior to maintain original size and position of scanned elements.
Expand Down
115 changes: 115 additions & 0 deletions scripts/prep_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,121 @@ sed -i.bak -E "s/( \* Version:[[:space:]]*)[0-9]+\.[0-9]+\.[0-9]+/\1${BUMPED_VER
sed -i.bak -E "s/(define\( 'EDAC_VERSION', ')[0-9]+\.[0-9]+\.[0-9]+/\1${BUMPED_VERSION}/" "${MAIN_FILE_PATH}"
sed -i.bak -E "s/(\"version\": \")[0-9]+\.[0-9]+\.[0-9]+/\1${BUMPED_VERSION}/" package.json
sed -i.bak -E "s/(Stable tag: )[0-9]+\.[0-9]+\.[0-9]+/\1${BUMPED_VERSION}/" readme.txt

echo
echo "Updating WordPress version requirements"
echo

# Function to fetch WordPress versions and calculate required version
update_wp_requires_version() {
echo "Fetching WordPress version list..."

# Get current "Tested up to" version from readme.txt
local tested_up_to=$(grep "Tested up to:" "${README_PATH}" | sed -E 's/Tested up to: ([0-9]+\.[0-9]+).*/\1/')

if [[ -z "${tested_up_to}" ]]; then
echo "Error: Could not extract 'Tested up to' version from readme.txt" >&2
return 1
fi

echo "Current 'Tested up to': ${tested_up_to}"

# Try to fetch WordPress versions from the API first
local wp_versions_json=$(curl -s --max-time 10 "https://api.wordpress.org/core/version-check/1.7/" 2>/dev/null || echo "")

if [[ -n "${wp_versions_json}" ]]; then
echo "Using WordPress API for version data..."
# Parse JSON response to get version list in reverse chronological order
# Extract major.minor versions from major.minor.patch format
local versions_list=$(echo "${wp_versions_json}" | \
grep -o '"version":"[0-9]*\.[0-9]*\.[0-9]*"' | \
sed 's/"version":"\([0-9]*\.[0-9]*\)\.[0-9]*"/\1/' | \
sort -rV | \
uniq)
Comment thread
pattonwebz marked this conversation as resolved.
else
echo "API unavailable, trying to parse releases page..."
# Fallback: try to parse the releases page
local releases_html=$(curl -s --max-time 15 "https://wordpress.org/download/releases/" 2>/dev/null || echo "")

if [[ -n "${releases_html}" ]]; then
# Extract version numbers from the releases page
# Look for patterns like "WordPress 6.8" or "wordpress-6.7.zip"
local versions_list=$(echo "${releases_html}" | \
grep -oE '(WordPress [0-9]+\.[0-9]+|wordpress-[0-9]+\.[0-9]+)' | \
sed -E 's/(WordPress |wordpress-)([0-9]+\.[0-9]+)/\2/' | \
sort -rV | \
uniq)
else
echo "Error: Could not fetch WordPress version data from any source" >&2
return 1
fi
fi

if [[ -z "${versions_list}" ]]; then
echo "Error: No WordPress versions found in response" >&2
return 1
fi

echo "Found WordPress versions (latest first):"
echo "${versions_list}" | head -10

# Find the current tested version in the list and go back 2 versions (to support last 3 versions)
local found_current=false
local version_count=0
local target_version=""

while IFS= read -r version; do
if [[ "${found_current}" == true ]]; then
Comment thread
pattonwebz marked this conversation as resolved.
version_count=$((version_count + 1))
if [[ ${version_count} -eq 2 ]]; then
target_version="${version}"
break
fi
elif [[ "${version}" == "${tested_up_to}" ]]; then
found_current=true
echo "Found current tested version ${tested_up_to} in version list"
fi
done <<< "${versions_list}"

if [[ "${found_current}" == false ]]; then
echo "Warning: Current 'Tested up to' version ${tested_up_to} not found in WordPress version list" >&2
echo "Available versions: $(echo "${versions_list}" | tr '\n' ' ')" >&2
return 1
fi

if [[ -z "${target_version}" ]]; then
echo "Warning: Could not find version 2 releases back from ${tested_up_to}" >&2
# Try to use the oldest version we found if we don't have enough history
target_version=$(echo "${versions_list}" | tail -1)
if [[ -n "${target_version}" ]]; then
echo "Using oldest available version: ${target_version}"
else
return 1
fi
fi

# Ensure we don't go below WordPress 5.0 (reasonable minimum)
local min_major=$(echo "${target_version}" | cut -d. -f1)
if [[ ${min_major} -lt 5 ]]; then
target_version="5.0"
echo "Adjusted to minimum supported version: ${target_version}"
fi

echo "Setting 'Requires at least' to: ${target_version} (2 versions back from ${tested_up_to} to support last 3 versions)"

# Update the readme.txt file
sed -i.bak -E "s/(Requires at least: )[0-9]+\.[0-9]+/\1${target_version}/" "${README_PATH}"

return 0
}

# Update WordPress version requirements
if update_wp_requires_version; then
echo "Successfully updated WordPress version requirements"
else
echo "Warning: Could not update WordPress version requirements, keeping current values"
fi

rm "${MAIN_FILE_PATH}.bak" "${PACKAGE_JSON_PATH}.bak" "${README_PATH}.bak"

echo
Expand Down
Loading