build dropdown
This commit is contained in:
parent
9641d10cc9
commit
4a32858ab4
|
@ -5,8 +5,10 @@ class ComicPressPostMediaHandlingMetabox {
|
||||||
return array_keys(ComicPressMediaHandling::_bundle_global_variables());
|
return array_keys(ComicPressMediaHandling::_bundle_global_variables());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _verify_nonce() { return __comicpress_verify_nonce(); }
|
||||||
|
|
||||||
function save_post($post_id) {
|
function save_post($post_id) {
|
||||||
if (__comicpress_verify_nonce() == 'post-media-update') {
|
if ($this->_verify_nonce() == 'post-media-update') {
|
||||||
$info = $_REQUEST['cp'];
|
$info = $_REQUEST['cp'];
|
||||||
$result = array();
|
$result = array();
|
||||||
if (isset($info['urls'])) {
|
if (isset($info['urls'])) {
|
||||||
|
|
|
@ -7,29 +7,31 @@ require_once(dirname(__FILE__) . '/../classes/ComicPressPostMediaHandlingMetabox
|
||||||
class ComicPressPostMediaHandlingMetaboxTest extends PHPUnit_Framework_TestCase {
|
class ComicPressPostMediaHandlingMetaboxTest extends PHPUnit_Framework_TestCase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
_reset_wp();
|
_reset_wp();
|
||||||
|
$_REQUEST = array();
|
||||||
$this->pmh = new ComicPressPostMediaHandlingMetabox();
|
$this->pmh = new ComicPressPostMediaHandlingMetabox();
|
||||||
}
|
}
|
||||||
|
|
||||||
function providerTestPostMediaUpdate() {
|
function providerTestSavePost() {
|
||||||
return array(
|
return array(
|
||||||
array(array(), ''),
|
array(array(), array()),
|
||||||
array(array('post_id' => 'test'), ''),
|
array(array('urls' => false), array()),
|
||||||
array(array('post_id' => 1), array()),
|
array(array('urls' => array()), array()),
|
||||||
array(array('post_id' => 1, 'urls' => false), array()),
|
array(array('urls' => array('test' => 'test')), array()),
|
||||||
array(array('post_id' => 1, 'urls' => array()), array()),
|
array(array('urls' => array('comic' => 'test')), array('comic' => 'test')),
|
||||||
array(array('post_id' => 1, 'urls' => array('test' => 'test')), array()),
|
|
||||||
array(array('post_id' => 1, 'urls' => array('comic' => 'test')), array('comic' => 'test')),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providerTestPostMediaUpdate
|
* @dataProvider providerTestSavePost
|
||||||
*/
|
*/
|
||||||
function testPostMediaUpdate($input, $expected_post_metadata) {
|
function testSavePost($input, $expected_post_metadata) {
|
||||||
$pmh = $this->getMock('ComicPressPostMediaHandlingMetabox', array('_get_valid_types'));
|
$pmh = $this->getMock('ComicPressPostMediaHandlingMetabox', array('_get_valid_types', '_verify_nonce'));
|
||||||
|
$pmh->expects($this->once())->method('_verify_nonce')->will($this->returnValue(true));
|
||||||
$pmh->expects($this->any())->method('_get_valid_types')->will($this->returnValue(array('comic')));
|
$pmh->expects($this->any())->method('_get_valid_types')->will($this->returnValue(array('comic')));
|
||||||
|
|
||||||
$this->pmh->handle_post_media_update($input);
|
$_REQUEST = array('cp' => $input);
|
||||||
|
|
||||||
|
$pmh->save_post(1);
|
||||||
$this->assertEquals($expected_post_metadata, get_post_meta(1, 'backend_url_images', true));
|
$this->assertEquals($expected_post_metadata, get_post_meta(1, 'backend_url_images', true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,102 +0,0 @@
|
||||||
<?php
|
|
||||||
/*
|
|
||||||
Widget Name: comicpress archive dropdown
|
|
||||||
Widget URI: http://comicpress.org/
|
|
||||||
Description:
|
|
||||||
Author: Philip M. Hofer (Frumph)
|
|
||||||
Version: 1.04
|
|
||||||
Author URI: http://frumph.net/
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
function comicpress_archive_dropdown_storyline() {
|
|
||||||
$storyline = new ComicPressStoryline();
|
|
||||||
$storyline->create_structure(get_option('comicpress-storyline-category-order'));
|
|
||||||
$categories = array_keys($storyline->_structure);
|
|
||||||
foreach ($categories as $id) {
|
|
||||||
$post = ComicPressDBInterface::get_instance()->get_first_comic($id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
function comicpress_archive_dropdown() { ?>
|
|
||||||
<div class="archive-dropdown-wrap">
|
|
||||||
<select name="archive-dropdown" class="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
|
|
||||||
<option value=""><?php echo attribute_escape(__('Archives...','comicpress')); ?></option>
|
|
||||||
<?php wp_get_archives('type=monthly&format=option&show_post_count=-1'); ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<?php }
|
|
||||||
|
|
||||||
function comicpress_archive_dropdown_comics() {
|
|
||||||
global $post, $wp_query;
|
|
||||||
$temp_post = $post;
|
|
||||||
$temp_query = $wp_query;
|
|
||||||
?>
|
|
||||||
<div class="archive-dropdown-wrap">
|
|
||||||
<select name="archive-dropdown" class="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
|
|
||||||
<option value=""><?php echo attribute_escape(__('Archives...','comicpress')); ?></option>
|
|
||||||
<?php $comicArchive = new WP_Query(); $comicArchive->query('showposts=-1&cat='.get_all_comic_categories_as_cat_string());
|
|
||||||
while ($comicArchive->have_posts()) : $comicArchive->the_post() ?>
|
|
||||||
<option value="<?php echo get_permalink($post->ID) ?>"><?php the_title() ?></option>
|
|
||||||
<?php endwhile; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
$post = $temp_post; $temp_post = null;
|
|
||||||
$wp_query = $temp_query; $temp_query = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
class widget_comicpress_archive_dropdown extends WP_Widget {
|
|
||||||
|
|
||||||
function widget_comicpress_archive_dropdown() {
|
|
||||||
$widget_ops = array('classname' => 'widget_comicpress_archive_dropdown', 'description' => __('Display a dropdown list of your archives, styled.','comicpress') );
|
|
||||||
$this->WP_Widget('archive_dropdown', __('ComicPress Archive Dropdown','comicpress'), $widget_ops);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 $before_title . $title . $after_title; };
|
|
||||||
if ($instance['showcomicposts'] == 'on') {
|
|
||||||
comicpress_archive_dropdown_comics();
|
|
||||||
} else {
|
|
||||||
comicpress_archive_dropdown();
|
|
||||||
}
|
|
||||||
echo $after_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
function update($new_instance, $old_instance) {
|
|
||||||
$instance = $old_instance;
|
|
||||||
$instance['title'] = strip_tags($new_instance['title']);
|
|
||||||
$instance['showcomicposts'] = $new_instance['showcomicposts'];
|
|
||||||
return $instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
function form($instance) {
|
|
||||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'showcomicposts' => 'off' ) );
|
|
||||||
$title = strip_tags($instance['title']);
|
|
||||||
$showcomicposts = $instance['showcomicposts']; if (empty($showcomicposts)) $showcomicposts = 'off';
|
|
||||||
?>
|
|
||||||
<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('showcomicposts'); ?>"><strong><?php _e('Show individual comic posts?','comicpress'); ?></strong><br />
|
|
||||||
<input id="<?php echo $this->get_field_id('showcomicposts'); ?>" name="<?php echo $this->get_field_name('showcomicposts'); ?>" type="radio" value="on"<?php if ( $showcomicposts == "on") { echo " checked"; } ?> />On</label> <input id="<?php echo $this->get_field_id('showcomicposts'); ?>" name="<?php echo $this->get_field_name('showcomicposts'); ?>" type="radio" value="off"<?php if ( $showcomicposts == "off") { echo " checked"; } ?> />Off</label></p>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
register_widget('widget_comicpress_archive_dropdown');
|
|
||||||
|
|
||||||
|
|
||||||
function widget_comicpress_archive_dropdown_init() {
|
|
||||||
new widget_comicpress_archive_dropdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
add_action('widgets_init', 'widget_comicpress_archive_dropdown_init');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
Loading…
Reference in New Issue