143 $msg .= " <a href='update-core.php' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>'; |
143 $msg .= " <a href='update-core.php' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>'; |
144 |
144 |
145 echo "<span id='wp-version-message'>$msg</span>"; |
145 echo "<span id='wp-version-message'>$msg</span>"; |
146 } |
146 } |
147 |
147 |
|
148 function get_plugin_updates() { |
|
149 $all_plugins = get_plugins(); |
|
150 $upgrade_plugins = array(); |
|
151 $current = get_transient( 'update_plugins' ); |
|
152 foreach ( (array)$all_plugins as $plugin_file => $plugin_data) { |
|
153 if ( isset( $current->response[ $plugin_file ] ) ) { |
|
154 $upgrade_plugins[ $plugin_file ] = (object) $plugin_data; |
|
155 $upgrade_plugins[ $plugin_file ]->update = $current->response[ $plugin_file ]; |
|
156 } |
|
157 } |
|
158 |
|
159 return $upgrade_plugins; |
|
160 } |
|
161 |
|
162 function wp_plugin_update_rows() { |
|
163 $plugins = get_transient( 'update_plugins' ); |
|
164 if ( isset($plugins->response) && is_array($plugins->response) ) { |
|
165 $plugins = array_keys( $plugins->response ); |
|
166 foreach( $plugins as $plugin_file ) { |
|
167 add_action( "after_plugin_row_$plugin_file", 'wp_plugin_update_row', 10, 2 ); |
|
168 } |
|
169 } |
|
170 } |
|
171 add_action( 'admin_init', 'wp_plugin_update_rows' ); |
|
172 |
148 function wp_plugin_update_row( $file, $plugin_data ) { |
173 function wp_plugin_update_row( $file, $plugin_data ) { |
149 $current = get_transient( 'update_plugins' ); |
174 $current = get_transient( 'update_plugins' ); |
150 if ( !isset( $current->response[ $file ] ) ) |
175 if ( !isset( $current->response[ $file ] ) ) |
151 return false; |
176 return false; |
152 |
177 |
167 |
192 |
168 do_action( "in_plugin_update_message-$file", $plugin_data, $r ); |
193 do_action( "in_plugin_update_message-$file", $plugin_data, $r ); |
169 |
194 |
170 echo '</div></td></tr>'; |
195 echo '</div></td></tr>'; |
171 } |
196 } |
172 add_action( 'after_plugin_row', 'wp_plugin_update_row', 10, 2 ); |
|
173 |
197 |
174 function wp_update_plugin($plugin, $feedback = '') { |
198 function wp_update_plugin($plugin, $feedback = '') { |
175 |
199 |
176 if ( !empty($feedback) ) |
200 if ( !empty($feedback) ) |
177 add_filter('update_feedback', $feedback); |
201 add_filter('update_feedback', $feedback); |
178 |
202 |
179 include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
203 include ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
180 $upgrader = new Plugin_Upgrader(); |
204 $upgrader = new Plugin_Upgrader(); |
181 return $upgrader->upgrade($plugin); |
205 return $upgrader->upgrade($plugin); |
|
206 } |
|
207 |
|
208 function get_theme_updates() { |
|
209 $themes = get_themes(); |
|
210 $current = get_transient('update_themes'); |
|
211 $update_themes = array(); |
|
212 |
|
213 foreach ( $themes as $theme ) { |
|
214 $theme = (object) $theme; |
|
215 if ( isset($current->response[ $theme->Stylesheet ]) ) { |
|
216 $update_themes[$theme->Stylesheet] = $theme; |
|
217 $update_themes[$theme->Stylesheet]->update = $current->response[ $theme->Stylesheet ]; |
|
218 } |
|
219 } |
|
220 |
|
221 return $update_themes; |
182 } |
222 } |
183 |
223 |
184 function wp_update_theme($theme, $feedback = '') { |
224 function wp_update_theme($theme, $feedback = '') { |
185 |
225 |
186 if ( !empty($feedback) ) |
226 if ( !empty($feedback) ) |