mirror of
https://github.com/Frumph/comic-easel.git
synced 2026-07-21 00:35:30 -04:00
1. Added ajax uploader to comic metabox
2. fixed uploader.php to attach comic to post on uploader.php 3. added function to ceo-core.php to inser css and secripts only on comic add/edit pages ------------------------------------------------------ To-Do 1. fix select box attacher for add/edit comic page 2. fix auto-updater for comic Thumb list on add/editpage. ------------------------------------------------------- comment out selectbox untill it is working
This commit is contained in:
+29
-6
@@ -8,7 +8,7 @@ add_action('wp_dashboard_setup', 'ceo_add_dashboard_widgets' );
|
||||
|
||||
// INIT ComicPress Manager pages & hook activation of scripts per page.
|
||||
function ceo_add_menu_pages() {
|
||||
global $pagenow;
|
||||
global $pagenow, $post_type;
|
||||
|
||||
$menu_location = 'edit.php?post_type=comic';
|
||||
$plugin_title = __('Comic Easel', 'comiceasel');
|
||||
@@ -26,11 +26,8 @@ function ceo_add_menu_pages() {
|
||||
$upload_hook = add_submenu_page($menu_location, $plugin_title . ' - ' . $upload_title, $upload_title, 'edit_theme_options', 'comiceasel-upload', 'ceo_upload');
|
||||
|
||||
// post_type is only found on the post-new.php with $_GET, so when the $pagenow is post.php it will not be able to strictly determine the post type so it will be executed on all already made post/page edits
|
||||
if (isset($_GET['post_type'])) {
|
||||
if (($pagenow == 'post.php') || (($pagenow == 'post-new.php') && ($_GET['post_type'] == 'comic'))) {
|
||||
add_action('admin_print_scripts', 'ceo_load_scripts_image_manager');
|
||||
add_action('admin_print_styles', 'ceo_load_styles_image_manager');
|
||||
}
|
||||
if (($_GET['post_type'] == 'comic') || ($post_type == 'comic')) {
|
||||
add_action('admin_head', 'comic_admin_css');
|
||||
}
|
||||
|
||||
// Notice how its checking the _GET['page'], do this for the other areas
|
||||
@@ -114,5 +111,31 @@ function ceo_comic_upload() {
|
||||
exit;
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_ceo_thumb_update', 'ceo_comic_thumb_update' );
|
||||
|
||||
function ceo_comic_thumb_update() {
|
||||
echo ceo_display_comic_thumbnail('small', $_POST[post_id], false, 198);
|
||||
exit;
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_ceo_comic_add', 'ceo_comic_add' );
|
||||
|
||||
function ceo_comic_add() {
|
||||
add_post_meta($_GET[post_id], 'comic', $_GET[comicfile], false);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function comic_admin_css() {
|
||||
|
||||
global $post_type;
|
||||
|
||||
if (($_GET['post_type'] == 'comic') || ($post_type == 'comic')) :
|
||||
|
||||
echo "<link type='text/css' rel='stylesheet' href='" . plugins_url('/css/fileuploader.css', __FILE__) . "' />";
|
||||
echo "<script type='text/javascript' src='". plugins_url('/js/fileuploader.js', __FILE__) . "'></script>";
|
||||
endif;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
+55
-17
@@ -74,20 +74,6 @@ function ceo_edit_comic_in_post($post) {
|
||||
</noscript>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
function createUploader(){
|
||||
var uploader = new qq.FileUploader({
|
||||
element: document.getElementById('file-uploader-demo1'),
|
||||
action: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
|
||||
params: {
|
||||
action: 'ceo_uploader'
|
||||
}
|
||||
});
|
||||
}
|
||||
// in your app create uploader as soon as the DOM is readyi
|
||||
// don't wait for the window to load
|
||||
window.onload = createUploader;
|
||||
</script>
|
||||
<hr>
|
||||
Meta Box Inside a Post
|
||||
TODO<br />
|
||||
@@ -100,21 +86,73 @@ function ceo_edit_comic_in_post($post) {
|
||||
</ol>
|
||||
</td>
|
||||
<td valign="top" style="width: 240px;">
|
||||
<center>
|
||||
<?php echo ceo_display_comic_thumbnail('small', $post, false, 198); ?>
|
||||
</center>
|
||||
<div id="comicthumbs"><center>
|
||||
<?php echo ceo_display_comic_thumbnail('small', $post, false, 198); ?>
|
||||
</center></div>
|
||||
<script>
|
||||
var refreshId = setInterval(function()
|
||||
{
|
||||
$('#comicthumbs').load('response.php');
|
||||
}, 5000);
|
||||
</script>
|
||||
|
||||
<br />
|
||||
Display Current Comic Thumbnail(s) that is set in this area. Basically do a loop through the meta fields for 'comic' and display each thumbnail here of all that are attached.
|
||||
|
||||
<br /> ZERZIX : Need to updated these on upload and formsubmit success
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" style="border-top: solid 1px #000;">
|
||||
|
||||
<form>
|
||||
<div class="wrap">
|
||||
<form name="test_form" id="test_form">
|
||||
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post->ID ?>" />
|
||||
<input type="hidden" name="action" value="ceo_comic_add" />
|
||||
<select multiple name='comicselector' id='comicselector' ><?php
|
||||
//The path to the style directory
|
||||
// $dirpath = ceo_pluginfo('comic_path');
|
||||
// $dh = opendir($dirpath);
|
||||
// while (false !== ($file = readdir($dh))) {
|
||||
//Don't list subdirectories
|
||||
// if (!is_dir("$dirpath/$file")) {
|
||||
// //Truncate the file extension and capitalize the first letter
|
||||
// echo "<option value='$file'>" . htmlspecialchars(ucfirst(preg_replace('/\..*$/', '', $file))) . '</option>';
|
||||
// }
|
||||
// }
|
||||
// closedir($dh);
|
||||
// </select>
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
ZERZIX : Need to add the AJAX form submitter.
|
||||
Display 'selection' box where you can reselect a different comic that is already available here instead of uploading.<br />
|
||||
This also needs to be ajaxified where when clicking the select button it will update the custom post meta field with the appropriate filename for the comic.<br />
|
||||
If multiple comics selected it will create a new comic field for all of them.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<script>
|
||||
function createUploader(){
|
||||
var uploader = new qq.FileUploader({
|
||||
element: document.getElementById('file-uploader-demo1'),
|
||||
action: '<?php echo admin_url( 'admin-ajax.php' ); ?>',
|
||||
params: {
|
||||
action: 'ceo_uploader',
|
||||
post_id: '<?php echo $post->ID ?>'
|
||||
},
|
||||
onComplete: function(id, fileName, responseJSON){
|
||||
//refreash thumbnail DIV
|
||||
}
|
||||
});
|
||||
}
|
||||
// in your app create uploader as soon as the DOM is readyi
|
||||
// don't wait for the window to load
|
||||
window.onload = createUploader;
|
||||
</script>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -79,7 +79,8 @@ function ceo_handleUpload(){
|
||||
$thumb -> Thumbprefix = '';
|
||||
$thumb -> Createthumb(ceo_pluginfo('comic_path') .'/'. $filename . '.' . $ext,'file');
|
||||
}
|
||||
|
||||
add_post_meta($_GET[post_id], 'comic', $filename . '.' . $ext, false);
|
||||
|
||||
return array(success=>true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user