| 1 | <?php |
||
| 12 | class Give_Form_API { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * The defaults for all elements |
||
| 16 | * |
||
| 17 | * @since 1.9 |
||
| 18 | * @access static |
||
| 19 | */ |
||
| 20 | static $field_defaults = array( |
||
| 21 | 'name' => '', |
||
| 22 | 'desc' => '', |
||
| 23 | 'id' => '', |
||
| 24 | 'type' => '', |
||
| 25 | 'default' => '', |
||
| 26 | 'data_type' => '', |
||
| 27 | 'options' => array(), |
||
| 28 | 'attributes' => array(), |
||
| 29 | ); |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Initialize this module |
||
| 33 | * |
||
| 34 | * @since 1.9 |
||
| 35 | * @access static |
||
| 36 | */ |
||
| 37 | static function init() { |
||
| 39 | |||
| 40 | |||
| 41 | /** |
||
| 42 | * Return HTML with tag $tagname and keyed attrs $attrs. |
||
| 43 | * |
||
| 44 | * @since 1.9 |
||
| 45 | * @access static |
||
| 46 | */ |
||
| 47 | static function make_tag() { |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Get elements from a form. |
||
| 52 | * |
||
| 53 | * @since 1.9 |
||
| 54 | * @access static |
||
| 55 | * |
||
| 56 | * @param array $form |
||
| 57 | */ |
||
| 58 | static function get_elements( $form ) { |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Is the element a button? |
||
| 63 | * |
||
| 64 | * @since 1.9 |
||
| 65 | * @access static |
||
| 66 | * |
||
| 67 | * @param array $element |
||
| 68 | * |
||
| 69 | * @return bool |
||
| 70 | */ |
||
| 71 | static function is_button( $element ) { |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Render forms. |
||
| 77 | * |
||
| 78 | * @since 1.9 |
||
| 79 | * @access static |
||
| 80 | */ |
||
| 81 | static function render_form() { |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Render an element |
||
| 86 | * @since 1.9 |
||
| 87 | * @access static |
||
| 88 | */ |
||
| 89 | static function render_element() { |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Process a form, filling in $values with what's been posted |
||
| 94 | * |
||
| 95 | * @since 1.9 |
||
| 96 | * @access static |
||
| 97 | */ |
||
| 98 | static function process_form() { |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Recursively process a meta form element, filling in $values accordingly |
||
| 103 | * |
||
| 104 | * @since 1.9 |
||
| 105 | * @access static |
||
| 106 | */ |
||
| 107 | static function process_element() { |
||
| 109 | } |
||
| 110 | |||
| 112 | add_action( 'init', array( 'Give_Form_API', 'init' ) ); |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.