| @@ -52,8 +52,10 @@ | ||
| 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 | + | |
| 56 | 58 | // only for testing |
| 57 | 59 | // $this->_addAction( 'admin_init', 'getUsage' ); |
| 58 | 60 | } |
| 59 | 61 | /** |
| @@ -402,7 +404,23 @@ | ||
| 402 | 404 | $hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true ); |
| 403 | 405 | $new_schedules[ $chart_id ] = time() + $hours * HOUR_IN_SECONDS; |
| 404 | 406 | } |
| 405 | 407 | update_option( Visualizer_Plugin::CF_DB_SCHEDULE, $new_schedules ); |
| 408 | + } | |
| 409 | + | |
| 410 | + /** | |
| 411 | + * Save flag for existing users. | |
| 412 | + */ | |
| 413 | + public function checkIsExistingUser() { | |
| 414 | + $chart_exists = get_option( 'visualizer-new-user', '' ); | |
| 415 | + if ( '' === $chart_exists ) { | |
| 416 | + $charts = get_posts( | |
| 417 | + array( | |
| 418 | + 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 419 | + 'fields' => 'ids', | |
| 420 | + ) | |
| 421 | + ); | |
| 422 | + update_option( 'visualizer-new-user', ! empty( $charts ) ? 'no' : 'yes' ); | |
| 423 | + } | |
| 406 | 424 | } |
| 407 | 425 | |
| 408 | 426 | } |