Created
May 4, 2019 07:16
-
-
Save gaupoit/10e97e91402a0eaab36f2bb5411fe42a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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