style: replace short ternary operator with ?? / explicit ternary to pass WordPress-Core sniff
This commit is contained in:
@@ -178,7 +178,7 @@ class PRAutoBlogger_Admin_Page {
|
||||
break;
|
||||
|
||||
case 'checkboxes':
|
||||
$current = json_decode( (string) $value, true ) ?: array();
|
||||
$current = json_decode( (string) $value, true ) ?? array();
|
||||
// Hidden input ensures an empty value is POSTed when all boxes
|
||||
// are unchecked — without this, the browser omits the field
|
||||
// entirely, so WordPress never fires the sanitize callback and
|
||||
|
||||
@@ -266,7 +266,7 @@ class PRAutoBlogger_Ideas_Browser {
|
||||
return null;
|
||||
}
|
||||
|
||||
$meta = json_decode( $row['metadata_json'] ?? '{}', true ) ?: array();
|
||||
$meta = json_decode( $row['metadata_json'] ?? '{}', true ) ?? array();
|
||||
return array(
|
||||
'topic' => $row['topic'],
|
||||
'article_type' => $row['analysis_type'],
|
||||
@@ -274,7 +274,7 @@ class PRAutoBlogger_Ideas_Browser {
|
||||
'summary' => $row['summary'] ?? '',
|
||||
'score' => (float) $row['relevance_score'],
|
||||
'analysis_id' => (int) $row['id'],
|
||||
'source_ids' => json_decode( $row['source_ids_json'] ?? '[]', true ) ?: array(),
|
||||
'source_ids' => json_decode( $row['source_ids_json'] ?? '[]', true ) ?? array(),
|
||||
'key_points' => $meta['key_points'] ?? array(),
|
||||
'target_keywords' => $meta['target_keywords'] ?? array(),
|
||||
);
|
||||
@@ -312,7 +312,7 @@ class PRAutoBlogger_Ideas_Browser {
|
||||
: $wpdb->get_results( $wpdb->prepare( $full_sql, ...$params ), ARRAY_A );
|
||||
|
||||
return array(
|
||||
'rows' => $rows ?: array(),
|
||||
'rows' => $rows ?? array(),
|
||||
'total' => $total,
|
||||
);
|
||||
}
|
||||
@@ -329,7 +329,7 @@ class PRAutoBlogger_Ideas_Browser {
|
||||
);
|
||||
|
||||
$counts = array();
|
||||
foreach ( $rows ?: array() as $row ) {
|
||||
foreach ( $rows ?? array() as $row ) {
|
||||
$counts[ $row['analysis_type'] ] = (int) $row['cnt'];
|
||||
}
|
||||
return $counts;
|
||||
|
||||
@@ -27,9 +27,8 @@ class PRAutoBlogger_OpenRouter_Model_Field {
|
||||
*/
|
||||
public static function render( string $id, string $value, array $args ): void {
|
||||
$capability = $args['capability'] ?? 'text→text';
|
||||
$display_name = $value ?: __( '— Select a model —', 'prautoblogger' );
|
||||
$display_name = '' !== $value ? $value : __( '— Select a model —', 'prautoblogger' );
|
||||
$display_price = '';
|
||||
|
||||
if ( 'image_generation' === $capability ) {
|
||||
// Resolve from the static image model list defined in settings.
|
||||
$image_models = PRAutoBlogger_Settings_Fields_Extended::get_image_models();
|
||||
|
||||
@@ -138,7 +138,7 @@ class PRAutoBlogger_Content_Analyzer {
|
||||
gmdate( 'Y-m-d H:i:s', time() - DAY_IN_SECONDS )
|
||||
),
|
||||
ARRAY_A
|
||||
) ?: array();
|
||||
) ?? array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,7 +51,7 @@ class PRAutoBlogger_Content_Generator {
|
||||
absint( get_option( 'prautoblogger_min_word_count', 800 ) ),
|
||||
absint( get_option( 'prautoblogger_max_word_count', 2000 ) ),
|
||||
get_option( 'prautoblogger_niche_description', '' ),
|
||||
json_decode( get_option( 'prautoblogger_topic_exclusions', '[]' ), true ) ?: array(),
|
||||
json_decode( get_option( 'prautoblogger_topic_exclusions', '[]' ), true ) ?? array(),
|
||||
get_option( 'prautoblogger_writing_instructions', '' )
|
||||
);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class PRAutoBlogger_Cost_Reporter {
|
||||
);
|
||||
|
||||
$daily = array();
|
||||
foreach ( ( $results ?: array() ) as $row ) {
|
||||
foreach ( ( $results ?? array() ) as $row ) {
|
||||
$daily[ $row['day'] ] = (float) $row['total_cost'];
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ class PRAutoBlogger_Cost_Reporter {
|
||||
);
|
||||
|
||||
$breakdown = array();
|
||||
foreach ( ( $results ?: array() ) as $row ) {
|
||||
foreach ( ( $results ?? array() ) as $row ) {
|
||||
$breakdown[ $row['stage'] ] = array(
|
||||
'cost' => (float) $row['total_cost'],
|
||||
'tokens' => (int) $row['total_tokens'],
|
||||
|
||||
@@ -46,7 +46,7 @@ class PRAutoBlogger_Idea_Scorer {
|
||||
* @return PRAutoBlogger_Article_Idea[] Top-ranked ideas, sorted by score desc.
|
||||
*/
|
||||
public function score_and_rank( array $analysis_results, int $target_count ): array {
|
||||
$exclusions = json_decode( get_option( 'prautoblogger_topic_exclusions', '[]' ), true ) ?: array();
|
||||
$exclusions = json_decode( get_option( 'prautoblogger_topic_exclusions', '[]' ), true ) ?? array();
|
||||
$ideas = array();
|
||||
$excluded_count = 0;
|
||||
$deduped_count = 0;
|
||||
|
||||
@@ -207,7 +207,7 @@ class PRAutoBlogger_Logger {
|
||||
);
|
||||
|
||||
return array(
|
||||
'rows' => $rows ?: array(),
|
||||
'rows' => $rows ?? array(),
|
||||
'total' => $total,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class PRAutoBlogger_Source_Collector {
|
||||
private function get_config_for_source( string $source_type ): array {
|
||||
if ( 'reddit' === $source_type ) {
|
||||
return array(
|
||||
'subreddits' => json_decode( get_option( 'prautoblogger_target_subreddits', '[]' ), true ) ?: array(),
|
||||
'subreddits' => json_decode( get_option( 'prautoblogger_target_subreddits', '[]' ), true ) ?? array(),
|
||||
'limit' => 25,
|
||||
'time_filter' => 'day',
|
||||
'include_comments' => true,
|
||||
|
||||
@@ -171,7 +171,7 @@ class PRAutoBlogger_Posts_Widget {
|
||||
'category' => sanitize_text_field( $atts['category'] ),
|
||||
'title' => sanitize_text_field( $atts['title'] ),
|
||||
'subtitle' => sanitize_text_field( $atts['subtitle'] ),
|
||||
'archiveUrl' => esc_url( get_post_type_archive_link( 'post' ) ?: '' ),
|
||||
'archiveUrl' => esc_url( get_post_type_archive_link( 'post' ) ?? '' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ class PRAutoBlogger_Posts_Widget {
|
||||
'date' => get_the_date( 'c', $post ),
|
||||
'category_name' => $category_name,
|
||||
'category_slug' => $category_slug,
|
||||
'featured_image' => $featured_image ?: '',
|
||||
'featured_image' => $featured_image ?? '',
|
||||
'word_count' => $word_count,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class PRAutoBlogger_OpenRouter_Image_Provider implements PRAutoBlogger_Image_Pro
|
||||
|
||||
$curl_filter = $this->request_builder->register_curl_auth_filter(
|
||||
$headers,
|
||||
wp_parse_url( $base_url, PHP_URL_HOST ) ?: ''
|
||||
wp_parse_url( $base_url, PHP_URL_HOST ) ?? ''
|
||||
);
|
||||
|
||||
$started_at = microtime( true );
|
||||
|
||||
Reference in New Issue
Block a user