admin-menu-settings.html.php
5.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<div class="wrap">
<h1><?php esc_html_e( 'Settings', 'ninja-forms' ); ?></h1>
<h2 class="nav-tab-wrapper">
<?php foreach( $tabs as $tab => $name ): ?>
<?php if( $tab == $active_tab ): ?>
<span class="nav-tab nav-tab-active"><?php echo $name ?></span>
<?php else: ?>
<a href="<?php echo esc_url( add_query_arg( 'tab', $tab ) ); ?>" target="" class="nav-tab "><?php echo $name ?></a>
<?php endif; ?>
<?php endforeach; ?>
</h2>
<div id="poststuff">
<?php if( 'settings' != $active_tab ): ?>
<?php do_meta_boxes('nf_settings_' . $active_tab, 'advanced', NULL ); ?>
<?php else: ?>
<form action="" method="POST">
<?php if( $errors ): ?>
<?php foreach( $errors as $error_id => $error ): ?>
<?php $message = $error . " <a href='#$error_id'>" . esc_html__( 'Fix it.', 'ninja-forms' ) . '</a>'; ?>
<?php Ninja_Forms::template( 'admin-notice.html.php', array( 'class' => 'error', 'message' => $message ) ); ?>
<?php endforeach; ?>
<?php endif; ?>
<?php foreach( $grouped_settings as $group => $settings ) : ?>
<div id="ninja_forms_metabox_<?php echo $group; ?>_settings" class="postbox">
<span class="item-controls">
<a class="item-edit metabox-item-edit" id="edit_id" title="<?php esc_html_e( 'Edit Menu Item', 'ninja-forms' ); ?>" href="#"><?php esc_html_e( 'Edit Menu Item', 'ninja-forms' ); ?></a>
</span>
<h3 class="hndle"><span><?php echo $groups[ $group ][ 'label' ]; ?></span></h3>
<div class="inside" style="">
<table class="form-table">
<tbody>
<?php foreach( $settings as $key => $setting ) : ?>
<?php if( 'prompt' == $setting[ 'type' ] ) continue; ?>
<tr id="row_<?php echo $setting[ 'id' ]; ?>">
<th scope="row">
<label for="<?php echo $setting[ 'id' ]; ?>"><?php echo $setting[ 'label' ]; ?></label>
</th>
<td>
<?php
switch ( $setting[ 'type' ] ) {
case 'html':
echo $setting[ 'html'];
break;
case 'desc' :
echo $setting[ 'value' ];
break;
case 'textbox' :
echo "<input type='text' class='code widefat' name='{$setting['id']}' id='{$setting['id']}' value='" . esc_attr($setting['value']) . "'>";
break;
case 'password' :
echo "<input type='password' class='code widefat' name='{$setting['id']}' id='{$setting['id']}' value='" . esc_attr($setting['value']) . "'>";
break;
case 'checkbox' :
$checked = ( $setting[ 'value' ] ) ? 'checked' : '';
echo "<input type='hidden' name='{$setting['id']}' value='0'>";
echo "<input type='checkbox' name='{$setting['id']}' value='1' id='{$setting['id']}' class='widefat' $checked>";
break;
case 'select' :
echo "<select name='{$setting['id']}' id='{$setting['id']}'>";
foreach( $setting['options'] as $option ) {
$selected = ( $setting['value'] == $option['value'] ) ? 'selected="selected"' : '';
echo "<option value='{$option['value']}' {$selected}>{$option['label']}</option>";
}
echo "</select>";
break;
}
if( isset( $setting[ 'desc' ] ) ) {
echo "<p class='description'>" . $setting[ 'desc' ] . "</p>";
}
?>
<?php
if( isset( $setting[ 'errors' ] ) ){
foreach( $setting[ 'errors' ] as $error_id => $error ){
echo "<div id='$error_id' class='error'><p>$error</p></div>";
}
}
?>
</td>
</tr>
</tbody>
<?php endforeach; ?>
</table>
</div>
</div>
<?php endforeach; ?>
<input type="hidden" name="update_ninja_forms_settings_nonce" value="<?php echo wp_create_nonce( "ninja_forms_settings_nonce" ); ?>">
<input type="hidden" name="update_ninja_forms_settings">
<input type="submit" class="button button-primary" value="<?php echo $save_button_text; ?>">
</form>
<?php endif; ?>
</div>
</div>