| @@ -189,9 +189,24 @@ | ||
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | 191 | * Activate the plugin |
| 192 | 192 | */ |
| 193 | - public function activate() { | |
| 193 | + public function activate( $network_wide ) { | |
| 194 | + if ( is_multisite() && $network_wide ) { | |
| 195 | + foreach ( get_sites( array( 'fields' => 'ids' ) ) as $blog_id ) { | |
| 196 | + switch_to_blog( $blog_id ); | |
| 197 | + $this->activate_on_site(); | |
| 198 | + restore_current_blog(); | |
| 199 | + } | |
| 200 | + } else { | |
| 201 | + $this->activate_on_site(); | |
| 202 | + } | |
| 203 | + } | |
| 204 | + | |
| 205 | + /** | |
| 206 | + * Activates the plugin on a particular blog instance (supports multisite and single site). | |
| 207 | + */ | |
| 208 | + private function activate_on_site() { | |
| 194 | 209 | wp_clear_scheduled_hook( 'visualizer_schedule_refresh_db' ); |
| 195 | 210 | wp_schedule_event( strtotime( 'midnight' ) - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS, 'hourly', 'visualizer_schedule_refresh_db' ); |
| 196 | 211 | add_option( 'visualizer-activated', true ); |
| 197 | 212 | } |
| @@ -196,8 +211,31 @@ | ||
| 196 | 211 | add_option( 'visualizer-activated', true ); |
| 197 | 212 | } |
| 198 | 213 | |
| 199 | 214 | /** |
| 215 | + * Deactivate the plugin | |
| 216 | + */ | |
| 217 | + public function deactivate( $network_wide ) { | |
| 218 | + if ( is_multisite() && $network_wide ) { | |
| 219 | + foreach ( get_sites( array( 'fields' => 'ids' ) ) as $blog_id ) { | |
| 220 | + switch_to_blog( $blog_id ); | |
| 221 | + $this->deactivate_on_site(); | |
| 222 | + restore_current_blog(); | |
| 223 | + } | |
| 224 | + } else { | |
| 225 | + $this->deactivate_on_site(); | |
| 226 | + } | |
| 227 | + } | |
| 228 | + | |
| 229 | + /** | |
| 230 | + * Deactivates the plugin on a particular blog instance (supports multisite and single site). | |
| 231 | + */ | |
| 232 | + private function deactivate_on_site() { | |
| 233 | + wp_clear_scheduled_hook( 'visualizer_schedule_refresh_db' ); | |
| 234 | + delete_option( 'visualizer-activated', true ); | |
| 235 | + } | |
| 236 | + | |
| 237 | + /** | |
| 200 | 238 | * Check if plugin has been activated and then redirect to the correct page. |
| 201 | 239 | */ |
| 202 | 240 | public function adminInit() { |
| 203 | 241 | if ( defined( 'TI_UNIT_TESTING' ) ) { |
| @@ -218,16 +256,8 @@ | ||
| 218 | 256 | } |
| 219 | 257 | |
| 220 | 258 | |
| 221 | 259 | /** |
| 222 | - * Deactivate the plugin | |
| 223 | - */ | |
| 224 | - public function deactivate() { | |
| 225 | - wp_clear_scheduled_hook( 'visualizer_schedule_refresh_db' ); | |
| 226 | - delete_option( 'visualizer-activated', true ); | |
| 227 | - } | |
| 228 | - | |
| 229 | - /** | |
| 230 | 260 | * Refresh the specific chart from the db. |
| 231 | 261 | * |
| 232 | 262 | * @param WP_Post $chart The chart object. |
| 233 | 263 | * @param int $chart_id The chart id. |
| @@ -305,8 +335,20 @@ | ||
| 305 | 335 | if ( $load_series ) { |
| 306 | 336 | update_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, $source->getSeries() ); |
| 307 | 337 | } |
| 308 | 338 | |
| 339 | + $allow_html = false; | |
| 340 | + $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true ); | |
| 341 | + if ( isset( $settings['allowHtml'] ) && intval( $settings['allowHtml'] ) === 1 ) { | |
| 342 | + $allow_html = true; | |
| 343 | + } | |
| 344 | + | |
| 345 | + $allow_html = apply_filters( 'visualizer_allow_html_content', $allow_html, $chart_id, $chart ); | |
| 346 | + | |
| 347 | + if ( $allow_html ) { | |
| 348 | + kses_remove_filters(); | |
| 349 | + } | |
| 350 | + | |
| 309 | 351 | wp_update_post( |
| 310 | 352 | array( |
| 311 | 353 | 'ID' => $chart_id, |
| 312 | 354 | 'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ), |
| @@ -311,8 +353,12 @@ | ||
| 311 | 353 | 'ID' => $chart_id, |
| 312 | 354 | 'post_content' => $source->getData( get_post_meta( $chart_id, Visualizer_Plugin::CF_EDITABLE_TABLE, true ) ), |
| 313 | 355 | ) |
| 314 | 356 | ); |
| 357 | + | |
| 358 | + if ( $allow_html ) { | |
| 359 | + kses_init_filters(); | |
| 360 | + } | |
| 315 | 361 | |
| 316 | 362 | $chart = get_post( $chart_id ); |
| 317 | 363 | delete_post_meta( $chart_id, Visualizer_Plugin::CF_ERROR ); |
| 318 | 364 | } else { |