mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 15:47:38 +02:00
In wp_ajax_parse_media_shortcode()
, don't require a global $post
for all passed shortcodes.
`embed` is the only shortcode that requires a post ID. This will allow MCE views to work for `playlist`, `audio`, and `video` outside of the Edit Post screen. See #30835. Built from https://develop.svn.wordpress.org/trunk@31201 git-svn-id: http://core.svn.wordpress.org/trunk@31182 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7f8b548df1
commit
60c285aa22
@ -2725,18 +2725,28 @@ function wp_ajax_parse_embed() {
|
|||||||
function wp_ajax_parse_media_shortcode() {
|
function wp_ajax_parse_media_shortcode() {
|
||||||
global $post, $wp_scripts;
|
global $post, $wp_scripts;
|
||||||
|
|
||||||
if ( ! $post = get_post( (int) $_POST['post_ID'] ) ) {
|
if ( empty( $_POST['shortcode'] ) ) {
|
||||||
wp_send_json_error();
|
wp_send_json_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $_POST['shortcode'] ) || ! current_user_can( 'edit_post', $post->ID ) ) {
|
$shortcode = wp_unslash( $_POST['shortcode'] );
|
||||||
wp_send_json_error();
|
|
||||||
|
if ( ! empty( $_POST['post_ID'] ) ) {
|
||||||
|
$post = get_post( (int) $_POST['post_ID'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the embed shortcode requires a post
|
||||||
|
if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
|
||||||
|
if ( 'embed' === $shortcode ) {
|
||||||
|
wp_send_json_error();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
setup_postdata( $post );
|
setup_postdata( $post );
|
||||||
$shortcode = do_shortcode( wp_unslash( $_POST['shortcode'] ) );
|
}
|
||||||
|
|
||||||
if ( empty( $shortcode ) ) {
|
$parsed = do_shortcode( $shortcode );
|
||||||
|
|
||||||
|
if ( empty( $parsed ) ) {
|
||||||
wp_send_json_error( array(
|
wp_send_json_error( array(
|
||||||
'type' => 'no-items',
|
'type' => 'no-items',
|
||||||
'message' => __( 'No items found.' ),
|
'message' => __( 'No items found.' ),
|
||||||
@ -2756,7 +2766,7 @@ function wp_ajax_parse_media_shortcode() {
|
|||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
echo $shortcode;
|
echo $parsed;
|
||||||
|
|
||||||
if ( 'playlist' === $_REQUEST['type'] ) {
|
if ( 'playlist' === $_REQUEST['type'] ) {
|
||||||
wp_underscore_playlist_templates();
|
wp_underscore_playlist_templates();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.2-alpha-31200';
|
$wp_version = '4.2-alpha-31201';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user