Tagged: editor
- This topic has 5 replies, 3 voices, and was last updated 5 years, 7 months ago by
Jason.
-
AuthorPosts
-
-
June 20, 2016 at 9:52 pm #6778
eflouretMemberHi,
I would like to show only four buttons (b, i, link, unlink) in my frontend editor.
I can’t find a way to do that with Piklist, so I tried with the regular wordpress hooks/filters/actions whatever.
The problem is that all of them need an editor ID, which it isn’t an option (as far as I know) in the Piklist editor field.
Is there a way I can display a custom toolbar in my editor field?
Thanks!
Enrique
-
June 21, 2016 at 11:04 am #6784
-
June 21, 2016 at 11:22 am #6786
eflouretMemberHi Steve,
Sorry, but I didn’t test anything yet. I saw several tutorials, but all of them took quite different approaches. Some of them asked for a wp_editor instance ID like this one:
add_filter( 'teeny_mce_buttons', 'my_editor_buttons', 10, 2 ); function my_editor_buttons( $buttons, $editor_id ) { return array( 'formatselect', 'bold', 'italic' ); }I believe that there is an ID attribute in the WP_EDITOR() that I can pass to piklist, but I didn’t try it. Besides, how will that work with add_more fields?
Sorry, although I can code a bit of PHP, I’m not a programmer.
Thanks
Enrique
-
June 21, 2016 at 11:52 am #6787
eflouretMemberOk, this works (source: http://rachievee.com/wp-tutorial-remove-tinymce-buttons/)
function remove_bold_tinymce_button( $buttons ){ //Remove bold button $remove = 'bold'; //Find the array key and then unset if ( ( $key = array_search( $remove, $buttons ) ) !== false ) unset( $buttons[$key] ); return $buttons; } add_filter( 'teeny_mce_buttons', 'remove_bold_tinymce_button' );You can use it with ‘teeny_mce_buttons’ or ‘mce_buttons’. This function will remove the Bold button. Not that I want that, but it is just an example of how to remove a button.
But it alters all instances of the editor in your site.
I have to find a way to make this work only in the frontend and in the add_more fields too. I guess that should be fairly easy.
Any suggestions?
Enrique
-
June 27, 2016 at 10:54 am #6805
SteveKeymasterEnrique–
You can let WordPress tell you. Try this. It should display the $editor_id for you.
function my_editor_buttons( $buttons, $editor_id ) { print_r($editor_id); // display id return array( 'formatselect', 'bold', 'italic' ); } add_filter( 'teeny_mce_buttons', 'my_editor_buttons', 10, 2 ); -
June 28, 2016 at 2:57 pm #6830
-
-
AuthorPosts
- You must be logged in to reply to this topic.