From 8f481a0b92bf4e1b6d13827aa4f64a9acb42cc2e Mon Sep 17 00:00:00 2001 From: Frumph Date: Sun, 9 Aug 2015 02:24:43 -0700 Subject: [PATCH] Widgets updated for WordPress 4.3 - includes new widget to display a dropdown archive list of *all* the comics in the current chapter --- widgets/archive-dropdown.php | 18 ++++--- widgets/casthover.php | 18 ++++--- widgets/comic-calendar.php | 21 ++++---- widgets/comicblogpost.php | 19 +++++--- widgets/comiclist-dropdown.php | 89 ++++++++++++++++++++++++++++++++++ widgets/navigation.php | 19 +++++--- widgets/recentcomics.php | 23 ++++----- widgets/scheduledcomics.php | 22 ++++----- widgets/thumbnail.php | 21 ++++---- 9 files changed, 181 insertions(+), 69 deletions(-) create mode 100644 widgets/comiclist-dropdown.php diff --git a/widgets/archive-dropdown.php b/widgets/archive-dropdown.php index 2cb5658..337cc02 100644 --- a/widgets/archive-dropdown.php +++ b/widgets/archive-dropdown.php @@ -94,11 +94,15 @@ function ceo_comic_archive_jump_to_chapter($unhide = false, $exclude = '', $show class ceo_comic_archive_dropdown_widget extends WP_Widget { - function ceo_comic_archive_dropdown_widget($skip_widget_init = false) { - if (!$skip_widget_init) { - $widget_ops = array('classname' => __CLASS__, 'description' => __('Display dropdown list of comic chapters.', 'comiceasel') ); - $this->WP_Widget(__CLASS__, __('Comic Easel - Comic Chapters','comiceasel'), $widget_ops); - } + /** + * Register widget with WordPress. + */ + function __construct() { + parent::__construct( + __CLASS__, // Base ID + __( 'Comic Easel - Comic Chapters', 'comiceasel' ), // Name + array( 'classname' => __CLASS__, 'description' => __( 'Display dropdown list of comic chapters.', 'comiceasel' ), ) + ); } function widget($args, $instance) { @@ -140,4 +144,6 @@ class ceo_comic_archive_dropdown_widget extends WP_Widget { } } -add_action( 'widgets_init', create_function('', 'return register_widget("ceo_comic_archive_dropdown_widget");') ); +add_action( 'widgets_init', function(){ + register_widget('ceo_comic_archive_dropdown_widget'); +}); diff --git a/widgets/casthover.php b/widgets/casthover.php index 704bd59..9faa42a 100644 --- a/widgets/casthover.php +++ b/widgets/casthover.php @@ -69,9 +69,15 @@ function ceo_add_characters_hovercards($post_characters) { //widget code below here class ceo_casthover_reference_widget extends WP_Widget { - function ceo_casthover_reference_widget() { - $widget_ops = array('classname' => __CLASS__, 'description' => __('Creates a grid of avatars for characters in the current comic.', 'comiceasel') ); - $this->WP_Widget(__CLASS__, __('Comic Easel - Cast Hover', 'comiceasel'), $widget_ops); + /** + * Register widget with WordPress. + */ + function __construct() { + parent::__construct( + __CLASS__, // Base ID + __( 'Comic Easel - Cast Hover', 'comiceasel' ), // Name + array( 'classname' => __CLASS__, 'description' => __( 'Creates a grid of avatars for characters in the current comic.', 'comiceasel' ), ) // Args + ); } function widget($args, $instance) { @@ -124,9 +130,7 @@ class ceo_casthover_reference_widget extends WP_Widget { } -function ceo_casthover_reference_widget_register() { +add_action( 'widgets_init', function(){ register_widget('ceo_casthover_reference_widget'); -} +}); -add_action('widgets_init', 'ceo_casthover_reference_widget_register'); -?> \ No newline at end of file diff --git a/widgets/comic-calendar.php b/widgets/comic-calendar.php index 9f0afb8..c762467 100644 --- a/widgets/comic-calendar.php +++ b/widgets/comic-calendar.php @@ -244,12 +244,16 @@ add_action( 'update_option_gmt_offset', 'ceo_delete_get_calendar_cache' ); class ceo_calendar_widget extends WP_Widget { - - function ceo_calendar_widget($skip_widget_init = false) { - if (!$skip_widget_init) { - $widget_ops = array('classname' => __CLASS__, 'description' => __('Display a calendar showing this months posts. (this calendar does not drop lines if there is no title given.)','comiceasel') ); - $this->WP_Widget(__CLASS__, __('Comic Easel - Calendar','comiceasel'), $widget_ops); - } + + /** + * Register widget with WordPress. + */ + function __construct() { + parent::__construct( + __CLASS__, // Base ID + __( 'Comic Easel - Calendar', 'comiceasel' ), // Name + array( 'classname' => __CLASS__, 'description' => __( 'Display a calendar showing this months posts. (this calendar does not drop lines if there is no title given.', 'comiceasel' ), ) // Args + ); } function widget($args, $instance) { @@ -337,8 +341,7 @@ class ceo_calendar_widget extends WP_Widget { } } -function ceo_calendar_widget_register() { +add_action( 'widgets_init', function(){ register_widget('ceo_calendar_widget'); -} +}); -add_action( 'widgets_init', 'ceo_calendar_widget_register'); diff --git a/widgets/comicblogpost.php b/widgets/comicblogpost.php index a33d352..cd1b33f 100644 --- a/widgets/comicblogpost.php +++ b/widgets/comicblogpost.php @@ -23,11 +23,15 @@ function ceo_display_comic_small_blog_post($instance) { class ceo_comic_blog_post_widget extends WP_Widget { - function ceo_comic_blog_post_widget($skip_widget_init = false) { - if (!$skip_widget_init) { - $widget_ops = array('classname' => __CLASS__, 'description' => __('Displays the comic blog post for the day, best used when the comic blog post is disabled and you want to put this into a sidebar.','comiceasel') ); - $this->WP_Widget(__CLASS__, __('Comic Easel - Blog Post','comiceasel'), $widget_ops); - } + /** + * Register widget with WordPress. + */ + function __construct() { + parent::__construct( + __CLASS__, // Base ID + __( 'Comic Easel - Blog Post', 'comiceasel' ), // Name + array( 'classname' => __CLASS__, 'description' => __( 'Displays the comic blog post for the day, best used when the comic blog post is disabled and you want to put this into a sidebar.', 'comiceasel' ), ) // Args + ); } function widget($args, $instance) { @@ -101,8 +105,7 @@ class ceo_comic_blog_post_widget extends WP_Widget { } } -function ceo_comic_blog_post_widget_register() { +add_action( 'widgets_init', function(){ register_widget('ceo_comic_blog_post_widget'); -} +}); -add_action( 'widgets_init', 'ceo_comic_blog_post_widget_register'); diff --git a/widgets/comiclist-dropdown.php b/widgets/comiclist-dropdown.php new file mode 100644 index 0000000..1355638 --- /dev/null +++ b/widgets/comiclist-dropdown.php @@ -0,0 +1,89 @@ +ID, 'chapters'); + if (!empty($terms)){ + $term = reset($terms); // only one chapter + $output = '
'; + $output .= ''; + $output .= ''; + $output .= '
'; + if ($return) { + return $output; + } else echo $output; + } + + ceo_unprotect(); +} + +class ceo_comic_list_dropdown_widget extends WP_Widget { + + /** + * Register widget with WordPress. + */ + function __construct() { + parent::__construct( + __CLASS__, // Base ID + __( 'Comic Easel - Comic List Dropdown', 'comiceasel' ), // Name + array( 'classname' => __CLASS__, 'description' => __( 'Display dropdown list of comics.', 'comiceasel' ), ) // Args + ); + } + + function widget($args, $instance) { + global $post; + extract($args, EXTR_SKIP); + echo $before_widget; + $title = empty($instance['title']) ? __('Comic List','comiceasel') : apply_filters('widget_title', $instance['title']); + if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; + ceo_list_jump_to_comic($instance['exclude'], false); + echo $after_widget; + } + + function update($new_instance, $old_instance) { + $instance = $old_instance; + $instance['title'] = strip_tags($new_instance['title']); + $instance['exclude'] = strip_tags($new_instance['exclude']); + return $instance; + } + + function form($instance) { + $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'exclude' => '', 'unhide' => 1, 'showcount' => 1) ); + $title = $instance['title']; + $exclude = $instance['exclude']; + ?> +

+

+ __CLASS__, 'description' => __('Displays navigation links for navigating your comics. This widget works best in the above-comic and under-comic sidebars if you set them in the theme you use.','comiceasel') ); - $this->WP_Widget('ceo_comic_navigation', __('Comic Easel - Navigation','comiceasel'), $widget_ops); + + /** + * Register widget with WordPress. + */ + function __construct() { + parent::__construct( + __CLASS__, // Base ID + __( 'Comic Easel - Navigation', 'comiceasel' ), // Name + array( 'classname' => __CLASS__, 'description' => __( 'Displays navigation links for navigating your comics. This widget works in the above-comic and under-comic sidebars if you set them in the theme you use.', 'comiceasel' ), ) // Args + ); } function display_comic_nav_wrapper($args, $instance) { @@ -354,9 +360,8 @@ class ceo_comic_navigation_widget extends WP_Widget { } } -function ceo_widget_comic_navigation_register() { +add_action( 'widgets_init', function(){ register_widget('ceo_comic_navigation_widget'); -} +}); -add_action( 'widgets_init', 'ceo_widget_comic_navigation_register'); diff --git a/widgets/recentcomics.php b/widgets/recentcomics.php index 1da6ed6..ceed70e 100644 --- a/widgets/recentcomics.php +++ b/widgets/recentcomics.php @@ -8,12 +8,16 @@ Version: 1.02 */ class ceo_latest_comics_widget extends WP_Widget { - - function ceo_latest_comics_widget($skip_widget_init = false) { - if (!$skip_widget_init) { - $widget_ops = array('classname' => __CLASS__, 'description' => __('Display a list of the latest comics','comiceasel') ); - $this->WP_Widget(__CLASS__, __('Comic Easel - Latest Comics','comiceasel'), $widget_ops); - } + + /** + * Register widget with WordPress. + */ + function __construct() { + parent::__construct( + __CLASS__, // Base ID + __( 'Comic Easel - Latest Comics', 'comiceasel' ), // Name + array( 'classname' => __CLASS__, 'description' => __( 'Display a list of the latest comics.', 'comiceasel' ), ) // Args + ); } function widget($args, $instance) { @@ -57,10 +61,7 @@ class ceo_latest_comics_widget extends WP_Widget { } } -function ceo_latest_comics_widget_register() { +add_action( 'widgets_init', function(){ register_widget('ceo_latest_comics_widget'); -} +}); -add_action('widgets_init', 'ceo_latest_comics_widget_register'); - -?> \ No newline at end of file diff --git a/widgets/scheduledcomics.php b/widgets/scheduledcomics.php index dd94379..734e4b8 100644 --- a/widgets/scheduledcomics.php +++ b/widgets/scheduledcomics.php @@ -10,11 +10,15 @@ Version: 1.04 class ceo_scheduled_comics_widget extends WP_Widget { - function ceo_scheduled_comics_widget($skip_widget_init = false) { - if (!$skip_widget_init) { - $widget_ops = array('classname' => __CLASS__, 'description' => __('Display a list of comics that are scheduled to be published.','comiceasel') ); - $this->WP_Widget(__CLASS__, __('Comic Easel - Scheduled Posts','comiceasel'), $widget_ops); - } + /** + * Register widget with WordPress. + */ + function __construct() { + parent::__construct( + __CLASS__, // Base ID + __( 'Comic Easel - Scheduled Posts', 'comiceasel' ), // Name + array( 'classname' => __CLASS__, 'description' => __( 'Display a list of comics that are scheduled to be published.', 'comiceasel' ), ) // Args + ); } function widget($args, $instance) { @@ -58,10 +62,6 @@ class ceo_scheduled_comics_widget extends WP_Widget { } } -function ceo_scheduled_comics_widget_register() { +add_action( 'widgets_init', function(){ register_widget('ceo_scheduled_comics_widget'); -} - -add_action( 'widgets_init', 'ceo_scheduled_comics_widget_register'); - -?> \ No newline at end of file +}); diff --git a/widgets/thumbnail.php b/widgets/thumbnail.php index cdfb9fa..926bf44 100644 --- a/widgets/thumbnail.php +++ b/widgets/thumbnail.php @@ -9,9 +9,15 @@ Version: 1.3 class ceo_thumbnail_widget extends WP_Widget { - function ceo_thumbnail_widget() { - $widget_ops = array('classname' => __CLASS__, 'description' => __('Display a thumbnail of a comic, by chapter, newest, first or random, clickable to go to the comic.', 'comiceasel') ); - $this->WP_Widget(__CLASS__, __('Comic Easel - Thumbnail', 'comiceasel'), $widget_ops); + /** + * Register widget with WordPress. + */ + function __construct() { + parent::__construct( + __CLASS__, // Base ID + __( 'Comic Easel - Thumbnail', 'comiceasel' ), // Name + array( 'classname' => __CLASS__, 'description' => __( 'Display a thumbnail of a comic, by chapter, newest, first or random, clickable to go to the comic.', 'comiceasel' ), ) // Args + ); } function widget($args, $instance) { @@ -155,11 +161,6 @@ class ceo_thumbnail_widget extends WP_Widget { } } -function ceo_thumbnail_widget_register() { +add_action( 'widgets_init', function(){ register_widget('ceo_thumbnail_widget'); -} - -add_action('widgets_init', 'ceo_thumbnail_widget_register'); - - -?> +});