1列管理屏幕选项-将submitdiv移到底部

时间:2012-02-07 作者:PrivateUser

我正在使用此代码。

add_filter(\'meta-box-order_post\',\'one_column_for_all\');
function one_column_for_all($result, $option, $user){
    $result[\'normal\'] = \'postexcerpt,formatdiv,trackbacksdiv,tagsdiv-post_tag,categorydiv,postimagediv,postcustom,commentstatusdiv,slugdiv,authordiv,submitdiv\';
    $result[\'side\'] = \'\';
    $result[\'advanced\'] = \'\';
    return $result;
}
我的submitdiv 总是出现在中间而不是底部。有人能帮我把它移到底部吗?

请注意:我还有一些自定义的元数据库,它们是由一些插件添加的。所以我想移动submitdiv 页面最底部

1 个回复
最合适的回答,由SO网友:Tomas Buteler 整理而成

尝试以下操作:

// First make all metaboxes have \'normal\' context (note the absence of \'submitdiv\')
// If you know the ids of the metaboxes, you could add them here and skip the next function altogether
add_filter(\'get_user_option_meta-box-order_post\', \'one_column_for_all\', 10, 1);
function one_column_for_all($option) {
    $result[\'normal\'] = \'postexcerpt,formatdiv,trackbacksdiv,tagsdiv-post_tag,categorydiv,postimagediv,postcustom,commentstatusdiv,slugdiv,authordiv\';
    $result[\'side\'] = \'\';
    $result[\'advanced\'] = \'\';
    return $result;
}

// Then we add \'submitdiv\' on the bottom, by creating this filter with a low priority
// It feels a bit like overkill, because it assumes other plug-ins might be using the same filter, but still...
add_filter(\'get_user_option_meta-box-order_post\',\'submitdiv_at_bottom\', 999, 1);
function submitdiv_at_bottom($result){
    $result[\'normal\'] .= \',submitdiv\';
    return $result;
}
而且,由于您将内容强制放在一列中,您可能需要添加以下内容以实现设计一致性:

// Allow only 1 column option on screen options
add_filter(\'screen_layout_columns\', \'one_column_on_screen_options\');
function one_column_on_screen_options($columns) {
    $columns[\'post\'] = 1;
    return $columns;
}

// Ignore user preferences stored in DB, and serve only one column layout    
add_filter(\'get_user_option_screen_layout_post\', \'one_column_layout\');
function one_column_layout($option) {
    return 1;
}
我假设你说的是正常的帖子,这就是我在上面展示的,但我想,这些帖子也可以适应其他类型的帖子,使用不同的过滤器。

结束