Make WordPress Core


Ignore:
Timestamp:
04/01/2010 09:21:27 PM (15 years ago)
Author:
markjaquith
Message:

Huge MS refactoring and code cleanup. see #12460. props ocean90.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/my-sites.php

    r13896 r13918  
    11<?php
    2 
    3 require_once('admin.php');
     2require_once( './admin.php' );
    43
    54if ( !is_multisite() )
    6     wp_die( __('Multisite support is not enabled.') );
     5    wp_die( __( 'Multisite support is not enabled.' ) );
    76
    87if ( ! current_user_can('read') )
    9     wp_die(__('You do not have sufficient permissions to view this page.'));
     8    wp_die( __( 'You do not have sufficient permissions to view this page.' ) );
    109
    11 $action = isset($_POST['action']) ? $_POST['action'] : 'splash';
     10$action = isset( $_POST['action'] ) ? $_POST['action'] : 'splash';
    1211
    1312$blogs = get_blogs_of_user( $current_user->id );
     
    1817$updated = false;
    1918if ( 'updateblogsettings' == $action && isset( $_POST['primary_blog'] ) ) {
    20     check_admin_referer('update-my-sites');
    21     // @todo Validate primary blog.
    22     update_user_option( $current_user->id, 'primary_blog', (int) $_POST['primary_blog'], true );
    23     $updated = true;
     19    check_admin_referer( 'update-my-sites' );
     20
     21    $blog = get_blog_details( (int) $_POST['primary_blog'] );
     22    if ( $blog && isset( $blog->domain ) ) {
     23        update_user_option( $current_user->id, 'primary_blog', (int) $_POST['primary_blog'], true );
     24        $updated = true;
     25    } else {
     26        wp_die( __( "The primary site, which you have choosen, doesn't exists." ) );   
     27    }
    2428}
    2529
    26 $title = __('My Sites');
     30$title = __( 'My Sites' );
    2731$parent_file = 'index.php';
    28 require_once('admin-header.php');
     32require_once( './admin-header.php' );
    2933
    3034if ( $updated ) { ?>
    31         <div id="message" class="updated fade"><p><strong><?php _e( 'Your site preferences have been updated.' ); ?></strong></p></div>
     35    <div id="message" class="updated fade"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
    3236<?php } ?>
    3337
    3438<div class="wrap">
    3539<?php screen_icon(); ?>
    36 <h2><?php echo esc_html($title); ?></h2>
     40<h2><?php esc_html_e( $title ); ?></h2>
    3741<form id="myblogs" action="" method="post">
    3842    <?php
    3943    choose_primary_blog();
    4044    do_action( 'myblogs_allblogs_options' );
    41     ?><table class='widefat'> <?php
     45    ?>
     46    <br clear="all" />
     47    <table class="widefat fixed">
     48    <?php
    4249    $settings_html = apply_filters( 'myblogs_options', '', 'global' );
    4350    if ( $settings_html != '' ) {
     
    5360    elseif ( $num >= 10 )
    5461        $cols = 2;
    55     $num_rows = ceil($num/$cols);
     62    $num_rows = ceil( $num / $cols );
    5663    $split = 0;
    5764    for ( $i = 1; $i <= $num_rows; $i++ ) {
     
    6269    $c = '';
    6370    foreach ( $rows as $row ) {
    64         $c = $c == "alternate" ? '' : 'alternate';
     71        $c = $c == 'alternate' ? '' : 'alternate';
    6572        echo "<tr class='$c'>";
    66         $t = '';
     73        $i = 0;
    6774        foreach ( $row as $user_blog ) {
    68             $t = $t == 'border-right: 1px solid #ccc;' ? '' : 'border-right: 1px solid #ccc;';
    69             echo "<td valign='top' style='$t; width:50%'>";
     75            $s = $i == 3 ? '' : 'border-right: 1px solid #ccc;';
     76            echo "<td valign='top' style='$s'>";
    7077            echo "<h3>{$user_blog->blogname}</h3>";
    71             echo "<p>" . apply_filters( "myblogs_blog_actions", "<a href='" . get_home_url($user_blog->userblog_id) . "'>" . __( 'Visit' ) . "</a> | <a href='" . get_admin_url($user_blog->userblog_id) . "'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>";
     78            echo "<p>" . apply_filters( 'myblogs_blog_actions', "<a href='" . esc_url( get_home_url( $user_blog->userblog_id ) ). "'>" . __( 'Visit' ) . "</a> | <a href='" . esc_url( get_admin_url( $user_blog->userblog_id ) ) . "'>" . __( 'Dashboard' ) . "</a>", $user_blog ) . "</p>";
    7279            echo apply_filters( 'myblogs_options', '', $user_blog );
    7380            echo "</td>";
     81            $i++;
    7482        }
    7583        echo "</tr>";
     
    7785    </table>
    7886    <input type="hidden" name="action" value="updateblogsettings" />
    79     <?php wp_nonce_field('update-my-sites'); ?>
     87    <?php wp_nonce_field( 'update-my-sites' ); ?>
    8088    <p>
    81      <input type="submit" class="button-primary" value="<?php _e('Update Options') ?>" name="submit" />
     89     <input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" />
    8290    </p>
    8391    </form>
    8492    </div>
    8593<?php
    86 include('admin-footer.php');
    87 
     94include( './admin-footer.php' );
    8895?>
Note: See TracChangeset for help on using the changeset viewer.