[wp-trac] [WordPress Trac] #37482: Copy/paste shortcode view containing HTML tags is broken
WordPress Trac
noreply at wordpress.org
Sat Jul 30 15:44:17 UTC 2016
#37482: Copy/paste shortcode view containing HTML tags is broken
--------------------------+------------------------------
Reporter: bduclos | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: TinyMCE | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses: javascript
--------------------------+------------------------------
Comment (by bduclos):
Here's a simplified code:
1. The registration of the view:
{{{
window.wp.mce.views.register( 'test', {
initialize: function() {
var self = this;
wp.ajax.post( 'get-shortcode' , {
shortcode: self.shortcode.string(),
} )
.done( function( response ) {
self.render( response );
} );
}
});
}}}
2. The function called to retrieve the shortcode content:
{{{#!php
function wp_ajax_get_shortcode() {
$shortcode = $_POST['shortcode'] ;
ob_start();
echo do_shortcode( $shortcode );
$content = ob_get_clean();
wp_send_json_success( $content );
}
add_action( 'wp_ajax_get-shortcode', 'wp_ajax_get_shortcode' );
}}}
3. The function that add the shortcode:
{{{#!php
function ve_test_func( $attr, $content = '' ) {
return $content;
}
add_shortcode('test', 've_test_func' );
}}}
4. Now in the editor, type the following content in Text Mode:
{{{
[test]
<h1>Heading</h1>
[/test]
}}}
Switch to Visual Mode. If you try to copy/paste the view, the new view is
broken.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37482#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list