| Server IP : 162.214.67.83 / Your IP : 216.73.217.9 Web Server : Apache System : Linux dedi-13542965.clustter.com.br 5.14.0-687.20.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 30 06:22:49 EDT 2026 x86_64 User : pjacortinas ( 1096) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/pjacortinas/www/wp-content/plugins/formlayer/main/ |
Upload File : |
<?php
namespace FormLayer;
if(!defined('ABSPATH')){
exit;
}
class Util{
static function get_form_field_labels($form_id) {
$form = get_post($form_id);
$field_labels = [];
if ($form) {
$form_data = json_decode($form->post_content, true);
if (is_array($form_data) && !empty($form_data['fields'])) {
foreach ($form_data['fields'] as $field) {
$name = self::get_field_name($field);
$field_labels[$name] = !empty($field['label']) ? $field['label'] : $name;
}
}
}
return $field_labels;
}
static function get_form_field_types($form_id){
$form = get_post($form_id);
$field_types = [];
if(!empty($form)){
$form_data = json_decode($form->post_content, true);
if(is_array($form_data) && !empty($form_data['fields'])){
foreach($form_data['fields'] as $field){
$name = self::get_field_name($field);
$field_types[$name] = isset($field['type']) ? $field['type'] : 'text';
}
}
}
return $field_types;
}
static function get_field_name($field) {
if (!empty($field['name_attr'])) {
return $field['name_attr'];
}
$id = isset($field['id']) ? $field['id'] : sanitize_title(isset($field['label']) ? $field['label'] : '');
return 'field_' . $id;
}
static function get_post_id_by_display_id($display_id) {
$posts = get_posts([
'post_type' => 'formlayer_form',
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
'meta_query' => [
[
'key' => '_formlayer_display_id',
'value' => $display_id,
'compare' => '='
]
],
'posts_per_page' => 1,
'post_status' => 'any'
]);
return !empty($posts) ? $posts[0]->ID : 0;
}
}