Changeset 12094 for trunk/wp-admin/press-this.php
- Timestamp:
- 10/23/2009 04:32:56 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/press-this.php
r12042 r12094 101 101 $image = isset($_GET['i']) ? $_GET['i'] : ''; 102 102 103 if ( !empty($_ GET['ajax']) ) {104 switch ($_ GET['ajax']) {103 if ( !empty($_REQUEST['ajax']) ) { 104 switch ($_REQUEST['ajax']) { 105 105 case 'video': ?> 106 106 <script type="text/javascript" charset="utf-8"> … … 108 108 jQuery('.select').click(function() { 109 109 append_editor(jQuery('#embed-code').val()); 110 jQuery('#extra _fields').hide();111 jQuery('#extra _fields').html('');110 jQuery('#extra-fields').hide(); 111 jQuery('#extra-fields').html(''); 112 112 }); 113 113 jQuery('.close').click(function() { 114 jQuery('#extra _fields').hide();115 jQuery('#extra _fields').html('');114 jQuery('#extra-fields').hide(); 115 jQuery('#extra-fields').html(''); 116 116 }); 117 117 /* ]]> */ … … 193 193 */ 194 194 function get_images_from_uri($uri) { 195 $uri = preg_replace('/\/#.+?$/','', $uri); 195 196 if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') ) 196 197 return "'".html_entity_decode($uri)."'"; … … 199 200 return ''; 200 201 $host = parse_url($uri); 201 $pattern = '/<img ([^>]*)src=(\"|\')([^<> ]+?\.(png|jpeg|jpg|jpe|gif)[^<>\'\"]*)(\2)([^>]*)\/*>/is';202 $pattern = '/<img ([^>]*)src=(\"|\')([^<>\'\"]+)(\2)([^>]*)\/*>/is'; 202 203 preg_match_all($pattern, $content, $matches); 203 204 if ( empty($matches[0]) ) … … 216 217 return "'" . implode("','", $sources) . "'"; 217 218 } 218 $url = urldecode($url);219 $url = wp_kses(urldecode($url), null); 219 220 echo 'new Array('.get_images_from_uri($url).')'; 220 221 221 break; 222 222 … … 225 225 var last = null 226 226 var img, img_tag, aspect, w, h, skip, i, strtoappend = ""; 227 if(photostorage == false) { 227 228 var my_src = eval( 228 229 jQuery.ajax({ … … 250 251 } 251 252 } 252 253 } 253 254 for (i = 0; i < my_src.length; i++) { 254 255 img = new Image(); … … 295 296 src = jQuery('#this_photo').val(); 296 297 pick(src, desc); 297 jQuery('#extra _fields').hide();298 jQuery('#extra _fields').html('');298 jQuery('#extra-fields').hide(); 299 jQuery('#extra-fields').html(''); 299 300 return false; 300 301 } 301 302 jQuery(document).ready(function() { 303 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>'); 304 jQuery('.close').click(function() { 305 jQuery('#extra_fields').hide(); 306 jQuery('#extra_fields').html(''); 307 }); 308 jQuery('.refresh').click(function() { 309 show('photo'); 310 }); 302 jQuery('#extra-fields').html('<div class="postbox"><h2>Add Photos <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="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>'); 311 303 jQuery('#img_container').html(strtoappend); 312 jQuery('#photo_add_url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');313 tb_init('#extra_fields .thickbox');314 315 316 });317 304 <?php break; 318 305 } … … 329 316 <?php 330 317 add_thickbox(); 331 wp_enqueue_style( 'press-this');332 wp_enqueue_style( 'press-this-ie');318 wp_enqueue_style( 'press-this' ); 319 wp_enqueue_style( 'press-this-ie'); 333 320 wp_enqueue_style( 'colors' ); 334 321 wp_enqueue_script( 'post' ); 335 wp_enqueue_script( 'editor');322 wp_enqueue_script( 'editor' ); 336 323 ?> 337 324 <script type="text/javascript"> … … 340 327 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'}; 341 328 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'press-this'; 329 var photostorage = false; 342 330 //]]> 343 331 </script> … … 377 365 378 366 function show(tab_name) { 379 jQuery('#extra_fields').html(''); 380 jQuery('#extra_fields').show(); 367 jQuery('#extra-fields').html(''); 381 368 switch(tab_name) { 382 369 case 'video' : 383 jQuery('#extra _fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {370 jQuery('#extra-fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() { 384 371 <?php 385 372 $content = ''; … … 403 390 jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>'); 404 391 }); 392 jQuery('#extra-fields').show(); 405 393 return false; 406 394 break; 407 395 case 'photo' : 408 jQuery('#extra_fields').before('<p id="waiting"><img src="images/wpspin_light.gif" alt="" /> <?php echo esc_js( __( 'Loading...' ) ); ?></p>'); 409 jQuery.ajax({ 410 type: "GET", 411 cache : false, 412 url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>", 413 data: "ajax=photo_js&u=<?php echo urlencode($url)?>", 414 dataType : "script", 415 success : function() { 416 jQuery('#waiting').remove(); 417 } 418 }); 396 function setup_photo_actions() { 397 jQuery('.close').click(function() { 398 jQuery('#extra-fields').hide(); 399 jQuery('#extra-fields').html(''); 400 }); 401 jQuery('.refresh').click(function() { 402 photostorage = false; 403 show('photo'); 404 }); 405 jQuery('#photo-add-url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500'); 406 tb_init('#extra-fields .thickbox'); 407 jQuery('#waiting').hide(); 408 jQuery('#extra-fields').show(); 409 } 410 jQuery('#extra-fields').before('<div id="waiting"><img src="images/wpspin_light.gif" alt="" /> <?php echo esc_js( __( 'Loading...' ) ); ?></div>'); 411 412 if(photostorage == false) { 413 jQuery.ajax({ 414 type: "GET", 415 cache : false, 416 url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>", 417 data: "ajax=photo_js&u=<?php echo urlencode($url)?>", 418 dataType : "script", 419 success : function(data) { 420 eval(data); 421 photostorage = jQuery('#extra-fields').html(); 422 setup_photo_actions(); 423 } 424 }); 425 } else { 426 jQuery('#extra-fields').html(photostorage); 427 setup_photo_actions(); 428 } 419 429 return false; 420 430 break; … … 423 433 jQuery(document).ready(function($) { 424 434 //resize screen 425 window.resizeTo(720,5 70);435 window.resizeTo(720,540); 426 436 // set button actions 427 437 jQuery('#photo_button').click(function() { show('photo'); return false; }); … … 450 460 <div id="side-info-column"> 451 461 <div class="sleeve"> 452 <h1 id="viewsite"><a class="button"href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> › <?php _e('Press This') ?></a></span></h1>462 <h1 id="viewsite"><a href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> › <?php _e('Press This') ?></a></span></h1> 453 463 454 464 <?php wp_nonce_field('press-this') ?> … … 462 472 463 473 <div id="submitdiv" class="stuffbox"> 474 <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>"> 475 <br/> 476 </div> 464 477 <h3><?php _e('Publish') ?></h3> 465 478 <div class="inside"> … … 477 490 478 491 <div id="categorydiv" class="stuffbox"> 492 <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>"> 493 <br/> 494 </div> 479 495 <h3><?php _e('Categories') ?></h3> 480 496 <div class="inside"> 481 497 482 498 <div id="categories-all" class="tabs-panel"> 499 483 500 <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> 484 501 <?php wp_category_checklist($post_ID, false) ?> … … 500 517 501 518 <div id="tagsdiv-post_tag" class="stuffbox" > 519 <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>"> 520 <br/> 521 </div> 502 522 <h3><span><?php _e('Post Tags'); ?></span></h3> 503 523 <div class="inside"> … … 519 539 </div> 520 540 </div> 521 522 541 <div class="posting"> 523 542 <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?> … … 531 550 </div> 532 551 533 <div id="extra _fields" style="display: none"></div>552 <div id="extra-fields" style="display: none"></div> 534 553 535 554 <div class="postdivrich"> 536 <ul id="actions" >555 <ul id="actions" class="actions"> 537 556 538 557 <li id="photo_button">
Note: See TracChangeset
for help on using the changeset viewer.