mirror of
https://github.com/Frumph/comic-easel.git
synced 2026-08-26 18:06:41 -04:00
df7a6f78ba
The domain has been 'comiceasel' since 2012 while the wordpress.org slug is 'comic-easel'. Language packs from translate.wordpress.org are keyed to the slug, so they could never load; no working translation ever shipped against the old domain. Renames the domain in every gettext call, in load_plugin_textdomain(), in both Text Domain headers, and on the lang/ template files, which already carried comic-easel domain markers internally. Option keys, admin page slugs, nonce actions and style handles that share the comiceasel prefix are deliberately left alone; only the $domain argument moved. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
101 lines
3.7 KiB
PHP
101 lines
3.7 KiB
PHP
<?php
|
|
/*
|
|
Widget Name: Comic List Dropdown of Current Chapter
|
|
Widget URI: https://github.com/Frumph/comic-easel
|
|
Description: Display a list of links of the latest comics.
|
|
Author: Philip M. Hofer (Frumph)
|
|
Version: 1.02
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) exit;
|
|
|
|
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-list-dropdown-form">';
|
|
$output .= '<select onchange="document.location.href=this.options[this.selectedIndex].value;">';
|
|
$level = 0;
|
|
$output .= '<option class="level-select" value="">'.__('Jump To','comic-easel').'</option>';
|
|
$post_args = array(
|
|
'showposts' => -1,
|
|
'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).'">'.esc_html($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', 'comic-easel' ), // Name
|
|
array( 'classname' => __CLASS__, 'description' => __( 'Display dropdown list of comics.', 'comic-easel' ), ) // Args
|
|
);
|
|
}
|
|
|
|
function widget($args, $instance) {
|
|
global $post;
|
|
|
|
extract($args, EXTR_SKIP);
|
|
echo $before_widget;
|
|
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
|
|
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
|
|
if ((is_home() || is_front_page()) && !is_paged() && !ceo_pluginfo('disable_comic_on_home_page')) {
|
|
$chapter_on_home = '';
|
|
$chapter_on_home = get_term_by( 'id', ceo_pluginfo('chapter_on_home'), 'chapters');
|
|
$chapter_on_home = (!is_wp_error($chapter_on_home) && !empty($chapter_on_home)) ? '&chapters='.$chapter_on_home->slug : '';
|
|
$order = (ceo_pluginfo('display_first_comic_on_home_page')) ? 'asc' : 'desc';
|
|
$query_args = 'post_type=comic&showposts=1&order='.$order.$chapter_on_home;
|
|
apply_filters('ceo_display_comic_mininav_home_query', $query_args);
|
|
$comicFrontpage = new WP_Query(); $comicFrontpage->query($query_args);
|
|
while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post();
|
|
ceo_list_jump_to_comic($instance['exclude'], false);
|
|
endwhile;
|
|
} elseif (!empty($post)) {
|
|
ceo_list_jump_to_comic($instance['exclude'], false);
|
|
}
|
|
echo $after_widget;
|
|
}
|
|
|
|
function update($new_instance, $old_instance) {
|
|
$instance = $old_instance;
|
|
$instance['title'] = wp_strip_all_tags($new_instance['title']);
|
|
$instance['exclude'] = wp_strip_all_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 esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title:','comic-easel'); ?> <input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
|
|
</p>
|
|
<?php
|
|
}
|
|
}
|