-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathoptions.php
405 lines (344 loc) · 12.3 KB
/
options.php
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<?php
add_action( 'admin_menu', 'comicpress_options_setup' );
function comicpress_options_setup() {
$options_title = __( 'Options', 'comicpress' );
$admin_title = __( 'ComicPress Options', 'comicpress' );
$pagehook = add_theme_page( $admin_title, $admin_title, 'edit_theme_options', 'comicpress-options', 'comicpress_admin_options' );
add_action( 'admin_head-' . $pagehook, 'comicpress_admin_page_head' );
add_action( 'admin_print_scripts-' . $pagehook, 'comicpress_admin_print_scripts' );
add_action( 'admin_print_styles-' . $pagehook, 'comicpress_admin_print_styles' );
}
function comicpress_admin_print_scripts() {
wp_enqueue_script( 'utils' );
wp_enqueue_script( 'jquery' );
}
function comicpress_admin_print_styles() {
wp_admin_css( 'css/global' );
wp_admin_css( 'css/colors' );
wp_admin_css( 'css/ie' );
wp_enqueue_style( 'comicpress-options-style', get_template_directory_uri() . '/options/options.css' );
}
function comicpress_admin_page_head() {
?>
<!--[if lt ie 8]> <style> div.show { position: static; margin-top: 1px; } #eadmin div.off { height: 22px; } </style> <![endif]-->
<?php
}
function comicpress_admin_options() {
?>
<div class="wrap">
<div id="eadmin-headericon" style="background: url('<?php echo get_template_directory_uri(); ?>/images/comicpress-rascal.png') no-repeat;"></div>
<h2>
<?php _e( 'ComicPress Options', 'comicpress' ); ?>
</h2>
<?php _e( 'ComicPress is a modular theme that has an abundance of hooks and actions placed in it for additional usability. Ref: Comic Easel', 'comicpress' ); ?>
<br />
<?php _e( 'While ComicPress is an excellent stand-alone theme, it can be enhanced in usability with the associated plugins that have been built to utilize its functionality.', 'comicpress' ); ?>
<br />
<div class="clear"></div>
<?php
if ( isset( $_GET['tab'] ) ) {
$tab = wp_filter_nohtml_kses( $_GET['tab'] );
} else {
$tab = '';
};
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'comicpress_reset' ) {
delete_option( 'cp-options' );
global $comicpress_themeinfo;
$comicpress_themeinfo = '';
?>
<div id="message" class="updated">
<p>
<strong>
<?php _e( 'ComicPress Settings RESET!', 'comicpress' ); ?>
</strong>
</p>
</div>
<?php
}
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'comicpress_reset_customize' ) {
remove_theme_mod( 'comicpress-customize' );
delete_option( 'theme_mods_comicpress ' );
global $comicpress_themeinfo;
$comicpress_themeinfo = '';
?>
<div id="message" class="updated">
<p>
<strong>
<?php _e( 'ComicPress Customizer Colors RESET!', 'comicpress' ); ?>
</strong>
</p>
</div>
<?php
}
if ( empty( $comicpress_options ) ) {
comicpress_themeinfo( 'reset' );
}
$comicpress_options = comicpress_load_options();
if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'update-options' ) ) {
if ( $_REQUEST['action'] == 'comicpress_save_general' ) {
foreach ( array(
'disable_scroll_to_top', // General.
'enable_post_thumbnail_rss', // General.
'disable_footer_text', // General.
'disable_blog_on_homepage', // General.
'over-blog-sidebar-all-posts', // General.
) as $key ) {
if ( ! isset( $_REQUEST[$key] ) ) $_REQUEST[$key] = 0;
$comicpress_options[$key] = (bool) ( $_REQUEST[$key] == 1 ? true : false );
}
foreach ( array(
'home_post_count', // General.
'copyright_name', // General.
'copyright_url', // General.
) as $key ) {
if ( isset( $_REQUEST[$key] ) )
$comicpress_options[$key] = wp_filter_nohtml_kses( $_REQUEST[$key] );
}
$tab = 'general';
update_option( 'cp-options', $comicpress_options );
}
if ( $_REQUEST['action'] == 'comicpress_save_menubar' ) {
foreach ( array(
'disable_jquery_menu_code',
'disable_default_menubar',
'enable_search_in_menubar',
'enable_rss_in_menubar',
'menubar_social_icons',
'enable_breadcrumbs',
) as $key ) {
if ( ! isset( $_REQUEST[$key] ) ) $_REQUEST[$key] = 0;
$comicpress_options[$key] = (bool) ( $_REQUEST[$key] == 1 ? true : false );
}
foreach ( array(
'menubar_social_twitter',
'menubar_social_facebook',
'menubar_social_linkedin',
'menubar_social_pinterest',
'menubar_social_youtube',
'menubar_social_flickr',
'menubar_social_tumblr',
'menubar_social_deviantart',
'menubar_social_myspace',
'menubar_social_email',
) as $key ) {
if ( isset( $_REQUEST[$key] ) && ! empty( $_REQUEST[$key] ) ) {
$comicpress_options[$key] = esc_url( $_REQUEST[$key] );
} else {
// Set to empty if it's not set.
$comicpress_options[$key] = '';
}
}
$tab = 'menubar';
update_option( 'cp-options', $comicpress_options );
}
if ( $_REQUEST['action'] == 'comicpress_save_postspages' ) {
foreach ( array(
'enable_avatar_trick', // Posts & Pages.
'disable_page_titles', // Posts & Pages.
'disable_post_titles', // Posts & Pages.
'enable_post_calendar', // Posts & Pages.
'enable_post_author_gravatar', // Posts & Pages.
'disable_categories_in_posts', // Posts & Pages.
'disable_tags_in_posts', // Posts & Pages.
'disable_author_info_in_posts', // Posts & Pages.
'disable_date_info_in_posts', // Posts & Pages.
'enable_last_modified_in_posts', // Posts & Pages.
'disable_posted_at_time_in_posts', // Posts & Pages.
) as $key ) {
if ( ! isset( $_REQUEST[$key] ) ) $_REQUEST[$key] = 0;
$comicpress_options[$key] = (bool) ( $_REQUEST[$key] == 1 ? true : false );
}
foreach ( array(
'moods_directory', // Posts & Pages.
'content_width', // Posts & Pages.
'content_width_disabled_sidebars', // Posts & Pages.
) as $key ) {
if ( isset( $_REQUEST[$key] ) )
$comicpress_options[$key] = wp_filter_nohtml_kses( $_REQUEST[$key] );
}
$tab = 'postspages';
update_option( 'cp-options', $comicpress_options );
}
if ( $_REQUEST['action'] == 'comicpress_save_comments' ) {
foreach ( array(
'disable_comment_note', // Comments.
'disable_comment_javascript', // Comments.
'enable_comments_on_homepage', // Comments.
) as $key ) {
if ( ! isset( $_REQUEST[$key] ) ) $_REQUEST[$key] = 0;
$comicpress_options[$key] = (bool) ( $_REQUEST[$key] == 1 ? true : false );
}
foreach ( array(
'avatar_directory', // Comments.
) as $key ) {
if ( isset( $_REQUEST[$key] ) )
$comicpress_options[$key] = wp_filter_nohtml_kses( $_REQUEST[$key] );
}
$tab = 'comments';
update_option( 'cp-options', $comicpress_options );
}
if ( $_REQUEST['action'] == 'comicpress_save_archivesearch' ) {
foreach ( array(
'display_archive_as_links', // Archive & Search.
'enable_numbered_pagination', // Posts & Pages.
) as $key ) {
if ( ! isset( $_REQUEST[$key] ) ) $_REQUEST[$key] = 0;
$comicpress_options[$key] = (bool) ( $_REQUEST[$key] == 1 ? true : false );
}
foreach ( array(
'archive_display_order', // Archive & Search.
'excerpt_or_content_in_archive', // Archive & Search.
) as $key ) {
if ( isset( $_REQUEST[$key] ) )
$comicpress_options[$key] = wp_filter_nohtml_kses( $_REQUEST[$key] );
}
$tab = 'archivesearch';
update_option( 'cp-options', $comicpress_options );
}
if ( $_REQUEST['action'] == 'comicpress_save_debug' ) {
foreach ( array(
'enable_debug_footer_code',
'force_active_connection_close',
) as $key ) {
if ( ! isset( $_REQUEST[$key] ) ) $_REQUEST[$key] = 0;
$comicpress_options[$key] = (bool) ( $_REQUEST[$key] == 1 ? true : false );
}
$tab = 'debug';
update_option( 'cp-options', $comicpress_options );
}
if ( $tab ) {
?>
<div id="message" class="updated">
<p>
<strong>
<?php _e( 'ComicPress Settings SAVED!', 'comicpress' ); ?>
</strong>
</p>
</div>
<script>
function hidemessage() { document.getElementById('message').style.display = 'none'; }
</script>
<?php
}
}
$version = comicpress_themeinfo( 'version' );
$comicpress_options = comicpress_load_options();
?>
<div id="poststuff" class="metabox-holder">
<div id="eadmin">
<?php
$tab_info = array(
'splash' => __( 'Introduction', 'comicpress' ),
'general' => __( 'General', 'comicpress' ),
'menubar' => __( 'Menubar', 'comicpress' ),
'postspages' => __( 'Posts & Pages', 'comicpress' ),
'comments' => __( 'Comments', 'comicpress' ),
'archivesearch' => __( 'Archive & Search', 'comicpress' ),
'debug' => __( 'Debug', 'comicpress' ),
);
if ( empty( $tab ) ) {
$tab = 'splash'; }
foreach ( $tab_info as $tab_id => $label ) {
?>
<div id="comicpress-tab-<?php echo $tab_id; ?>" class="comicpress-tab <?php echo ( $tab == $tab_id ) ? 'on' : 'off'; ?>">
<span>
<?php echo $label; ?>
</span>
</div>
<?php
}
?>
</div>
<div id="comicpress-options-pages">
<?php
foreach ( glob( get_template_directory() . '/options/*.php' ) as $file ) {
include( $file );
}
?>
</div>
</div>
<script type="text/javascript">
(function($) {
var showPage = function(which) {
$('#comicpress-options-pages > div').each(function(i) {
$(this)[(this.id == 'comicpress-' + which) ? 'show' : 'hide']();
});
};
$('.comicpress-tab').click(function() {
$('#message').animate({height:"0", opacity:0, margin: 0}, 100, 'swing', function() { $(this).remove() });
showPage(this.id.replace('comicpress-tab-', ''));
var myThis = this;
$('.comicpress-tab').each(function() {
var isSame = (this == myThis);
$(this).toggleClass('on', isSame).toggleClass('off', !isSame);
});
return false;
});
showPage('<?php echo esc_js( $tab ); ?>');
}(jQuery));
</script>
</div>
<div class="eadmin-footer">
<div id="comicpress-version-title">
<?php
printf(
/* translators: %1$1s: Link to website %2$2s: Additional link attribute %3$3s: Theme versions number*/
__( '<a href="%1$1s" %2$2s>ComicPress</a> %3$3s', 'comicpress' ),
esc_url( 'http://frumph.net/' ),
'target="_blank" rel="noopener noreferrer"',
comicpress_themeinfo( 'version' )
);
?>
</div>
<br />
<?php
printf(
/* translators: %1$1s: Link to website %2$2s: Additional link attribute */
__( 'Developed and maintained by <a href="%1$1s" %2$2s>Philip M. Hofer alias <small>(Frumph)</small></a>.', 'comicpress' ),
esc_url( 'http://frumph.net/' ),
'target="_blank" rel="noopener noreferrer"'
);
?>
<?php
printf(
/* translators: %1$1s: Link to website %2$2s: Additional link attribute */
__( 'Originally created by<a href="%1$1s" %2$2s> Tyler Martin</a>.', 'comicpress' ),
esc_url( 'http://mindfaucet.com/' ),
'target="_blank" rel="noopener noreferrer"'
);
?>
</a>
<br />
<?php
_e( 'If you like the ComicPress theme, please donate. It will help in developing new features and versions.', 'comicpress' );
?>
<table style="margin:0 auto;">
<tr>
<td style="width:200px;">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="hidden" name="hosted_button_id" value="46RNWXBE7467Q" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!" />
<img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>
</td>
<td style="width:200px;">
<form method="post" id="myForm" name="template" enctype="multipart/form-data" action="">
<?php wp_nonce_field( 'update-options' ); ?>
<input name="comicpress_reset" type="submit" class="button" value="<?php _e( 'Reset All Settings', 'comicpress' ); ?>" />
<input type="hidden" name="action" value="comicpress_reset" />
</form>
</td>
<td style="width:200px;">
<form method="post" id="myForm" name="template" enctype="multipart/form-data" action="">
<?php wp_nonce_field( 'update-options' ); ?>
<input name="comicpress_reset_customize" type="submit" class="button" value="<?php _e( 'Reset Customizer Colors', 'comicpress' ); ?>" />
<input type="hidden" name="action" value="comicpress_reset_customize" />
</form>
</td>
</tr>
</table>
</div>
<?php
}
?>