PluginProbe
WP Synchro – The Ultimate WordPress Migration Tool / trunk
WP Synchro – The Ultimate WordPress Migration Tool vtrunk
1.16.1 1.16.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.10.0 1.11.0 1.11.1 1.11.2 1.11.3 1.11.4 1.11.5 1.12.0 1.13.0 1.14.0 1.15.0 1.2.0 1.3.0 1.3.1 1.3.2 All 45 releases
wpsynchro / src / API / ExecuteAction.php

ExecuteAction.php in WP Synchro – The Ultimate WordPress Migration Tool trunk, at src/API/ExecuteAction.php

45 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPSynchro\API;
4
5 use WPSynchro\Transport\ReturnResult;
6 use WPSynchro\Transport\Transfer;
7 use WPSynchro\Transport\TransferAccessKey;
8 use WPSynchro\Utilities\Actions\ClearCachesOnSuccess;
9 use WPSynchro\Utilities\Actions\ClearCurrentTransfer;
10 use WPSynchro\Utilities\Actions\ClearTransients;
11
12 /**
13 * Class for handling service "executeaction"
14 * Call should already be verified by permissions callback
15 */
16 class ExecuteAction extends WPSynchroService
17 {
18 public function service()
19 {
20 $result = new \stdClass();
21
22 // Get transfer object, so we can get data
23 $transfer = new Transfer();
24 $transfer->setEncryptionKey(TransferAccessKey::getAccessKey());
25 $transfer->populateFromString($this->getRequestBody());
26 $data = $transfer->getDataObject();
27 if (in_array("clearcaches", $data)) {
28 (new ClearCachesOnSuccess())->doAction([]);
29 }
30
31 if (in_array("cleartransfertoken", $data)) {
32 (new ClearCurrentTransfer())->doAction([]);
33 }
34
35 // Clear site transients, always, to prevent wrong data in transients after transfer
36 (new ClearTransients())->doAction([]);
37
38 // Return
39 $returnresult = new ReturnResult();
40 $returnresult->init();
41 $returnresult->setDataObject($result);
42 return $returnresult->echoDataFromServiceAndExit();
43 }
44 }
45