Skip to content
This repository
Browse code

Getting Hybrid Core on this Git thing.

  • Loading branch information...
commit 07779cf6635f7a45d090c90ff368c48deac44c2a 0 parents
Justin Tadlock authored

Showing 77 changed files with 12,717 additions and 0 deletions. Show diff stats Hide diff stats

  1. +132 0 admin/admin.php
  2. +128 0 admin/meta-box-post-seo.php
  3. +133 0 admin/meta-box-post-template.php
  4. +94 0 admin/meta-box-theme-about.php
  5. +74 0 admin/meta-box-theme-footer.php
  6. +300 0 admin/theme-settings.php
  7. +206 0 classes/widget-archives.php
  8. +211 0 classes/widget-authors.php
  9. +326 0 classes/widget-bookmarks.php
  10. +120 0 classes/widget-calendar.php
  11. +287 0 classes/widget-categories.php
  12. +205 0 classes/widget-nav-menu.php
  13. +275 0 classes/widget-pages.php
  14. +171 0 classes/widget-search.php
  15. +307 0 classes/widget-tags.php
  16. +1 0  css/18px.css
  17. +308 0 css/18px.dev.css
  18. +1 0  css/20px.css
  19. +308 0 css/20px.dev.css
  20. +1 0  css/21px.css
  21. +308 0 css/21px.dev.css
  22. +1 0  css/22px.css
  23. +308 0 css/22px.dev.css
  24. +1 0  css/24px.css
  25. +308 0 css/24px.dev.css
  26. +1 0  css/25px.css
  27. +308 0 css/25px.dev.css
  28. +5 0 css/2c-l-fixed.css
  29. +5 0 css/2c-r-fixed.css
  30. +5 0 css/3c-c-fixed.css
  31. +5 0 css/3c-l-fixed.css
  32. +5 0 css/3c-r-fixed.css
  33. +1 0  css/admin.css
  34. +76 0 css/admin.dev.css
  35. +1 0  css/drop-downs.css
  36. +64 0 css/drop-downs.dev.css
  37. +1 0  css/gallery.css
  38. +68 0 css/gallery.dev.css
  39. +5 0 css/holy-grail-fluid.css
  40. +1 0  css/nav-bar.css
  41. +83 0 css/nav-bar.dev.css
  42. +5 0 css/plugins.css
  43. +1 0  css/reset.css
  44. +27 0 css/reset.dev.css
  45. +5 0 css/screen.css
  46. +687 0 extensions/breadcrumb-trail.php
  47. +88 0 extensions/cleaner-caption.php
  48. +166 0 extensions/cleaner-gallery.php
  49. +270 0 extensions/custom-field-series.php
  50. +194 0 extensions/entry-views.php
  51. +544 0 extensions/get-the-image.php
  52. +107 0 extensions/loop-pagination.php
  53. +327 0 extensions/post-stylesheets.php
  54. +553 0 extensions/theme-layouts.php
  55. +233 0 functions/comments.php
  56. +468 0 functions/context.php
  57. +244 0 functions/core-seo.php
  58. +216 0 functions/core.php
  59. +575 0 functions/deprecated.php
  60. +209 0 functions/i18n.php
  61. +247 0 functions/media.php
  62. +49 0 functions/menus.php
  63. +66 0 functions/meta.php
  64. +87 0 functions/settings.php
  65. +474 0 functions/shortcodes.php
  66. +114 0 functions/sidebars.php
  67. +211 0 functions/template-hierarchy.php
  68. +199 0 functions/utility.php
  69. +113 0 functions/widgets.php
  70. +348 0 hybrid.php
  71. BIN  images/pingback.png
  72. BIN  images/trackback.png
  73. +248 0 js/drop-downs.dev.js
  74. +1 0  js/drop-downs.js
  75. +153 0 js/nav-bar.dev.js
  76. +1 0  js/nav-bar.js
  77. +339 0 license.txt
