Compare commits
25 Commits
Author | SHA1 | Date |
---|---|---|
John Bintz | d87b36594b | |
John Bintz | 7b27b38ce5 | |
John Bintz | a31d8dbd3e | |
John Bintz | 7b2db6f334 | |
John Bintz | 4590eed89a | |
John Bintz | 1bb7edfd04 | |
John Bintz | 374871e158 | |
John Bintz | 2d251358f1 | |
John Bintz | af30e9353c | |
John Bintz | bf603ec8db | |
John Bintz | 85844be3e8 | |
John Bintz | b7c7536884 | |
John Bintz | d578797b7b | |
John Bintz | 81832d0b5a | |
John Bintz | 0b9e530582 | |
John Bintz | 4abe51d106 | |
John Bintz | 425102f97d | |
John Bintz | c3cb81a4ef | |
John Bintz | 14312979ad | |
John Bintz | b0a829ecb6 | |
John Bintz | 11045bc588 | |
John Bintz | fb642f0e85 | |
John Bintz | ba6281b2c3 | |
John Bintz | 50bbc6ff5a | |
John Bintz | a5a72a9128 |
|
@ -5,4 +5,3 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
coverage/
|
coverage/
|
||||||
comicpress-config.php
|
comicpress-config.php
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,11 @@ function display_comic_post() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="entry">
|
<div class="entry">
|
||||||
|
<?php if (!comicpress_check_child_file('partials/displaycomicpost-entry')) { ?>
|
||||||
<?php if (!is_single()) { global $more; $more = 0; } ?>
|
<?php if (!is_single()) { global $more; $more = 0; } ?>
|
||||||
<?php the_content(__('↓ Read the rest of this entry...','comicpress')); ?>
|
<?php the_content(__('↓ Read the rest of this entry...','comicpress')); ?>
|
||||||
<?php if (is_single()) wp_link_pages(array('before' => '<div class="linkpages"><span class="linkpages-pagetext">Pages:</span> ', 'after' => '</div>', 'next_or_number' => 'number')); ?>
|
<?php if (is_single()) wp_link_pages(array('before' => '<div class="linkpages"><span class="linkpages-pagetext">Pages:</span> ', 'after' => '</div>', 'next_or_number' => 'number')); ?>
|
||||||
|
<?php } ?>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="post-comic-extras">
|
<div class="post-comic-extras">
|
||||||
|
|
|
@ -33,4 +33,89 @@ class BuyThisPrintWidgetTest extends PHPUnit_Framework_TestCase {
|
||||||
function testUpdate($input, $expected_output) {
|
function testUpdate($input, $expected_output) {
|
||||||
$this->assertEquals($expected_output, $this->w->update($input));
|
$this->assertEquals($expected_output, $this->w->update($input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testBuyThisPrintStructure() {
|
||||||
|
global $post;
|
||||||
|
|
||||||
|
$w = $this->getMock('BuyThisPrintWidget', array('_load_options'));
|
||||||
|
$w->expects($this->once())->method('_load_options')->will($this->returnValue(array('buy_print_url' => 'buy_print_url_value')));
|
||||||
|
|
||||||
|
$post = (object)array('ID' => 10);
|
||||||
|
|
||||||
|
$result = $w->buy_print_structure();
|
||||||
|
|
||||||
|
$this->assertTag(array(
|
||||||
|
'tag' => 'form',
|
||||||
|
'attributes' => array('action' => 'buy_print_url_value')
|
||||||
|
), $result);
|
||||||
|
|
||||||
|
$this->assertTag(array(
|
||||||
|
'tag' => 'input',
|
||||||
|
'attributes' => array(
|
||||||
|
'name' => 'comic',
|
||||||
|
'value' => 10
|
||||||
|
)
|
||||||
|
), $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestWidget() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
array(), array(), array(), array('beforeafter'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('title' => 'title'), array(), array(), array('before:bt:title:at:after'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('title' => 'title'), array(), array('widget_title' => 'newtitle'), array('before:bt:newtitle:at:after'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(), array(), array('comicpress_buy_print_structure' => 'buy'), array('beforebuyafter'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(), array('buythiscomic' => 'yes'), array('comicpress_buy_print_structure' => 'buy'), array('beforebuyafter'),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(), array('buythiscomic' => 'sold'), array('comicpress_buy_print_structure' => 'buy'), array('beforeafter'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestWidget
|
||||||
|
*/
|
||||||
|
function testWidget($instance, $post_meta, $filter_expectations, $expected_matches) {
|
||||||
|
global $post;
|
||||||
|
|
||||||
|
$post = (object)array('ID' => 1);
|
||||||
|
foreach ($post_meta as $meta => $value) {
|
||||||
|
update_post_meta(1, $meta, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($filter_expectations as $name => $result) {
|
||||||
|
_set_filter_expectation($name, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$this->w->widget(array('before_widget' => 'before', 'after_widget' => 'after', 'before_title' => ':bt:', 'after_title' => ':at:'), $instance);
|
||||||
|
$content = ob_get_clean();
|
||||||
|
|
||||||
|
foreach ($expected_matches as $match) {
|
||||||
|
$this->assertTrue(preg_match("#${match}#mis", $content) > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function testForm() {
|
||||||
|
ob_start();
|
||||||
|
$this->w->form(array('title' => 'title'));
|
||||||
|
$content = ob_get_clean();
|
||||||
|
|
||||||
|
$this->assertTag(array(
|
||||||
|
'tag' => 'input',
|
||||||
|
'attributes' => array(
|
||||||
|
'type' => 'text',
|
||||||
|
'value' => 'title'
|
||||||
|
)
|
||||||
|
), $content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('PHPUnit/Framework.php');
|
||||||
|
require_once('MockPress/mockpress.php');
|
||||||
|
require_once(dirname(__FILE__) . '/../../widgets/ComicDateWidget.inc');
|
||||||
|
|
||||||
|
class ComicDateWidgetTest extends PHPUnit_Framework_TestCase {
|
||||||
|
function setUp() {
|
||||||
|
_reset_wp();
|
||||||
|
$this->w = new ComicDateWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestFilterInstance() {
|
||||||
|
return array(
|
||||||
|
array(array(), array('format' => 'F jS, Y')),
|
||||||
|
array(array('title' => 'test'), array('title' => 'test', 'format' => 'F jS, Y')),
|
||||||
|
array(array('title' => '<em>test</em>'), array('title' => 'test', 'format' => 'F jS, Y')),
|
||||||
|
array(array('title' => '<em>test</em>', 'format' => 'test'), array('title' => 'test', 'format' => 'test')),
|
||||||
|
array(array('title' => '<em>test</em>', 'format' => ''), array('title' => 'test', 'format' => 'F jS, Y')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestFilterInstance
|
||||||
|
*/
|
||||||
|
function testFilterInstance($new_instance, $expected_result) {
|
||||||
|
$this->assertEquals($expected_result, $this->w->_filter_instance($new_instance, array()));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testUpdate() {
|
||||||
|
$w = $this->getMock('ComicDateWidget', array('_filter_instance'));
|
||||||
|
$w->expects($this->once())->method('_filter_instance');
|
||||||
|
|
||||||
|
$w->update(array(), array());
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,22 +28,29 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
function providerTestIsNavLinkVisible() {
|
function providerTestIsNavLinkVisible() {
|
||||||
return array(
|
return array(
|
||||||
array('first', 1, 2, true),
|
array('first', 1, 2, 1, 1, 'on', true),
|
||||||
array('first', 1, 1, false),
|
array('first', 1, 1, 1, 1, 'on', false),
|
||||||
array('last', 1, 2, true),
|
array('last', 1, 2, 1, 1, 'on', true),
|
||||||
array('last', 1, 1, false),
|
array('last', 1, 1, 1, 1, 'on', false),
|
||||||
array('prev', 1, 2, true),
|
array('prev', 1, 2, 1, 1, 'on', true),
|
||||||
|
array('first', 1, 1, 2, 2, 'on', true),
|
||||||
|
array('first', 1, 1, 1, 2, 'on', false),
|
||||||
|
array('first', 1, 1, 2, 2, 'off', false),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerTestIsNavLinkVisible
|
* @dataProvider providerTestIsNavLinkVisible
|
||||||
*/
|
*/
|
||||||
function testIsNavLinkVisible($which, $current_id, $target_id, $expected_result) {
|
function testIsNavLinkVisible($which, $current_id, $target_id, $_page, $_numpages, $multi_page_support, $expected_result) {
|
||||||
|
global $page, $numpages;
|
||||||
|
$page = $_page;
|
||||||
|
$numpages = $_numpages;
|
||||||
|
|
||||||
$current = (object)array('ID' => $current_id);
|
$current = (object)array('ID' => $current_id);
|
||||||
$target = (object)array('ID' => $target_id);
|
$target = (object)array('ID' => $target_id);
|
||||||
|
|
||||||
$this->assertEquals($expected_result, $this->w->_will_display_nav_link($which, $current, $target));
|
$this->assertEquals($expected_result, $this->w->_will_display_nav_link($which, $current, $target, array('enable_multipage_support' => $multi_page_support)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function providerTestGroupNavigationButtons() {
|
function providerTestGroupNavigationButtons() {
|
||||||
|
@ -83,7 +90,39 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase {
|
||||||
$this->assertEquals($expected_grouping, $this->w->_group_navigation_buttons($buttons, array()));
|
$this->assertEquals($expected_grouping, $this->w->_group_navigation_buttons($buttons, array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
function providerTestSetUpPostNav() {
|
/**
|
||||||
|
* @expectedException PHPUnit_Framework_Error
|
||||||
|
*/
|
||||||
|
function testGroupNavigationButtonsNoDefaultGroup() {
|
||||||
|
_set_filter_expectation('comicpress_navigation_grouping_details', array(array()));
|
||||||
|
$this->w->_group_navigation_buttons(array(), array());
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetUpPostNavFilterReturnsData() {
|
||||||
|
_set_filter_expectation('comicpress_set_up_post_nav', array(array('test')));
|
||||||
|
|
||||||
|
$w = $this->getMock('GraphicalNavigationWidget', array('_new_comicpress_storyline', '_new_comicpress_navigation'));
|
||||||
|
$w->expects($this->once())->method('_new_comicpress_storyline')->will($this->returnValue($this->getMock('Storyline', array('set_order_via_flattened_storyline'))));
|
||||||
|
$w->expects($this->once())->method('_new_comicpress_navigation')->will($this->returnValue($this->getMock('Navigation', array('init', 'get_post_nav'))));
|
||||||
|
|
||||||
|
$this->assertEquals('test', $w->set_up_post_nav(array()));
|
||||||
|
}
|
||||||
|
|
||||||
|
function testSetUpPostNavFilterReturnsFalse() {
|
||||||
|
_set_filter_expectation('comicpress_set_up_post_nav', false);
|
||||||
|
|
||||||
|
$w = $this->getMock('GraphicalNavigationWidget', array('_new_comicpress_storyline', '_new_comicpress_navigation'));
|
||||||
|
$w->expects($this->once())->method('_new_comicpress_storyline')->will($this->returnValue($this->getMock('Storyline', array('set_order_via_flattened_storyline'))));
|
||||||
|
|
||||||
|
$n = $this->getMock('Navigation', array('init', 'get_post_nav'));
|
||||||
|
$n->expects($this->once())->method('get_post_nav')->will($this->returnValue('test'));
|
||||||
|
|
||||||
|
$w->expects($this->once())->method('_new_comicpress_navigation')->will($this->returnValue($n));
|
||||||
|
|
||||||
|
$this->assertEquals('test', $w->set_up_post_nav(array()));
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestSetUpPostNavStoryPrev() {
|
||||||
return array(
|
return array(
|
||||||
array(
|
array(
|
||||||
array('story_prev_acts_as_prev_in' => 'off'),
|
array('story_prev_acts_as_prev_in' => 'off'),
|
||||||
|
@ -109,10 +148,104 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerTestSetUpPostNav
|
* @dataProvider providerTestSetUpPostNavStoryPrev
|
||||||
*/
|
*/
|
||||||
function testComicPressSetUpPostNavFilter($instance, $post_nav, $expected_post_nav) {
|
function testComicPressSetUpPostNavFilterStoryPrev($instance, $post_nav, $expected_post_nav) {
|
||||||
$this->assertEquals($expected_post_nav, array_shift($this->w->comicpress_set_up_post_nav($post_nav, $instance)));
|
$this->assertEquals($expected_post_nav, array_shift($this->w->_comicpress_set_up_post_nav_story_prev(array($post_nav, null, $instance))));
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestComicPressSetUpPostNavFilterMultiPageSupport() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'off'),
|
||||||
|
array('previous' => 'prev-post', 'next' => 'next-post'),
|
||||||
|
1, 4,
|
||||||
|
array('previous' => 'prev-post', 'next' => 'next-post')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'on'),
|
||||||
|
array('previous' => (object)array('post_content' => 'test', 'guid' => 'prev-post', 'post_status' => 'publish'), 'next' => 'next-post'),
|
||||||
|
1, 1,
|
||||||
|
array('previous' => (object)array('post_content' => 'test', 'guid' => 'prev-post', 'post_status' => 'publish'), 'next' => 'next-post')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'on'),
|
||||||
|
array('previous' => (object)array('post_content' => 'test<!--nextpage-->test2', 'guid' => 'prev-post', 'post_status' => 'publish'), 'next' => 'next-post'),
|
||||||
|
1, 1,
|
||||||
|
array('previous' => 'prev-post/2/', 'next' => 'next-post')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'on'),
|
||||||
|
array('previous' => (object)array('post_content' => 'test', 'guid' => 'prev-post', 'post_status' => 'publish'), 'next' => 'next-post'),
|
||||||
|
1, 2,
|
||||||
|
array(
|
||||||
|
'previous' => (object)array('post_content' => 'test', 'guid' => 'prev-post', 'post_status' => 'publish'),
|
||||||
|
'next' => 'current-post/2/',
|
||||||
|
'storyline-next' => 'current-post/2/',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'on'),
|
||||||
|
array('previous' => 'prev-post', 'next' => 'next-post'),
|
||||||
|
2, 2,
|
||||||
|
array(
|
||||||
|
'previous' => 'current-post/1/',
|
||||||
|
'storyline-previous' => 'current-post/1/',
|
||||||
|
'next' => 'next-post'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('enable_multipage_support' => 'on'),
|
||||||
|
array(
|
||||||
|
'previous' => 'prev-post',
|
||||||
|
'next' => 'next-post',
|
||||||
|
'storyline-previous' => 'prev-post',
|
||||||
|
'storyline-next' => 'next-post',
|
||||||
|
),
|
||||||
|
2, 3,
|
||||||
|
array(
|
||||||
|
'previous' => 'current-post/1/',
|
||||||
|
'next' => 'current-post/3/',
|
||||||
|
'storyline-previous' => 'current-post/1/',
|
||||||
|
'storyline-next' => 'current-post/3/',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestComicPressSetUpPostNavFilterMultiPageSupport
|
||||||
|
* @return unknown_type
|
||||||
|
*/
|
||||||
|
function testComicPressSetUpPostNavFilterMultiPageSupport($instance, $post_nav, $_page, $_numpages, $expected_post_nav) {
|
||||||
|
global $post, $page, $numpages;
|
||||||
|
|
||||||
|
update_option('permalink_structure', '/test/');
|
||||||
|
|
||||||
|
$post = (object)array('ID' => 1, 'guid' => 'current-post', 'post_status' => 'publish');
|
||||||
|
$page = $_page;
|
||||||
|
$numpages = $_numpages;
|
||||||
|
|
||||||
|
$this->assertEquals($expected_post_nav, array_shift($this->w->_comicpress_set_up_post_nav_multi_page_support(array($post_nav, $post, $instance))));
|
||||||
|
}
|
||||||
|
|
||||||
|
function providerTestBuildInPostPageLink() {
|
||||||
|
return array(
|
||||||
|
array('', 'publish', 'post-guid&page=2'),
|
||||||
|
array('test', 'publish', 'post-guid/2'),
|
||||||
|
array('test/', 'publish', 'post-guid/2/'),
|
||||||
|
array('test/', 'draft', 'post-guid&page=2'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestBuildInPostPageLink
|
||||||
|
*/
|
||||||
|
function testBuildInPostPageLink($permalink_structure, $post_status, $expected_link) {
|
||||||
|
update_option('permalink_structure', $permalink_structure);
|
||||||
|
$post = (object)array('guid' => 'post-guid', 'post_status' => $post_status);
|
||||||
|
|
||||||
|
$this->assertEquals($expected_link, $this->w->_build_in_post_page_link($post, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSetUpPostNav() {
|
function testSetUpPostNav() {
|
||||||
|
@ -137,6 +270,43 @@ class GraphicalNavigationWidgetTest extends PHPUnit_Framework_TestCase {
|
||||||
|
|
||||||
$css->set_up_post_nav(array());
|
$css->set_up_post_nav(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function providerTestGetLinkNaviClassNames() {
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'previous', (object)array('guid' => 'previous'), array(), array(
|
||||||
|
'link' => 'previous',
|
||||||
|
'navi_class_names' => array('navi-previous', 'navi-prev')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'last', (object)array('guid' => 'last'), array('lastgohome' => 'off'), array(
|
||||||
|
'link' => 'last',
|
||||||
|
'navi_class_names' => array('navi-last')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'last', (object)array('guid' => 'last'), array('lastgohome' => 'on'), array(
|
||||||
|
'link' => 'home',
|
||||||
|
'navi_class_names' => array('navi-last')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'next', 'next', array(), array(
|
||||||
|
'link' => 'next',
|
||||||
|
'navi_class_names' => array('navi-next')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider providerTestGetLinkNaviClassNames
|
||||||
|
*/
|
||||||
|
function testGetLinkNaviClassNames($which, $target, $instance, $expected_results) {
|
||||||
|
_set_bloginfo('url', 'home');
|
||||||
|
$this->assertEquals($expected_results, $this->w->_get_link_navi_class_names($which, null, $target, $instance));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('PHPUnit/Framework.php');
|
||||||
|
require_once('MockPress/mockpress.php');
|
||||||
|
require_once(dirname(__FILE__) . '/../../widgets/SocialWidget.inc');
|
||||||
|
|
||||||
|
class SocialWidgetTest extends PHPUnit_Framework_TestCase {
|
||||||
|
function setUp() {
|
||||||
|
$this->w = new SocialWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
function testUpdate() {
|
||||||
|
$this->assertEquals(array(
|
||||||
|
'title' => 'title',
|
||||||
|
'urlstr' => 'urlstr',
|
||||||
|
'image' => 'image',
|
||||||
|
), $this->w->update(array(
|
||||||
|
'title' => '<em>title</em>',
|
||||||
|
'urlstr' => '<em>urlstr</em>',
|
||||||
|
'image' => '<em>image</em>',
|
||||||
|
), array()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,15 +15,19 @@ class BuyThisPrintWidget extends WP_Widget {
|
||||||
$this->WP_Widget('comicpress_buyprint', __('Buy This Print','comicpress'), $widget_ops);
|
$this->WP_Widget('comicpress_buyprint', __('Buy This Print','comicpress'), $widget_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
function init() {
|
function init() {
|
||||||
add_filter('comicpress_buy_print_structure', array(&$this, 'buy_print_structure'));
|
add_filter('comicpress_buy_print_structure', array(&$this, 'buy_print_structure'));
|
||||||
}
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
function widget($args, $instance) {
|
function widget($args, $instance) {
|
||||||
extract($args, EXTR_SKIP);
|
extract($args, EXTR_SKIP);
|
||||||
|
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
|
if (isset($instance['title'])) {
|
||||||
$title = apply_filters('widget_title', $instance['title']);
|
$title = apply_filters('widget_title', $instance['title']);
|
||||||
|
}
|
||||||
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
|
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
|
||||||
|
|
||||||
if ( get_post_meta( get_the_ID(), "buythiscomic", true ) !== 'sold' ) {
|
if ( get_post_meta( get_the_ID(), "buythiscomic", true ) !== 'sold' ) {
|
||||||
|
@ -33,13 +37,17 @@ class BuyThisPrintWidget extends WP_Widget {
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _load_options() { return comicpress_load_options(); }
|
||||||
|
|
||||||
function buy_print_structure($content = '') {
|
function buy_print_structure($content = '') {
|
||||||
$comicpress_options = comicpress_load_options(); ?>
|
$comicpress_options = $this->_load_options();
|
||||||
|
ob_start(); ?>
|
||||||
<div class="buythis"><form method="post" action="<?php echo $comicpress_options['buy_print_url']; ?>">
|
<div class="buythis"><form method="post" action="<?php echo $comicpress_options['buy_print_url']; ?>">
|
||||||
<input type="hidden" name="comic" value="<?php echo get_the_ID(); ?>" />
|
<input type="hidden" name="comic" value="<?php echo get_the_ID(); ?>" />
|
||||||
<button class="buythisbutton" type="submit" value="submit" name="submit"></button></form></div>
|
<button class="buythisbutton" type="submit" value="submit" name="submit"></button></form></div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<?php
|
<?php
|
||||||
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
function update($new_instance, $old_instance = array()) {
|
function update($new_instance, $old_instance = array()) {
|
||||||
|
@ -54,7 +62,7 @@ class BuyThisPrintWidget extends WP_Widget {
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
|
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
|
||||||
$title = strip_tags($instance['title']);
|
$title = strip_tags($instance['title']);
|
||||||
?>
|
?>
|
||||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','comicpress'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
|
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','comicpress'); ?> <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>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Widget Name: Comic Date
|
||||||
|
Widget URI: http://comicpress.org/
|
||||||
|
Description: Display's the date of post of the comic.
|
||||||
|
Author: Philip M. Hofer (Frumph)
|
||||||
|
Version: 1.01
|
||||||
|
Author URI: http://frumph.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ComicDateWidget extends WP_Widget {
|
||||||
|
function ComicDateWidget() {
|
||||||
|
$widget_ops = array('classname' => 'ComicDateWidget', 'description' => __('Displays the date of the post of the comic.','comicpress') );
|
||||||
|
$this->WP_Widget('comic_date', __('Comic Date','comicpress'), $widget_ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
function widget($args, $instance) {
|
||||||
|
extract($args, EXTR_SKIP);
|
||||||
|
|
||||||
|
echo $before_widget;
|
||||||
|
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
|
||||||
|
if ( !empty( $title ) ) { echo $title; } ?> <?php the_time($instance['format']); ?>
|
||||||
|
<?php echo $after_widget;
|
||||||
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
|
function _filter_instance($instance) {
|
||||||
|
foreach (array('title', 'format') as $field) {
|
||||||
|
if (isset($instance[$field])) {
|
||||||
|
$instance[$field] = strip_tags($instance[$field]);
|
||||||
|
}
|
||||||
|
switch ($field) {
|
||||||
|
case 'format':
|
||||||
|
if (empty($instance[$field])) {
|
||||||
|
$instance[$field] = 'F jS, Y';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update($new_instance, $old_instance) {
|
||||||
|
return $this->_filter_instance($new_instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
function form($instance) {
|
||||||
|
$instance = wp_parse_args((array) $instance, array('title' => '', 'format' => ''));
|
||||||
|
$instance = $this->_filter_instance($instance);
|
||||||
|
|
||||||
|
foreach (array(
|
||||||
|
'title' => __('Words to use before date:', 'comicpress'),
|
||||||
|
'format' => __('Format of the Time/Date:', 'comicpress'),
|
||||||
|
) as $field => $title) {
|
||||||
|
?><p>
|
||||||
|
<label for="<?php echo esc_attr($this->get_field_id($field)); ?>">
|
||||||
|
<?php echo esc_html($title); ?><br />
|
||||||
|
<input class="widefat" id="<?php echo esc_attr($this->get_field_id($field)); ?>"
|
||||||
|
name="<?php echo esc_attr($this->get_field_name($field)); ?>"
|
||||||
|
type="text"
|
||||||
|
value="<?php echo esc_attr($instance[$field]); ?>" />
|
||||||
|
</label>
|
||||||
|
</p><?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<p><a href="http://us.php.net/manual/en/function.date.php" target="_blank"><?php _e('Date String Examples','comicpress'); ?></a></p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ Author URI: http://frumph.net/
|
||||||
require_once(dirname(__FILE__) . '/../classes/ComicPressNavigation.inc');
|
require_once(dirname(__FILE__) . '/../classes/ComicPressNavigation.inc');
|
||||||
|
|
||||||
class GraphicalNavigationWidget extends WP_Widget {
|
class GraphicalNavigationWidget extends WP_Widget {
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
function GraphicalNavigationWidget() {
|
function GraphicalNavigationWidget() {
|
||||||
$widget_ops = array('classname' => 'WidgetComicPressGraphicalStorylineNavigation', 'description' => __('Displays Graphical Navigation Buttons. (used in comic sidebars)','comicpress') );
|
$widget_ops = array('classname' => 'WidgetComicPressGraphicalStorylineNavigation', 'description' => __('Displays Graphical Navigation Buttons. (used in comic sidebars)','comicpress') );
|
||||||
$this->WP_Widget('graphicalstorylinenavigation', __('Comic Navigation','comicpress'), $widget_ops);
|
$this->WP_Widget('graphicalstorylinenavigation', __('Comic Navigation','comicpress'), $widget_ops);
|
||||||
|
@ -25,7 +26,11 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
add_filter('comicpress_wrap_navigation_buttons', array(&$this, 'comicpress_wrap_navigation_buttons'), 10, 2);
|
add_filter('comicpress_wrap_navigation_buttons', array(&$this, 'comicpress_wrap_navigation_buttons'), 10, 2);
|
||||||
add_filter('comicpress_navigation_grouping_details', array(&$this, 'comicpress_navigation_grouping_details'));
|
add_filter('comicpress_navigation_grouping_details', array(&$this, 'comicpress_navigation_grouping_details'));
|
||||||
|
|
||||||
add_filter('comicpress_set_up_post_nav', array(&$this, 'comicpress_set_up_post_nav'), 10, 2);
|
foreach (get_class_methods($this) as $method) {
|
||||||
|
if (strpos($method, '_comicpress_set_up_post_nav') === 0) {
|
||||||
|
add_filter('comicpress_set_up_post_nav', array(&$this, $method), 10, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// these two need to be moved one level up
|
// these two need to be moved one level up
|
||||||
add_filter('comicpress_get_random_link_url', array(&$this, 'comicpress_get_random_link_url'));
|
add_filter('comicpress_get_random_link_url', array(&$this, 'comicpress_get_random_link_url'));
|
||||||
|
@ -54,17 +59,11 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
function comicpress_display_navigation_link($which, $current, $target, $instance, $content = '') {
|
function comicpress_display_navigation_link($which, $current, $target, $instance, $content = '') {
|
||||||
global $id;
|
global $id;
|
||||||
|
|
||||||
$css_name_mapping = array(
|
|
||||||
'story_prev' => 'prevchap',
|
|
||||||
'previous' => 'prev',
|
|
||||||
'story_next' => 'nextchap'
|
|
||||||
);
|
|
||||||
|
|
||||||
$ok = true;
|
$ok = true;
|
||||||
switch ($which) {
|
switch ($which) {
|
||||||
case 'first':
|
case 'first':
|
||||||
case 'last':
|
case 'last':
|
||||||
$ok = $this->_will_display_nav_link($which, $current, $target);
|
$ok = $this->_will_display_nav_link($which, $current, $target, $instance);
|
||||||
break;
|
break;
|
||||||
case 'previous':
|
case 'previous':
|
||||||
case 'next':
|
case 'next':
|
||||||
|
@ -89,23 +88,9 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
case 'story_next':
|
case 'story_next':
|
||||||
case 'story_prev_in':
|
case 'story_prev_in':
|
||||||
case 'story_next_in':
|
case 'story_next_in':
|
||||||
$obj_ok = false;
|
extract($this->_get_link_navi_class_names($which, $current, $target, $instance));
|
||||||
$navi_class_names = array("navi-${which}");
|
|
||||||
$link = false;
|
|
||||||
if (is_object($target)) {
|
|
||||||
$obj_ok = true;
|
|
||||||
if (isset($css_name_mapping[$which])) { $navi_class_names[] = "navi-{$css_name_mapping[$which]}"; }
|
|
||||||
|
|
||||||
$link = get_permalink($target->ID);
|
if ($ok && $link) {
|
||||||
if (($which == 'last') && ($instance['lastgohome'] == 'on')) { $link = get_bloginfo('url'); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($filter_link = array_shift(apply_filters('comicpress_display_navigation_link', $link, $which, $current, $target, $instance))) !== false) {
|
|
||||||
$link = $filter_link;
|
|
||||||
$obj_ok = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ok && $obj_ok) {
|
|
||||||
?><a href="<?php echo $link; ?>"
|
?><a href="<?php echo $link; ?>"
|
||||||
class="navi <?php echo implode(" ", $navi_class_names); ?>"
|
class="navi <?php echo implode(" ", $navi_class_names); ?>"
|
||||||
title="<?php echo $instance["${which}_title"]; ?>"><?php echo htmlspecialchars_decode($instance["${which}_title"]); ?></a><?php
|
title="<?php echo $instance["${which}_title"]; ?>"><?php echo htmlspecialchars_decode($instance["${which}_title"]); ?></a><?php
|
||||||
|
@ -148,6 +133,33 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
}
|
}
|
||||||
return array($which, $current, $target, $instance, ob_get_clean());
|
return array($which, $current, $target, $instance, ob_get_clean());
|
||||||
}
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
|
function _get_link_navi_class_names($which, $current, $target, $instance) {
|
||||||
|
$css_name_mapping = array(
|
||||||
|
'story_prev' => 'prevchap',
|
||||||
|
'previous' => 'prev',
|
||||||
|
'story_next' => 'nextchap'
|
||||||
|
);
|
||||||
|
|
||||||
|
$navi_class_names = array("navi-${which}");
|
||||||
|
if (isset($css_name_mapping[$which])) { $navi_class_names[] = "navi-{$css_name_mapping[$which]}"; }
|
||||||
|
|
||||||
|
$link = false;
|
||||||
|
if (is_object($target)) {
|
||||||
|
if (($which == 'last') && ($instance['lastgohome'] == 'on')) {
|
||||||
|
$link = get_bloginfo('url');
|
||||||
|
} else {
|
||||||
|
$link = get_permalink($target);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (is_string($target)) {
|
||||||
|
$link = $target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return compact('link', 'navi_class_names');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the combination of target and current post will show or hide this nav link.
|
* Returns true if the combination of target and current post will show or hide this nav link.
|
||||||
|
@ -157,11 +169,19 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
* @param object $target The target post to comare to.
|
* @param object $target The target post to comare to.
|
||||||
* @return boolean True if this link should be visible.
|
* @return boolean True if this link should be visible.
|
||||||
*/
|
*/
|
||||||
function _will_display_nav_link($which, $current, $target) {
|
function _will_display_nav_link($which, $current, $target, $instance) {
|
||||||
|
global $page, $numpages;
|
||||||
|
|
||||||
$return = true;
|
$return = true;
|
||||||
|
|
||||||
switch ($which) {
|
switch ($which) {
|
||||||
case 'first':
|
case 'first':
|
||||||
|
if ($instance['enable_multipage_support'] == 'on') {
|
||||||
|
if ($page != 1 && $numpages > 1) {
|
||||||
|
$return = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
case 'last':
|
case 'last':
|
||||||
$return = ($target->ID != $current->ID);
|
$return = ($target->ID != $current->ID);
|
||||||
break;
|
break;
|
||||||
|
@ -173,22 +193,24 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
return apply_filters('comicpress_graphical_navigation_will_display_nav_link', $return, $which, $current, $target);
|
return apply_filters('comicpress_graphical_navigation_will_display_nav_link', $return, $which, $current, $target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
/**
|
/**
|
||||||
* Get the order of the buttons to be displayed on-screen.
|
* Get the order of the buttons to be displayed on-screen.
|
||||||
*/
|
*/
|
||||||
function comicpress_display_navigation_order($order = array()) {
|
function comicpress_display_navigation_order($order = array()) {
|
||||||
return array(
|
return array(
|
||||||
'first', 'story_prev', 'story_prev_in', 'previous', 'archives', 'random', 'comictitle', 'comments', 'buyprint', 'next', 'story_next_in', 'story_next', 'last'
|
'first', 'previous', 'story_prev_in', 'story_prev', 'archives', 'random', 'comictitle', 'comments', 'buyprint', 'story_next', 'story_next_in', 'next', 'last'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function comicpress_navigation_grouping_details($details = array()) {
|
function comicpress_navigation_grouping_details($details = array()) {
|
||||||
return array(
|
return array(
|
||||||
'comic_navi_left' => array('first', 'story_prev', 'story_prev_in', 'previous'),
|
'comic_navi_left' => array('first', 'previous', 'story_prev_in', 'story_prev'),
|
||||||
'comic_navi_center' => true,
|
'comic_navi_center' => true,
|
||||||
'comic_navi_right' => array('next', 'story_next_in', 'story_next', 'last')
|
'comic_navi_right' => array('story_next', 'story_next_in', 'next', 'last')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
function _group_navigation_buttons($buttons = array(), $grouped_buttons = array()) {
|
function _group_navigation_buttons($buttons = array(), $grouped_buttons = array()) {
|
||||||
$grouping_hash = array();
|
$grouping_hash = array();
|
||||||
|
@ -206,7 +228,9 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
|
|
||||||
if (is_null($default_group)) {
|
if (is_null($default_group)) {
|
||||||
trigger_error('No default group defined for filter comicpress_navigation_grouping_details', E_USER_WARNING);
|
trigger_error('No default group defined for filter comicpress_navigation_grouping_details', E_USER_WARNING);
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
}
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
$groups = array();
|
$groups = array();
|
||||||
foreach ($buttons as $key => $button) {
|
foreach ($buttons as $key => $button) {
|
||||||
|
@ -278,8 +302,10 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
function _new_comicpress_storyline() { return new ComicPressStoryline(); }
|
function _new_comicpress_storyline() { return new ComicPressStoryline(); }
|
||||||
function _new_comicpress_navigation() { return new ComicPressNavigation(); }
|
function _new_comicpress_navigation() { return new ComicPressNavigation(); }
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
function set_up_post_nav($instance) {
|
function set_up_post_nav($instance) {
|
||||||
global $post;
|
global $post;
|
||||||
|
@ -291,7 +317,7 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
$navigation->init($storyline);
|
$navigation->init($storyline);
|
||||||
$post_nav = $navigation->get_post_nav($post);
|
$post_nav = $navigation->get_post_nav($post);
|
||||||
|
|
||||||
$result = apply_filters('comicpress_set_up_post_nav', $post_nav, $instance);
|
$result = apply_filters('comicpress_set_up_post_nav', array($post_nav, $post, $instance));
|
||||||
if (is_array($result)) {
|
if (is_array($result)) {
|
||||||
return array_shift($result);
|
return array_shift($result);
|
||||||
} else {
|
} else {
|
||||||
|
@ -299,13 +325,52 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function comicpress_set_up_post_nav($post_nav, $instance) {
|
function _build_in_post_page_link($post, $page) {
|
||||||
|
if (!get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending'))) {
|
||||||
|
return get_permalink($post) . "&page=${page}";
|
||||||
|
} else {
|
||||||
|
return trailingslashit(get_permalink($post)) . user_trailingslashit($page, 'single_paged');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function _comicpress_set_up_post_nav_story_prev($info) {
|
||||||
|
list($post_nav, $post, $instance) = $info;
|
||||||
if ($instance['story_prev_acts_as_prev_in'] == 'on') {
|
if ($instance['story_prev_acts_as_prev_in'] == 'on') {
|
||||||
if ($post_nav['storyline-previous'] !== false) {
|
if ($post_nav['storyline-previous'] !== false) {
|
||||||
$post_nav['storyline-chapter-previous'] = $post_nav['storyline-previous'];
|
$post_nav['storyline-chapter-previous'] = $post_nav['storyline-previous'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array($post_nav, $instance);
|
return array($post_nav, $post, $instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _get_page_count($post) {
|
||||||
|
return preg_match_all('#<!--nextpage-->#', $post->post_content, $matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _comicpress_set_up_post_nav_multi_page_support($info) {
|
||||||
|
global $page, $numpages;
|
||||||
|
list($post_nav, $post, $instance) = $info;
|
||||||
|
|
||||||
|
if ($instance['enable_multipage_support'] == 'on') {
|
||||||
|
if ($page < $numpages && $numpages != 1) {
|
||||||
|
$post_nav['next'] = $post_nav['storyline-next'] = $this->_build_in_post_page_link($post, $page + 1);
|
||||||
|
}
|
||||||
|
if ($page != 1 && $numpages > 1) {
|
||||||
|
$post_nav['previous'] = $post_nav['storyline-previous'] = $this->_build_in_post_page_link($post, $page - 1);
|
||||||
|
}
|
||||||
|
if ($page == 1) {
|
||||||
|
foreach (array('previous', 'previous_storyline') as $which) {
|
||||||
|
if (isset($post_nav[$which])) {
|
||||||
|
$count = $this->_get_page_count($post_nav[$which]);
|
||||||
|
if (!empty($count)) {
|
||||||
|
$post_nav[$which] = $this->_build_in_post_page_link($post_nav[$which], $count + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($post_nav, $post, $instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -320,7 +385,7 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
'first', 'story_prev', 'story_next', 'story_prev_in',
|
'first', 'story_prev', 'story_next', 'story_prev_in',
|
||||||
'story_next_in', 'previous', 'random', 'archives',
|
'story_next_in', 'previous', 'random', 'archives',
|
||||||
'comments', 'next', 'last', 'buyprint', 'comictitle', 'lastgohome',
|
'comments', 'next', 'last', 'buyprint', 'comictitle', 'lastgohome',
|
||||||
'story_prev_acts_as_prev_in'
|
'story_prev_acts_as_prev_in', 'enable_multipage_support'
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($all_fields as $field) {
|
foreach ($all_fields as $field) {
|
||||||
|
@ -352,7 +417,8 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
'buyprint' => 'off',
|
'buyprint' => 'off',
|
||||||
'comictitle' => 'off',
|
'comictitle' => 'off',
|
||||||
'lastgohome' => 'off',
|
'lastgohome' => 'off',
|
||||||
'story_prev_acts_as_prev_in' => 'on'
|
'story_prev_acts_as_prev_in' => 'on',
|
||||||
|
'enable_multipage_support' => 'off',
|
||||||
);
|
);
|
||||||
|
|
||||||
$title_defaults = array(
|
$title_defaults = array(
|
||||||
|
@ -385,7 +451,8 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
'archives' => __('Archives', 'comicpress'),
|
'archives' => __('Archives', 'comicpress'),
|
||||||
'comments' => __('Comments', 'comicpress'),
|
'comments' => __('Comments', 'comicpress'),
|
||||||
'random' => __('Random', 'comicpress'),
|
'random' => __('Random', 'comicpress'),
|
||||||
'buyprint' => __('Buy Print', 'comicpress')
|
'buyprint' => __('Buy Print', 'comicpress'),
|
||||||
|
'enable_multipage_support' => __('Enable multi-page support', 'comicpress'),
|
||||||
) as $field => $label) {
|
) as $field => $label) {
|
||||||
$title_field = "${field}_title"; ?>
|
$title_field = "${field}_title"; ?>
|
||||||
<div class="comicpress-field-holder">
|
<div class="comicpress-field-holder">
|
||||||
|
@ -428,6 +495,15 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<?php break;
|
<?php break;
|
||||||
|
case "enable_multipage_support": ?>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
<em>
|
||||||
|
<?php _e('If using posts with multiple pages, previous/next navigation will link to pages if available.', 'comicpress') ?>
|
||||||
|
</em>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php break;
|
||||||
case "story_prev": ?>
|
case "story_prev": ?>
|
||||||
<div>
|
<div>
|
||||||
<label>
|
<label>
|
||||||
|
@ -435,12 +511,12 @@ class GraphicalNavigationWidget extends WP_Widget {
|
||||||
name="<?php echo $this->get_field_name('story_prev_acts_as_prev_in'); ?>"
|
name="<?php echo $this->get_field_name('story_prev_acts_as_prev_in'); ?>"
|
||||||
type="checkbox" class="comicpress-field" value="yes"<?php if ($instance['story_prev_acts_as_prev_in'] == "on") { echo ' checked="checked"'; } ?> />
|
type="checkbox" class="comicpress-field" value="yes"<?php if ($instance['story_prev_acts_as_prev_in'] == "on") { echo ' checked="checked"'; } ?> />
|
||||||
<strong><?php _e('Enable alternate behavior', 'comicpress'); ?></strong>
|
<strong><?php _e('Enable alternate behavior', 'comicpress'); ?></strong>
|
||||||
|
</label>
|
||||||
<p>
|
<p>
|
||||||
<em>
|
<em>
|
||||||
<?php _e('If the current post is not at the start of a chapter, the button will act the same as "Previous In Chapter".', 'comicpress') ?>
|
<?php _e('If the current post is not at the start of a chapter, the button will act the same as "Previous In Chapter".', 'comicpress') ?>
|
||||||
</em>
|
</em>
|
||||||
</p>
|
</p>
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
<?php break;
|
<?php break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Widget Name: ComicPress Social
|
||||||
|
Widget URI: http://comicpress.org/
|
||||||
|
Description: Translates a user's URL line into a social widget, associating it to images.
|
||||||
|
Author: Philip M. Hofer (Frumph)
|
||||||
|
Version: 1.01
|
||||||
|
Author URI: http://frumph.net/
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class SocialWidget extends WP_Widget {
|
||||||
|
|
||||||
|
function SocialWidget() {
|
||||||
|
$widget_ops = array('classname' => 'SocialWidget', 'description' => __('Display a user defined social button, with translated URL','comicpress') );
|
||||||
|
$this->WP_Widget('social', __('ComicPress Social','comicpress'), $widget_ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
function widget($args, $instance) {
|
||||||
|
global $post;
|
||||||
|
extract($args, EXTR_SKIP);
|
||||||
|
|
||||||
|
/* Get the info necessary */
|
||||||
|
$permalink = get_permalink($post->ID);
|
||||||
|
$posttitle = $post->post_title;
|
||||||
|
$posttitle = str_replace(' ', '%20', $posttitle);
|
||||||
|
$title = $instance['title'];
|
||||||
|
if (empty($title)) $title = $posttitle;
|
||||||
|
|
||||||
|
$rss = get_bloginfo('rss2_url');
|
||||||
|
$blogname = urlencode(get_bloginfo('name')." ".get_bloginfo('description'));
|
||||||
|
// Grab the excerpt, if there is no excerpt, create one
|
||||||
|
$excerpt = urlencode(strip_tags(strip_shortcodes($post->post_excerpt)));
|
||||||
|
if ($excerpt == "") {
|
||||||
|
$excerpt = urlencode(substr(strip_tags(strip_shortcodes($post->post_content)),0,250));
|
||||||
|
}
|
||||||
|
// Clean the excerpt for use with links
|
||||||
|
$excerpt = str_replace('+','%20',$excerpt);
|
||||||
|
|
||||||
|
echo $before_widget;
|
||||||
|
$url = $instance['urlstr'];
|
||||||
|
$url = str_replace('[URL]', $permalink, $url);
|
||||||
|
$url = str_replace('[TITLE]', $posttitle, $url);
|
||||||
|
$url = str_replace('[RSS]', $rss, $url);
|
||||||
|
$url = str_replace('[BLOGNAME]', $blogname, $url);
|
||||||
|
$url = str_replace('[EXCERPT]', $excerpt, $url); ?>
|
||||||
|
|
||||||
|
<div class="social-<?php echo sanitize_title($title); ?>">
|
||||||
|
<?php if (!empty($instance['image'])) { ?>
|
||||||
|
<a href="<?php echo $url; ?>" target="_blank" class="social-<?php echo sanitize_title($title); ?>"><img src="<?php echo $instance['image']; ?>" alt="<?php echo $title; ?>" /></a>
|
||||||
|
<?php } else { ?>
|
||||||
|
<a href="<?php echo $url; ?>" target="_blank" class="social-<?php echo sanitize_title($title); ?>"><?php echo $title; ?></a>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php echo $after_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
function update($new_instance, $old_instance) {
|
||||||
|
$instance = array();
|
||||||
|
foreach (array('title', 'urlstr', 'image') as $field) {
|
||||||
|
$instance[$field] = strip_tags($new_instance[$field]);
|
||||||
|
}
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
function form($instance) {
|
||||||
|
$instance = wp_parse_args( (array) $instance, array( 'title' => 'Share This!', 'urlstr' => '', 'image' => '') );
|
||||||
|
$title = strip_tags($instance['title']);
|
||||||
|
if (empty($title)) $title = 'Share This!';
|
||||||
|
$urlstr = strip_tags($instance['urlstr']);
|
||||||
|
$image = strip_tags($instance['image']);
|
||||||
|
?>
|
||||||
|
<small>
|
||||||
|
<strong>Translated Strings:</strong> [URL] [TITLE] [RSS] [BLOGNAME] [EXCERPT]<br />
|
||||||
|
<strong>Examples:</strong><br />
|
||||||
|
http://twitter.com/home?status=[TITLE]%20-%20[URL]<br />
|
||||||
|
http://www.stumbleupon.com/submit?url=[URL]&title=[TITLE]<br />
|
||||||
|
</small>
|
||||||
|
<br />
|
||||||
|
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title (used as CSS marker too):','comicpress'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
|
||||||
|
<p><label for="<?php echo $this->get_field_id('urlstr'); ?>"><?php _e('URL','comicpress'); ?> <input class="widefat" id="<?php echo $this->get_field_id('urlstr'); ?>" name="<?php echo $this->get_field_name('urlstr'); ?>" type="text" value="<?php echo attribute_escape($urlstr); ?>" /></label></p>
|
||||||
|
<p><label for="<?php echo $this->get_field_id('image'); ?>"><?php _e('Image','comicpress'); ?> <input class="widefat" id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="text" value="<?php echo attribute_escape($image); ?>" /></label></p>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,59 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Widget Name: Comic Date
|
|
||||||
Widget URI: http://comicpress.org/
|
|
||||||
Description: Display's the date of post of the comic.
|
|
||||||
Author: Philip M. Hofer (Frumph)
|
|
||||||
Version: 1.01
|
|
||||||
Author URI: http://frumph.net/
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
class widget_comicpress_comic_date extends WP_Widget {
|
|
||||||
|
|
||||||
function widget_comicpress_comic_date() {
|
|
||||||
$widget_ops = array('classname' => 'widget_comicpress_comic_date', 'description' => __('Displays the date of the post of the comic.','comicpress') );
|
|
||||||
$this->WP_Widget('comic_date', __('Comic Date','comicpress'), $widget_ops);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 $title; } ?> <?php the_time($instance['format']); ?>
|
|
||||||
<?php echo $after_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
function update($new_instance, $old_instance) {
|
|
||||||
$instance = $old_instance;
|
|
||||||
$instance['title'] = strip_tags($new_instance['title']);
|
|
||||||
$instance['format'] = strip_tags($new_instance['format']);
|
|
||||||
if (empty($instance['format'])) $instance['format'] = 'F jS, Y';
|
|
||||||
return $instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
function form($instance) {
|
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'format' => '' ) );
|
|
||||||
$title = strip_tags($instance['title']);
|
|
||||||
$format = strip_tags($instance['format']);
|
|
||||||
if (empty($format)) $format = 'F jS, Y';
|
|
||||||
?>
|
|
||||||
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Words to use before date:','comicpress'); ?><br /><input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
|
|
||||||
<p><label for="<?php echo $this->get_field_id('format'); ?>"><?php _e('Format of the Time/Date:','comicpress'); ?><br /><input class="widefat" id="<?php echo $this->get_field_id('format'); ?>" name="<?php echo $this->get_field_name('format'); ?>" type="text" value="<?php echo attribute_escape($format); ?>" /></label></p>
|
|
||||||
<p><a href="http://us.php.net/manual/en/function.date.php" target="_blank"><?php _e('Date String Examples','comicpress'); ?></a></p>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
register_widget('widget_comicpress_comic_date');
|
|
||||||
|
|
||||||
|
|
||||||
function widget_comicpress_comic_date_init() {
|
|
||||||
new widget_comicpress_comic_date();
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('widgets_init', 'widget_comicpress_comic_date_init');
|
|
||||||
|
|
||||||
?>
|
|
|
@ -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