| @@ -52,10 +52,8 @@ | ||
| 52 | 52 | $this->_addAction( 'plugins_loaded', 'loadTextDomain' ); |
| 53 | 53 | $this->_addFilter( 'visualizer_logger_data', 'getLoggerData' ); |
| 54 | 54 | $this->_addFilter( 'visualizer_get_chart_counts', 'getUsage', 10, 2 ); |
| 55 | 55 | |
| 56 | - $this->_addAction( 'init', 'checkIsExistingUser' ); | |
| 57 | - | |
| 58 | 56 | // only for testing |
| 59 | 57 | // $this->_addAction( 'admin_init', 'getUsage' ); |
| 60 | 58 | } |
| 61 | 59 | /** |
| @@ -208,14 +206,10 @@ | ||
| 208 | 206 | * Activates the plugin on a particular blog instance (supports multisite and single site). |
| 209 | 207 | */ |
| 210 | 208 | private function activate_on_site() { |
| 211 | 209 | wp_clear_scheduled_hook( 'visualizer_schedule_refresh_db' ); |
| 212 | - wp_schedule_event( strtotime( 'midnight' ) - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS, apply_filters( 'visualizer_chart_schedule_interval', 'hourly' ), 'visualizer_schedule_refresh_db' ); | |
| 210 | + wp_schedule_event( strtotime( 'midnight' ) - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS, 'hourly', 'visualizer_schedule_refresh_db' ); | |
| 213 | 211 | add_option( 'visualizer-activated', true ); |
| 214 | - $is_fresh_install = get_option( 'visualizer_fresh_install', false ); | |
| 215 | - if ( ! defined( 'TI_CYPRESS_TESTING' ) && false === $is_fresh_install ) { | |
| 216 | - update_option( 'visualizer_fresh_install', '1' ); | |
| 217 | - } | |
| 218 | 212 | } |
| 219 | 213 | |
| 220 | 214 | /** |
| 221 | 215 | * Deactivate the plugin |
| @@ -247,9 +241,8 @@ | ||
| 247 | 241 | if ( defined( 'TI_UNIT_TESTING' ) ) { |
| 248 | 242 | return; |
| 249 | 243 | } |
| 250 | 244 | |
| 251 | - define( 'VISUALIZER_SURVEY', Visualizer_Module::is_pro() ? 'https://forms.gle/7Zo7FuZbvQ8DTvRi6' : 'https://forms.gle/muMtbcyvHn1aTvmJ7' ); | |
| 252 | 245 | // fire any upgrades necessary. |
| 253 | 246 | Visualizer_Module_Upgrade::upgrade(); |
| 254 | 247 | |
| 255 | 248 | if ( get_option( 'visualizer-activated' ) ) { |
| @@ -254,25 +247,10 @@ | ||
| 254 | 247 | |
| 255 | 248 | if ( get_option( 'visualizer-activated' ) ) { |
| 256 | 249 | delete_option( 'visualizer-activated' ); |
| 257 | 250 | if ( ! headers_sent() ) { |
| 258 | - if ( ! Visualizer_Module::is_pro() && ! empty( get_option( 'visualizer_fresh_install', false ) ) ) { | |
| 259 | - $redirect_url = array( | |
| 260 | - 'page' => 'visualizer-setup-wizard', | |
| 261 | - 'tab' => '#step-1', | |
| 262 | - ); | |
| 263 | - } else { | |
| 264 | - $page_name = Visualizer_Module::numberOfCharts() > 0 ? Visualizer_Plugin::NAME : 'viz-support'; | |
| 265 | - $redirect_url = array( | |
| 266 | - 'page' => $page_name, | |
| 267 | - ); | |
| 268 | - } | |
| 269 | - wp_safe_redirect( | |
| 270 | - add_query_arg( | |
| 271 | - $redirect_url, | |
| 272 | - admin_url( 'admin.php' ) | |
| 273 | - ) | |
| 274 | - ); | |
| 251 | + $page_name = Visualizer_Module::numberOfCharts() > 0 ? Visualizer_Plugin::NAME : 'viz-support'; | |
| 252 | + wp_redirect( add_query_arg( 'page', $page_name, admin_url( 'admin.php' ) ) ); | |
| 275 | 253 | exit(); |
| 276 | 254 | } |
| 277 | 255 | } |
| 278 | 256 | } |
| @@ -415,32 +393,11 @@ | ||
| 415 | 393 | } |
| 416 | 394 | |
| 417 | 395 | // if the time is nigh, we force an update. |
| 418 | 396 | $this->refresh_db_for_chart( null, $chart_id, true ); |
| 419 | - // Clear existing chart cache. | |
| 420 | - $cache_key = Visualizer_Plugin::CF_CHART_CACHE . '_' . $chart_id; | |
| 421 | - if ( get_transient( $cache_key ) ) { | |
| 422 | - delete_transient( $cache_key ); | |
| 423 | - } | |
| 424 | 397 | $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true ); |
| 425 | 398 | $new_schedules[ $chart_id ] = time() + $hours * HOUR_IN_SECONDS; |
| 426 | 399 | } |
| 427 | 400 | update_option( Visualizer_Plugin::CF_DB_SCHEDULE, $new_schedules ); |
| 428 | - } | |
| 429 | - | |
| 430 | - /** | |
| 431 | - * Save flag for existing users. | |
| 432 | - */ | |
| 433 | - public function checkIsExistingUser() { | |
| 434 | - $chart_exists = get_option( 'visualizer-new-user', '' ); | |
| 435 | - if ( '' === $chart_exists ) { | |
| 436 | - $charts = get_posts( | |
| 437 | - array( | |
| 438 | - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 439 | - 'fields' => 'ids', | |
| 440 | - ) | |
| 441 | - ); | |
| 442 | - update_option( 'visualizer-new-user', ! empty( $charts ) ? 'no' : 'yes' ); | |
| 443 | - } | |
| 444 | 401 | } |
| 445 | 402 | |
| 446 | 403 | } |