132 admin/admin.php
... ... @@ -0,0 +1,132 @@
  1 +<?php
  2 +/**
  3 + * Theme administration functions used with other components of the framework admin. This file is for
  4 + * setting up any basic features and holding additional admin helper functions.
  5 + *
  6 + * @package HybridCore
  7 + * @subpackage Admin
  8 + * @author Justin Tadlock <justin@justintadlock.com>
  9 + * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
  10 + * @link http://themehybrid.com/hybrid-core
  11 + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  12 + */
  13 +
  14 +/* Add the admin setup function to the 'admin_menu' hook. */
  15 +add_action( 'admin_menu', 'hybrid_admin_setup' );
  16 +
  17 +/**
  18 + * Sets up the adminstration functionality for the framework and themes.
  19 + *
  20 + * @since 1.3.0
  21 + * @return void
  22 + */
  23 +function hybrid_admin_setup() {
  24 +
  25 + /* Load the post meta boxes on the new post and edit post screens. */
  26 + add_action( 'load-post.php', 'hybrid_admin_load_post_meta_boxes' );
  27 + add_action( 'load-post-new.php', 'hybrid_admin_load_post_meta_boxes' );
  28 +
  29 + /* Registers admin stylesheets for the framework. */
  30 + add_action( 'admin_enqueue_scripts', 'hybrid_admin_register_styles', 1 );
  31 +
  32 + /* Loads admin stylesheets for the framework. */
  33 + add_action( 'admin_enqueue_scripts', 'hybrid_admin_enqueue_styles' );
  34 +}
  35 +
  36 +/**
  37 + * Loads the core post meta box files on the 'load-post.php' action hook. Each meta box file is only loaded if
  38 + * the theme declares support for the feature.
  39 + *
  40 + * @since 1.2.0
  41 + * @return void
  42 + */
  43 +function hybrid_admin_load_post_meta_boxes() {
  44 +
  45 + /* Load the SEO post meta box. */
  46 + require_if_theme_supports( 'hybrid-core-seo', trailingslashit( HYBRID_ADMIN ) . 'meta-box-post-seo.php' );
  47 +
  48 + /* Load the post template meta box. */
  49 + require_if_theme_supports( 'hybrid-core-template-hierarchy', trailingslashit( HYBRID_ADMIN ) . 'meta-box-post-template.php' );
  50 +}
  51 +
  52 +/**
  53 + * Registers the framework's 'admin.css' stylesheet file. The function does not load the stylesheet. It merely
  54 + * registers it with WordPress.
  55 + *
  56 + * @since 1.2.0
  57 + * @return void
  58 + */
  59 +function hybrid_admin_register_styles() {
  60 + wp_register_style( 'hybrid-core-admin', trailingslashit( HYBRID_CSS ) . 'admin.css', false, '20110512', 'screen' );
  61 +}
  62 +
  63 +/**
  64 + * Loads the admin.css stylesheet for admin-related features.
  65 + *
  66 + * @since 1.2.0
  67 + * @return void
  68 + */
  69 +function hybrid_admin_enqueue_styles( $hook_suffix ) {
  70 +
  71 + /* Load admin styles if on the widgets screen and the current theme supports 'hybrid-core-widgets'. */
  72 + if ( current_theme_supports( 'hybrid-core-widgets' ) && 'widgets.php' == $hook_suffix )
  73 + wp_enqueue_style( 'hybrid-core-admin' );
  74 +}
  75 +
  76 +/**
  77 + * Function for getting an array of available custom templates with a specific header. Ideally, this function
  78 + * would be used to grab custom singular post (any post type) templates. It is a recreation of the WordPress
  79 + * page templates function because it doesn't allow for other types of templates.
  80 + *
  81 + * @since 0.7.0
  82 + * @param array $args Arguments to check the templates against.
  83 + * @return array $post_templates The array of templates.
  84 + */
  85 +function hybrid_get_post_templates( $args = array() ) {
  86 +
  87 + /* Parse the arguments with the defaults. */
  88 + $args = wp_parse_args( $args, array( 'label' => array( 'Post Template' ) ) );
  89 +
  90 + /* Get theme and templates variables. */
  91 + $themes = get_themes();
  92 + $theme = get_current_theme();
  93 + $templates = $themes[$theme]['Template Files'];
  94 + $post_templates = array();
  95 +
  96 + /* If there's an array of templates, loop through each template. */
  97 + if ( is_array( $templates ) ) {
  98 +
  99 + /* Set up a $base path that we'll use to remove from the file name. */
  100 + $base = array( trailingslashit( get_template_directory() ), trailingslashit( get_stylesheet_directory() ) );
  101 +
  102 + /* Loop through the post templates. */
  103 + foreach ( $templates as $template ) {
  104 +
  105 + /* Remove the base (parent/child theme path) from the template file name. */
  106 + $basename = str_replace( $base, '', $template );
  107 +
  108 + /* Get the template data. */
  109 + $template_data = implode( '', file( $template ) );
  110 +
  111 + /* Make sure the name is set to an empty string. */
  112 + $name = '';
  113 +
  114 + /* Loop through each of the potential labels and see if a match is found. */
  115 + foreach ( $args['label'] as $label ) {
  116 + if ( preg_match( "|{$label}:(.*)$|mi", $template_data, $name ) ) {
  117 + $name = _cleanup_header_comment( $name[1] );
  118 + break;
  119 + }
  120 + }
  121 +
  122 + /* If a post template was found, add its name and file name to the $post_templates array. */
  123 + if ( !empty( $name ) )
  124 + $post_templates[trim( $name )] = $basename;
  125 + }
  126 + }
  127 +
  128 + /* Return array of post templates. */
  129 + return $post_templates;
  130 +}
  131 +
  132 +?>
128 admin/meta-box-post-seo.php
... ... @@ -0,0 +1,128 @@
  1 +<?php
  2 +/**
  3 + * Adds the SEO meta box to the post editing screen for public post types. This feature allows the post author
  4 + * to set a custom title, description, and keywords for the post, which will be viewed on the singular post page.
  5 + * To use this feature, the theme must support the 'hybrid-core-seo' feature. The functions in this file create
  6 + * the SEO meta box and save the settings chosen by the user when the post is saved.
  7 + *
  8 + * @package HybridCore
  9 + * @subpackage Admin
  10 + * @author Justin Tadlock <justin@justintadlock.com>
  11 + * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
  12 + * @link http://themehybrid.com/hybrid-core
  13 + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  14 + */
  15 +
  16 +/* Add the post SEO meta box on the 'add_meta_boxes' hook. */
  17 +add_action( 'add_meta_boxes', 'hybrid_meta_box_post_add_seo', 10, 2 );
  18 +add_action( 'add_meta_boxes', 'hybrid_meta_box_post_remove_seo', 10, 2 );
  19 +
  20 +/* Save the post SEO meta box data on the 'save_post' hook. */
  21 +add_action( 'save_post', 'hybrid_meta_box_post_save_seo', 10, 2 );
  22 +
  23 +/**
  24 + * Adds the post SEO meta box for all public post types.
  25 + *
  26 + * @since 1.2.0
  27 + * @param string $post_type The post type of the current post being edited.
  28 + * @param object $post The current post being edited.
  29 + * @return void
  30 + */
  31 +function hybrid_meta_box_post_add_seo( $post_type, $post ) {
  32 +
  33 + $post_type_object = get_post_type_object( $post_type );
  34 +
  35 + /* Only add meta box if current user can edit, add, or delete meta for the post. */
  36 + if ( ( true === $post_type_object->public ) && ( current_user_can( 'edit_post_meta', $post->ID ) || current_user_can( 'add_post_meta', $post->ID ) || current_user_can( 'delete_post_meta', $post->ID ) ) )
  37 + add_meta_box( 'hybrid-core-post-seo', __( 'SEO', 'hybrid-core' ), 'hybrid_meta_box_post_display_seo', $post_type, 'normal', 'high' );
  38 +}
  39 +
  40 +/**
  41 + * Remove the meta box from some post types.
  42 + *
  43 + * @since 1.3.0
  44 + * @param string $post_type The post type of the current post being edited.
  45 + * @param object $post The current post being edited.
  46 + * @return void
  47 + */
  48 +function hybrid_meta_box_post_remove_seo( $post_type, $post ) {
  49 +
  50 + /* Removes post stylesheets support of the bbPress 'topic' post type. */
  51 + if ( function_exists( 'bbp_get_topic_post_type' ) && bbp_get_topic_post_type() == $post_type )
  52 + remove_meta_box( 'hybrid-core-post-seo', bbp_get_topic_post_type(), 'normal' );
  53 +
  54 + /* Removes post stylesheets support of the bbPress 'reply' post type. */
  55 + elseif ( function_exists( 'bbp_get_reply_post_type' ) && bbp_get_reply_post_type() == $post_type )
  56 + remove_meta_box( 'hybrid-core-post-seo', bbp_get_reply_post_type(), 'normal' );
  57 +}
  58 +
  59 +/**
  60 + * Displays the post SEO meta box.
  61 + *
  62 + * @since 1.2.0
  63 + * @return void
  64 + */
  65 +function hybrid_meta_box_post_display_seo( $object, $box ) {
  66 +
  67 + wp_nonce_field( basename( __FILE__ ), 'hybrid-core-post-seo' ); ?>
  68 +
  69 + <p>
  70 + <label for="hybrid-document-title"><?php _e( 'Document Title:', 'hybrid-core' ); ?></label>
  71 + <br />
  72 + <input type="text" name="hybrid-document-title" id="hybrid-document-title" value="<?php echo esc_attr( get_post_meta( $object->ID, 'Title', true ) ); ?>" size="30" tabindex="30" style="width: 99%;" />
  73 + </p>
  74 +
  75 + <p>
  76 + <label for="hybrid-meta-description"><?php _e( 'Meta Description:', 'hybrid-core' ); ?></label>
  77 + <br />
  78 + <textarea name="hybrid-meta-description" id="hybrid-meta-description" cols="60" rows="2" tabindex="30" style="width: 99%;"><?php echo esc_textarea( get_post_meta( $object->ID, 'Description', true ) ); ?></textarea>
  79 + </p>
  80 +
  81 + <p>
  82 + <label for="hybrid-meta-keywords"><?php _e( 'Meta Keywords:', 'hybrid-core' ); ?></label>
  83 + <br />
  84 + <input type="text" name="hybrid-meta-keywords" id="hybrid-meta-keywords" value="<?php echo esc_attr( get_post_meta( $object->ID, 'Keywords', true ) ); ?>" size="30" tabindex="30" style="width: 99%;" />
  85 + </p>
  86 +<?php }
  87 +
  88 +/**
  89 + * Saves the post SEO meta box settings as post metadata.
  90 + *
  91 + * @since 1.2.0
  92 + * @param int $post_id The ID of the current post being saved.
  93 + * @param int $post The post object currently being saved.
  94 + */
  95 +function hybrid_meta_box_post_save_seo( $post_id, $post ) {
  96 +
  97 + $prefix = hybrid_get_prefix();
  98 +
  99 + /* Verify the nonce before proceeding. */
  100 + if ( !isset( $_POST['hybrid-core-post-seo'] ) || !wp_verify_nonce( $_POST['hybrid-core-post-seo'], basename( __FILE__ ) ) )
  101 + return $post_id;
  102 +
  103 + $meta = array(
  104 + 'Title' => $_POST['hybrid-document-title'],
  105 + 'Description' => $_POST['hybrid-meta-description'],
  106 + 'Keywords' => $_POST['hybrid-meta-keywords']
  107 + );
  108 +
  109 + foreach ( $meta as $meta_key => $new_meta_value ) {
  110 +
  111 + /* Get the meta value of the custom field key. */
  112 + $meta_value = get_post_meta( $post_id, $meta_key, true );
  113 +
  114 + /* If there is no new meta value but an old value exists, delete it. */
  115 + if ( current_user_can( 'delete_post_meta', $post_id, $meta_key ) && '' == $new_meta_value && $meta_value )
  116 + delete_post_meta( $post_id, $meta_key, $meta_value );
  117 +
  118 + /* If a new meta value was added and there was no previous value, add it. */
  119 + elseif ( current_user_can( 'add_post_meta', $post_id, $meta_key ) && $new_meta_value && '' == $meta_value )
  120 + add_post_meta( $post_id, $meta_key, $new_meta_value, true );
  121 +
  122 + /* If the new meta value does not match the old value, update it. */
  123 + elseif ( current_user_can( 'edit_post_meta', $post_id, $meta_key ) && $new_meta_value && $new_meta_value != $meta_value )
  124 + update_post_meta( $post_id, $meta_key, $new_meta_value );
  125 + }
  126 +}
  127 +
  128 +?>
