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