default-design
5 months ago
popup
5 months ago
slidein
3 years ago
sshare
5 months ago
class-hustle-meta-base-content.php
3 years ago
class-hustle-meta-base-design.php
3 years ago
class-hustle-meta-base-display.php
6 years ago
class-hustle-meta-base-emails.php
4 months ago
class-hustle-meta-base-integrations.php
3 years ago
class-hustle-meta-base-settings.php
3 years ago
class-hustle-meta-base-visibility.php
5 months ago
class-hustle-meta-base-emails.php
126 lines
| 1 | <?php |
| 2 | /** |
| 3 | * File for Hustle_Meta_Base_Emails class. |
| 4 | * |
| 5 | * @package Hustle |
| 6 | * @since 4.2.0 |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * Hustle_Meta_Base_Emails is the base class for the "emails" meta of modules. |
| 11 | * This class should handle what's related to the "emails" meta. |
| 12 | * |
| 13 | * @since 4.2.0 |
| 14 | */ |
| 15 | class Hustle_Meta_Base_Emails extends Hustle_Meta { |
| 16 | |
| 17 | /** |
| 18 | * Returns the defaults for merging purposes. |
| 19 | * Avoid overwritting the saved form elements when the default fields aren't present. |
| 20 | * |
| 21 | * @since 4.4.1 |
| 22 | * |
| 23 | * @return array |
| 24 | */ |
| 25 | protected function get_defaults_for_merge() { |
| 26 | $defaults = $this->get_defaults(); |
| 27 | |
| 28 | // Avoid overwritting the saved form elements when the default fields aren't present. |
| 29 | if ( isset( $defaults['form_elements'] ) && ! empty( $this->data['form_elements'] ) ) { |
| 30 | unset( $defaults['form_elements'] ); |
| 31 | } |
| 32 | return $defaults; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Get the defaults for this meta. |
| 37 | * |
| 38 | * @since 4.2.0 |
| 39 | * |
| 40 | * @return array |
| 41 | */ |
| 42 | public function get_defaults() { |
| 43 | return array( |
| 44 | 'form_elements' => $this->get_default_form_fields(), |
| 45 | 'after_successful_submission' => 'show_success', |
| 46 | 'success_message' => '', |
| 47 | 'auto_close_success_message' => '0', |
| 48 | 'auto_close_time' => 5, |
| 49 | 'auto_close_unit' => 'seconds', |
| 50 | 'redirect_url' => '', |
| 51 | 'automated_email' => '0', |
| 52 | 'email_time' => 'instant', |
| 53 | 'recipient' => '{email}', |
| 54 | 'notification_email_recipient' => get_option( 'admin_email' ), |
| 55 | 'notification_email' => '0', |
| 56 | 'notification_email_subject' => '', |
| 57 | 'notification_email_body' => '', |
| 58 | 'day' => '', |
| 59 | 'time' => '', |
| 60 | 'auto_email_time' => '5', |
| 61 | 'schedule_auto_email_time' => '5', |
| 62 | 'auto_email_unit' => 'seconds', |
| 63 | 'schedule_auto_email_unit' => 'seconds', |
| 64 | 'email_subject' => '', |
| 65 | 'email_body' => '', |
| 66 | 'automated_file' => '0', |
| 67 | 'auto_download_file' => '', |
| 68 | 'redirect_tab' => '', |
| 69 | ); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Default form fields for new modules. |
| 74 | * |
| 75 | * @since the beginning of time |
| 76 | * |
| 77 | * @return array |
| 78 | */ |
| 79 | public static function get_default_form_fields() { |
| 80 | |
| 81 | $default_fields = array( |
| 82 | 'first_name' => array( |
| 83 | 'required' => 'false', |
| 84 | 'label' => __( 'First Name', 'hustle' ), |
| 85 | 'name' => 'first_name', |
| 86 | 'type' => 'name', |
| 87 | 'placeholder' => 'John', |
| 88 | 'can_delete' => true, |
| 89 | ), |
| 90 | 'last_name' => array( |
| 91 | 'required' => 'false', |
| 92 | 'label' => __( 'Last Name', 'hustle' ), |
| 93 | 'name' => 'last_name', |
| 94 | 'type' => 'name', |
| 95 | 'placeholder' => 'Smith', |
| 96 | 'can_delete' => true, |
| 97 | ), |
| 98 | 'email' => array( |
| 99 | 'required' => 'true', |
| 100 | 'label' => __( 'Your email', 'hustle' ), |
| 101 | 'name' => 'email', |
| 102 | 'type' => 'email', |
| 103 | 'placeholder' => 'johnsmith@example.com', |
| 104 | 'validate' => 'true', |
| 105 | 'can_delete' => false, |
| 106 | ), |
| 107 | 'submit' => array( |
| 108 | 'required' => 'true', |
| 109 | 'label' => __( 'Submit', 'hustle' ), |
| 110 | 'error_message' => __( 'Something went wrong, please try again.', 'hustle' ), |
| 111 | 'name' => 'submit', |
| 112 | 'type' => 'submit', |
| 113 | 'placeholder' => __( 'Subscribe', 'hustle' ), |
| 114 | 'can_delete' => false, |
| 115 | ), |
| 116 | ); |
| 117 | |
| 118 | /** |
| 119 | * Filter the form fields that are added by default when creating a new module |
| 120 | * |
| 121 | * @since 4.2.0 |
| 122 | */ |
| 123 | return apply_filters( 'hustle_get_module_default_form_fields', $default_fields ); |
| 124 | } |
| 125 | } |
| 126 |