PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 3.1.2
Admin Columns v3.1.2
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
124 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 // TODO: https://github.com/codepress/admin-columns-issues/issues/982
40 //$this->apply_updates = 'true' === filter_input( INPUT_GET, 'ac_do_update' );
41 $this->apply_updates = true;
42 }
43
44 public function add_update( AC_Plugin_Update $update ) {
45 $this->updates[ $update->get_version() ] = $update;
46 }
47
48 /**
49 * Checks conditions like user permissions
50 *
51 */
52 public function check_update_conditions() {
53 if ( ! AC()->user_can_manage_admin_columns() ) {
54 return false;
55 }
56
57 // Network wide updating is not supported yet
58 if ( is_network_admin() ) {
59 return false;
60 }
61
62 return true;
63 }
64
65 public function parse_updates() {
66 if ( ! $this->check_update_conditions() ) {
67 return;
68 }
69
70 if ( $this->plugin->is_new_install() ) {
71 $this->plugin->update_stored_version();
72
73 return;
74 }
75
76 krsort( $this->updates, SORT_NUMERIC );
77
78 /* @var AC_Plugin_Update $update */
79 foreach ( $this->updates as $update ) {
80 if ( $update->needs_update() ) {
81 if ( ! $this->apply_updates ) {
82 $this->show_update_notice();
83
84 return;
85 }
86
87 $update->apply_update();
88 $this->plugin->update_stored_version( $update->get_version() );
89 }
90 }
91
92 if ( ! $this->apply_updates ) {
93 return;
94 }
95
96 $this->plugin->update_stored_version();
97 // TODO: https://github.com/codepress/admin-columns-issues/issues/982
98 //$this->show_completed_notice();
99 }
100
101 protected function show_completed_notice() {
102 $message = sprintf( '<strong>%s</strong> &ndash; %s',
103 esc_html__( 'Admin Columns', 'codepress-admin-columns' ),
104 esc_html__( 'Your database is up to date. You are awesome.', 'codepress-admin-columns' )
105 );
106
107 AC()->notice( $message );
108 }
109
110 protected function show_update_notice() {
111 $url = add_query_arg( array( 'ac_do_update' => 'true' ), AC()->admin()->get_settings_url() );
112
113 $message = sprintf( '<strong>%s</strong> &ndash; %s <a href="%s" class="button ac-update-now">%s</a>',
114 esc_html__( 'Admin Columns', 'codepress-admin-columns' ),
115 esc_html__( 'We need to update your database to the latest version.', 'codepress-admin-columns' ),
116 esc_url( $url ),
117 esc_html__( 'Run the updater', 'codepress-admin-columns' )
118 );
119
120 AC()->notice( $message, 'notice-info' );
121 }
122
123 }
124