Changeset 3373797 for updraftplus/trunk/central/modules/core.php
- Timestamp:
- 10/06/2025 03:23:19 PM (4 months ago)
- File:
-
- 1 edited
-
updraftplus/trunk/central/modules/core.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
updraftplus/trunk/central/modules/core.php
r3341192 r3373797 172 172 return $this->_generic_error_response('data_uri_field_empty_or_invalid', array('error_message' => __('Required data URI is either missing or invalid.', 'updraftcentral'))); 173 173 } 174 } 175 176 /** 177 * Pulls blog sites available 178 * for the current WP instance. 179 * If the site is a multisite, then sites under the network 180 * will be pulled, otherwise, it will return an empty array. 181 * 182 * @return Array - an array of sites 183 */ 184 public function get_blog_sites() { 185 186 if (!is_multisite()) { 187 return $this->_generic_error_response('not_multisite'); 188 } 189 190 $sites = array(); 191 $network_sites = array(); 192 193 // Use `get_sites` for WP version >= 4.6 else use old `wp_get_sites`. 194 if (function_exists('get_sites') && class_exists('WP_Site_Query')) { 195 $network_sites = get_sites(); 196 } else { 197 if (function_exists('wp_get_sites')) { 198 $network_sites = wp_get_sites(); 199 } 200 } 201 202 if (!empty($network_sites)) { 203 foreach ($network_sites as $site) { 204 205 // Check if the site type is an array, 206 // because `wp_get_sites` returns site data as associative array while, 207 // `get_sites` returns the data as WP_Site object. 208 $blog_id = is_array($site) ? $site['blog_id'] : $site->blog_id; 209 210 $sites[] = array( 211 'site_id' => $blog_id, 212 'name' => get_blog_details($blog_id)->blogname, 213 ); 214 } 215 } 216 217 return $this->_response(array( 218 'sites' => $sites, 219 )); 174 220 } 175 221
Note: See TracChangeset
for help on using the changeset viewer.