|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* A status class for Jetpack. |
|
4
|
|
|
* |
|
5
|
|
|
* @package jetpack-status |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Automattic\Jetpack; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class Automattic\Jetpack\Status |
|
12
|
|
|
* |
|
13
|
|
|
* Used to retrieve information about the current status of Jetpack and the site overall. |
|
14
|
|
|
*/ |
|
15
|
|
|
class Status { |
|
16
|
|
|
/** |
|
17
|
|
|
* Is Jetpack in development (offline) mode? |
|
18
|
|
|
* |
|
19
|
|
|
* @return bool Whether Jetpack's development mode is active. |
|
20
|
|
|
*/ |
|
21
|
|
View Code Duplication |
public function is_development_mode() { |
|
22
|
|
|
$development_mode = false; |
|
23
|
|
|
$site_url = site_url(); |
|
24
|
|
|
|
|
25
|
|
|
if ( defined( '\\JETPACK_DEV_DEBUG' ) ) { |
|
26
|
|
|
$development_mode = constant( '\\JETPACK_DEV_DEBUG' ); |
|
27
|
|
|
} elseif ( $site_url ) { |
|
28
|
|
|
$development_mode = false === strpos( $site_url, '.' ); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Filters Jetpack's development mode. |
|
33
|
|
|
* |
|
34
|
|
|
* @see https://jetpack.com/support/development-mode/ |
|
35
|
|
|
* |
|
36
|
|
|
* @since 2.2.1 |
|
37
|
|
|
* |
|
38
|
|
|
* @param bool $development_mode Is Jetpack's development mode active. |
|
39
|
|
|
*/ |
|
40
|
|
|
$development_mode = (bool) apply_filters( 'jetpack_development_mode', $development_mode ); |
|
41
|
|
|
|
|
42
|
|
|
return $development_mode; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Whether this is a system with a multiple networks. |
|
47
|
|
|
* Implemented since there is no core is_multi_network function. |
|
48
|
|
|
* Right now there is no way to tell which network is the dominant network on the system. |
|
49
|
|
|
* |
|
50
|
|
|
* @return boolean |
|
51
|
|
|
*/ |
|
52
|
|
View Code Duplication |
public function is_multi_network() { |
|
53
|
|
|
global $wpdb; |
|
54
|
|
|
|
|
55
|
|
|
// If we don't have a multi site setup no need to do any more. |
|
56
|
|
|
if ( ! is_multisite() ) { |
|
57
|
|
|
return false; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$num_sites = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->site}" ); |
|
61
|
|
|
if ( $num_sites > 1 ) { |
|
62
|
|
|
return true; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return false; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Whether the current site is single user site. |
|
70
|
|
|
* |
|
71
|
|
|
* @return bool |
|
72
|
|
|
*/ |
|
73
|
|
View Code Duplication |
public function is_single_user_site() { |
|
74
|
|
|
global $wpdb; |
|
75
|
|
|
|
|
76
|
|
|
$some_users = get_transient( 'jetpack_is_single_user' ); |
|
77
|
|
|
if ( false === $some_users ) { |
|
78
|
|
|
$some_users = $wpdb->get_var( "SELECT COUNT(*) FROM (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '{$wpdb->prefix}capabilities' LIMIT 2) AS someusers" ); |
|
79
|
|
|
set_transient( 'jetpack_is_single_user', (int) $some_users, 12 * HOUR_IN_SECONDS ); |
|
80
|
|
|
} |
|
81
|
|
|
return 1 === (int) $some_users; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|