133 admin/meta-box-post-template.php
... ... @@ -0,0 +1,133 @@
  1 +<?php
  2 +/**
  3 + * Adds the template meta box to the post editing screen for public post types. This feature allows users and
  4 + * devs to create custom templates for any post type, not just pages as default in WordPress core. The
  5 + * functions in this file create the template meta box and save the template chosen by the user when the
  6 + * post is saved. This file is only used if the theme supports the 'hybrid-core-template-hierarchy' feature.
  7 + *
  8 + * @package HybridCore
  9 + * @subpackage Admin
  10 + * @author Justin Tadlock <justin@justintadlock.com>
  11 + * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
  12 + * @link http://themehybrid.com/hybrid-core
  13 + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  14 + */
  15 +
  16 +/* Add the post template meta box on the 'add_meta_boxes' hook. */
  17 +add_action( 'add_meta_boxes', 'hybrid_meta_box_post_add_template', 10, 2 );
  18 +add_action( 'add_meta_boxes', 'hybrid_meta_box_post_remove_template', 10, 2 );
  19 +
  20 +/* Save the post template meta box data on the 'save_post' hook. */
  21 +add_action( 'save_post', 'hybrid_meta_box_post_save_template', 10, 2 );
  22 +
  23 +/**
  24 + * Adds the post template meta box for all public post types, excluding the 'page' post type since WordPress
  25 + * core already handles page templates.
  26 + *
  27 + * @since 1.2.0
  28 + * @return void
  29 + */
  30 +function hybrid_meta_box_post_add_template( $post_type, $post ) {
  31 +
  32 + $post_type_object = get_post_type_object( $post_type );
  33 +
  34 + /* Only add meta box if current user can edit, add, or delete meta for the post. */
  35 + if ( ( true === $post_type_object->public ) && ( current_user_can( 'edit_post_meta', $post->ID ) || current_user_can( 'add_post_meta', $post->ID ) || current_user_can( 'delete_post_meta', $post->ID ) ) )
  36 + add_meta_box( 'hybrid-core-post-template', __( 'Template', 'hybrid-core' ), 'hybrid_meta_box_post_display_template', $post_type, 'side', 'default' );
  37 +}
  38 +
  39 +/**
  40 + * Remove the meta box from some post types.
  41 + *
  42 + * @since 1.3.0
  43 + * @param string $post_type The post type of the current post being edited.
  44 + * @param object $post The current post being edited.
  45 + * @return void
  46 + */
  47 +function hybrid_meta_box_post_remove_template( $post_type, $post ) {
  48 +
  49 + /* Removes meta box from pages since this is a built-in WordPress feature. */
  50 + if ( 'page' == $post_type )
  51 + remove_meta_box( 'hybrid-core-post-template', 'page', 'side' );
  52 +
  53 + /* Removes meta box from the bbPress 'topic' post type. */
  54 + elseif ( function_exists( 'bbp_get_topic_post_type' ) && bbp_get_topic_post_type() == $post_type )
  55 + remove_meta_box( 'hybrid-core-post-template', bbp_get_topic_post_type(), 'side' );
  56 +
  57 + /* Removes meta box from the bbPress 'reply' post type. */
  58 + elseif ( function_exists( 'bbp_get_reply_post_type' ) && bbp_get_reply_post_type() == $post_type )
  59 + remove_meta_box( 'hybrid-core-post-template', bbp_get_reply_post_type(), 'side' );
  60 +}
  61 +
  62 +/**
  63 + * Displays the post template meta box.
  64 + *
  65 + * @since 1.2.0
  66 + * @return void
  67 + */
  68 +function hybrid_meta_box_post_display_template( $object, $box ) {
  69 +
  70 + /* Get the post type object. */
  71 + $post_type_object = get_post_type_object( $object->post_type );
  72 +
  73 + /* Get a list of available custom templates for the post type. */
  74 + $templates = hybrid_get_post_templates( array( 'label' => array( "{$post_type_object->labels->singular_name} Template", "{$post_type_object->name} Template" ) ) );
  75 +
  76 + wp_nonce_field( basename( __FILE__ ), 'hybrid-core-post-meta-box-template' ); ?>
  77 +
  78 + <p>
  79 + <?php if ( 0 != count( $templates ) ) { ?>
  80 + <select name="hybrid-post-template" id="hybrid-post-template" class="widefat">
  81 + <option value=""></option>
  82 + <?php foreach ( $templates as $label => $template ) { ?>
  83 + <option value="<?php echo esc_attr( $template ); ?>" <?php selected( esc_attr( get_post_meta( $object->ID, "_wp_{$post_type_object->name}_template", true ) ), esc_attr( $template ) ); ?>><?php echo esc_html( $label ); ?></option>
  84 + <?php } ?>
  85 + </select>
  86 + <?php } else { ?>
  87 + <?php _e( 'No templates exist for this post type.', 'hybrid-core' ); ?>
  88 + <?php } ?>
  89 + </p>
  90 +<?php
  91 +}
  92 +
  93 +/**
  94 + * Saves the post template meta box settings as post metadata.
  95 + *
  96 + * @since 1.2.0
  97 + * @param int $post_id The ID of the current post being saved.
  98 + * @param int $post The post object currently being saved.
  99 + * @return void|int
  100 + */
  101 +function hybrid_meta_box_post_save_template( $post_id, $post ) {
  102 +
  103 + /* Verify the nonce before proceeding. */
  104 + if ( !isset( $_POST['hybrid-core-post-meta-box-template'] ) || !wp_verify_nonce( $_POST['hybrid-core-post-meta-box-template'], basename( __FILE__ ) ) )
  105 + return $post_id;
  106 +
  107 + /* Return here if the template is not set. There's a chance it won't be if the post type doesn't have any templates. */
  108 + if ( !isset( $_POST['hybrid-post-template'] ) )
  109 + return $post_id;
  110 +
  111 + /* Get the posted meta value. */
  112 + $new_meta_value = $_POST['hybrid-post-template'];
  113 +
  114 + /* Set the $meta_key variable based off the post type name. */
  115 + $meta_key = "_wp_{$post->post_type}_template";
  116 +
  117 + /* Get the meta value of the meta key. */
  118 + $meta_value = get_post_meta( $post_id, $meta_key, true );
  119 +
  120 + /* If there is no new meta value but an old value exists, delete it. */
  121 + if ( current_user_can( 'delete_post_meta', $post_id ) && '' == $new_meta_value && $meta_value )
  122 + delete_post_meta( $post_id, $meta_key, $meta_value );
  123 +
  124 + /* If a new meta value was added and there was no previous value, add it. */
  125 + elseif ( current_user_can( 'add_post_meta', $post_id, $meta_key ) && $new_meta_value && '' == $meta_value )
  126 + add_post_meta( $post_id, $meta_key, $new_meta_value, true );
  127 +
  128 + /* If the new meta value does not match the old value, update it. */
  129 + elseif ( current_user_can( 'edit_post_meta', $post_id ) && $new_meta_value && $new_meta_value != $meta_value )
  130 + update_post_meta( $post_id, $meta_key, $new_meta_value );
  131 +}
  132 +
  133 +?>
