mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Add a new AJAX action: parse-media-shortcode
. This async call will replace JS rendering of audio/video/playlist shortcodes.
See #28905. Built from https://develop.svn.wordpress.org/trunk@29178 git-svn-id: http://core.svn.wordpress.org/trunk@28962 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
237b3a9344
commit
043715e8a4
@ -60,7 +60,8 @@ $core_actions_post = array(
|
||||
'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
|
||||
'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
|
||||
'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
|
||||
'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail'
|
||||
'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
|
||||
'parse-media-shortcode'
|
||||
);
|
||||
|
||||
// Register core Ajax calls.
|
||||
|
@ -2684,3 +2684,36 @@ function wp_ajax_parse_embed() {
|
||||
|
||||
wp_send_json_success( $parsed );
|
||||
}
|
||||
|
||||
function wp_ajax_parse_media_shortcode() {
|
||||
global $post, $wp_scripts;
|
||||
|
||||
if ( ! $post = get_post( (int) $_REQUEST['post_ID'] ) ) {
|
||||
wp_send_json_error();
|
||||
}
|
||||
|
||||
setup_postdata( $post );
|
||||
|
||||
ob_start();
|
||||
|
||||
$styles = wp_media_mce_styles();
|
||||
foreach ( $styles as $style ) {
|
||||
printf( '<link rel="stylesheet" href="%s"/>', $style );
|
||||
}
|
||||
|
||||
echo do_shortcode( wp_unslash( $_REQUEST['shortcode'] ) );
|
||||
|
||||
if ( ! empty( $wp_scripts ) ) {
|
||||
$wp_scripts->done = array();
|
||||
}
|
||||
|
||||
if ( 'playlist' === $_REQUEST['type'] ) {
|
||||
wp_underscore_playlist_templates();
|
||||
|
||||
wp_print_scripts( 'wp-playlist' );
|
||||
} else {
|
||||
wp_print_scripts( 'wp-mediaelement' );
|
||||
}
|
||||
|
||||
wp_send_json_success( ob_get_clean() );
|
||||
}
|
Loading…
Reference in New Issue
Block a user