Image
2 days ago
Select
2 days ago
Arrays.php
2 days ago
AvailableTranslations.php
2 days ago
Creatable.php
2 days ago
Dashicon.php
2 days ago
Date.php
2 days ago
Html.php
2 days ago
Icon.php
2 days ago
Image.php
2 days ago
LocalFile.php
2 days ago
Mbstring.php
2 days ago
MediaIdResolver.php
2 days ago
Menu.php
2 days ago
Network.php
2 days ago
Post.php
2 days ago
Strings.php
2 days ago
Taxonomy.php
2 days ago
User.php
2 days ago
UserRoles.php
2 days ago
WpDateFormat.php
2 days ago
Network.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Helper; |
| 6 | |
| 7 | use WP_Theme; |
| 8 | |
| 9 | class Network extends Creatable |
| 10 | { |
| 11 | public function get_site_option(int $blog_id, string $option): string |
| 12 | { |
| 13 | global $wpdb; |
| 14 | |
| 15 | $table = $wpdb->get_blog_prefix($blog_id) . 'options'; |
| 16 | |
| 17 | $sql = " |
| 18 | SELECT $table.option_value |
| 19 | FROM $table |
| 20 | WHERE option_name = %s |
| 21 | "; |
| 22 | |
| 23 | return (string)$wpdb->get_var($wpdb->prepare($sql, $option)); |
| 24 | } |
| 25 | |
| 26 | public function get_active_theme(int $blog_id): ?WP_Theme |
| 27 | { |
| 28 | $stylesheet = $this->get_site_option($blog_id, 'stylesheet'); |
| 29 | |
| 30 | // An empty stylesheet would make wp_get_theme() fall back to the current site's theme, so bail instead. |
| 31 | if ('' === $stylesheet) { |
| 32 | return null; |
| 33 | } |
| 34 | |
| 35 | return wp_get_theme($stylesheet); |
| 36 | } |
| 37 | |
| 38 | } |
| 39 |