Issues is affecting both 3.0.4 and 3.0.5. To reproduce, try entering & saving custom metadata in TSF metabox belonging to any media file, under Edit more details. Demonstration. Please inform the reporting user, after the issue is fixed.
I forgot that by adding support for all posts types, attachments were included.
There are some attachment exclusions in TSF's code that prevent some execution, and I'll investigate the cause.
I'm yet uncertain if wp_update_attachment_metadata() should exclusively be used when dealing with attachments, but that'll add another (unwanted) dimension in the metadata storage.
Hey Sybre,
I'm pretty sure the problem is that you used wp_enqueue_media() without any $args in '/inc/classes/admin-init.class.php'. That way, images uploaded are not getting attached to the proper posts which can break other plugins.
If you replace \wp_enqueue_media(); on line 144 with something like this, it works:
global $post;
$args = array( 'post' => $post->ID );
\wp_enqueue_media( $args );
Would love if you could test this and looking forward to your feedback!
[Added by @sybrew; the code that's being discussed]
https://github.com/sybrew/the-seo-framework/blob/366c157e759ebb5c73da27908f0120033598566f/inc/classes/admin-init.class.php#L132-L156
Thanks for looking into this @crimann!
From wp_enqueue_media():
if ( isset( $args['post'] ) ) {
$post = get_post( $args['post'] );
$settings['post'] = array(
'id' => $post->ID,
'nonce' => wp_create_nonce( 'update-post_' . $post->ID ),
);
$thumbnail_support = current_theme_supports( 'post-thumbnails', $post->post_type ) && post_type_supports( $post->post_type, 'thumbnail' );
if ( ! $thumbnail_support && 'attachment' === $post->post_type && $post->post_mime_type ) {
if ( wp_attachment_is( 'audio', $post ) ) {
$thumbnail_support = post_type_supports( 'attachment:audio', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:audio' );
} elseif ( wp_attachment_is( 'video', $post ) ) {
$thumbnail_support = post_type_supports( 'attachment:video', 'thumbnail' ) || current_theme_supports( 'post-thumbnails', 'attachment:video' );
}
}
if ( $thumbnail_support ) {
$featured_image_id = get_post_meta( $post->ID, '_thumbnail_id', true );
$settings['post']['featuredImageId'] = $featured_image_id ? $featured_image_id : -1;
}
}
What's most important here is that a nonce is created. Which is outputted via:
var _wpMediaViewsL10n.settings.nonce
This will only happen when the aforementioned suggestion is implemented.
Thank you for looking into this, great teamwork:)!
@crimann I just confirmed that the (soon to be attached) fix you suggested for https://github.com/sybrew/the-seo-framework/issues/278#issuecomment-374852683 will work as intended. Feel free to double-check it 馃槃