94 admin/meta-box-theme-about.php
... ... @@ -0,0 +1,94 @@
  1 +<?php
  2 +/**
  3 + * Creates a meta box for the theme settings page, which displays information about the theme. If a child
  4 + * theme is in use, an additional meta box will be added with its information. To use this feature, the theme
  5 + * must support the 'about' argument for 'hybrid-core-theme-settings' feature.
  6 + *
  7 + * @package HybridCore
  8 + * @subpackage Admin
  9 + * @author Justin Tadlock <justin@justintadlock.com>
  10 + * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
  11 + * @link http://themehybrid.com/hybrid-core
  12 + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  13 + */
  14 +
  15 +/* Create the about theme meta box on the 'add_meta_boxes' hook. */
  16 +add_action( 'add_meta_boxes', 'hybrid_meta_box_theme_add_about' );
  17 +
  18 +/**
  19 + * Adds the core about theme meta box to the theme settings page.
  20 + *
  21 + * @since 1.2.0
  22 + * @return void
  23 + */
  24 +function hybrid_meta_box_theme_add_about() {
  25 +
  26 + /* Get theme information. */
  27 + $prefix = hybrid_get_prefix();
  28 + $theme_data = hybrid_get_theme_data();
  29 +
  30 + /* Adds the About box for the parent theme. */
  31 + add_meta_box( 'hybrid-core-about-theme', sprintf( __( 'About %1$s', 'hybrid-core' ), $theme_data['Title'] ), 'hybrid_meta_box_theme_display_about', hybrid_get_settings_page_name(), 'side', 'high' );
  32 +
  33 + /* If the user is using a child theme, add an About box for it. */
  34 + if ( is_child_theme() ) {
  35 + $child_data = hybrid_get_theme_data( 'stylesheet' );
  36 + add_meta_box( 'hybrid-core-about-child', sprintf( __( 'About %1$s', 'hybrid-core' ), $child_data['Title'] ), 'hybrid_meta_box_theme_display_about', hybrid_get_settings_page_name(), 'side', 'high' );
  37 + }
  38 +}
  39 +
  40 +/**
  41 + * Creates an information meta box with no settings about the theme. The meta box will display
  42 + * information about both the parent theme and child theme. If a child theme is active, this function
  43 + * will be called a second time.
  44 + *
  45 + * @since 1.2.0
  46 + * @param object $object Variable passed through the do_meta_boxes() call.
  47 + * @param array $box Specific information about the meta box being loaded.
  48 + * @return void
  49 + */
  50 +function hybrid_meta_box_theme_display_about( $object, $box ) {
  51 +
  52 + /* Get theme information. */
  53 + $prefix = hybrid_get_prefix();
  54 +
  55 + /* Grab theme information for the parent/child theme. */
  56 + $theme_data = ( ( 'hybrid-core-about-child' == $box['id'] ) ? hybrid_get_theme_data( 'stylesheet' ) : hybrid_get_theme_data() ); ?>
  57 +
  58 + <table class="form-table">
  59 + <tr>
  60 + <th>
  61 + <?php _e( 'Theme:', 'hybrid-core' ); ?>
  62 + </th>
  63 + <td>
  64 + <a href="<?php echo $theme_data['URI']; ?>" title="<?php echo $theme_data['Title']; ?>"><?php echo $theme_data['Title']; ?></a>
  65 + </td>
  66 + </tr>
  67 + <tr>
  68 + <th>
  69 + <?php _e( 'Version:', 'hybrid-core' ); ?>
  70 + </th>
  71 + <td>
  72 + <?php echo $theme_data['Version']; ?>
  73 + </td>
  74 + </tr>
  75 + <tr>
  76 + <th>
  77 + <?php _e( 'Author:', 'hybrid-core' ); ?>
  78 + </th>
  79 + <td>
  80 + <?php echo $theme_data['Author']; ?>
  81 + </td>
  82 + </tr>
  83 + <tr>
  84 + <th>
  85 + <?php _e( 'Description:', 'hybrid-core' ); ?>
  86 + </th>
  87 + <td>
  88 + <?php echo $theme_data['Description']; ?>
  89 + </td>
  90 + </tr>
  91 + </table><!-- .form-table --><?php
  92 +}
  93 +
  94 +?>
