get_special_noptin_form_fields()
Returns a list of all form fields.
Return Return
(array) An array of subscriber fields.
Source Source
File: includes/functions.php
function get_special_noptin_form_fields() { // array of fields. $fields = array(); // Retrieve subscription forms. $forms = get_posts( array( 'numberposts' => -1, 'post_status' => array( 'draft', 'publish' ), 'post_type' => 'noptin-form', 'fields' => 'ids', ) ); // Ignore some fields. $to_ignore = array( 'email', 'first_name', 'last_name', 'name', 'GDPR_consent' ); $to_ignore = apply_filters( 'noptin_special_fields_to_ignore', $to_ignore ); foreach ( $forms as $form ) { // Retrieve state. $state = get_post_meta( $form, '_noptin_state', true ); if ( ! is_array( $state ) ) { continue; } if ( empty( $state['fields'] ) || ! is_array( $state['fields'] ) ) { continue; } foreach ( $state['fields'] as $field ) { $name = $field['type']['name']; $type = $field['type']['type']; $label = $field['type']['label']; if ( in_array( $name, $to_ignore, true ) || in_array( $type, $to_ignore, true ) ) { continue; } if ( 'text' !== $name && 'checkbox' !== $type ) { $label = $name; } $fields[ $name ] = array( $type, $label ); } } return apply_filters( 'special_noptin_form_fields', $fields ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.3.1 | Introduced. |