<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[21501] trunk: Hide the link manager from the UI on upgrade, if the site has no links.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/21501">21501</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-08-13 16:18:42 +0000 (Mon, 13 Aug 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>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 <a href="http://core.trac.wordpress.org/ticket/21307">#21307</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesbookmarkphp">trunk/wp-admin/includes/bookmark.php</a></li>
<li><a href="#trunkwpadminincludesschemaphp">trunk/wp-admin/includes/schema.php</a></li>
<li><a href="#trunkwpadminincludesupgradephp">trunk/wp-admin/includes/upgrade.php</a></li>
<li><a href="#trunkwpadminnetworkusersphp">trunk/wp-admin/network/users.php</a></li>
<li><a href="#trunkwpadminoptionswritingphp">trunk/wp-admin/options-writing.php</a></li>
<li><a href="#trunkwpadminusersphp">trunk/wp-admin/users.php</a></li>
<li><a href="#trunkwpincludescapabilitiesphp">trunk/wp-includes/capabilities.php</a></li>
<li><a href="#trunkwpincludesdefaultwidgetsphp">trunk/wp-includes/default-widgets.php</a></li>
<li><a href="#trunkwpincludestaxonomyphp">trunk/wp-includes/taxonomy.php</a></li>
<li><a href="#trunkwpincludesversionphp">trunk/wp-includes/version.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesschemaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/schema.php (21500 => 21501)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/schema.php        2012-08-13 15:55:15 UTC (rev 21500)
+++ trunk/wp-admin/includes/schema.php        2012-08-13 16:18:42 UTC (rev 21501)
</span><span class="lines">@@ -481,6 +481,9 @@
</span><span class="cx">
</span><span class="cx">         // 3.1
</span><span class="cx">         'default_post_format' => 0,
</span><ins>+
+        // 3.5
+        'link_manager_enabled' => 0,
</ins><span class="cx">         );
</span><span class="cx">
</span><span class="cx">         // 3.3
</span></span></pre></div>
<a id="trunkwpadminincludesupgradephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/upgrade.php (21500 => 21501)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/upgrade.php        2012-08-13 15:55:15 UTC (rev 21500)
+++ trunk/wp-admin/includes/upgrade.php        2012-08-13 16:18:42 UTC (rev 21501)
</span><span class="lines">@@ -399,6 +399,9 @@
</span><span class="cx">         if ( $wp_current_db_version < 20080 )
</span><span class="cx">                 upgrade_340();
</span><span class="cx">
</span><ins>+        if ( $wp_current_db_version < 21501 )
+                upgrade_350();
+
</ins><span class="cx">         maybe_disable_automattic_widgets();
</span><span class="cx">
</span><span class="cx">         update_option( 'db_version', $wp_db_version );
</span><span class="lines">@@ -1182,6 +1185,18 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * 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()
+}
+
+/**
</ins><span class="cx"> * Execute network level changes
</span><span class="cx"> *
</span><span class="cx"> * @since 3.0.0
</span></span></pre></div>
<a id="trunkwpadminnetworkusersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network/users.php (21500 => 21501)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network/users.php        2012-08-13 15:55:15 UTC (rev 21500)
+++ trunk/wp-admin/network/users.php        2012-08-13 16:18:42 UTC (rev 21501)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx">         screen_icon();
</span><span class="cx">         ?>
</span><span class="cx">         <h2><?php esc_html_e( 'Users' ); ?></h2>
</span><del>-        <p><?php _e( 'Transfer or delete posts and links before deleting users.' ); ?></p>
</del><ins>+        <p><?php _e( 'Transfer or delete posts before deleting users.' ); ?></p>
</ins><span class="cx">         <form action="users.php?action=dodelete" method="post">
</span><span class="cx">         <input type="hidden" name="dodelete" />
</span><span class="cx">         <?php
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx">
</span><span class="cx">                         if ( !empty( $blogs ) ) {
</span><span class="cx">                                 ?>
</span><del>-                                <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>
</del><ins>+                                <br /><fieldset><p><legend><?php printf( __( "What should be done with posts owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p>
</ins><span class="cx">                                 <?php
</span><span class="cx">                                 foreach ( (array) $blogs as $key => $details ) {
</span><span class="cx">                                         $blog_users = get_users( array( 'blog_id' => $details->userblog_id ) );
</span><span class="lines">@@ -67,9 +67,9 @@
</span><span class="cx">                                                 <ul style="list-style:none;">
</span><span class="cx">                                                         <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li>
</span><span class="cx">                                                         <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" />
</span><del>-                                                        <?php _e( 'Delete all posts and links.' ); ?></label></li>
</del><ins>+                                                        <?php _e( 'Delete all posts.' ); ?></label></li>
</ins><span class="cx">                                                         <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" />
</span><del>-                                                        <?php echo __( 'Attribute all posts and links to:' ) . '</label>' . $user_dropdown; ?></li>
</del><ins>+                                                        <?php echo __( 'Attribute all posts to:' ) . '</label>' . $user_dropdown; ?></li>
</ins><span class="cx">                                                 </ul>
</span><span class="cx">                                                 <?php
</span><span class="cx">                                         }
</span></span></pre></div>
<a id="trunkwpadminoptionswritingphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/options-writing.php (21500 => 21501)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/options-writing.php        2012-08-13 15:55:15 UTC (rev 21500)
+++ trunk/wp-admin/options-writing.php        2012-08-13 16:18:42 UTC (rev 21501)
</span><span class="lines">@@ -107,7 +107,10 @@
</span><span class="cx">         </select>
</span><span class="cx"> </td>
</span><span class="cx"> </tr>
</span><del>-<?php endif; endif; ?>
</del><ins>+<?php endif; endif;
+
+if ( get_option( 'link_manager_enabled' ) ) :
+?>
</ins><span class="cx"> <tr valign="top">
</span><span class="cx"> <th scope="row"><label for="default_link_category"><?php _e('Default Link Category') ?></label></th>
</span><span class="cx"> <td>
</span><span class="lines">@@ -116,6 +119,8 @@
</span><span class="cx"> ?>
</span><span class="cx"> </td>
</span><span class="cx"> </tr>
</span><ins>+<?php endif; ?>
+
</ins><span class="cx"> <?php do_settings_fields('writing', 'default'); ?>
</span><span class="cx"> </table>
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminusersphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/users.php (21500 => 21501)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/users.php        2012-08-13 15:55:15 UTC (rev 21500)
+++ trunk/wp-admin/users.php        2012-08-13 16:18:42 UTC (rev 21501)
</span><span class="lines">@@ -212,12 +212,12 @@
</span><span class="cx">         ?>
</span><span class="cx">         </ul>
</span><span class="cx"> <?php if ( $go_delete ) : ?>
</span><del>-        <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>
</del><ins>+        <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>
</ins><span class="cx">         <ul style="list-style:none;">
</span><span class="cx">                 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
</span><del>-                <?php _e('Delete all posts and links.'); ?></label></li>
</del><ins>+                <?php _e('Delete all posts.'); ?></label></li>
</ins><span class="cx">                 <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
</span><del>-                <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:').'</label>';
</del><ins>+                <?php echo '<label for="delete_option1">'.__('Attribute all posts to:').'</label>';
</ins><span class="cx">                 wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
</span><span class="cx">         </ul></fieldset>
</span><span class="cx">         <input type="hidden" name="action" value="dodelete" />
</span></span></pre></div>
<a id="trunkwpincludescapabilitiesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/capabilities.php (21500 => 21501)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/capabilities.php        2012-08-13 15:55:15 UTC (rev 21500)
+++ trunk/wp-includes/capabilities.php        2012-08-13 16:18:42 UTC (rev 21501)
</span><span class="lines">@@ -1226,6 +1226,12 @@
</span><span class="cx">                 else
</span><span class="cx">                         $caps[] = 'do_not_allow';
</span><span class="cx">                 break;
</span><ins>+        case 'manage_links' :
+                if ( get_option( 'link_manager_enabled' ) )
+                        $caps[] = $cap;
+                else
+                        $caps[] = 'do_not_allow';
+                break;
</ins><span class="cx">         default:
</span><span class="cx">                 // Handle meta capabilities for custom post types.
</span><span class="cx">                 $post_type_meta_caps = _post_type_meta_capabilities();
</span></span></pre></div>
<a id="trunkwpincludesdefaultwidgetsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-widgets.php (21500 => 21501)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-widgets.php        2012-08-13 15:55:15 UTC (rev 21500)
+++ trunk/wp-includes/default-widgets.php        2012-08-13 16:18:42 UTC (rev 21501)
</span><span class="lines">@@ -1158,7 +1158,8 @@
</span><span class="cx">
</span><span class="cx">         register_widget('WP_Widget_Archives');
</span><span class="cx">
</span><del>-        register_widget('WP_Widget_Links');
</del><ins>+        if ( get_option( 'link_manager_enabled' ) )
+                register_widget('WP_Widget_Links');
</ins><span class="cx">
</span><span class="cx">         register_widget('WP_Widget_Meta');
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludestaxonomyphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/taxonomy.php (21500 => 21501)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/taxonomy.php        2012-08-13 15:55:15 UTC (rev 21500)
+++ trunk/wp-includes/taxonomy.php        2012-08-13 16:18:42 UTC (rev 21501)
</span><span class="lines">@@ -89,6 +89,12 @@
</span><span class="cx">                         'add_or_remove_items' => null,
</span><span class="cx">                         'choose_from_most_used' => null,
</span><span class="cx">                 ),
</span><ins>+                'capabilities' => array(
+                        'manage_terms' => 'manage_links',
+                        'edit_terms' => 'manage_links',
+                        'delete_terms' => 'manage_links',
+                        'assign_terms' => 'manage_links',
+                ),
</ins><span class="cx">                 'query_var' => false,
</span><span class="cx">                 'rewrite' => false,
</span><span class="cx">                 'public' => false,
</span></span></pre></div>
<a id="trunkwpincludesversionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/version.php (21500 => 21501)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/version.php        2012-08-13 15:55:15 UTC (rev 21500)
+++ trunk/wp-includes/version.php        2012-08-13 16:18:42 UTC (rev 21501)
</span><span class="lines">@@ -11,7 +11,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @global int $wp_db_version
</span><span class="cx"> */
</span><del>-$wp_db_version = 20596;
</del><ins>+$wp_db_version = 21501;
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Holds the TinyMCE version
</span></span></pre>
</div>
</div>
</body>
</html>