From 1813d419e5bbe3c1e29538236ef085429b71f0f3 Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Tue, 16 Jun 2026 14:01:59 +0000 Subject: [PATCH] style: auto-fix PHPCS violations via phpcbf --- .../prautoblogger-deploy-receiver.php | 85 +++++++------ includes/core/class-keyword-extractor.php | 118 ++++++++++++++++-- .../providers/class-image-aspect-ratio.php | 42 +++++-- .../class-runware-image-validator.php | 1 - scripts/check-constants.php | 22 ++-- templates/admin/ideas-browser.php | 26 ++-- templates/admin/log-viewer.php | 39 ++++-- templates/admin/metabox-generation-info.php | 6 +- 8 files changed, 246 insertions(+), 93 deletions(-) diff --git a/.github/mu-plugins/prautoblogger-deploy-receiver.php b/.github/mu-plugins/prautoblogger-deploy-receiver.php index 007ea77..48475f0 100644 --- a/.github/mu-plugins/prautoblogger-deploy-receiver.php +++ b/.github/mu-plugins/prautoblogger-deploy-receiver.php @@ -35,25 +35,33 @@ add_action( 'rest_api_init', 'prautoblogger_deploy_register_route' ); * Register the deploy REST route. */ function prautoblogger_deploy_register_route(): void { - register_rest_route( 'prautoblogger-deploy/v1', '/deploy', [ - 'methods' => 'POST', - 'callback' => 'prautoblogger_deploy_handle', - 'permission_callback' => 'prautoblogger_deploy_check_auth', - ] ); + register_rest_route( + 'prautoblogger-deploy/v1', + '/deploy', + array( + 'methods' => 'POST', + 'callback' => 'prautoblogger_deploy_handle', + 'permission_callback' => 'prautoblogger_deploy_check_auth', + ) + ); // Health check endpoint (GET) — useful for monitoring. - register_rest_route( 'prautoblogger-deploy/v1', '/status', [ - 'methods' => 'GET', - 'callback' => function () { - return [ - 'status' => 'ready', - 'plugin' => is_dir( WP_PLUGIN_DIR . '/prautoblogger' ) ? 'installed' : 'not_installed', - 'active' => is_plugin_active( 'prautoblogger/prautoblogger.php' ), - 'version' => prautoblogger_deploy_get_installed_version(), - ]; - }, - 'permission_callback' => 'prautoblogger_deploy_check_auth', - ] ); + register_rest_route( + 'prautoblogger-deploy/v1', + '/status', + array( + 'methods' => 'GET', + 'callback' => function () { + return array( + 'status' => 'ready', + 'plugin' => is_dir( WP_PLUGIN_DIR . '/prautoblogger' ) ? 'installed' : 'not_installed', + 'active' => is_plugin_active( 'prautoblogger/prautoblogger.php' ), + 'version' => prautoblogger_deploy_get_installed_version(), + ); + }, + 'permission_callback' => 'prautoblogger_deploy_check_auth', + ) + ); } /** @@ -78,7 +86,7 @@ function prautoblogger_deploy_handle( WP_REST_Request $request ): WP_REST_Respon return new WP_Error( 'rate_limited', 'Deploy in progress or recently completed. Wait 60 seconds.', - [ 'status' => 429 ] + array( 'status' => 429 ) ); } set_transient( 'prautoblogger_deploy_lock', time(), 60 ); @@ -87,7 +95,7 @@ function prautoblogger_deploy_handle( WP_REST_Request $request ): WP_REST_Respon $files = $request->get_file_params(); if ( empty( $files['plugin']['tmp_name'] ) || ! is_uploaded_file( $files['plugin']['tmp_name'] ) ) { delete_transient( 'prautoblogger_deploy_lock' ); - return new WP_Error( 'no_file', 'No plugin zip uploaded.', [ 'status' => 400 ] ); + return new WP_Error( 'no_file', 'No plugin zip uploaded.', array( 'status' => 400 ) ); } $tmp_file = $files['plugin']['tmp_name']; @@ -96,7 +104,7 @@ function prautoblogger_deploy_handle( WP_REST_Request $request ): WP_REST_Respon $zip = new ZipArchive(); if ( true !== $zip->open( $tmp_file ) ) { delete_transient( 'prautoblogger_deploy_lock' ); - return new WP_Error( 'invalid_zip', 'Uploaded file is not a valid zip.', [ 'status' => 400 ] ); + return new WP_Error( 'invalid_zip', 'Uploaded file is not a valid zip.', array( 'status' => 400 ) ); } $has_main_file = false; @@ -113,7 +121,7 @@ function prautoblogger_deploy_handle( WP_REST_Request $request ): WP_REST_Respon return new WP_Error( 'invalid_plugin', 'Zip must contain prautoblogger/prautoblogger.php at root.', - [ 'status' => 400 ] + array( 'status' => 400 ) ); } @@ -143,7 +151,7 @@ function prautoblogger_deploy_handle( WP_REST_Request $request ): WP_REST_Respon activate_plugin( 'prautoblogger/prautoblogger.php' ); } delete_transient( 'prautoblogger_deploy_lock' ); - return new WP_Error( 'backup_failed', 'Could not backup current plugin.', [ 'status' => 500 ] ); + return new WP_Error( 'backup_failed', 'Could not backup current plugin.', array( 'status' => 500 ) ); } } @@ -161,7 +169,7 @@ function prautoblogger_deploy_handle( WP_REST_Request $request ): WP_REST_Respon } delete_transient( 'prautoblogger_deploy_lock' ); error_log( '[PRAutoBlogger Deploy] Extraction failed. Rolled back to previous version.' ); - return new WP_Error( 'extract_failed', 'Zip extraction failed. Rolled back.', [ 'status' => 500 ] ); + return new WP_Error( 'extract_failed', 'Zip extraction failed. Rolled back.', array( 'status' => 500 ) ); } // 7. Activate plugin. @@ -178,7 +186,7 @@ function prautoblogger_deploy_handle( WP_REST_Request $request ): WP_REST_Respon return new WP_Error( 'activation_failed', 'Plugin activation failed: ' . $activation_result->get_error_message() . '. Rolled back.', - [ 'status' => 500 ] + array( 'status' => 500 ) ); } @@ -188,18 +196,23 @@ function prautoblogger_deploy_handle( WP_REST_Request $request ): WP_REST_Respon } $old_version = prautoblogger_deploy_get_installed_version(); - error_log( sprintf( - '[PRAutoBlogger Deploy] Successfully deployed v%s (was: %s) at %s', - $incoming_version, - $old_version ?: 'fresh install', - gmdate( 'Y-m-d H:i:s' ) - ) ); + error_log( + sprintf( + '[PRAutoBlogger Deploy] Successfully deployed v%s (was: %s) at %s', + $incoming_version, + $old_version ?: 'fresh install', + gmdate( 'Y-m-d H:i:s' ) + ) + ); - return new WP_REST_Response( [ - 'success' => true, - 'version' => $incoming_version, - 'message' => "PRAutoBlogger v{$incoming_version} deployed and activated.", - ], 200 ); + return new WP_REST_Response( + array( + 'success' => true, + 'version' => $incoming_version, + 'message' => "PRAutoBlogger v{$incoming_version} deployed and activated.", + ), + 200 + ); } /** @@ -210,7 +223,7 @@ function prautoblogger_deploy_get_installed_version(): string { if ( ! file_exists( $main_file ) ) { return ''; } - $data = get_file_data( $main_file, [ 'Version' => 'Version' ] ); + $data = get_file_data( $main_file, array( 'Version' => 'Version' ) ); return $data['Version'] ?? ''; } diff --git a/includes/core/class-keyword-extractor.php b/includes/core/class-keyword-extractor.php index 84d077f..cc6e3c4 100644 --- a/includes/core/class-keyword-extractor.php +++ b/includes/core/class-keyword-extractor.php @@ -25,19 +25,111 @@ class PRAutoBlogger_Keyword_Extractor { * @var string[] */ private const STOPWORDS = array( - 'a', 'an', 'the', 'and', 'or', 'but', 'is', 'are', 'was', 'were', - 'in', 'on', 'at', 'to', 'for', 'of', 'with', 'by', 'from', 'as', - 'it', 'its', 'this', 'that', 'your', 'you', 'how', 'what', 'when', - 'why', 'where', 'which', 'who', 'do', 'does', 'did', 'not', 'no', - 'can', 'will', 'should', 'could', 'would', 'may', 'might', 'have', - 'has', 'had', 'be', 'been', 'being', 'about', 'into', 'through', - 'during', 'before', 'after', 'above', 'below', 'between', 'same', - 'up', 'down', 'out', 'off', 'over', 'under', 'again', 'then', 'here', - 'there', 'all', 'each', 'every', 'both', 'few', 'more', 'most', - 'other', 'some', 'such', 'than', 'too', 'very', 'just', 'also', - 'only', 'own', 'so', 'if', 'while', 'because', 'until', 'vs', - 'versus', 'guide', 'complete', 'ultimate', 'best', 'top', 'new', - 'first', 'need', 'know', 'everything', + 'a', + 'an', + 'the', + 'and', + 'or', + 'but', + 'is', + 'are', + 'was', + 'were', + 'in', + 'on', + 'at', + 'to', + 'for', + 'of', + 'with', + 'by', + 'from', + 'as', + 'it', + 'its', + 'this', + 'that', + 'your', + 'you', + 'how', + 'what', + 'when', + 'why', + 'where', + 'which', + 'who', + 'do', + 'does', + 'did', + 'not', + 'no', + 'can', + 'will', + 'should', + 'could', + 'would', + 'may', + 'might', + 'have', + 'has', + 'had', + 'be', + 'been', + 'being', + 'about', + 'into', + 'through', + 'during', + 'before', + 'after', + 'above', + 'below', + 'between', + 'same', + 'up', + 'down', + 'out', + 'off', + 'over', + 'under', + 'again', + 'then', + 'here', + 'there', + 'all', + 'each', + 'every', + 'both', + 'few', + 'more', + 'most', + 'other', + 'some', + 'such', + 'than', + 'too', + 'very', + 'just', + 'also', + 'only', + 'own', + 'so', + 'if', + 'while', + 'because', + 'until', + 'vs', + 'versus', + 'guide', + 'complete', + 'ultimate', + 'best', + 'top', + 'new', + 'first', + 'need', + 'know', + 'everything', ); /** diff --git a/includes/providers/class-image-aspect-ratio.php b/includes/providers/class-image-aspect-ratio.php index ef77000..0ffe3e6 100644 --- a/includes/providers/class-image-aspect-ratio.php +++ b/includes/providers/class-image-aspect-ratio.php @@ -26,13 +26,41 @@ class PRAutoBlogger_Image_Aspect_Ratio { * @var array */ private const STANDARD_ASPECTS = array( - array( 'w' => 1, 'h' => 1, 'ratio' => 1.0 ), - array( 'w' => 3, 'h' => 2, 'ratio' => 1.5 ), - array( 'w' => 2, 'h' => 3, 'ratio' => 0.6667 ), - array( 'w' => 4, 'h' => 3, 'ratio' => 1.3333 ), - array( 'w' => 3, 'h' => 4, 'ratio' => 0.75 ), - array( 'w' => 16, 'h' => 9, 'ratio' => 1.7778 ), - array( 'w' => 9, 'h' => 16, 'ratio' => 0.5625 ), + array( + 'w' => 1, + 'h' => 1, + 'ratio' => 1.0, + ), + array( + 'w' => 3, + 'h' => 2, + 'ratio' => 1.5, + ), + array( + 'w' => 2, + 'h' => 3, + 'ratio' => 0.6667, + ), + array( + 'w' => 4, + 'h' => 3, + 'ratio' => 1.3333, + ), + array( + 'w' => 3, + 'h' => 4, + 'ratio' => 0.75, + ), + array( + 'w' => 16, + 'h' => 9, + 'ratio' => 1.7778, + ), + array( + 'w' => 9, + 'h' => 16, + 'ratio' => 0.5625, + ), ); /** diff --git a/includes/providers/class-runware-image-validator.php b/includes/providers/class-runware-image-validator.php index 059ab2d..5fa8920 100644 --- a/includes/providers/class-runware-image-validator.php +++ b/includes/providers/class-runware-image-validator.php @@ -86,5 +86,4 @@ class PRAutoBlogger_Runware_Validator { 'message' => __( 'Runware API key valid.', 'prautoblogger' ), ); } - } diff --git a/scripts/check-constants.php b/scripts/check-constants.php index 2d36670..1b83efd 100644 --- a/scripts/check-constants.php +++ b/scripts/check-constants.php @@ -35,18 +35,18 @@ const CONSTANTS_GUARD_WINDOW = 4; // 4 covers if/elseif blocks and multi-line && const CONSTANTS_BOOTSTRAP_FILE = 'prautoblogger.php'; // Directories skipped when walking the shipped tree for references. -const CONSTANTS_EXCLUDE_DIRS = ['tests', 'vendor', '.github', '.git', 'node_modules']; +const CONSTANTS_EXCLUDE_DIRS = array( 'tests', 'vendor', '.github', '.git', 'node_modules' ); // Entry points for the reference scan (files and dirs relative to repo root). -const CONSTANTS_SCAN_ROOTS = [ +const CONSTANTS_SCAN_ROOTS = array( 'prautoblogger.php', 'uninstall.php', 'includes', 'templates', -]; +); -$verbose = in_array( '--verbose', $argv ?? [], true ); -$self_test = in_array( '--self-test', $argv ?? [], true ); +$verbose = in_array( '--verbose', $argv ?? array(), true ); +$self_test = in_array( '--self-test', $argv ?? array(), true ); // ------------------------------------------------------------------------- // 1. Build the defined set from prautoblogger.php only. @@ -67,7 +67,7 @@ preg_match_all( ); /** @var array $defined_set constant name => 1 */ -$defined_set = array_flip( $def_matches[1] ?? [] ); +$defined_set = array_flip( $def_matches[1] ?? array() ); if ( $verbose ) { echo 'Defined in ' . CONSTANTS_BOOTSTRAP_FILE . ' (' . count( $defined_set ) . "):\n"; @@ -108,7 +108,7 @@ function constants_collect_php_files( string $dir, array &$files ): void { } /** @var string[] $php_files */ -$php_files = []; +$php_files = array(); foreach ( CONSTANTS_SCAN_ROOTS as $root ) { if ( ! file_exists( $root ) ) { @@ -133,7 +133,7 @@ if ( $verbose ) { // ------------------------------------------------------------------------- /** @var array $errors */ -$errors = []; +$errors = array(); foreach ( $php_files as $php_path ) { $raw = file_get_contents( $php_path ); @@ -188,7 +188,7 @@ foreach ( $php_files as $php_path ) { } if ( ! $guarded ) { - $errors[] = [ $php_path, $idx + 1, $name, $raw_line ]; + $errors[] = array( $php_path, $idx + 1, $name, $raw_line ); } } } @@ -198,7 +198,7 @@ foreach ( $php_files as $php_path ) { // 4. Report results. // ------------------------------------------------------------------------- -if ( $errors !== [] ) { +if ( $errors !== array() ) { fwrite( STDERR, "\nFAIL -- Unguarded undefined PRAUTOBLOGGER_* constants:\n\n" ); foreach ( $errors as [ $php_path, $lineno, $name, $line_text ] ) { fwrite( STDERR, " {$php_path}:{$lineno}: {$name}\n" ); @@ -228,7 +228,7 @@ if ( $self_test ) { // Now simulate an unguarded reference by re-running the scan on a temp file. $tmp_file = tempnam( sys_get_temp_dir(), 'prab_selftest_' ) . '.php'; file_put_contents( $tmp_file, " $raw_line ) { if ( preg_match_all( '/PRAUTOBLOGGER_[A-Z0-9_]+/', $raw_line, $m ) ) { diff --git a/templates/admin/ideas-browser.php b/templates/admin/ideas-browser.php index c1da706..a04efac 100644 --- a/templates/admin/ideas-browser.php +++ b/templates/admin/ideas-browser.php @@ -72,10 +72,10 @@ $base_url = admin_url( 'admin.php?page=prautoblogger-ideas' ); 1 ) : ?>
add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'current' => $paged, - 'total' => $total_pages, - 'prev_text' => '«', - 'next_text' => '»', - ] ) ); + echo wp_kses_post( + paginate_links( + array( + 'base' => add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'current' => $paged, + 'total' => $total_pages, + 'prev_text' => '«', + 'next_text' => '»', + ) + ) + ); ?>
diff --git a/templates/admin/log-viewer.php b/templates/admin/log-viewer.php index 348a24e..6b11d7d 100755 --- a/templates/admin/log-viewer.php +++ b/templates/admin/log-viewer.php @@ -18,13 +18,13 @@ if ( ! defined( 'ABSPATH' ) ) { } $base_url = admin_url( 'admin.php?page=prautoblogger-logs' ); -$level_counts = [ +$level_counts = array( 'all' => __( 'All', 'prautoblogger' ), 'error' => __( 'Errors', 'prautoblogger' ), 'warning' => __( 'Warnings', 'prautoblogger' ), 'info' => __( 'Info', 'prautoblogger' ), 'debug' => __( 'Debug', 'prautoblogger' ), -]; +); ?>
@@ -46,7 +46,20 @@ $level_counts = [
$lv_label ) : ?> - @@ -119,14 +132,18 @@ $level_counts = [ 1 ) : ?>
add_query_arg( 'paged', '%#%' ), - 'format' => '', - 'current' => $paged, - 'total' => $total_pages, - 'prev_text' => '«', - 'next_text' => '»', - ] ) ); + echo wp_kses_post( + paginate_links( + array( + 'base' => add_query_arg( 'paged', '%#%' ), + 'format' => '', + 'current' => $paged, + 'total' => $total_pages, + 'prev_text' => '«', + 'next_text' => '»', + ) + ) + ); ?>
diff --git a/templates/admin/metabox-generation-info.php b/templates/admin/metabox-generation-info.php index b9778eb..8781722 100755 --- a/templates/admin/metabox-generation-info.php +++ b/templates/admin/metabox-generation-info.php @@ -11,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } -$meta = [ +$meta = array( 'topic' => get_post_meta( $post->ID, '_prautoblogger_topic', true ), 'type' => get_post_meta( $post->ID, '_prautoblogger_article_type', true ), 'model' => get_post_meta( $post->ID, '_prautoblogger_model_used', true ), @@ -22,7 +22,7 @@ $meta = [ 'seo_score' => get_post_meta( $post->ID, '_prautoblogger_seo_score', true ), 'generated_at' => get_post_meta( $post->ID, '_prautoblogger_generated_at', true ), 'keywords' => get_post_meta( $post->ID, '_prautoblogger_target_keywords', true ), -]; +); ?>

@@ -69,7 +69,7 @@ $meta = [

- +