• Resolved webbo69

    (@webbo69)


    Hi

    My client wants to be able to update her site exclusively from a mobile/cell phone – she has no computer.

    I’m looking to simplify the dashboard for her so she can readily view/edit the Content Sidebar without having to scroll down past the Available/Inactive Widgets – the (responsive) Content Sidebar moves below them on a small screen. (I know I could direct her to contract these by tapping the “up” arrow next to them – but I want to minimalise the actions she needs to undertake.)

    In my Child Theme’s functions.php file, I’ve added the following:

    // unregister all widgets
    function unregister_default_widgets() {
         unregister_widget('WP_Widget_Pages');
         unregister_widget('WP_Widget_Calendar');
         unregister_widget('WP_Widget_Archives');
         unregister_widget('WP_Widget_Links');
         unregister_widget('WP_Widget_Meta');
         unregister_widget('WP_Widget_Search');
         unregister_widget('WP_Widget_Text');
         unregister_widget('WP_Widget_Categories');
         unregister_widget('WP_Widget_Recent_Posts');
         unregister_widget('WP_Widget_Recent_Comments');
         unregister_widget('WP_Widget_RSS');
         unregister_widget('WP_Widget_Tag_Cloud');
         unregister_widget('WP_Nav_Menu_Widget');
         unregister_widget('Twenty_Fourteen_Ephemera_Widget');
    }
    add_action('widgets_init', 'unregister_default_widgets', 11);

    …to unregister all widgets except the Black Studio TinyMCE Widget – “Visual Editor”, which she will use in the Content Sidebar. (NB. Can anybody tell me the relevance of the figure “11” as the final parameter of “add_action” – I’ve googled it without success…)

    This works fine when I run it locally with localhost (using XAMMP v3.2.1) – none of the other widgets are displayed. However; when I upload the functions.php file to the Child Theme directory on the server, all the other widgets are still displayed. Other functions in my Child Theme (e.g., Custom Admin Login Header Logo, Hide Error Messages, etc.) are working fine both on localhost and server, and so I don’t believe there’s anything wrong with the coding itself.

    I’m really perplexed by this – anybody got any ideas? All assistance greatly received!

    Cheers
    Webbo

Viewing 7 replies - 1 through 7 (of 7 total)
  • Have you thought about just hiding those widget areas using CSS? When WordPress displays the dashboard, the body element is assigned the class wp-admin, so you can add CSS rules using a plugin like Custom CSS Manager. Unlike the child theme’s style.css file, the stylesheet produced by Custom CSS Manager will even be brought in on the admin dashboard. So it’s just a matter of inspecting each widget area to see which ID you want use in your selector. For example, if you want to hide all of the widgets in the Primary Sidebar area, you could add this CSS rule:

    .wp-admin #sidebar-1 {
       display: none;
    }

    If you want to hide the Available Widgets section, add the .wp-admin #available-widgets selector to the above rule. What’s even better is to nest the rule inside a media query, so that those areas are only hidden on a mobile device, but are displayed on a desktop or laptop.

    Thread Starter webbo69

    (@webbo69)

    Hi CrouchingBruin

    Thanks – I hadn’t thought of going down that route. I particularly like the idea of nesting the rule inside a media query.

    I edited my Child Theme’s style.css file after some inspection, but couldn’t get it to work. I then installed the Custom CSS Manager plugin, but it gave me the following error message against all my plugins:

    Use of undefined constant SB_LOADER – assumed ‘SB_LOADER’ in /../wp-content/plugins/custom-css-manager-plugin/custom-css-manager-plugin.php on line…

    So I then deactivated the new plugin and went back to good old CSS and tried a few variations – all without success. Here’s what I’ve currently added to my Child Theme’s style.css file:

    .wp-admin #widgets-left {
       display: none !important;
    }

    (My Primary (Left) Sidebar is hidden using a plugin.) Any ideas where I’m going wrong?

    Cheers
    Webbo

    I probably wasn’t clear in my earlier post that the reason why I suggested using Custom CSS Manager is that a child theme’s style.css file will not be used in the admin dashboard, so no use trying to make that work.

    There’s a post on the Custom CSS Manager support forum that says to edit the plugin (go to Plugins > Editor and select Custom CSS Manager), and edit the custom-css-manager-plugin.php file to change this on line 416:

    plugin_basename(SB_LOADER)

    to this:

    plugin_basename(__FILE__)

    Thread Starter webbo69

    (@webbo69)

    Thanks CrouchingBruin – all sorted!

    I’d seen that post on the Support Forum, but was cautious about implementing the edit. Your post gave me the push into the pool… Strangely, while I got the (SB_LOADER) error on localhost, it didn’t happen when I uploaded to the server – thus, I haven’t changed it to (__FILE__) there. (Don’t know whether I should…?)

    Thanks for the pointer that the Child Theme’s style.css file won’t work. Whilst I appreciate that (although I don’t quite understand why); isn’t there a way for CSS aficionados to be able to edit the dashboard without resorting to plugins? Or is that there’s perhaps a reliance on (say) JavaScript (with which I’m not too comfortable) within the plugin? That’s not to say that I don’t like plugins – I just like to understand what I’m doing! I see WordPress almost as a necessary evil for building CMS sites; given the choice, I much prefer just coding pure HTML and CSS.

    As an aside, I also edited all the .php files within the Custom CSS Manager plugin – they all had whitespace at the end of files and all were concluded by closing tags. I’ve had horrendous problems with whitespace in .php files in the past, so the whitespace and tags had to go!

    Anyway; thanks so much for your help – much appreciated.

    Cheers
    Webbo

    Thread Starter webbo69

    (@webbo69)

    Meant to add:

    Presumably I can also edit adminmenu (to reduce menu items available to client) in a similar fashion just by adding relevant IDs in the same .css area in Custom CSS Manager?

    Yes, there shouldn’t be any reason why you can’t hide sections of the admin menu using the same technique. As long as you include the .wp-admin class at the beginning of your selectors, it should only affect elements on the admin pages.

    I think the reason why the child style.css file (and the theme’s style.css file) isn’t included on the admin pages is to prevent inadvertent changes to the dashboard. I remember adding some CSS via the Custom CSS Manager plugin to set the background property of the body element of a site to an image, and it changed the background of the admin pages as well.

    Thread Starter webbo69

    (@webbo69)

    Cheers

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘[Theme: Twenty Fourteen Child] Functions.php behaviour localhost vs server’ is closed to new replies.