Widgets updated for WordPress 4.3 - includes new widget to display a dropdown archive list of *all* the comics in the current chapter

This commit is contained in:
Frumph
2015-08-09 02:24:43 -07:00
parent 20243615ba
commit 8f481a0b92
9 changed files with 181 additions and 69 deletions
+12 -6
View File
@@ -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');
});
+11 -7
View File
@@ -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');
?>
+12 -9
View File
@@ -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');
+11 -8
View File
@@ -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');
+89
View File
@@ -0,0 +1,89 @@
<?php
/*
Widget Name: Comic List Dropdown of Current Chapter
Widget URI: http://comiceasel.org/
Description: Display a list of links of the latest comics.
Author: Philip M. Hofer (Frumph)
Version: 1.02
*/
function ceo_list_jump_to_comic($exclude = '', $return = false) {
global $post;
ceo_protect();
$output = '';
$terms = wp_get_object_terms( $post->ID, 'chapters');
if (!empty($terms)){
$term = reset($terms); // only one chapter
$output = '<form method="get" class="comic-archive-dropdown-form">';
$output .= '<select onchange="document.location.href=this.options[this.selectedIndex].value;">';
$level = 0;
$output .= '<option class="level-select" value="">'.__('Select','comiceasel').'</option>';
$post_args = array(
'post_type' => 'comic',
'order' => 'ASC',
'post_status' => 'publish',
'chapters' => $term->slug,
);
$qposts = get_posts( $post_args );
foreach($qposts as $qpost) {
$permalink = get_permalink($qpost->ID);
if (!empty($permalink)) $output .='<option class="level-0" value="'.esc_url($permalink).'">'.$qpost->post_title.'</option>';
}
$output .= '</select>';
$output .= '<noscript>';
$output .= '<div><input type="submit" value="View" /></div>';
$output .= '</noscript>';
$output .= '</form>';
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'];
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','comiceasel'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
</p>
<?php
}
}
add_action( 'widgets_init', function(){
register_widget('ceo_comic_list_dropdown_widget');
});
+12 -7
View File
@@ -9,10 +9,16 @@ Version: 1.1m
*/
class ceo_comic_navigation_widget extends WP_Widget {
function ceo_comic_navigation_widget() {
$widget_ops = array('classname' => __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');
+12 -11
View File
@@ -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');
?>
+11 -11
View File
@@ -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');
?>
});
+11 -10
View File
@@ -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');
?>
});