-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpfc-admin.php
executable file
·330 lines (320 loc) · 19.5 KB
/
wpfc-admin.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
<?php
class WPFC_Admin {
public static function menus(){
$page = add_options_page('WP FullCalendar', 'WP FullCalendar', 'manage_options', 'wp-fullcalendar', array('WPFC_Admin','admin_options'));
wp_enqueue_style('wp-fullcalendar', plugins_url('includes/css/admin.css',__FILE__));
}
public static function admin_options(){
if( !empty($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'wpfc_options_save')){
foreach($_REQUEST as $option_name => $option_value){
if(substr($option_name, 0, 5) == 'wpfc_'){
if( $option_name == 'wpfc_scripts_limit' ){ $option_value = str_replace(' ', '', $option_value); } //clean up comma seperated emails, no spaces needed
update_option($option_name, $option_value);
}
}
if( empty($_REQUEST['wpfc_post_taxonomies']) ){ update_option('wpfc_post_taxonomies', ''); }
echo '<div class="updated notice"><p>'.__('Settings saved.').'</p></div>';
}
?>
<div class="wrap">
<h2>WP FullCalendar</h2>
<div id="poststuff" class="metabox-holder has-right-sidebar">
<div id="side-info-column" class="inner-sidebar">
<div id="categorydiv" class="postbox ">
<div class="handlediv" title="Click to toggle"></div>
<h3 class="hndle" style="color:green;">** Support this plugin! **</h3>
<div class="inside">
<p>This plugin was developed by <a href="http://msyk.es/">Marcus Sykes</a> and is now provided free of charge thanks to proceeds from the <a href="http://wp-events-plugin.com/">Events Manager</a> Pro plugin.</p>
<p>We're not asking for donations, but we'd appreciate a 5* rating and/or a link to our plugin page!</p>
<ul>
<li><a href="http://wordpress.org/extend/plugins/wp-fullcalendar/" >Give us 5 Stars on WordPress.org</a></li>
<li><a href="http://wordpress.org/extend/plugins/wp-fullcalendar/" >Link to our plugin page.</a></li>
</ul>
</div>
</div>
<div id="categorydiv" class="postbox ">
<div class="handlediv" title="Click to toggle"></div>
<h3 class="hndle">About FullCalendar</h3>
<div class="inside">
<p><a href="http://arshaw.com/fullcalendar/">FullCalendar</a> is a jQuery plugin developed by Adam Shaw, which adds a beautiful AJAX-enabled calendar which can communicate with your blog.</p>
<p>If you find this calendar particularly useful and can spare a few bucks, please <a href="http://arshaw.com/fullcalendar/">donate something to his project</a>, most of the hard work here was done by him and he gives this out freely for everyone to use!</p>
</div>
</div>
<div id="categorydiv" class="postbox ">
<div class="handlediv" title="Click to toggle"></div>
<h3 class="hndle">Getting Help</h3>
<div class="inside">
<p>Before asking for help, check the readme files or the plugin pages for answers to common issues.</p>
<p>If you're still stuck, try the <a href="http://wordpress.org/support/plugin/wp-fullcalendar/">community forums</a>.</p>
</div>
</div>
<div id="categorydiv" class="postbox ">
<div class="handlediv" title="Click to toggle"></div>
<h3 class="hndle">Translating</h3>
<div class="inside">
<p>If you'd like to translate this plugin, the language files are in the langs folder.</p>
<p>Please email any translations to [email protected] and we'll incorporate it into the plugin.</p>
</div>
</div>
</div>
<div id="post-body">
<div id="post-body-content">
<p>
<?php echo sprintf(__('To use this plugin, simply use the %s shortcode in one of your posts or pages.','wp-fullcalendar'),'<code>[fullcalendar]</code>'); ?>
<?php echo sprintf(__('You can also do this with PHP and this snippet : %s.','wp-fullcalendar'),'<code>echo WP_FullCalendar::calendar($args);</code>'); ?>
</p>
<form action="" class="wpfc-options" method="post">
<?php do_action('wpfc_admin_before_options'); ?>
<h2 style="margin-top:0px;"><?php _e('Post Types','wp-fullcalendar'); ?></h2>
<p><?php echo sprintf(__('By default, your calendar will show the types of posts based on settings below.','wp-fullcalendar'),''); ?></p>
<p>
<?php echo sprintf(__('You can override these settings by choosing your post type in your shortode like this %s.','wp-fullcalendar'),'<code>[fullcalendar type="post"]</code>'); ?>
<?php echo sprintf(__('You can override taxonomy search settings as well like this %s.','wp-fullcalendar'),'<code>[fullcalendar type="post_tag,category"]</code>'); ?>
<?php _e('In both cases, the values you should use are in (parenteses) below.','wp-fullcalendar');?>
</p>
<p>
<ul class="wpfc-post-types">
<?php
$selected_taxonomies = get_option('wpfc_post_taxonomies');
foreach( get_post_types( apply_filters('wpfc_get_post_types_args', array('public'=>true )), 'names') as $post_type ){
$checked = get_option('wpfc_default_type') == $post_type ? 'checked':'';
$post_data = get_post_type_object($post_type);
echo "<li><label><input type='radio' class='wpfc-post-type' name='wpfc_default_type' value='$post_type' $checked /> {$post_data->labels->name} (<em>$post_type</em>)</label>";
do_action('wpfc_admin_options_post_type_'.$post_type);
$post_type_taxonomies = get_object_taxonomies($post_type);
if( count($post_type_taxonomies) > 0 ){
$display = empty($checked) ? 'style="display:none;"':'';
echo "<div $display>";
echo "<p>".__('Choose which taxonomies you want to see listed as search options on the calendar.','wp-fullcalendar')."</p>";
echo "<ul>";
foreach( $post_type_taxonomies as $taxonomy_name ){
$taxonomy = get_taxonomy($taxonomy_name);
$tax_checked = !empty($selected_taxonomies[$post_type][$taxonomy_name]) ? 'checked':'';
echo "<li><label><input type='checkbox' name='wpfc_post_taxonomies[$post_type][$taxonomy_name]' value='1' $tax_checked /> {$taxonomy->labels->name} (<em>$taxonomy_name</em>)</label></li>";
}
echo "</ul>";
echo "</div>";
}
echo "</li>";
}
?>
</ul>
</p>
<script type="text/javascript">
jQuery(document).ready(function($){
$('input.wpfc-post-type').change(function(){
$('ul.wpfc-post-types div').hide();
$('input[name=wpfc_default_type]:checked').parent().parent().find('div').show();
});
});
</script>
<?php do_action('wpfc_admin_after_cpt_options'); ?>
<h2><?php _e('Calendar Options','wp-fullcalendar'); ?></h2>
<table class='form-table'>
<?php
$available_views = apply_filters('wpfc_available_views',array('month'=>'Month','basicWeek'=>'Week (basic)','basicDay'=>'Day (basic)','agendaWeek'=>'Week (agenda)','agendaDay'=>'Day (agenda)'));
?>
<tr>
<th scope="row"><?php _e('Available Views','wp-fullcalendar'); ?></th>
<td>
<?php $wpfc_available_views = get_option('wpfc_available_views', array('month','basicWeek','basicDay')); ?>
<?php foreach( $available_views as $view_key => $view_value ): ?>
<input type="checkbox" name="wpfc_available_views[]" value="<?php echo $view_key ?>" <?php if( in_array($view_key, $wpfc_available_views) ){ echo 'checked="checked"'; } ?>/> <?php echo $view_value; ?><br />
<?php endforeach; ?>
<em><?php _e('Users will be able to select from these views when viewing the calendar.'); ?></em>
</td>
</tr>
<?php
wpfc_options_select( __('Default View','wp-fullcalendar'), 'wpfc_defaultView', $available_views, __('Choose the default view to be displayed when the calendar is first shown.','wp-fullcalendar') );
wpfc_options_input_text ( __( 'Time Format', 'wp-fullcalendar'), 'wpfc_timeFormat', sprintf(__('Set the format used for showing the times on the calendar, <a href="%s">see possible combinations</a>. Leave blank for no time display.','wp-fullcalendar'),'http://momentjs.com/docs/#/displaying/format/'), 'h(:mm)a' );
wpfc_options_input_text ( __( 'Events limit', 'wp-fullcalendar'), 'wpfc_limit', __('Enter the maximum number of events to show per day, which will then be preceded by a link to the calendar day page.','wp-fullcalendar') );
wpfc_options_input_text ( __( 'View events link', 'wp-fullcalendar'), 'wpfc_limit_txt', __('When the limit of events is shown for one day, this text will be used for the link to the calendar day page.','wp-fullcalendar') );
?>
</table>
<?php do_action('wpfc_admin_after_calendar_options'); ?>
<h2><?php _e('jQuery UI Themeroller','wp-fullcalendar'); ?></h2>
<p><?php echo sprintf(__( 'You can select from a set of pre-made CSS themes, which are taken from the <a href="%s">jQuery Theme Roller</a> gallery. If you roll your own theme, upload the CSS file and images folder to <code>wp-content/yourtheme/plugins/wp-fullcalendar/</code> and refresh this page, it should appear an option in the pull down menu below.','wp-fullcalendar'),'http://jqueryui.com/themeroller/'); ?></p>
<table class='form-table'>
<?php
//jQuery UI ships with pre-made themes, so here they are. This was coded for packaged CSS Themes 1.10.4 and 1.11.4
$jquery_themes = array('black-tie','blitzer','cupertino','dark-hive','dot-luv','eggplant','excite-bike','flick','hot-sneaks','humanity','le-frog','mint-choc','overcast','pepper-grinder','redmond','smoothness','south-street','start','sunny','swanky-purse','trontastic','ui-darkness','ui-lightness','vader');
$jquery_themes = apply_filters('wpfc_jquery_themes', $jquery_themes);
//get custom theme CSS files
$plugin_path = get_stylesheet_directory()."/plugins/wp-fullcalendar/";
foreach( glob( $plugin_path.'*.css') as $css_file ){
$css_file = str_replace($plugin_path,'',$css_file);
$css_custom_files[] = $css_file;
}
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="product_package_unit_price"><?php _e( 'jQuery CSS Theme?', 'wp-fullcalendar'); ?></label></th>
<td>
<select name="wpfc_theme_css">
<option value="0"><?php _e( 'No Theme','wp-fullcalendar'); ?></option>
<optgroup label="<?php _e('Built-In','wp-fullcalendar'); ?>">
<?php foreach( $jquery_themes as $jquery_theme ): ?>
<option <?php if(get_option('wpfc_theme_css') == $jquery_theme) echo 'selected="selected"'; ?>><?php echo esc_html($jquery_theme); ?></option>
<?php endforeach; ?>
</optgroup>
<?php if( !empty($css_custom_files) ): ?>
<optgroup label="<?php _e('Custom','wp-fullcalendar'); ?>">
<?php foreach( $css_custom_files as $css_custom_file ): ?>
<option <?php if(get_option('wpfc_theme_css') == $css_custom_file) echo 'selected="selected"'; ?>><?php echo esc_html($css_custom_file); ?></option>
<?php endforeach; ?>
</optgroup>
<?php endif; ?>
</select>
<i><?php _e( 'You can use the jQuery UI CSS framework to style the calendar, and choose from a set of themes below.','wp-fullcalendar'); ?></i>
</td>
</tr>
</table>
<?php do_action('wpfc_admin_after_themeroller_options'); ?>
<h2><?php _e('Tooltips','wp-fullcalendar'); ?></h2>
<p><?php _e( 'You can use <a href="http://craigsworks.com/projects/qtip2/">jQuery qTips</a> to show excerpts of your events within a tooltip when hovering over a specific event on the calendar. You can control the content shown, positioning and style of the tool tips below.','wp-fullcalendar'); ?></p>
<table class='form-table'>
<?php
wpfc_options_radio_binary ( __( 'Enable event tooltips?', 'wp-fullcalendar'), 'wpfc_qtips', '' );
$tip_styles = array();
foreach( WP_FullCalendar::$tip_styles as $tip_style ){
$tip_styles[$tip_style] = $tip_style;
}
wpfc_options_select(__('Tooltip style','wp-fullcalendar'), 'wpfc_qtips_style', $tip_styles, __('You can choose from one of these preset styles for your tooltip.','wp-fullcalendar'));
wpfc_options_radio_binary ( __( 'Rounded tooltips?', 'wp-fullcalendar'), 'wpfc_qtips_rounded', __( 'If your chosen tooltip style doesn\'t already do/prevent this, you can add rounded corners using CSS3.','wp-fullcalendar') );
wpfc_options_radio_binary ( __( 'Add shadow to tooltips?', 'wp-fullcalendar'), 'wpfc_qtips_shadow', __( 'If your chosen tooltip style doesn\'t already do/prevent this, you can add a CSS3 drop-shadow effect to your tooltip.','wp-fullcalendar') );
$positions_options = array();
foreach( WP_FullCalendar::$tip_positions as $position ){
$positions_options[$position] = $position;
}
wpfc_options_select ( __( 'Tooltip pointer position', 'wp-fullcalendar'), 'wpfc_qtips_my', $positions_options, __( 'Choose where the pointer will be situated on your tooltip.','wp-fullcalendar') );
wpfc_options_select ( __( 'Tooltip bubble position', 'wp-fullcalendar'), 'wpfc_qtips_at', $positions_options, __( 'Choose where your tooltip will be situated relative to the event link which triggers the tooltip.','wp-fullcalendar') );
wpfc_options_radio_binary ( __( 'Enable featured image?', 'wp-fullcalendar'), 'wpfc_qtips_image', __('If your post has a featured image, it will be included as a thumbnail.','wp-fullcalendar') );
?>
<tr>
<td><label><?php _e('Featured image size','wp-fullcalendar'); ?></label></td>
<td>
<?php _e('Width','wp-fullcalendar'); ?> : <input name="wpfc_qtips_image_w" type="text" style="width:40px;" value="<?php echo get_option('wpfc_qtips_image_w'); ?>" />
<?php _e('Height','wp-fullcalendar'); ?> : <input name="wpfc_qtips_image_h" type="text" style="width:40px;" value="<?php echo get_option('wpfc_qtips_image_h'); ?>" />
</td>
</tr>
</table>
<?php do_action('wpfc_admin_after_tooltip_options'); ?>
<h2><?php _e ( 'JS and CSS Files (Optimization)', 'wp-fullcalendar'); ?></h2>
<table class="form-table">
<?php
wpfc_options_input_text( __( 'Load JS and CSS files on', 'dbem' ), 'wpfc_scripts_limit', __('Write the page IDs where you will display the FullCalendar on so CSS and JS files are only included on these pages. For multiple pages, use comma-seperated values e.g. 1,2,3. Leaving this blank will load our CSS and JS files on EVERY page, enter -1 for the home page.','wp-fullcalendar') );
?>
</table>
<?php do_action('wpfc_admin_after_optimizations'); ?>
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce('wpfc_options_save'); ?>" />
<p class="submit"><input type="submit" value="<?php _e('Submit Changes','wp-fullcalendar'); ?>" class="button-primary"></p>
</form>
</div>
</div>
</div>
</div>
<?php
}
}
//check for updates
if( version_compare(WPFC_VERSION, get_option('wpfc_version',0)) > 0 && current_user_can('activate_plugins') ){
include('wpfc-install.php');
}
//add admin action hook
add_action ( 'admin_menu', array('WPFC_Admin', 'menus') );
/*
* Admin UI Helpers
*/
function wpfc_options_input_text($title, $name, $description, $default='') {
?>
<tr valign="top" id='<?php echo esc_attr($name);?>_row'>
<th scope="row"><?php echo esc_html($title); ?></th>
<td>
<input name="<?php echo esc_attr($name) ?>" type="text" id="<?php echo esc_attr($title) ?>" style="width: 95%" value="<?php echo esc_attr(get_option($name, $default), ENT_QUOTES); ?>" size="45" /><br />
<em><?php echo $description; ?></em>
</td>
</tr>
<?php
}
function wpfc_options_input_password($title, $name, $description) {
?>
<tr valign="top" id='<?php echo esc_attr($name);?>_row'>
<th scope="row"><?php echo esc_html($title); ?></th>
<td>
<input name="<?php echo esc_attr($name) ?>" type="password" id="<?php echo esc_attr($title) ?>" style="width: 95%" value="<?php echo esc_attr(get_option($name)); ?>" size="45" /><br />
<em><?php echo $description; ?></em>
</td>
</tr>
<?php
}
function wpfc_options_textarea($title, $name, $description) {
?>
<tr valign="top" id='<?php echo esc_attr($name);?>_row'>
<th scope="row"><?php echo esc_html($title); ?></th>
<td>
<textarea name="<?php echo esc_attr($name) ?>" id="<?php echo esc_attr($name) ?>" rows="6" cols="60"><?php echo esc_attr(get_option($name), ENT_QUOTES);?></textarea><br/>
<em><?php echo $description; ?></em>
</td>
</tr>
<?php
}
function wpfc_options_radio($name, $options, $title='') {
$option = get_option($name);
?>
<tr valign="top" id='<?php echo esc_attr($name);?>_row'>
<?php if( !empty($title) ): ?>
<th scope="row"><?php echo esc_html($title); ?></th>
<td>
<?php else: ?>
<td colspan="2">
<?php endif; ?>
<table>
<?php foreach($options as $value => $text): ?>
<tr>
<td><input id="<?php echo esc_attr($name) ?>_<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($name) ?>" type="radio" value="<?php echo esc_attr($value); ?>" <?php if($option == $value) echo "checked='checked'"; ?> /></td>
<td><?php echo $text ?></td>
</tr>
<?php endforeach; ?>
</table>
</td>
</tr>
<?php
}
function wpfc_options_radio_binary($title, $name, $description, $option_names = '') {
if( empty($option_names) ) $option_names = array(0 => __('No','dbem'), 1 => __('Yes','dbem'));
if( substr($name, 0, 7) == 'dbem_ms' ){
$list_events_page = get_site_option($name);
}else{
$list_events_page = get_option($name);
}
?>
<tr valign="top" id='<?php echo $name;?>_row'>
<th scope="row"><?php echo esc_html($title); ?></th>
<td>
<?php echo $option_names[1]; ?> <input id="<?php echo esc_attr($name) ?>_yes" name="<?php echo esc_attr($name) ?>" type="radio" value="1" <?php if($list_events_page) echo "checked='checked'"; ?> />
<?php echo $option_names[0]; ?> <input id="<?php echo esc_attr($name) ?>_no" name="<?php echo esc_attr($name) ?>" type="radio" value="0" <?php if(!$list_events_page) echo "checked='checked'"; ?> />
<br/><em><?php echo $description; ?></em>
</td>
</tr>
<?php
}
function wpfc_options_select($title, $name, $list, $description, $default='') {
$option_value = get_option($name, $default);
if( $name == 'dbem_events_page' && !is_object(get_page($option_value)) ){
$option_value = 0; //Special value
}
?>
<tr valign="top" id='<?php echo esc_attr($name);?>_row'>
<th scope="row"><?php echo esc_html($title); ?></th>
<td>
<select name="<?php echo esc_attr($name); ?>" >
<?php foreach($list as $key => $value) : ?>
<option value='<?php echo esc_attr($key) ?>' <?php echo ("$key" == $option_value) ? "selected='selected' " : ''; ?>>
<?php echo esc_html($value); ?>
</option>
<?php endforeach; ?>
</select> <br/>
<em><?php echo $description; ?></em>
</td>
</tr>
<?php
}