Ticket #5684: tags-patch.diff
File tags-patch.diff, 16.8 KB (added by , 17 years ago) |
---|
-
E:/EclipseWorkWeb/WordPressDev/wp-includes/category.php
Property changes on: E:\EclipseWorkWeb\WordPressDev ___________________________________________________________________ Name: svn:ignore + .project
149 149 return get_term($tag, 'post_tag', $output, $filter); 150 150 } 151 151 152 // Retrieves tag data given a tag ID or tag object. 153 // Converts to appropriate form for use in tag management pages 154 function &get_tag_for_page($tag, $output = OBJECT, $filter = 'raw') { 155 $tag = get_term($tag, 'post_tag', $output, $filter); 156 if ( is_wp_error( $tag ) ) 157 return $tag; 158 159 _make_tag_compat($tag); 160 161 return $tag; 162 } 163 152 164 // 153 165 // Cache 154 166 // … … 183 195 } 184 196 } 185 197 198 function _make_tag_compat( &$tag) { 199 if ( is_object($tag) ) { 200 $tag->tag_ID = &$tag->term_id; 201 $tag->tag_count = &$tag->count; 202 $tag->tag_name = &$tag->name; 203 $tag->tag_slug = &$tag->slug; 204 } else if ( is_array($tag) && isset($tag['term_id']) ) { 205 $tag['tag_ID'] = &$tag['term_id']; 206 $tag['tag_count'] = &$tag['count']; 207 $tag['tag_name'] = &$tag['name']; 208 $tag['tag_slug'] = &$tag['slug']; 209 } 210 } 186 211 ?> -
E:/EclipseWorkWeb/WordPressDev/wp-includes/taxonomy.php
525 525 'hide_empty' => true, 'exclude' => '', 'include' => '', 526 526 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 527 527 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 528 'pad_counts' => false );528 'pad_counts' => false, 'start' => ''); 529 529 $args = wp_parse_args( $args, $defaults ); 530 530 $args['number'] = absint( $args['number'] ); 531 $args['start'] = absint( $args['start'] ); 531 532 if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) || 532 533 '' != $args['parent'] ) { 533 534 $args['child_of'] = 0; … … 625 626 if ( $hide_empty && !$hierarchical ) 626 627 $where .= ' AND tt.count > 0'; 627 628 628 if ( !empty($number) ) 629 $number = 'LIMIT ' . $number; 630 else 629 if ( !empty($number) ) { 630 if( $start ) 631 $number = 'LIMIT ' . $start . ',' . $number; 632 else 633 $number = 'LIMIT ' . $number; 634 635 } else 631 636 $number = ''; 632 637 633 638 if ( 'all' == $fields ) -
E:/EclipseWorkWeb/WordPressDev/wp-includes/script-loader.php
94 94 'how' => __('Separate multiple categories with commas.') 95 95 ) ); 96 96 $this->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20071031' ); 97 $this->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20071031' ); 97 98 $this->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' ); 98 99 $this->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20070405' ); 99 100 $this->localize( 'password-strength-meter', 'pwsL10n', array( -
E:/EclipseWorkWeb/WordPressDev/wp-admin/tags.php
1 <?php 2 require_once('admin.php'); 3 4 $title = __('Tags'); 5 $parent_file = 'edit.php'; 6 7 wp_reset_vars(array('action', 'tag')); 8 9 switch($action) { 10 11 case 'addtag': 12 13 check_admin_referer('add-tag'); 14 15 if ( !current_user_can('manage_categories') ) 16 wp_die(__('Cheatin’ uh?')); 17 18 $ret = wp_insert_tag($_POST ); 19 if( $ret && !is_wp_error( $ret ) ) { 20 wp_redirect('tags.php?message=1#addtag'); 21 } else { 22 wp_redirect('tags.php?message=4#addtag'); 23 } 24 exit; 25 break; 26 27 case 'delete': 28 $tag_ID = (int) $_GET['tag_ID']; 29 check_admin_referer('delete-tag_' . $tag_ID); 30 31 if ( !current_user_can('manage_categories') ) 32 wp_die(__('Cheatin’ uh?')); 33 34 wp_delete_term( $tag_ID, 'post_tag'); 35 36 wp_redirect('tags.php?message=2'); 37 exit; 38 39 break; 40 41 case 'edit': 42 43 require_once ('admin-header.php'); 44 $tag_ID = (int) $_GET['tag_ID']; 45 46 $tag = get_tag_for_page($tag_ID, OBJECT, 'edit'); 47 include('edit-tag-form.php'); 48 49 break; 50 51 case 'editedtag': 52 $tag_ID = (int) $_POST['tag_ID']; 53 check_admin_referer('update-tag_' . $tag_ID); 54 55 if ( !current_user_can('manage_categories') ) 56 wp_die(__('Cheatin’ uh?')); 57 58 $ret = wp_insert_tag($_POST ); 59 if( $ret && !is_wp_error( $ret ) ) { 60 wp_redirect('tags.php?message=3'); 61 } else { 62 wp_redirect('tags.php?message=5'); 63 } 64 exit; 65 break; 66 67 default: 68 69 wp_enqueue_script( 'admin-tags' ); 70 require_once ('admin-header.php'); 71 72 $messages[1] = __('Tag added.'); 73 $messages[2] = __('Tag deleted.'); 74 $messages[3] = __('Tag updated.'); 75 $messages[4] = __('Tag not added.'); 76 $messages[5] = __('Tag not updated.'); 77 ?> 78 79 <?php if (isset($_GET['message'])) : ?> 80 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div> 81 <?php endif; ?> 82 83 <div class="wrap"> 84 <?php if ( current_user_can('manage_categories') ) : ?> 85 <h2><?php printf(__('Tags (<a href="%s">add new</a>)'), '#addtag') ?> </h2> 86 <?php else : ?> 87 <h2><?php _e('Tags') ?> </h2> 88 <?php endif; ?> 89 <table class="widefat"> 90 <thead> 91 <tr> 92 <th scope="col" style="text-align: center"><?php _e('ID') ?></th> 93 <th scope="col"><?php _e('Name') ?></th> 94 <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th> 95 <th colspan="2" style="text-align: center"><?php _e('Action') ?></th> 96 </tr> 97 </thead> 98 <tbody id="the-list" class="list:tag"> 99 <?php 100 $pagenum = absint( $_GET['pagenum'] ); 101 $perpage = 10; 102 $count = tag_rows( $pagenum, $perpage ); 103 ?> 104 </tbody> 105 </table> 106 <?php 107 108 $baseurl = get_bloginfo( 'home') . '/wp-admin/tags.php?pagenum='; 109 if( $pagenum >= 1 ) { 110 echo '<a href="' . $baseurl . ($pagenum - 1 ) . '"><<' . __('Previous Tags') . '</a>'; 111 if( $count == $perpage ) { 112 echo ' | '; 113 } 114 } 115 116 117 if( $count == $perpage ) { 118 echo '<a href="' . $baseurl . ($pagenum + 1 ) . '">' . __('Next Tags') . '>></a>'; 119 } 120 121 ?> 122 123 </div> 124 125 <?php if ( current_user_can('manage_categories') ) : ?> 126 127 <br /> 128 <?php include('edit-tag-form.php'); ?> 129 130 <?php endif; ?> 131 132 <?php 133 break; 134 } 135 136 include('admin-footer.php'); 137 138 ?> -
E:/EclipseWorkWeb/WordPressDev/wp-admin/admin-ajax.php
62 62 die('1'); 63 63 else die('0'); 64 64 break; 65 case 'delete-tag' : 66 check_ajax_referer( "delete-tag_$id" ); 67 if ( !current_user_can( 'manage_categories' ) ) 68 die('-1'); 69 70 if ( wp_delete_term($id, 'post_tag')) 71 die('1'); 72 else die('0'); 73 break; 65 74 case 'delete-link-cat' : 66 75 check_ajax_referer( "delete-link-category_$id" ); 67 76 if ( !current_user_can( 'manage_categories' ) ) … … 302 311 ) ); 303 312 $x->send(); 304 313 break; 314 case 'add-tag' : // From Manage->Tags 315 check_ajax_referer( 'add-tag' ); 316 if ( !current_user_can( 'manage_categories' ) ) 317 die('-1'); 318 319 if ( '' === trim($_POST['tag_name']) ) { 320 $x = new WP_Ajax_Response( array( 321 'what' => 'tag', 322 'id' => new WP_Error( 'tag_name', __('You did not enter a tag name.') ) 323 ) ); 324 $x->send(); 325 } 326 327 $tag = wp_insert_tag( $_POST, true ); 328 329 if ( is_wp_error($tag) ) { 330 $x = new WP_Ajax_Response( array( 331 'what' => 'tag', 332 'id' => $tag 333 ) ); 334 $x->send(); 335 } 336 337 if ( !$tag || (!$tag = get_tag_for_page( $tag )) ) 338 die('0'); 339 340 $tag_full_name = $tag->name; 341 $_tag = $tag; 342 $tag_full_name = attribute_escape($tag_full_name); 343 344 $x = new WP_Ajax_Response( array( 345 'what' => 'tag', 346 'id' => $tag->term_id, 347 'data' => _tag_row( $tag ), 348 'supplemental' => array('name' => $tag_full_name, 'show-link' => sprintf(__( 'Tag <a href="#%s">%s</a> added' ), "tag-$tag->term_id", $tag_full_name)) 349 ) ); 350 $x->send(); 351 break; 305 352 case 'add-comment' : 306 353 check_ajax_referer( $action ); 307 354 if ( !current_user_can( 'edit_post', $id ) ) -
E:/EclipseWorkWeb/WordPressDev/wp-admin/includes/template.php
232 232 } 233 233 } 234 234 235 // Tag stuff 236 237 // Returns a single tag row (see tag_rows below) 238 // Note: this is also used in admin-ajax.php! 239 function _tag_row( $tag, $class = '' ) { 240 $count = number_format_i18n( $tag->count ); 241 $count = ( $count > 0 ) ? "<a href='edit.php?tag_id=$tag->term_id'>$count</a>" : $count; 242 243 $out = ''; 244 $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>'; 245 $out .= '<th scope="row">' . $tag->term_id . '</th>'; 246 247 $out .= '<td>' . apply_filters( 'term_name', $tag->name ) . '</td>'; 248 249 $out .= "<td>$count</td>"; 250 $out .= '<td><a href="tags.php?action=edit&tag_ID=' . $tag->term_id . '" class="edit">' . 251 __( 'Edit' ) . "</a></td>" . 252 '<td><a href="' . wp_nonce_url( "tags.php?action=delete&tag_ID=$tag->term_id", 253 'delete-tag_' . $tag->term_id ) . 254 '" class="delete:the-list:tag-' . $tag->term_id . ' delete">' . 255 __( 'Delete' ) . "</a></td>"; 256 $out .= '</tr>'; 257 258 return $out; 259 } 260 261 // Outputs appropriate rows for the Nth page of the Tag Management screen, 262 // assuming M tags displayed at a time on the page 263 // Returns the number of tags displayed 264 function tag_rows( $page = 0, $pagesize = 20 ) { 265 266 // Get a page worth of tags 267 $start = $page * $pagesize; 268 $tags = get_terms( 'post_tag', "start=$start&number=$pagesize&hide_empty=0" ); 269 270 // convert it to table rows 271 $out = ''; 272 $class = ''; 273 $i = 0; 274 $count = 0; 275 foreach( $tags as $tag ) { 276 if( $i ) { 277 $i = 0; 278 $class = ' class="alternate"'; 279 } else { 280 $i = 1; 281 $class = ''; 282 } 283 284 $out .= _tag_row( $tag, $class ); 285 $count++; 286 } 287 288 // filter and send to screen 289 $out = apply_filters('tag_rows', $out); 290 echo $out; 291 return $count; 292 } 293 235 294 // define the columns to display, the syntax is 'internal name' => 'display name' 236 295 function wp_manage_posts_columns() { 237 296 $posts_columns = array(); -
E:/EclipseWorkWeb/WordPressDev/wp-admin/includes/taxonomy.php
141 141 return wp_insert_term($tag_name, 'post_tag'); 142 142 } 143 143 144 // Inserts or updates a tag 145 // $args is an array with elements: 146 // 'tag_name' - name of the tag - required 147 // 'tag_slug' - slug for the tag - not required 148 // 'tag_ID' - ID number (if updating an existing tag; omit or set to 0 if not) 149 // Return value: WP error object or 0 if it fails, ID if successful 150 function wp_insert_tag( $args, $wp_error = false ) { 151 extract($args, EXTR_SKIP); 152 153 if ( trim( $tag_name ) == '' ) 154 return 0; 155 156 $tag_ID = (int) $tag_ID; 157 158 // Are we updating or creating? 159 if ( !empty ($tag_ID) ) 160 $update = true; 161 else 162 $update = false; 163 164 $name = $tag_name; 165 $slug = $tag_slug; 166 167 $args = compact('name', 'slug'); 168 169 if ( $update ) 170 $tag_ID = wp_update_term($tag_ID, 'post_tag', $args); 171 else 172 $tag_ID = wp_insert_term($name, 'post_tag', $args); 173 174 if ( is_wp_error($tag_ID) ) { 175 if ( $wp_error ) 176 return $tag_ID; 177 else 178 return 0; 179 } 180 181 return $tag_ID['term_id']; 182 } 183 144 184 ?> -
E:/EclipseWorkWeb/WordPressDev/wp-admin/js/tags.js
1 jQuery(function($) { 2 var options = false 3 4 var addAfter = function( r, settings ) { 5 var name = $("<span>" + $('name', r).text() + "</span>").html(); 6 var id = $('tag', r).attr('id'); 7 options[options.length] = new Option(name, id); 8 } 9 10 var delAfter = function( r, settings ) { 11 var id = $('tag', r).attr('id'); 12 for ( var o = 0; o < options.length; o++ ) 13 if ( id == options[o].value ) 14 options[o] = null; 15 } 16 17 if ( options ) 18 $('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } ); 19 else 20 $('#the-list').wpList(); 21 }); -
E:/EclipseWorkWeb/WordPressDev/wp-admin/edit-tag-form.php
1 <?php 2 if ( ! empty($tag_ID) ) { 3 $heading = __('Edit Tag'); 4 $submit_text = __('Edit Tag »'); 5 $form = '<form name="edittag" id="edittag" method="post" action="tags.php">'; 6 $action = 'editedtag'; 7 $nonce_action = 'update-tag_' . $tag_ID; 8 do_action('edit_tag_form_pre', $tag); 9 } else { 10 $heading = __('Add Tag'); 11 $submit_text = __('Add Tag »'); 12 $form = '<form name="addtag" id="addtag" method="post" action="tags.php" class="add:the-list:">'; 13 $action = 'addtag'; 14 $nonce_action = 'add-tag'; 15 do_action('add_tag_form_pre', $tag); 16 } 17 ?> 18 19 <div class="wrap"> 20 <h2><?php echo $heading ?></h2> 21 <div id="ajax-response"></div> 22 <?php echo $form ?> 23 <input type="hidden" name="action" value="<?php echo $action ?>" /> 24 <input type="hidden" name="tag_ID" value="<?php echo $tag->term_id ?>" /> 25 <?php wp_nonce_field($nonce_action); ?> 26 <table class="editform" width="100%" cellspacing="2" cellpadding="5"> 27 <tr class="form-field form-required"> 28 <th width="33%" scope="row" valign="top"><label for="tag_name"><?php _e('Tag name:') ?></label></th> 29 <td width="67%"><input name="tag_name" id="tag_name" type="text" value="<?php echo attribute_escape($tag->name); ?>" size="40" /></td> 30 </tr> 31 <tr class="form-field"> 32 <th scope="row" valign="top"><label for="tag_slug"><?php _e('Tag slug:') ?></label></th> 33 <td><input name="tag_slug" id="tag_slug" type="text" value="<?php echo attribute_escape($tag->slug); ?>" size="40" /></td> 34 </tr> 35 </table> 36 <p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p> 37 <?php do_action('edit_tag_form', $tag); ?> 38 </form> 39 </div> -
E:/EclipseWorkWeb/WordPressDev/wp-admin/menu.php
42 42 $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php'); 43 43 $submenu['edit.php'][15] = array(__('Links'), 'manage_links', 'link-manager.php'); 44 44 $submenu['edit.php'][20] = array(__('Categories'), 'manage_categories', 'categories.php'); 45 $submenu['edit.php'][21] = array(__('Tags'), 'manage_categories', 'tags.php'); 45 46 $submenu['edit.php'][25] = array(__('Media Library'), 'upload_files', 'upload.php'); 46 47 $submenu['edit.php'][30] = array(__('Import'), 'import', 'import.php'); 47 48 $submenu['edit.php'][35] = array(__('Export'), 'import', 'export.php'); -
E:/EclipseWorkWeb/WordPressDev/wp-admin/edit.php
48 48 } 49 49 $h2_search = isset($_GET['s']) && $_GET['s'] ? ' ' . sprintf(__('matching “%s”'), wp_specialchars( get_search_query() ) ) : ''; 50 50 $h2_cat = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in “%s”'), single_cat_title('', false) ) : ''; 51 $h2_tag = isset($_GET['tag_id']) && $_GET['tag_id'] ? ' ' . sprintf( __('tagged with “%s”'), single_tag_title('', false) ) : ''; 51 52 $h2_month = isset($_GET['m']) && $_GET['m'] ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : ''; 52 printf( _c( '%1$s%2$s%3$s%4$s%5$s |You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_month );53 printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month ); 53 54 } 54 55 ?></h2> 55 56