Changeset 6633
- Timestamp:
- 01/17/2008 04:51:32 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r6631 r6633 474 474 update_usermeta($current_user->ID, 'closedpostboxes', $closed); 475 475 break; 476 case 'sample-permalink': 477 check_ajax_referer( $action ); 478 $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; 479 die(get_sample_permalink_html($post_id, $_POST['new_slug'])); 480 break; 476 481 default : 477 482 do_action( 'wp_ajax_' . $_POST['action'] ); -
trunk/wp-admin/edit-form-advanced.php
r6625 r6633 71 71 <div id="titlediv"> 72 72 <h3><?php _e('Title') ?></h3> 73 <div class="inside"><input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" /></div> 73 <div class="inside"> 74 <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo attribute_escape($post->post_title); ?>" id="title" /> 75 <?php 76 $sample_permalink_html = get_sample_permalink_html($post->ID); 77 if ($post->ID && $sample_permalink_html): 78 ?> 79 <div id="edit-slug-box" style="display: <?php echo $post->ID? 'block' : 'none';?>"> 80 <strong><?php _e('Permalink:'); ?></strong> 81 <span id="sample-permalink"><?php echo $sample_permalink_html; ?></span> 82 <span id="edit-slug-buttons"><a href="#post_name" class="edit-slug" onclick="edit_permalink(<?php echo $post->ID; ?>);return false;"><?php _e('Edit');?></a></span> 83 </div> 84 <?php 85 endif; 86 ?> 87 </div> 74 88 </div> 75 89 … … 127 141 128 142 <p class="submit"> 129 <input type="submit" name="s ubmit" value="<?php _e('Save'); ?>" style="font-weight: bold;" tabindex="4" />143 <input type="submit" name="save" value="<?php _e('Save'); ?>" style="font-weight: bold;" tabindex="4" /> 130 144 <?php 131 145 if ( !in_array( $post->post_status, array('publish', 'future') ) || 0 == $post_ID ) { -
trunk/wp-admin/includes/post.php
r6604 r6633 525 525 } 526 526 527 function get_sample_permalink($id, $name = null) { 528 $post = &get_post($id); 529 $original_status = $post->post_status; 530 $original_date = $post->post_date; 531 $original_name = $post->post_name; 532 if (in_array($post->post_status, array('draft', 'pending'))) { 533 $post->post_status = 'publish'; 534 $post->post_date = date('Y-m-d H:i:s'); 535 $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID); 536 } 537 if (!is_null($name)) { 538 $post->post_name = sanitize_title($name, $post->ID); 539 } 540 $permalink = get_permalink($post, true); 541 $permalink = array($permalink, $post->post_name); 542 $post->post_status = $original_status; 543 $post->post_date = $original_date; 544 $post->post_name = $original_name; 545 return $permalink; 546 } 547 548 function get_sample_permalink_html($id, $new_slug=null) { 549 $post = &get_post($id); 550 list($permalink, $post_name) = get_sample_permalink($post->ID, $new_slug); 551 if (false === strpos($permalink, '%postname%')) { 552 return ''; 553 } 554 $title = __('You can edit this part of the permalink using the Edit button on the right'); 555 if (strlen($post_name) > 30) { 556 $post_name = substr($post_name, 0, 14). '…' . substr($post_name, -14); 557 } 558 $post_name_html = '<span id="editable-post-name" title="'.$title.'">'.$post_name.'</span>'; 559 $display_link = str_replace('%postname%', $post_name_html, $permalink); 560 return $display_link; 561 } 562 527 563 ?> -
trunk/wp-admin/js/post.js
r6602 r6633 64 64 closed: closed, 65 65 cookie: document.cookie}); 66 } 67 68 function edit_permalink(post_id) { 69 var e = jQuery('#editable-post-name'); 70 var revert_e = e.html(); 71 var real_slug = jQuery('#post_name'); 72 var b = jQuery('#edit-slug-buttons'); 73 var revert_b = b.html(); 74 var old_slug = e.children('span').html(); 75 76 b.html('<a href="" class="save">'+postL10n.save+'</a> <a class="cancel" href="">'+postL10n.cancel+'</a>'); 77 b.children('.save').click(function() { 78 var new_slug = e.children('input').attr('value'); 79 jQuery.post(postL10n.requestFile, { 80 action: 'sample-permalink', 81 post_id: post_id, 82 new_slug: new_slug, 83 cookie: document.cookie}, function(data) { 84 jQuery('#sample-permalink').html(data); 85 b.html(revert_b); 86 real_slug.attr('value', new_slug); 87 }); 88 return false; 89 }); 90 jQuery('#edit-slug-buttons .cancel').click(function() { 91 e.html(revert_e); 92 b.html(revert_b); 93 real_slug.attr('value', revert_e); 94 return false; 95 }); 96 e.html('<input type="text" id="new-post-slug" value="" />').children('input').keypress(function(e){ 97 var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0; 98 // on enter, just save the new slug, don't save the post 99 if (13 == key) {b.children('.save').click();return false;} 100 if (27 == key) {b.children('.cancel').click();return false;} 101 real_slug.attr('value', this.value)}).focus(); 66 102 } 67 103 … … 137 173 } ); 138 174 jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); 175 176 jQuery('#editable-post-name').click(function() {jQuery('#edit-slug-buttons').children('.edit-slug').click()}); 139 177 }); -
trunk/wp-admin/wp-admin.css
r6611 r6633 1179 1179 width: 98%; 1180 1180 } 1181 #edit-slug-box { 1182 margin-top: 8px; 1183 color: #999; 1184 } 1185 #edit-slug-box strong {color: #777;} 1186 #editable-post-name {background-color: #FFFBCC;} 1187 #editable-post-name input {width: 16em;} 1188 #edit-slug-buttons a.save { 1189 background-color: #ebebeb; 1190 -moz-border-raduis: 5px; 1191 padding: 6px; 1192 } 1193 #edit-slug-buttons a.cancel {font-size: 80%;} 1181 1194 1182 1195 #poststuff #editor-toolbar { … … 1332 1345 .form-input-tip { color: #999; } 1333 1346 1347 -
trunk/wp-includes/link-template.php
r6592 r6633 44 44 45 45 46 function get_permalink($id = 0 ) {46 function get_permalink($id = 0, $leavename=false) { 47 47 $rewritecode = array( 48 48 '%year%', … … 52 52 '%minute%', 53 53 '%second%', 54 '%postname%',54 $leavename? '' : '%postname%', 55 55 '%post_id%', 56 56 '%category%', 57 57 '%author%', 58 '%pagename%'58 $leavename? '' : '%pagename%', 59 59 ); 60 60 -
trunk/wp-includes/script-loader.php
r6618 r6633 115 115 'addTag' => attribute_escape(__('Add new tag')), 116 116 'separate' => __('Separate tags with commas'), 117 'save' => __('Save'), 118 'cancel' => __('Cancel'), 117 119 'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php', 118 120 ) );
Note: See TracChangeset
for help on using the changeset viewer.