PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.2
GiveWP – Donation Plugin and Fundraising Platform v4.15.2
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / FormMigration / Steps / PdfSettings.php
PdfSettings.php
58 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\FormMigration\Steps;
4
5 use Give\FormMigration\Contracts\FormMigrationStep;
6
7 /**
8 * @since 3.0.0
9 */
10 class PdfSettings extends FormMigrationStep
11 {
12 /**
13 * @since 3.0.0
14 */
15 public function process()
16 {
17 $oldFormId = $this->formV2->id;
18 $newForm = $this->formV3;
19
20 $pdfSettings = [
21 'enable' => $this->getMetaValue($oldFormId, 'give_pdf_receipts_enable_disable', 'global'),
22 'generationMethod' => $this->getMetaValue($oldFormId, 'give_pdf_generation_method', 'set_pdf_templates'),
23 'colorPicker' => $this->getMetaValue($oldFormId, 'give_pdf_colorpicker', '#1E8CBE'),
24 'templateId' => $this->getMetaValue($oldFormId, 'give_pdf_templates', 'default'),
25 'logoUpload' => $this->getMetaValue($oldFormId, 'give_pdf_logo_upload', ''),
26 'name' => $this->getMetaValue($oldFormId, 'give_pdf_company_name', ''),
27 'addressLine1' => $this->getMetaValue($oldFormId, 'give_pdf_address_line1', ''),
28 'addressLine2' => $this->getMetaValue($oldFormId, 'give_pdf_address_line2', ''),
29 'cityStateZip' => $this->getMetaValue($oldFormId, 'give_pdf_address_city_state_zip', ''),
30 'displayWebsiteUrl' => $this->getMetaValue($oldFormId, 'give_pdf_url', ''),
31 'emailAddress' => $this->getMetaValue($oldFormId, 'give_pdf_email_address', ''),
32 'headerMessage' => $this->getMetaValue($oldFormId, 'give_pdf_header_message', ''),
33 'footerMessage' => $this->getMetaValue($oldFormId, 'give_pdf_footer_message', ''),
34 'additionalNotes' => $this->getMetaValue($oldFormId, 'give_pdf_additional_notes', ''),
35 'customTemplateId' => $this->getMetaValue($oldFormId, 'give_pdf_receipt_template', ''),
36 'customTemplateName' => $this->getMetaValue($oldFormId, 'give_pdf_receipt_template_name', ''),
37 'customPageSize' => $this->getMetaValue($oldFormId, 'give_pdf_builder_page_size', ''),
38 'customPdfBuilder' => $this->getMetaValue($oldFormId, 'give_pdf_builder', ''),
39 ];
40
41 $newForm->settings->pdfSettings = $pdfSettings;
42 }
43
44 /**
45 * @since 3.0.0
46 */
47 private function getMetaValue(int $formId, string $metaKey, $defaultValue)
48 {
49 $metaValue = give()->form_meta->get_meta($formId, $metaKey, true);
50
51 if ( ! $metaValue) {
52 return $defaultValue;
53 }
54
55 return $metaValue;
56 }
57 }
58