From d7df22b86233bcef1e92e0b360eb38ff8f68ebff Mon Sep 17 00:00:00 2001 From: andrewmbacon Date: Tue, 12 Aug 2014 13:33:42 -0400 Subject: [PATCH] Manual Merge Getting Salman's and Joshs changes into place --- css/widgets-area.php | 22 +++ functions.php | 401 ++++++++++++++++++++------------------- inc/reg-sidebars.php | 318 +++++++++++++++---------------- js/min/navigation.min.js | 2 +- js/navigation.js | 101 ++++++---- 5 files changed, 452 insertions(+), 392 deletions(-) create mode 100644 css/widgets-area.php mode change 100755 => 100644 js/navigation.js diff --git a/css/widgets-area.php b/css/widgets-area.php new file mode 100644 index 0000000..042fcfc --- /dev/null +++ b/css/widgets-area.php @@ -0,0 +1,22 @@ + $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; } '; + } +?> \ No newline at end of file diff --git a/functions.php b/functions.php index 3a233eb..a9c7158 100644 --- a/functions.php +++ b/functions.php @@ -1,199 +1,204 @@ - __( 'Primary Menu', 'cs' ), - ) ); - - // Enable support for Post Formats. - add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) ); - - // Setup the WordPress core custom background feature. - add_theme_support( 'custom-background', apply_filters( 'cs_custom_background_args', array( - 'default-color' => 'ffffff', - 'default-image' => '', - ) ) ); - - // Enable support for HTML5 markup. - add_theme_support( 'html5', array( - 'comment-list', - 'search-form', - 'comment-form', - 'gallery', - 'caption', - ) ); -} -endif; // cs_setup -add_action( 'after_setup_theme', 'cs_setup' ); - -/** - * Register widget area. - * - * @link http://codex.wordpress.org/Function_Reference/register_sidebar - */ -function cs_widgets_init() { - require get_template_directory() . '/inc/reg-sidebars.php'; -} -add_action( 'widgets_init', 'cs_widgets_init' ); - -/** - * Enqueue scripts and styles. - */ -function cs_scripts() { - - wp_enqueue_style( 'cs-style', get_stylesheet_uri()); - - wp_enqueue_script( 'cs-bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' )); - wp_enqueue_script( 'cs-modernizr', get_template_directory_uri() . '/js/cs-modernizr.js', array( 'jquery' )); - wp_enqueue_script( 'cs', get_template_directory_uri() . '/js/cs.js', array( 'jquery' )); - wp_enqueue_script( 'cs-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'cs-bootstrap-js'), '20120206', true ); - wp_enqueue_script( 'cs-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true ); - - if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { - wp_enqueue_script( 'comment-reply' ); - } -} - -add_action( 'wp_enqueue_scripts', 'cs_scripts' ); - -function htmlShiv(){ - $template = get_template_directory_uri(); - echo ''; - - //needed for IE7 grid hack - /*echo ''; */ -} - -add_action( 'wp_head', htmlShiv, 1 ); - -function ieBootstrap(){ - $template = get_template_directory_uri(); - echo ''; - /* - echo ''; - */ -} -add_action( 'wp_head', ieBootstrap, 99 ); - -/** - * Implement the Custom Header feature. - */ -require get_template_directory() . '/inc/custom-header.php'; - -/** - * Custom template tags for this theme. - */ -require get_template_directory() . '/inc/template-tags.php'; - -/** - * Custom functions that act independently of the theme templates. - */ -require get_template_directory() . '/inc/extras.php'; - -/** - * Customizer additions. - */ -require get_template_directory() . '/inc/customizer.php'; - -/** - * Load Jetpack compatibility file. - */ -//require get_template_directory() . '/inc/jetpack.php'; - - -/** -* New versions of functions from Hale, added as includes -*/ -require get_template_directory() . '/inc/nav-walker.php'; - - -/** -* Bootstrap the comment form. -*/ -require get_template_directory() . '/inc/bootstrap-forms.php'; - - -// Change what's hidden by default -add_filter('default_hidden_meta_boxes', 'be_hidden_meta_boxes', 10, 2); -function be_hidden_meta_boxes($hidden, $screen) { - if ( 'post' == $screen->base || 'page' == $screen->base ) - $hidden = array('slugdiv', 'trackbacksdiv', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); - // removed 'postcustom', - return $hidden; -} - - -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'); - -} -add_action( 'widgets_init', 'remove_widgets' ); -*/ - + __( 'Primary Menu', 'cs' ), + ) ); + + // Enable support for Post Formats. + add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) ); + + // Setup the WordPress core custom background feature. + add_theme_support( 'custom-background', apply_filters( 'cs_custom_background_args', array( + 'default-color' => 'ffffff', + 'default-image' => '', + ) ) ); + + // Enable support for HTML5 markup. + add_theme_support( 'html5', array( + 'comment-list', + 'search-form', + 'comment-form', + 'gallery', + 'caption', + ) ); +} +endif; // cs_setup +add_action( 'after_setup_theme', 'cs_setup' ); + +/** + * Register widget area. + * + * @link http://codex.wordpress.org/Function_Reference/register_sidebar + */ +function cs_widgets_init() { + require get_template_directory() . '/inc/reg-sidebars.php'; +} +add_action( 'widgets_init', 'cs_widgets_init' ); + +/** + * Enqueue scripts and styles. + */ +function cs_scripts() { + + wp_enqueue_style( 'cs-style', get_stylesheet_uri()); + + wp_enqueue_script( 'cs-bootstrap-js', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' )); + wp_enqueue_script( 'cs-modernizr', get_template_directory_uri() . '/js/cs-modernizr.js', array( 'jquery' )); + wp_enqueue_script( 'cs', get_template_directory_uri() . '/js/cs.js', array( 'jquery' )); + wp_enqueue_script( 'cs-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'cs-bootstrap-js'), '20120206', true ); + wp_enqueue_script( 'cs-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true ); + + if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { + wp_enqueue_script( 'comment-reply' ); + } +} + +add_action( 'wp_enqueue_scripts', 'cs_scripts' ); + +function htmlShiv(){ + $template = get_template_directory_uri(); + echo ''; + + //needed for IE7 grid hack + /*echo ''; */ +} + +add_action( 'wp_head', htmlShiv, 1 ); + +function ieBootstrap(){ + $template = get_template_directory_uri(); + echo ''; + /* + echo ''; + */ +} +add_action( 'wp_head', ieBootstrap, 99 ); + +/** + * Implement the Custom Header feature. + */ +require get_template_directory() . '/inc/custom-header.php'; + +/** + * Custom template tags for this theme. + */ +require get_template_directory() . '/inc/template-tags.php'; + +/** + * Custom functions that act independently of the theme templates. + */ +require get_template_directory() . '/inc/extras.php'; + +/** + * Customizer additions. + */ +require get_template_directory() . '/inc/customizer.php'; + +/** + * Load Jetpack compatibility file. + */ +//require get_template_directory() . '/inc/jetpack.php'; + + +/** +* New versions of functions from Hale, added as includes +*/ +require get_template_directory() . '/inc/nav-walker.php'; + + +/** +* Bootstrap the comment form. +*/ +require get_template_directory() . '/inc/bootstrap-forms.php'; + + +// Change what's hidden by default +add_filter('default_hidden_meta_boxes', 'be_hidden_meta_boxes', 10, 2); +function be_hidden_meta_boxes($hidden, $screen) { + if ( 'post' == $screen->base || 'page' == $screen->base ) + $hidden = array('slugdiv', 'trackbacksdiv', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); + // removed 'postcustom', + return $hidden; +} + + +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'); + +} +add_action( 'widgets_init', 'remove_widgets' ); +*/ + add_theme_support( 'post-thumbnails' ); \ No newline at end of file diff --git a/inc/reg-sidebars.php b/inc/reg-sidebars.php index c74c16f..ada2f54 100644 --- a/inc/reg-sidebars.php +++ b/inc/reg-sidebars.php @@ -1,160 +1,160 @@ - __( 'Mega Footer', 'theme_text_domain' ), - 'description' => 'Limited to 6 widgets. Will appear at the bottom of every page in the site.', - 'before_widget' => '', - 'before_title' => '

