Browse files

More moving and shuffling of files and functions to clean this thing up.

git-svn-id: http://svn.locallylost.com/themes/hybrid-core/trunk@433 dba0f204-706d-4bc1-bc29-8b92e0485636
  • Loading branch information...
1 parent 8d8f1a3 commit 942ca07f19e5b90b9ebc2edd333b0d6d926fac45 greenshady committed Oct 19, 2010
Showing with 129 additions and 150 deletions.
  1. +1 −1 functions/media.php
  2. +0 −12 functions/menus.php
  3. +112 −0 functions/sidebars.php
  4. +9 −133 functions/widgets.php
  5. +7 −4 hybrid.php
View
2 functions/media.php
@@ -22,7 +22,7 @@
*/
function hybrid_debug_stylesheet( $stylesheet_uri, $stylesheet_dir_uri ) {
- /* If SCRIP_DEBUG is set to true and the theme supports 'dev-stylesheet'. */
+ /* If SCRIPT_DEBUG is set to true and the theme supports 'dev-stylesheet'. */
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && current_theme_supports( 'dev-stylesheet' ) ) {
/* Remove the stylesheet directory URI from the file name. */
View
12 functions/menus.php
@@ -25,16 +25,4 @@ function hybrid_register_menus() {
register_nav_menu( 'primary', __( 'Primary Menu', hybrid_get_textdomain() ) );
}
-/**
- * Loads the 'Primary Menu' template file. Users can overwrite menu-primary.php in their child
- * theme folder.
- *
- * @since 0.8.0
- * @uses get_template_part() Checks for template in child and parent theme.
- * @link http://codex.wordpress.org/Function_Reference/get_template_part
- */
-function hybrid_get_primary_menu() {
- get_template_part( 'menu', 'primary' );
-}
-
?>
View
112 functions/sidebars.php
@@ -0,0 +1,112 @@
+<?php
+/**
+ * Sets up the default framework sidebars if the theme supports them. By default, the framework
+ * registers six sidebars. Themes may choose to use or not use these sidebars, create new sidebars, or
+ * unregister individual sidebars. A theme must register support for 'hybrid-core-sidebars' to use them.
+ *
+ * @package HybridCore
+ * @subpackage Functions
+ */
+
+/* Register widget areas. */
+add_action( 'widgets_init', 'hybrid_register_sidebars' );
+
+/**
+ * Registers the default framework dynamic sidebars. Theme developers may optionally choose to support
+ * these sidebars within their themes or add more custom sidebars to the mix.
+ *
+ * @since 0.7.0
+ * @uses register_sidebar() Registers a sidebar with WordPress.
+ * @link http://codex.wordpress.org/Function_Reference/register_sidebar
+ */
+function hybrid_register_sidebars() {
+
+ /* Get the theme textdomain. */
+ $domain = hybrid_get_textdomain();
+
+ /* Set up the primary sidebar arguments. */
+ $primary = array(
+ 'id' => 'primary',
+ 'name' => __( 'Primary', $domain ),
+ 'description' => __( 'The main (primary) widget area, most often used as a sidebar.', $domain ),
+ 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-wrap widget-inside">',
+ 'after_widget' => '</div></div>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>'
+ );
+
+ /* Set up the secondary sidebar arguments. */
+ $secondary = array(
+ 'id' => 'secondary',
+ 'name' => __( 'Secondary', $domain ),
+ 'description' => __( 'The second most important widget area, most often used as a secondary sidebar.', $domain ),
+ 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-wrap widget-inside">',
+ 'after_widget' => '</div></div>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>'
+ );
+
+ /* Set up the subsidiary sidebar arguments. */
+ $subsidiary = array(
+ 'id' => 'subsidiary',
+ 'name' => __( 'Subsidiary', $domain ),
+ 'description' => __( 'A widget area loaded in the footer of the site.', $domain ),
+ 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-wrap widget-inside">',
+ 'after_widget' => '</div></div>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>'
+ );
+
+ /* Set up the before content sidebar arguments. */
+ $before_content = array(
+ 'id' => 'before-content',
+ 'name' => __( 'Before Content', $domain ),
+ 'description' => __( 'Loaded before the page\'s main content area.', $domain ),
+ 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-wrap widget-inside">',
+ 'after_widget' => '</div></div>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>'
+ );
+
+ /* Set up the after content sidebar arguments. */
+ $after_content = array(
+ 'id' => 'after-content',
+ 'name' => __( 'After Content', $domain ),
+ 'description' => __( 'Loaded after the page\'s main content area.', $domain ),
+ 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-wrap widget-inside">',
+ 'after_widget' => '</div></div>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>'
+ );
+
+ /* Set up the after singular sidebar arguments. */
+ $after_singular = array(
+ 'id' => 'after-singular',
+ 'name' => __( 'After Singular', $domain ),
+ 'description' => __( 'Loaded on singular post (page, attachment, etc.) views before the comments area.', $domain ),
+ 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-wrap widget-inside">',
+ 'after_widget' => '</div></div>',
+ 'before_title' => '<h3 class="widget-title">',
+ 'after_title' => '</h3>'
+ );
+
+ /* Register the primary sidebar. */
+ register_sidebar( $primary );
+
+ /* Register the secondary sidebar. */
+ register_sidebar( $secondary );
+
+ /* Register the subsidiary sidebar. */
+ register_sidebar( $subsidiary );
+
+ /* Register the before content sidebar. */
+ register_sidebar( $before_content );
+
+ /* Register the after content sidebar. */
+ register_sidebar( $after_content );
+
+ /* Register the after singular sidebar. */
+ register_sidebar( $after_singular );
+}
+
+?>
View
142 functions/widgets.php
@@ -1,55 +1,20 @@
<?php
/**
- * Widgets and sidebars functions file. The functions here register default sidebars and widgets for the
- * core framework. It also unregisters default WordPress widgets if being replaced by the framework
- * widgets. The framework's widgets are meant to extend the functionality of the base WordPress widgets
- * by offering additional options to the end user. The framework sidebars provide a starting point for theme
- * developers when developing themes off the framework.
+ * Sets up the core framework's widgets and unregisters some of the default WordPress widgets if the
+ * theme supports this feature. The framework's widgets are meant to extend the default WordPress
+ * widgets by giving users highly-customizable widget settings. A theme must register support for the
+ * 'hybrid-core-widgets' feature to use the framework widgets.
*
* @package HybridCore
* @subpackage Functions
*/
-/* Register widget areas. */
-add_action( 'widgets_init', 'hybrid_register_sidebars' );
-
/* Unregister WP widgets. */
add_action( 'widgets_init', 'hybrid_unregister_widgets' );
/* Register Hybrid widgets. */
add_action( 'widgets_init', 'hybrid_register_widgets' );
-/* Disables widget areas. */
-add_filter( 'sidebars_widgets', 'remove_sidebars' );
-
-/**
- * Registers the default framework dynamic sidebars. Theme developers may optionally choose to support
- * these sidebars within their themes or add more custom sidebars to the mix.
- *
- * @since 0.7.0
- * @uses register_sidebar() Registers a sidebar with WordPress.
- * @link http://codex.wordpress.org/Function_Reference/register_sidebar
- */
-function hybrid_register_sidebars() {
-
- /* If the current theme doesn't support the Hybrid Core sidebars, return. */
- if ( !current_theme_supports( 'hybrid-core-sidebars' ) )
- return;
-
- /* Get the theme textdomain. */
- $domain = hybrid_get_textdomain();
-
- /* Register aside widget areas. */
- register_sidebar( array( 'name' => __( 'Primary', $domain ), 'id' => 'primary', 'description' => __( 'The main (primary) widget area, most often used as a sidebar.', $domain ), 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) );
- register_sidebar( array( 'name' => __( 'Secondary', $domain ), 'id' => 'secondary', 'description' => __( 'The second most important widget area, most often used as a secondary sidebar', $domain ), 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) );
- register_sidebar( array( 'name' => __( 'Subsidiary', $domain ), 'id' => 'subsidiary', 'description' => __( 'A widget area loaded in the footer of the site.', $domain ), 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) );
-
- /* Register utility widget areas. */
- register_sidebar( array( 'name' => __( 'Before Content', $domain ), 'id' => 'before-content', 'description' => __( 'Loaded before the page\'s main content area.', $domain ), 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) );
- register_sidebar( array( 'name' => __( 'After Content', $domain ), 'id' => 'after-content', 'description' => __( 'Loaded after the page\'s main content area.', $domain ), 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) );
- register_sidebar( array( 'name' => __( 'After Singular', $domain ), 'id' => 'after-singular', 'description' => __( 'Loaded on singular post (page, attachment, etc.) views before the comments area.', $domain ), 'before_widget' => '<div id="%1$s" class="widget %2$s widget-%2$s"><div class="widget-inside">', 'after_widget' => '</div></div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' ) );
-}
-
/**
* Registers the core frameworks widgets. These widgets typically overwrite the equivalent default WordPress
* widget by extending the available options of the widget.
@@ -60,11 +25,7 @@ function hybrid_register_sidebars() {
*/
function hybrid_register_widgets() {
- /* If the current theme doesn't support the Hybrid Core widgets, return. */
- if ( !current_theme_supports( 'hybrid-core-widgets' ) )
- return;
-
- /* Load each widget file. */
+ /* Load the core framework widget files. */
require_once( trailingslashit( HYBRID_CLASSES ) . 'widget-archives.php' );
require_once( trailingslashit( HYBRID_CLASSES ) . 'widget-authors.php' );
require_once( trailingslashit( HYBRID_CLASSES ) . 'widget-bookmarks.php' );
@@ -75,7 +36,7 @@ function hybrid_register_widgets() {
require_once( trailingslashit( HYBRID_CLASSES ) . 'widget-search.php' );
require_once( trailingslashit( HYBRID_CLASSES ) . 'widget-tags.php' );
- /* Register each widget. */
+ /* Register each of the core framework widgets. */
register_widget( 'Hybrid_Widget_Archives' );
register_widget( 'Hybrid_Widget_Authors' );
register_widget( 'Hybrid_Widget_Bookmarks' );
@@ -89,18 +50,15 @@ function hybrid_register_widgets() {
/**
* Unregister default WordPress widgets that are replaced by the framework's widgets. Widgets that
- * aren't replaced are not unregistered.
+ * aren't replaced by the framework widgets are not unregistered.
*
* @since 0.3.2
- * @uses unregister_widget() Unregisters a preexisting widget.
+ * @uses unregister_widget() Unregisters a registered widget.
* @link http://codex.wordpress.org/Function_Reference/unregister_widget
*/
function hybrid_unregister_widgets() {
- /* If the current theme doesn't support the Hybrid Core widgets, return. */
- if ( !current_theme_supports( 'hybrid-core-widgets' ) )
- return;
-
+ /* Unregister the default WordPress widgets. */
unregister_widget( 'WP_Widget_Archives' );
unregister_widget( 'WP_Widget_Calendar' );
unregister_widget( 'WP_Widget_Categories' );
@@ -112,86 +70,4 @@ function hybrid_unregister_widgets() {
unregister_widget( 'WP_Widget_Tag_Cloud' );
}
-/**
- * Loads the Primary widget area. Users can overwrite 'sidebar-primary.php'.
- *
- * @since 0.2.2
- * @uses get_sidebar() Checks for the template in the child and parent theme.
- */
-function hybrid_get_primary() {
- get_sidebar( 'primary' );
-}
-
-/**
- * Loads the Secondary widget area. Users can overwrite 'sidebar-secondary.php'.
- *
- * @since 0.2.2
- * @uses get_sidebar() Checks for the template in the child and parent theme.
- */
-function hybrid_get_secondary() {
- get_sidebar( 'secondary' );
-}
-
-/**
- * Loads the Subsidiary widget area. Users can overwrite 'sidebar-subsidiary.php'.
- *
- * @since 0.3.1
- * @uses get_sidebar() Checks for the template in the child and parent theme.
- */
-function hybrid_get_subsidiary() {
- get_sidebar( 'subsidiary' );
-}
-
-/**
- * Loads the Utility: Before Content widget area. Users can overwrite
- * 'sidebar-before-content.php' in child themes.
- *
- * @since 0.4.0
- * @uses get_sidebar() Checks for the template in the child and parent theme.
- */
-function hybrid_get_utility_before_content() {
- get_sidebar( 'before-content' );
-}
-
-/**
- * Loads the Utility: After Content widget area. Users can overwrite
- * 'sidebar-after-content.php' in child themes.
- *
- * @since 0.4.0
- * @uses get_sidebar() Checks for the template in the child and parent theme.
- */
-function hybrid_get_utility_after_content() {
- get_sidebar( 'after-content' );
-}
-
-/**
- * Loads the Utility: After Singular widget area. Users can overwrite
- * 'sidebar-after-singular.php' in child themes.
- *
- * @since 0.7.0
- * @uses get_sidebar() Checks for the template in the child and parent theme.
- */
-function hybrid_get_utility_after_singular() {
- get_sidebar( 'after-singular' );
-}
-
-/**
- * Removes all widget areas on the No Widgets page template. We're only going to run
- * it on the No Widgets template. Users that need additional templates without widgets
- * should create a simliar function in their child theme.
- *
- * @since 0.5.0
- * @uses sidebars_widgets Filter to remove all widget areas
- */
-function remove_sidebars( $sidebars_widgets ) {
- global $wp_query;
-
- if ( is_singular() ) {
- $template = get_post_meta( $wp_query->post->ID, "_wp_{$wp_query->post->post_type}_template", true );
- if ( 'no-widgets.php' == $template || "{$wp_query->post->post_type}-no-widgets.php" == $template )
- $sidebars_widgets = array( false );
- }
- return $sidebars_widgets;
-}
-
?>
View
11 hybrid.php
@@ -188,9 +188,6 @@ function functions() {
/* Load the utility functions. */
require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'utility.php' );
- /* Load the widget functions. */
- require_once( trailingslashit( HYBRID_FUNCTIONS ) . 'widgets.php' );
-
/* Load the menus functions if supported. */
require_if_theme_supports( 'hybrid-core-menus', trailingslashit( HYBRID_FUNCTIONS ) . 'menus.php' );
@@ -200,6 +197,12 @@ function functions() {
/* Load the shortcodes if supported. */
require_if_theme_supports( 'hybrid-core-shortcodes', trailingslashit( HYBRID_FUNCTIONS ) . 'shortcodes.php' );
+ /* Load the sidebars if supported. */
+ require_if_theme_supports( 'hybrid-core-sidebars', trailingslashit( HYBRID_FUNCTIONS ) . 'sidebars.php' );
+
+ /* Load the widgets if supported. */
+ require_if_theme_supports( 'hybrid-core-widgets', trailingslashit( HYBRID_FUNCTIONS ) . 'widgets.php' );
+
/* Load the template hierarchy if supported. */
require_if_theme_supports( 'hybrid-core-template-hierarchy', trailingslashit( HYBRID_FUNCTIONS ) . 'template-hierarchy.php' );
@@ -229,7 +232,7 @@ function extensions() {
/* Load the Get the Object extension if supported. */
require_if_theme_supports( 'get-the-object', trailingslashit( HYBRID_EXTENSIONS ) . 'get-the-object.php' );
- /* Load the Pagination extension if supported. */
+ /* Load the Loop Pagination extension if supported. */
require_if_theme_supports( 'loop-pagination', trailingslashit( HYBRID_EXTENSIONS ) . 'loop-pagination.php' );
/* Load the Entry Views extension if supported. */

0 comments on commit 942ca07

Please sign in to comment.