Skip to content

Commit

Permalink
add new option/feature to allow map coordinates to comics usemap="#co…
Browse files Browse the repository at this point in the history
…micmap"
  • Loading branch information
Frumph committed Nov 9, 2014
1 parent 1c9c08d commit 662c0eb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
12 changes: 11 additions & 1 deletion functions/admin-meta.php
Expand Up @@ -328,7 +328,14 @@ function ceo_edit_toggles_in_post($post) {
<input id="comic-open-lightbox" name="comic-open-lightbox" type="checkbox" value="1" <?php checked(1, get_post_meta( $post->ID, 'comic-open-lightbox', true )); ?> />
</td>
</tr>
<tr>
<th scope="row"><label for="comic-has-map"><?php _e('*Comic has Map?','comiceasel'); ?></label></th>
<td>
<input id="comic-has-map" name="comic-has-map" type="checkbox" value="1" <?php checked(1, get_post_meta( $post->ID, 'comic-has-map', true )); ?> />
</td>
</tr>
</table>
<em><?php _e('* usemap="#comicmap" will be added, add the map html to the below html box','comiceasel'); ?></em>
<?php
}

Expand Down Expand Up @@ -441,6 +448,8 @@ function ceo_flash_upload_box($post) { ?>
<?php _e('Set the dimensions of the flash .swf comic.','comiceasel'); ?><br />
<label for="flash_height"><?php _e('Height:','comiceasel'); ?> <input id="flash_height" name="flash_height" type="text" value="<?php echo get_post_meta( $post->ID, 'flash_height', true ); ?>" /></label>
<label for="flash_width"><?php _e('Width:','comiceasel'); ?> <input id="flash_width" name="flash_width" type="text" value="<?php echo get_post_meta( $post->ID, 'flash_width', true ); ?>" /></label><br />
<br />
<em><?php _e('You still need to have a featured image set, it will be used as a thumbnail.','comiceasel'); ?></em>
<?php }

function ceo_add_comic_in_post() {
Expand Down Expand Up @@ -541,7 +550,8 @@ function ceo_handle_edit_save_comic($post_id, $post) {
'flash_width',
'media_url',
'media_width',
'link-to'
'link-to',
'comic-has-map'
);

foreach ($meta_array as $meta_key) {
Expand Down
29 changes: 21 additions & 8 deletions functions/displaycomic.php
Expand Up @@ -55,14 +55,25 @@ function ceo_display_motion_artist_comic($motion_artist_comic = '') {
function ceo_display_featured_image_comic($size = 'full') {
global $post;
$output = '';
$usemap = '';
$next_comic = '';
$comic_has_map = false;
$post_image_id = get_post_thumbnail_id($post->ID);
if ($post_image_id) { // If there's a featured image.
$hovertext = ceo_the_hovertext();
if (!empty($hovertext)) {
$hovertext = 'alt="'.$hovertext.'" title="'.$hovertext.'" ';
} else {
$hovertext = 'alt="'.get_the_title($post->ID).'" title="'.get_the_title($post->ID).'" ';
}
$thumbnail = wp_get_attachment_image_src( $post_image_id, $size, false);
if (is_array($thumbnail)) {
$thumbnail = reset($thumbnail);

$comic_lightbox = get_post_meta( $post->ID, 'comic-open-lightbox', true );
$comic_has_map = get_post_meta($post->ID, 'comic-has-map', true);
if (!$comic_has_map || is_wp_error($comic_has_map)) $comic_has_map = false;

$comic_lightbox = get_post_meta($post->ID, 'comic-open-lightbox', true);
if (is_wp_error($comic_lightbox)) $comic_lightbox = false;

if (ceo_pluginfo('navigate_only_chapters')) {
Expand All @@ -75,21 +86,23 @@ function ceo_display_featured_image_comic($size = 'full') {
$linkto = get_post_meta($post->ID, 'link-to', true);
if ($linkto) $next_comic = esc_url($linkto);

if ($linkto) $output .= '<a href="'.$linkto.'" title="'.$hovertext.'">';
if ($linkto && !$comic_has_map) $output .= '<a href="'.$linkto.'" title="'.$hovertext.'">';

if ($comic_lightbox && !$linkto) {
if ($comic_lightbox && !$linkto && !$comic_has_map) {
$output .= '<a href="'.$thumbnail.'" title="'.$hovertext.'" rel="lightbox">';
}

if (ceo_pluginfo('click_comic_next') && !empty($next_comic) && !$comic_lightbox && !$linkto) {
if (ceo_pluginfo('click_comic_next') && !empty($next_comic) && !$comic_lightbox && !$linkto && !$comic_has_map) {
$output .= '<a href="'.$next_comic.'" title="'.$hovertext.'">';
}

$output .= '<img src="'.$thumbnail.'" alt="'.$hovertext.'" title="'.$hovertext.'" />';
if ((ceo_pluginfo('click_comic_next') && !empty($next_comic)) || $comic_lightbox || $linkto) {
// only show if the comic is not linkable
if ($comic_has_map) $usemap = 'usemap="#comicmap" ';

$output .= '<img src="'.$thumbnail.'" '.$hovertext.' '.$usemap.' />';
if ((ceo_pluginfo('click_comic_next') && !empty($next_comic) && !$comic_has_map) || $comic_lightbox || $linkto) {
$output .= '</a>';
}
if ($comic_lightbox) $output .= '<div class="comic-lightbox-text">'.__('Click comic to view larger version.','comiceasel').'</div>';
// if ($comic_lightbox) $output .= '<div class="comic-lightbox-text">'.__('Click comic to view larger version.','comiceasel').'</div>';
}
}
return apply_filters('ceo_display_featured_image_comic', $output);
Expand Down

0 comments on commit 662c0eb

Please sign in to comment.