| @@ -1,5 +1,6 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | /** |
| 3 | 4 | * Get set Form,fields |
| 4 | 5 | */ |
| 5 | 6 | |
| @@ -11,19 +12,42 @@ | ||
| 11 | 12 | use BitCode\BitForm\Core\Form\FormManager; |
| 12 | 13 | |
| 13 | 14 | final class AdminFormManager extends FormManager |
| 14 | 15 | { |
| 15 | - public function __construct($form_id) | |
| 16 | - { | |
| 17 | - parent::__construct($form_id); | |
| 16 | + public function __construct($form_id) | |
| 17 | + { | |
| 18 | + parent::__construct($form_id); | |
| 19 | + } | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * Pinned to raw: the builder saves back what it reads, so a translated string | |
| 23 | + * reaching it would overwrite the stored source language. | |
| 24 | + * | |
| 25 | + * @return string | |
| 26 | + */ | |
| 27 | + protected function getEffectiveFormContentJson() | |
| 28 | + { | |
| 29 | + // $this->form is a WP_Error when the form was not found; indexing it here | |
| 30 | + // fataled for callers that pass an unknown or empty form id | |
| 31 | + $raw = $this->isExist() ? ($this->form[0]->form_content ?? '') : ''; | |
| 32 | + return is_string($raw) ? $raw : ''; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public function getFormMetaData() | |
| 36 | + { | |
| 37 | + if (!$this->isExist()) { | |
| 38 | + return [ | |
| 39 | + 'created_at' => null, | |
| 40 | + 'views' => null, | |
| 41 | + 'entries' => null, | |
| 42 | + 'status' => null | |
| 43 | + ]; | |
| 18 | 44 | } |
| 19 | 45 | |
| 20 | - public function getFormMetaData(){ | |
| 21 | - return [ | |
| 22 | - "created_at" => static::$form[0]->created_at, | |
| 23 | - "views" => static::$form[0]->views, | |
| 24 | - "entries" => static::$form[0]->entries, | |
| 25 | - "status" => static::$form[0]->status | |
| 26 | - ]; | |
| 27 | - } | |
| 46 | + return [ | |
| 47 | + 'created_at' => $this->form[0]->created_at, | |
| 48 | + 'views' => $this->form[0]->views, | |
| 49 | + 'entries' => $this->form[0]->entries, | |
| 50 | + 'status' => $this->form[0]->status | |
| 51 | + ]; | |
| 52 | + } | |
| 28 | 53 | } |
| 29 | - | |