', - 'after_title' => '

', - 'pages' => array(), - 'children' => 'off', - 'force' => true - ); - update_option('uc_sidebars',$sidebars); - $sidebars['mega-footer']['id'] = 'mega-footer'; - register_sidebar($sidebars['mega-footer']); - } - if(!isset($sidebars['sidebar'])){ - $sidebars['sidebar'] = array( - 'name' => __( 'Default Sidebar', 'theme_text_domain' ), - 'description' => 'Appears with Archives, Search Results, the Blog page template, and when viewing single posts.', - 'class' => 'sidebar', - 'before_widget' => '', - 'before_title' => '

', - 'after_title' => '

', - 'pages' => array(), - 'children' => 'off', - 'force' => true - ); - update_option('uc_sidebars',$sidebars); - $sidebars['sidebar']['id'] = 'sidebar'; - register_sidebar($sidebars['sidebar']); - } - - /*register_sidebar(array( - 'name' => __( 'Sidebar', 'theme_text_domain' ), - 'id' => 'sidebar', - 'description' => 'Appears with Archives, Search Results, the Blog page template, and when viewing single posts.', - 'class' => 'sidebar', - 'before_widget' => '', - 'before_title' => '

', - 'after_title' => '

' - )); - - register_sidebar( array( - 'name' => __( 'Mega Footer' ), - 'id' => 'mega-footer', - 'description' => 'Limited to 6 widgets. Will appear at the bottom of every page in the site.', - 'before_widget' => '', - 'before_title' => '

