@@ 88-98 (lines=11) @@ | ||
85 | <?php |
|
86 | } |
|
87 | ||
88 | public function is_active() { |
|
89 | Jetpack::load_xml_rpc_client(); |
|
90 | $xml = new Jetpack_IXR_Client( array( |
|
91 | 'user_id' => get_current_user_id() |
|
92 | ) ); |
|
93 | $xml->query( 'jetpack.monitor.isActive' ); |
|
94 | if ( $xml->isError() ) { |
|
95 | wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) ); |
|
96 | } |
|
97 | return $xml->getResponse(); |
|
98 | } |
|
99 | ||
100 | public function update_option_receive_jetpack_monitor_notification( $value ) { |
|
101 | Jetpack::load_xml_rpc_client(); |
|
@@ 100-111 (lines=12) @@ | ||
97 | return $xml->getResponse(); |
|
98 | } |
|
99 | ||
100 | public function update_option_receive_jetpack_monitor_notification( $value ) { |
|
101 | Jetpack::load_xml_rpc_client(); |
|
102 | $xml = new Jetpack_IXR_Client( array( |
|
103 | 'user_id' => get_current_user_id() |
|
104 | ) ); |
|
105 | $xml->query( 'jetpack.monitor.setNotifications', (bool) $value ); |
|
106 | ||
107 | if ( $xml->isError() ) { |
|
108 | wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) ); |
|
109 | } |
|
110 | return true; |
|
111 | } |
|
112 | ||
113 | public function user_receives_notifications() { |
|
114 | Jetpack::load_xml_rpc_client(); |
|
@@ 113-124 (lines=12) @@ | ||
110 | return true; |
|
111 | } |
|
112 | ||
113 | public function user_receives_notifications() { |
|
114 | Jetpack::load_xml_rpc_client(); |
|
115 | $xml = new Jetpack_IXR_Client( array( |
|
116 | 'user_id' => get_current_user_id() |
|
117 | ) ); |
|
118 | $xml->query( 'jetpack.monitor.isUserInNotifications' ); |
|
119 | ||
120 | if ( $xml->isError() ) { |
|
121 | wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) ); |
|
122 | } |
|
123 | return $xml->getResponse(); |
|
124 | } |
|
125 | ||
126 | public function activate_monitor() { |
|
127 | Jetpack::load_xml_rpc_client(); |
|
@@ 126-138 (lines=13) @@ | ||
123 | return $xml->getResponse(); |
|
124 | } |
|
125 | ||
126 | public function activate_monitor() { |
|
127 | Jetpack::load_xml_rpc_client(); |
|
128 | $xml = new Jetpack_IXR_Client( array( |
|
129 | 'user_id' => get_current_user_id() |
|
130 | ) ); |
|
131 | ||
132 | $xml->query( 'jetpack.monitor.activate' ); |
|
133 | ||
134 | if ( $xml->isError() ) { |
|
135 | wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) ); |
|
136 | } |
|
137 | return true; |
|
138 | } |
|
139 | ||
140 | public function deactivate_monitor() { |
|
141 | Jetpack::load_xml_rpc_client(); |
|
@@ 140-152 (lines=13) @@ | ||
137 | return true; |
|
138 | } |
|
139 | ||
140 | public function deactivate_monitor() { |
|
141 | Jetpack::load_xml_rpc_client(); |
|
142 | $xml = new Jetpack_IXR_Client( array( |
|
143 | 'user_id' => get_current_user_id() |
|
144 | ) ); |
|
145 | ||
146 | $xml->query( 'jetpack.monitor.deactivate' ); |
|
147 | ||
148 | if ( $xml->isError() ) { |
|
149 | wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) ); |
|
150 | } |
|
151 | return true; |
|
152 | } |
|
153 | ||
154 | /* |
|
155 | * Returns date of the last downtime. |
|
@@ 160-172 (lines=13) @@ | ||
157 | * @since 4.0 |
|
158 | * @return date in YYYY-MM-DD HH:mm:ss format |
|
159 | */ |
|
160 | public function monitor_get_last_downtime() { |
|
161 | Jetpack::load_xml_rpc_client(); |
|
162 | $xml = new Jetpack_IXR_Client( array( |
|
163 | 'user_id' => get_current_user_id() |
|
164 | ) ); |
|
165 | ||
166 | $xml->query( 'jetpack.monitor.getLastDowntime' ); |
|
167 | ||
168 | if ( $xml->isError() ) { |
|
169 | return new WP_Error( 'monitor-downtime', $xml->getErrorMessage() ); |
|
170 | } |
|
171 | return $xml->getResponse(); |
|
172 | } |
|
173 | ||
174 | } |
|
175 |
@@ 537-549 (lines=13) @@ | ||
534 | return $xml->getResponse(); |
|
535 | } |
|
536 | ||
537 | static function request_initial_nonce() { |
|
538 | Jetpack::load_xml_rpc_client(); |
|
539 | $xml = new Jetpack_IXR_Client( array( |
|
540 | 'user_id' => get_current_user_id() |
|
541 | ) ); |
|
542 | $xml->query( 'jetpack.sso.requestNonce' ); |
|
543 | ||
544 | if ( $xml->isError() ) { |
|
545 | wp_die( sprintf( '%s: %s', $xml->getErrorCode(), $xml->getErrorMessage() ) ); |
|
546 | } |
|
547 | ||
548 | return $xml->getResponse(); |
|
549 | } |
|
550 | ||
551 | /** |
|
552 | * The function that actually handles the login! |