| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
|
| 4 |
$tab_slug = isset($current_tab) ? $current_tab : 'user_data'; |
| 5 |
|
| 6 |
|
| 7 |
// assume this file is in the plugin root and fields/ is sibling |
| 8 |
include EASYELEMENTS_DIR_PATH . "includes/Admin/settings-framework/init.php"; |
| 9 |
$fields_dir = __DIR__ . '../settings-framework/fields'; |
| 10 |
|
| 11 |
$fm = new Easyel_FieldManager($fields_dir); |
| 12 |
|
| 13 |
|
| 14 |
$settings = get_option('easy_element_user_data', []); |
| 15 |
$settings_sections = [ |
| 16 |
[ |
| 17 |
'id' => 'social_feeds', |
| 18 |
'label' => 'Social Feeds', |
| 19 |
], |
| 20 |
]; |
| 21 |
$settings_fields = [ |
| 22 |
[ |
| 23 |
'section_id' => 'social_feeds', |
| 24 |
'id' => 'fb_config', |
| 25 |
'name' => 'fb_config', |
| 26 |
'label' => 'Facebook', |
| 27 |
'type' => 'fields_group', |
| 28 |
'options' => [ |
| 29 |
[ 'id' => 'page_id', 'name' => 'page_id', 'type' => 'text', 'default' => '', 'placeholder' => 'Page ID' ], |
| 30 |
[ 'id' => 'page_access_token', 'name' => 'page_access_token', 'type' => 'text', 'default' => '', 'class' => 'w-100', 'placeholder' => 'Page Access Token' ], |
| 31 |
], |
| 32 |
'value' => !empty($settings['fb_config']) ? $settings['fb_config'] : [], |
| 33 |
'default' => '', |
| 34 |
], |
| 35 |
[ |
| 36 |
'section_id' => 'social_feeds', |
| 37 |
'id' => 'insta_config', |
| 38 |
'name' => 'insta_config', |
| 39 |
'label' => 'Instagram', |
| 40 |
'type' => 'fields_group', |
| 41 |
'options' => [ |
| 42 |
[ 'id' => 'username', 'name' => 'username', 'type' => 'text', 'default' => '', 'placeholder' => 'easy_elements' ], |
| 43 |
[ 'id' => 'page_access_token', 'name' => 'page_access_token', 'type' => 'text', 'default' => '', 'class' => 'w-100', 'placeholder' => 'Access Token' ], |
| 44 |
], |
| 45 |
'value' => !empty($settings['insta_config']) ? $settings['insta_config'] : [], |
| 46 |
'default' => '', |
| 47 |
], |
| 48 |
]; |
| 49 |
?> |
| 50 |
<div class="easyel-settings-wrapper"> |
| 51 |
<div class="easyel-settings-topbar"> |
| 52 |
<h3 class="easyel-settings-title"><?php echo esc_html__( 'Settings', 'easy-elements' )?></h3> |
| 53 |
<div class="easyel-settings-actions"> |
| 54 |
<button type="button" id="easyel-settings-save">Save</button> |
| 55 |
</div> |
| 56 |
</div> |
| 57 |
<form id="easyel-settings-form" class="easyel-settings-wrapper"> |
| 58 |
<div class="easyel-settings-fields"> |
| 59 |
<?php foreach ( $settings_sections as $section ) : ?> |
| 60 |
<div class="easyel-settings-section" id="section-<?php echo esc_attr($section['id']); ?>"> |
| 61 |
<h3 class="easyel-section-title"><?php echo esc_html( $section['label'] ); ?></h3> |
| 62 |
|
| 63 |
<?php foreach ( $settings_fields as $field ) : |
| 64 |
if($field['section_id'] !== $section['id']) continue; |
| 65 |
?> |
| 66 |
|
| 67 |
<?php |
| 68 |
// Fields Group |
| 69 |
if ($field['type'] === 'fields_group') { |
| 70 |
?> |
| 71 |
<div class="easyel-settings-field"> |
| 72 |
<div class="easyel-settings-field-label"><?php echo esc_html($field['label']); ?></div> |
| 73 |
<div class="easyel-settings-field-inputs"> |
| 74 |
<div class="easyel-settings-field-input-wrapper"> |
| 75 |
<?php $fm->render_fields_group($field, $settings); ?> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
<?php |
| 80 |
} else { |
| 81 |
|
| 82 |
// Single Field Support |
| 83 |
$name = $field['name']; |
| 84 |
$value = $settings[$name] ?? ($field['default'] ?? ''); |
| 85 |
$field['full_name'] = $name; |
| 86 |
?> |
| 87 |
<div class="easyel-settings-field"> |
| 88 |
<div class="easyel-settings-field-label"><?php echo esc_html($field['label']); ?></div> |
| 89 |
<div class="easyel-settings-field-inputs"> |
| 90 |
<div class="easyel-settings-field-input-wrapper"> |
| 91 |
<?php $fm->render_field($field, $value, ['name'=>$name, 'settings'=>$settings]); ?> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
</div> |
| 95 |
<?php } ?> |
| 96 |
|
| 97 |
<?php endforeach; ?> |
| 98 |
|
| 99 |
</div> |
| 100 |
<?php endforeach; ?> |
| 101 |
</div> |
| 102 |
</form> |
| 103 |
</div> |