$field ) { $key = ! empty( $field['id'] ) ? (string) $field['id'] : (string) $field_id; $values[ $key ] = isset( $field['value'] ) ? $field['value'] : ''; } AOLI_Form_Processor::process( 'wpforms', (string) $form_data['id'], $values ); } /** * Get available WPForms forms. * * @return array */ public static function get_forms() { if ( ! function_exists( 'wpforms' ) && ! post_type_exists( 'wpforms' ) ) { return array(); } $posts = get_posts( array( 'post_type' => 'wpforms', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', ) ); $forms = array(); foreach ( $posts as $post ) { $forms[ $post->ID ] = $post->post_title; } return $forms; } /** * Get form field names. * * @param int $form_id Form ID. * @return array */ public static function get_form_fields( $form_id ) { $form_id = absint( $form_id ); if ( ! $form_id ) { return array(); } $form_post = get_post( $form_id ); if ( ! $form_post || 'wpforms' !== $form_post->post_type ) { return array(); } $content = json_decode( $form_post->post_content, true ); if ( empty( $content['fields'] ) || ! is_array( $content['fields'] ) ) { return array(); } $fields = array(); foreach ( $content['fields'] as $field ) { if ( empty( $field['id'] ) || empty( $field['label'] ) ) { continue; } $fields[ (string) $field['id'] ] = $field['label']; } return $fields; } }