74 admin/meta-box-theme-footer.php
... ... @@ -0,0 +1,74 @@
300 admin/theme-settings.php
... ... @@ -0,0 +1,300 @@
  1 +<?php
  2 +/**
  3 + * Handles the display and functionality of the theme settings page. This provides the needed hooks and
  4 + * meta box calls for developers to create any number of theme settings needed. This file is only loaded if
  5 + * the theme supports the 'hybrid-core-theme-settings' feature.
  6 + *
  7 + * Provides the ability for developers to add custom meta boxes to the theme settings page by using the
  8 + * add_meta_box() function. Developers should register their meta boxes on the 'add_meta_boxes' hook
  9 + * and register the meta box for 'appearance_page_theme-settings'. To validate/sanitize data from
  10 + * custom settings, devs should use the 'sanitize_option_{$prefix}_theme_settings' filter hook.
  11 + *
  12 + * @package HybridCore
  13 + * @subpackage Admin
  14 + * @author Justin Tadlock <justin@justintadlock.com>
  15 + * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
  16 + * @link http://themehybrid.com/hybrid-core
  17 + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  18 + */
  19 +
  20 +/* Hook the settings page function to 'admin_menu'. */
  21 +add_action( 'admin_menu', 'hybrid_settings_page_init' );
  22 +
  23 +/**
  24 + * Initializes all the theme settings page functionality. This function is used to create the theme settings
  25 + * page, then use that as a launchpad for specific actions that need to be tied to the settings page.
  26 + *
  27 + * @since 0.7.0
  28 + * @global string $hybrid The global theme object.
  29 + * @return void
  30 + */
  31 +function hybrid_settings_page_init() {
  32 + global $hybrid;
  33 +
  34 + /* Get theme information. */
  35 + $theme = hybrid_get_theme_data();
  36 + $prefix = hybrid_get_prefix();
  37 +
  38 + /* Register theme settings. */
  39 + register_setting(
  40 + "{$prefix}_theme_settings", // Options group.
  41 + "{$prefix}_theme_settings", // Database option.
  42 + 'hybrid_save_theme_settings' // Validation callback function.
  43 + );
  44 +
  45 + /* Create the theme settings page. */
  46 + $hybrid->settings_page = add_theme_page(
  47 + sprintf( esc_html__( '%1$s Theme Settings', 'hybrid-core' ), $theme['Name'] ), // Settings page name.
  48 + esc_html__( 'Theme Settings', 'hybrid-core' ), // Menu item name.
  49 + hybrid_settings_page_capability(), // Required capability.
  50 + 'theme-settings', // Screen name.
  51 + 'hybrid_settings_page' // Callback function.
  52 + );
  53 +
  54 + /* Check if the settings page is being shown before running any functions for it. */
  55 + if ( !empty( $hybrid->settings_page ) ) {
  56 +
  57 + /* Filter the settings page capability so that it recognizes the 'edit_theme_options' cap. */
  58 + add_filter( "option_page_capability_{$prefix}_theme_settings", 'hybrid_settings_page_capability' );
  59 +
  60 + /* Add help tabs to the theme settings page. */
  61 + add_action( "load-{$hybrid->settings_page}", 'hybrid_settings_page_help' );
  62 +
  63 + /* Load the theme settings meta boxes. */
  64 + add_action( "load-{$hybrid->settings_page}", 'hybrid_load_settings_page_meta_boxes' );
  65 +
  66 + /* Create a hook for adding meta boxes. */
  67 + add_action( "load-{$hybrid->settings_page}", 'hybrid_settings_page_add_meta_boxes' );
  68 +
  69 + /* Load the JavaScript and stylesheets needed for the theme settings screen. */
  70 + add_action( 'admin_enqueue_scripts', 'hybrid_settings_page_enqueue_scripts' );
  71 + add_action( 'admin_enqueue_scripts', 'hybrid_settings_page_enqueue_styles' );
  72 + add_action( "admin_footer-{$hybrid->settings_page}", 'hybrid_settings_page_load_scripts' );
  73 + }
  74 +}
  75 +
  76 +/**
  77 + * Returns the required capability for viewing and saving theme settings.
  78 + *
  79 + * @since 1.2.0
  80 + * @return string
  81 + */
  82 +function hybrid_settings_page_capability() {
  83 + return apply_filters( hybrid_get_prefix() . '_settings_capability', 'edit_theme_options' );
  84 +}
  85 +
  86 +/**
  87 + * Returns the theme settings page name/hook as a string.
  88 + *
  89 + * @since 1.2.0
  90 + * @return string
  91 + */
  92 +function hybrid_get_settings_page_name() {
  93 + global $hybrid;
  94 +
  95 + return ( isset( $hybrid->settings_page ) ? $hybrid->settings_page : 'appearance_page_theme-settings' );
  96 +}
  97 +
  98 +/**
  99 + * Provides a hook for adding meta boxes as seen on the post screen in the WordPress admin. This addition
  100 + * is needed because normal plugin/theme pages don't have this hook by default. The other goal of this
  101 + * function is to provide a way for themes to load and execute meta box code only on the theme settings
  102 + * page in the admin. This way, they're not needlessly loading extra files.
  103 + *
  104 + * @since 1.2.0
  105 + * @return void
  106 + */
  107 +function hybrid_settings_page_add_meta_boxes() {
  108 +
  109 + do_action( 'add_meta_boxes', hybrid_get_settings_page_name(), hybrid_get_theme_data() );
  110 +}
  111 +
  112 +/**
  113 + * Loads the meta boxes packaged with the framework on the theme settings page. These meta boxes are
  114 + * merely loaded with this function. Meta boxes are only loaded if the feature is supported by the theme.
  115 + *
  116 + * @since 1.2.0
  117 + * @return void
  118 + */
  119 +function hybrid_load_settings_page_meta_boxes() {
  120 +
  121 + /* Get theme-supported meta boxes for the settings page. */
  122 + $supports = get_theme_support( 'hybrid-core-theme-settings' );
  123 +
  124 + /* If there are any supported meta boxes, load them. */
  125 + if ( is_array( $supports[0] ) ) {
  126 +
  127 + /* Load the 'About' meta box if it is supported. */
  128 + if ( in_array( 'about', $supports[0] ) )
  129 + require_once( trailingslashit( HYBRID_ADMIN ) . 'meta-box-theme-about.php' );
  130 +
  131 + /* Load the 'Footer' meta box if it is supported. */
  132 + if ( in_array( 'footer', $supports[0] ) )
  133 + require_once( trailingslashit( HYBRID_ADMIN ) . 'meta-box-theme-footer.php' );
  134 + }
  135 +}
  136 +
  137 +/**
  138 + * Validation/Sanitization callback function for theme settings. This just returns the data passed to it. Theme
  139 + * developers should validate/sanitize their theme settings on the "sanitize_option_{$prefix}_theme_settings"
  140 + * hook. This function merely exists for backwards compatibility.
  141 + *
  142 + * @since 0.7.0
  143 + * @param array $settings An array of the theme settings passed by the Settings API for validation.
  144 + * @return array $settings The array of theme settings.
  145 + */
  146 +function hybrid_save_theme_settings( $settings ) {
  147 +
  148 + /* @deprecated 1.0.0. Developers should filter "sanitize_option_{$prefix}_theme_settings" instead. */
  149 + return apply_filters( hybrid_get_prefix() . '_validate_theme_settings', $settings );
  150 +}
  151 +
  152 +/**
  153 + * Displays the theme settings page and calls do_meta_boxes() to allow additional settings
  154 + * meta boxes to be added to the page.
  155 + *
  156 + * @since 0.7.0
  157 + * @return void
  158 + */
  159 +function hybrid_settings_page() {
  160 +
  161 + /* Get the theme information. */
  162 + $prefix = hybrid_get_prefix();
  163 + $theme_data = hybrid_get_theme_data(); ?>
  164 +
  165 + <div class="wrap">
  166 +
  167 + <?php screen_icon(); ?>
  168 + <h2><?php printf( __( '%1$s Theme Settings', 'hybrid-core' ), $theme_data['Name'] ); ?></h2>
  169 + <?php settings_errors(); ?>
  170 +
  171 + <div class="hybrid-core-settings-wrap">
  172 +
  173 + <form method="post" action="options.php">
  174 +
  175 + <?php settings_fields( "{$prefix}_theme_settings" ); ?>
  176 + <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
  177 + <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
  178 +
  179 + <div class="metabox-holder">
  180 + <div class="post-box-container column-1 normal"><?php do_meta_boxes( hybrid_get_settings_page_name(), 'normal', null ); ?></div>
  181 + <div class="post-box-container column-2 side"><?php do_meta_boxes( hybrid_get_settings_page_name(), 'side', null ); ?></div>
  182 + <div class="post-box-container column-3 advanced"><?php do_meta_boxes( hybrid_get_settings_page_name(), 'advanced', null ); ?></div>
  183 + </div>
  184 +
  185 + <?php submit_button( esc_attr__( 'Update Settings', 'hybrid-core' ) ); ?>
  186 +
  187 + </form>
  188 +
  189 + </div><!-- .hybrid-core-settings-wrap -->
  190 +
  191 + </div><!-- .wrap --><?php
  192 +}
  193 +
  194 +/**
  195 + * Creates a settings field id attribute for use on the theme settings page. This is a helper function for use
  196 + * with the WordPress settings API.
  197 + *
  198 + * @since 1.0.0
  199 + * @return string
  200 + */
  201 +function hybrid_settings_field_id( $setting ) {
  202 + return hybrid_get_prefix() . '_theme_settings-' . sanitize_html_class( $setting );
  203 +}
  204 +
  205 +/**
  206 + * Creates a settings field name attribute for use on the theme settings page. This is a helper function for
  207 + * use with the WordPress settings API.
  208 + *
  209 + * @since 1.0.0
  210 + * @return string
  211 + */
  212 +function hybrid_settings_field_name( $setting ) {
  213 + return hybrid_get_prefix() . "_theme_settings[{$setting}]";
  214 +}
  215 +
  216 +/**
  217 + * Adds a help tab to the theme settings screen if the theme has provided a 'Documentation URI' and/or
  218 + * 'Support URI'. Theme developers can add custom help tabs using get_current_screen()->add_help_tab().
  219 + *
  220 + * @since 1.3.0
  221 + * @return void
  222 + */
  223 +function hybrid_settings_page_help() {
  224 +
  225 + /* Get the parent theme data. */
  226 + $theme = hybrid_get_theme_data();
  227 +
  228 + /* If the theme has provided a documentation or support URI, add them to the help text. */
  229 + if ( !empty( $theme['Documentation URI'] ) || !empty( $theme['Support URI'] ) ) {
  230 +
  231 + /* Open an unordered list for the help text. */
  232 + $help = '<ul>';
  233 +
  234 + /* Add the Documentation URI. */
  235 + if ( !empty( $theme['Documentation URI'] ) )
  236 + $help .= '<li><a href="' . esc_url( $theme['Documentation URI'] ) . '">' . __( 'Documentation', 'hybrid-core' ) . '</a></li>';
  237 +
  238 + /* Add the Support URI. */
  239 + if ( !empty( $theme['Support URI'] ) )
  240 + $help .= '<li><a href="' . esc_url( $theme['Support URI'] ) . '">' . __( 'Support', 'hybrid-core' ) . '</a></li>';
  241 +
  242 + /* Close the unordered list for the help text. */
  243 + $help .= '</ul>';
  244 +
  245 + /* Add a help tab with links for documentation and support. */
  246 + get_current_screen()->add_help_tab(
  247 + array(
  248 + 'id' => 'default',
  249 + 'title' => esc_attr( $theme['Name'] ),
  250 + 'content' => $help
  251 + )
  252 + );
  253 + }
  254 +}
  255 +
  256 +/**
  257 + * Loads the required stylesheets for displaying the theme settings page in the WordPress admin.
  258 + *
  259 + * @since 1.2.0
  260 + * @return void
  261 + */
  262 +function hybrid_settings_page_enqueue_styles( $hook_suffix ) {
  263 +
  264 + /* Load admin stylesheet if on the theme settings screen. */
  265 + if ( $hook_suffix == hybrid_get_settings_page_name() )
  266 + wp_enqueue_style( 'hybrid-core-admin' );
  267 +}
  268 +
  269 +/**
  270 + * Loads the JavaScript files required for managing the meta boxes on the theme settings
  271 + * page, which allows users to arrange the boxes to their liking.
  272 + *
  273 + * @since 1.2.0
  274 + * @param string $hook_suffix The current page being viewed.
  275 + * @return void
  276 + */
  277 +function hybrid_settings_page_enqueue_scripts( $hook_suffix ) {
  278 +
  279 + if ( $hook_suffix == hybrid_get_settings_page_name() )
  280 + wp_enqueue_script( 'postbox' );
  281 +}
  282 +
  283 +/**
  284 + * Loads the JavaScript required for toggling the meta boxes on the theme settings page.
  285 + *
  286 + * @since 0.7.0
  287 + * @return void
  288 + */
  289 +function hybrid_settings_page_load_scripts() { ?>
  290 + <script type="text/javascript">
  291 + //<![CDATA[
  292 + jQuery(document).ready( function($) {
  293 + $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
  294 + postboxes.add_postbox_toggles( '<?php echo hybrid_get_settings_page_name(); ?>' );
  295 + });
  296 + //]]>
  297 + </script><?php
  298 +}
  299 +
  300 +?>
