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

Attempt to read property “ID“ on null“ at `./wp-content/plugins/avatar-manager/avatar-manager.php:1144 #43

Open
JanThiel opened this issue Aug 9, 2023 · 0 comments

Comments

@JanThiel
Copy link

JanThiel commented Aug 9, 2023

Triggered by:

function avatar_manager_display_media_states( $media_states ) {
global $post;
// Retrieves attachment meta field based on attachment ID.
$meta_avatar = get_post_meta( $post->ID, '_avatar_manager_is_custom_avatar', true );
if ( ! empty( $meta_avatar ) )
$media_states[] = __( 'Avatar Image', 'avatar-manager' );

But since WP 4.8.0 display_media_states passes the relevant $post as parameter.

	/**
	 * Filters the default media display states for items in the Media list table.
	 *
	 * @since 3.2.0
	 * @since 4.8.0 Added the `$post` parameter.
	 *
	 * @param string[] $media_states An array of media states. Default 'Header Image',
	 *                               'Background Image', 'Site Icon', 'Logo'.
	 * @param WP_Post  $post         The current attachment object.
	 */
	return apply_filters( 'display_media_states', $media_states, $post );

No need to fallback to the global. Just take the passed WP_Post and work on that

JanThiel added a commit to JanThiel/avatar-manager that referenced this issue Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant