columns.php
10 years ago
counter.php
10 years ago
cron.php
10 years ago
dashboard.php
10 years ago
frontend.php
10 years ago
functions.php
10 years ago
query.php
10 years ago
settings.php
10 years ago
update.php
10 years ago
widgets.php
10 years ago
update.php
34 lines
| 1 | <?php |
| 2 | // exit if accessed directly |
| 3 | if ( ! defined( 'ABSPATH' ) ) |
| 4 | exit; |
| 5 | |
| 6 | /** |
| 7 | * Post_Views_Counter_Update class. |
| 8 | */ |
| 9 | class Post_Views_Counter_Update { |
| 10 | |
| 11 | public function __construct() { |
| 12 | // actions |
| 13 | add_action( 'init', array( $this, 'check_update' ) ); |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Check if there's a db update required |
| 18 | */ |
| 19 | public function check_update() { |
| 20 | if ( ! current_user_can( 'manage_options' ) ) |
| 21 | return; |
| 22 | |
| 23 | // get current database version |
| 24 | $current_db_version = get_option( 'post_views_counter_version', '1.0.0' ); |
| 25 | |
| 26 | // new version? |
| 27 | if ( version_compare( $current_db_version, Post_Views_Counter()->defaults['version'], '<' ) ) { |
| 28 | // update plugin version |
| 29 | update_option( 'post_views_counter_version', Post_Views_Counter()->defaults['version'] ); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | } |
| 34 |