Changes between Initial Version and Version 1 of Ticket #25293, comment 9
- Timestamp:
- 08/17/2016 11:53:48 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #25293, comment 9
initial v1 3 3 {{{ 4 4 function switch_to_site( $site, $switch_network = false ) { 5 if ( $switch_network && ! is_object( $site ) ) { 6 $site = get_site( $site ); 5 if ( $switch_network ) { 6 if ( ! is_object( $site ) { 7 $site = get_site( $site ); 8 } 7 9 $site_id = $site->blog_id; 8 } elseif ( is_object( $site ) ) { 9 $site_id = $site->blog_id; 10 $site = $site_id; 10 $GLOBALS['_wp_switched_sites_stack'][] = $GLOBALS['current_blog']; 11 11 } else { 12 $site_id = $site; 12 if ( is_object( $site ) { 13 $site_id = $site->blog_id; 14 $site = $site_id; 15 } else { 16 $site_id = $site; 17 } 18 $GLOBALS['_wp_switched_sites_stack'][] = $GLOBALS['current_blog']->blog_id; 13 19 } 14 15 $GLOBALS['_wp_switched_sites_stack'][] = $site;16 20 17 21 // do rest of the regular logic with $site_id … … 45 49 46 50 function switch_to_network( $network, $switch_site = false ) { 47 if ( $switch_site && ! is_object( $network ) ) { 48 $network = get_network( $network ); 51 if ( $switch_site ) { 52 if ( ! is_object( $network ) { 53 $network = get_network( $network ); 54 } 49 55 $network_id = $network->id; 50 } elseif ( is_object( $network ) ) { 51 $network_id = $network->id; 52 $network = $network_id; 56 $GLOBALS['_wp_switched_networks_stack'][] = $GLOBALS['current_site']; 53 57 } else { 54 $network_id = $network; 58 if ( is_object( $network ) { 59 $network_id = $network->id; 60 $network = $network_id; 61 } else { 62 $network_id = $network; 63 } 64 $GLOBALS['_wp_switched_networks_stack'][] = $GLOBALS['current_site']->id; 55 65 } 56 57 $GLOBALS['_wp_switched_networks_stack'][] = $network;58 66 59 67 // do rest of the regular logic with $network_id