PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 3.0.5
Admin Columns v3.0.5
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Plugin / Updater.php
codepress-admin-columns / classes / Plugin Last commit date
Update 8 years ago Update.php 8 years ago Updater.php 8 years ago
Updater.php
96 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class AC_Plugin_Updater {
8
9 /**
10 * @var self
11 */
12 protected static $instance;
13
14 /**
15 * @var bool
16 */
17 protected $fresh_install;
18
19 /**
20 * @var bool
21 */
22 protected $apply_updates;
23
24 /**
25 * @var AC_Plugin_Update[]
26 */
27 protected $updates;
28
29 /**
30 * @var AC_Plugin
31 */
32 protected $plugin;
33
34 /**
35 * @param AC_Plugin $plugin
36 */
37 public function __construct( AC_Plugin $plugin ) {
38 $this->plugin = $plugin;
39 $this->apply_updates = 'true' === filter_input( INPUT_GET, 'ac_do_update' );
40 }
41
42 public function add_update( AC_Plugin_Update $update ) {
43 $this->updates[ $update->get_version() ] = $update;
44 }
45
46 public function parse_updates() {
47
48 // Network wide updating is not allowed
49 if ( is_network_admin() ) {
50 return;
51 }
52
53 $plugin = $this->plugin;
54
55 if ( $plugin->is_fresh_install() ) {
56 $plugin->update_stored_version( $plugin->get_version() );
57
58 return;
59 }
60
61 krsort( $this->updates, SORT_NUMERIC );
62
63 /* @var AC_Plugin_Update $update */
64 foreach ( $this->updates as $update ) {
65 if ( $update->needs_update() ) {
66 if ( ! $this->apply_updates ) {
67 $this->show_update_notice();
68
69 return;
70 }
71
72 $update->apply_update();
73 $plugin->update_stored_version( $update->get_version() );
74 }
75 }
76
77 if ( $this->apply_updates ) {
78 $plugin->update_stored_version( $plugin->get_version() );
79 }
80 }
81
82 public function show_update_notice() {
83 $url = add_query_arg( array( 'ac_do_update' => 'true' ), AC()->admin()->get_settings_url() );
84
85 $message = sprintf( '<strong>%s</strong> &ndash; %s <a href="%s" class="button ac-update-now">%s</a>',
86 esc_html__( 'Admin Columns', 'codepress-admin-columns' ),
87 esc_html__( 'We need to update your database to the latest version.', 'codepress-admin-columns' ),
88 esc_url( $url ),
89 esc_html__( 'Run the updater', 'codepress-admin-columns' )
90 );
91
92 AC()->notice( $message, 'notice-info' );
93 }
94
95 }
96