Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge the "classes" and "functions" folders into a new folder called …

…"includes".
  • Loading branch information...
commit 703728fb1b53de476b397b6cd9b6c01c2c3a0276 1 parent 5c2fb36
@justintadlock authored
View
10 functions.php
@@ -47,11 +47,11 @@ function news_theme_setup() {
$prefix = hybrid_get_prefix();
/* Load shortcodes file. */
- require_once( trailingslashit( THEME_DIR ) . 'functions/shortcodes.php' );
+ require_once( trailingslashit( THEME_DIR ) . 'includes/shortcodes.php' );
/* Load admin functions. */
if ( is_admin() )
- require_once( trailingslashit( THEME_DIR ) . 'functions/admin.php' );
+ require_once( trailingslashit( THEME_DIR ) . 'includes/admin.php' );
/* Add theme support for WordPress features. */
add_theme_support( 'automatic-feed-links' );
@@ -145,16 +145,16 @@ function news_register_widgets() {
/* Load the popular tabs widget. */
if ( current_theme_supports( 'entry-views' ) ) {
- require_once( trailingslashit( THEME_DIR ) . 'classes/widget-popular-tabs.php' );
+ require_once( trailingslashit( THEME_DIR ) . 'includes/widget-popular-tabs.php' );
register_widget( 'News_Widget_Popular_Tabs' );
}
/* Load the image stream widget. */
- require_once( trailingslashit( THEME_DIR ) . 'classes/widget-image-stream.php' );
+ require_once( trailingslashit( THEME_DIR ) . 'includes/widget-image-stream.php' );
register_widget( 'News_Widget_Image_Stream' );
/* Load the newsletter widget. */
- require_once( trailingslashit( THEME_DIR ) . 'classes/widget-newsletter.php' );
+ require_once( trailingslashit( THEME_DIR ) . 'includes/widget-newsletter.php' );
register_widget( 'News_Widget_Newsletter' );
}
View
172 functions/admin.php → includes/admin.php
@@ -1,87 +1,87 @@
-<?php
-/**
- * Admin functions.
- *
- * @package News
- * @subpackage Functions
- */
-
-add_action( 'admin_menu', 'news_admin_setup', 11 );
-
-/**
- * Sets up the admin functionality for the News theme.
- *
- * @since 0.2.0
- */
-function news_admin_setup() {
-
- $prefix = hybrid_get_prefix();
- $settings_page = hybrid_get_settings_page_name();
-
- /* Load theme settings meta boxes. */
- add_action( "load-{$settings_page}", 'news_create_settings_meta_boxes' );
-
- /* Validate theme settings. */
- add_filter( "sanitize_option_{$prefix}_theme_settings", 'news_validate_theme_settings' );
-}
-
-/**
- * Validates the theme settings.
- *
- * @since 0.1.0
- */
-function news_validate_theme_settings( $settings ) {
-
- $settings['home_template_categories'] = ( ( isset( $settings['home_template_categories'] ) && is_array( $settings['home_template_categories'] ) ) ? array_map( 'absint', $settings['home_template_categories'] ) : array() );
-
- return $settings;
-}
-
-/**
- * Add meta boxes to the theme settings page.
- *
- * @since 0.1.0
- */
-function news_create_settings_meta_boxes() {
- add_meta_box( "news-home-template-meta-box", __( 'Home Page Template Settings', 'news' ), 'news_home_template_theme_meta_box', 'appearance_page_theme-settings', 'normal', 'low' );
- }
-
-/**
- * Display the home template meta box.
- *
- * @since 0.1.0
- */
-function news_home_template_theme_meta_box() {
- $prefix = hybrid_get_prefix();
-
- /* Settings used. */
- $category_highlight = hybrid_get_setting( 'home_template_categories' );
-
- /* Get categories. */
- $categories = get_categories(); ?>
-
- <table class="form-table">
-
- <tr>
- <th><?php _e( 'About:', 'news' ); ?></th>
- <td>
- <?php _e( 'Settings used on pages that use the "Home" page template. This template must be assigned to a page before its settings take effect.', 'news' ); ?>
- </td>
- </tr>
- <tr>
- <th><label for="<?php echo hybrid_settings_field_id( 'home_template_categories' ); ?>"><?php _e( 'Category Highlight:', 'news' ); ?></label></th>
- <td>
- <label for="<?php echo hybrid_settings_field_id( 'home_template_categories' ); ?>"><?php _e( 'Categories to show blog posts from in the category highlight section. Multiple categories may be chosen by holding the <code>Ctrl</code> key and selecting.', 'news' ); ?></label>
- <br />
- <select id="<?php echo hybrid_settings_field_id( 'home_template_categories' ); ?>" name="<?php echo hybrid_settings_field_name( 'home_template_categories' ); ?>[]" multiple="multiple" style="height:150px;">
- <?php foreach( $categories as $cat ) { ?>
- <option value="<?php echo $cat->term_id; ?>" <?php if ( is_array( $category_highlight ) && in_array( $cat->term_id, $category_highlight ) ) echo ' selected="selected"'; ?>><?php echo esc_html( $cat->name ); ?></option>
- <?php } ?>
- </select>
- </td>
- </tr>
-
- </table><?php
-}
-
+<?php
+/**
+ * Admin functions.
+ *
+ * @package News
+ * @subpackage Functions
+ */
+
+add_action( 'admin_menu', 'news_admin_setup', 11 );
+
+/**
+ * Sets up the admin functionality for the News theme.
+ *
+ * @since 0.2.0
+ */
+function news_admin_setup() {
+
+ $prefix = hybrid_get_prefix();
+ $settings_page = hybrid_get_settings_page_name();
+
+ /* Load theme settings meta boxes. */
+ add_action( "load-{$settings_page}", 'news_create_settings_meta_boxes' );
+
+ /* Validate theme settings. */
+ add_filter( "sanitize_option_{$prefix}_theme_settings", 'news_validate_theme_settings' );
+}
+
+/**
+ * Validates the theme settings.
+ *
+ * @since 0.1.0
+ */
+function news_validate_theme_settings( $settings ) {
+
+ $settings['home_template_categories'] = ( ( isset( $settings['home_template_categories'] ) && is_array( $settings['home_template_categories'] ) ) ? array_map( 'absint', $settings['home_template_categories'] ) : array() );
+
+ return $settings;
+}
+
+/**
+ * Add meta boxes to the theme settings page.
+ *
+ * @since 0.1.0
+ */
+function news_create_settings_meta_boxes() {
+ add_meta_box( "news-home-template-meta-box", __( 'Home Page Template Settings', 'news' ), 'news_home_template_theme_meta_box', 'appearance_page_theme-settings', 'normal', 'low' );
+ }
+
+/**
+ * Display the home template meta box.
+ *
+ * @since 0.1.0
+ */
+function news_home_template_theme_meta_box() {
+ $prefix = hybrid_get_prefix();
+
+ /* Settings used. */
+ $category_highlight = hybrid_get_setting( 'home_template_categories' );
+
+ /* Get categories. */
+ $categories = get_categories(); ?>
+
+ <table class="form-table">
+
+ <tr>
+ <th><?php _e( 'About:', 'news' ); ?></th>
+ <td>
+ <?php _e( 'Settings used on pages that use the "Home" page template. This template must be assigned to a page before its settings take effect.', 'news' ); ?>
+ </td>
+ </tr>
+ <tr>
+ <th><label for="<?php echo hybrid_settings_field_id( 'home_template_categories' ); ?>"><?php _e( 'Category Highlight:', 'news' ); ?></label></th>
+ <td>
+ <label for="<?php echo hybrid_settings_field_id( 'home_template_categories' ); ?>"><?php _e( 'Categories to show blog posts from in the category highlight section. Multiple categories may be chosen by holding the <code>Ctrl</code> key and selecting.', 'news' ); ?></label>
+ <br />
+ <select id="<?php echo hybrid_settings_field_id( 'home_template_categories' ); ?>" name="<?php echo hybrid_settings_field_name( 'home_template_categories' ); ?>[]" multiple="multiple" style="height:150px;">
+ <?php foreach( $categories as $cat ) { ?>
+ <option value="<?php echo $cat->term_id; ?>" <?php if ( is_array( $category_highlight ) && in_array( $cat->term_id, $category_highlight ) ) echo ' selected="selected"'; ?>><?php echo esc_html( $cat->name ); ?></option>
+ <?php } ?>
+ </select>
+ </td>
+ </tr>
+
+ </table><?php
+}
+
?>
View
448 functions/shortcodes.php → includes/shortcodes.php
@@ -1,225 +1,225 @@
-<?php
-/**
- * Additional shortcodes for use within the theme.
- *
- * @package News
- * @subpackage Functions
- */
-
-/**
- * Registers new shortcodes.
- *
- * @since 0.1.0
- */
-function news_register_shortcodes() {
- add_shortcode( 'slideshow', 'news_slideshow_shortcode' );
- add_shortcode( 'entry-popup-shortlink', 'news_entry_shortlink_popup_shortcode' );
- add_shortcode( 'entry-print-link', 'news_entry_print_link_shortcode' );
- add_shortcode( 'entry-email-link', 'news_entry_email_link_shortcode' );
- add_shortcode( 'entry-mixx-link', 'news_entry_mixx_link_shortcode' );
- add_shortcode( 'entry-delicious-link', 'news_entry_delicious_link_shortcode' );
- add_shortcode( 'entry-digg-link', 'news_entry_digg_link_shortcode' );
- add_shortcode( 'entry-facebook-link', 'news_entry_facebook_link_shortcode' );
- add_shortcode( 'entry-twitter-link', 'news_entry_twitter_link_shortcode' );
-}
-
-/**
- * Shortlink popup shortcode.
- *
- * @since 0.1.0
- */
-function news_entry_shortlink_popup_shortcode() {
- $shortlink = wp_get_shortlink( get_the_ID() );
-
- if ( empty( $shortlink ) )
- return '';
-
- $id = 'shortlink-' . get_the_ID();
- $title = sprintf( __( "Shortlink for '%s'", 'news' ), get_the_title() );
- $out = '<a class="tips shortlink hide-if-no-js" rel="#' . $id . '" title="' . esc_attr( $title ) . '">' . __( 'Shortlink', 'news' ) . '</a>';
- $out .= ' <div id="' . $id . '" class="tip hide">';
- $out .= '<input type="text" value="' . esc_url( $shortlink ) . '" onclick="this.focus(); this.select();" />';
- $out .= '</div>';
-
- return $out;
-}
-
-/**
- * Print link shortcode.
- *
- * @since 0.1.0
- */
-function news_entry_print_link_shortcode() {
- return '<a class="print-link hide-if-no-js" href="#">' . __( 'Print', 'news' ) . '</a>';
-}
-
-/**
- * Email link shortcode.
- *
- * @since 0.1.0
- */
-function news_entry_email_link_shortcode() {
- $subject = urlencode( esc_attr( '[' . get_bloginfo( 'name' ) . ']' . the_title_attribute( 'echo=0' ) ) );
- $body = urlencode( esc_attr( sprintf( __( 'Check out this post: %1$s', 'news' ), get_permalink( get_the_ID() ) ) ) );
- return '<a class="email-link" href="mailto:?subject=' . $subject . '&amp;body=' . $body . '">' . __( 'Email', 'news' ) . '</a>';
-}
-
-/**
- * Mixx link shortcode.
- *
- * @since 0.1.0
- */
-function news_entry_mixx_link_shortcode() {
- return '<a href="http://www.mixx.com" onclick="window.location=\'http://www.mixx.com/submit?page_url=\'+window.location; return false;">' . __( 'Mixx', 'news' ) . '</a>';
-}
-
-/**
- * Delicious link shortcode.
- *
- * @since 0.1.0
- */
-function news_entry_delicious_link_shortcode() {
- return '<a href="http://delicious.com/save" onclick="window.open(\'http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url=\'+encodeURIComponent(\'' . get_permalink() . '\')+\'&amp;title=\'+encodeURIComponent(\'' . the_title_attribute( 'echo=0' ) . '\'),\'delicious\', \'toolbar=no,width=550,height=550\'); return false;">' . __( 'Delicious', 'news' ) . '</a>';
-}
-
-/**
- * Digg link shortcode.
- * @note This won't work from your computer (http://localhost). Must be a live site.
- *
- * @since 0.1.0
- */
-function news_entry_digg_link_shortcode() {
- $url = esc_url( 'http://digg.com/submit?phase=2&amp;url=' . urlencode( get_permalink( get_the_ID() ) ) . '&amp;title="' . urlencode( the_title_attribute( 'echo=0' ) ) );
-
- return '<a href="' . $url . '" title="' . __( 'Digg this entry', 'news' ) . '">Digg</a>';
-}
-
-/**
- * Facebook share link shortcode.
- *
- * @todo Figure out why this doesn't work.
- *
- * @since 0.1.0
- */
-function news_entry_facebook_link_shortcode() {
- $url = esc_url( 'http://facebook.com/sharer.php?u=' . urlencode( get_permalink( get_the_ID() ) ) . '&amp;t=' . urlencode( the_title_attribute( 'echo=0' ) ) );
-
- return '<a href="' . $url . '" title="' . __( 'Share this entry on Facebook', 'news' ) . '">' . __( 'Facebook', 'news' ) . '</a>';
-}
-
-/**
- * Twitter link shortcode.
- *
- * @since 0.1.0
- */
-function news_entry_twitter_link_shortcode() {
-
- $post_id = get_the_ID();
-
- $post_type = get_post_type( $post_id );
-
- if ( 'post' == $post_type || 'page' == $post_type || 'attachment' == $post_type )
- $shortlink = wp_get_shortlink( $post_id );
- else
- $shortlink = get_permalink( $post_id );
-
- $url = esc_url( 'http://twitter.com/home?status=' . urlencode( sprintf( __( 'Currently reading %1$s', 'news' ), $shortlink ) ) );
- return '<a href="' . $url . '" title="' . __( 'Share this entry on Twitter', 'news' ) . '">' . __( 'Twitter', 'news' ) . '</a>';
-}
-
-/**
- * Slideshow shortcode.
- *
- * @since 0.1.0
- */
-function news_slideshow_shortcode( $attr ) {
- global $post;
-
- /* Set up the defaults for the slideshow shortcode. */
- $defaults = array(
- 'order' => 'ASC',
- 'orderby' => 'menu_order ID',
- 'id' => $post->ID,
- 'size' => 'news-slideshow',
- 'include' => '',
- 'exclude' => '',
- 'numberposts' => -1,
- );
- $attr = shortcode_atts( $defaults, $attr );
-
- /* Allow users to overwrite the default args. */
- extract( apply_atomic( 'slideshow_shortcode_args', $attr ) );
-
- /* Arguments for get_children(). */
- $children = array(
- 'post_parent' => intval( $id ),
- 'post_status' => 'inherit',
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'order' => $order,
- 'orderby' => $orderby,
- 'exclude' => absint( $exclude ),
- 'include' => absint( $include ),
- 'numberposts' => intval( $numberposts ),
- );
-
- /* Get image attachments. If none, return. */
- $attachments = get_children( $children );
-
- if ( empty( $attachments ) )
- return '';
-
- /* If is feed, leave the default WP settings. We're only worried about on-site presentation. */
- if ( is_feed() ) {
- $output = "\n";
- foreach ( $attachments as $id => $attachment )
- $output .= wp_get_attachment_link( $id, $size, true ) . "\n";
- return $output;
- }
-
- $slideshow = '<div class="slideshow-set"><div class="slideshow-items">';
-
- $i = 0;
-
- foreach ( $attachments as $attachment ) {
-
- /* Open item. */
- $slideshow .= '<div class="slideshow-item item item-' . ++$i . '">';
-
- /* Get image. */
- $slideshow .= wp_get_attachment_link( $attachment->ID, $size, true, false );
-
- /* Check for caption. */
- if ( !empty( $attachment->post_excerpt ) )
- $caption = $attachment->post_excerpt;
- elseif ( !empty( $attachment->post_content ) )
- $caption = $attachment->post_content;
- else
- $caption = '';
-
- if ( !empty( $caption ) ) {
- $slideshow .= '<div class="slideshow-caption">';
- $slideshow .= '<a class="slideshow-caption-control">' . __( 'Caption', 'news' ) . '</a>';
- $slideshow .= '<div class="slideshow-caption-text">' . $caption . '</div>';
- $slideshow .= '</div>';
- }
-
- $slideshow .= '</div>';
- }
-
- $slideshow .= '</div><div class="slideshow-controls">';
-
- $slideshow .= '<div class="slideshow-pager"></div>';
- $slideshow .= '<div class="slideshow-nav">';
- $slideshow .= '<a class="slider-prev">' . __( 'Previous', 'news' ) . '</a>';
- $slideshow .= '<a class="slider-next">' . __( 'Next', 'news' ) . '</a>';
- $slideshow .= '</div>';
-
- $slideshow .= '</div>';
-
- $slideshow .= '</div><!-- End slideshow. -->';
-
- return apply_atomic( 'slideshow_shortcode', $slideshow );
-}
-
+<?php
+/**
+ * Additional shortcodes for use within the theme.
+ *
+ * @package News
+ * @subpackage Functions
+ */
+
+/**
+ * Registers new shortcodes.
+ *
+ * @since 0.1.0
+ */
+function news_register_shortcodes() {
+ add_shortcode( 'slideshow', 'news_slideshow_shortcode' );
+ add_shortcode( 'entry-popup-shortlink', 'news_entry_shortlink_popup_shortcode' );
+ add_shortcode( 'entry-print-link', 'news_entry_print_link_shortcode' );
+ add_shortcode( 'entry-email-link', 'news_entry_email_link_shortcode' );
+ add_shortcode( 'entry-mixx-link', 'news_entry_mixx_link_shortcode' );
+ add_shortcode( 'entry-delicious-link', 'news_entry_delicious_link_shortcode' );
+ add_shortcode( 'entry-digg-link', 'news_entry_digg_link_shortcode' );
+ add_shortcode( 'entry-facebook-link', 'news_entry_facebook_link_shortcode' );
+ add_shortcode( 'entry-twitter-link', 'news_entry_twitter_link_shortcode' );
+}
+
+/**
+ * Shortlink popup shortcode.
+ *
+ * @since 0.1.0
+ */
+function news_entry_shortlink_popup_shortcode() {
+ $shortlink = wp_get_shortlink( get_the_ID() );
+
+ if ( empty( $shortlink ) )
+ return '';
+
+ $id = 'shortlink-' . get_the_ID();
+ $title = sprintf( __( "Shortlink for '%s'", 'news' ), get_the_title() );
+ $out = '<a class="tips shortlink hide-if-no-js" rel="#' . $id . '" title="' . esc_attr( $title ) . '">' . __( 'Shortlink', 'news' ) . '</a>';
+ $out .= ' <div id="' . $id . '" class="tip hide">';
+ $out .= '<input type="text" value="' . esc_url( $shortlink ) . '" onclick="this.focus(); this.select();" />';
+ $out .= '</div>';
+
+ return $out;
+}
+
+/**
+ * Print link shortcode.
+ *
+ * @since 0.1.0
+ */
+function news_entry_print_link_shortcode() {
+ return '<a class="print-link hide-if-no-js" href="#">' . __( 'Print', 'news' ) . '</a>';
+}
+
+/**
+ * Email link shortcode.
+ *
+ * @since 0.1.0
+ */
+function news_entry_email_link_shortcode() {
+ $subject = urlencode( esc_attr( '[' . get_bloginfo( 'name' ) . ']' . the_title_attribute( 'echo=0' ) ) );
+ $body = urlencode( esc_attr( sprintf( __( 'Check out this post: %1$s', 'news' ), get_permalink( get_the_ID() ) ) ) );
+ return '<a class="email-link" href="mailto:?subject=' . $subject . '&amp;body=' . $body . '">' . __( 'Email', 'news' ) . '</a>';
+}
+
+/**
+ * Mixx link shortcode.
+ *
+ * @since 0.1.0
+ */
+function news_entry_mixx_link_shortcode() {
+ return '<a href="http://www.mixx.com" onclick="window.location=\'http://www.mixx.com/submit?page_url=\'+window.location; return false;">' . __( 'Mixx', 'news' ) . '</a>';
+}
+
+/**
+ * Delicious link shortcode.
+ *
+ * @since 0.1.0
+ */
+function news_entry_delicious_link_shortcode() {
+ return '<a href="http://delicious.com/save" onclick="window.open(\'http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url=\'+encodeURIComponent(\'' . get_permalink() . '\')+\'&amp;title=\'+encodeURIComponent(\'' . the_title_attribute( 'echo=0' ) . '\'),\'delicious\', \'toolbar=no,width=550,height=550\'); return false;">' . __( 'Delicious', 'news' ) . '</a>';
+}
+
+/**
+ * Digg link shortcode.
+ * @note This won't work from your computer (http://localhost). Must be a live site.
+ *
+ * @since 0.1.0
+ */
+function news_entry_digg_link_shortcode() {
+ $url = esc_url( 'http://digg.com/submit?phase=2&amp;url=' . urlencode( get_permalink( get_the_ID() ) ) . '&amp;title="' . urlencode( the_title_attribute( 'echo=0' ) ) );
+
+ return '<a href="' . $url . '" title="' . __( 'Digg this entry', 'news' ) . '">Digg</a>';
+}
+
+/**
+ * Facebook share link shortcode.
+ *
+ * @todo Figure out why this doesn't work.
+ *
+ * @since 0.1.0
+ */
+function news_entry_facebook_link_shortcode() {
+ $url = esc_url( 'http://facebook.com/sharer.php?u=' . urlencode( get_permalink( get_the_ID() ) ) . '&amp;t=' . urlencode( the_title_attribute( 'echo=0' ) ) );
+
+ return '<a href="' . $url . '" title="' . __( 'Share this entry on Facebook', 'news' ) . '">' . __( 'Facebook', 'news' ) . '</a>';
+}
+
+/**
+ * Twitter link shortcode.
+ *
+ * @since 0.1.0
+ */
+function news_entry_twitter_link_shortcode() {
+
+ $post_id = get_the_ID();
+
+ $post_type = get_post_type( $post_id );
+
+ if ( 'post' == $post_type || 'page' == $post_type || 'attachment' == $post_type )
+ $shortlink = wp_get_shortlink( $post_id );
+ else
+ $shortlink = get_permalink( $post_id );
+
+ $url = esc_url( 'http://twitter.com/home?status=' . urlencode( sprintf( __( 'Currently reading %1$s', 'news' ), $shortlink ) ) );
+ return '<a href="' . $url . '" title="' . __( 'Share this entry on Twitter', 'news' ) . '">' . __( 'Twitter', 'news' ) . '</a>';
+}
+
+/**
+ * Slideshow shortcode.
+ *
+ * @since 0.1.0
+ */
+function news_slideshow_shortcode( $attr ) {
+ global $post;
+
+ /* Set up the defaults for the slideshow shortcode. */
+ $defaults = array(
+ 'order' => 'ASC',
+ 'orderby' => 'menu_order ID',
+ 'id' => $post->ID,
+ 'size' => 'news-slideshow',
+ 'include' => '',
+ 'exclude' => '',
+ 'numberposts' => -1,
+ );
+ $attr = shortcode_atts( $defaults, $attr );
+
+ /* Allow users to overwrite the default args. */
+ extract( apply_atomic( 'slideshow_shortcode_args', $attr ) );
+
+ /* Arguments for get_children(). */
+ $children = array(
+ 'post_parent' => intval( $id ),
+ 'post_status' => 'inherit',
+ 'post_type' => 'attachment',
+ 'post_mime_type' => 'image',
+ 'order' => $order,
+ 'orderby' => $orderby,
+ 'exclude' => absint( $exclude ),
+ 'include' => absint( $include ),
+ 'numberposts' => intval( $numberposts ),
+ );
+
+ /* Get image attachments. If none, return. */
+ $attachments = get_children( $children );
+
+ if ( empty( $attachments ) )
+ return '';
+
+ /* If is feed, leave the default WP settings. We're only worried about on-site presentation. */
+ if ( is_feed() ) {
+ $output = "\n";
+ foreach ( $attachments as $id => $attachment )
+ $output .= wp_get_attachment_link( $id, $size, true ) . "\n";
+ return $output;
+ }
+
+ $slideshow = '<div class="slideshow-set"><div class="slideshow-items">';
+
+ $i = 0;
+
+ foreach ( $attachments as $attachment ) {
+
+ /* Open item. */
+ $slideshow .= '<div class="slideshow-item item item-' . ++$i . '">';
+
+ /* Get image. */
+ $slideshow .= wp_get_attachment_link( $attachment->ID, $size, true, false );
+
+ /* Check for caption. */
+ if ( !empty( $attachment->post_excerpt ) )
+ $caption = $attachment->post_excerpt;
+ elseif ( !empty( $attachment->post_content ) )
+ $caption = $attachment->post_content;
+ else
+ $caption = '';
+
+ if ( !empty( $caption ) ) {
+ $slideshow .= '<div class="slideshow-caption">';
+ $slideshow .= '<a class="slideshow-caption-control">' . __( 'Caption', 'news' ) . '</a>';
+ $slideshow .= '<div class="slideshow-caption-text">' . $caption . '</div>';
+ $slideshow .= '</div>';
+ }
+
+ $slideshow .= '</div>';
+ }
+
+ $slideshow .= '</div><div class="slideshow-controls">';
+
+ $slideshow .= '<div class="slideshow-pager"></div>';
+ $slideshow .= '<div class="slideshow-nav">';
+ $slideshow .= '<a class="slider-prev">' . __( 'Previous', 'news' ) . '</a>';
+ $slideshow .= '<a class="slider-next">' . __( 'Next', 'news' ) . '</a>';
+ $slideshow .= '</div>';
+
+ $slideshow .= '</div>';
+
+ $slideshow .= '</div><!-- End slideshow. -->';
+
+ return apply_atomic( 'slideshow_shortcode', $slideshow );
+}
+
?>
View
266 classes/widget-image-stream.php → includes/widget-image-stream.php
@@ -1,134 +1,134 @@
-<?php
-/**
- * Gallery Stream Widget Class
- *
- * Pulls post thumbnails by category or tag.
- *
- * @package News
- * @subpackage Classes
- * @since 0.1.0
- */
-
-class News_Widget_Image_Stream extends WP_Widget {
-
- /**
- * Set up the widget's unique name, ID, class, description, and other options.
- *
- * @since 0.3.0
- */
- function __construct() {
-
- /* Set up the widget options. */
- $widget_options = array(
- 'classname' => 'image-stream',
- 'description' => esc_html__( 'Displays image thumbnails in a gallery-like format.', 'news' )
- );
-
- /* Set up the widget control options. */
- $control_options = array(
- 'width' => 200,
- 'height' => 350
- );
-
- /* Create the widget. */
- $this->WP_Widget(
- 'news-image-stream', // $this->id_base
- __( 'News: Image Stream', 'news' ), // $this->name
- $widget_options, // $this->widget_options
- $control_options // $this->control_options
- );
- }
-
- /**
- * Outputs the widget based on the arguments input through the widget controls.
- *
- * @since 0.1.0
- */
- function widget( $sidebar, $instance ) {
- extract( $sidebar );
-
- /* Output the theme's $before_widget wrapper. */
- echo $before_widget;
-
- /* If a title was input by the user, display it. */
- if ( !empty( $instance['title'] ) )
- echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
-
- /* Query images. */
- $loop = new WP_Query(
- array(
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'post_status' => 'inherit',
- 'posts_per_page' => intval( $instance['posts_per_page'] ),
- 'orderby' => 'parent'
- )
- );
-
- echo '<div>';
-
- if ( $loop->have_posts() ) {
-
- while ( $loop->have_posts() ) {
-
- $loop->the_post();
-
- echo wp_get_attachment_link( get_the_ID(), 'thumbnail', true );
- }
- } else {
- echo '<p>' . __( 'There are currently no images found.', 'news' ) . '</p>';
- }
-
- echo '</div>';
-
- /* Close the theme's widget wrapper. */
- echo $after_widget;
- }
-
- /**
- * Updates the widget control options for the particular instance of the widget.
- *
- * @since 0.1.0
- */
- function update( $new_instance, $old_instance ) {
-
- $instance = $new_instance;
-
- $instance['title'] = strip_tags( $new_instance['title'] );
- $instance['posts_per_page'] = strip_tags( $new_instance['posts_per_page'] );
-
- return $instance;
- }
-
- /**
- * Displays the widget control options in the Widgets admin screen.
- *
- * @since 0.1.0
- */
- function form( $instance ) {
-
- /* Set up the default form values. */
- $defaults = array(
- 'title' => esc_attr__( 'Image Stream', 'news' ),
- 'posts_per_page' => 6,
- );
-
- /* Merge the user-selected arguments with the defaults. */
- $instance = wp_parse_args( (array) $instance, $defaults ); ?>
-
- <div class="hybrid-widget-controls columns-1">
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'news' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'posts_per_page' ); ?>"><?php _e( 'Limit:', 'news' ); ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'posts_per_page' ); ?>" name="<?php echo $this->get_field_name( 'posts_per_page' ); ?>" value="<?php echo esc_attr( $instance['posts_per_page'] ); ?>" />
- </p>
- </div>
- <div style="clear:both;">&nbsp;</div>
- <?php
- }
-}
-
+<?php
+/**
+ * Gallery Stream Widget Class
+ *
+ * Pulls post thumbnails by category or tag.
+ *
+ * @package News
+ * @subpackage Classes
+ * @since 0.1.0
+ */
+
+class News_Widget_Image_Stream extends WP_Widget {
+
+ /**
+ * Set up the widget's unique name, ID, class, description, and other options.
+ *
+ * @since 0.3.0
+ */
+ function __construct() {
+
+ /* Set up the widget options. */
+ $widget_options = array(
+ 'classname' => 'image-stream',
+ 'description' => esc_html__( 'Displays image thumbnails in a gallery-like format.', 'news' )
+ );
+
+ /* Set up the widget control options. */
+ $control_options = array(
+ 'width' => 200,
+ 'height' => 350
+ );
+
+ /* Create the widget. */
+ $this->WP_Widget(
+ 'news-image-stream', // $this->id_base
+ __( 'News: Image Stream', 'news' ), // $this->name
+ $widget_options, // $this->widget_options
+ $control_options // $this->control_options
+ );
+ }
+
+ /**
+ * Outputs the widget based on the arguments input through the widget controls.
+ *
+ * @since 0.1.0
+ */
+ function widget( $sidebar, $instance ) {
+ extract( $sidebar );
+
+ /* Output the theme's $before_widget wrapper. */
+ echo $before_widget;
+
+ /* If a title was input by the user, display it. */
+ if ( !empty( $instance['title'] ) )
+ echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
+
+ /* Query images. */
+ $loop = new WP_Query(
+ array(
+ 'post_type' => 'attachment',
+ 'post_mime_type' => 'image',
+ 'post_status' => 'inherit',
+ 'posts_per_page' => intval( $instance['posts_per_page'] ),
+ 'orderby' => 'parent'
+ )
+ );
+
+ echo '<div>';
+
+ if ( $loop->have_posts() ) {
+
+ while ( $loop->have_posts() ) {
+
+ $loop->the_post();
+
+ echo wp_get_attachment_link( get_the_ID(), 'thumbnail', true );
+ }
+ } else {
+ echo '<p>' . __( 'There are currently no images found.', 'news' ) . '</p>';
+ }
+
+ echo '</div>';
+
+ /* Close the theme's widget wrapper. */
+ echo $after_widget;
+ }
+
+ /**
+ * Updates the widget control options for the particular instance of the widget.
+ *
+ * @since 0.1.0
+ */
+ function update( $new_instance, $old_instance ) {
+
+ $instance = $new_instance;
+
+ $instance['title'] = strip_tags( $new_instance['title'] );
+ $instance['posts_per_page'] = strip_tags( $new_instance['posts_per_page'] );
+
+ return $instance;
+ }
+
+ /**
+ * Displays the widget control options in the Widgets admin screen.
+ *
+ * @since 0.1.0
+ */
+ function form( $instance ) {
+
+ /* Set up the default form values. */
+ $defaults = array(
+ 'title' => esc_attr__( 'Image Stream', 'news' ),
+ 'posts_per_page' => 6,
+ );
+
+ /* Merge the user-selected arguments with the defaults. */
+ $instance = wp_parse_args( (array) $instance, $defaults ); ?>
+
+ <div class="hybrid-widget-controls columns-1">
+ <p>
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'news' ); ?></label>
+ <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'] ); ?>" />
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'posts_per_page' ); ?>"><?php _e( 'Limit:', 'news' ); ?></label>
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'posts_per_page' ); ?>" name="<?php echo $this->get_field_name( 'posts_per_page' ); ?>" value="<?php echo esc_attr( $instance['posts_per_page'] ); ?>" />
+ </p>
+ </div>
+ <div style="clear:both;">&nbsp;</div>
+ <?php
+ }
+}
+
?>
View
260 classes/widget-newsletter.php → includes/widget-newsletter.php
@@ -1,131 +1,131 @@
-<?php
-/**
- * Newsletter Widget Class
- *
- * Provides a subscribe form for integration with the Google/Feedburner service.
- *
- * @package News
- * @subpackage Classes
- * @since 0.1.0
- */
-
-class News_Widget_Newsletter extends WP_Widget {
-
- /**
- * Set up the widget's unique name, ID, class, description, and other options.
- *
- * @since 0.3.0
- */
- function __construct() {
-
- /* Set up the widget options. */
- $widget_options = array(
- 'classname' => 'newsletter',
- 'description' => esc_html__( 'Displays a subscription form for your Google/Feedburner account.', 'news' )
- );
-
- /* Set up the widget control options. */
- $control_options = array(
- 'width' => 200,
- 'height' => 350
- );
-
- /* Create the widget. */
- $this->WP_Widget(
- 'news-newsletter', // $this->id_base
- __( 'News: Newsletter', 'news' ), // $this->name
- $widget_options, // $this->widget_options
- $control_options // $this->control_options
- );
- }
-
- /**
- * Outputs the widget based on the arguments input through the widget controls.
- *
- * @since 0.1.0
- */
- function widget( $sidebar, $instance ) {
- extract( $sidebar );
-
- /* Output the theme's $before_widget wrapper. */
- echo $before_widget;
-
- /* If a title was input by the user, display it. */
- if ( !empty( $instance['title'] ) )
- echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
-
- ?>
- <div class="newsletter-wrap">
- <form action="http://feedburner.google.com/fb/a/mailverify" method="post">
- <p>
- <input class="newsletter-text" type="text" name="email" value="<?php echo esc_attr( $instance['input_text'] ); ?>" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" />
- <input class="newsletter-submit" type="submit" value="<?php echo esc_attr( $instance['submit_text'] ); ?>" />
- <input type="hidden" value="<?php echo esc_attr( $instance['id'] ); ?>" name="uri" />
- <input type="hidden" name="loc" value="en_US" />
- </p>
- </form>
- </div><?php
-
- /* Close the theme's widget wrapper. */
- echo $after_widget;
- }
-
- /**
- * Updates the widget control options for the particular instance of the widget.
- *
- * @since 0.1.0
- */
- function update( $new_instance, $old_instance ) {
-
- $instance = $new_instance;
-
- $instance['title'] = strip_tags( $new_instance['title'] );
- $instance['id'] = strip_tags( $new_instance['id'] );
- $instance['input_text'] = strip_tags( $new_instance['input_text'] );
- $instance['submit_text'] = strip_tags( $new_instance['submit_text'] );
-
- return $instance;
- }
-
- /**
- * Displays the widget control options in the Widgets admin screen.
- *
- * @since 0.1.0
- */
- function form( $instance ) {
-
- /* Set up the default form values. */
- $defaults = array(
- 'title' => esc_attr__( 'Newsletter', 'news' ),
- 'input_text' => esc_attr__( 'you@site.com', 'news' ),
- 'submit_text' => esc_attr__( 'Subscribe', 'news' ),
- 'id' => ''
- );
-
- /* Merge the user-selected arguments with the defaults. */
- $instance = wp_parse_args( (array) $instance, $defaults ); ?>
-
- <div class="hybrid-widget-controls columns-1">
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'news' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php _e( 'Google/Feedburner ID:', 'news' ); ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'id' ); ?>" name="<?php echo $this->get_field_name( 'id' ); ?>" value="<?php echo esc_attr( $instance['id'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'input_text' ); ?>"><?php _e( 'Input Text:', 'news' ); ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'input_text' ); ?>" name="<?php echo $this->get_field_name( 'input_text' ); ?>" value="<?php echo esc_attr( $instance['input_text'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'submit_text' ); ?>"><?php _e( 'Submit Text:', 'news' ); ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'submit_text' ); ?>" name="<?php echo $this->get_field_name( 'submit_text' ); ?>" value="<?php echo esc_attr( $instance['submit_text'] ); ?>" />
- </p>
- </div>
- <div style="clear:both;">&nbsp;</div>
- <?php
- }
-}
-
+<?php
+/**
+ * Newsletter Widget Class
+ *
+ * Provides a subscribe form for integration with the Google/Feedburner service.
+ *
+ * @package News
+ * @subpackage Classes
+ * @since 0.1.0
+ */
+
+class News_Widget_Newsletter extends WP_Widget {
+
+ /**
+ * Set up the widget's unique name, ID, class, description, and other options.
+ *
+ * @since 0.3.0
+ */
+ function __construct() {
+
+ /* Set up the widget options. */
+ $widget_options = array(
+ 'classname' => 'newsletter',
+ 'description' => esc_html__( 'Displays a subscription form for your Google/Feedburner account.', 'news' )
+ );
+
+ /* Set up the widget control options. */
+ $control_options = array(
+ 'width' => 200,
+ 'height' => 350
+ );
+
+ /* Create the widget. */
+ $this->WP_Widget(
+ 'news-newsletter', // $this->id_base
+ __( 'News: Newsletter', 'news' ), // $this->name
+ $widget_options, // $this->widget_options
+ $control_options // $this->control_options
+ );
+ }
+
+ /**
+ * Outputs the widget based on the arguments input through the widget controls.
+ *
+ * @since 0.1.0
+ */
+ function widget( $sidebar, $instance ) {
+ extract( $sidebar );
+
+ /* Output the theme's $before_widget wrapper. */
+ echo $before_widget;
+
+ /* If a title was input by the user, display it. */
+ if ( !empty( $instance['title'] ) )
+ echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
+
+ ?>
+ <div class="newsletter-wrap">
+ <form action="http://feedburner.google.com/fb/a/mailverify" method="post">
+ <p>
+ <input class="newsletter-text" type="text" name="email" value="<?php echo esc_attr( $instance['input_text'] ); ?>" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" />
+ <input class="newsletter-submit" type="submit" value="<?php echo esc_attr( $instance['submit_text'] ); ?>" />
+ <input type="hidden" value="<?php echo esc_attr( $instance['id'] ); ?>" name="uri" />
+ <input type="hidden" name="loc" value="en_US" />
+ </p>
+ </form>
+ </div><?php
+
+ /* Close the theme's widget wrapper. */
+ echo $after_widget;
+ }
+
+ /**
+ * Updates the widget control options for the particular instance of the widget.
+ *
+ * @since 0.1.0
+ */
+ function update( $new_instance, $old_instance ) {
+
+ $instance = $new_instance;
+
+ $instance['title'] = strip_tags( $new_instance['title'] );
+ $instance['id'] = strip_tags( $new_instance['id'] );
+ $instance['input_text'] = strip_tags( $new_instance['input_text'] );
+ $instance['submit_text'] = strip_tags( $new_instance['submit_text'] );
+
+ return $instance;
+ }
+
+ /**
+ * Displays the widget control options in the Widgets admin screen.
+ *
+ * @since 0.1.0
+ */
+ function form( $instance ) {
+
+ /* Set up the default form values. */
+ $defaults = array(
+ 'title' => esc_attr__( 'Newsletter', 'news' ),
+ 'input_text' => esc_attr__( 'you@site.com', 'news' ),
+ 'submit_text' => esc_attr__( 'Subscribe', 'news' ),
+ 'id' => ''
+ );
+
+ /* Merge the user-selected arguments with the defaults. */
+ $instance = wp_parse_args( (array) $instance, $defaults ); ?>
+
+ <div class="hybrid-widget-controls columns-1">
+ <p>
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'news' ); ?></label>
+ <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'] ); ?>" />
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'id' ); ?>"><?php _e( 'Google/Feedburner ID:', 'news' ); ?></label>
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'id' ); ?>" name="<?php echo $this->get_field_name( 'id' ); ?>" value="<?php echo esc_attr( $instance['id'] ); ?>" />
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'input_text' ); ?>"><?php _e( 'Input Text:', 'news' ); ?></label>
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'input_text' ); ?>" name="<?php echo $this->get_field_name( 'input_text' ); ?>" value="<?php echo esc_attr( $instance['input_text'] ); ?>" />
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'submit_text' ); ?>"><?php _e( 'Submit Text:', 'news' ); ?></label>
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'submit_text' ); ?>" name="<?php echo $this->get_field_name( 'submit_text' ); ?>" value="<?php echo esc_attr( $instance['submit_text'] ); ?>" />
+ </p>
+ </div>
+ <div style="clear:both;">&nbsp;</div>
+ <?php
+ }
+}
+
?>
View
370 classes/widget-popular-tabs.php → includes/widget-popular-tabs.php
@@ -1,186 +1,186 @@
-<?php
-/**
- * Popular Tabs Widget Class
- *
- * The Popular Tabs widget lists posts by view count and comment count in a tabbed display using the
- * jQuery UI Tabs feature.
- *
- * @package News
- * @subpackage Classes
- * @since 0.1
- */
-
-class News_Widget_Popular_Tabs extends WP_Widget {
-
- /**
- * Set up the widget's unique name, ID, class, description, and other options.
- *
- * @since 0.3.0
- */
- function __construct() {
-
- /* Set up the widget options. */
- $widget_options = array(
- 'classname' => 'popular-tabs',
- 'description' => esc_html__( 'Displays popular posts by number of views and comments in tab format.', 'news' )
- );
-
- /* Set up the widget control options. */
- $control_options = array(
- 'width' => 200,
- 'height' => 350
- );
-
- /* Create the widget. */
- $this->WP_Widget(
- 'news-popular-tabs', // $this->id_base
- __( 'News: Popular Tabs', 'news' ), // $this->name
- $widget_options, // $this->widget_options
- $control_options // $this->control_options
- );
- }
-
- /**
- * Outputs the widget based on the arguments input through the widget controls.
- *
- * @since 0.1.0
- */
- function widget( $sidebar, $instance ) {
- extract( $sidebar );
-
- /* Output the theme's $before_widget wrapper. */
- echo $before_widget;
-
- /* If a title was input by the user, display it. */
- if ( !empty( $instance['title'] ) )
- echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
-
- ?>
- <div class="ui-tabs">
-
- <div class="ui-tabs-wrap">
-
- <ul class="ui-tabs-nav">
- <li><a href="#<?php echo sanitize_html_class( "{$this->id}-1" ); ?>"><?php echo $instance['views_tab_title']; ?></a></li>
- <li><a href="#<?php echo sanitize_html_class( "{$this->id}-2" ); ?>"><?php echo $instance['comments_tab_title']; ?></a></li>
- </ul><!-- .ui-tabs-nav -->
-
- <div id="<?php echo sanitize_html_class( "{$this->id}-1" ); ?>" class="ui-tabs-panel">
-
- <?php $loop = new WP_Query( array( 'post_type' => $instance['post_type'], 'ignore_sticky_posts' => true, 'posts_per_page' => intval( $instance['posts_per_page'] ), 'meta_key' => 'Views', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>
-
- <?php if ( $loop->have_posts() ) : ?>
-
- <ul class="xoxo">
-
- <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
- <?php the_title( '<li><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '">', '</a>' ); ?>
- <span class="count view-count"><?php printf( __( '(%s)', 'news' ), get_post_meta( get_the_ID(), 'Views', true ) ); ?></span>
- </li>
- <?php endwhile; ?>
-
- </ul>
-
- <?php endif; ?>
-
- </div><!-- .ui-tabs-panel -->
-
- <div id="<?php echo sanitize_html_class( "{$this->id}-2" ); ?>" class="ui-tabs-panel">
-
- <?php $loop = new WP_Query( array( 'post_type' => $instance['post_type'], 'ignore_sticky_posts' => true, 'posts_per_page' => intval( $instance['posts_per_page'] ), 'orderby' => 'comment_count' ) ); ?>
-
- <?php if ( $loop->have_posts() ) : ?>
-
- <ul class="xoxo">
-
- <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
- <?php the_title( '<li><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '">', '</a>' ); ?>
- <span class="count view-count"><?php printf( __( '(%s)', 'news' ), get_comments_number() ); ?></span>
- </li>
- <?php endwhile; ?>
-
- </ul>
-
- <?php endif; wp_reset_query(); ?>
-
- </div><!-- .ui-tabs-panel -->
-
- </div><!-- .ui-tabs-wrap -->
-
- </div><!-- .ui-tabs --> <?php
-
- /* Close the theme's widget wrapper. */
- echo $after_widget;
- }
-
- /**
- * Updates the widget control options for the particular instance of the widget.
- *
- * @since 0.1.0
- */
- function update( $new_instance, $old_instance ) {
-
- $instance = $new_instance;
-
- $instance['title'] = strip_tags( $new_instance['title'] );
- $instance['views_tab_title'] = strip_tags( $new_instance['views_tab_title'] );
- $instance['comments_tab_title'] = strip_tags( $new_instance['comments_tab_title'] );
- $instance['posts_per_page'] = intval( $new_instance['posts_per_page'] );
- $instance['post_type'] = strip_tags( $new_instance['post_type'] );
-
- return $instance;
- }
-
- /**
- * Displays the widget control options in the Widgets admin screen.
- *
- * @since 0.1.0
- */
- function form( $instance ) {
-
- /* Set up the default form values. */
- $defaults = array(
- 'title' => esc_attr__( 'Most', 'news' ),
- 'posts_per_page' => 3,
- 'post_type' => 'post',
- 'views_tab_title' => esc_attr__( 'Viewed', 'news' ),
- 'comments_tab_title' => esc_attr__( 'Commented', 'news' )
- );
-
- /* Merge the user-selected arguments with the defaults. */
- $instance = wp_parse_args( (array) $instance, $defaults ); ?>
-
- <div class="hybrid-widget-controls columns-1">
- <p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'news' ); ?></label>
- <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'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'post_type' ); ?>"><?php _e( 'Post Type:', 'news' ); ?></label>
- <select class="widefat" id="<?php echo $this->get_field_id( 'post_type' ); ?>" name="<?php echo $this->get_field_name( 'post_type' ); ?>">
- <?php foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $post_type ) {
- if ( post_type_supports( $post_type->name, 'entry-views' ) ) { ?>
- <option value="<?php echo esc_attr( $post_type->name ); ?>" <?php selected( $instance['post_type'], $post_type->name ); ?>><?php echo esc_html( $post_type->labels->singular_name ); ?></option>
- <?php }
- } ?>
- </select>
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'posts_per_page' ); ?>"><?php _e( 'Limit:', 'news' ); ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'posts_per_page' ); ?>" name="<?php echo $this->get_field_name( 'posts_per_page' ); ?>" value="<?php echo esc_attr( $instance['posts_per_page'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'views_tab_title' ); ?>"><?php _e( 'Views Tab Title:', 'news' ); ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'views_tab_title' ); ?>" name="<?php echo $this->get_field_name( 'views_tab_title' ); ?>" value="<?php echo esc_attr( $instance['views_tab_title'] ); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'comments_tab_title' ); ?>"><?php _e( 'Comments Tab Title:', 'news' ); ?></label>
- <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'comments_tab_title' ); ?>" name="<?php echo $this->get_field_name( 'comments_tab_title' ); ?>" value="<?php echo esc_attr( $instance['comments_tab_title'] ); ?>" />
- </p>
- </div>
- <div style="clear:both;">&nbsp;</div>
- <?php
- }
-}
-
+<?php
+/**
+ * Popular Tabs Widget Class
+ *
+ * The Popular Tabs widget lists posts by view count and comment count in a tabbed display using the
+ * jQuery UI Tabs feature.
+ *
+ * @package News
+ * @subpackage Classes
+ * @since 0.1
+ */
+
+class News_Widget_Popular_Tabs extends WP_Widget {
+
+ /**
+ * Set up the widget's unique name, ID, class, description, and other options.
+ *
+ * @since 0.3.0
+ */
+ function __construct() {
+
+ /* Set up the widget options. */
+ $widget_options = array(
+ 'classname' => 'popular-tabs',
+ 'description' => esc_html__( 'Displays popular posts by number of views and comments in tab format.', 'news' )
+ );
+
+ /* Set up the widget control options. */
+ $control_options = array(
+ 'width' => 200,
+ 'height' => 350
+ );
+
+ /* Create the widget. */
+ $this->WP_Widget(
+ 'news-popular-tabs', // $this->id_base
+ __( 'News: Popular Tabs', 'news' ), // $this->name
+ $widget_options, // $this->widget_options
+ $control_options // $this->control_options
+ );
+ }
+
+ /**
+ * Outputs the widget based on the arguments input through the widget controls.
+ *
+ * @since 0.1.0
+ */
+ function widget( $sidebar, $instance ) {
+ extract( $sidebar );
+
+ /* Output the theme's $before_widget wrapper. */
+ echo $before_widget;
+
+ /* If a title was input by the user, display it. */
+ if ( !empty( $instance['title'] ) )
+ echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
+
+ ?>
+ <div class="ui-tabs">
+
+ <div class="ui-tabs-wrap">
+
+ <ul class="ui-tabs-nav">
+ <li><a href="#<?php echo sanitize_html_class( "{$this->id}-1" ); ?>"><?php echo $instance['views_tab_title']; ?></a></li>
+ <li><a href="#<?php echo sanitize_html_class( "{$this->id}-2" ); ?>"><?php echo $instance['comments_tab_title']; ?></a></li>
+ </ul><!-- .ui-tabs-nav -->
+
+ <div id="<?php echo sanitize_html_class( "{$this->id}-1" ); ?>" class="ui-tabs-panel">
+
+ <?php $loop = new WP_Query( array( 'post_type' => $instance['post_type'], 'ignore_sticky_posts' => true, 'posts_per_page' => intval( $instance['posts_per_page'] ), 'meta_key' => 'Views', 'orderby' => 'meta_value_num', 'order' => 'DESC' ) ); ?>
+
+ <?php if ( $loop->have_posts() ) : ?>
+
+ <ul class="xoxo">
+
+ <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
+ <?php the_title( '<li><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '">', '</a>' ); ?>
+ <span class="count view-count"><?php printf( __( '(%s)', 'news' ), get_post_meta( get_the_ID(), 'Views', true ) ); ?></span>
+ </li>
+ <?php endwhile; ?>
+
+ </ul>
+
+ <?php endif; ?>
+
+ </div><!-- .ui-tabs-panel -->
+
+ <div id="<?php echo sanitize_html_class( "{$this->id}-2" ); ?>" class="ui-tabs-panel">
+
+ <?php $loop = new WP_Query( array( 'post_type' => $instance['post_type'], 'ignore_sticky_posts' => true, 'posts_per_page' => intval( $instance['posts_per_page'] ), 'orderby' => 'comment_count' ) ); ?>
+
+ <?php if ( $loop->have_posts() ) : ?>
+
+ <ul class="xoxo">
+
+ <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
+ <?php the_title( '<li><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '">', '</a>' ); ?>
+ <span class="count view-count"><?php printf( __( '(%s)', 'news' ), get_comments_number() ); ?></span>
+ </li>
+ <?php endwhile; ?>
+
+ </ul>
+
+ <?php endif; wp_reset_query(); ?>
+
+ </div><!-- .ui-tabs-panel -->
+
+ </div><!-- .ui-tabs-wrap -->
+
+ </div><!-- .ui-tabs --> <?php
+
+ /* Close the theme's widget wrapper. */
+ echo $after_widget;
+ }
+
+ /**
+ * Updates the widget control options for the particular instance of the widget.
+ *
+ * @since 0.1.0
+ */
+ function update( $new_instance, $old_instance ) {
+
+ $instance = $new_instance;
+
+ $instance['title'] = strip_tags( $new_instance['title'] );
+ $instance['views_tab_title'] = strip_tags( $new_instance['views_tab_title'] );
+ $instance['comments_tab_title'] = strip_tags( $new_instance['comments_tab_title'] );
+ $instance['posts_per_page'] = intval( $new_instance['posts_per_page'] );
+ $instance['post_type'] = strip_tags( $new_instance['post_type'] );
+
+ return $instance;
+ }
+
+ /**
+ * Displays the widget control options in the Widgets admin screen.
+ *
+ * @since 0.1.0
+ */
+ function form( $instance ) {
+
+ /* Set up the default form values. */
+ $defaults = array(
+ 'title' => esc_attr__( 'Most', 'news' ),
+ 'posts_per_page' => 3,
+ 'post_type' => 'post',
+ 'views_tab_title' => esc_attr__( 'Viewed', 'news' ),
+ 'comments_tab_title' => esc_attr__( 'Commented', 'news' )
+ );
+
+ /* Merge the user-selected arguments with the defaults. */
+ $instance = wp_parse_args( (array) $instance, $defaults ); ?>
+
+ <div class="hybrid-widget-controls columns-1">
+ <p>
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'news' ); ?></label>
+ <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'] ); ?>" />
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'post_type' ); ?>"><?php _e( 'Post Type:', 'news' ); ?></label>
+ <select class="widefat" id="<?php echo $this->get_field_id( 'post_type' ); ?>" name="<?php echo $this->get_field_name( 'post_type' ); ?>">
+ <?php foreach ( get_post_types( array( 'public' => true ), 'objects' ) as $post_type ) {
+ if ( post_type_supports( $post_type->name, 'entry-views' ) ) { ?>
+ <option value="<?php echo esc_attr( $post_type->name ); ?>" <?php selected( $instance['post_type'], $post_type->name ); ?>><?php echo esc_html( $post_type->labels->singular_name ); ?></option>
+ <?php }
+ } ?>
+ </select>
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'posts_per_page' ); ?>"><?php _e( 'Limit:', 'news' ); ?></label>
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'posts_per_page' ); ?>" name="<?php echo $this->get_field_name( 'posts_per_page' ); ?>" value="<?php echo esc_attr( $instance['posts_per_page'] ); ?>" />
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'views_tab_title' ); ?>"><?php _e( 'Views Tab Title:', 'news' ); ?></label>
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'views_tab_title' ); ?>" name="<?php echo $this->get_field_name( 'views_tab_title' ); ?>" value="<?php echo esc_attr( $instance['views_tab_title'] ); ?>" />
+ </p>
+ <p>
+ <label for="<?php echo $this->get_field_id( 'comments_tab_title' ); ?>"><?php _e( 'Comments Tab Title:', 'news' ); ?></label>
+ <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'comments_tab_title' ); ?>" name="<?php echo $this->get_field_name( 'comments_tab_title' ); ?>" value="<?php echo esc_attr( $instance['comments_tab_title'] ); ?>" />
+ </p>
+ </div>
+ <div style="clear:both;">&nbsp;</div>
+ <?php
+ }
+}
+
?>
Please sign in to comment.
Something went wrong with that request. Please try again.