cleanup comic title and add test
This commit is contained in:
parent
b7c7536884
commit
85844be3e8
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
require_once('PHPUnit/Framework.php');
|
||||
require_once('MockPress/mockpress.php');
|
||||
require_once(dirname(__FILE__) . '/../../widgets/DisplayComicTitleWidget.inc');
|
||||
|
||||
class DisplayComicTitleWidgetTest extends PHPUnit_Framework_TestCase {
|
||||
function testRenderWidget() {
|
||||
global $post;
|
||||
|
||||
$post = (object)array(
|
||||
'post_title' => 'title',
|
||||
'guid' => 'link'
|
||||
);
|
||||
|
||||
$w = new DisplayComicTitleWidget();
|
||||
|
||||
ob_start();
|
||||
$w->widget(array('before_widget' => '', 'after_widget' => ''), array());
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertEquals('<a href="link">title</a>', $result);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/*
|
||||
Widget Name: comictitle
|
||||
Widget URI: http://comicpress.org/
|
||||
Description: Display a Title of the Comic that can be used in any area around the comic.
|
||||
Author: Philip M. Hofer (Frumph)
|
||||
Version: 1.01
|
||||
Author URI: http://frumph.net/
|
||||
|
||||
*/
|
||||
|
||||
class DisplayComicTitleWidget extends WP_Widget {
|
||||
function DisplayComicTitleWidget() {
|
||||
$widget_ops = array('classname' => 'DisplayComicTitleWidget', 'description' => __('Displays the title of the comic. (used in comic sidebars)','comicpress') );
|
||||
$this->WP_Widget('comictitle', __('Comic Title','comicpress'), $widget_ops);
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
extract($args, EXTR_SKIP);
|
||||
|
||||
echo $before_widget;
|
||||
?><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><?php
|
||||
echo $after_widget;
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
Widget Name: comictitle
|
||||
Widget URI: http://comicpress.org/
|
||||
Description: Display a Title of the Comic that can be used in any area around the comic.
|
||||
Author: Philip M. Hofer (Frumph)
|
||||
Version: 1.01
|
||||
Author URI: http://frumph.net/
|
||||
|
||||
*/
|
||||
|
||||
class widget_comicpress_comictitle extends WP_Widget {
|
||||
|
||||
function widget_comicpress_comictitle() {
|
||||
$widget_ops = array('classname' => 'widget_comicpress_comictitle', 'description' => __('Displays the title of the comic. (used in comic sidebars)','comicpress') );
|
||||
$this->WP_Widget('comictitle', __('Comic Title','comicpress'), $widget_ops);
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
global $post;
|
||||
extract($args, EXTR_SKIP);
|
||||
|
||||
echo $before_widget;?>
|
||||
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
||||
<?php echo $after_widget;
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
$instance = $old_instance;
|
||||
return $instance;
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
}
|
||||
}
|
||||
register_widget('widget_comicpress_comictitle');
|
||||
|
||||
|
||||
function widget_comicpress_comictitle_init() {
|
||||
new widget_comicpress_comictitle();
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'widget_comicpress_comictitle_init');
|
||||
|
||||
?>
|
Loading…
Reference in New Issue