<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[12911] trunk/wp-admin/ms-options.php: Fix PHP Notices: Use checked()
template function & initialise variables.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12911">12911</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-01-31 12:23:50 +0000 (Sun, 31 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix PHP Notices: Use checked() template function & initialise variables. s/WP/WordPress/ & some code formatting. See <a href="http://trac.wordpress.org/ticket/11644">#11644</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminmsoptionsphp">trunk/wp-admin/ms-options.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminmsoptionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/ms-options.php (12910 => 12911)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/ms-options.php        2010-01-31 11:55:39 UTC (rev 12910)
+++ trunk/wp-admin/ms-options.php        2010-01-31 12:23:50 UTC (rev 12911)
</span><span class="lines">@@ -51,13 +51,13 @@
</span><span class="cx">                                         update_site_option( 'registration', 'all' );
</span><span class="cx">                                 ?>
</span><span class="cx">                                 <td>
</span><del>-                                        <label><input name="registration" type="radio" id="registration1" value='none' <?php echo get_site_option('registration') == 'none' ? 'checked="checked"' : ''; ?> /> <?php _e('Disabled'); ?></label><br />
-                                        <label><input name="registration" type="radio" id="registration2" value='all' <?php echo get_site_option('registration') == 'all' ? 'checked="checked"' : ''; ?> /> <?php _e('Enabled. Blogs and user accounts can be created.'); ?></label><br />
-                                        <label><input name="registration" type="radio" id="registration3" value='user' <?php echo get_site_option('registration') == 'user' ? 'checked="checked"' : ''; ?> /> <?php _e('Only user account can be created.'); ?></label><br />
-                                        <label><input name="registration" type="radio" id="registration4" value='blog' <?php echo get_site_option('registration') == 'blog' ? 'checked="checked"' : ''; ?> /> <?php _e('Only logged in users can create new blogs.'); ?></label><br />
</del><ins>+                                        <label><input name="registration" type="radio" id="registration1" value='none' <?php checked( get_site_option('registration'), 'none') ?> /> <?php _e('Disabled'); ?></label><br />
+                                        <label><input name="registration" type="radio" id="registration2" value='all' <?php checked( get_site_option('registration'), 'all') ?> /> <?php _e('Enabled. Blogs and user accounts can be created.'); ?></label><br />
+                                        <label><input name="registration" type="radio" id="registration3" value='user' <?php checked( get_site_option('registration'), 'user') ?> /> <?php _e('Only user account can be created.'); ?></label><br />
+                                        <label><input name="registration" type="radio" id="registration4" value='blog' <?php checked( get_site_option('registration'), 'blog') ?> /> <?php _e('Only logged in users can create new blogs.'); ?></label><br />
</ins><span class="cx">                                         <p><?php _e('Disable or enable registration and who or what can be registered. (Default=all)'); ?></p>
</span><span class="cx">                                         <?php if ( is_subdomain_install() ) {
</span><del>-                                                echo "<p>" . __('If registration is disabled, please set "NOBLOGREDIRECT" in wp-config.php to a url you will redirect visitors to if they visit a non existant blog.') . "</p>";
</del><ins>+                                                echo '<p>' . __('If registration is disabled, please set "NOBLOGREDIRECT" in wp-config.php to a url you will redirect visitors to if they visit a non existant blog.') . '</p>';
</ins><span class="cx">                                         } ?>
</span><span class="cx">                                 </td>
</span><span class="cx">                         </tr>
</span><span class="lines">@@ -69,8 +69,8 @@
</span><span class="cx">                                         update_site_option( 'registrationnotification', 'yes' );
</span><span class="cx">                                 ?>
</span><span class="cx">                                 <td>
</span><del>-                                        <input name="registrationnotification" type="radio" id="registrationnotification1" value='yes' <?php echo get_site_option('registrationnotification') == 'yes' ? 'checked="checked"' : ''; ?> /> <?php _e('Yes'); ?><br />
-                                        <input name="registrationnotification" type="radio" id="registrationnotification2" value='no' <?php echo get_site_option('registrationnotification') == 'no' ? 'checked="checked"' : ''; ?> /> <?php _e('No'); ?><br />
</del><ins>+                                        <input name="registrationnotification" type="radio" id="registrationnotification1" value='yes' <?php checked( get_site_option('registrationnotification'), 'yes') ?> /> <?php _e('Yes'); ?><br />
+                                        <input name="registrationnotification" type="radio" id="registrationnotification2" value='no' <?php checked( get_site_option('registrationnotification'), 'no') ?> /> <?php _e('No'); ?><br />
</ins><span class="cx">                                         <?php _e('Send the site admin an email notification every time someone registers a blog or user account.') ?>
</span><span class="cx">                                 </td>
</span><span class="cx">                         </tr>
</span><span class="lines">@@ -79,8 +79,8 @@
</span><span class="cx">                                 <th scope="row"><?php _e('Add New Users') ?></th>
</span><span class="cx">                                 <td>
</span><span class="cx">                                         <a name='addnewusers'></a>
</span><del>-                                        <input name="add_new_users" type="radio" id="add_new_users1" value='1' <?php echo get_site_option('add_new_users') == 1 ? 'checked="checked"' : ''; ?> /> <?php _e('Yes'); ?><br />
-                                        <input name="add_new_users" type="radio" id="add_new_users2" value='0' <?php echo get_site_option('add_new_users') == 0 ? 'checked="checked"' : ''; ?> /> <?php _e('No'); ?><br />
</del><ins>+                                        <input name="add_new_users" type="radio" id="add_new_users1" value='1' <?php checked( get_site_option('add_new_users') ) ?> /> <?php _e('Yes'); ?><br />
+                                        <input name="add_new_users" type="radio" id="add_new_users2" value='0' <?php checked( get_site_option('add_new_users'), false) ?> /> <?php _e('No'); ?><br />
</ins><span class="cx">                                         <?php _e('Allow blog administrators to add new users to their blog via the Users->Add New page.') ?>
</span><span class="cx">                                 </td>
</span><span class="cx">                         </tr>
</span><span class="lines">@@ -202,16 +202,16 @@
</span><span class="cx">                         <tr valign="top">
</span><span class="cx">                                 <th scope="row"><?php _e('Upload media button') ?></th>
</span><span class="cx">                                 <?php $mu_media_buttons = get_site_option( 'mu_media_buttons', array() ); ?>
</span><del>-                                <td><label><input type='checkbox' id="mu_media_buttons_image" name="mu_media_buttons[image]" value='1' <?php if ( $mu_media_buttons[ 'image' ] ) { echo 'checked=checked '; } ?>/> <?php _e( 'Images' ); ?></label><br />
-                                <label><input type='checkbox' id="mu_media_buttons_video" name="mu_media_buttons[video]" value='1' <?php if ( $mu_media_buttons[ 'video' ] ) { echo 'checked=checked '; } ?>/> <?php _e( 'Videos' ); ?></label><br />
-                                <label><input type='checkbox' id="mu_media_buttons_audio" name="mu_media_buttons[audio]" value='1' <?php if ( $mu_media_buttons[ 'audio' ] ) { echo 'checked=checked '; } ?>/> <?php _e( 'Music' ); ?></label><br />
</del><ins>+                                <td><label><input type='checkbox' id="mu_media_buttons_image" name="mu_media_buttons[image]" value='1' <?php checked( !empty($mu_media_buttons[ 'image' ]) ) ?>/> <?php _e( 'Images' ); ?></label><br />
+                                <label><input type='checkbox' id="mu_media_buttons_video" name="mu_media_buttons[video]" value='1' <?php checked( !empty($mu_media_buttons[ 'video' ]) ) ?>/> <?php _e( 'Videos' ); ?></label><br />
+                                <label><input type='checkbox' id="mu_media_buttons_audio" name="mu_media_buttons[audio]" value='1' <?php checked( !empty($mu_media_buttons[ 'audio' ]) ) ?>/> <?php _e( 'Music' ); ?></label><br />
</ins><span class="cx">                                 <?php _e( 'The media upload buttons to display on the "Write Post" page. Make sure you update the "Upload File Types" below as well.' ); ?></td>
</span><span class="cx">                         </tr>
</span><span class="cx">                         <tr valign="top">
</span><span class="cx">                                 <th scope="row"><?php _e('Blog upload space check') ?></th>
</span><span class="cx">                                 <td>
</span><del>-                                <label><input type='radio' id="upload_space_check_disabled" name="upload_space_check_disabled" value='0' <?php if ( !get_site_option( 'upload_space_check_disabled' ) ) { echo 'checked=checked '; } ?>/> <?php _e( 'Enabled' ); ?></label><br />
-                                <label><input type='radio' id="upload_space_check_disabled" name="upload_space_check_disabled" value='1' <?php if ( get_site_option( 'upload_space_check_disabled' ) ) { echo 'checked=checked '; } ?>/> <?php _e( 'Disabled' ); ?></label><br />
</del><ins>+                                <label><input type='radio' id="upload_space_check_disabled" name="upload_space_check_disabled" value='0' <?php checked( get_site_option( 'upload_space_check_disabled' ), false ) ?>/> <?php _e( 'Enabled' ); ?></label><br />
+                                <label><input type='radio' id="upload_space_check_disabled" name="upload_space_check_disabled" value='1' <?php checked( get_site_option( 'upload_space_check_disabled' ) ) ?>/> <?php _e( 'Disabled' ); ?></label><br />
</ins><span class="cx">                                 <?php _e( 'By default there is a limit on the total size of files uploaded but it can be disabled here.' ); ?></td>
</span><span class="cx">                         </tr>
</span><span class="cx">                         <tr valign="top">
</span><span class="lines">@@ -252,12 +252,13 @@
</span><span class="cx">                 <h3><?php _e('Site Wide Settings <em>(These settings may be overridden by blog owners)</em>') ?></h3>
</span><span class="cx">                 <table class="form-table">
</span><span class="cx">                         <?php
</span><ins>+                        $lang_files = array();
</ins><span class="cx">                         if ( is_dir( ABSPATH . LANGDIR ) && $dh = opendir( ABSPATH . LANGDIR ) )
</span><span class="cx">                                 while( ( $lang_file = readdir( $dh ) ) !== false )
</span><span class="cx">                                         if ( substr( $lang_file, -3 ) == '.mo' )
</span><span class="cx">                                                 $lang_files[] = $lang_file;
</span><span class="cx">                         $lang = get_site_option('WPLANG');
</span><del>-                        if ( is_array($lang_files) && !empty($lang_files) ) {
</del><ins>+                        if ( !empty($lang_files) ) {
</ins><span class="cx">                                 ?>
</span><span class="cx">                                 <tr valign="top">
</span><span class="cx">                                         <th width="33%"><?php _e('Default Language') ?></th>
</span><span class="lines">@@ -272,7 +273,7 @@
</span><span class="cx">                         ?>
</span><span class="cx">                 </table>
</span><span class="cx">
</span><del>-                <h3><?php _e('Menus <em>(Enable or disable WP Backend Menus)</em>') ?></h3>
</del><ins>+                <h3><?php _e('Menus <em>(Enable or disable WordPress Backend Menus)</em>') ?></h3>
</ins><span class="cx">                 <table class="form-table">
</span><span class="cx">                         <tr>
</span><span class="cx">                                 <th scope="row"><?php _e("Menu"); ?></th>
</span><span class="lines">@@ -280,10 +281,10 @@
</span><span class="cx">                         </tr>
</span><span class="cx">                         <a name='menu'></a>
</span><span class="cx">                         <?php
</span><del>-                        $menu_perms = get_site_option( "menu_items" );
</del><ins>+                        $menu_perms = get_site_option( 'menu_items' );
</ins><span class="cx">                         $menu_items = apply_filters( 'mu_menu_items', array('plugins' => __('Plugins')) );
</span><span class="cx">                         foreach ( (array) $menu_items as $key => $val ) {
</span><del>-                                echo "<tr><th scope='row'>" . wp_specialchars($val) . "</th><td><input type='checkbox' name='menu_items[" . $key . "]' value='1'" . (( $menu_perms[$key] == '1' ) ? ' checked="checked"' : '') . " /></td></tr>";
</del><ins>+                                echo "<tr><th scope='row'>" . wp_specialchars($val) . "</th><td><input type='checkbox' name='menu_items[" . $key . "]' value='1'" . checked($menu_perms[$key], '1', false) . " /></td></tr>";
</ins><span class="cx">                         }
</span><span class="cx">                         ?>
</span><span class="cx">                 </table>
</span></span></pre>
</div>
</div>
</body>
</html>