1

I have an editor on the front end of a website using wp_editor. It mostly works as expected; very similar to the admin side editor. However, when I enter an audio or video link, the players are not rendered as they are on the admin side. For example, inputting:-

http://chromafunk.com/bucket/ring.mp3

...on the admin side will immediately render to the audio player. On my public side wp_editor, it remains as a URL string.

There are obviously some filters/scripts on the admin side that render these URLs that are not available as standard from the public facing side. Is it possible to get a public side wp_editor to behave exactly like the admin side editor? Its kind of pointless having front end editing if I lose a chunk of functionality from the admin side editor.

Im using my own custom plugin to launch the editor. Im using the following:-

function create_tinymce() {
    $settings = array(
        'media_buttons' => true,
        'drag_drop_upload' => false,
        'wpautop' => true,
        );
    wp_editor("", "my-editor", $settings);
}

Im then hooking the above function using:-

add_action( 'wp_head', 'create_tinymce', 0 );
3
  • How are you adding it to the frontend? Are you using a plugin? If not can you show us some of your code?
    – Fencer04
    Jul 27, 2016 at 13:23
  • Thanks Fencer. Ive appended my OP with some code examples. Jul 27, 2016 at 14:27
  • There are 2 trac tickets regarding the oEmbed functionality outside of post/page edit screens here and here. It looks like it is on the radar but won't appear until an unspecified future release. Aug 3, 2016 at 15:58

1 Answer 1

2

I've been fighting this for a while on a series of themes I make that provide a front end content creation interface not requiring a WP account. For the last two years I have said "trust me, URLs will embed".

Those old tickets are dormant, but I just have found a solution here https://wordpress.stackexchange.com/a/287623

For the template that renders the page you are using for your form, you need to add an enqueue statement.

This is some partial code on a site where auto embeds are not working on an editor added via wp_editor()

add_action('wp_enqueue_scripts', 'add_truwriter_scripts');

function add_truwriter_scripts() {  

    // set up main styles
    $parent_style = 'radcliffe_style'; 

    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );

    wp_enqueue_style( 'child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );



if ( is_page('write') ) { // use on just our form page

    // Get Embed functionality in rich text editor
    // h/t https://wordpress.stackexchange.com/a/287623
    wp_enqueue_script( 'mce-view' );
   :
   :
   // unrelated code follows
2
  • Does this still work?
    – user145078
    Jan 14, 2021 at 17:31
  • It only worked when my code was secretly logging in as an author. My hunch is it's a problem caling admin-ajax.php Got no answer here wordpress.org/support/topic/…
    – cogdog
    Jan 15, 2021 at 1:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.