WordPress.org

Make WordPress Core

Changeset 13008


Ignore:
Timestamp:
02/07/2010 05:54:33 AM (8 years ago)
Author:
dd32
Message:

Remove cat_rows() admin template functions. See #11838

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r12968 r13008  
    88 * @subpackage Administration
    99 */
    10 
    11 // Ugly recursive category stuff.
    12 /**
    13  * {@internal Missing Short Description}}
    14  *
    15  * @since unknown
    16  *
    17  * @param unknown_type $parent
    18  * @param unknown_type $level
    19  * @param unknown_type $categories
    20  * @param unknown_type $page
    21  * @param unknown_type $per_page
    22  */
    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 unknown
    49  *
    50  * @param unknown_type $categories
    51  * @param unknown_type $count
    52  * @param unknown_type $parent
    53  * @param unknown_type $level
    54  * @param unknown_type $page
    55  * @param unknown_type $per_page
    56  * @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 unknown
    109  *
    110  * @param unknown_type $category
    111  * @param unknown_type $level
    112  * @param unknown_type $name_override
    113  * @return unknown
    114  */
    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 &#8220;%s&#8221;'), $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&nbsp;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&amp;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 .= "&nbsp;";
    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 }
    20010
    20111/**
     
    27092519</select>
    27102520<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" tabindex="7" value="" />
    2711 <a href="#postcustomstuff" class="hide-if-no-js" onclick="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;">
    27122522<span id="enternew"><?php _e('Enter new'); ?></span>
    27132523<span id="cancelnew" class="hidden"><?php _e('Cancel'); ?></span></a>
     
    33863196                <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label>
    33873197                <input type="text" id="find-posts-input" name="ps" value="" />
    3388                 <input type="button" onclick="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 />
    33893199
    33903200                <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" />
     
    33963206        </div>
    33973207        <div class="find-box-buttons">
    3398             <input type="button" class="button alignleft" onclick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
     3208            <input type="button" class="button alignleft" onClick="findPosts.close();" value="<?php esc_attr_e('Close'); ?>" />
    33993209            <input id="find-posts-submit" type="submit" class="button-primary alignright" value="<?php esc_attr_e('Select'); ?>" />
    34003210        </div>
Note: See TracChangeset for help on using the changeset viewer.