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.



git-svn-id: http://core.svn.wordpress.org/trunk@21501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-08-13 16:18:42 +00:00
parent 720e09ff5b
commit 84c3a86036
9 changed files with 46 additions and 10 deletions

View File

@ -481,6 +481,9 @@ function populate_options() {
// 3.1
'default_post_format' => 0,
// 3.5
'link_manager_enabled' => 0,
);
// 3.3

View File

@ -399,6 +399,9 @@ function upgrade_all() {
if ( $wp_current_db_version < 20080 )
upgrade_340();
if ( $wp_current_db_version < 21501 )
upgrade_350();
maybe_disable_automattic_widgets();
update_option( 'db_version', $wp_db_version );
@ -1181,6 +1184,18 @@ function upgrade_340() {
}
}
/**
* Execute changes made in WordPress 3.5.
*
* @since 3.5.0
*/
function upgrade_350() {
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 21501 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
}
/**
* Execute network level changes
*

View File

@ -24,7 +24,7 @@ function confirm_delete_users( $users ) {
screen_icon();
?>
<h2><?php esc_html_e( 'Users' ); ?></h2>
<p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
<p><?php _e( 'Transfer or delete posts before deleting users.' ); ?></p>
<form action="users.php?action=dodelete" method="post">
<input type="hidden" name="dodelete" />
<?php
@ -47,7 +47,7 @@ function confirm_delete_users( $users ) {
if ( !empty( $blogs ) ) {
?>
<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>
<br /><fieldset><p><legend><?php printf( __( "What should be done with posts owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
<?php
foreach ( (array) $blogs as $key => $details ) {
$blog_users = get_users( array( 'blog_id' => $details->userblog_id ) );
@ -67,9 +67,9 @@ function confirm_delete_users( $users ) {
<ul style="list-style:none;">
<li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
<li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
<?php _e( 'Delete all posts and links.' ); ?></label></li>
<?php _e( 'Delete all posts.' ); ?></label></li>
<li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
<?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li>
<?php echo __( 'Attribute all posts to:' ) . '</label>' . $user_dropdown; ?></li>
</ul>
<?php
}

View File

@ -107,7 +107,10 @@ if ( current_theme_supports( 'post-formats' ) ) :
</select>
</td>
</tr>
<?php endif; endif; ?>
<?php endif; endif;
if ( get_option( 'link_manager_enabled' ) ) :
?>
<tr valign="top">
<th scope="row"><label for="default_link_category"><?php _e('Default Link Category') ?></label></th>
<td>
@ -116,6 +119,8 @@ wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_link_category
?>
</td>
</tr>
<?php endif; ?>
<?php do_settings_fields('writing', 'default'); ?>
</table>

View File

@ -212,12 +212,12 @@ case 'delete':
?>
</ul>
<?php if ( $go_delete ) : ?>
<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>
<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>
<ul style="list-style:none;">
<li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
<?php _e('Delete all posts and links.'); ?></label></li>
<?php _e('Delete all posts.'); ?></label></li>
<li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
<?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:').'</label>';
<?php echo '<label for="delete_option1">'.__('Attribute all posts to:').'</label>';
wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
</ul></fieldset>
<input type="hidden" name="action" value="dodelete" />

View File

@ -1226,6 +1226,12 @@ function map_meta_cap( $cap, $user_id ) {
else
$caps[] = 'do_not_allow';
break;
case 'manage_links' :
if ( get_option( 'link_manager_enabled' ) )
$caps[] = $cap;
else
$caps[] = 'do_not_allow';
break;
default:
// Handle meta capabilities for custom post types.
$post_type_meta_caps = _post_type_meta_capabilities();

View File

@ -1158,7 +1158,8 @@ function wp_widgets_init() {
register_widget('WP_Widget_Archives');
register_widget('WP_Widget_Links');
if ( get_option( 'link_manager_enabled' ) )
register_widget('WP_Widget_Links');
register_widget('WP_Widget_Meta');

View File

@ -89,6 +89,12 @@ function create_initial_taxonomies() {
'add_or_remove_items' => null,
'choose_from_most_used' => null,
),
'capabilities' => array(
'manage_terms' => 'manage_links',
'edit_terms' => 'manage_links',
'delete_terms' => 'manage_links',
'assign_terms' => 'manage_links',
),
'query_var' => false,
'rewrite' => false,
'public' => false,

View File

@ -11,7 +11,7 @@ $wp_version = '3.5-alpha-21499';
*
* @global int $wp_db_version
*/
$wp_db_version = 20596;
$wp_db_version = 21501;
/**
* Holds the TinyMCE version