style: auto-fix PHPCS violations via phpcbf

This commit is contained in:
peptiderepo
2026-06-12 06:49:13 +00:00
parent 934bf2ec42
commit 93d422efc8
2 changed files with 282 additions and 283 deletions

View File

@@ -18,11 +18,11 @@ declare(strict_types=1);
*/ */
class PRAutoBlogger_Admin_Page { class PRAutoBlogger_Admin_Page {
private const PAGE_SLUG = 'prautoblogger-settings'; private const PAGE_SLUG = 'prautoblogger-settings';
private const OPTION_GROUP = 'prautoblogger_settings_group'; private const OPTION_GROUP = 'prautoblogger_settings_group';
/** Register the top-level PRAutoBlogger menu item. */ /** Register the top-level PRAutoBlogger menu item. */
public function on_register_menu(): void { public function on_register_menu(): void {
add_menu_page( add_menu_page(
__( 'PRAutoBlogger', 'prautoblogger' ), __( 'PRAutoBlogger', 'prautoblogger' ),
__( 'PRAutoBlogger', 'prautoblogger' ), __( 'PRAutoBlogger', 'prautoblogger' ),
@@ -32,10 +32,10 @@ class PRAutoBlogger_Admin_Page {
'dashicons-edit-page', 'dashicons-edit-page',
30 30
); );
} }
/** Register all settings with the WordPress Settings API. */ /** Register all settings with the WordPress Settings API. */
public function on_register_settings(): void { public function on_register_settings(): void {
$sections = PRAutoBlogger_Settings_Fields::get_sections(); $sections = PRAutoBlogger_Settings_Fields::get_sections();
$fields = PRAutoBlogger_Settings_Fields::get_fields(); $fields = PRAutoBlogger_Settings_Fields::get_fields();
@@ -56,10 +56,10 @@ class PRAutoBlogger_Admin_Page {
); );
add_settings_field( $field['id'], $field['label'], array( $this, 'render_field' ), self::PAGE_SLUG, $section, $field ); add_settings_field( $field['id'], $field['label'], array( $this, 'render_field' ), self::PAGE_SLUG, $section, $field );
} }
} }
/** Enqueue admin CSS and JS on all PRAutoBlogger admin pages. */ /** Enqueue admin CSS and JS on all PRAutoBlogger admin pages. */
public function on_enqueue_assets( string $hook_suffix ): void { public function on_enqueue_assets( string $hook_suffix ): void {
$pages = array( $pages = array(
'toplevel_page_' . self::PAGE_SLUG, 'toplevel_page_' . self::PAGE_SLUG,
'prautoblogger_page_prautoblogger-board', 'prautoblogger_page_prautoblogger-board',
@@ -105,24 +105,24 @@ class PRAutoBlogger_Admin_Page {
if ( 'prautoblogger_page_prautoblogger-ideas' === $hook_suffix ) { if ( 'prautoblogger_page_prautoblogger-ideas' === $hook_suffix ) {
wp_enqueue_script( 'prautoblogger-ideas-browser', PRAUTOBLOGGER_PLUGIN_URL . 'assets/js/ideas-browser.js', array( 'jquery', 'prautoblogger-admin' ), PRAUTOBLOGGER_VERSION, true ); wp_enqueue_script( 'prautoblogger-ideas-browser', PRAUTOBLOGGER_PLUGIN_URL . 'assets/js/ideas-browser.js', array( 'jquery', 'prautoblogger-admin' ), PRAUTOBLOGGER_VERSION, true );
} }
} }
/** Render the settings page (delegates to template). */ /** Render the settings page (delegates to template). */
public function render_page(): void { public function render_page(): void {
if ( ! current_user_can( 'manage_options' ) ) { if ( ! current_user_can( 'manage_options' ) ) {
return; return;
} }
$sections = PRAutoBlogger_Settings_Fields::get_sections(); $sections = PRAutoBlogger_Settings_Fields::get_sections();
$fields = PRAutoBlogger_Settings_Fields::get_fields(); $fields = PRAutoBlogger_Settings_Fields::get_fields();
include PRAUTOBLOGGER_PLUGIN_DIR . 'templates/admin/settings-page.php'; include PRAUTOBLOGGER_PLUGIN_DIR . 'templates/admin/settings-page.php';
} }
/** /**
* Render a single settings field based on its type. * Render a single settings field based on its type.
* *
* @param array<string, mixed> $args Field definition. * @param array<string, mixed> $args Field definition.
*/ */
public function render_field( array $args ): void { public function render_field( array $args ): void {
$id = esc_attr( $args['id'] ); $id = esc_attr( $args['id'] );
$type = $args['type'] ?? 'text'; $type = $args['type'] ?? 'text';
$default = $args['default'] ?? ''; $default = $args['default'] ?? '';
@@ -243,16 +243,16 @@ class PRAutoBlogger_Admin_Page {
if ( '' !== $desc ) { if ( '' !== $desc ) {
printf( '<p class="ab-field-desc">%s</p>', esc_html( $desc ) ); printf( '<p class="ab-field-desc">%s</p>', esc_html( $desc ) );
} }
} }
/** /**
* Delegate source status rendering to the dedicated field class. * Delegate source status rendering to the dedicated field class.
* *
* @see admin/fields/class-source-status-field.php * @see admin/fields/class-source-status-field.php
*/ */
private function render_source_status_field(): void { private function render_source_status_field(): void {
PRAutoBlogger_Source_Status_Field::render(); PRAutoBlogger_Source_Status_Field::render();
} }
/** /**
* Delegate model picker rendering to the dedicated field class. * Delegate model picker rendering to the dedicated field class.
@@ -263,9 +263,9 @@ class PRAutoBlogger_Admin_Page {
* *
* @see admin/fields/class-openrouter-model-field.php * @see admin/fields/class-openrouter-model-field.php
*/ */
private function render_model_select_field( string $id, string $value, array $args ): void { private function render_model_select_field( string $id, string $value, array $args ): void {
PRAutoBlogger_OpenRouter_Model_Field::render( $id, $value, $args ); PRAutoBlogger_OpenRouter_Model_Field::render( $id, $value, $args );
} }
/** /**
* Sanitize a settings field value. * Sanitize a settings field value.
@@ -273,7 +273,7 @@ class PRAutoBlogger_Admin_Page {
* @param mixed $value The submitted value. * @param mixed $value The submitted value.
* @return mixed Sanitized value. * @return mixed Sanitized value.
*/ */
public function sanitize_field( $value ) { public function sanitize_field( $value ) {
$option_name = ''; $option_name = '';
$filter = current_filter(); $filter = current_filter();
if ( 0 === strpos( $filter, 'sanitize_option_' ) ) { if ( 0 === strpos( $filter, 'sanitize_option_' ) ) {
@@ -337,10 +337,10 @@ class PRAutoBlogger_Admin_Page {
return PRAutoBlogger_Image_Template_Filler::sanitize_for_save( (string) $value ); return PRAutoBlogger_Image_Template_Filler::sanitize_for_save( (string) $value );
} }
return sanitize_text_field( (string) $value ); return sanitize_text_field( (string) $value );
} }
/** Validate model id against the registry and persist the derived provider. */ /** Validate model id against the registry and persist the derived provider. */
private function sanitize_image_model( string $value ): string { private function sanitize_image_model( string $value ): string {
$candidate = sanitize_text_field( $value ); $candidate = sanitize_text_field( $value );
$provider = PRAutoBlogger_Image_Model_Registry::provider_for( $candidate ); $provider = PRAutoBlogger_Image_Model_Registry::provider_for( $candidate );
if ( '' !== $provider ) { if ( '' !== $provider ) {

View File

@@ -142,5 +142,4 @@ class PRAutoBlogger_Cost_Reporter {
} }
return ( $this->get_monthly_spend() / $budget ) * 100.0; return ( $this->get_monthly_spend() / $budget ) * 100.0;
} }
} }