mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Press This Display and Handler.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Press_This
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 if ( ! current_user_can('publish_posts') ) wp_die( __( 'Cheatin’ uh?' ) );
mp-wp_genesis 13
mp-wp_genesis 14 /**
mp-wp_genesis 15 * Replace forward slash with backslash and slash.
mp-wp_genesis 16 *
mp-wp_genesis 17 * @package WordPress
mp-wp_genesis 18 * @subpackage Press_This
mp-wp_genesis 19 * @since 2.6.0
mp-wp_genesis 20 *
mp-wp_genesis 21 * @param string $string
mp-wp_genesis 22 * @return string
mp-wp_genesis 23 */
mp-wp_genesis 24 function preg_quote2($string) {
mp-wp_genesis 25 return str_replace('/', '\/', preg_quote($string));
mp-wp_genesis 26 }
mp-wp_genesis 27
mp-wp_genesis 28 /**
mp-wp_genesis 29 * Convert characters.
mp-wp_genesis 30 *
mp-wp_genesis 31 * @package WordPress
mp-wp_genesis 32 * @subpackage Press_This
mp-wp_genesis 33 * @since 2.6.0
mp-wp_genesis 34 *
mp-wp_genesis 35 * @param string $text
mp-wp_genesis 36 * @return string
mp-wp_genesis 37 */
mp-wp_genesis 38 function aposfix($text) {
mp-wp_genesis 39 $translation_table[chr(34)] = '"';
mp-wp_genesis 40 $translation_table[chr(38)] = '&';
mp-wp_genesis 41 $translation_table[chr(39)] = ''';
mp-wp_genesis 42 return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($text, $translation_table));
mp-wp_genesis 43 }
mp-wp_genesis 44
mp-wp_genesis 45 /**
mp-wp_genesis 46 * Press It form handler.
mp-wp_genesis 47 *
mp-wp_genesis 48 * @package WordPress
mp-wp_genesis 49 * @subpackage Press_This
mp-wp_genesis 50 * @since 2.6.0
mp-wp_genesis 51 *
mp-wp_genesis 52 * @return int Post ID
mp-wp_genesis 53 */
mp-wp_genesis 54 function press_it() {
mp-wp_genesis 55 // define some basic variables
mp-wp_genesis 56 $quick['post_status'] = 'draft'; // set as draft first
mp-wp_genesis 57 $quick['post_category'] = $_REQUEST['post_category'];
mp-wp_genesis 58 $quick['tags_input'] = $_REQUEST['tags_input'];
mp-wp_genesis 59 $quick['post_title'] = $_REQUEST['title'];
mp-wp_genesis 60 $quick['post_content'] = '';
mp-wp_genesis 61
mp-wp_genesis 62 // insert the post with nothing in it, to get an ID
mp-wp_genesis 63 $post_ID = wp_insert_post($quick, true);
mp-wp_genesis 64 $content = $_REQUEST['content'];
mp-wp_genesis 65
mp-wp_genesis 66 if($_REQUEST['photo_src'])
mp-wp_genesis 67 foreach( (array) $_REQUEST['photo_src'] as $key => $image)
mp-wp_genesis 68 // see if files exist in content - we don't want to upload non-used selected files.
mp-wp_genesis 69 if( strpos($_REQUEST['content'], $image) !== false ) {
mp-wp_genesis 70 $upload = media_sideload_image($image, $post_ID, $_REQUEST['photo_description'][$key]);
mp-wp_genesis 71
mp-wp_genesis 72 // Replace the POSTED content <img> with correct uploaded ones.
mp-wp_genesis 73 // escape quote for matching
mp-wp_genesis 74 $quoted = preg_quote2($image);
mp-wp_genesis 75 if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=(\"|\')'.$quoted.'(\2)([^>\/]*)\/*>/is', $upload, $content);
mp-wp_genesis 76 }
mp-wp_genesis 77
mp-wp_genesis 78 // set the post_content and status
mp-wp_genesis 79 $quick['post_status'] = isset($_REQUEST['publish']) ? 'publish' : 'draft';
mp-wp_genesis 80 $quick['post_content'] = $content;
mp-wp_genesis 81 // error handling for $post
mp-wp_genesis 82 if ( is_wp_error($post_ID)) {
mp-wp_genesis 83 wp_die($id);
mp-wp_genesis 84 wp_delete_post($post_ID);
mp-wp_genesis 85 // error handling for media_sideload
mp-wp_genesis 86 } elseif ( is_wp_error($upload)) {
mp-wp_genesis 87 wp_die($upload);
mp-wp_genesis 88 wp_delete_post($post_ID);
mp-wp_genesis 89 } else {
mp-wp_genesis 90 $quick['ID'] = $post_ID;
mp-wp_genesis 91 wp_update_post($quick);
mp-wp_genesis 92 }
mp-wp_genesis 93 return $post_ID;
mp-wp_genesis 94 }
mp-wp_genesis 95
mp-wp_genesis 96 // For submitted posts.
mp-wp_genesis 97 if ( 'post' == $_REQUEST['action'] ) {
mp-wp_genesis 98 check_admin_referer('press-this');
mp-wp_genesis 99 $post_ID = press_it();
mp-wp_genesis 100 $posted = $post_ID;
mp-wp_genesis 101 }
mp-wp_genesis 102
mp-wp_genesis 103 // Set Variables
mp-wp_genesis 104 $title = wp_specialchars(aposfix(stripslashes($_GET['t'])));
mp-wp_genesis 105 $selection = trim( aposfix( stripslashes($_GET['s']) ) );
mp-wp_genesis 106 if ( ! empty($selection) ) {
mp-wp_genesis 107 $selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
mp-wp_genesis 108 $selection = '<p>'.str_replace('<p></p>', '', $selection).'</p>';
mp-wp_genesis 109 }
mp-wp_genesis 110 $url = clean_url($_GET['u']);
mp-wp_genesis 111 $image = $_GET['i'];
mp-wp_genesis 112
mp-wp_genesis 113 if($_REQUEST['ajax']) {
mp-wp_genesis 114 switch ($_REQUEST['ajax']) {
mp-wp_genesis 115 case 'video': ?>
mp-wp_genesis 116 <script type="text/javascript" charset="utf-8">
mp-wp_genesis 117 jQuery('.select').click(function() {
mp-wp_genesis 118 append_editor(jQuery('#embed-code').val());
mp-wp_genesis 119 jQuery('#extra_fields').hide();
mp-wp_genesis 120 jQuery('#extra_fields').html('');
mp-wp_genesis 121 });
mp-wp_genesis 122 jQuery('.close').click(function() {
mp-wp_genesis 123 jQuery('#extra_fields').hide();
mp-wp_genesis 124 jQuery('#extra_fields').html('');
mp-wp_genesis 125 });
mp-wp_genesis 126 </script>
mp-wp_genesis 127 <div class="postbox">
mp-wp_genesis 128 <h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
mp-wp_genesis 129 <div class="inside">
mp-wp_genesis 130 <textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo format_to_edit($selection, true); ?></textarea>
mp-wp_genesis 131 <p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
mp-wp_genesis 132 </div>
mp-wp_genesis 133 </div>
mp-wp_genesis 134 <?php break;
mp-wp_genesis 135
mp-wp_genesis 136 case 'photo_thickbox': ?>
mp-wp_genesis 137 <script type="text/javascript" charset="utf-8">
mp-wp_genesis 138 jQuery('.cancel').click(function() {
mp-wp_genesis 139 tb_remove();
mp-wp_genesis 140 });
mp-wp_genesis 141 jQuery('.select').click(function() {
mp-wp_genesis 142 image_selector();
mp-wp_genesis 143 });
mp-wp_genesis 144 </script>
mp-wp_genesis 145 <h3 class="tb"><label for="this_photo_description"><?php _e('Description') ?></label></h3>
mp-wp_genesis 146 <div class="titlediv">
mp-wp_genesis 147 <div class="titlewrap">
mp-wp_genesis 148 <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/>
mp-wp_genesis 149 </div>
mp-wp_genesis 150 </div>
mp-wp_genesis 151
mp-wp_genesis 152 <p class="centered"><input type="hidden" name="this_photo" value="<?php echo attribute_escape($image); ?>" id="this_photo" />
mp-wp_genesis 153 <a href="#" class="select"><img src="<?php echo clean_url($image); ?>" alt="<?php echo attribute_escape(__('Click to insert.')); ?>" title="<?php echo attribute_escape(__('Click to insert.')); ?>" /></a></p>
mp-wp_genesis 154
mp-wp_genesis 155 <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
mp-wp_genesis 156
mp-wp_genesis 157
mp-wp_genesis 158 <?php break;
mp-wp_genesis 159
mp-wp_genesis 160 case 'photo_thickbox_url': ?>
mp-wp_genesis 161 <script type="text/javascript" charset="utf-8">
mp-wp_genesis 162 jQuery('.cancel').click(function() {
mp-wp_genesis 163 tb_remove();
mp-wp_genesis 164 });
mp-wp_genesis 165
mp-wp_genesis 166 jQuery('.select').click(function() {
mp-wp_genesis 167 image_selector();
mp-wp_genesis 168 });
mp-wp_genesis 169 </script>
mp-wp_genesis 170 <h3 class="tb"><label for="this_photo"><?php _e('URL') ?></label></h3>
mp-wp_genesis 171 <div class="titlediv">
mp-wp_genesis 172 <div class="titlewrap">
mp-wp_genesis 173 <input id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" />
mp-wp_genesis 174 </div>
mp-wp_genesis 175 </div>
mp-wp_genesis 176
mp-wp_genesis 177
mp-wp_genesis 178 <h3 class="tb"><label for="photo_description"><?php _e('Description') ?></label></h3>
mp-wp_genesis 179 <div id="titlediv">
mp-wp_genesis 180 <div class="titlewrap">
mp-wp_genesis 181 <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo attribute_escape($title);?>"/>
mp-wp_genesis 182 </div>
mp-wp_genesis 183 </div>
mp-wp_genesis 184
mp-wp_genesis 185 <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p>
mp-wp_genesis 186 <?php break;
mp-wp_genesis 187 case 'photo_images':
mp-wp_genesis 188 /**
mp-wp_genesis 189 * Retrieve all image URLs from given URI.
mp-wp_genesis 190 *
mp-wp_genesis 191 * @package WordPress
mp-wp_genesis 192 * @subpackage Press_This
mp-wp_genesis 193 * @since 2.6.0
mp-wp_genesis 194 *
mp-wp_genesis 195 * @param string $uri
mp-wp_genesis 196 * @return string
mp-wp_genesis 197 */
mp-wp_genesis 198 function get_images_from_uri($uri) {
mp-wp_genesis 199 if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
mp-wp_genesis 200 return "'".$uri."'";
mp-wp_genesis 201 $content = wp_remote_fopen($uri);
mp-wp_genesis 202 if ( false === $content )
mp-wp_genesis 203 return '';
mp-wp_genesis 204 $host = parse_url($uri);
mp-wp_genesis 205 $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is';
mp-wp_genesis 206 preg_match_all($pattern, $content, $matches);
mp-wp_genesis 207 if ( empty($matches[0]) )
mp-wp_genesis 208 return '';
mp-wp_genesis 209 $sources = array();
mp-wp_genesis 210 foreach ($matches[3] as $src) {
mp-wp_genesis 211 // if no http in url
mp-wp_genesis 212 if(strpos($src, 'http') === false)
mp-wp_genesis 213 // if it doesn't have a relative uri
mp-wp_genesis 214 if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
mp-wp_genesis 215 $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
mp-wp_genesis 216 else
mp-wp_genesis 217 $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
mp-wp_genesis 218 $sources[] = clean_url($src);
mp-wp_genesis 219 }
mp-wp_genesis 220 return "'" . implode("','", $sources) . "'";
mp-wp_genesis 221 }
mp-wp_genesis 222 $url = urldecode($url);
mp-wp_genesis 223 $url = str_replace(' ', '%20', $url);
mp-wp_genesis 224 echo 'new Array('.get_images_from_uri($url).')';
mp-wp_genesis 225
mp-wp_genesis 226 break;
mp-wp_genesis 227
mp-wp_genesis 228 case 'photo_js': ?>
mp-wp_genesis 229 // gather images and load some default JS
mp-wp_genesis 230 var last = null
mp-wp_genesis 231 var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
mp-wp_genesis 232 var my_src = eval(
mp-wp_genesis 233 jQuery.ajax({
mp-wp_genesis 234 type: "GET",
mp-wp_genesis 235 url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
mp-wp_genesis 236 cache : false,
mp-wp_genesis 237 async : false,
mp-wp_genesis 238 data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
mp-wp_genesis 239 dataType : "script"
mp-wp_genesis 240 }).responseText
mp-wp_genesis 241 );
mp-wp_genesis 242 if(my_src.length == 0) {
mp-wp_genesis 243 var my_src = eval(
mp-wp_genesis 244 jQuery.ajax({
mp-wp_genesis 245 type: "GET",
mp-wp_genesis 246 url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
mp-wp_genesis 247 cache : false,
mp-wp_genesis 248 async : false,
mp-wp_genesis 249 data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
mp-wp_genesis 250 dataType : "script"
mp-wp_genesis 251 }).responseText
mp-wp_genesis 252 );
mp-wp_genesis 253 if(my_src.length == 0) {
mp-wp_genesis 254 strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
mp-wp_genesis 255 }
mp-wp_genesis 256 }
mp-wp_genesis 257
mp-wp_genesis 258 for (i = 0; i < my_src.length; i++) {
mp-wp_genesis 259 img = new Image();
mp-wp_genesis 260 img.src = my_src[i];
mp-wp_genesis 261 img_attr = 'id="img' + i + '"';
mp-wp_genesis 262 skip = false;
mp-wp_genesis 263
mp-wp_genesis 264 maybeappend = '<a href="?ajax=photo_thickbox&i=' + encodeURIComponent(img.src) + '&u=<?php echo urlencode($url); ?>&height=400&width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
mp-wp_genesis 265
mp-wp_genesis 266 if (img.width && img.height) {
mp-wp_genesis 267 if (img.width >= 30 && img.height >= 30) {
mp-wp_genesis 268 aspect = img.width / img.height;
mp-wp_genesis 269 scale = (aspect > 1) ? (71 / img.width) : (71 / img.height);
mp-wp_genesis 270
mp-wp_genesis 271 w = img.width;
mp-wp_genesis 272 h = img.height;
mp-wp_genesis 273
mp-wp_genesis 274 if (scale < 1) {
mp-wp_genesis 275 w = parseInt(img.width * scale);
mp-wp_genesis 276 h = parseInt(img.height * scale);
mp-wp_genesis 277 }
mp-wp_genesis 278 img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
mp-wp_genesis 279 strtoappend += maybeappend;
mp-wp_genesis 280 }
mp-wp_genesis 281 } else {
mp-wp_genesis 282 strtoappend += maybeappend;
mp-wp_genesis 283 }
mp-wp_genesis 284 }
mp-wp_genesis 285
mp-wp_genesis 286 function pick(img, desc) {
mp-wp_genesis 287 if (img) {
mp-wp_genesis 288 if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
mp-wp_genesis 289 if(length == 0) length = 1;
mp-wp_genesis 290 jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
mp-wp_genesis 291 jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
mp-wp_genesis 292 insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
mp-wp_genesis 293 }
mp-wp_genesis 294 return false;
mp-wp_genesis 295 }
mp-wp_genesis 296
mp-wp_genesis 297 function image_selector() {
mp-wp_genesis 298 tb_remove();
mp-wp_genesis 299 desc = jQuery('#this_photo_description').val();
mp-wp_genesis 300 src = jQuery('#this_photo').val();
mp-wp_genesis 301 pick(src, desc);
mp-wp_genesis 302 jQuery('#extra_fields').hide();
mp-wp_genesis 303 jQuery('#extra_fields').html('');
mp-wp_genesis 304 return false;
mp-wp_genesis 305 }
mp-wp_genesis 306
mp-wp_genesis 307 jQuery(document).ready(function() {
mp-wp_genesis 308 jQuery('#extra_fields').html('<div class="postbox"><h2>Photo <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul id="actions"><li><a href="#" id="photo_add_url" class="thickbox button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
mp-wp_genesis 309 jQuery('.close').click(function() {
mp-wp_genesis 310 jQuery('#extra_fields').hide();
mp-wp_genesis 311 jQuery('#extra_fields').html('');
mp-wp_genesis 312 });
mp-wp_genesis 313 jQuery('.refresh').click(function() {
mp-wp_genesis 314 show('photo');
mp-wp_genesis 315 });
mp-wp_genesis 316 jQuery('#img_container').html(strtoappend);
mp-wp_genesis 317 jQuery('#photo_add_url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
mp-wp_genesis 318 tb_init('#extra_fields .thickbox');
mp-wp_genesis 319
mp-wp_genesis 320
mp-wp_genesis 321 });
mp-wp_genesis 322 <?php break;
mp-wp_genesis 323 }
mp-wp_genesis 324 die;
mp-wp_genesis 325 }
mp-wp_genesis 326
mp-wp_genesis 327 ?>
mp-wp_genesis 328 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
mp-wp_genesis 329 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
mp-wp_genesis 330 <head>
mp-wp_genesis 331 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
mp-wp_genesis 332 <title><?php _e('Press This') ?></title>
mp-wp_genesis 333
mp-wp_genesis 334 <?php
mp-wp_genesis 335 add_thickbox();
mp-wp_genesis 336 wp_enqueue_style('press-this');
mp-wp_genesis 337 wp_enqueue_style('press-this-ie');
mp-wp_genesis 338 wp_enqueue_style( 'colors' );
mp-wp_genesis 339 wp_enqueue_script( 'post' );
mp-wp_genesis 340 wp_enqueue_script('editor');
mp-wp_genesis 341
mp-wp_genesis 342 do_action('admin_print_styles');
mp-wp_genesis 343 do_action('admin_print_scripts');
mp-wp_genesis 344 do_action('admin_head');
mp-wp_genesis 345
mp-wp_genesis 346 if ( user_can_richedit() ) {
mp-wp_genesis 347 add_filter( 'teeny_mce_before_init', create_function( '$a', '$a["height"] = "400"; $a["onpageload"] = ""; $a["mode"] = "textareas"; $a["editor_selector"] = "mceEditor"; return $a;' ) );
mp-wp_genesis 348 wp_tiny_mce( true );
mp-wp_genesis 349 }
mp-wp_genesis 350 ?>
mp-wp_genesis 351 <script type="text/javascript">
mp-wp_genesis 352 jQuery('#tags-input').hide();
mp-wp_genesis 353 tag_update_quickclicks();
mp-wp_genesis 354 // add the quickadd form
mp-wp_genesis 355 jQuery('#jaxtag').prepend('<span id="ajaxtag"><input type="text" name="newtag" id="newtag" class="form-input-tip" size="16" autocomplete="off" value="'+postL10n.addTag+'" /><input type="submit" class="button" id="tagadd" value="' + postL10n.add + '" tabindex="3" onclick="return false;" /><input type="hidden"/><input type="hidden"/><span class="howto">'+postL10n.separate+'</span></span>');
mp-wp_genesis 356
mp-wp_genesis 357 jQuery('#tagadd').click( tag_flush_to_text );
mp-wp_genesis 358 jQuery('#newtag').focus(function() {
mp-wp_genesis 359 if ( this.value == postL10n.addTag )
mp-wp_genesis 360 jQuery(this).val( '' ).removeClass( 'form-input-tip' );
mp-wp_genesis 361 });
mp-wp_genesis 362 jQuery('#newtag').blur(function() {
mp-wp_genesis 363 if ( this.value == '' )
mp-wp_genesis 364 jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' );
mp-wp_genesis 365 });
mp-wp_genesis 366 // auto-save tags on post save/publish
mp-wp_genesis 367 jQuery('#publish').click( tag_save_on_publish );
mp-wp_genesis 368 jQuery('#save').click( tag_save_on_publish );
mp-wp_genesis 369 function insert_plain_editor(text) {
mp-wp_genesis 370 edCanvas = document.getElementById('content');
mp-wp_genesis 371 edInsertContent(edCanvas, text);
mp-wp_genesis 372 }
mp-wp_genesis 373 function set_editor(text) {
mp-wp_genesis 374 if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
mp-wp_genesis 375 if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text);
mp-wp_genesis 376 }
mp-wp_genesis 377 function insert_editor(text) {
mp-wp_genesis 378 if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
mp-wp_genesis 379 tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
mp-wp_genesis 380 } else {
mp-wp_genesis 381 insert_plain_editor(decodeURI(text));
mp-wp_genesis 382 }
mp-wp_genesis 383 }
mp-wp_genesis 384 function append_editor(text) {
mp-wp_genesis 385 if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
mp-wp_genesis 386 tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
mp-wp_genesis 387 tinyMCE.execCommand('mceCleanup');
mp-wp_genesis 388 } else {
mp-wp_genesis 389 insert_plain_editor(text);
mp-wp_genesis 390 }
mp-wp_genesis 391 }
mp-wp_genesis 392
mp-wp_genesis 393 function show(tab_name) {
mp-wp_genesis 394 jQuery('#extra_fields').html('');
mp-wp_genesis 395 jQuery('#extra_fields').show();
mp-wp_genesis 396 switch(tab_name) {
mp-wp_genesis 397 case 'video' :
mp-wp_genesis 398 jQuery('#extra_fields').load('<?php echo clean_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo attribute_escape($selection); ?>'}, function() {
mp-wp_genesis 399 <?php
mp-wp_genesis 400 $content = '';
mp-wp_genesis 401 if ( preg_match("/youtube\.com\/watch/i", $url) ) {
mp-wp_genesis 402 list($domain, $video_id) = split("v=", $url);
mp-wp_genesis 403 $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>';
mp-wp_genesis 404
mp-wp_genesis 405 } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
mp-wp_genesis 406 list($domain, $video_id) = split(".com/", $url);
mp-wp_genesis 407 $content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /> <embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>';
mp-wp_genesis 408
mp-wp_genesis 409 if ( trim($selection) == '' )
mp-wp_genesis 410 $selection = '<p><a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a></p>';
mp-wp_genesis 411
mp-wp_genesis 412 } elseif ( strpos( $selection, '<object' ) !== false ) {
mp-wp_genesis 413 $content = $selection;
mp-wp_genesis 414 }
mp-wp_genesis 415 ?>
mp-wp_genesis 416 jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
mp-wp_genesis 417 });
mp-wp_genesis 418 return false;
mp-wp_genesis 419 break;
mp-wp_genesis 420 case 'photo' :
mp-wp_genesis 421 jQuery('#extra_fields').before('<p id="waiting"><img src="images/loading.gif" alt="" /> <?php echo js_escape( __( 'Loading...' ) ); ?></p>');
mp-wp_genesis 422 jQuery.ajax({
mp-wp_genesis 423 type: "GET",
mp-wp_genesis 424 cache : false,
mp-wp_genesis 425 url: "<?php echo clean_url($_SERVER['PHP_SELF']); ?>",
mp-wp_genesis 426 data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
mp-wp_genesis 427 dataType : "script",
mp-wp_genesis 428 success : function() {
mp-wp_genesis 429 jQuery('#waiting').remove();
mp-wp_genesis 430 }
mp-wp_genesis 431 });
mp-wp_genesis 432 return false;
mp-wp_genesis 433 break;
mp-wp_genesis 434 }
mp-wp_genesis 435 }
mp-wp_genesis 436 jQuery(document).ready(function() {
mp-wp_genesis 437 //resize screen
mp-wp_genesis 438 window.resizeTo(720,570);
mp-wp_genesis 439 // set button actions
mp-wp_genesis 440 jQuery('#photo_button').click(function() { show('photo'); return false; });
mp-wp_genesis 441 jQuery('#video_button').click(function() { show('video'); return false; });
mp-wp_genesis 442 // auto select
mp-wp_genesis 443 <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
mp-wp_genesis 444 show('video');
mp-wp_genesis 445 <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
mp-wp_genesis 446 show('video');
mp-wp_genesis 447 <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
mp-wp_genesis 448 show('photo');
mp-wp_genesis 449 <?php } ?>
mp-wp_genesis 450 jQuery('#title').unbind();
mp-wp_genesis 451 jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
mp-wp_genesis 452 });
mp-wp_genesis 453 </script>
mp-wp_genesis 454 </head>
mp-wp_genesis 455 <body class="press-this">
mp-wp_genesis 456 <div id="wphead"></div>
mp-wp_genesis 457 <form action="press-this.php?action=post" method="post">
mp-wp_genesis 458 <div id="poststuff" class="metabox-holder">
mp-wp_genesis 459 <div id="side-info-column">
mp-wp_genesis 460 <div class="sleeve">
mp-wp_genesis 461 <h1 id="viewsite"><a class="button" href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> › <?php _e('Press This') ?></a></span></h1>
mp-wp_genesis 462
mp-wp_genesis 463 <?php wp_nonce_field('press-this') ?>
mp-wp_genesis 464 <input type="hidden" name="post_type" id="post_type" value="text"/>
mp-wp_genesis 465 <input type="hidden" name="autosave" id="autosave" />
mp-wp_genesis 466 <input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
mp-wp_genesis 467 <input type="hidden" id="prev_status" name="prev_status" value="draft" />
mp-wp_genesis 468
mp-wp_genesis 469 <!-- This div holds the photo metadata -->
mp-wp_genesis 470 <div class="photolist"></div>
mp-wp_genesis 471
mp-wp_genesis 472 <div id="categorydiv" class="stuffbox">
mp-wp_genesis 473 <h2><?php _e('Categories') ?></h2>
mp-wp_genesis 474 <div class="inside">
mp-wp_genesis 475
mp-wp_genesis 476 <div id="categories-all" class="ui-tabs-panel">
mp-wp_genesis 477 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
mp-wp_genesis 478 <?php wp_category_checklist($post->ID, false, false, $popular_ids) ?>
mp-wp_genesis 479 </ul>
mp-wp_genesis 480 </div>
mp-wp_genesis 481
mp-wp_genesis 482 <div id="category-adder" class="wp-hidden-children">
mp-wp_genesis 483 <a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a>
mp-wp_genesis 484 <p id="category-add" class="wp-hidden-child">
mp-wp_genesis 485 <label class="hidden" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
mp-wp_genesis 486 <label class="hidden" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
mp-wp_genesis 487 <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
mp-wp_genesis 488 <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
mp-wp_genesis 489 <span id="category-ajax-response"></span>
mp-wp_genesis 490 </p>
mp-wp_genesis 491 </div>
mp-wp_genesis 492 </div>
mp-wp_genesis 493 </div>
mp-wp_genesis 494
mp-wp_genesis 495 <div class="stuffbox">
mp-wp_genesis 496 <h2><?php _e('Tags') ?></h2>
mp-wp_genesis 497 <div class="inside">
mp-wp_genesis 498
mp-wp_genesis 499 <div id="jaxtag">
mp-wp_genesis 500 <label class="hidden" for="newtag"><?php _e('Tags'); ?></label>
mp-wp_genesis 501 <input type="text" name="tags_input" class="tags-input" id="tags-input" size="40" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
mp-wp_genesis 502 </div>
mp-wp_genesis 503 <div id="tagchecklist"></div>
mp-wp_genesis 504 </div>
mp-wp_genesis 505 </div>
mp-wp_genesis 506 <div id="submitdiv" class="postbox">
mp-wp_genesis 507 <h2><?php _e('Publish') ?></h2>
mp-wp_genesis 508 <div class="inside">
mp-wp_genesis 509 <p>
mp-wp_genesis 510 <input class="button" type="submit" name="draft" value="<?php _e('Save Draft') ?>" id="save" />
mp-wp_genesis 511 <input class="button-primary" type="submit" name="publish" value="<?php _e('Publish') ?>" id="publish" />
mp-wp_genesis 512 <img src="images/loading-publish.gif" alt="" id="saving" style="display:none;"/>
mp-wp_genesis 513 </p>
mp-wp_genesis 514 </div>
mp-wp_genesis 515 </div>
mp-wp_genesis 516 </div>
mp-wp_genesis 517 </div>
mp-wp_genesis 518
mp-wp_genesis 519 <div class="posting">
mp-wp_genesis 520 <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
mp-wp_genesis 521 <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div>
mp-wp_genesis 522 <?php } ?>
mp-wp_genesis 523
mp-wp_genesis 524 <div id="titlediv">
mp-wp_genesis 525 <div class="titlewrap">
mp-wp_genesis 526 <input name="title" id="title" class="text" value="<?php echo attribute_escape($title);?>"/>
mp-wp_genesis 527 </div>
mp-wp_genesis 528 </div>
mp-wp_genesis 529
mp-wp_genesis 530 <div id="extra_fields" style="display: none"></div>
mp-wp_genesis 531
mp-wp_genesis 532 <div class="postdivrich">
mp-wp_genesis 533 <ul id="actions">
mp-wp_genesis 534 <li id="photo_button">
mp-wp_genesis 535 Add: <a title="<?php _e('Insert an Image'); ?>" href="#">
mp-wp_genesis 536 <img alt="<?php _e('Insert an Image'); ?>" src="images/media-button-image.gif"/></a>
mp-wp_genesis 537 </li>
mp-wp_genesis 538 <li id="video_button">
mp-wp_genesis 539 <a title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="images/media-button-video.gif"/></a>
mp-wp_genesis 540 </li>
mp-wp_genesis 541 <?php if( user_can_richedit() ) { ?>
mp-wp_genesis 542 <li id="switcher">
mp-wp_genesis 543 <?php wp_print_scripts( 'quicktags' ); ?>
mp-wp_genesis 544 <?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
mp-wp_genesis 545 <a id="edButtonHTML" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
mp-wp_genesis 546 <a id="edButtonPreview" class="active" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
mp-wp_genesis 547 <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
mp-wp_genesis 548 </li>
mp-wp_genesis 549 <?php } ?>
mp-wp_genesis 550 </ul>
mp-wp_genesis 551 <div id="quicktags"></div>
mp-wp_genesis 552 <div class="editor-container">
mp-wp_genesis 553 <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15">
mp-wp_genesis 554 <?php if ($selection) echo wp_richedit_pre(htmlspecialchars_decode($selection)); ?>
mp-wp_genesis 555 <?php if ($url) { echo '<p>'; if($selection) _e('via '); echo "<a href='$url'>$title</a>."; echo '</p>'; } ?>
mp-wp_genesis 556 </textarea>
mp-wp_genesis 557 </div>
mp-wp_genesis 558 </div>
mp-wp_genesis 559 </div>
mp-wp_genesis 560 </div>
mp-wp_genesis 561 </form>
mp-wp_genesis 562 </body>
mp-wp_genesis 563 </html>