braginteractive / MDLWP

Material Design Lite WordPress Theme
http://mdlwp.com
GNU General Public License v2.0
331 stars 83 forks source link

Front-end wp_editor() not working #2

Closed yoyecros closed 9 years ago

yoyecros commented 9 years ago

The Visual tab of the WP Editor on front office doesn't work, unlike the text tab. There is a problem with this line : wp_enqueue_script( 'mdlwp-mdl-js', '//storage.googleapis.com/code.getmdl.io/1.0.0/material.min.js', array(), '1.0.0', true ); in the file inc\scripts.php.

braginteractive commented 9 years ago

Is front office a plugin or something? MDLWP doesn't include anything called front office.

The text and visual editor in the backend work just fine with MDL.

yoyecros commented 9 years ago

Everything in the front office, plug-in, static page... try to put <?php wp_editor('test', 'test'); ?> in a php template to see this bug

Le jeu. 23 juil. 2015 à 16:28, Brad Williams notifications@github.com a écrit :

Is front office a plugin or something? MDLWP doesn't include anything called front office.

The text and visual editor in the backend work just fine with MDL.

— Reply to this email directly or view it on GitHub https://github.com/braginteractive/MDLWP/issues/2#issuecomment-124123929 .

braginteractive commented 9 years ago

Oh, you are talking about using the wp_editor() on the front-end..

I don't see any console errors as to why it isn't working.. If you comment out wp_enqueue_script( 'mdlwp-mdl-js', '//storage.googleapis.com/code.getmdl.io/1.0.0/material.min.js', array(), '1.0.0', true ); it does start working though.

The theme uses MDL JS out-of-box without any changes, so I am not sure how to go about providing a work around or fixing this.

Ideas welcome.

tlongren commented 9 years ago

@yoyecros, try something like this at the top of the .php file you're calling wp_editor in:

<?php
$content = 'This content gets loaded first.';
$editor_id = 'my_frontend_editor';
$settings =   array(
    'wpautop' => true, // use wpautop?
    'media_buttons' => true, // show insert/upload button(s)
    'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
    'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
    'tabindex' => '',
    'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped".
    'editor_class' => '', // add extra class(es) to the editor textarea
    'teeny' => false, // output the minimal editor config used in Press This
    'dfw' => false, // replace the default fullscreen with DFW (supported on the front-end in WordPress 3.4)
    'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
    'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
);
?>

Then, where you want the editor to appear, add this:

<?php wp_editor( $content, $editor_id, $settings ); ?>

The editor shows up fine for me. I'm using the latest copy of the master branch.

Answer taken from StackExchange.

braginteractive commented 9 years ago

Awesome. Thank you.