WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a site with a lot of widgets. They have been highly customized.

Several admins/editors will have to edit these widgets when the site is live.

Right now I'm scared to see a widget (and its configuration) can be fully erased in a single mouse move (dropping it off the side bar).

Is there any way to prevent widgets removal while keeping the ability to edit its content ?

Additionally, the widget management page in the Administration gives in my opinion too much space to the "add widget" module and not enough to the "activated widget" module. This is helpful while building a site but useless when the site is done. Is there any way to switch the size of these modules ?

Thanks a lot

share|improve this question
up vote 2 down vote accepted

The solution I can think of is removing the panels Available and Inactive Widgets so there's simply nowhere to drag (and delete) the widgets used in the sidebar.

You can inject something else to fill the gap.

In this example, only one user is able to add/delete widgets.

function wpse_53398_script_printer(){
    // used to display the front end site
    $site = get_site_url();

    // here you can filter who can add/delete widgets
    global $current_user;  
    if ( 'kursus' == $current_user->data->user_login ) 
            echo <<<HTML
            <!-- CSS to hide the widgets descriptions = real estate gains -->
            <style type="text/css">#widget-list .widget-description {display:none;}</style>
            <script type="text/javascript">
            jQuery(document).ready( function($) {
                // swaps the placement of the panels Available Widgets and Incactive Widgets
            echo <<<HTML
            <!-- CSS to prevent the div from briefly appearing before the jQuery can act -->
            <style type="text/css">#widgets-left {display:none;}</style>
            <script type="text/javascript">
            // reload the contents of the iframe
            function Reload () {
                var f = document.getElementById('the-front-end');
                f.src = f.src;
            jQuery(document).ready( function($) {
                // inject other content to fill the void
                $('<div style="width:70%;"><input type="button" value="Reload front page" onclick="Reload();" style="float:right"><br /><iframe id="the-front-end" src="{$site}" frameborder="0" width="100%" height="700"></div>').insertBefore('#widgets-left');

                // removes the whole left side of the widgets page

add_action('admin_footer-widgets.php', 'wpse_53398_script_printer');

Important: the HTML; closing line cannot have any whitespace characters before or after

PS: this Heredoc syntax <<<HTML code HTML; is preventing the code to display the PHP properly formatted here in WPSE. But the code is tested and working.

share|improve this answer
Pretty clever, thanks ! – kursus Oct 31 '12 at 18:14

The probem of deleting widgets is more general, it is caused by the developer and the editor using the same backend interface. Similar problems like deleting widgets are - inserting images in the wrong size - adding fonts that were not intended by the designer - creating more menu items than allowed .. and many more

The solution is simple, give editors their own interface. And probably the best way to do this is: let this interface look like the website itself. This approach is what I call "frontend CMS"

The frontend editor plugin is a free plugin that can be used for this. I myself wrote a plugin that takes this philosophy a bit further, frontendcms.com. It is not free however.

share|improve this answer
An answer should be more than just a link to an external site. Please add a solution. – kaiser Oct 18 '12 at 17:17
thanks kaiser, I updated the answer – Carlo Roosen Oct 19 '12 at 7:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.