Skip to content

Commit b06cf28

Browse files
authored
Merge pull request #182 from wp-graphql/fix/180-unexpected-type-for-hook_suffix
fix: admin_enqueue_scripts callback should expect a possible null value passed to it
2 parents 2ed5e0c + 9a89199 commit b06cf28

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Admin/PostTypeRegistration.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,18 @@ public function add_cpt_registration_fields( array $args, array $post_type ): ar
167167
}
168168

169169
/**
170-
* @param string $screen
170+
* Enqueue the admin scripts for the ACF Post Type settings.
171+
* This script is only enqueued on the ACF Post Type edit screen.
172+
*
173+
* @param ?string $screen
171174
*/
172-
public function enqueue_admin_scripts( string $screen ): void {
175+
public function enqueue_admin_scripts( ?string $screen ): void {
173176
global $post;
174177

178+
if ( empty( $screen ) ) {
179+
return;
180+
}
181+
175182
// if the screen is not a new post / edit post screen, do nothing
176183
if ( ! ( 'post-new.php' === $screen || 'post.php' === $screen ) ) {
177184
return;

src/Admin/TaxonomyRegistration.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,18 @@ public function add_taxonomy_registration_fields( array $args, array $taxonomy )
165165
}
166166

167167
/**
168-
* @param string $screen
168+
* Enqueue the admin scripts for the ACF Post Type settings.
169+
* This script is only enqueued on the ACF Taxonomy edit screen.
170+
*
171+
* @param ?string $screen
169172
*/
170-
public function enqueue_admin_scripts( string $screen ): void {
173+
public function enqueue_admin_scripts( ?string $screen ): void {
171174
global $post;
172175

176+
if ( empty( $screen ) ) {
177+
return;
178+
}
179+
173180
// if the screen is not a new post / edit post screen, do nothing
174181
if ( ! ( 'post-new.php' === $screen || 'post.php' === $screen ) ) {
175182
return;

0 commit comments

Comments
 (0)