| | 1 | <?php |
|---|
| | 2 | require_once('admin.php'); |
|---|
| | 3 | |
|---|
| | 4 | if ( ! current_user_can('publish_posts') ) |
|---|
| | 5 | wp_die( __( 'Cheatin’ uh?' )); |
|---|
| | 6 | |
|---|
| | 7 | function quick_post() { |
|---|
| | 8 | $quick['post_status'] = 'publish'; |
|---|
| | 9 | $quick['post_category'] = $_REQUEST['post_category']; |
|---|
| | 10 | $quick['tags_input'] = $_REQUEST['tags_input']; |
|---|
| | 11 | $quick['post_title'] = $_REQUEST['post_title']; |
|---|
| | 12 | |
|---|
| | 13 | $content = ''; |
|---|
| | 14 | switch ( $_REQUEST['post_type'] ) { |
|---|
| | 15 | case 'regular': |
|---|
| | 16 | $content = $_REQUEST['content']; |
|---|
| | 17 | if ($_REQUEST['content2']) |
|---|
| | 18 | $content .= '<p>' . $_REQUEST['content2']; |
|---|
| | 19 | break; |
|---|
| | 20 | |
|---|
| | 21 | case 'quote': |
|---|
| | 22 | $content = '<blockquote>' . $_REQUEST['content']; |
|---|
| | 23 | if ($_REQUEST['content2']) { |
|---|
| | 24 | $content = $content . '</blockquote>'; |
|---|
| | 25 | $content = $content . '<p>' . $_REQUEST['content2']; |
|---|
| | 26 | } |
|---|
| | 27 | break; |
|---|
| | 28 | |
|---|
| | 29 | case 'photo': |
|---|
| | 30 | if ($_REQUEST['photo_link']) |
|---|
| | 31 | $content = '<a href="' . $_REQUEST['photo_link'] . '" target="_new">'; |
|---|
| | 32 | |
|---|
| | 33 | $content .= '<img src="' . $_REQUEST['photo_src'] . '\ style="float:left;padding:5px;">'; |
|---|
| | 34 | |
|---|
| | 35 | if ($_REQUEST['photo_link']) |
|---|
| | 36 | $content .= '</a>'; |
|---|
| | 37 | |
|---|
| | 38 | if ($_REQUEST['content']) |
|---|
| | 39 | $content = $content . "<br clear=\"all\">" . $_REQUEST['content']; |
|---|
| | 40 | |
|---|
| | 41 | break; |
|---|
| | 42 | case "video": |
|---|
| | 43 | list($garbage,$video_id) = split("v=", $_REQUEST['content']); |
|---|
| | 44 | $content = "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"http://www.youtube.com/v/" .$video_id ."\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/" .$video_id ."\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\"></embed></object>"; |
|---|
| | 45 | if ($_REQUEST['content2']) |
|---|
| | 46 | $content = $content ."</br><p>" .$_REQUEST['content2'] ."</p>"; |
|---|
| | 47 | break; |
|---|
| | 48 | } |
|---|
| | 49 | |
|---|
| | 50 | $quick['post_content'] = $content; |
|---|
| | 51 | |
|---|
| | 52 | $post_ID = wp_insert_post($quick, true); |
|---|
| | 53 | |
|---|
| | 54 | if ( is_wp_error($post_ID) ) |
|---|
| | 55 | wp_die($wp_error); |
|---|
| | 56 | |
|---|
| | 57 | return $post_ID; |
|---|
| | 58 | } |
|---|
| | 59 | |
|---|
| | 60 | function tag_input() { |
|---|
| | 61 | $s = '<div id="tagdiv"> |
|---|
| | 62 | <h2>' . __('Tags') . '</h2> |
|---|
| | 63 | <input type="text" name="tags_input" class="text" id="tags-input" size="30" tabindex="3" value="" /><br/>' . |
|---|
| | 64 | __('Comma separated (e.g. Wordpress, Plugins)') . |
|---|
| | 65 | '</div>'; |
|---|
| | 66 | |
|---|
| | 67 | return $s; |
|---|
| | 68 | } |
|---|
| | 69 | |
|---|
| | 70 | ?> |
|---|
| | 71 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| | 72 | <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> |
|---|
| | 73 | <head> |
|---|
| | 74 | <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> |
|---|
| | 75 | <title><?php _e('Quick Post') ?></title> |
|---|
| | 76 | |
|---|
| | 77 | <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce.js"></script> |
|---|
| | 78 | |
|---|
| | 79 | <?php wp_enqueue_script('jquery-ui-tabs'); ?> |
|---|
| | 80 | <?php wp_enqueue_script('thickbox'); ?> |
|---|
| | 81 | <?php do_action('admin_print_scripts'); do_action('admin_head'); ?> |
|---|
| | 82 | <?php wp_admin_css('css/quick-post'); ?> |
|---|
| | 83 | |
|---|
| | 84 | <script type="text/javascript"> |
|---|
| | 85 | <? if ( user_can_richedit() ) { ?> |
|---|
| | 86 | tinyMCE.init({ |
|---|
| | 87 | mode: "textareas", |
|---|
| | 88 | editor_selector: "mceEditor", |
|---|
| | 89 | width: "100%", |
|---|
| | 90 | theme : "advanced", |
|---|
| | 91 | theme_advanced_buttons1 : "bold,italic,underline,indent,separator,strikethrough,bullist,numlist,undo,redo,link,unlink", |
|---|
| | 92 | theme_advanced_buttons2 : "", |
|---|
| | 93 | theme_advanced_buttons3 : "", |
|---|
| | 94 | theme_advanced_toolbar_location : "top", |
|---|
| | 95 | theme_advanced_toolbar_align : "left", |
|---|
| | 96 | theme_advanced_path_location : "bottom", |
|---|
| | 97 | extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]" |
|---|
| | 98 | }); |
|---|
| | 99 | <? } ?> |
|---|
| | 100 | |
|---|
| | 101 | jQuery(document).ready(function() { |
|---|
| | 102 | <?php if ( preg_match("/youtube\.com\/watch/i", $_GET['u']) ) { ?> |
|---|
| | 103 | jQuery('#container > ul').tabs({ selected: 4 })({ fx: { height: 'toggle', opacity: 'toggle', fxSpeed: 'fast' } }); |
|---|
| | 104 | <?php } elseif ( preg_match("/flickr\.com/i", $_GET['u']) ) { ?> |
|---|
| | 105 | jQuery('#container > ul').tabs({ selected: 2 })({ fx: { height: 'toggle', opacity: 'toggle', fxSpeed: 'fast' } }); |
|---|
| | 106 | <?php } else { ?> |
|---|
| | 107 | jQuery('#container > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle', fxSpeed: 'fast' } }); |
|---|
| | 108 | <?php } ?> |
|---|
| | 109 | }); |
|---|
| | 110 | |
|---|
| | 111 | </script> |
|---|
| | 112 | </head> |
|---|
| | 113 | <body> |
|---|
| | 114 | |
|---|
| | 115 | <?php |
|---|
| | 116 | if ( 'post' == $_REQUEST['action'] ) { |
|---|
| | 117 | //check_admin_referer('quick-post'); |
|---|
| | 118 | $post_ID = quick_post(); |
|---|
| | 119 | ?> |
|---|
| | 120 | <script>if(confirm("<?php _e('Your post is saved. Do you want to view the post?') ?>")) {window.opener.location.replace("<?php echo get_permalink($post_ID);?>");}window.close();</script> |
|---|
| | 121 | </body></html> |
|---|
| | 122 | <?php |
|---|
| | 123 | die; |
|---|
| | 124 | } |
|---|
| | 125 | |
|---|
| | 126 | // Clean up the data being passed in |
|---|
| | 127 | $title = stripslashes($_GET['t']); |
|---|
| | 128 | |
|---|
| | 129 | ?> |
|---|
| | 130 | <div id="container"> |
|---|
| | 131 | |
|---|
| | 132 | <ul> |
|---|
| | 133 | <li><a href="#section-1"><span><?php _e('Text/Link') ?></span></a></li> |
|---|
| | 134 | <li><a href="#section-2"><span><?php _e('Photo') ?></span></a></li> |
|---|
| | 135 | <li><a href="#section-3"><span><?php _e('Quote') ?></span></a></li> |
|---|
| | 136 | <li><a href="#section-4"><span><?php _e('Video') ?></span></a></li> |
|---|
| | 137 | </ul> |
|---|
| | 138 | |
|---|
| | 139 | <!-- Regular --> |
|---|
| | 140 | <div id="section-1"> |
|---|
| | 141 | <form action="quick-post.php?action=post" method="post" id="regular_form"> |
|---|
| | 142 | <input type="hidden" name="source" value="bookmarklet"/> |
|---|
| | 143 | <input type="hidden" name="post_type" value="regular"/> |
|---|
| | 144 | <div id="posting"> |
|---|
| | 145 | <h2><?php _e('Post Title') ?></h2> |
|---|
| | 146 | <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> |
|---|
| | 147 | |
|---|
| | 148 | <h2><?php _e('Post') ?></h2> |
|---|
| | 149 | <div> |
|---|
| | 150 | <textarea name="content" id="regular_post_two" style="height:170px;width:100%;" class="mceEditor"><?php echo stripslashes($_GET['s']);?><br><a href="<?php echo $_GET['u'];?>"><?php echo $title;?></a></textarea> |
|---|
| | 151 | </div> |
|---|
| | 152 | |
|---|
| | 153 | <?php tag_input(); ?> |
|---|
| | 154 | |
|---|
| | 155 | <div> |
|---|
| | 156 | <input type="submit" value="<?php _e('Create Post') ?>" style="margin-top:15px;" onclick="document.getElementById('regular_saving').style.display = '';"/> |
|---|
| | 157 | <a href="#" onclick="if (confirm('<?php _e('Are you sure?') ?>')) { self.close(); } else { return false; }" style="color:#007BFF;"><?php _e('Cancel') ?></a> |
|---|
| | 158 | <img src="/images/bookmarklet_loader.gif" alt="" id="regular_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> |
|---|
| | 159 | </div> |
|---|
| | 160 | </div> |
|---|
| | 161 | <div id="categories"> |
|---|
| | 162 | <h2><?php _e('Categories') ?></h2> |
|---|
| | 163 | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> |
|---|
| | 164 | <?php wp_category_checklist($post_ID) ?> |
|---|
| | 165 | </ul> |
|---|
| | 166 | </div> |
|---|
| | 167 | </form> |
|---|
| | 168 | </div> |
|---|
| | 169 | |
|---|
| | 170 | <!-- Photo --> |
|---|
| | 171 | <div id="section-2"> |
|---|
| | 172 | <form action="quick-post.php?action=post" method="post" id="photo_form"> |
|---|
| | 173 | <input type="hidden" name="source" value="bookmarklet"/> |
|---|
| | 174 | <input type="hidden" name="post_type" value="photo"/> |
|---|
| | 175 | <div id="posting"> |
|---|
| | 176 | <h2><?php _e('Post Title') ?></h2> |
|---|
| | 177 | <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> |
|---|
| | 178 | |
|---|
| | 179 | <h2><?php _e('Caption') ?></h2> |
|---|
| | 180 | <div> |
|---|
| | 181 | <textarea name="content" id="photo_post_two" style="height:130px;width:100%;" class="mceEditor"><?php echo "" .stripslashes($_GET['s']);?> |
|---|
| | 182 | <br><a href="<?php echo $_GET['u'];?>"><?php echo $title;?></a></textarea> |
|---|
| | 183 | </div> |
|---|
| | 184 | |
|---|
| | 185 | <h2><?php _e('Photo URL') ?></h2> |
|---|
| | 186 | <input name="photo_src" id="photo_src" class="text" onkeydown="pick(0);"/> |
|---|
| | 187 | |
|---|
| | 188 | <style type="text/css"> |
|---|
| | 189 | #img_container img { |
|---|
| | 190 | width: 75px; |
|---|
| | 191 | height: 75px; |
|---|
| | 192 | padding: 2px; |
|---|
| | 193 | background-color: #f4f4f4; |
|---|
| | 194 | margin-right: 7px; |
|---|
| | 195 | margin-bottom: 7px; |
|---|
| | 196 | cursor: pointer; |
|---|
| | 197 | } |
|---|
| | 198 | </style> |
|---|
| | 199 | |
|---|
| | 200 | <div id="img_container" style="border:solid 1px #ccc; background-color:#f4f4f4; padding:5px; width:370px; margin-top:10px; overflow:auto; height:100px;"> |
|---|
| | 201 | <script type="text/javascript"> |
|---|
| | 202 | var img, img_tag, aspect, w, h, skip, i, strtoappend = ""; |
|---|
| | 203 | var my_src = ['<?php echo str_replace(",", "','", rtrim($_GET['imagez'], ","));?>']; |
|---|
| | 204 | var last = null; |
|---|
| | 205 | |
|---|
| | 206 | function pick(img) { |
|---|
| | 207 | if (last) last.style.backgroundColor = '#f4f4f4'; |
|---|
| | 208 | if (img) { |
|---|
| | 209 | document.getElementById('photo_src').value = img.src; |
|---|
| | 210 | img.style.backgroundColor = '#44f'; |
|---|
| | 211 | } |
|---|
| | 212 | last = img; |
|---|
| | 213 | return false; |
|---|
| | 214 | } |
|---|
| | 215 | for (i = 0; i < my_src.length; i++) { |
|---|
| | 216 | img = new Image(); |
|---|
| | 217 | img.src = my_src[i]; |
|---|
| | 218 | img_attr = 'id="img' + i + '" onclick="pick(this);"'; |
|---|
| | 219 | skip = false; |
|---|
| | 220 | if (img.width && img.height) { |
|---|
| | 221 | if (img.width * img.height < 2500) skip = true; |
|---|
| | 222 | aspect = img.width / img.height; |
|---|
| | 223 | if (aspect > 1) { |
|---|
| | 224 | // Image is wide |
|---|
| | 225 | scale = 75 / img.width; |
|---|
| | 226 | } else { |
|---|
| | 227 | // Image is tall or square |
|---|
| | 228 | scale = 75 / img.height; |
|---|
| | 229 | } |
|---|
| | 230 | if (scale < 1) { |
|---|
| | 231 | w = parseInt(img.width * scale); |
|---|
| | 232 | h = parseInt(img.height * scale); |
|---|
| | 233 | } else { |
|---|
| | 234 | w = img.width; |
|---|
| | 235 | h = img.height; |
|---|
| | 236 | } |
|---|
| | 237 | img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"'; |
|---|
| | 238 | } |
|---|
| | 239 | if (!skip) { |
|---|
| | 240 | strtoappend += '<a href="' + img.src + '" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>' |
|---|
| | 241 | } |
|---|
| | 242 | } |
|---|
| | 243 | if (jQuery.browser.safari) { |
|---|
| | 244 | document.getElementById('img_container').innerHTML = strtoappend; |
|---|
| | 245 | } else { |
|---|
| | 246 | document.write(strtoappend); |
|---|
| | 247 | } |
|---|
| | 248 | </script> |
|---|
| | 249 | </div> |
|---|
| | 250 | |
|---|
| | 251 | <h2><?php _e('Link Photo to following URL') ?></h2><?php _e('(leave blank to leave the photo unlinked)') ?> |
|---|
| | 252 | <input name="photo_link" id="photo_link" class="text" value="<?php echo attribute_escape($_GET['u']);?>"/> |
|---|
| | 253 | |
|---|
| | 254 | <?php tag_input(); ?> |
|---|
| | 255 | |
|---|
| | 256 | <div> |
|---|
| | 257 | <input type="submit" value="<?php _e('Create Photo') ?>" style="margin-top:15px;" onclick="document.getElementById('photo_saving').style.display = '';"/> |
|---|
| | 258 | |
|---|
| | 259 | <a href="#" onclick="if (confirm('Are you sure?')) { self.close(); } else { return false; }" style="color:#007BFF;">Cancel</a> |
|---|
| | 260 | <img src="/images/bookmarklet_loader.gif" alt="" id="photo_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> |
|---|
| | 261 | </div> |
|---|
| | 262 | </div> |
|---|
| | 263 | <div id="categories"> |
|---|
| | 264 | <h2><?php _e('Categories') ?></h2> |
|---|
| | 265 | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> |
|---|
| | 266 | <?php wp_category_checklist($post_ID) ?> |
|---|
| | 267 | </ul> |
|---|
| | 268 | </div> |
|---|
| | 269 | </form> |
|---|
| | 270 | </div> |
|---|
| | 271 | |
|---|
| | 272 | <!-- Quote --> |
|---|
| | 273 | <div id="section-3"> |
|---|
| | 274 | <form action="quick-post.php?action=post" method="post" id="quote_form"> |
|---|
| | 275 | |
|---|
| | 276 | <input type="hidden" name="source" value="bookmarklet"/> |
|---|
| | 277 | <input type="hidden" name="post_type" value="quote"/> |
|---|
| | 278 | <div id="posting"> |
|---|
| | 279 | <h2><?php _e('Post Title') ?></h2> |
|---|
| | 280 | <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape(sprintf(__('Quote by %s'), $title)); ?>"/> |
|---|
| | 281 | |
|---|
| | 282 | <h2><?php _e('Quote') ?></h2> |
|---|
| | 283 | <div> |
|---|
| | 284 | <textarea name="content" id="quote_post_one" style="height:130px;width:100%;" class="mceEditor"><?php echo stripslashes($_GET['s']);?></textarea> |
|---|
| | 285 | </div> |
|---|
| | 286 | |
|---|
| | 287 | <h2><?php _e('Source <span class="optional">(optional)</span>') ?></h2> |
|---|
| | 288 | <div> |
|---|
| | 289 | <textarea name="content2" id="quote_post_two" style="height:130px;width:100%;" class="mceEditor"><br><a href="<?php echo clean_url($_GET['u']);?>"><?php echo $title;?></a></textarea> |
|---|
| | 290 | </div> |
|---|
| | 291 | |
|---|
| | 292 | <?php tag_input(); ?> |
|---|
| | 293 | |
|---|
| | 294 | <div> |
|---|
| | 295 | <input type="submit" value="Create Quote" style="margin-top:15px;" onclick="document.getElementById('quote_saving').style.display = '';"/> |
|---|
| | 296 | <a href="#" onclick="if (confirm('Are you sure?')) { self.close(); } else { return false; }" style="color:#007BFF;"><?php _e('Cancel') ?></a> |
|---|
| | 297 | <img src="/images/bookmarklet_loader.gif" alt="" id="quote_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> |
|---|
| | 298 | </div> |
|---|
| | 299 | </div> |
|---|
| | 300 | <div id="categories"> |
|---|
| | 301 | <h2><?php _e('Categories') ?></h2> |
|---|
| | 302 | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> |
|---|
| | 303 | <?php wp_category_checklist($post_ID) ?> |
|---|
| | 304 | </ul> |
|---|
| | 305 | </div> |
|---|
| | 306 | </form> |
|---|
| | 307 | </div> |
|---|
| | 308 | |
|---|
| | 309 | <!-- Video --> |
|---|
| | 310 | <div id="section-4"> |
|---|
| | 311 | <form action="quick-post.php?action=post" method="post" id="video_form"> |
|---|
| | 312 | <input type="hidden" name="source" value="bookmarklet"/> |
|---|
| | 313 | <input type="hidden" name="post_type" value="video"/> |
|---|
| | 314 | <div id="posting"> |
|---|
| | 315 | <h2><?php _e('Post Title') ?></h2> |
|---|
| | 316 | <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> |
|---|
| | 317 | |
|---|
| | 318 | <?php |
|---|
| | 319 | if ( preg_match("/youtube\.com\/watch/i", $_GET['u']) ) { |
|---|
| | 320 | list($domain, $video_id) = split("v=", $_GET['u']); |
|---|
| | 321 | ?> |
|---|
| | 322 | <input type="hidden" name="content" value="<?php echo $_GET['u']; ?>" /> |
|---|
| | 323 | <img src="http://img.youtube.com/vi/<?php echo $video_id; ?>/default.jpg" align="right" style="border:solid 1px #aaa;" width="130" height="97"/><br clear="all" /> |
|---|
| | 324 | <?php } else { ?> |
|---|
| | 325 | <h2><?php _e('Embed Code') ?></h2> |
|---|
| | 326 | <textarea name="content" id="video_post_one" style="height:80px;width:100%;"></textarea> |
|---|
| | 327 | <?php } ?> |
|---|
| | 328 | |
|---|
| | 329 | <h2><?php _e('Caption <span class="optional">(optional)</span>') ?></h2> |
|---|
| | 330 | |
|---|
| | 331 | <div> |
|---|
| | 332 | <textarea name="content2" id="video_post_two" style="height:130px;width:100%;" class="mceEditor"><?php echo stripslashes($_GET['s']);?><br><a href="<?php echo $_GET['u'];?>"><?php echo $title;?></a></textarea> |
|---|
| | 333 | </div> |
|---|
| | 334 | |
|---|
| | 335 | <?php tag_input(); ?> |
|---|
| | 336 | |
|---|
| | 337 | <div> |
|---|
| | 338 | <input type="submit" value="<?php _e('Create Video') ?>" style="margin-top:15px;" onclick="document.getElementById('video_saving').style.display = '';"/> |
|---|
| | 339 | <a href="#" onclick="if (confirm('Are you sure?')) { self.close(); } else { return false; }" style="color:#007BFF;"><?php _e('Cancel'); ?></a> |
|---|
| | 340 | <img src="/images/bookmarklet_loader.gif" alt="" id="video_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> |
|---|
| | 341 | </div> |
|---|
| | 342 | </div> |
|---|
| | 343 | <div id="categories"> |
|---|
| | 344 | <h2><?php _e('Categories') ?></h2> |
|---|
| | 345 | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> |
|---|
| | 346 | <?php wp_category_checklist($post_ID) ?> |
|---|
| | 347 | </ul> |
|---|
| | 348 | </div> |
|---|
| | 349 | </form> |
|---|
| | 350 | </div> |
|---|
| | 351 | |
|---|
| | 352 | </div> |
|---|
| | 353 | |
|---|
| | 354 | </body> |
|---|
| | 355 | </html> |