0

I have added a meta box in the page edit section:

add_meta_box('custom_section_box', 'Sections', array($this, 'section_box'), 'page','normal','high');

Within the box, there is a wp_editor call:

$tinymce_options = array('plugins' => "table,lists,link,textcolor,hr", 'toolbar1'=>"fontsizeselect,forecolor,backcolor,bold,italic,underline,strikethrough,alignleft,aligncenter,alignright,alignjustify",'toolbar2'=>"blockquote,hr,table,bullist,numlist,undo,redo,link,unlink");
$editor_config= array('teeny'=>true, 'textarea_rows'=>10, 'editor_class'=>'csec_text', 'textarea_name'=>'csec_body', 'wpautop'=>false, 'tinymce'=>$tinymce_options);
wp_editor(html_entity_decode(stripslashes($vals['content'])), 'csec_body', $editor_config); 

Everything is working fine, but when I add a gallery through the media button, it displays the gallery shortcode only (like [gallery link="file" ids="759,760,761"]). There is no usual display of the gallery as in the normal page editor with edit/delete buttons.

I had tried to add the do_shortcode to pass the value in wp_editor, but that displays the full html instead. Also other shortcodes are rendered as html.

Can you please help?

5
  • Include your w_editor settings $editor_config too
    – anton
    May 1, 2019 at 13:36
  • Yes. I did that. $editor_config= array('teeny'=>true, 'textarea_rows'=>10, 'editor_class'=>'csec_text', 'textarea_name'=>'csec_body', 'wpautop'=>false, 'tinymce'=>$tinymce_options);
    – sariDon
    May 1, 2019 at 13:38
  • All is working fine except the gallery display.Image edit is also not working too.
    – sariDon
    May 1, 2019 at 13:39
  • Try to simply call wp_editor without 3 argument - '$editor_config'. At least we will know if the problem related to settings.
    – anton
    May 1, 2019 at 13:44
  • Thanks Anton. It works with the settings removed! I think we need to add something in the settings.
    – sariDon
    May 1, 2019 at 13:47

2 Answers 2

1

Make sure tinymce option has a valid value.
Remove it or set it to true if you don't pass any parameters to tinymce

$editor_config = array(
    'teeny'=>true,
    'textarea_rows'=>10, 
    'editor_class'=>'csec_text', 
    'textarea_name'=>'csec_body', 
    'wpautop'=>false, 
    'tinymce'=>$tinymce_options //THIS OPTION SHOULD BE VALID
);

Edit:

Made a small research. Add wpview in plugins argument of tinymce options.

$tinymce_options = array(
    'plugins' => "wpview,lists,link,textcolor,hr",
    //all other options
}


Also, there is no tinymce table plugin.
List of available plugins:

'charmap',
'colorpicker',
'hr',
'lists',
'media',
'paste',
'tabfocus',
'textcolor',
'fullscreen',
'wordpress',
'wpautoresize',
'wpeditimage',
'wpemoji',
'wpgallery',
'wplink',
'wpdialogs',
'wptextpattern',
'wpview',
9
  • teeny is already set to true. The $tinymce_options are also valid. I have updated the question with these options. Please check. The problem still persists.
    – sariDon
    May 1, 2019 at 13:56
  • Doing a little more r & d and it seems the $tinymce_options is the problem. Though it's valid, passing this parameter breaks the gallery amd image edit/delete format.
    – sariDon
    May 1, 2019 at 14:00
  • what options do you pass there
    – anton
    May 1, 2019 at 14:03
  • $tinymce_options = array('plugins' => "table,lists,link,textcolor,hr", 'toolbar1'=>"fontsizeselect,forecolor,backcolor,bold,italic,underline,strikethrough,alignleft,aligncenter,alignright,alignjustify",'toolbar2'=>"blockquote,hr,table,bullist,numlist,undo,redo,link,unlink");
    – sariDon
    May 1, 2019 at 14:03
  • Check the question. I have updated with the full code.
    – sariDon
    May 1, 2019 at 14:04
0

This piece works perfectly:

$tinymce_options = array(
'plugins' => "paste,lists,link,textcolor,hr,media,wordpress,wpeditimage,wpgallery,wpdialogs,wplink,wpview",
'wordpress_adv_hidden'=> false,
'toolbar1'=>"formatselect,fontsizeselect,forecolor,backcolor,bold,italic,underline,strikethrough,alignleft,aligncenter,alignright,alignjustify,wp_adv",
'toolbar2'=>"blockquote,hr,table,bullist,numlist,outdent,indent,undo,redo,link,unlink,wp_fullscreen,wp_help"
);

Note I have added few wordpress related plugins in the tinymce options.

1
  • I updated my answer, check it out!)
    – anton
    May 1, 2019 at 15:14

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.