206 classes/widget-archives.php
... ... @@ -0,0 +1,206 @@
  1 +<?php
  2 +/**
  3 + * The Archives widget replaces the default WordPress Archives widget. This version gives total
  4 + * control over the output to the user by allowing the input of all the arguments typically seen
  5 + * in the wp_get_archives() function.
  6 + *
  7 + * @package Hybrid
  8 + * @subpackage Classes
  9 + * @author Justin Tadlock <justin@justintadlock.com>
  10 + * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
  11 + * @link http://themehybrid.com/hybrid-core
  12 + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  13 + */
  14 +
  15 +/**
  16 + * Archives widget class.
  17 + *
  18 + * @since 0.6.0
  19 + */
  20 +class Hybrid_Widget_Archives extends WP_Widget {
  21 +
  22 + /**
  23 + * Set up the widget's unique name, ID, class, description, and other options.
  24 + *
  25 + * @since 1.2.0
  26 + */
  27 + function __construct() {
  28 +
  29 + /* Set up the widget options. */
  30 + $widget_options = array(
  31 + 'classname' => 'archives',
  32 + 'description' => esc_html__( 'An advanced widget that gives you total control over the output of your archives.', 'hybrid-core' )
  33 + );
  34 +
  35 + /* Set up the widget control options. */
  36 + $control_options = array(
  37 + 'width' => 525,
  38 + 'height' => 350
  39 + );
  40 +
  41 + /* Create the widget. */
  42 + $this->WP_Widget(
  43 + 'hybrid-archives', // $this->id_base
  44 + __( 'Archives', 'hybrid-core' ), // $this->name
  45 + $widget_options, // $this->widget_options
  46 + $control_options // $this->control_options
  47 + );
  48 + }
  49 +
  50 + /**
  51 + * Outputs the widget based on the arguments input through the widget controls.
  52 + *
  53 + * @since 0.6.0
  54 + */
  55 + function widget( $sidebar, $instance ) {
  56 + extract( $sidebar );
  57 +
  58 + /* Set the $args for wp_get_archives() to the $instance array. */
  59 + $args = $instance;
  60 +
  61 + /* Overwrite the $echo argument and set it to false. */
  62 + $args['echo'] = false;
  63 +
  64 + /* Output the theme's $before_widget wrapper. */
  65 + echo $before_widget;
  66 +
  67 + /* If a title was input by the user, display it. */
  68 + if ( !empty( $instance['title'] ) )
  69 + echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
  70 +
  71 + /* Get the archives list. */
  72 + $archives = str_replace( array( "\r", "\n", "\t" ), '', wp_get_archives( $args ) );
  73 +
  74 + /* If the archives should be shown in a <select> drop-down. */
  75 + if ( 'option' == $args['format'] ) {
  76 +
  77 + /* Create a title for the drop-down based on the archive type. */
  78 + if ( 'yearly' == $args['type'] )
  79 + $option_title = esc_html__( 'Select Year', 'hybrid-core' );
  80 +
  81 + elseif ( 'monthly' == $args['type'] )
  82 + $option_title = esc_html__( 'Select Month', 'hybrid-core' );
  83 +
  84 + elseif ( 'weekly' == $args['type'] )
  85 + $option_title = esc_html__( 'Select Week', 'hybrid-core' );
  86 +
  87 + elseif ( 'daily' == $args['type'] )
  88 + $option_title = esc_html__( 'Select Day', 'hybrid-core' );
  89 +
  90 + elseif ( 'postbypost' == $args['type'] || 'alpha' == $args['type'] )
  91 + $option_title = esc_html__( 'Select Post', 'hybrid-core' );
  92 +
  93 + /* Output the <select> element and each <option>. */
  94 + echo '<p><select name="archive-dropdown" onchange=\'document.location.href=this.options[this.selectedIndex].value;\'>';
  95 + echo '<option value="">' . $option_title . '</option>';
  96 + echo $archives;
  97 + echo '</select></p>';
  98 + }
  99 +
  100 + /* If the format should be an unordered list. */
  101 + elseif ( 'html' == $args['format'] ) {
  102 + echo '<ul class="xoxo archives">' . $archives . '</ul><!-- .xoxo .archives -->';
  103 + }
  104 +
  105 + /* All other formats. */
  106 + else {
  107 + echo $archives;
  108 + }
  109 +
  110 + /* Close the theme's widget wrapper. */
  111 + echo $after_widget;
  112 + }
  113 +
  114 + /**
  115 + * Updates the widget control options for the particular instance of the widget.
  116 + *
  117 + * @since 0.6.0
  118 + */
  119 + function update( $new_instance, $old_instance ) {
  120 +
  121 + $instance = $new_instance;
  122 +
  123 + $instance['title'] = strip_tags( $new_instance['title'] );
  124 + $instance['before'] = strip_tags( $new_instance['before'] );
  125 + $instance['after'] = strip_tags( $new_instance['after'] );
  126 + $instance['limit'] = strip_tags( $new_instance['limit'] );
  127 + $instance['show_post_count'] = ( isset( $new_instance['show_post_count'] ) ? 1 : 0 );
  128 +
  129 + return $instance;
  130 + }
  131 +
  132 + /**
  133 + * Displays the widget control options in the Widgets admin screen.
  134 + *
  135 + * @since 0.6.0
  136 + */
  137 + function form( $instance ) {
  138 +
  139 + /* Set up the default form values. */
  140 + $defaults = array(
  141 + 'title' => esc_attr__( 'Archives', 'hybrid-core' ),
  142 + 'limit' => 10,
  143 + 'type' => 'monthly',
  144 + 'format' => 'html',
  145 + 'before' => '',
  146 + 'after' => '',
  147 + 'show_post_count' => false
  148 + );
  149 +
  150 + /* Merge the user-selected arguments with the defaults. */
  151 + $instance = wp_parse_args( (array) $instance, $defaults );
  152 +
  153 + /* Create an array of archive types. */
  154 + $type = array( 'alpha' => esc_attr__( 'Alphabetical', 'hybrid-core' ), 'daily' => esc_attr__( 'Daily', 'hybrid-core' ), 'monthly' => esc_attr__( 'Monthly', 'hybrid-core' ),'postbypost' => esc_attr__( 'Post By Post', 'hybrid-core' ), 'weekly' => esc_attr__( 'Weekly', 'hybrid-core' ), 'yearly' => esc_attr__( 'Yearly', 'hybrid-core' ) );
  155 +
  156 + /* Create an array of archive formats. */
  157 + $format = array( 'custom' => esc_attr__( 'Custom', 'hybrid-core' ), 'html' => esc_attr__( 'HTML', 'hybrid-core' ), 'option' => esc_attr__( 'Option', 'hybrid-core' ) );
  158 + ?>
  159 +
  160 + <div class="hybrid-widget-controls columns-2">
  161 + <p>
  162 + <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'hybrid-core' ); ?></label>
  163 + <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" />
  164 + </p>
  165 + <p>
  166 + <label for="<?php echo $this->get_field_id( 'limit' ); ?>"><code>limit</code></label>
  167 + <input type="text" class="smallfat code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" value="<?php echo esc_attr( $instance['limit'] ); ?>" />
  168 + </p>
  169 + <p>
  170 + <label for="<?php echo $this->get_field_id( 'type' ); ?>"><code>type</code></label>
  171 + <select class="widefat" id="<?php echo $this->get_field_id( 'type' ); ?>" name="<?php echo $this->get_field_name( 'type' ); ?>">
  172 + <?php foreach ( $type as $option_value => $option_label ) { ?>
  173 + <option value="<?php echo esc_attr( $option_value ); ?>" <?php selected( $instance['type'], $option_value ); ?>><?php echo esc_html( $option_label ); ?></option>
  174 + <?php } ?>
  175 + </select>
  176 + </p>
  177 + <p>
  178 + <label for="<?php echo $this->get_field_id( 'format' ); ?>"><code>format</code></label>
  179 + <select class="widefat" id="<?php echo $this->get_field_id( 'format' ); ?>" name="<?php echo $this->get_field_name( 'format' ); ?>">
  180 + <?php foreach ( $format as $option_value => $option_label ) { ?>
  181 + <option value="<?php echo esc_attr( $option_value ); ?>" <?php selected( $instance['format'], $option_value ); ?>><?php echo esc_html( $option_label ); ?></option>
  182 + <?php } ?>
  183 + </select>
  184 + </p>
  185 + </div>
  186 +
  187 + <div class="hybrid-widget-controls columns-2 column-last">
  188 + <p>
  189 + <label for="<?php echo $this->get_field_id( 'before' ); ?>"><code>before</code></label>
  190 + <input type="text" class="widefat code" id="<?php echo $this->get_field_id( 'before' ); ?>" name="<?php echo $this->get_field_name( 'before' ); ?>" value="<?php echo esc_attr( $instance['before'] ); ?>" />
  191 + </p>
  192 + <p>
  193 + <label for="<?php echo $this->get_field_id( 'after' ); ?>"><code>after</code></label>
  194 + <input type="text" class="widefat code" id="<?php echo $this->get_field_id( 'after' ); ?>" name="<?php echo $this->get_field_name( 'after' ); ?>" value="<?php echo esc_attr( $instance['after'] ); ?>" />
  195 + </p>
  196 + <p>
  197 + <label for="<?php echo $this->get_field_id( 'show_post_count' ); ?>">
  198 + <input class="checkbox" type="checkbox" <?php checked( $instance['show_post_count'], true ); ?> id="<?php echo $this->get_field_id( 'show_post_count' ); ?>" name="<?php echo $this->get_field_name( 'show_post_count' ); ?>" /> <?php _e( 'Show post count?', 'hybrid-core' ); ?> <code>show_post_count</code></label>
  199 + </p>
  200 + </div>
  201 + <div style="clear:both;">&nbsp;</div>
  202 + <?php
  203 + }
  204 +}
  205 +
  206 +?>
