有没有办法在wordpress上设置个人资料页面的样式?我想补充如下内容:
Start of the page just below the <h2>
tag
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
<div id="poststuff" class="metabox-holder has-right-sidebar">
<div id="post-body">
<div id="post-body-content" style="margin-right: 0 !important;">
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
Before each opening <table>
tag (注意“php\\u e(\'name\')”)
<div id="namepage" class="postbox ">
<h3 style="cursor: default !important;"><?php _e(\'Name\') ?></h3>
<div class="inside">
After each closing </table>
tag
</div>
</div>
After the </form>
tag
</div>
</div>
</div>
</div>
</div>
我对添加自定义CSS文件不感兴趣,我很乐意使用已有的CSS文件。
作为测试,我编辑了用户编辑。php从wp管理和它看起来很好,在我看来要好得多。
有没有合适的方法将这些div添加到页面中。
编辑,我知道下面的代码,但我希望有人可以帮助“preg\\u replace”添加上述div。
function users_edited($buffer) {
if (!current_user_can(\'activate_plugins\')) {
global $pagenow;
if ($pagenow == \'profile.php\' || $pagenow == \'users.php\' || $pagenow == \'user-edit.php\') {
//Hide the Name table
$name = \'#<h3>Name</h3>.+?<table.+?/table>#s\';
$buffer=preg_replace($name,\'\',$buffer,1);
$personal = array(\'#<h3>Name</h3>.+?<table.+?/table>#s\', \'#<h3>Personal Options</h3>.+?<table.+?/table>#s\');
$buffer=preg_replace($personal,\'\',$buffer,1);
//Modiffy Contact Person header from h2 to h3
$contactperson=\'#<h2>Contact Person</h2>#\';
$buffer=preg_replace($contactperson,\'<h3>Contact Person</h3>\',$buffer,1);
}
return $buffer;
}
}
function users_edit_start() {
if (!current_user_can(\'activate_plugins\')) {
ob_start("users_edited");
}
}
function users_edit_end() {
if (!current_user_can(\'activate_plugins\')) {
ob_end_flush();
}
}
add_action(\'admin_head\', \'users_edit_start\');
add_action(\'admin_footer\', \'users_edit_end\');
最合适的回答,由SO网友:user983248 整理而成
它在标准配置文件页面(您的配置文件/配置文件)上工作,没有安装其他插件。
其他插件可能会影响总体结果。我认为代码可以改进,如果有人知道怎么做,请试一试。
function better_profile_page($buffer) {
global $pagenow;
if ($pagenow == \'profile.php\' || $pagenow == \'users.php\' || $pagenow == \'user-edit.php\') {
$form_start = \'#<form id="your-profile" action="\'.esc_url( self_admin_url( IS_PROFILE_PAGE ? \'profile.php\' : \'user-edit.php\' ) ).\'" method="post">#\';
$new_form_start = \'<form id="your-profile" action="\'.esc_url( self_admin_url( IS_PROFILE_PAGE ? \'profile.php\' : \'user-edit.php\' ) ).\'" method="post"><div id="normal-sortables" class="meta-box-sortables ui-sortable">
<div id="poststuff" class="metabox-holder has-right-sidebar">
<div id="post-body">
<div id="post-body-content" style="margin-right: 0 !important;">
<div id="normal-sortables" class="meta-box-sortables ui-sortable">\';
$buffer=preg_replace($form_start, $new_form_start ,$buffer,1);
$h3_open_a = \'#<h3>#\';
$buffer=preg_replace($h3_open_a,\'<div id="namepage" class="postbox "><h3 style="cursor: default !important;">\',$buffer,1);
$h3_close = \'#</h3>#\';
$buffer=preg_replace($h3_close,\'</h3><div class="inside">\',$buffer,1);
$h3_open_b = \'#<h3>#\';
$buffer=preg_replace($h3_open_b,\'</div></div><div id="namepage" class="postbox "><h3 style="cursor: default !important;">\',$buffer);
$submit_button = \'#<p class="submit">#\';
$buffer=preg_replace($submit_button,\'<p class="submit" style="float: left ! important; padding: 12px ! important;">\',$buffer);
$form_close = \'#</form>#\';
$new_form_close = \'</div></div></div></form>\';
$buffer=preg_replace($form_close, $new_form_close ,$buffer,1);
}
return $buffer;
}
function edit_profile_page_start() {
ob_start("better_profile_page");
}
function edit_profile_page_end() {
ob_end_flush();
}
add_action(\'admin_head\', \'edit_profile_page_start\');
add_action(\'admin_footer\', \'edit_profile_page_end\');