added preliminary support for motion artist comics, disabled for right now with define in comiceasel.php

added random in chapter only code to the navigation widgets/navigation.php
This commit is contained in:
Frumph
2013-06-09 16:46:17 -07:00
parent 160f478d10
commit 7ec779f350
9 changed files with 251 additions and 93 deletions

View File

@@ -39,7 +39,8 @@ if ( isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'update-op
'disable_related_comics',
'display_first_comic_on_home_page',
'disable_style_sheet',
'enable_transcripts_in_comic_posts'
'enable_transcripts_in_comic_posts',
'enable_motion_artist_support'
) as $key) {
if (!isset($_REQUEST[$key])) $_REQUEST[$key] = 0;
$ceo_options[$key] = (bool)( $_REQUEST[$key] == 1 ? true : false );

View File

@@ -3,7 +3,7 @@
Plugin Name: Comic Easel
Plugin URI: http://comiceasel.com
Description: Comic Easel allows you to incorporate a WebComic using the WordPress Media Library functionality with Navigation into almost all WordPress themes. With just a few modifications of adding injection do_action locations into a theme, you can have the theme of your choice display and manage a webcomic.
Version: 1.3.12
Version: 1.3.13
Author: Philip M. Hofer (Frumph)
Author URI: http://frumph.net/
@@ -27,6 +27,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
add_action('init', 'ceo_initialize_post_types');
define('CEO_FEATURE_DISABLE_MOTION_ARTIST', true);
function ceo_initialize_post_types() {
if (!post_type_exists('comic')) {
$labels = array(
@@ -311,7 +313,8 @@ function ceo_load_options($reset = false) {
'display_first_comic_on_home_page' => false,
'disable_style_sheet' => false,
'enable_transcripts_in_comic_posts' => false,
'enable_chapter_only_random' => false
'enable_chapter_only_random' => false,
'enable_motion_artist_support' => false
) as $field => $value) {
$ceo_config[$field] = $value;
}
@@ -352,7 +355,7 @@ function ceo_pluginfo($whichinfo = null) {
// comic-easel plugin directory/url
'plugin_url' => plugin_dir_url(dirname (__FILE__)) . 'comic-easel',
'plugin_path' => trailingslashit(ABSPATH) . ceo_get_plugin_path(),
'version' => '1.3.12-github'
'version' => '1.3.13-github'
);
// Combine em.
$ceo_pluginfo = array_merge($ceo_pluginfo, $ceo_addinfo);

View File

@@ -223,4 +223,9 @@ a.transcript-title {
.comicbutton {
margin: 0 5px;
display: inline-block;
}
.MADoc {
margin: 0 auto !important;
padding: 0 !important;
}

View File

@@ -159,6 +159,66 @@ function ceo_manage_comic_columns($column_name, $id) {
} // end switch
}
function ceo_edit_select_motion_artist_directory_in_post($post) {
$current_directory = get_post_meta( $post->ID, 'ma-directory', true );
if (empty($current_directory) || is_wp_error($current_directory)) $current_directory = '';
$dirs_to_search = array_unique(array(get_template_directory(),get_stylesheet_directory()));
$ma_directories = array();
$ma_dir = get_stylesheet_directory() . '/motion-artist';
if (is_dir($ma_dir)) {
$thisdir = null;
$thisdir = array();
$thisdir = glob($ma_dir. '/*');
$ma_directories = array_merge($ma_directories, $thisdir);
}
if (empty($ma_directories) || is_wp_error($ma_directories)) echo "No 'motion-artist' directory found in theme.";
?>
<div class="admin-motion-artist" style="">
<table>
<tr>
<td colspan="2">
<?php
if (!empty($ma_directories) && !is_wp_error($ma_directories)) {
?>
<select name="ma-directory" id="ma-directory">
<option class="level-0" value="" <?php if (empty($current_directory)) { ?>selected="selected"<?php } ?>><?php echo __('None', 'comiceasel'); ?></option>
<?php
foreach ($ma_directories as $ma_dirs) {
if (is_dir($ma_dirs)) {
$ma_dir_name = basename($ma_dirs); ?>
<option class="level-0" value="<?php echo $ma_dir_name; ?>" <?php if ($current_directory == $ma_dir_name) { ?>selected="selected"<?php } ?>><?php echo $ma_dir_name; ?></option>
<?php }
}
?>
</select>
</td>
</tr>
<?php } else { ?>
No 'motion-artist' directory found in theme.<br />
<?php }
$current_height = get_post_meta( $post->ID, 'ma-height', true );
$current_width = get_post_meta( $post->ID, 'ma-width', true );
if (empty($current_height) || is_wp_error($current_height)) $current_height = '';
if (empty($current_height) || is_wp_error($current_width)) $current_width = '';
?>
<tr>
<td>
Height: <input id="ma-height" name="ma-height" style="width: 40px;" type="text" value="<?php echo $current_height; ?>" />
</td>
<td>
Width: <input id="ma-width" name="ma-width" style="width: 40px;" type="text" value="<?php echo $current_width; ?>" />
</td>
</tr>
</table>
</div>
<?php
}
function ceo_edit_comic_in_post($post) { ?>
<div class="admin-comicbox" style="margin:0; padding:0; overflow:hidden;">
<center>
@@ -265,6 +325,8 @@ function ceo_add_comic_in_post() {
add_meta_box('ceo_html_above_comic', __('HTML (Above) Comic', 'comiceasel'), 'ceo_edit_html_above_comic', 'comic', 'normal', 'high');
add_meta_box('ceo_html_below_comic', __('HTML (Below) Comic', 'comiceasel'), 'ceo_edit_html_below_comic', 'comic', 'normal', 'high');
}
if (!defined('CEO_FEATURE_DISABLE_MOTION_ARTIST') && ceo_pluginfo('enable_motion_artist_support'))
add_meta_box('ceo_select_motion_artist_directory_in_post', __('Select Motion Artist Comic', 'comiceasel'), 'ceo_edit_select_motion_artist_directory_in_post', 'comic', 'side', 'high');
}
function ceo_handle_edit_save_comic($post_id, $post) {
@@ -294,7 +356,10 @@ function ceo_handle_edit_save_comic($post_id, $post) {
'comic-gallery-columns',
'comic-open-lightbox',
'comic-gallery-full',
'comic-gallery-jquery'
'comic-gallery-jquery',
'ma-directory',
'ma-height',
'ma-width'
);
foreach ($meta_array as $meta_key) {
@@ -307,4 +372,20 @@ function ceo_handle_edit_save_comic($post_id, $post) {
elseif ( '' == $new_meta_value && $meta_value )
delete_post_meta( $post_id, $meta_key, $meta_value );
}
if (isset($_POST['ma-directory']) && !empty($_POST['ma-directory'])) {
$ma_directories = array();
$ma_dir = esc_textarea( $_POST['ma-directory'] );
$ma_dir = get_stylesheet_directory() . '/motion-artist/'.$ma_dir.'/scripts';
if (is_dir($ma_dir)) {
$thisdir = null;
$thisdir = array();
$thisdir = glob($ma_dir. '/*.js');
$ma_script = str_replace('.js', '', basename(reset($thisdir)));
update_post_meta( $post_id, 'ma-id', $ma_script );
}
} else {
delete_post_meta($post_id, 'ma-id');
delete_post_meta($post_id, 'ma-height');
delete_post_meta($post_id, 'ma-width');
}
}

View File

@@ -1,98 +1,130 @@
<?php
if (!defined('CEO_FEATURE_DISABLE_MOTION_ARTIST'))
add_action('wp_head', 'ceo_add_motion_artist_header_info');
function ceo_add_motion_artist_header_info() {
global $post;
if (!empty($post)) {
$motion_artist_comic = get_post_meta( $post->ID, 'ma-directory', true );
$motion_artist_id = get_post_meta( $post->ID, 'ma-id', true );
if (!empty($motion_artist_comic)) {
echo '<link rel="stylesheet" type="text/css" href="'.get_stylesheet_directory_uri().'/motion-artist/'.$motion_artist_comic.'/css/MA_style.css">'."\r\n";
echo '<script src="http://motionartist.smithmicro.com/public/motionartist_1.0.js"></script>'."\r\n";
echo '<script src="'.get_stylesheet_directory_uri().'/motion-artist/'.$motion_artist_comic.'/scripts/'.$motion_artist_id.'.js"></script>';
}
}
}
function ceo_display_comic($size = 'full') {
global $post;
if ( post_password_required() ) {
return __('This comic is password protected.','comiceasel');
}
$output = '';
$comic_galleries = get_post_meta( $post->ID, 'comic-gallery', true );
if (is_wp_error($comic_galleries)) $comic_galleries = false;
$comic_galleries_full = get_post_meta( $post->ID, 'comic-gallery-full', true );
if (is_wp_error($comic_galleries_full)) $comic_galleries_full = false;
$post_image_id = get_post_thumbnail_id($post->ID);
if (ceo_the_above_html()) $output .= html_entity_decode(ceo_the_above_html())."\r\n";
if ((is_numeric($post_image_id) && !$comic_galleries) || ($comic_galleries && !$comic_galleries_full)) {
$thumbnail = wp_get_attachment_image_src( $post_image_id, $size, false);
if (is_array($thumbnail)) {
$thumbnail = reset($thumbnail);
$hovertext = ceo_the_hovertext();
$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')) {
$next_comic = ceo_get_next_comic_in_chapter_permalink();
} else {
$next_comic = ceo_get_next_comic_permalink();
}
if ($comic_lightbox) {
$output .= '<a href="'.$thumbnail.'" title="'.$hovertext.'" rel="lightbox">';
}
if (ceo_pluginfo('click_comic_next') && !empty($next_comic) && !$comic_lightbox) {
$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) {
$output .= '</a>';
}
if ($comic_lightbox) $output .= '<div class="comic-lightbox-text">'.__('Click comic to view larger version.','comiceasel').'</div>';
}
}
if (is_numeric($post_image_id) && $comic_galleries) {
if ($comic_galleries_full) {
$hovertext = ceo_the_hovertext();
$comic_lightbox = get_post_meta( $post->ID, 'comic-open-lightbox', true );
$comic_galleries_jquery = get_post_meta( $post->ID, 'comic-gallery-jquery', true );
if($images = get_posts(array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'numberposts' => -1, // show all
'post_status' => null,
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC'
))) {
$count = 0;
if ($comic_galleries_jquery) wp_enqueue_script('multicomic', ceo_pluginfo('plugin_url') . '/js/multicomic.js', null, null, true);
foreach($images as $image) {
if ($comic_galleries_jquery) $output .= '<div id="comic-'.$count.'" class="comicpane">';
$thumbnail = wp_get_attachment_image_src($image->ID, 'full');
$thumbnail = reset($thumbnail);
if (ceo_pluginfo('navigate_only_chapters')) {
$next_comic = ceo_get_next_comic_in_chapter_permalink();
} else {
$next_comic = ceo_get_next_comic_permalink();
}
if ($comic_lightbox) {
$output .= '<a href="'.$thumbnail.'" title="'.$hovertext.'" rel="lightbox">';
}
if (ceo_pluginfo('click_comic_next') && !empty($next_comic) && !$comic_lightbox) {
$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) {
$output .= '</a>';
}
if ($comic_galleries_jquery) $output .= "</div>\r\n";
$count += 1;
$motion_artist_comic = get_post_meta( $post->ID, 'ma-directory', true );
if (!empty($motion_artist_comic) && !is_wp_error($motion_artist_comic) && !defined('CEO_FEATURE_DISABLE_MOTION_ARTIST')) {
$motion_artist_id = get_post_meta( $post->ID, 'ma-id', true );
$motion_artist_height = get_post_meta( $post->ID, 'ma-height', true);
$motion_artist_width = get_post_meta( $post->ID, 'ma-width', true);
echo "<center>\r\n";
echo '<div class="MADoc">'."\r\n";
echo ' <canvas id="'.$motion_artist_id.'_canvas" width="'.$motion_artist_width.'" height="'.$motion_artist_height.'"></canvas>'."\r\n";
echo '</div>'."\r\n";
echo '<div class="MAButtons">'."\r\n";
echo ' <ul class="MAButtonSet">'."\r\n";
echo ' <li><button class="MAButton" id="'.$motion_artist_id.'_pauseButton">Play</button></li>'."\r\n";
echo ' </ul>'."\r\n";
echo '</div>'."\r\n";
echo "</center>\r\n";
} else {
$comic_galleries = get_post_meta( $post->ID, 'comic-gallery', true );
if (is_wp_error($comic_galleries)) $comic_galleries = false;
$comic_galleries_full = get_post_meta( $post->ID, 'comic-gallery-full', true );
if (is_wp_error($comic_galleries_full)) $comic_galleries_full = false;
$post_image_id = get_post_thumbnail_id($post->ID);
if ((is_numeric($post_image_id) && !$comic_galleries) || ($comic_galleries && !$comic_galleries_full)) {
$thumbnail = wp_get_attachment_image_src( $post_image_id, $size, false);
if (is_array($thumbnail)) {
$thumbnail = reset($thumbnail);
$hovertext = ceo_the_hovertext();
$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')) {
$next_comic = ceo_get_next_comic_in_chapter_permalink();
} else {
$next_comic = ceo_get_next_comic_permalink();
}
if ($comic_lightbox) {
$output .= '<a href="'.$thumbnail.'" title="'.$hovertext.'" rel="lightbox">';
}
if (ceo_pluginfo('click_comic_next') && !empty($next_comic) && !$comic_lightbox) {
$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) {
$output .= '</a>';
}
if ($comic_galleries_jquery) $output .= "<button id=\"show-".$count."\" type=\"button\" style=\"display:none;\">".$count."</button>\r\n";
if ($comic_lightbox) $output .= '<div class="comic-lightbox-text">'.__('Click comic to view larger version.','comiceasel').'</div>';
}
} else {
$columns = get_post_meta( $post->ID, 'comic-gallery-columns', true );
if (empty($columns)) $columns = 5;
$args = array(
'id' => $post->ID,
'columns' => $columns,
'exclude' => $post_image_id
);
$output .= gallery_shortcode($args);
}
}
if (is_numeric($post_image_id) && $comic_galleries) {
if ($comic_galleries_full) {
$hovertext = ceo_the_hovertext();
$comic_lightbox = get_post_meta( $post->ID, 'comic-open-lightbox', true );
$comic_galleries_jquery = get_post_meta( $post->ID, 'comic-gallery-jquery', true );
if($images = get_posts(array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'numberposts' => -1, // show all
'post_status' => null,
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC'
))) {
$count = 0;
if ($comic_galleries_jquery) wp_enqueue_script('multicomic', ceo_pluginfo('plugin_url') . '/js/multicomic.js', null, null, true);
foreach($images as $image) {
if ($comic_galleries_jquery) $output .= '<div id="comic-'.$count.'" class="comicpane">';
$thumbnail = wp_get_attachment_image_src($image->ID, 'full');
$thumbnail = reset($thumbnail);
if (ceo_pluginfo('navigate_only_chapters')) {
$next_comic = ceo_get_next_comic_in_chapter_permalink();
} else {
$next_comic = ceo_get_next_comic_permalink();
}
if ($comic_lightbox) {
$output .= '<a href="'.$thumbnail.'" title="'.$hovertext.'" rel="lightbox">';
}
if (ceo_pluginfo('click_comic_next') && !empty($next_comic) && !$comic_lightbox) {
$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) {
$output .= '</a>';
}
if ($comic_galleries_jquery) $output .= "</div>\r\n";
$count += 1;
}
if ($comic_galleries_jquery) $output .= "<button id=\"show-".$count."\" type=\"button\" style=\"display:none;\">".$count."</button>\r\n";
if ($comic_lightbox) $output .= '<div class="comic-lightbox-text">'.__('Click comic to view larger version.','comiceasel').'</div>';
}
} else {
$columns = get_post_meta( $post->ID, 'comic-gallery-columns', true );
if (empty($columns)) $columns = 5;
$args = array(
'id' => $post->ID,
'columns' => $columns,
'exclude' => $post_image_id
);
$output .= gallery_shortcode($args);
}
}
}

View File

@@ -74,7 +74,7 @@ function ceo_display_comic_navigation() {
$stay = '';
if (ceo_pluginfo('enable_chapter_only_random')) {
$chapter = get_the_terms($post->ID, 'chapters');
if (!empty($chapter)) $stay = '&stay='.reset($chapter)->term_id;
if (!empty($chapter) && !is_wp_error($chapter)) $stay = '&stay='.reset($chapter)->term_id;
}
?>

View File

@@ -89,10 +89,32 @@
<td>
<?php _e('Enabling this will make transcripts show at the bottom of comic posts, if the comic has a transcript.','comiceasel'); ?>
</td>
</tr>
</tr>
<?php } ?>
</table>
<br />
<?php
if (!defined('CEO_FEATURE_DISABLE_MOTION_ARTIST')) {
if (!isset($ceo_options['enable_motion_artist_support'])) $ceo_options['enable_motion_artist_support'] = false;
?>
<table class="widefat">
<thead>
<tr>
<th colspan="3"><?php _e('Motion Artist Comics','comiceasel'); ?></th>
</tr>
</thead>
<tr class="alternate">
<th scope="row"><label for="enable_motion_artist_support"><?php _e('Enable support for Motion Artist Comics','comiceasel'); ?></label></th>
<td>
<input id="enable_motion_artist_support" name="enable_motion_artist_support" type="checkbox" value="1" <?php checked(true, $ceo_options['enable_motion_artist_support']); ?> />
</td>
<td>
<?php _e('When enabled, this will provide a drop down box that you can select which directory to use for the motion comic for that post.','comiceasel'); ?>
</td>
</tr>
</table>
<br />
<?php } ?>
<table class="widefat">
<thead>
<tr>

View File

@@ -3,7 +3,7 @@ Contributors: Frumph
Tags: comiceasel, easel, webcomic, comic, webcomic
Requires at least: 3.2
Tested up to: 3.5.1
Stable tag: 1.3.12
Stable tag: 1.3.13
Donate link: http://frumph.net
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -126,6 +126,12 @@ The comic navigation widget is only seen if you have the comic sidebar's enabled
== Changelog ==
= 1.4 COMING SOON =
* Added support for 'motion artist' comics. Read documentation at comiceasel.com
= 1.3.13 =
* Added the random comic in navigation to work like the default one if set to chapter only
= 1.3.12 =
* make it so the chapter dropdown doesn't show empty chapters it just doesn't work
* check for 404 pages for the thumbnail casthover and comblogpost widgets and do not execute if it's a 404 page, or even page

View File

@@ -94,8 +94,16 @@ class ceo_comic_navigation_widget extends WP_Widget {
if ($instance['archives'] && !empty($instance['archive_path'])) { ?>
<a href="<?php echo $instance['archive_path']; ?>" class="navi navi-archives navi-archive" title="<?php echo $instance['archives_title']; ?>"><?php echo $instance['archives_title']; ?></a>
<?php }
if ($instance['random']) { ?>
<a href="<?php echo home_url(); ?>/?random&amp;nocache=1" class="navi navi-random" title="<?php echo $instance['random_title']; ?>"><?php echo $instance['random_title']; ?></a>
if ($instance['random']) {
$stay = '';
if (ceo_pluginfo('enable_random_nav')) {
if (ceo_pluginfo('enable_chapter_only_random')) {
$chapter = get_the_terms($post->ID, 'chapters');
if (!empty($chapter) && !is_wp_error($chapter)) $stay = '&stay='.reset($chapter)->term_id;
}
} ?>
<a href="<?php echo home_url(); ?>/?random&amp;nocache=1<?php echo $stay; ?>" class="navi navi-random" title="<?php echo $instance['random_title']; ?>"><?php echo $instance['random_title']; ?></a>
<?php }
do_action('inside-comic-navigation');
if ($instance['comments']) { ?>