-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcontrol.php
More file actions
176 lines (175 loc) · 5.81 KB
/
control.php
File metadata and controls
176 lines (175 loc) · 5.81 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
function bootstrap_add_admin() {
global $options;
$options = array (
array (
"name" => __ ( 'Navbar Brand', 'Bootstrap' ),
"id" => "navbar_brand",
"std" => get_bloginfo ( 'name' ),
"type" => "text"
),
array (
"name" => __ ( 'Subtext for Header', 'Bootstrap' ),
"id" => "subtext_for_header",
"std" => "",
"type" => "text"
),
array (
"name" => __ ( 'Navbar Color', 'Bootstrap' ),
"id" => "navbar_color",
"std" => "black",
"type" => "radio",
"list" => array (
"black" => __ ( 'Black', 'Bootstrap' ),
"white" => __ ( 'White', 'Bootstrap' )
)
),
array (
"name" => __ ( 'Analytics Code', 'Bootstrap' ),
"id" => "analytics_code",
"std" => "",
"type" => "textarea",
"label" => __ ( 'Enter your analytics codes or other html codes.', 'Bootstrap' )
),
array (
"name" => __ ( 'Footer Code', 'Bootstrap' ),
"id" => "footer_code",
"std" => "",
"type" => "textarea",
"label" => sprintf ( __ ( 'Enter your codes like this: %s', 'Bootstrap' ), '<li><a href="http://www.abc.com/">My Link</a></li>' )
)
);
if ( $_GET ['page'] == basename ( __FILE__ ) ) {
if ( 'save' == $_REQUEST ['action'] ) {
foreach ( $options as $value ) {
update_option ( $value ['id'], $_REQUEST [$value ['id']] );
}
foreach ( $options as $value ) {
if ( isset ( $_REQUEST [$value ['id']] ) ) {
update_option ( $value ['id'], $_REQUEST [$value ['id']] );
} else {
delete_option ( $value ['id'] );
}
}
header ( "Location: themes.php?page=control.php&saved=true" );
die ();
} else if ( 'reset' == $_REQUEST ['action'] ) {
foreach ( $options as $value ) {
delete_option ( $value ['id'] );
update_option ( $value ['id'], $value ['std'] );
}
header ( "Location: themes.php?page=control.php&reset=true" );
die ();
}
}
add_theme_page( __ ( 'Theme Setup', 'Bootstrap' ), __ ( 'Theme Setup', 'Bootstrap' ), 'edit_theme_options', basename ( __FILE__ ), 'bootstrap_admin' );
}
function bootstrap_admin() {
global $options;
if ( $_REQUEST ['saved'] )
echo '<div id="message" class="updated fade"><p>' . __ ( 'Your settings have been saved.', 'Bootstrap' ) . '</p></div>';
if ( $_REQUEST ['reset'] )
echo '<div id="message" class="updated fade"><p>' . __ ( 'Your settings have been reset.', 'Bootstrap' ) . '</p></div>';
?>
<div class="wrap">
<h2><?php _e ( 'Theme Setup', 'Bootstrap' ); ?></h2>
<form method="post">
<table class="form-table">
<tbody>
<?php
foreach ( $options as $value ) {
if ( $value ['type'] == "text" ) {
?>
<tr valign="top">
<th scope="row"><label><?php echo $value['name']; ?></label></th>
<td>
<input name="<?php echo $value['id']; ?>" class="regular-text ltr" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php echo stripslashes ( get_option ( $value['id'], $value['std'] )); ?>" size="40" />
<?php
if ( isset ( $value ['label'] ) && $value ['label'] != "" ) {
echo '<p class="description">' . $value ['label'] . '</p>';
}
?>
</td>
</tr>
<?php } elseif ( $value['type'] == "textarea" ) { ?>
<tr valign="top">
<th scope="row"><label><?php echo $value['name']; ?></label></th>
<td><textarea name="<?php echo $value['id']; ?>" class="widefat" rows="5"><?php echo stripslashes ( get_option ( $value['id'], $value['std'] ) ); ?></textarea>
<?php
if ( isset ( $value ['label'] ) && $value ['label'] != "" ) {
echo '<p class="description">' . $value ['label'] . '</p>';
}
?>
</td>
</tr>
<?php } elseif ( $value['type'] == "radio" ) { ?>
<tr valign="top">
<th scope="row"><label><?php echo $value['name']; ?></label></th>
<td>
<fieldset>
<?php
foreach ( $value['list'] as $key => $radio) {
?>
<label>
<input type="radio" name="<?php echo $value['id']; ?>" value="<?php echo $key; ?>"<?php if ( get_option ( $value['id'], $value['std'] ) == $key ) { ?> checked="checked"<?php } ?>/>
<span><?php echo $radio; ?></span>
</label>
<br>
<?php }?>
<?php
if ( isset ( $value ['label'] ) && $value ['label'] != "" ) {
echo '<p class="description">' . $value ['label'] . '</p>';
}
?>
</fieldset>
</td>
</tr>
<?php }?>
<?php } ?>
</tbody>
</table>
<div class="submit">
<input name="save" class="button button-primary" type="submit" value="<?php _e ( 'Save', 'Bootstrap' ); ?>" />
<input type="hidden" name="action" value="save" />
</div>
</form>
</div>
<div class="wrap">
<h2><?php _e ( 'Advanced Settings', 'Bootstrap' ); ?></h2>
<form method="post">
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row"><label><?php _e ( 'Reset Settings', 'Bootstrap' ); ?></label></th>
<td>
<input name="reset" class="button" type="submit" value="<?php _e ( 'Reset', 'Bootstrap' ); ?>" />
<input type="hidden" name="action" value="reset" />
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div class="wrap">
<h2 class="title"><?php _e ( 'About', 'Bootstrap' ); ?></h2>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row"><label><?php _e ( 'Theme Version', 'Bootstrap' ); ?></label></th>
<td><?php echo wp_get_theme() -> get( 'Version' ); ?></td>
</tr>
<tr valign="top">
<th scope="row"><label><?php _e ( 'Designer', 'Bootstrap' ); ?></label></th>
<td>Crexyer</td>
</tr>
<tr valign="top">
<th scope="row"><label><?php _e ( 'Technical Support', 'Bootstrap' ); ?></label></th>
<td><a href="http://www.crexyer.com/" target="_blank">http://www.crexyer.com/</a></td>
</tr>
</tbody>
</table>
</div>
<?php
}
add_action ( 'admin_menu', 'bootstrap_add_admin' );
?>