211 classes/widget-authors.php
... ... @@ -0,0 +1,211 @@
  1 +<?php
  2 +/**
  3 + * The authors widget was created to give users the ability to list the authors of their blog because
  4 + * there was no equivalent WordPress widget that offered the functionality. This widget allows full
  5 + * control over its output by giving access to the parameters of wp_list_authors().
  6 + *
  7 + * @package Hybrid
  8 + * @subpackage Classes
  9 + * @author Justin Tadlock <justin@justintadlock.com>
  10 + * @copyright Copyright (c) 2008 - 2012, Justin Tadlock
  11 + * @link http://themehybrid.com/hybrid-core
  12 + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  13 + */
  14 +
  15 +/**
  16 + * Authors Widget Class
  17 + *
  18 + * @since 0.6.0
  19 + */
  20 +class Hybrid_Widget_Authors extends WP_Widget {
  21 +
  22 + /**
  23 + * Set up the widget's unique name, ID, class, description, and other options.
  24 + *
  25 + * @since 1.2.0
  26 + */
  27 + function __construct() {
  28 +
  29 + /* Set up the widget options. */
  30 + $widget_options = array(
  31 + 'classname' => 'authors',
  32 + 'description' => esc_html__( 'An advanced widget that gives you total control over the output of your author lists.', 'hybrid-core' )
  33 + );
  34 +
  35 + /* Set up the widget control options. */
  36 + $control_options = array(
  37 + 'width' => 525,
  38 + 'height' => 350
  39 + );
  40 +
  41 + /* Create the widget. */
  42 + $this->WP_Widget(
  43 + 'hybrid-authors', // $this->id_base
  44 + __( 'Authors', 'hybrid-core' ), // $this->name