Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Hiding inactive home sidebars
Browse files Browse the repository at this point in the history
widgets-area.php: css to hide the sidebars in widgets page
functions.php: enqueue css in widgets-area.php
admin-style.js: hide containers of hidden sidebars in widgets page
  • Loading branch information
szk11001 committed Aug 11, 2014
1 parent ba0ffe3 commit ba8fd57
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
22 changes: 22 additions & 0 deletions css/widgets-area.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
$absolute_path = explode('wp-content', $_SERVER['SCRIPT_FILENAME']);
$wp_load = $absolute_path[0] . 'wp-load.php';
require_once($wp_load);

header("Content-type: text/css; charset: UTF-8");
header('Cache-control: must-revalidate');

$sidebars = wp_get_sidebars_widgets();
$index = 0;
for ($i=1; $i < 31 ; $i++) {
if( !empty($sidebars['home'.$i]) ){
if( $i > $index ){
$index = $i; //$index is the biggest home widget area that has widgets, the next widget area doesn't have widgets
}
}
}
$start = ++$index;
for ($i=$start; $i < 31; $i++) {
echo '#home'.$i.'{ display:none; } ';
}
?>
32 changes: 13 additions & 19 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,30 +172,24 @@ function be_hidden_meta_boxes($hidden, $screen) {
}


function load_custom_wp_admin_style($page) {
wp_register_style( 'custom_wp_admin_css', get_template_directory_uri() . '/css/admin-style.css', false, '1.0.0' );
wp_enqueue_style( 'custom_wp_admin_css' );


wp_register_script('uc-admin-js', get_template_directory_uri() . '/js/admin-style.js', false, '1.0.0');
wp_enqueue_script('uc-admin-js');

function load_custom_wp_admin_style($hook) {
wp_register_style( 'custom_wp_admin_css', get_template_directory_uri() . '/css/admin-style.css', false, '1.0.0' );
wp_enqueue_style( 'custom_wp_admin_css' );


wp_register_script('uc-admin-js', get_template_directory_uri() . '/js/admin-style.js', false, '1.0.0');
wp_enqueue_script('uc-admin-js');

if( 'widgets.php' != $hook )
return;
wp_register_style( 'css-widgets-area', get_template_directory_uri().'/css/widgets-area.php' );
wp_enqueue_style( 'css-widgets-area' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );

/*
function remove_widgets() {
// removed to avoid confusion with UConn Calendar widget
unregister_widget('WP_Widget_Calendar');
// removed to de-emphasize blog use
unregister_widget('WP_Widget_Recent_Comments');
unregister_widget('WP_Widget_Meta');
// removed for conflict with simple social plugin on IE9
unregister_widget('WP_Widget_Categories');
function widgets_page_css($hook) {

}
add_action( 'widgets_init', 'remove_widgets' );
*/
add_action( 'admin_enqueue_scripts', 'widgets_page_css' );

add_theme_support( 'post-thumbnails' );
10 changes: 10 additions & 0 deletions js/admin-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@ jQuery(document).ready(function($) {
$('#accordion-section-layout_builder .ui-slider-handle').each(function(){
$(this).addClass('button button-primary');
});

var path = window.location.pathname;
if( path.split('/').indexOf('widgets.php') != -1 ){
$('.widgets-holder-wrap.sidebar-sidebar').each(function(i){
if( !($(this['children'][0]).is(":visible")) ){
$(this).css('display', 'none');
}
});
}

});

0 comments on commit ba8fd57

Please sign in to comment.