Make WordPress Core

Ticket #26268: 26268.7.diff

File 26268.7.diff, 7.8 KB (added by kraftbj, 10 years ago)

Same as .6, minus the user-edit.php revision.

  • src/wp-admin/css/list-tables.css

     
    741741        padding: 2px 0 0;
    742742}
    743743
     744.row-actions a {
     745        white-space: nowrap;
     746}
     747
    744748tr:hover .row-actions,
    745749.mobile .row-actions,
    746750.row-actions.visible,
  • src/wp-admin/edit-tags.php

     
    6666
    6767        break;
    6868
     69case 'default':
     70
     71        if ( ! current_user_can( 'manage_options' ) ) {
     72                wp_die( __( 'Cheatin’ uh?' ) );
     73        }
     74
     75        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
     76        if ( ! isset( $_REQUEST['tag_ID'] ) ) {
     77                break;
     78        }
     79
     80        $tag_ID = (int) $_REQUEST['tag_ID'];
     81        check_admin_referer( 'default-tag_' . $tag_ID );
     82
     83        if ( ! term_exists( $tag_ID, $taxonomy ) ) {
     84                break;
     85        }
     86
     87        update_option( 'default_' . $taxonomy,  $tag_ID );
     88
     89        $location = add_query_arg( 'message', 7, $location );
     90       
     91        break;
     92
    6993case 'delete':
    7094        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
    7195        if ( 'post' != $post_type )
     
    256280        3 => __( 'Item updated.' ),
    257281        4 => __( 'Item not added.' ),
    258282        5 => __( 'Item not updated.' ),
    259         6 => __( 'Items deleted.' )
     283        6 => __( 'Items deleted.' ),
     284        7 => __( 'Item set as default.')
    260285);
    261286$messages['category'] = array(
    262287        0 => '', // Unused. Messages start at index 1.
     
    265290        3 => __( 'Category updated.' ),
    266291        4 => __( 'Category not added.' ),
    267292        5 => __( 'Category not updated.' ),
    268         6 => __( 'Categories deleted.' )
     293        6 => __( 'Categories deleted.' ),
     294        7 => __( 'Category set as default.')
    269295);
    270296$messages['post_tag'] = array(
    271297        0 => '', // Unused. Messages start at index 1.
     
    274300        3 => __( 'Tag updated.' ),
    275301        4 => __( 'Tag not added.' ),
    276302        5 => __( 'Tag not updated.' ),
    277         6 => __( 'Tags deleted.' )
     303        6 => __( 'Tags deleted.' ),
     304        7 => __( 'Tag set as default.')
    278305);
    279306
    280307/**
  • src/wp-admin/includes/class-wp-terms-list-table.php

     
    192192                        } else {
    193193                                $children = _get_term_hierarchy( $taxonomy );
    194194                        }
     195                        // Handle custom display of default category by showing it first in the list
     196
     197                        if ( 'category' == $taxonomy ) {
     198                                $default_category = get_term( get_option( 'default_category' ), 'category' );
     199                                $this->single_row( $default_category );
     200                        }
     201
    195202                        // Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake
    196203                        $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count );
    197204                } else {
    198205                        $terms = get_terms( $taxonomy, $args );
     206
     207                        // Handle custom display of default category by showing it first in the list
     208
     209                        $default_category_id = false;
     210                        if ( 'category' == $taxonomy ) {
     211                                $default_category = get_term( get_option( 'default_category' ), 'category' );
     212                                $this->single_row( $default_category );
     213                                $default_category_id = $default_category->term_id;
     214                        }
     215
    199216                        foreach ( $terms as $term ) {
     217                                if ( $default_category_id == $term->term_taxonomy_id ) {
     218                                        continue;
     219                                }
    200220                                $this->single_row( $term );
    201221                        }
    202222                }
     
    206226
    207227                $end = $start + $per_page;
    208228
     229                // Handle display of default category by showing it first in the list, capture default category id
     230
     231                $default_category_id = false;
     232                if ( 'category' == $taxonomy ) {
     233                        $default_category_id = get_option( 'default_category' );
     234                }
     235
    209236                foreach ( $terms as $key => $term ) {
    210237
    211238                        if ( $count >= $end )
     
    214241                        if ( $term->parent != $parent && empty( $_REQUEST['s'] ) )
    215242                                continue;
    216243
    217                         // If the page starts in a subtree, print the parents.
     244                        // Skip duplicating display of default category
     245                        if ( $default_category_id == $term->term_taxonomy_id ) {
     246                                continue;
     247                        }
     248                       
     249                                // If the page starts in a subtree, print the parents.
    218250                        if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) {
    219251                                $my_parents = $parent_ids = array();
    220252                                $p = $term->parent;
     
    280312
    281313                $default_term = get_option( 'default_' . $taxonomy );
    282314
     315                $default_term_label = '';
     316                if ( $tag->term_id == $default_term ) {
     317                        $default_term_label = ' - <span class="taxonomy-label"> ' . __( 'Default' ) . '</span>';
     318                }
     319                $default_link_args = array(
     320                        'action' => 'default',
     321                        'taxonomy' => $taxonomy,
     322                        'tag_ID' => $tag->term_id,
     323                        'paged' => $this->get_pagenum(),
     324                        );
     325                $default_link = wp_nonce_url( add_query_arg( $default_link_args, admin_url( 'edit-tags.php' ) ), 'default-tag_' . $tag->term_id );
     326
    283327                $pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
    284328
    285329                /**
     
    300344                $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
    301345                $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
    302346
    303                 $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
     347        $default_categories = array(
     348            'category',
     349            'link_category'
     350        );
     351       
     352                $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a>' . $default_term_label . '</strong><br />';
    304353
    305354                $actions = array();
    306355                if ( current_user_can( $tax->cap->edit_terms ) ) {
    307356                        $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    308                         $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
     357                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick Edit' ) . '</a>';
    309358                }
     359                if ( current_user_can( 'manage_options' ) && $tag->term_id != $default_term && ( in_array( $taxonomy, $default_categories ) ) ) {
     360                        $actions['default'] = '<a href="' . $default_link . '">' . __( 'Set as Default' ) . '</a>';
     361                }
    310362                if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
    311363                        $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
    312364                if ( $tax->public )
  • src/wp-admin/options-writing.php

     
    7171<label for="use_balanceTags"><input name="use_balanceTags" type="checkbox" id="use_balanceTags" value="1" <?php checked('1', get_option('use_balanceTags')); ?> /> <?php _e('WordPress should correct invalidly nested XHTML automatically') ?></label>
    7272</fieldset></td>
    7373</tr>
    74 <tr>
    75 <th scope="row"><label for="default_category"><?php _e('Default Post Category') ?></label></th>
    76 <td>
    7774<?php
    78 wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_category', 'orderby' => 'name', 'selected' => get_option('default_category'), 'hierarchical' => true));
    79 ?>
    80 </td>
    81 </tr>
    82 <?php
    8375$post_formats = get_post_format_strings();
    8476unset( $post_formats['standard'] );
    8577?>
     
    9486        </select>
    9587</td>
    9688</tr>
    97 <?php
    98 if ( get_option( 'link_manager_enabled' ) ) :
    99 ?>
    100 <tr>
    101 <th scope="row"><label for="default_link_category"><?php _e('Default Link Category') ?></label></th>
    102 <td>
    103 <?php
    104 wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_link_category', 'orderby' => 'name', 'selected' => get_option('default_link_category'), 'hierarchical' => true, 'taxonomy' => 'link_category'));
    105 ?>
    106 </td>
    107 </tr>
    108 <?php endif; ?>
    10989
    11090<?php
    11191do_settings_fields('writing', 'default');