WordPress.org

Make WordPress Core

Changeset 16764


Ignore:
Timestamp:
12/07/2010 02:28:40 PM (9 years ago)
Author:
westi
Message:

Introduce can_edit_site to replace inline checks on whether or not the site_id is for the current Network. See #15716.

Location:
trunk/wp-admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-ms-users-list-table.php

    r16607 r16764  
    218218                            if ( is_array( $blogs ) ) {
    219219                                foreach ( (array) $blogs as $key => $val ) {
    220                                     if ( $current_site->id != $val->site_id ) continue;
    221                                    
    222                                         $path   = ( $val->path == '/' ) ? '' : $val->path;
     220                                    if ( !can_edit_site( $val->site_id ) )
     221                                        continue;
     222                                   
     223                                    $path   = ( $val->path == '/' ) ? '' : $val->path;
    223224                                    echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
    224                                     echo ' <small class="row-actions">';
     225                                    echo ' <small class="row-actions site-' . $val->site_id . '">';
    225226                                    $actions = array();
    226227                                    $actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
  • trunk/wp-admin/includes/ms.php

    r16748 r16764  
    722722    return false;
    723723}
     724/**
     725 * Whether or not we can edit this site from this page
     726 *
     727 * By default editing of sites is restricted to the Network Admin for that site_id this allows for this to be overridden
     728 *
     729 * @since 3.1.0
     730 * @param integer $site_id The site id to check.
     731 */
     732function can_edit_site( $site_id ) {
     733    global $wpdb;
     734       
     735    if ($site_id == $wpdb->siteid )
     736        $result = true;
     737    else
     738        $result = false;
     739   
     740    return apply_filters( 'can_edit_site', $result, $site_id );
     741}
    724742?>
  • trunk/wp-admin/network/site-info.php

    r16627 r16764  
    2323
    2424$details = get_blog_details( $id );
    25 if ( $details->site_id != $wpdb->siteid )
     25if ( !can_edit_site( $details->site_id ) )
    2626    wp_die( __( 'You do not have permission to access this page.' ) );
    2727
  • trunk/wp-admin/network/site-options.php

    r16627 r16764  
    2323
    2424$details = get_blog_details( $id );
    25 if ( $details->site_id != $wpdb->siteid )
     25if ( !can_edit_site( $details->site_id ) )
    2626    wp_die( __( 'You do not have permission to access this page.' ) );
    2727
  • trunk/wp-admin/network/site-themes.php

    r16606 r16764  
    3232
    3333$details = get_blog_details( $id );
    34 if ( $details->site_id != $wpdb->siteid )
     34if ( !can_edit_site( $details->site_id ) )
    3535    wp_die( __( 'You do not have permission to access this page.' ) );
    3636
  • trunk/wp-admin/network/site-users.php

    r16586 r16764  
    2929
    3030$details = get_blog_details( $id );
    31 if ( $details->site_id != $wpdb->siteid )
     31if ( !can_edit_site( $details->site_id ) )
    3232    wp_die( __( 'You do not have permission to access this page.' ) );
    3333
Note: See TracChangeset for help on using the changeset viewer.