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

Hiding Home Sidebars #11

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; } ';
}
?>
33 changes: 12 additions & 21 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,28 +172,19 @@ function be_hidden_meta_boxes($hidden, $screen) {
}


function load_custom_wp_admin_style() {
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');
}
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 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( 'widgets_init', 'remove_widgets' );
*/
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );

add_theme_support( 'post-thumbnails' );
2 changes: 1 addition & 1 deletion inc/reg-sidebars.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
*/
function uc_options_add_page() {
add_theme_page( 'Manage Sidebars', 'Manage Sidebars', 'edit_theme_options', 'uc_sidebars', 'uc_sidebars_do_page' );
remove_submenu_page( 'themes.php', 'widgets.php' );
//remove_submenu_page( 'themes.php', 'widgets.php' );
}
add_action( 'admin_menu', 'uc_options_add_page' );

Expand Down
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');
}
});
}

});