Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: admin_enqueue_scripts callback should expect a possible null value passed to it #182

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Admin/PostTypeRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,18 @@ public function add_cpt_registration_fields( array $args, array $post_type ): ar
}

/**
* @param string $screen
* Enqueue the admin scripts for the ACF Post Type settings.
* This script is only enqueued on the ACF Post Type edit screen.
*
* @param ?string $screen
*/
public function enqueue_admin_scripts( string $screen ): void {
public function enqueue_admin_scripts( ?string $screen ): void {
global $post;

if ( empty( $screen ) ) {
return;
}

// if the screen is not a new post / edit post screen, do nothing
if ( ! ( 'post-new.php' === $screen || 'post.php' === $screen ) ) {
return;
Expand Down
11 changes: 9 additions & 2 deletions src/Admin/TaxonomyRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,18 @@ public function add_taxonomy_registration_fields( array $args, array $taxonomy )
}

/**
* @param string $screen
* Enqueue the admin scripts for the ACF Post Type settings.
* This script is only enqueued on the ACF Taxonomy edit screen.
*
* @param ?string $screen
*/
public function enqueue_admin_scripts( string $screen ): void {
public function enqueue_admin_scripts( ?string $screen ): void {
global $post;

if ( empty( $screen ) ) {
return;
}

// if the screen is not a new post / edit post screen, do nothing
if ( ! ( 'post-new.php' === $screen || 'post.php' === $screen ) ) {
return;
Expand Down