Compare commits

..

No commits in common. "master" and "2.9-release" have entirely different histories.

21 changed files with 468 additions and 85 deletions

View File

@ -24,15 +24,16 @@ class ComicPressMediaHandling {
function _get_filter($filter_to_use = null) {
global $comic_filename_filters;
if (!is_null($filter_to_use)) {
if (is_string($filter_to_use)) {
if (isset($comic_filename_filters[$filter_to_use])) {
return $this->_convert_to_percent_filter($comic_filename_filters[$filter_to_use]);
}
$options = get_option('comicpress_options');
// if (isset($options['comic_filename_filters'][$filter_to_use])) {
// return $this->_convert_to_percent_filter($options['comic_filename_filters'][$filter_to_use]);
// }
if (isset($options['comic_filename_filters'][$filter_to_use])) {
return $this->_convert_to_percent_filter($options['comic_filename_filters'][$filter_to_use]);
}
}
}
@ -42,6 +43,7 @@ class ComicPressMediaHandling {
} else {
$filter = str_replace('{date}', $this->default_filename_filter, $filter);
}
return $filter;
}
@ -98,6 +100,9 @@ class ComicPressMediaHandling {
case 'type-folder':
$value = $this->type_folder;
break;
case 'upload-path':
$value = get_option('upload_path');
break;
default:
if (preg_match('#^date-(.*)$#', $matches[1], $date_matches) > 0) {
if (isset($this->post_to_use)) {

View File

@ -19,6 +19,23 @@ function comicpress_admin_print_styles() {
wp_enqueue_style('comicpress-options', get_template_directory_uri() . '/options/options.css');
}
function comicpress_save_options_comic_filename_filters($incoming) {
$filters = array();
foreach (array_values($incoming) as $filter) {
$filters[wp_filter_nohtml_kses($filter['name'])] = wp_filter_nohtml_kses($filter['filter']);
}
if (!empty($filters)) {
if (!isset($filters['default'])) {
$cpmh = new ComicPressMediaHandling();
$filters['default'] = $cpmh->default_filter;
}
}
return $filters;
}
function comicpress_admin_page_head() { ?>
<!--[if lt ie 8]> <style> div.show { position: static; margin-top: 1px; } #cpadmin div.off { height: 22px; } </style> <![endif]-->
<?php }
@ -54,7 +71,7 @@ function comicpress_admin() {
'comic_clicks_next',
'disable_default_comic_nav',
'enable_widgetarea_use_sidebar_css',
'disable_lrsidebars',
'disable_lrsidebars_frontpage',
'disable_footer_text',
'disable_blogheader',
'enable_comicpress_debug',
@ -190,6 +207,13 @@ function comicpress_admin() {
) as $key) {
$comicpress_options['comicpress_config'][$key] = wp_filter_nohtml_kses($_REQUEST[$key]);
}
if (isset($_REQUEST['comic_filename_filters'])) {
$comicpress_options['comic_filename_filters'] = comicpress_save_options_comic_filename_filters($_REQUEST['comic_filename_filters']);
} else {
$comicpress_options['comic_filename_filters'] = array();
}
$tab = 'config';
update_option('comicpress_options',$comicpress_options);
}

View File

@ -133,7 +133,7 @@ function comicpress_load_options() {
'disable_comic_blog_frontpage' => false,
'disable_comic_blog_single' => false,
'disable_blog_frontpage' => false,
'disable_lrsidebars' => false,
'disable_lrsidebars_frontpage' => false,
'disable_footer_text' => false,
'disable_blogheader' => false,
'disable_page_titles' => false,
@ -206,7 +206,8 @@ function comicpress_load_options() {
'enable_comment_count_in_rss' => false,
'enable_scroll_to_top' => false,
'enable_page_load_info' => false
'enable_page_load_info' => false,
'comic_filename_filters' => array()
) as $field => $value) {
$comicpress_options[$field] = $value;

View File

@ -2,23 +2,20 @@
<?php include(get_template_directory() . '/layout-head.php'); ?>
<?php if (!$comicpress_options['disable_comic_frontpage'] && !$comicpress_options['disable_comic_blog_frontpage'] && !is_paged() ) {
if (is_archive()) echo "Thinks its an archive";
Protect();
$comic_query = 'showposts=1&cat="'.get_all_comic_categories_as_cat_string().'"';
query_posts($comic_query);
$comic_query = '&showposts=1&cat='.get_all_comic_categories_as_cat_string();
$posts = query_posts($comic_query);
$wp_query->is_archive = false;
if (have_posts()) {
while (have_posts()) : the_post();
comicpress_display_post();
endwhile;
comicpress_display_post();
}
Restore();
UnProtect();
Restore();
UnProtect();
wp_reset_query();
?>
<?php } ?>
<?php if (function_exists('the_project_wonderful_ad')) {
<?php if (function_exists('the_project_wonderful_ad')) {
the_project_wonderful_ad('blog');
} ?>

View File

@ -1,4 +1,5 @@
<?php if (comicpress_check_child_file('layout-foot') == false) { ?>
</div>
</div>
<?php if (is_cp_theme_layout('v3cr')) { ?>
</div>

View File

@ -16,32 +16,28 @@
<?php if (is_cp_theme_layout('v,v3c')) { ?>
<div id="content" class="narrowcolumn">
<?php get_sidebar('overblog'); ?>
<div class="column">
<?php } ?>
<?php
if (is_home()) {
if (!$comicpress_options['disable_comic_frontpage']) {
Protect();
$comic_query = 'showposts=1&cat='.get_all_comic_categories_as_cat_string();
query_posts($comic_query);
if (have_posts()) {
while (have_posts()) : the_post();
$temp_single = $wp_query->is_single;
$wp_query->is_single = true;
comicpress_display_comic_area();
$wp_query->is_single = $temp_single;
$temp_single = null;
endwhile;
}
Restore();
UnProtect();
wp_reset_query();
}
} else {
if (is_single() && in_comic_category()) {
comicpress_display_comic_area();
if (!$comicpress_options['disable_comic_frontpage'] && is_home()) {
Protect();
$comic_query = 'showposts=1&cat='.get_all_comic_categories_as_cat_string();
$posts = query_posts($comic_query);
if (have_posts()) {
while (have_posts()) : the_post();
global $frontpage_postnum;
$frontpage_postnum = $post->ID;
$wp_query->is_single = true;
comicpress_display_comic_area();
endwhile;
}
Restore();
UnProtect();
wp_reset_query();
}
if (is_single() & in_comic_category()) {
comicpress_display_comic_area();
}
?>
@ -50,7 +46,8 @@
<div id="subcontent-wrapper">
<?php } ?>
<?php if (is_cp_theme_layout('3c,rgn')) get_sidebar('left'); ?>
<?php get_sidebar('overblog'); ?>
<?php if (is_cp_theme_layout('3c,rgn')) get_sidebar('left'); ?>
<?php if (is_cp_theme_layout('v3cr')) { ?>
<div id="subcontent-wrapper-head"></div>
@ -59,7 +56,7 @@
<?php if (!is_cp_theme_layout('v3c,v')) { ?>
<div id="content" class="narrowcolumn">
<?php get_sidebar('overblog'); ?>
<div class="column">
<?php } ?>
<?php } ?>

View File

@ -112,7 +112,7 @@
</th>
<td>
<?php _e('Choose a directory to get the ARCHIVE/SEARCH thumbnails from.','comicpress'); ?>
<?php _e('Choose a directory to get the Archive/Search thumbnails from.','comicpress'); ?>
</td>
</tr>
@ -135,7 +135,7 @@
</th>
<td>
<?php _e('Choose a directory to get the MINI thumbnails from. (for archive-comic-list, etc.)','comicpress'); ?>
<?php _e('Choose a directory to get the Mini thumbnails from. (for archive-comic-list, etc.)','comicpress'); ?>
</td>
</tr>
@ -147,18 +147,86 @@
</tr>
<tr>
<th scope="row"><label for="archive_comic_width"><?php _e('ARCHIVE Thumbnail Width','comicpress'); ?></label></th>
<th scope="row"><label for="archive_comic_width"><?php _e('Archive Thumbnail Width','comicpress'); ?></label></th>
<td colspan="2">
<input type="text" size="7" name="archive_comic_width" id="archive_comic_width" value="<?php echo $comicpress_options['comicpress_config']['archive_comic_width']; ?>" />
</td>
</tr>
<tr class="alternate">
<th scope="row"><label for="mini_comic_width"><?php _e('MINI Thumbnail Width','comicpress'); ?></label></th>
<th scope="row"><label for="mini_comic_width"><?php _e('Mini Thumbnail Width','comicpress'); ?></label></th>
<td colspan="2">
<input type="text" size="7" name="mini_comic_width" id="mini_comic_width" value="<?php echo $comicpress_options['comicpress_config']['mini_comic_width']; ?>" />
</td>
</tr>
<?php
$cpmh = new ComicPressMediaHandling();
$filters = $comicpress_options['comic_filename_filters'];
if (!isset($filters['default'])) {
$filters['default'] = $cpmh->default_filter;
}
?>
<tr>
<th scope="row"><label><?php _e('Comic Filename Filters', 'comicpress'); ?></label></th>
<td colspan="2">
<p>
<em>For advanced users.</em> Specify the filters used to find the filename.
</p>
<div id="comicpress-comic-filename-filters-holder">
</div>
<a href="#" id="add-new-filter"><?php _e('Add new filter', 'comicpress') ?></a>
<script type="text/javascript">
(function($) {
var filter_data = [];
<?php foreach ($filters as $name => $filter) { ?>
filter_data.push({name:'<?php echo esc_js($name) ?>', filter:'<?php echo esc_js($filter) ?>'});
<?php } ?>
var build_row = function(data) {
var key = (new Date()).getTime();
var row = $('<div>\
<label>\
<strong>Key:</strong>\
<input type="text" size="15" name="comic_filename_filters[' + key + '][name]" value="' + data.name + '" />\
</label>\
<label>\
<strong>Filter:</strong>\
<input type="text" size="60" name="comic_filename_filters[' + key + '][filter]" value="' + data.filter + '" />\
</label>\
<a href="#">Remove</a>\
</div>');
$('a', row).click(function() {
if (confirm('<?php _e('Are you sure?', 'comicpress') ?>')) {
$(this).parent().remove();
}
return false;
});
return row;
};
$('#add-new-filter').click(function() {
$('#comicpress-comic-filename-filters-holder').append(build_row({name:'new_filter',filter:'%wordpress%'}));
return false;
});
$.each(filter_data, function(index, f) {
$('#comicpress-comic-filename-filters-holder').append(build_row(f));
});
}(jQuery))
</script>
<p>
Available parameters:
</p>
<ul>
<li><strong>%wordpress%</strong>: The WordPress root folder</li>
<li><strong>%type-folder%</strong>: The folder for the requested filetype (comic, rss, archive, or mini)</li>
<li><strong>%date-(format)%</strong>: The formatting to use for the requested date as per the <a href="http://php.net/date">date()</a> function <em>(ex: %date-Ymd% is <?php echo date('Ymd') ?>)</em></li>
<li><strong>%upload-path%</strong>: The value of the upload_path option, which is the destination upload directory for WPMU installs.</li>
</ul>
</td>
</tr>
</table>

View File

@ -152,12 +152,12 @@
</td>
</tr>
<tr>
<th scope="row"><label for="disable_lrsidebars"><?php _e('Disable left and right sidebars','comicpress'); ?></label></th>
<th scope="row"><label for="disable_lrsidebars_frontpage"><?php _e('Disable home page sidebars','comicpress'); ?></label></th>
<td>
<input id="disable_lrsidebars" name="disable_lrsidebars" type="checkbox" value="1" <?php checked(true, $comicpress_options['disable_lrsidebars']); ?> />
<input id="disable_lrsidebars_frontpage" name="disable_lrsidebars_frontpage" type="checkbox" value="1" <?php checked(true, $comicpress_options['disable_lrsidebars_frontpage']); ?> />
</td>
<td>
<?php _e('Your site will not display the default left/right sidebars. Minimalists dream. WARNING: Not recommended for use with Graphic Novel layouts.','comicpress'); ?>
<?php _e('Your home page will not display the default left/right sidebars. Minimalists dream. WARNING: Not recommended for use with Graphic Novel layouts.','comicpress'); ?>
</td>
</tr>
</table>

View File

@ -221,3 +221,20 @@ div.show .cpadmin-footer img{
min-width: 80px;
text-align: center;
}
/** Comic Filters **/
#comicpress-comic-filename-filters-holder div {
border: solid #ddd 1px;
padding: 3px;
overflow: hidden;
}
#comicpress-comic-filename-filters-holder label {
float: left;
display: inline;
}
#comicpress-comic-filename-filters-holder input {
margin: 0 10px;
}

View File

@ -1,5 +1,5 @@
<?php global $comicpress_options;
if (!$comicpress_options['disable_lrsidebars']) { ?>
if (!$comicpress_options['disable_lrsidebars_frontpage']) { ?>
<div id="sidebar-left">
<div class="sidebar-head"></div>
<div class="sidebar">

View File

@ -1,5 +1,5 @@
<?php global $comicpress_options;
if (!$comicpress_options['disable_lrsidebars']) { ?>
if (!$comicpress_options['disable_lrsidebars_frontpage']) { ?>
<div id="sidebar-right">
<div class="sidebar-head"></div>
<div class="sidebar">

View File

@ -86,6 +86,15 @@ acronym, abbr {
border-bottom: 1px dashed #000;
}
code {
padding: 5px;
margin: 10px 0;
display: block;
overflow: scroll;
font-family: 'Courier', monospace;
border: 1px dotted #000;
}
form {
margin: 0;
}
@ -434,8 +443,8 @@ h4, h4 a {
}
.narrowcolumn {
width: 550px;
padding: 0 5px;
width: 540px;
padding: 5px 10px;
}
/* add 10px to smaller width layouts */
@ -449,6 +458,10 @@ h4, h4 a {
overflow: hidden;
}
.column {
overflow: hidden;
}
.column_one {
width: 48%;
float: left;
@ -461,15 +474,18 @@ h4, h4 a {
padding: 1%;
}
.post {}
.post, .post-page {
clear: both;
text-align: left;
padding: 2px;
margin-bottom: 20px;
}
.post-content {
padding: 3px;
}
.home .post-blog .post-foot,
.page-template-blog-php .post-foot {
margin-bottom: 40px;
.post-foot {
}
.post-image {

View File

@ -41,7 +41,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
array(null, $default),
array('fail', $default),
array(array(), $default),
array('test', 'test')
array('test', 'test'),
array('test-from-option', 'test-from-option'),
);
}
@ -53,6 +54,12 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
$comic_filename_filters['test'] = 'test';
update_option('comicpress_options', array(
'comic_filename_filters' => array(
'test-from-option' => 'test-from-option'
)
));
$default = str_replace('{date}', $this->cpmh->default_filename_filter, $this->cpmh->default_filter);
$cpmh = $this->getMock('ComicPressMediaHandling', array('_convert_to_percent_filter'));
@ -95,7 +102,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
array('%test test%', '%test test%'),
array('%wordpress%/%type-folder%', vfsStream::url('root') . '/comic'),
array('%date-Y%', '2009'),
array('%wordpress%/%type-folder%/%date-Y-m-d%*.*', vfsStream::url('root') . '/comic/2009-01-01.*\..*')
array('%wordpress%/%type-folder%/%date-Y-m-d%*.*', vfsStream::url('root') . '/comic/2009-01-01.*\..*'),
array('%wordpress%/%upload-path%/%type-folder%/%date-Y-m-d%*.*', vfsStream::url('root') . '/1/files/comic/2009-01-01.*\..*')
);
}
@ -106,6 +114,8 @@ class ComicPressMediaHandlingTest extends PHPUnit_Framework_TestCase {
$cpmh = $this->getMock('ComicPressMediaHandling', array('_abspath'));
$cpmh->expects($this->any())->method('_abspath')->will($this->returnValue(vfsStream::url('root')));
update_option('upload_path', '1/files');
$this->assertEquals($expected_result, $cpmh->_expand_filter($filter, 'comic', (object)array('ID' => 1, 'post_date' => '2009-01-01 15:00:00')));
}

View File

@ -0,0 +1,43 @@
<?php
require_once('PHPUnit/Framework.php');
require_once('MockPress/mockpress.php');
require_once(dirname(__FILE__) . '/../comicpress-options.php');
require_once(dirname(__FILE__) . '/../classes/ComicPressMediaHandling.inc');
class ComicPressOptionsAdminTest extends PHPUnit_Framework_TestCase {
function providerTestSaveComicFilenameFilters() {
$cpmh = new ComicPressMediaHandling();
return array(
array(
array(),
array()
),
array(
array(1 => array(
'name' => 'test', 'filter' => 'myfilter'
)),
array(
'default' => $cpmh->default_filter,
'test' => 'myfilter'
)
),
array(
array(1 => array(
'name' => 'default', 'filter' => 'test'
)),
array(
'default' => 'test'
)
)
);
}
/**
* @dataProvider providerTestSaveComicFilenameFilters
*/
function testSaveComicFilenameFilters($incoming, $expected) {
$this->assertEquals($expected, comicpress_save_options_comic_filename_filters($incoming));
}
}

View File

@ -11,7 +11,6 @@ class ComicPressRelatedPostsTest extends PHPUnit_Framework_TestCase {
}
function testBuildPostTable() {
$this->markTestIncomplete();
$posts = array(
(object)array('ID' => 1, 'post_date' => '2009-01-01', 'post_title' => 'Post 1', 'guid' => 'post-1'),
(object)array('ID' => 2, 'post_date' => '2009-01-02', 'post_title' => 'Post 2', 'guid' => 'post-2'),
@ -32,7 +31,7 @@ class ComicPressRelatedPostsTest extends PHPUnit_Framework_TestCase {
wp_set_post_categories($id, $cats);
}
$output = '<div class="related_posts"><span>Title</span><table class="month-table"><tr><td class="archive-date" align="right">Jan 3, 2009</td><td class="archive-title"><a title="Post 3" href="post-3">Post 3</a></td></tr></table></div>';
$output = '<div class="related_posts"><h4>Title</h4><ul><li><a title="Post 3" href="post-3">Post 3</a></li></ul></div>';
$this->rp->related_categories = array(2);

3
test/fixtures/destroy-widgets.inc vendored Normal file
View File

@ -0,0 +1,3 @@
<?php
$builder->option('sidebars_widgets', array());

View File

@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://comicpress.local/" />
<title>TestComicFilenameFilters</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">TestComicFilenameFilters</td></tr>
</thead><tbody>
<tr>
<td>clickAndWait</td>
<td>link=ComicPress Options</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@id='comicpress-tab-config']/span</td>
<td></td>
</tr>
<!--Remove existing filters-->
<tr>
<td>storeXpathCount</td>
<td>//div[@id=&quot;comicpress-comic-filename-filters-holder&quot;]/div</td>
<td>filter_count</td>
</tr>
<tr>
<td>while</td>
<td>${filter_count} &gt; 0</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@id='comicpress-comic-filename-filters-holder']/div[1]/a</td>
<td></td>
</tr>
<tr>
<td>assertConfirmation</td>
<td>Are you sure?</td>
<td></td>
</tr>
<tr>
<td>storeXpathCount</td>
<td>//div[@id=&quot;comicpress-comic-filename-filters-holder&quot;]/div</td>
<td>filter_count</td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>comicpress_save_config</td>
<td></td>
</tr>
<!--Add and remove works-->
<tr>
<td>storeXpathCount</td>
<td>//div[@id=&quot;comicpress-comic-filename-filters-holder&quot;]/div</td>
<td>filter_count</td>
</tr>
<tr>
<td>echo</td>
<td>${filter_count}</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>add-new-filter</td>
<td></td>
</tr>
<tr>
<td>storeXpathCount</td>
<td>//div[@id=&quot;comicpress-comic-filename-filters-holder&quot;]/div</td>
<td>new_filter_count</td>
</tr>
<tr>
<td>assertEval</td>
<td>(${new_filter_count}) == (${filter_count} + 1)</td>
<td>true</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>comicpress_save_config</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>ComicPress Settings SAVED!</td>
<td></td>
</tr>
<tr>
<td>storeXpathCount</td>
<td>//div[@id=&quot;comicpress-comic-filename-filters-holder&quot;]/div</td>
<td>new_filter_count</td>
</tr>
<tr>
<td>assertEval</td>
<td>(${new_filter_count}) == (${filter_count} + 1)</td>
<td>true</td>
</tr>
<tr>
<td>click</td>
<td>//div[@id='comicpress-comic-filename-filters-holder']/div[2]/a</td>
<td></td>
</tr>
<tr>
<td>assertConfirmation</td>
<td>Are you sure?</td>
<td></td>
</tr>
<tr>
<td>storeXpathCount</td>
<td>//div[@id=&quot;comicpress-comic-filename-filters-holder&quot;]/div</td>
<td>new_filter_count</td>
</tr>
<tr>
<td>assertEval</td>
<td>(${new_filter_count}) == (${filter_count})</td>
<td>true</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>comicpress_save_config</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>ComicPress Settings SAVED!</td>
<td></td>
</tr>
<tr>
<td>storeXpathCount</td>
<td>//div[@id=&quot;comicpress-comic-filename-filters-holder&quot;]/div</td>
<td>new_filter_count</td>
</tr>
<tr>
<td>assertEval</td>
<td>(${new_filter_count}) == (${filter_count})</td>
<td>true</td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>ComicPress Settings SAVED!</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="" />
<title>TestWidgetInitIsCorrect</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">TestWidgetInitIsCorrect</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/wp-admin/</td>
<td></td>
</tr>
<!--Blow away all widgets-->
<tr>
<td>clickAndWait</td>
<td>link=Post Fixtures</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>link=themes/comicpress-2.8/test/fixtures/destroy-widgets.inc</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>pf[is_ok]</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//input[@value='Load Provided Data']</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>New data set loaded into WordPress.</td>
<td></td>
</tr>
<!--Check to make sure no widgets have lingering init code-->
<tr>
<td>clickAndWait</td>
<td>site-visit-button</td>
<td></td>
</tr>
<tr>
<td>assertElementNotPresent</td>
<td>//script[contains(text(), 'var image_root')]</td>
<td></td>
</tr>
<!--Done, go home-->
<tr>
<td>open</td>
<td>/wp-admin/</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>

View File

@ -45,12 +45,11 @@ class ComicPressBookmarkWidget extends WP_Widget {
);
}
function init() {
add_action('wp_head', array(&$this, 'wp_head'));
}
function init() {}
function is_active() {
add_action('template_redirect', array(&$this, 'template_redirect'));
add_action('wp_head', array(&$this, 'wp_head'));
add_action('template_redirect', array(&$this, 'template_redirect'));
}
function template_redirect() {

View File

@ -33,11 +33,8 @@ class ComicPressComicBlogPostWidget extends WP_Widget {
$temp_query = $wp_query->is_single;
$wp_query->is_single = true;
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
if (!empty($title)) { echo "<div class=\"comic-post-widget-header\">".$title."</div>\r\n"; }
if ($instance['showtitle']) { echo "<div class=\"comic-post-widget-title\">".get_the_title()."</div>\r\n"; }
if ($instance['showdate']) { echo "<div class=\"comic-post-widget-date\">".get_the_time('F jS, Y')."</div>\r\n"; }
if ( !empty( $title ) ) { echo "<div class=\"comic-post-header\">".$title."</div>\r\n"; }
the_content();
if ($instance['showcommentlink']) comicpress_display_comment_link();
$wp_query->is_single = $temp_query;
echo $after_widget;
}
@ -47,14 +44,11 @@ class ComicPressComicBlogPostWidget extends WP_Widget {
UnProtect();
wp_reset_query();
} else {
if (!empty($post->post_content) && in_comic_category()) {
if (!empty($post->post_content)) {
echo $before_widget;
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
if (!empty($title)) { echo "<div class=\"comic-post-widget-header\">".$title."</div>\r\n"; }
if ($instance['showtitle']) { echo "<div class=\"comic-post-widget-title\">".get_the_title()."</div>\r\n"; }
if ($instance['showdate']) { echo "<div class=\"comic-post-widget-date\">".get_the_time('F jS, Y')."</div>\r\n"; }
if ( !empty( $title ) ) { echo "<div class=\"comic-post-header\">".$title."</div>\r\n"; }
the_content();
if ($instance['showcommentlink']) comicpress_display_comment_link();
echo $after_widget;
}
}
@ -63,27 +57,17 @@ class ComicPressComicBlogPostWidget extends WP_Widget {
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['onlyhome'] = (bool)( $new_instance['onlyhome'] == 1 ? true : false );
$instance['showtitle'] = (bool)( $new_instance['showtitle'] == 1 ? true : false );
$instance['showdate'] = (bool)( $new_instance['showdate'] == 1 ? true : false );
$instance['showcommentlink'] = (bool)( $new_instance['showcommentlink'] == 1 ? true : false );
$instance['onlyhome'] = (bool)( $new_instance['onlyhome'] == 1 ? true : false );
return $instance;
}
function form($instance) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'onlyhome' => false, 'showtitle' => false, 'showdate' => false, 'showcommentlink' => false ) );
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'onlyhome' => false ) );
$title = strip_tags($instance['title']);
$onlyhome = $instance['onlyhome'];
$showtitle = $instance['showtitle'];
$showdate = $instance['showdate'];
$showcommentlink = $instance['showcommentlink'];
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>">Heading:<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('onlyhome'); ?>"><input id="<?php echo $this->get_field_id('onlyhome'); ?>" name="<?php echo $this->get_field_name('onlyhome'); ?>" type="checkbox" value="1" <?php checked(true, $onlyhome); ?> /> Display only on the home page?</label></p>
<p><label for="<?php echo $this->get_field_id('showtitle'); ?>"><input id="<?php echo $this->get_field_id('showtitle'); ?>" name="<?php echo $this->get_field_name('showtitle'); ?>" type="checkbox" value="1" <?php checked(true, $showtitle); ?> /> Show the title of the post?</label></p>
<p><label for="<?php echo $this->get_field_id('showdate'); ?>"><input id="<?php echo $this->get_field_id('showdate'); ?>" name="<?php echo $this->get_field_name('showdate'); ?>" type="checkbox" value="1" <?php checked(true, $showdate); ?> /> Show the date of the post?</label></p>
<p><label for="<?php echo $this->get_field_id('showcommentlink'); ?>"><input id="<?php echo $this->get_field_id('showcommentlink'); ?>" name="<?php echo $this->get_field_name('showcommentlink'); ?>" type="checkbox" value="1" <?php checked(true, $showcommentlink); ?> /> Show the comment link to the post?</label></p>
<p><label for="<?php echo $this->get_field_id('onlyhome'); ?>"><input id="<?php echo $this->get_field_id('onlyhome'); ?>" name="<?php echo $this->get_field_name('onlyhome'); ?>" type="checkbox" value="1" <?php checked(true, $onlyhome); ?> /> Display only on the home page?</label></p>
<?php
}
}

View File

@ -24,7 +24,7 @@ class ComicPressCommentsWidget extends WP_Widget {
echo $before_widget;
$title = empty($instance['title']) ? __('Permalink','comicpress') : apply_filters('widget_title', $instance['title']); ?>
<?php if ('open' == $post->comment_status) { ?><div class="comment-link"><?php comments_popup_link('<span class="comment-balloon comment-balloon-empty"> </span> Comment ', '<span class="comment-balloon">1</span> Comment ', '<span class="comment-balloon">%</span> Comment '); ?></div><?php } ?>
<?php if ('open' == $post->comment_status) { ?><div class="comment-link"><?php comments_popup_link('<span class="comment-balloon comment-balloon-empty">&rdquo;</span>Comment ', '<span class="comment-balloon">1</span>Comment ', '<span class="comment-balloon">%</span>Comment '); ?></div><?php } ?>
<?php
echo $after_widget;
}