', - 'after_title' => '

' - ) );*/ - - for($i=1; $i<=30; $i++){ - $sidebars['home'.$i] = array( - 'name' => __( 'Home '.$i, 'theme_text_domain' ), - 'class' => 'sidebar', - 'before_widget' => '', - 'before_title' => '

', - 'after_title' => '

', - 'pages' => array(), - 'children' => 'off', - 'force' => true - ); - update_option('uc_sidebars',$sidebars); - $sidebars['home'.$i]['id'] = 'home'.$i; - register_sidebar($sidebars['home'.$i]); - } -} - - -/** - * Add the options page to the "Appearance" admin menu - * - * @since Unique Page Sidebars 0.1 - */ -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' ); -} -add_action( 'admin_menu', 'uc_options_add_page' ); - -function remove_wp_widgets( $wp_admin_bar ) { - $wp_admin_bar->remove_node( 'widgets' ); -} -add_action( 'admin_bar_menu', 'remove_wp_widgets', 999 ); - -// if no title then add widget content wrapper to before widget -function check_sidebar_params( $params ) { - global $wp_registered_widgets; - - $settings_getter = $wp_registered_widgets[ $params[0]['widget_id'] ]['callback'][0]; - $settings = $settings_getter->get_settings(); - $settings = $settings[ $params[1]['number'] ]; - - if ( $params[0][ 'after_widget' ] == '' && isset( $settings[ 'title' ] ) && empty( $settings[ 'title' ] ) ){ - $params[0][ 'before_widget' ] .= '
'; - } - - #Counts widgets in mega footer and adds column class accordingly - if( $params[0]['id'] == 'mega-footer' ){ - $sidebars = get_option('sidebars_widgets'); - $widgets = $sidebars['mega-footer']; - $count = count($widgets); - if( $count > 6 ){ - $cols = 2; - } else { - $cols = floor(12 / $count); - } - $params[0]['before_widget'] = str_replace('aside class="', 'aside class="col-sm-' . $cols . ' ', $params[0]['before_widget']); - } - return $params; -} -add_filter( 'dynamic_sidebar_params', 'check_sidebar_params' ); - -function mf_remove_extra( $sidebars_widgets ){ - $widgets = $sidebars_widgets['mega-footer']; - if( is_array($sidebars_widgets['mega-footer']) ){ - foreach ($sidebars_widgets['mega-footer'] as $i => $widget) { - if( $i > 5 ){ - unset($sidebars_widgets['mega-footer'][$i]); - } - } - } - return $sidebars_widgets; -} -add_filter( 'sidebars_widgets', 'mf_remove_extra' ); - -function custom_searchform($form){ - global $search_counter; - if( !$search_counter ){ - $search_counter = 0; - } - $search_counter++; - - $form = '
Search this Site'; - $form .= ''; - $form .= ''; - $form .= ''; - $form .= '
'; - - return $form; -} -add_filter('get_search_form', 'custom_searchform'); + __( 'Mega Footer', 'theme_text_domain' ), + 'description' => 'Limited to 6 widgets. Will appear at the bottom of every page in the site.', + 'before_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + 'pages' => array(), + 'children' => 'off', + 'force' => true + ); + update_option('uc_sidebars',$sidebars); + $sidebars['mega-footer']['id'] = 'mega-footer'; + register_sidebar($sidebars['mega-footer']); + } + if(!isset($sidebars['sidebar'])){ + $sidebars['sidebar'] = array( + 'name' => __( 'Default Sidebar', 'theme_text_domain' ), + 'description' => 'Appears with Archives, Search Results, the Blog page template, and when viewing single posts.', + 'class' => 'sidebar', + 'before_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + 'pages' => array(), + 'children' => 'off', + 'force' => true + ); + update_option('uc_sidebars',$sidebars); + $sidebars['sidebar']['id'] = 'sidebar'; + register_sidebar($sidebars['sidebar']); + } + + /*register_sidebar(array( + 'name' => __( 'Sidebar', 'theme_text_domain' ), + 'id' => 'sidebar', + 'description' => 'Appears with Archives, Search Results, the Blog page template, and when viewing single posts.', + 'class' => 'sidebar', + 'before_widget' => '', + 'before_title' => '

', + 'after_title' => '

' + )); + + register_sidebar( array( + 'name' => __( 'Mega Footer' ), + 'id' => 'mega-footer', + 'description' => 'Limited to 6 widgets. Will appear at the bottom of every page in the site.', + 'before_widget' => '', + 'before_title' => '

', + 'after_title' => '

' + ) );*/ + + for($i=1; $i<=30; $i++){ + $sidebars['home'.$i] = array( + 'name' => __( 'Home '.$i, 'theme_text_domain' ), + 'class' => 'sidebar', + 'before_widget' => '', + 'before_title' => '

', + 'after_title' => '

', + 'pages' => array(), + 'children' => 'off', + 'force' => true + ); + update_option('uc_sidebars',$sidebars); + $sidebars['home'.$i]['id'] = 'home'.$i; + register_sidebar($sidebars['home'.$i]); + } +} + + +/** + * Add the options page to the "Appearance" admin menu + * + * @since Unique Page Sidebars 0.1 + */ +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' ); +} +add_action( 'admin_menu', 'uc_options_add_page' ); + +function remove_wp_widgets( $wp_admin_bar ) { + $wp_admin_bar->remove_node( 'widgets' ); +} +add_action( 'admin_bar_menu', 'remove_wp_widgets', 999 ); + +// if no title then add widget content wrapper to before widget +function check_sidebar_params( $params ) { + global $wp_registered_widgets; + + $settings_getter = $wp_registered_widgets[ $params[0]['widget_id'] ]['callback'][0]; + $settings = $settings_getter->get_settings(); + $settings = $settings[ $params[1]['number'] ]; + + if ( $params[0][ 'after_widget' ] == '
' && isset( $settings[ 'title' ] ) && empty( $settings[ 'title' ] ) ){ + $params[0][ 'before_widget' ] .= '
'; + } + + #Counts widgets in mega footer and adds column class accordingly + if( $params[0]['id'] == 'mega-footer' ){ + $sidebars = get_option('sidebars_widgets'); + $widgets = $sidebars['mega-footer']; + $count = count($widgets); + if( $count > 6 ){ + $cols = 2; + } else { + $cols = floor(12 / $count); + } + $params[0]['before_widget'] = str_replace('aside class="', 'aside class="col-sm-' . $cols . ' ', $params[0]['before_widget']); + } + return $params; +} +add_filter( 'dynamic_sidebar_params', 'check_sidebar_params' ); + +function mf_remove_extra( $sidebars_widgets ){ + $widgets = $sidebars_widgets['mega-footer']; + if( is_array($sidebars_widgets['mega-footer']) ){ + foreach ($sidebars_widgets['mega-footer'] as $i => $widget) { + if( $i > 5 ){ + unset($sidebars_widgets['mega-footer'][$i]); + } + } + } + return $sidebars_widgets; +} +add_filter( 'sidebars_widgets', 'mf_remove_extra' ); + +function custom_searchform($form){ + global $search_counter; + if( !$search_counter ){ + $search_counter = 0; + } + $search_counter++; + + $form = '
Search this Site'; + $form .= ''; + $form .= ''; + $form .= ''; + $form .= '
'; + + return $form; +} +add_filter('get_search_form', 'custom_searchform'); ?> \ No newline at end of file diff --git a/js/min/navigation.min.js b/js/min/navigation.min.js index e4ec0e3..aad16bc 100644 --- a/js/min/navigation.min.js +++ b/js/min/navigation.min.js @@ -1 +1 @@ -!function(){var e,n,a;if(e=document.getElementById("site-navigation"),e&&(n=e.getElementsByTagName("button")[0],"undefined"!=typeof n)){if(a=e.getElementsByTagName("ul")[0],"undefined"==typeof a)return n.style.display="none",void 0;-1===a.className.indexOf("nav-menu")&&(a.className+=" nav-menu"),n.onclick=function(){-1!==e.className.indexOf("toggled")?e.className=e.className.replace(" toggled",""):e.className+=" toggled"}}}(); \ No newline at end of file +jQuery(document).ready(function(r){function n(n){r(n).each(function(){var n=r(this).children("a"),t=e(this);n.attr("href",t)})}function e(n){var t=r(n).children("a").attr("href");if("#"==t){var i=r(n).children("ul").children("li").first();return 0==i.length?t:e(i)}return t}n(".menu-item-has-children")}); \ No newline at end of file diff --git a/js/navigation.js b/js/navigation.js old mode 100755 new mode 100644 index 706e4d8..4df536d --- a/js/navigation.js +++ b/js/navigation.js @@ -1,34 +1,67 @@ -/** - * navigation.js - * - * Handles toggling the navigation menu for small screens. - */ -( function() { - var container, button, menu; - - container = document.getElementById( 'site-navigation' ); - if ( ! container ) - return; - - button = container.getElementsByTagName( 'button' )[0]; - if ( 'undefined' === typeof button ) - return; - - menu = container.getElementsByTagName( 'ul' )[0]; - - // Hide menu toggle button if menu is empty and return early. - if ( 'undefined' === typeof menu ) { - button.style.display = 'none'; - return; - } - - if ( -1 === menu.className.indexOf( 'nav-menu' ) ) - menu.className += ' nav-menu'; - - button.onclick = function() { - if ( -1 !== container.className.indexOf( 'toggled' ) ) - container.className = container.className.replace( ' toggled', '' ); - else - container.className += ' toggled'; - }; -} )(); +/** + * navigation.js + * + */ + +jQuery(document).ready(function($) { + + function replaceAnchors(selector) { + $(selector).each(function(){ + var atag = $(this).children('a'); + var newhref = getFirstLink(this); + atag.attr('href',newhref); + }); + } + function getFirstLink(element){ + var href = $(element).children('a').attr('href'); + if(href == '#'){ + var firstChild = $(element).children('ul').children('li').first(); + if(firstChild.length == 0){ + return href; + } + else { + return getFirstLink(firstChild); + } + } + else { + return href; + } + } + + replaceAnchors('.menu-item-has-children'); + +}); + +/* + * Handles toggling the navigation menu for small screens. + * +( function() { + var container, button, menu; + + container = document.getElementById( 'site-navigation' ); + if ( ! container ) + return; + + button = container.getElementsByTagName( 'button' )[0]; + if ( 'undefined' === typeof button ) + return; + + menu = container.getElementsByTagName( 'ul' )[0]; + + // Hide menu toggle button if menu is empty and return early. + if ( 'undefined' === typeof menu ) { + button.style.display = 'none'; + return; + } + + if ( -1 === menu.className.indexOf( 'nav-menu' ) ) + menu.className += ' nav-menu'; + + button.onclick = function() { + if ( -1 !== container.className.indexOf( 'toggled' ) ) + container.className = container.className.replace( ' toggled', '' ); + else + container.className += ' toggled'; + }; +} )(); +*/ \ No newline at end of file