| 120 | | function press_this_js_init() { ?> |
|---|
| 121 | | <?php if ( user_can_richedit() ) { |
|---|
| | 112 | // Clean up the data being passed in |
|---|
| | 113 | $title = wp_specialchars(stripslashes($_GET['t'])); |
|---|
| | 114 | $selection = trim(wp_specialchars(str_replace("\n", ' ',stripslashes($_GET['s'])))); |
|---|
| | 115 | $url = clean_url($_GET['u']); |
|---|
| | 116 | ?> |
|---|
| | 117 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| | 118 | <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> |
|---|
| | 119 | <head> |
|---|
| | 120 | <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> |
|---|
| | 121 | <title><?php _e('Press This') ?></title> |
|---|
| | 122 | |
|---|
| | 123 | <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce.js"></script> |
|---|
| | 124 | <?php |
|---|
| | 125 | wp_enqueue_script('jquery-ui-tabs'); |
|---|
| | 126 | add_thickbox(); |
|---|
| | 127 | wp_enqueue_style('press-this'); |
|---|
| | 128 | wp_enqueue_style( 'colors' ); |
|---|
| | 129 | wp_enqueue_script('post'); |
|---|
| | 130 | |
|---|
| | 131 | do_action('admin_print_styles'); |
|---|
| | 132 | do_action('admin_print_scripts'); |
|---|
| | 133 | do_action('admin_head'); |
|---|
| | 134 | ?> |
|---|
| | 135 | <script type="text/javascript"> |
|---|
| | 136 | <?php if ( user_can_richedit() ) { |
|---|
| 182 | | <?php |
|---|
| 183 | | } |
|---|
| 184 | | |
|---|
| 185 | | // Clean up the data being passed in |
|---|
| 186 | | $title = wp_specialchars(stripslashes($_GET['t'])); |
|---|
| 187 | | $selection = wp_specialchars(stripslashes($_GET['s'])); |
|---|
| 188 | | $url = clean_url($_GET['u']); |
|---|
| 189 | | |
|---|
| 190 | | if ( empty($_GET['tab']) ) { |
|---|
| 191 | | ?> |
|---|
| 192 | | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 193 | | <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> |
|---|
| 194 | | <head> |
|---|
| 195 | | <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> |
|---|
| 196 | | <title><?php _e('Press This') ?></title> |
|---|
| 197 | | |
|---|
| 198 | | <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce.js"></script> |
|---|
| 199 | | <?php |
|---|
| 200 | | wp_enqueue_script('jquery-ui-tabs'); |
|---|
| 201 | | add_thickbox(); |
|---|
| 202 | | wp_enqueue_style('press-this'); |
|---|
| 203 | | wp_enqueue_style( 'colors' ); |
|---|
| 204 | | wp_enqueue_script('post'); |
|---|
| 205 | | |
|---|
| 206 | | do_action('admin_print_styles'); |
|---|
| 207 | | do_action('admin_print_scripts'); |
|---|
| 208 | | do_action('admin_head'); |
|---|
| 209 | | ?> |
|---|
| 210 | | <script type="text/javascript"> |
|---|
| | 197 | |
|---|
| | 198 | function set_menu(type) { |
|---|
| | 199 | jQuery('#text_button').removeClass('ui-tabs-selected'); |
|---|
| | 200 | jQuery('#menu li').removeClass('ui-tabs-selected'); |
|---|
| | 201 | jQuery('#' + type + '_button').addClass('ui-tabs-selected'); |
|---|
| | 202 | jQuery("#post_type").val(type); |
|---|
| | 203 | } |
|---|
| | 204 | function set_editor(text) { |
|---|
| | 205 | tinyMCE.activeEditor.setContent(''); |
|---|
| | 206 | tinyMCE.execCommand('mceInsertContent' ,false, text); |
|---|
| | 207 | } |
|---|
| | 208 | function set_title(title) { jQuery("#content_type").text(title); } |
|---|
| | 209 | |
|---|
| | 210 | var last = null; |
|---|
| | 211 | function pick(img) { |
|---|
| | 212 | if (last) last.style.backgroundColor = '#f4f4f4'; |
|---|
| | 213 | if (img) { |
|---|
| | 214 | document.getElementById('photo_src').value = img.src; |
|---|
| | 215 | img.style.backgroundColor = '#44f'; |
|---|
| | 216 | } |
|---|
| | 217 | last = img; |
|---|
| | 218 | |
|---|
| | 219 | /*noel's code to select more than one image.... |
|---|
| | 220 | jQuery('.photolist').append('<h2><?php _e("Photo URL") ?></h2>' + |
|---|
| | 221 | '<div class="titlewrap">' + |
|---|
| | 222 | '<a href="#" class="remove">remove <input name="photo_src" id="photo_src[]" value ="'+ img.src +'" class="text" onkeydown="pick(0);"/></a>' + |
|---|
| | 223 | '</div>');*/ |
|---|
| | 224 | |
|---|
| | 225 | return false; |
|---|
| | 226 | } |
|---|
| 213 | | <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> |
|---|
| 214 | | jQuery('#container > ul').tabs({ selected: 3 }); |
|---|
| 215 | | <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?> |
|---|
| 216 | | jQuery('#container > ul').tabs({ selected: 1 }); |
|---|
| 217 | | <?php } else { ?> |
|---|
| 218 | | jQuery('#container > ul').tabs(); |
|---|
| 219 | | <?php } ?> |
|---|
| | 229 | |
|---|
| | 230 | |
|---|
| | 231 | <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> |
|---|
| | 232 | |
|---|
| | 233 | <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?> |
|---|
| | 234 | |
|---|
| | 235 | <?php } else { ?> |
|---|
| | 236 | |
|---|
| | 237 | <?php } ?> |
|---|
| | 238 | |
|---|
| | 239 | |
|---|
| | 240 | jQuery("#text_button").click(function () { |
|---|
| | 241 | jQuery('.editor-container').show(); |
|---|
| | 242 | jQuery('#content_type').show(); |
|---|
| | 243 | jQuery('#photo_fields').hide(); |
|---|
| | 244 | set_menu('text'); |
|---|
| | 245 | set_title('<?php _e('Text') ?>'); |
|---|
| | 246 | set_editor('<?php echo $selection; ?>'); |
|---|
| | 247 | return false; |
|---|
| | 248 | }); |
|---|
| | 249 | |
|---|
| | 250 | jQuery("#quote_button").click(function () { |
|---|
| | 251 | jQuery('.editor-container').show(); |
|---|
| | 252 | jQuery('#content_type').show(); |
|---|
| | 253 | jQuery('#photo_fields').hide(); |
|---|
| | 254 | set_menu('quote'); |
|---|
| | 255 | set_title('<?php _e('Quote') ?>'); |
|---|
| | 256 | set_editor('<blockquote><p><?php echo $selection; ?> </p><p><cite><a href="<?php echo $url; ?>"><?php echo $title; ?></a></cite> </p></blockquote>'); |
|---|
| | 257 | |
|---|
| | 258 | return false; |
|---|
| | 259 | }); |
|---|
| | 260 | |
|---|
| | 261 | |
|---|
| | 262 | jQuery("#video_button").click(function () { |
|---|
| | 263 | jQuery('.editor-container').show(); |
|---|
| | 264 | jQuery('#content_type').show(); |
|---|
| | 265 | jQuery('#photo_fields').hide(); |
|---|
| | 266 | set_menu('video'); |
|---|
| | 267 | set_title('<?php _e('Video') ?>'); |
|---|
| | 268 | set_editor('<a href="<?php echo $url; ?>"><?php echo $title; ?></a>'); |
|---|
| | 269 | <?php /* |
|---|
| | 270 | <!--list($garbage,$video_id) = split("v=", $_REQUEST['content']); |
|---|
| | 271 | $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>';--> |
|---|
| | 272 | */?> |
|---|
| | 273 | return false; |
|---|
| | 274 | }); |
|---|
| | 275 | |
|---|
| | 276 | |
|---|
| | 277 | jQuery("#photo_button").click(function () { |
|---|
| | 278 | set_menu('photo'); |
|---|
| | 279 | set_title('Caption'); |
|---|
| | 280 | set_editor('<a href="<?php echo $url; ?>"><?php echo $title; ?></a>'); |
|---|
| | 281 | jQuery('#photo_fields').show(); |
|---|
| | 282 | jQuery('.remove').click(function() { |
|---|
| | 283 | jQuery(this).remove; |
|---|
| | 284 | |
|---|
| | 285 | }); |
|---|
| | 286 | |
|---|
| | 287 | |
|---|
| | 288 | var img, img_tag, aspect, w, h, skip, i, strtoappend = ""; |
|---|
| | 289 | var my_src = [<?php echo get_images_from_uri($url); ?>]; |
|---|
| | 290 | |
|---|
| | 291 | for (i = 0; i < my_src.length; i++) { |
|---|
| | 292 | img = new Image(); |
|---|
| | 293 | img.src = my_src[i]; |
|---|
| | 294 | img_attr = 'id="img' + i + '" onclick="pick(this);"'; |
|---|
| | 295 | skip = false; |
|---|
| | 296 | |
|---|
| | 297 | if (img.width && img.height) { |
|---|
| | 298 | if (img.width * img.height < 2500) skip = true; |
|---|
| | 299 | aspect = img.width / img.height; |
|---|
| | 300 | if (aspect > 1) { // Image is wide |
|---|
| | 301 | scale = 75 / img.width; |
|---|
| | 302 | } else { // Image is tall or square |
|---|
| | 303 | scale = 75 / img.height; |
|---|
| | 304 | } |
|---|
| | 305 | if (scale < 1) { |
|---|
| | 306 | w = parseInt(img.width * scale); |
|---|
| | 307 | h = parseInt(img.height * scale); |
|---|
| | 308 | } else { |
|---|
| | 309 | w = img.width; |
|---|
| | 310 | h = img.height; |
|---|
| | 311 | } |
|---|
| | 312 | img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"'; |
|---|
| | 313 | } |
|---|
| | 314 | |
|---|
| | 315 | if (!skip) strtoappend += '<a href="' + img.src + '" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>'; |
|---|
| | 316 | |
|---|
| | 317 | } |
|---|
| | 318 | |
|---|
| | 319 | jQuery('#img_container').html(strtoappend); |
|---|
| | 320 | |
|---|
| | 321 | tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox |
|---|
| | 322 | |
|---|
| | 323 | }); |
|---|
| 230 | | <div id="container"> |
|---|
| 231 | | <ul> |
|---|
| 232 | | <li><a href="<?php echo clean_url(add_query_arg('tab', 'text', stripslashes($_SERVER['REQUEST_URI']))) ?>"><?php _e('Text') ?></a></li> |
|---|
| 233 | | <li><a href="<?php echo clean_url(add_query_arg('tab', 'photo', stripslashes($_SERVER['REQUEST_URI']))) ?>"><?php _e('Photo') ?></a></li> |
|---|
| 234 | | <li><a href="<?php echo clean_url(add_query_arg('tab', 'quote', stripslashes($_SERVER['REQUEST_URI']))) ?>"><?php _e('Quote') ?></a></li> |
|---|
| 235 | | <li><a href="<?php echo clean_url(add_query_arg('tab', 'video', stripslashes($_SERVER['REQUEST_URI']))) ?>"><?php _e('Video') ?></a></li> |
|---|
| | 333 | |
|---|
| | 334 | <ul id="menu" class="ui-tabs-nav"> |
|---|
| | 335 | <li id="text_button" class="ui-tabs-selected"><a href="#"><?php _e('Text') ?></a></li> |
|---|
| | 336 | <li id="photo_button"><a href="#"><?php _e('Photo') ?></a></li> |
|---|
| | 337 | <li id="quote_button"><a href="#"><?php _e('Quote') ?></a></li> |
|---|
| | 338 | <li id="video_button"><a href="#"><?php _e('Video') ?></a></li> |
|---|
| 237 | | |
|---|
| 238 | | </div> |
|---|
| 239 | | </body> |
|---|
| 240 | | </html> |
|---|
| 241 | | <?php exit; } elseif ( 'photo' == $_GET['tab'] ) { ?> |
|---|
| 242 | | <script type="text/javascript"> |
|---|
| 243 | | <?php press_this_js_init(); ?> |
|---|
| 244 | | var last = null; |
|---|
| 245 | | function pick(img) { |
|---|
| 246 | | if (last) last.style.backgroundColor = '#f4f4f4'; |
|---|
| 247 | | if (img) { |
|---|
| 248 | | document.getElementById('photo_src').value = img.src; |
|---|
| 249 | | img.style.backgroundColor = '#44f'; |
|---|
| 250 | | } |
|---|
| 251 | | last = img; |
|---|
| 252 | | |
|---|
| 253 | | /*jQuery('.photolist').append('<h2><?php _e("Photo URL") ?></h2>' + |
|---|
| 254 | | '<div class="titlewrap">' + |
|---|
| 255 | | '<a href="#" class="remove">remove <input name="photo_src" id="photo_src[]" value ="'+ img.src +'" class="text" onkeydown="pick(0);"/></a>' + |
|---|
| 256 | | '</div>');*/ |
|---|
| 257 | | return false; |
|---|
| 258 | | } |
|---|
| 259 | | |
|---|
| 260 | | jQuery('.remove').click(function() { |
|---|
| 261 | | jQuery(this).remove; |
|---|
| 262 | | |
|---|
| 263 | | }); |
|---|
| 264 | | jQuery(document).ready(function() { |
|---|
| 265 | | var img, img_tag, aspect, w, h, skip, i, strtoappend = ""; |
|---|
| 266 | | var my_src = [<?php echo get_images_from_uri($url); ?>]; |
|---|
| 267 | | |
|---|
| 268 | | for (i = 0; i < my_src.length; i++) { |
|---|
| 269 | | img = new Image(); |
|---|
| 270 | | img.src = my_src[i]; |
|---|
| 271 | | img_attr = 'id="img' + i + '" onclick="pick(this);"'; |
|---|
| 272 | | skip = false; |
|---|
| 273 | | if (img.width && img.height) { |
|---|
| 274 | | if (img.width * img.height < 2500) skip = true; |
|---|
| 275 | | aspect = img.width / img.height; |
|---|
| 276 | | if (aspect > 1) { |
|---|
| 277 | | // Image is wide |
|---|
| 278 | | scale = 75 / img.width; |
|---|
| 279 | | } else { |
|---|
| 280 | | // Image is tall or square |
|---|
| 281 | | scale = 75 / img.height; |
|---|
| 282 | | } |
|---|
| 283 | | if (scale < 1) { |
|---|
| 284 | | w = parseInt(img.width * scale); |
|---|
| 285 | | h = parseInt(img.height * scale); |
|---|
| 286 | | } else { |
|---|
| 287 | | w = img.width; |
|---|
| 288 | | h = img.height; |
|---|
| 289 | | } |
|---|
| 290 | | img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"'; |
|---|
| 291 | | } |
|---|
| 292 | | if (!skip) { |
|---|
| 293 | | strtoappend += '<a href="' + img.src + '" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>' |
|---|
| 294 | | } |
|---|
| 295 | | } |
|---|
| 296 | | |
|---|
| 297 | | jQuery('#img_container').html(strtoappend); |
|---|
| 298 | | |
|---|
| 299 | | tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox |
|---|
| 300 | | }); |
|---|
| 301 | | </script> |
|---|
| 302 | | <form action="press-this.php?action=post" method="post" id="photo_form"> |
|---|
| | 340 | |
|---|
| | 341 | <form action="press-this.php?action=post" method="post"> |
|---|
| 334 | | <textarea name="content" id="photo_post_two" style="" class="mceEditor"> |
|---|
| 335 | | <?php echo $selection; ?> |
|---|
| 336 | | <p><a href="<?php echo attribute_escape($url);?>"><?php echo $title;?></a> </p> |
|---|
| 337 | | </textarea> |
|---|
| 338 | | </div> |
|---|
| 339 | | |
|---|
| 340 | | <?php tag_div(); ?> |
|---|
| 341 | | |
|---|
| 342 | | </div> |
|---|
| 343 | | <?php category_div() ?> |
|---|
| 344 | | </form> |
|---|
| 345 | | <?php |
|---|
| 346 | | exit; |
|---|
| 347 | | } elseif ( 'text' == $_GET['tab'] ) { |
|---|
| 348 | | ?> |
|---|
| 349 | | <script type="text/javascript"> |
|---|
| 350 | | <?php press_this_js_init(); ?> |
|---|
| 351 | | </script> |
|---|
| 352 | | |
|---|
| 353 | | <form action="press-this.php?action=post" method="post" id="regular_form"> |
|---|
| 354 | | <?php wp_nonce_field('press-this') ?> |
|---|
| 355 | | <input type="hidden" name="source" value="bookmarklet"/> |
|---|
| 356 | | <input type="hidden" name="post_type" value="regular"/> |
|---|
| 357 | | <div id="posting"> |
|---|
| 358 | | <h2><?php _e('Title') ?></h2> |
|---|
| 359 | | <div class="titlewrap"> |
|---|
| 360 | | <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape($title);?>"/> |
|---|
| 361 | | </div> |
|---|
| 362 | | |
|---|
| 363 | | <h2><?php _e('Post') ?></h2> |
|---|
| 364 | | <div class="editor-container"> |
|---|
| 365 | | <textarea name="content" id="regular_post_two" style="height:170px;width:100%;" class="mceEditor"> |
|---|
| 366 | | <?php echo $selection; ?> |
|---|
| 367 | | <p><a href="<?php echo $url;?>"><?php echo $title;?></a> </p> |
|---|
| 368 | | </textarea> |
|---|
| 369 | | </div> |
|---|
| 370 | | <?php tag_div(); ?> |
|---|
| 371 | | |
|---|
| 372 | | </div> |
|---|
| 373 | | <?php category_div() ?> |
|---|
| 374 | | </form> |
|---|
| 375 | | <?php |
|---|
| 376 | | exit; |
|---|
| 377 | | } elseif ( 'quote' == $_GET['tab'] ) { |
|---|
| 378 | | ?> |
|---|
| 379 | | <script type="text/javascript"> |
|---|
| 380 | | <?php press_this_js_init(); ?> |
|---|
| 381 | | </script> |
|---|
| 382 | | |
|---|
| 383 | | <form action="press-this.php?action=post" method="post" id="quote_form"> |
|---|
| 384 | | <?php wp_nonce_field('press-this') ?> |
|---|
| 385 | | <input type="hidden" name="source" value="bookmarklet"/> |
|---|
| 386 | | <input type="hidden" name="post_type" value="quote"/> |
|---|
| 387 | | <div id="posting"> |
|---|
| 388 | | <h2><?php _e('Title') ?></h2> |
|---|
| 389 | | <div class="titlewrap"> |
|---|
| 390 | | <input name="post_title" id="post_title" class="text" value="<?php echo attribute_escape(sprintf(__('Quote by %s'), $title)); ?>"/> |
|---|
| 391 | | </div> |
|---|
| 392 | | |
|---|
| 393 | | <h2><?php _e('Quote') ?></h2> |
|---|
| 394 | | <div class="editor-container"> |
|---|
| 395 | | <textarea name="content" id="quote_post_one" style="height:130px;width:100%;" class="mceEditor"> |
|---|
| | 373 | <textarea name="content" id="content" style="height:170px;width:100%;" class="mceEditor"> |
|---|