Skip to content

Commit c8f987d

Browse files
Copilotswissspidy
andcommitted
Add theme exists check for better error handling
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 069b988 commit c8f987d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎src/WP_CLI/CommandWithTranslation.php‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,12 @@ protected function get_installed_languages( $slug = 'default' ) {
299299
}
300300
} elseif ( 'themes' === $this->obj_type ) {
301301
$theme_data = wp_get_theme( $slug );
302-
// Use the TextDomain property if available, otherwise fall back to slug.
303-
if ( ! empty( $theme_data->get( 'TextDomain' ) ) ) {
304-
$text_domain = $theme_data->get( 'TextDomain' );
302+
if ( $theme_data->exists() ) {
303+
// Use the TextDomain property if available, otherwise fall back to slug.
304+
$theme_text_domain = $theme_data->get( 'TextDomain' );
305+
if ( ! empty( $theme_text_domain ) ) {
306+
$text_domain = $theme_text_domain;
307+
}
305308
}
306309
}
307310
}

0 commit comments

Comments
 (0)