start work on cleaning up widgets

This commit is contained in:
John Bintz 2009-11-21 10:24:01 -05:00
parent 7e4a5de392
commit f2129728ad
2 changed files with 66 additions and 52 deletions

View File

@ -5,10 +5,21 @@ if (function_exists('add_theme_support')) {
add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-thumbnails' );
} }
// Queue up the scripts. function __comicpress_widgets_init() {
wp_enqueue_script('comicpress_scroll', get_template_directory_uri() . '/js/scroll.js'); if (($dh = opendir(dirname(__FILE__) . '/widgets')) !== false) {
while (($file = readdir($dh)) !== false) {
if (strpos($file, '.inc') !== false) {
$class_name = preg_replace('#\..*$#', '', $file);
require_once(dirname(__FILE__) . '/widgets/' . $file);
$widget = new $class_name();
if (method_exists($widget, 'init')) { $widget->init(); }
}
}
closedir($dh);
}
}
function init_language(){ function __comicpress_init() {
// xili-language plugin check // xili-language plugin check
if (class_exists('xili_language')) { if (class_exists('xili_language')) {
define('THEME_TEXTDOMAIN','comicpress'); define('THEME_TEXTDOMAIN','comicpress');
@ -16,13 +27,18 @@ function init_language(){
} else { } else {
load_theme_textdomain( 'comicpress', get_template_directory() . '/lang' ); load_theme_textdomain( 'comicpress', get_template_directory() . '/lang' );
} }
}
add_action ('init', 'init_language'); // Queue up the scripts.
wp_enqueue_script('comicpress_scroll', get_template_directory_uri() . '/js/scroll.js');
// remove intense debates control over the comment numbers // remove intense debates control over the comment numbers
if (function_exists('id_get_comment_number')) { if (function_exists('id_get_comment_number')) {
remove_filter('comments_number','id_get_comment_number'); remove_filter('comments_number','id_get_comment_number');
} }
}
add_action('widgets_init', '__comicpress_widgets_init');
add_action('init', '__comicpress_init');
$comicpress_version = '2.9.0.0'; $comicpress_version = '2.9.0.0';

View File

@ -1,11 +1,9 @@
<?php <?php
class ComicPressAddonBookmarkWidget { class BookmarkWidget {
function init($comicpress) { function init() {
wp_register_sidebar_widget('comic-bookmark', __('Comic Bookmark', 'comicpress'), array(&$this, 'render_widget'), array('description' => __('Let your readers save their place via a cookie.', 'comicpress'))); wp_register_sidebar_widget('comic-bookmark', __('Comic Bookmark', 'comicpress'), array(&$this, 'render_widget'), array('description' => __('Let your readers save their place via a cookie.', 'comicpress')));
$this->comicpress = $comicpress;
add_action('wp_head', array(&$this, 'wp_head')); add_action('wp_head', array(&$this, 'wp_head'));
wp_enqueue_script('prototype'); wp_enqueue_script('prototype');