Make WordPress Core

Ticket #26268: default-taxonomy.diff

File default-taxonomy.diff, 3.9 KB (added by paulwilde, 11 years ago)
  • wp-admin/edit-tags.php

    diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php
    index 56fa11a..0ec25a3 100644
    a b case 'add-tag': 
    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 )
  • wp-admin/includes/class-wp-terms-list-table.php

    diff --git a/wp-admin/includes/class-wp-terms-list-table.php b/wp-admin/includes/class-wp-terms-list-table.php
    index f44b626..2f9bd63 100644
    a b class WP_Terms_List_Table extends WP_List_Table { 
    245245
    246246                $default_term = get_option( 'default_' . $taxonomy );
    247247
     248                $default_term_label = '';
     249                if ( $tag->term_id == $default_term ) {
     250                        $default_term_label = ' - <span class="taxonomy-label"> ' . __( 'Default' ) . '</span>';
     251                }
     252                $default_link_args = array(
     253                        'action' => 'default',
     254                        'taxonomy' => $taxonomy,
     255                        'tag_ID' => $tag->term_id,
     256                );
     257                $default_link = esc_url( add_query_arg( $default_link_args, admin_url( 'edit-tags.php' ) ) );
     258               
    248259                $pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
    249260                $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
    250261                $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
    251262                $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
    252263
    253                 $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
     264                $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 />';
    254265
    255266                $actions = array();
    256267                if ( current_user_can( $tax->cap->edit_terms ) ) {
    257268                        $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
    258269                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    259270                }
     271                if ( current_user_can( 'manage_options' ) && $tag->term_id != $default_term && 'category' == $this->screen->taxonomy ) {
     272                        $actions['default'] = '<a href="' . $default_link . '">' . __( 'Set as Default' ) . '</a>';
     273                }
    260274                if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
    261275                        $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>";
    262276                if ( $tax->public )
  • wp-admin/options-writing.php

    diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php
    index 7810b29..89e494e 100644
    a b include( ABSPATH . 'wp-admin/admin-header.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>
    83 <?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>
    8880<?php
    8981$post_formats = get_post_format_strings();
    9082unset( $post_formats['standard'] );