← All changes
|
includes/fields/class-charitable-campaign-field.php
+42
-36
1.6.7
→
1.8.13
View file →
| @@ -2,13 +2,13 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Charitable_Campaign_Field model. |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Classes/Charitable_Campaign_Field |
| 6 | - * @author Eric Daams | |
| 7 | - * @copyright Copyright (c) 2018, Studio 164a | |
| 6 | + * @author David Bisset | |
| 7 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @since 1.6.0 |
| 10 | - * @version 1.6.0 | |
| 10 | + * @version 1.6.25 | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | * @property string $label |
| 27 | 27 | * @property string $data_type |
| 28 | 28 | * @property false|callable $value_callback |
| 29 | 29 | * @property boolean|array $admin_form |
| 30 | - * @property boolean|array $ambassadors_form | |
| 30 | + * @property boolean|array $campaign_form | |
| 31 | 31 | * @property boolean $show_in_export |
| 32 | 32 | * @property boolean|array $email_tag |
| 33 | 33 | */ |
| 34 | 34 | class Charitable_Campaign_Field extends Charitable_Field implements Charitable_Field_Interface { |
| @@ -49,14 +49,14 @@ | ||
| 49 | 49 | * |
| 50 | 50 | * @var array $args { |
| 51 | 51 | * Array of field arguments. |
| 52 | 52 | * |
| 53 | - * @type string $label The label to use in the export, meta, Ambassadors form (unless overridden), admin | |
| 54 | - * form (unless overriden) and email tag (unless overridden). | |
| 55 | - * If no `label` is provided in the ambassadors_form args, this label will be used in | |
| 56 | - * the Ambassadors form. If no `label` is provided in the admin_form args, this label | |
| 57 | - * will also be used in the admin form. Unless a `description` is set in the `email_tag` | |
| 58 | - * args, this label will also be used there as the tag description. | |
| 53 | + * @type string $label The label to use in the export, meta, Ambassadors campaign form (unless overridden), | |
| 54 | + * admin form (unless overriden) and email tag (unless overridden). | |
| 55 | + * If no `label` is provided in the campaign_form args, this label will be used in | |
| 56 | + * the Ambassadors campaign form. If no `label` is provided in the admin_form args, this | |
| 57 | + * label will also be used in the admin form. Unless a `description` is set in the | |
| 58 | + * `email_tag` args, this label will also be used there as the tag description. | |
| 59 | 59 | * @type string $data_type How the data should be saved. This may be set to 'meta' or 'core', through 'core' |
| 60 | 60 | * is designed stricly for core Charitable use. |
| 61 | 61 | * @type false|callable $value_callback A callback function to retrieve the value of the field for a campaign. |
| 62 | 62 | * The callback function receives up to two arguments: a `Charitable_Campaign` object |
| @@ -100,10 +100,10 @@ | ||
| 100 | 100 | * instead for fine-grained control. |
| 101 | 101 | * @type false|callable $value_callback A callback function to retrieve the value of the field for a campaign. |
| 102 | 102 | * This will override the `value_callback` setting for the field. |
| 103 | 103 | * } |
| 104 | - * @type boolean|array $ambassadors_form { | |
| 105 | - * Sets whether the field should be shown in the Ambassadors form. To prevent the field being available | |
| 104 | + * @type boolean|array $campaign_form { | |
| 105 | + * Sets whether the field should be shown in the Ambassadors campaign form. To prevent the field being available | |
| 106 | 106 | * in the form (not even as a hidden input), set to false. If set to true, the form field will inherit arguments |
| 107 | 107 | * from the `admin_form` (if provided), or use default arguments. For control over how the field should be |
| 108 | 108 | * shown in the form, an array can be passed with the same keys as described for `admin_form` above. |
| 109 | 109 | * } |
| @@ -129,15 +129,15 @@ | ||
| 129 | 129 | * @return array |
| 130 | 130 | */ |
| 131 | 131 | protected function get_defaults() { |
| 132 | 132 | return array( |
| 133 | - 'label' => '', | |
| 134 | - 'data_type' => 'meta', | |
| 135 | - 'value_callback' => false, | |
| 136 | - 'ambassadors_form' => true, | |
| 137 | - 'admin_form' => true, | |
| 138 | - 'show_in_export' => true, | |
| 139 | - 'email_tag' => true, | |
| 133 | + 'label' => '', | |
| 134 | + 'data_type' => 'meta', | |
| 135 | + 'value_callback' => false, | |
| 136 | + 'campaign_form' => true, | |
| 137 | + 'admin_form' => true, | |
| 138 | + 'show_in_export' => true, | |
| 139 | + 'email_tag' => true, | |
| 140 | 140 | ); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
| @@ -159,9 +159,9 @@ | ||
| 159 | 159 | return $value; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | - * Sanitize the ambassadors_form setting. | |
| 163 | + * Sanitize the campaign_form setting. | |
| 164 | 164 | * |
| 165 | 165 | * @since 1.6.0 |
| 166 | 166 | * |
| 167 | 167 | * @param mixed $value The argument setting. |
| @@ -166,16 +166,19 @@ | ||
| 166 | 166 | * |
| 167 | 167 | * @param mixed $value The argument setting. |
| 168 | 168 | * @return boolean|array |
| 169 | 169 | */ |
| 170 | - protected function sanitize_ambassadors_form( $value ) { | |
| 171 | - return $this->sanitize_form_arg( $value, array( | |
| 172 | - 'type' => 'text', | |
| 173 | - 'required' => false, | |
| 174 | - 'fullwidth' => false, | |
| 175 | - 'default' => '', | |
| 176 | - 'attrs' => array(), | |
| 177 | - ) ); | |
| 170 | + protected function sanitize_campaign_form( $value ) { | |
| 171 | + return $this->sanitize_form_arg( | |
| 172 | + $value, | |
| 173 | + array( | |
| 174 | + 'type' => 'text', | |
| 175 | + 'required' => false, | |
| 176 | + 'fullwidth' => false, | |
| 177 | + 'default' => '', | |
| 178 | + 'attrs' => array(), | |
| 179 | + ) | |
| 180 | + ); | |
| 178 | 181 | } |
| 179 | 182 | |
| 180 | 183 | /** |
| 181 | 184 | * Sanitize the admin_form setting. |
| @@ -185,16 +188,19 @@ | ||
| 185 | 188 | * @param mixed $value The argument setting. |
| 186 | 189 | * @return boolean|array |
| 187 | 190 | */ |
| 188 | 191 | public function sanitize_admin_form( $value ) { |
| 189 | - return $this->sanitize_form_arg( $value, array( | |
| 190 | - 'type' => 'text', | |
| 191 | - 'required' => false, | |
| 192 | - 'fullwidth' => false, | |
| 193 | - 'default' => '', | |
| 194 | - 'attrs' => array(), | |
| 195 | - 'section' => charitable()->campaign_fields()->get_default_section( 'admin' ), | |
| 196 | - ) ); | |
| 192 | + return $this->sanitize_form_arg( | |
| 193 | + $value, | |
| 194 | + array( | |
| 195 | + 'type' => 'text', | |
| 196 | + 'required' => false, | |
| 197 | + 'fullwidth' => false, | |
| 198 | + 'default' => '', | |
| 199 | + 'attrs' => array(), | |
| 200 | + 'section' => charitable()->campaign_fields()->get_default_section( 'admin' ), | |
| 201 | + ) | |
| 202 | + ); | |
| 197 | 203 | } |
| 198 | 204 | } |
| 199 | 205 | |
| 200 | 206 | endif; |