Make WordPress Core

Ticket #26268: 26268.diff

File 26268.diff, 3.9 KB (added by kraftbj, 11 years ago)

Refreshed version of paulwilde's patch

  • src/wp-admin/edit-tags.php

     
    6565        exit;
    6666break;
    6767
     68case 'default':
     69        if ( !current_user_can( 'manage_options' ) ) {
     70                wp_die( __( 'Cheatin’ uh?' ) );
     71        }
     72       
     73        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
     74
     75        if ( !isset( $_REQUEST['tag_ID'] ) ) {
     76                wp_redirect( $location );
     77                exit;
     78        }
     79       
     80        $tag_ID = (int) $_REQUEST['tag_ID'];
     81
     82        if ( !term_exists( $tag_ID, $taxonomy ) ) {
     83                wp_redirect( $location );
     84                exit;
     85        }
     86       
     87        update_option( 'default_' . $taxonomy,  $tag_ID );
     88
     89        wp_redirect( $location );
     90        exit;
     91
     92break;
     93
    6894case 'delete':
    6995        $location = 'edit-tags.php?taxonomy=' . $taxonomy;
    7096        if ( 'post' != $post_type )
  • src/wp-admin/includes/class-wp-terms-list-table.php

     
    268268
    269269                $default_term = get_option( 'default_' . $taxonomy );
    270270
     271                $default_term_label = '';
     272                if ( $tag->term_id == $default_term ) {
     273                        $default_term_label = ' - <span class="taxonomy-label"> ' . __( 'Default' ) . '</span>';
     274                }
     275                $default_link_args = array(
     276                        'action' => 'default',
     277                        'taxonomy' => $taxonomy,
     278                        'tag_ID' => $tag->term_id,
     279                        );
     280                $default_link = esc_url( add_query_arg( $default_link_args, admin_url( 'edit-tags.php' ) ) );
     281
    271282                $pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
    272283
    273284                /**
     
    288299                $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
    289300                $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
    290301
    291                 $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
     302                $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 />';
    292303
    293304                $actions = array();
    294305                if ( current_user_can( $tax->cap->edit_terms ) ) {
    295306                        $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    296307                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    297308                }
     309                if ( current_user_can( 'manage_options' ) && $tag->term_id != $default_term && 'category' == $this->screen->taxonomy ) {
     310                        $actions['default'] = '<a href="' . $default_link . '">' . __( 'Set as Default' ) . '</a>';
     311                }
    298312                if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
    299313                        $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>";
    300314                if ( $tax->public )
  • src/wp-admin/options-writing.php

     
    7777<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>
    7878</fieldset></td>
    7979</tr>
    80 <tr>
    81 <th scope="row"><label for="default_category"><?php _e('Default Post Category') ?></label></th>
    82 <td>
    8380<?php
    84 wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_category', 'orderby' => 'name', 'selected' => get_option('default_category'), 'hierarchical' => true));
    85 ?>
    86 </td>
    87 </tr>
    88 <?php
    8981$post_formats = get_post_format_strings();
    9082unset( $post_formats['standard'] );
    9183?>