Skip to content

Instantly share code, notes, and snippets.

@gaupoit
Created May 4, 2019 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaupoit/10e97e91402a0eaab36f2bb5411fe42a to your computer and use it in GitHub Desktop.
Save gaupoit/10e97e91402a0eaab36f2bb5411fe42a to your computer and use it in GitHub Desktop.
<?php
/**
* Handle auto upgrade extension
*/
public function pda_handle_upgrade_extension() {
$updates = get_plugin_updates();
$pda_skin = new PDA_WP_Upgrader_Skin();
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$upgrader = new Plugin_Upgrader( $pda_skin );
foreach ( $updates as $plugin ) {
if ( 'PDA Access Restriction' === $plugin->Name ) {
if ( version_compare( $plugin->Version, '1.0.4.5' ) < 0 ) {
$result = $upgrader->upgrade( $plugin->update->plugin );
if ( $result ) {
activate_plugin( $plugin->update->plugin, '', false, true );
}
}
}
if ( 'PDA Membership Integration' === $plugin->Name ) {
if ( version_compare( $plugin->Version, '1.1.6' ) < 0 ) {
$result = $upgrader->upgrade( $plugin->update->plugin );
if ( $result ) {
activate_plugin( $plugin->update->plugin, '', false, true );
}
}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment