Skip to content

Commit

Permalink
fix: php fatal and warning (#3502)
Browse files Browse the repository at this point in the history
Fixes a fatal and a notice that appears for php 8.3.
  • Loading branch information
chickenn00dle authored Oct 27, 2024
1 parent 5312d30 commit e089172
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions includes/class-newspack-image-credits.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ function( $setting ) use ( $key ) {
return $setting['key'] === $key;
}
);
return reset( array_values( $setting ) );
$setting_values = array_values( $setting );
return reset( $setting_values );
}

return $default_settings;
Expand Down Expand Up @@ -560,7 +561,7 @@ public static function populate_credit( $metadata, $attachment_id, $context ) {
*/
public static function register_meta() {
foreach ( [
static::MEDIA_CREDIT_META,
static::MEDIA_CREDIT_META,
static::MEDIA_CREDIT_URL_META,
static::MEDIA_CREDIT_ORG_META,
static::MEDIA_CREDIT_CAN_DISTRIBUTE_META,
Expand Down
14 changes: 8 additions & 6 deletions includes/wizards/class-setup-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,14 @@ public function api_retrieve_theme_and_set_defaults() {
}
}
$theme_mods['theme_colors'] = get_theme_mod( 'theme_colors', 'default' );
if ( 'default' === $theme_mods['theme_colors'] ) {
$theme_mods['primary_color_hex'] = newspack_get_primary_color();
$theme_mods['secondary_color_hex'] = newspack_get_secondary_color();
} else {
$theme_mods['primary_color_hex'] = get_theme_mod( 'primary_color_hex', newspack_get_primary_color() );
$theme_mods['secondary_color_hex'] = get_theme_mod( 'secondary_color_hex', newspack_get_secondary_color() );
if ( function_exists( '\newspack_get_primary_color' ) ) {
if ( 'default' === $theme_mods['theme_colors'] ) {
$theme_mods['primary_color_hex'] = \newspack_get_primary_color();
$theme_mods['secondary_color_hex'] = \newspack_get_secondary_color();
} else {
$theme_mods['primary_color_hex'] = get_theme_mod( 'primary_color_hex', \newspack_get_primary_color() );
$theme_mods['secondary_color_hex'] = get_theme_mod( 'secondary_color_hex', \newspack_get_secondary_color() );
}
}

// Set custom header color to primary, if not set.
Expand Down

0 comments on commit e089172

Please sign in to comment.