From 81551b9e3604aa53b726fb4cb2c97e2f949b1a56 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 23 Sep 2017 17:06:40 +0000 Subject: [PATCH] Posts, Post Types: Pass `$post` parameter to `post_submitbox_start`, `attachment_submitbox_misc_actions`, `media_submitbox_misc_sections`, `audio_submitbox_misc_sections` filters. Props sebastian.pisula, SergeyBiryukov. Fixes #36206. git-svn-id: https://develop.svn.wordpress.org/trunk@41581 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/media.php | 27 +++++++++++++++++---------- src/wp-admin/includes/meta-boxes.php | 13 ++++++++++--- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index 4c8a04d5c1..6bb541dd35 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -2899,6 +2899,10 @@ function attachment_submitbox_metadata() { endif; if ( preg_match( '#^(audio|video)/#', $post->post_mime_type ) ) { + $fields = array( + 'length_formatted' => __( 'Length:' ), + 'bitrate' => __( 'Bitrate:' ), + ); /** * Filters the audio and video metadata fields to be shown in the publish meta box. @@ -2907,13 +2911,12 @@ function attachment_submitbox_metadata() { * metadata key, and the value should be the desired label. * * @since 3.7.0 + * @since 4.9.0 Added the `$post` parameter. * - * @param array $fields An array of the attachment metadata keys and labels. + * @param array $fields An array of the attachment metadata keys and labels. + * @param WP_Post $post WP_Post object for the current attachment. */ - $fields = apply_filters( 'media_submitbox_misc_sections', array( - 'length_formatted' => __( 'Length:' ), - 'bitrate' => __( 'Bitrate:' ), - ) ); + $fields = apply_filters( 'media_submitbox_misc_sections', $fields, $post ); foreach ( $fields as $key => $label ) { if ( empty( $meta[ $key ] ) ) { @@ -2938,6 +2941,11 @@ function attachment_submitbox_metadata() { __( 'Audio Format:' ), + 'codec' => __( 'Audio Codec:' ) + ); + /** * Filters the audio attachment metadata fields to be shown in the publish meta box. * @@ -2945,13 +2953,12 @@ function attachment_submitbox_metadata() { * metadata key, and the value should be the desired label. * * @since 3.7.0 + * @since 4.9.0 Added the `$post` parameter. * - * @param array $fields An array of the attachment metadata keys and labels. + * @param array $fields An array of the attachment metadata keys and labels. + * @param WP_Post $post WP_Post object for the current attachment. */ - $audio_fields = apply_filters( 'audio_submitbox_misc_sections', array( - 'dataformat' => __( 'Audio Format:' ), - 'codec' => __( 'Audio Codec:' ) - ) ); + $audio_fields = apply_filters( 'audio_submitbox_misc_sections', $fields, $post ); foreach ( $audio_fields as $key => $label ) { if ( empty( $meta['audio'][ $key ] ) ) { diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index e3511faf67..1bc057141d 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -244,8 +244,12 @@ do_action( 'post_submitbox_misc_actions', $post ); * Fires at the beginning of the publishing actions section of the Publish meta box. * * @since 2.7.0 + * @since 4.9.0 Added the `$post` parameter. + * + * @param WP_Post|null $post WP_Post object for the current post on Edit Post screen, + * null on Edit Link screen. */ -do_action( 'post_submitbox_start' ); +do_action( 'post_submitbox_start', $post ); ?>
@@ -914,7 +921,7 @@ function link_submit_meta_box($link) {