GetMigratedFormId.php
2 years ago
MapSettingsToDesignHeader.php
2 years ago
MapSettingsToDonationSummary.php
2 years ago
TransferDonations.php
8 months ago
TransferFormUrl.php
2 years ago
TransferFormUrl.php
31 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\FormMigration\Actions; |
| 4 | |
| 5 | class TransferFormUrl |
| 6 | { |
| 7 | protected $sourceId; |
| 8 | |
| 9 | public function __construct($sourceId) |
| 10 | { |
| 11 | $this->sourceId = $sourceId; |
| 12 | } |
| 13 | |
| 14 | public static function from($sourceId): self |
| 15 | { |
| 16 | return new TransferFormUrl($sourceId); |
| 17 | } |
| 18 | |
| 19 | public function to($destinationId): void |
| 20 | { |
| 21 | $this->__invoke($destinationId); |
| 22 | } |
| 23 | |
| 24 | public function __invoke($destinationId) |
| 25 | { |
| 26 | $postName = get_post($this->sourceId)->post_name; |
| 27 | wp_update_post(['ID' => $this->sourceId, 'post_name' => $postName . '-v2']); |
| 28 | wp_update_post(['ID' => $destinationId, 'post_name' => $postName]); |
| 29 | } |
| 30 | } |
| 31 |