| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin form model class. |
| 4 |
* |
| 5 |
* @package Charitable/Classes/Charitable_Admin_Form |
| 6 |
* @author Eric Daams |
| 7 |
* @copyright Copyright (c) 2019, Studio 164a |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.5.0 |
| 10 |
* @version 1.5.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
// Exit if accessed directly. |
| 14 |
if ( ! defined( 'ABSPATH' ) ) { exit; } |
| 15 |
|
| 16 |
if ( ! class_exists( 'Charitable_Admin_Form' ) ) : |
| 17 |
|
| 18 |
/** |
| 19 |
* Charitable_Admin_Form |
| 20 |
* |
| 21 |
* @since 1.5.0 |
| 22 |
*/ |
| 23 |
class Charitable_Admin_Form extends Charitable_Form { |
| 24 |
|
| 25 |
/** |
| 26 |
* Fields in the form. |
| 27 |
* |
| 28 |
* @since 1.5.0 |
| 29 |
* |
| 30 |
* @var array |
| 31 |
*/ |
| 32 |
protected $fields = array(); |
| 33 |
|
| 34 |
/** |
| 35 |
* Return the Form_View object for this form. |
| 36 |
* |
| 37 |
* @since 1.5.0 |
| 38 |
* |
| 39 |
* @return Charitable_Form_View_Interface |
| 40 |
*/ |
| 41 |
public function view() { |
| 42 |
if ( ! isset( $this->view ) ) { |
| 43 |
$this->view = new Charitable_Admin_Form_View( $this ); |
| 44 |
} |
| 45 |
|
| 46 |
return $this->view; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Returns hidden fields to be added to the form. |
| 51 |
* |
| 52 |
* @since 1.5.0 |
| 53 |
* |
| 54 |
* @return array |
| 55 |
*/ |
| 56 |
public function get_hidden_fields() { |
| 57 |
$fields = parent::get_hidden_fields(); |
| 58 |
|
| 59 |
unset( |
| 60 |
$fields['_wp_http_referer'], |
| 61 |
$fields[ $this->nonce_name ] |
| 62 |
); |
| 63 |
|
| 64 |
return $fields; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Set the form fields. |
| 69 |
* |
| 70 |
* @since 1.5.0 |
| 71 |
* |
| 72 |
* @param array $fields An array of fields to be displayed. |
| 73 |
* @return void |
| 74 |
*/ |
| 75 |
public function set_fields( array $fields ) { |
| 76 |
uasort( $fields, 'charitable_priority_sort' ); |
| 77 |
$this->fields = $fields; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Return the fields. |
| 82 |
* |
| 83 |
* @since 1.5.0 |
| 84 |
* |
| 85 |
* @return array |
| 86 |
*/ |
| 87 |
public function get_fields() { |
| 88 |
return $this->fields; |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
endif; |
| 93 |
|