WordPress.org

Make WordPress Core

Changeset 21501


Ignore:
Timestamp:
08/13/2012 04:18:42 PM (6 years ago)
Author:
nacin
Message:

Hide the link manager from the UI on upgrade, if the site has no links. New DB option, link_manager_enabled.

Enforce this by denying the 'manage_links' capability, which hides the All Links, Add New Link, and Link Categories screens. Hide WP_Widget_Links and the UI for the default_link_category as well.

Convert all references to 'posts and links' when handling reassignment on user deletion to just 'posts'.

see #21307.

Location:
trunk
Files:
9 edited

Legend:

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

    r21471 r21501  
    482482    // 3.1
    483483    'default_post_format' => 0,
     484
     485    // 3.5
     486    'link_manager_enabled' => 0,
    484487    );
    485488
  • trunk/wp-admin/includes/upgrade.php

    r21500 r21501  
    400400        upgrade_340();
    401401
     402    if ( $wp_current_db_version < 21501 )
     403        upgrade_350();
     404
    402405    maybe_disable_automattic_widgets();
    403406
     
    11801183        }
    11811184    }
     1185}
     1186
     1187/**
     1188 * Execute changes made in WordPress 3.5.
     1189 *
     1190 * @since 3.5.0
     1191 */
     1192function upgrade_350() {
     1193    global $wp_current_db_version, $wpdb;
     1194
     1195    if ( $wp_current_db_version < 21501 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
     1196        update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
    11821197}
    11831198
  • trunk/wp-admin/network/users.php

    r21413 r21501  
    2525    ?>
    2626    <h2><?php esc_html_e( 'Users' ); ?></h2>
    27     <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
     27    <p><?php _e( 'Transfer or delete posts before deleting users.' ); ?></p>
    2828    <form action="users.php?action=dodelete" method="post">
    2929    <input type="hidden" name="dodelete" />
     
    4848            if ( !empty( $blogs ) ) {
    4949                ?>
    50                 <br /><fieldset><p><legend><?php printf( __( "What should be done with posts and links owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
     50                <br /><fieldset><p><legend><?php printf( __( "What should be done with posts owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
    5151                <?php
    5252                foreach ( (array) $blogs as $key => $details ) {
     
    6868                            <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
    6969                            <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
    70                             <?php _e( 'Delete all posts and links.' ); ?></label></li>
     70                            <?php _e( 'Delete all posts.' ); ?></label></li>
    7171                            <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
    72                             <?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li>
     72                            <?php echo __( 'Attribute all posts to:' ) . '</label>' . $user_dropdown; ?></li>
    7373                        </ul>
    7474                        <?php
  • trunk/wp-admin/options-writing.php

    r19818 r21501  
    108108</td>
    109109</tr>
    110 <?php endif; endif; ?>
     110<?php endif; endif;
     111
     112if ( get_option( 'link_manager_enabled' ) ) :
     113?>
    111114<tr valign="top">
    112115<th scope="row"><label for="default_link_category"><?php _e('Default Link Category') ?></label></th>
     
    117120</td>
    118121</tr>
     122<?php endif; ?>
     123
    119124<?php do_settings_fields('writing', 'default'); ?>
    120125</table>
  • trunk/wp-admin/users.php

    r21413 r21501  
    213213    </ul>
    214214<?php if ( $go_delete ) : ?>
    215     <fieldset><p><legend><?php echo _n( 'What should be done with posts and links owned by this user?', 'What should be done with posts and links owned by these users?', $go_delete ); ?></legend></p>
     215    <fieldset><p><legend><?php echo _n( 'What should be done with posts owned by this user?', 'What should be done with posts owned by these users?', $go_delete ); ?></legend></p>
    216216    <ul style="list-style:none;">
    217217        <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
    218         <?php _e('Delete all posts and links.'); ?></label></li>
     218        <?php _e('Delete all posts.'); ?></label></li>
    219219        <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
    220         <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:').'</label>';
     220        <?php echo '<label for="delete_option1">'.__('Attribute all posts to:').'</label>';
    221221        wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
    222222    </ul></fieldset>
  • trunk/wp-includes/capabilities.php

    r21496 r21501  
    12271227            $caps[] = 'do_not_allow';
    12281228        break;
     1229    case 'manage_links' :
     1230        if ( get_option( 'link_manager_enabled' ) )
     1231            $caps[] = $cap;
     1232        else
     1233            $caps[] = 'do_not_allow';
     1234        break;
    12291235    default:
    12301236        // Handle meta capabilities for custom post types.
  • trunk/wp-includes/default-widgets.php

    r20285 r21501  
    11591159    register_widget('WP_Widget_Archives');
    11601160
    1161     register_widget('WP_Widget_Links');
     1161    if ( get_option( 'link_manager_enabled' ) )
     1162        register_widget('WP_Widget_Links');
    11621163
    11631164    register_widget('WP_Widget_Meta');
  • trunk/wp-includes/taxonomy.php

    r20972 r21501  
    8989            'add_or_remove_items' => null,
    9090            'choose_from_most_used' => null,
     91        ),
     92        'capabilities' => array(
     93            'manage_terms' => 'manage_links',
     94            'edit_terms'   => 'manage_links',
     95            'delete_terms' => 'manage_links',
     96            'assign_terms' => 'manage_links',
    9197        ),
    9298        'query_var' => false,
  • trunk/wp-includes/version.php

    r21499 r21501  
    1212 * @global int $wp_db_version
    1313 */
    14 $wp_db_version = 20596;
     14$wp_db_version = 21501;
    1515
    1616/**
Note: See TracChangeset for help on using the changeset viewer.