install_plugin_install_status [ WordPress Function ]
install_plugin_install_status ( $api, $loop = false )
| Defined at: |
|
Soorgelijke functies: install_plugin_information, install_plugins_upload, uninstall_plugin, is_plugin_inactive, allow_subdomain_install
Determine the status we can perform on a plugin.
Source
<?php
function install_plugin_install_status($api, $loop = false) {
// this function is called recursively, $loop prevents further loops.
if ( is_array($api) )
$api = (object) $api;
//Default to a "new" plugin
$status = 'install';
$url = false;
//Check to see if this plugin is known to be installed, and has an update awaiting it.
$update_plugins = get_site_transient('update_plugins');
if ( isset( $update_plugins->response ) ) {
foreach ( (array)$update_plugins->response as $file => $plugin ) {
if ( $plugin->slug === $api->slug ) {
$status = 'update_available';
$update_file = $file;
$version = $plugin->new_version;
if ( current_user_can('update_plugins') )
$url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file);
break;
}
}
}
if ( 'install' == $status ) {
if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) {
$installed_plugin = get_plugins('/' . $api->slug);
if ( empty($installed_plugin) ) {
if ( current_user_can('install_plugins') )
$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
} else {
$key = array_shift( $key = array_keys($installed_plugin) ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers
if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){
$status = 'latest_installed';
} elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) {
$status = 'newer_installed';
$version = $installed_plugin[ $key ]['Version'];
} else {
//If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh
if ( ! $loop ) {
delete_site_transient('update_plugins');
wp_update_plugins();
return install_plugin_install_status($api, true);
}
}
}
} else {
// "install" & no directory with that slug
if ( current_user_can('install_plugins') )
$url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug);
}
}
if ( isset($_GET['from']) )
$url .= '&from=' . urlencode(stripslashes($_GET['from']));
return compact('status', 'url', 'version');
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- install_plugin_install_status | A HitchHackers guide through ...
Feb 12, 2011 ... function install_plugin_install_status($api, $loop = false) { // this function is called recursivly, $loop prevents futhur loops. if ( is_array($api) ) ...
hitchhackerguide.com - wp-admin/includes/plugin-install.php source
174 * 175 * @since 3.0.0 176 */ 177 function install_plugin_install_status($api, $ loop = false) { 178 // this function is called recursively, $loop prevents further ...
phpxref.ftwr.co.uk - 19790 - WordPress Trac
Yeah, you do have to take some additional steps before calling install_plugin_install_status(), so a wrapper would be good. On the other hand, I haven't heard ...
core.trac.wordpress.org - /wp-admin/includes/plugin-install.php source - PHP Cross ...
Jun 1, 2011 ... 174 * 175 * @since 3.0.0 176 */ 177 function install_plugin_install_status($api, $ loop = false) { 178 // this function is called recursivly, $loop ...
xref.yoast.com