admin管理员组文章数量:1279009
I noticed when you typein the user's “biographical info” on the profile, it shows up in one page! Looks really terrible. So:
Is there a way to use tinyMCE or other solution for user “biographical info” without messing with any core file, and without any plugin?
Thanks a lot.
I noticed when you typein the user's “biographical info” on the profile, it shows up in one page! Looks really terrible. So:
Is there a way to use tinyMCE or other solution for user “biographical info” without messing with any core file, and without any plugin?
Thanks a lot.
Share Improve this question edited Nov 13, 2011 at 4:05 Tara asked Nov 12, 2011 at 0:32 TaraTara 8681 gold badge13 silver badges18 bronze badges 2- Not really sure what you're asking here. It shows up all on one page? What exactly is the issue and what exactly are you trying to accomplish? – Kevin Langley Jr. Commented Nov 12, 2011 at 7:31
- @Kevin Langly thanks for your response. As I mentioned initially, when you typein the user's “biographical info” on the author bio profile (in the admin), It does not save paragraps, etc. - the entire bio shows up in one big paragraph! I am trying to make stops the stripping of html formatting from the description (bio) field. I hope I made it clear. Thanks again. – Tara Commented Nov 13, 2011 at 1:23
5 Answers
Reset to default 3Not sure if this is the perfect way to do it, but it worked for me by removing the description element using jQuery and then adding editor for the description element.
/*******************************************
* TinyMCE EDITOR "Biographical Info" USER PROFILE
*******************************************/
function biographical_info_tinymce() {
if ( basename($_SERVER['PHP_SELF']) == 'profile.php' || basename($_SERVER['PHP_SELF']) == 'user-edit.php' && function_exists('wp_tiny_mce') ) {
echo "<script>jQuery(document).ready(function($){ $('#description').remove();});</script>";
$settings = array(
'tinymce' => array(
'toolbar1' => 'bold,italic,bullist,numlist,link,unlink',
'toolbar2' => '',
'toolbar3' => '',
'toolbar4' => '',
),
'wpautop' => true,
'media_buttons' => false,
'quicktags' => false,
);
$description = get_user_meta( $user->ID, 'description', true);
wp_editor( $description, 'description', $settings );
}
}
add_action('admin_head', 'biographical_info_tinymce');
remove_filter('pre_user_description', 'wp_filter_kses');
add_filter( 'pre_user_description', 'wp_filter_post_kses' );
Add this to your functions.php
:
/*******************************************
* TinyMCE EDITOR "Biographical Info" USER PROFILE
*******************************************/
function biographical_info_tinymce() {
if ( basename($_SERVER['PHP_SELF']) == 'profile.php' || basename($_SERVER['PHP_SELF']) == 'user-edit.php' && function_exists('wp_tiny_mce') ) {
wp_admin_css();
wp_enqueue_script('utils');
wp_enqueue_script('editor');
do_action('admin_print_scripts');
do_action('admin_print_styles-post-php');
do_action('admin_print_styles');
remove_all_filters('mce_external_plugins');
add_filter( 'teeny_mce_before_init',
create_function( '$a', '
$a["theme"] = "advanced";
$a["skin"] = "wp_theme";
$a["height"] = "300";
$a["width"] = "440";
$a["onpageload"] = "";
$a["mode"] = "exact";
$a["elements"] = "description";
$a["theme_advanced_buttons1"] = "formatselect, forecolor, bold, italic, pastetext, pasteword, bullist, numlist, link, unlink, outdent, indent, charmap, removeformat, spellchecker, fullscreen, wp_adv";
$a["theme_advanced_buttons2"] = "underline, justifyleft, justifycenter, justifyright, justifyfull, forecolor, pastetext, undo, redo, charmap, wp_help";
$a["theme_advanced_blockformats"] = "p,h2,h3,h4,h5,h6";
$a["theme_advanced_disable"] = "strikethrough";
return $a;' )
);
wp_tiny_mce( true );
}
}
add_action('admin_head', 'biographical_info_tinymce');
. Someone is due for credit on this but i can't remember where i have found this..
Anyhow this works great for me
I’ve written a plugin that replaces the Biographical Info profile field with the WordPress visual editor, TinyMCE, allowing you to editor an author’s biography using rich text using a new function, wp_editor(), that was released with WordPress 3.3.
http://wordpress/extend/plugins/visual-biography-editor/
Using this plugin will ensure that the editor isn’t wiped out with the next core update, which you should definitely do for security reasons.
Just adding this to the theme's functions.php solve the problem (prevent stripping of the html from the author's bio):
remove_filter('pre_user_description', 'wp_filter_kses');
add_filter( 'pre_user_description', 'wp_filter_post_kses' );
Just add it
function mysite_show_extra_profile_fields($user) {
wp_enqueue_editor();
?>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var id = 'description';
wp.editor.initialize(id, {
tinymce: {
wpautop: true
},
quicktags: true
});
});
</script>
<?
}
add_action('show_user_profile', 'mysite_show_extra_profile_fields');
本文标签: How to use tinyMCE for user “biographical info” without messing with any core file
版权声明:本文标题:How to use tinyMCE for user “biographical info” without messing with any core file? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741238046a2363414.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论