I'm setting up Wordpress 3.0.1 for a novice user. The Dashboard widgets are appropriately placed, and I'd like them to stay that way. As fa开发者_JAVA技巧r as I know, there's no add_filter or add_action hook to prevent dragging, so another approach would be to make a plugin that uses jQuery to disable dragging. What handler(s) would I override -- click, mouseUp, mouseMove, etc -- and on which DOM elements?
Maybe the easiest thing to do is prevent the new order from being saved. This will let the user change the order, but it won't save the changes for the next time the page is loaded.
You want to prevent the meta-box-order
ajax event:
add_action('check_ajax_referer', 'prevent_meta_box_order');
function prevent_meta_box_order($action)
{
if ('meta-box-order' == $action /* && $wp_user == 'santa claus' */) {
die('-1');
}
}
There are probably other actions you want to prevent too. Open Firebug and check out which requests to admin-ajax.php
are made when you do stuff that you would like to prevent. Or hide the Screen Options tab with CSS.
You can prevent loading the script that handles the widget/metabox dragging and collapsing behaviour:
add_action( 'admin_init', function() {
wp_deregister_script( 'postbox' );
} );
Optionally combine it with some CSS to hide the arrow icon and dragging cursor since this functionality is now disabled:
.handlediv {
display: none !important;
}
.hndle, .widget-top {
cursor: default !important;
}
Use a Roles plugin like WordPress › Role Scoper « WordPress Plugins to restrict what the user can do. Not a good idea to edit core files, as your changes will get overwritten on upgrade.
精彩评论