diff --git a/functions.php b/functions.php index d5e413d..924bfb9 100644 --- a/functions.php +++ b/functions.php @@ -1,6 +1,6 @@ comicpress_options["${type}_dimensions"])) { + list($width, $height) = explode("x", $comicpress_options_admin->comicpress_options["${type}_dimensions"]); + $dimensions = compact('width', 'height'); + } + + echo ' $value) { + echo $parameter . '="' . $value . '" '; + } + } + echo "/>"; +} + /** * Get the hyperlink to the first comic post in the database. * @return string The hyperlink to the first comic post, or false. @@ -357,8 +380,12 @@ function comicpress_list_storyline_categories($args = "") { * Text is taken from a custom field named "hovertext" */ function the_hovertext() { - $hovertext = get_post_meta( get_the_ID(), "hovertext", true ); - echo (empty($hovertext)) ? get_the_title() : $hovertext; + echo get_the_hovertext(); +} + +function get_the_hovertext() { + $hovertext = get_post_meta(get_the_ID(), "hovertext", true ); + return (empty($hovertext)) ? get_the_title() : $hovertext; } /** diff --git a/header.php b/header.php index 5ca736e..a6ba3ba 100644 --- a/header.php +++ b/header.php @@ -1,5 +1,10 @@ > + <?php diff --git a/index.php b/index.php index d3db2c4..67887de 100644 --- a/index.php +++ b/index.php @@ -6,7 +6,8 @@ while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post() ?> <div id="comic-head"></div> <div id="comic"> - <img src="<?php the_comic() ?>" alt="<?php the_title() ?>" title="<?php the_hovertext() ?>" /> + <?php the_comic_img_tag(get_comic_url('comic'), 'comic', array('alt' => get_the_title(), + 'title' => get_the_hovertext())) ?> </div> <div id="comic-foot"></div> <?php endwhile; ?> diff --git a/options.php b/options.php index 6ec1260..a333f01 100644 --- a/options.php +++ b/options.php @@ -5,7 +5,7 @@ class ComicPressOptionsAdmin { 'comic_category_id' => 1, 'comic_dimensions' => '760x', 'rss_dimensions' => '350x', - 'thumbnail_dimensions' => '125x' + 'archive_dimensions' => '125x' ); function render_admin() { @@ -97,7 +97,7 @@ class ComicPressOptionsAdmin { break; case 'comic_dimensions': case 'rss_dimensions': - case 'thumbnail_dimensions': + case 'archive_dimensions': if (is_array($_POST['cp'][$option])) { $dim_parts = array(); $is_valid = true; @@ -125,10 +125,16 @@ class ComicPressOptionsAdmin { $this->update_comicpress_options(); } } + + function init() { + $this->get_comicpress_options(); + } } $comicpress_options_admin = new ComicPressOptionsAdmin(); +add_action('init', array(&$comicpress_options_admin, 'init')); + function __comicpress_add_options_admin() { global $comicpress_options_admin; add_theme_page(__("ComicPress Options", 'comicpress'), __('ComicPress Options', 'comicpress'), 'edit_themes', basename(__FILE__), array($comicpress_options_admin, 'render_admin')); diff --git a/partials/options-admin.inc b/partials/options-admin.inc index 0862a4f..75d7b9f 100644 --- a/partials/options-admin.inc +++ b/partials/options-admin.inc @@ -14,7 +14,7 @@ <?php foreach (array( 'comic_dimensions' => __('Comic Image Dimensions', 'comicpress'), 'rss_dimensions' => __('RSS Feed Image Dimensions', 'comicpress'), - 'thumbnail_dimensions' => __('Thumbnail Image Dimensions', 'comicpress'), + 'archive_dimensions' => __('Archive Image Dimensions', 'comicpress'), ) as $field => $name) { ?> <tr> <th scope="row"><?php echo $name ?></th> diff --git a/test/FunctionsTest.php b/test/FunctionsTest.php new file mode 100644 index 0000000..f16922c --- /dev/null +++ b/test/FunctionsTest.php @@ -0,0 +1,46 @@ +<?php + +require_once('PHPUnit/Framework.php'); +require_once(dirname(__FILE__) . '/../../mockpress/mockpress.php'); +require_once(dirname(__FILE__) . '/../functions.php'); + +class FunctionsTest extends PHPUnit_Framework_TestCase { + function providerTestGenerateComicTag() { + return array( + array( + "150x150", + ), + array( + false, + ) + ); + } + + /** + * @dataProvider providerTestGenerateComicTag + */ + function testGenerateComicImgTag($dimensions) { + global $comicpress_options_admin; + + $comicpress_options_admin->comicpress_options['comic_dimensions'] = $dimensions; + + ob_start(); + the_comic_img_tag("test.gif", "comic"); + $source = ob_get_clean(); + + if (count($parts = explode("x", $dimensions)) == 2) { + list($width, $height) = $parts; + $dimensions = compact('width', 'height'); + } + + foreach (array('width', 'height') as $field) { + if (isset($dimensions[$field])) { + $this->assertTrue(strpos($source, "${field}=\"{$dimensions[$field]}\"") !== false, $field); + } else { + $this->assertTrue(strpos($source, "${field}=") === false, 'not set'); + } + } + } +} + +?> \ No newline at end of file