Make WordPress Core

Changeset 29178


Ignore:
Timestamp:
07/15/2014 10:07:16 PM (10 years ago)
Author:
wonderboymusic
Message:

Add a new AJAX action: parse-media-shortcode. This async call will replace JS rendering of audio/video/playlist shortcodes.

See #28905.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/admin-ajax.php

    r29029 r29178  
    6161    'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
    6262    'send-attachment-to-editor', 'save-attachment-order', 'heartbeat', 'get-revision-diffs',
    63     'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail'
     63    'save-user-color-scheme', 'update-widget', 'query-themes', 'parse-embed', 'set-attachment-thumbnail',
     64    'parse-media-shortcode'
    6465);
    6566
  • trunk/src/wp-admin/includes/ajax-actions.php

    r29176 r29178  
    26852685    wp_send_json_success( $parsed );
    26862686}
     2687
     2688function wp_ajax_parse_media_shortcode() {
     2689    global $post, $wp_scripts;
     2690
     2691    if ( ! $post = get_post( (int) $_REQUEST['post_ID'] ) ) {
     2692        wp_send_json_error();
     2693    }
     2694
     2695    setup_postdata( $post );
     2696
     2697    ob_start();
     2698
     2699    $styles = wp_media_mce_styles();
     2700    foreach ( $styles as $style ) {
     2701        printf( '<link rel="stylesheet" href="%s"/>', $style );
     2702    }
     2703
     2704    echo do_shortcode( wp_unslash( $_REQUEST['shortcode'] ) );
     2705
     2706    if ( ! empty( $wp_scripts ) ) {
     2707        $wp_scripts->done = array();
     2708    }
     2709   
     2710    if ( 'playlist' === $_REQUEST['type'] ) {
     2711        wp_underscore_playlist_templates();
     2712
     2713        wp_print_scripts( 'wp-playlist' );
     2714    } else {
     2715        wp_print_scripts( 'wp-mediaelement' );
     2716    }
     2717
     2718    wp_send_json_success( ob_get_clean() );
     2719}
Note: See TracChangeset for help on using the changeset viewer.