Changeset 13008
- Timestamp:
- 02/07/2010 05:54:33 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r12968 r13008 8 8 * @subpackage Administration 9 9 */ 10 11 // Ugly recursive category stuff.12 /**13 * {@internal Missing Short Description}}14 *15 * @since unknown16 *17 * @param unknown_type $parent18 * @param unknown_type $level19 * @param unknown_type $categories20 * @param unknown_type $page21 * @param unknown_type $per_page22 */23 function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20, $taxonomy = 'category' ) {24 25 $count = 0;26 27 if ( empty($categories) ) {28 29 $args = array('hide_empty' => 0, 'taxonomy' => $taxonomy);30 if ( !empty($_GET['s']) )31 $args['search'] = $_GET['s'];32 33 $categories = get_categories( $args );34 35 if ( empty($categories) )36 return false;37 }38 39 $children = _get_term_hierarchy($taxonomy);40 41 echo _cat_rows( $parent, $level, $categories, $children, $page, $per_page, $count );42 43 }44 45 /**46 * {@internal Missing Short Description}}47 *48 * @since unknown49 *50 * @param unknown_type $categories51 * @param unknown_type $count52 * @param unknown_type $parent53 * @param unknown_type $level54 * @param unknown_type $page55 * @param unknown_type $per_page56 * @return string the output of the table.57 */58 function _cat_rows( $parent = 0, $level = 0, $categories, &$children, $page = 1, $per_page = 20, &$count ) {59 60 $start = ($page - 1) * $per_page;61 $end = $start + $per_page;62 63 $output = '';64 foreach ( $categories as $key => $category ) {65 if ( $count >= $end )66 break;67 68 if ( $category->parent != $parent && empty($_GET['s']) )69 continue;70 71 // If the page starts in a subtree, print the parents.72 if ( $count == $start && $category->parent > 0 ) {73 74 $my_parents = array();75 $p = $category->parent;76 while ( $p ) {77 $my_parent = get_category( $p );78 $my_parents[] = $my_parent;79 if ( $my_parent->parent == 0 )80 break;81 $p = $my_parent->parent;82 }83 84 $num_parents = count($my_parents);85 while( $my_parent = array_pop($my_parents) ) {86 $output = "\t" . _cat_row( $my_parent, $level - $num_parents );87 $num_parents--;88 }89 }90 91 if ( $count >= $start )92 $output .= "\t" . _cat_row( $category, $level );93 94 unset( $categories[ $key ] );95 96 $count++;97 98 if ( isset($children[$category->term_id]) )99 $output .= _cat_rows( $category->term_id, $level + 1, $categories, $children, $page, $per_page, $count );100 }101 102 return $output;103 }104 105 /**106 * {@internal Missing Short Description}}107 *108 * @since unknown109 *110 * @param unknown_type $category111 * @param unknown_type $level112 * @param unknown_type $name_override113 * @return unknown114 */115 function _cat_row( $category, $level, $name_override = false ) {116 static $row_class = '';117 118 $category = get_category( $category, OBJECT, 'display' );119 120 $default_cat_id = (int) get_option( 'default_category' );121 $pad = str_repeat( '— ', max(0, $level) );122 $name = ( $name_override ? $name_override : $pad . ' ' . $category->name );123 $edit_link = "categories.php?action=edit&cat_ID=$category->term_id";124 if ( current_user_can( 'manage_categories' ) ) {125 $edit = "<a class='row-title' href='$edit_link' title='" . esc_attr(sprintf(__('Edit “%s”'), $category->name)) . "'>" . esc_attr( $name ) . '</a><br />';126 $actions = array();127 $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';128 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';129 if ( $default_cat_id != $category->term_id )130 $actions['delete'] = "<a class='delete:the-list:cat-$category->term_id submitdelete' href='" . wp_nonce_url("categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";131 $actions = apply_filters('cat_row_actions', $actions, $category);132 $action_count = count($actions);133 $i = 0;134 $edit .= '<div class="row-actions">';135 foreach ( $actions as $action => $link ) {136 ++$i;137 ( $i == $action_count ) ? $sep = '' : $sep = ' | ';138 $edit .= "<span class='$action'>$link$sep</span>";139 }140 $edit .= '</div>';141 } else {142 $edit = $name;143 }144 145 $row_class = 'alternate' == $row_class ? '' : 'alternate';146 $qe_data = get_category_to_edit($category->term_id);147 148 $category->count = number_format_i18n( $category->count );149 $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;150 $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>";151 152 $columns = get_column_headers('categories');153 $hidden = get_hidden_columns('categories');154 foreach ( $columns as $column_name => $column_display_name ) {155 $class = "class=\"$column_name column-$column_name\"";156 157 $style = '';158 if ( in_array($column_name, $hidden) )159 $style = ' style="display:none;"';160 161 $attributes = "$class$style";162 163 switch ($column_name) {164 case 'cb':165 $output .= "<th scope='row' class='check-column'>";166 if ( $default_cat_id != $category->term_id ) {167 $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";168 } else {169 $output .= " ";170 }171 $output .= '</th>';172 break;173 case 'name':174 $output .= "<td $attributes>$edit";175 $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';176 $output .= '<div class="name">' . $qe_data->name . '</div>';177 $output .= '<div class="slug">' . apply_filters('editable_slug', $qe_data->slug) . '</div>';178 $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';179 break;180 case 'description':181 $output .= "<td $attributes>$category->description</td>";182 break;183 case 'slug':184 $output .= "<td $attributes>" . apply_filters('editable_slug', $category->slug) . "</td>";185 break;186 case 'posts':187 $attributes = 'class="posts column-posts num"' . $style;188 $output .= "<td $attributes>$posts_count</td>\n";189 break;190 default:191 $output .= "<td $attributes>";192 $output .= apply_filters('manage_categories_custom_column', '', $column_name, $category->term_id);193 $output .= "</td>";194 }195 }196 $output .= '</tr>';197 198 return $output;199 }200 10 201 11 /** … … 2709 2519 </select> 2710 2520 <input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" /> 2711 <a href="#postcustomstuff" class="hide-if-no-js" on click="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">2521 <a href="#postcustomstuff" class="hide-if-no-js" onClick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;"> 2712 2522 <span id="enternew"><?php _e('Enter new'); ?></span> 2713 2523 <span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a> … … 3386 3196 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> 3387 3197 <input type="text" id="find-posts-input" name="ps" value="" /> 3388 <input type="button" on click="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br />3198 <input type="button" onClick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> 3389 3199 3390 3200 <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" /> … … 3396 3206 </div> 3397 3207 <div class="find-box-buttons"> 3398 <input type="button" class="button alignleft" on click="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />3208 <input type="button" class="button alignleft" onClick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" /> 3399 3209 <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" /> 3400 3210 </div>
Note: See TracChangeset
for help on using the changeset viewer.