This repository has been archived by the owner on Jan 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsimpleslider-admin.php
366 lines (307 loc) · 10.2 KB
/
simpleslider-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
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
<?php
add_action( 'admin_init', 'sss_settings_init' );
add_action( 'admin_menu', 'sss_load_menu' );
add_filter( 'plugin_action_links', 'sss_add_action_link', 10, 2 );
add_filter( 'contextual_help', 'sss_contextual_help_handler', 10, 3 );
require_once 'simpleslider-admin-help.php';
function sss_settings_init() {
register_setting( 'sss_settings', 'sss_settings', 'sss_settings_validate');
add_settings_section( 'sss_settings_main', '',
'sss_settings_text', 'simple_slideshow' );
add_settings_field( 'sss_size', 'Image size', 'sss_settings_size',
'simple_slideshow', 'sss_settings_main');
add_settings_field( 'sss_transition_speed', 'Transition speed',
'sss_settings_transition_speed', 'simple_slideshow',
'sss_settings_main');
add_settings_field( 'sss_link_click', 'Click image to open full-size ' .
'version in a new window', 'sss_settings_link_click',
'simple_slideshow', 'sss_settings_main');
add_settings_field( 'sss_link_target', 'Link target',
'sss_settings_link_target', 'simple_slideshow',
'sss_settings_main');
add_settings_field( 'sss_show_counter', 'Show image counter',
'sss_settings_show_counter', 'simple_slideshow',
'sss_settings_main');
add_settings_field( 'sss_show_controls', 'Show image controls',
'sss_settings_show_controls', 'simple_slideshow',
'sss_settings_main');
add_settings_field( 'sss_cycle_version', 'Cycle version',
'sss_settings_cycle_version', 'simple_slideshow',
'sss_settings_main');
add_settings_field( 'sss_transition', 'Transition effect',
'sss_settings_transition', 'simple_slideshow',
'sss_settings_main');
add_settings_field( 'sss_auto_advance', 'Auto-advance',
'sss_settings_auto_advance', 'simple_slideshow',
'sss_settings_main');
add_settings_field( 'sss_auto_advance_speed', 'Auto-advance speed',
'sss_settings_auto_advance_speed', 'simple_slideshow',
'sss_settings_main');
}
function sss_load_menu() {
global $sss_menu_hook_name;
$sss_menu_hook_name = add_options_page( 'Simple Slideshow Settings', 'Simple Slideshow',
'manage_options', 'simple_slideshow', 'sss_admin_menu');
}
function sss_settings_text() {
// Moved into the form itself in order to keep consistent look/avoid WP's
// styling of settings section introductory texts - but still need a
// function here to keep the signature expected.
return;
}
// From http://codex.wordpress.org/Adding_Contextual_Help_to_Administration_Menus
function sss_contextual_help_handler( $contextual_help, $screen_id, $screen ) {
global $sss_menu_hook_name, $sss_contextual_help;
if( $screen_id == $sss_menu_hook_name )
$contextual_help = $sss_contextual_help;
return $contextual_help;
}
function sss_settings_size() {
$opts = get_option( 'sss_settings' );
$sizes = get_intermediate_image_sizes();
$curr = sss_settings_defaults('size');
if( $opts and isset( $opts[ 'size' ] ) )
$curr = $opts[ 'size' ];
echo '<select id="sss_size" name="sss_settings[size]">';
foreach( $sizes as $size ) {
echo '<option ';
if( $size == $curr )
echo 'selected ';
echo 'value="', $size, '">', ucfirst($size) ,'</option>';
}
echo '</select>';
}
function sss_settings_transition_speed() {
$opts = get_option( 'sss_settings' );
$curr = sss_settings_defaults('transition_speed');
if( $opts and isset( $opts[ 'transition_speed' ] ) )
$curr = $opts[ 'transition_speed' ];
echo '<input type="number" min="10" max="1000" step="10" value="',
$curr, '" id="sss_transition_speed" ',
'name="sss_settings[transition_speed]">';
}
function sss_settings_transition() {
$opts = get_option( 'sss_settings' );
$curr = sss_settings_defaults( 'transition' );
if( $opts and isset( $opts[ 'transition' ] ) )
$curr = $opts[ 'transition' ];
echo '<input type="text" value="', $curr,
'" id="sss_transition" ',
'name="sss_settings[transition]"';
if ( 'lite' == $opts[ 'cycle_version' ] )
echo ' disabled ';
echo '>';
}
function sss_settings_auto_advance_speed() {
$opts = get_option( 'sss_settings' );
$curr = sss_settings_defaults( 'auto_advance_speed' );
if( $opts and isset( $opts[ 'auto_advance_speed' ] ) )
$curr = $opts[ 'auto_advance_speed' ];
echo '<input type="number" min="1000" max="30000" step="500" value="', $curr,
'" id="sss_auto_advance_speed" ',
'name="sss_settings[auto_advance_speed]">';
}
function sss_settings_auto_advance() {
$opts = get_option( 'sss_settings' );
$curr = sss_settings_defaults( 'auto_advance' );
if( $opts and isset( $opts[ 'auto_advance' ] ) )
$curr = $opts[ 'auto_advance' ];
echo '<select id="sss_auto_advance" name="sss_settings[auto_advance]">',
'<option ';
if( ! $curr )
echo 'selected ';
echo 'value="0">Disabled</option><option ';
if( $curr )
echo 'selected ';
echo 'value="1">Enabled</option></select>';
}
function sss_settings_link_click() {
$opts = get_option( 'sss_settings' );
$curr = sss_settings_defaults( 'link_click' );
if( $opts and isset( $opts[ 'link_click' ] ) )
$curr = $opts[ 'link_click' ];
echo '<select id="sss_link_click" name="sss_settings[link_click]">',
'<option ';
if( ! $curr )
echo 'selected ';
echo 'value="0">No</option><option ';
if( $curr )
echo 'selected ';
echo 'value="1">Yes</option></select>';
}
function sss_settings_cycle_version() {
$opts = get_option( 'sss_settings' );
$curr = sss_settings_defaults( 'cycle_version' );
if( $opts and isset( $opts[ 'cycle_version' ] ) )
$curr = $opts[ 'cycle_version' ];
echo '<select id="sss_cycle_version" name="sss_settings[cycle_version]">',
'<option ';
if( 'lite' == $curr )
echo 'selected ';
echo 'value="lite">Lite</option><option ';
if( 'all' == $curr )
echo 'selected ';
echo 'value="all">All</option></select>';
}
function sss_settings_link_target() {
$opts = get_option( 'sss_settings' );
$curr = sss_settings_defaults( 'link_target' );
if( $opts and isset( $opts[ 'link_target' ] ) )
$curr = $opts[ 'link_target' ];
echo '<select id="sss_target" name="sss_settings[link_target]"><option ';
if( 'attach' == $curr )
echo 'selected ';
echo 'value="attach">Attachment page</option><option ';
if( 'direct' == $curr )
echo 'selected ';
echo 'value="direct">Image file</option></select>';
}
function sss_settings_show_counter() {
$opts = get_option( 'sss_settings' );
$curr = sss_settings_defaults( 'show_counter' );
if( $opts and isset( $opts[ 'show_counter' ] ) )
$curr = $opts[ 'show_counter' ];
echo '<select id="sss_show_counter" name="sss_settings[show_counter]">',
'<option ';
if( ! $curr )
echo 'selected ';
echo 'value="0">No</option><option ';
if( $curr )
echo 'selected ';
echo 'value="1">Yes</option></select>';
}
function sss_settings_show_controls() {
$opts = get_option( 'sss_settings' );
$curr = sss_settings_defaults( 'show_controls' );
if( $opts and isset( $opts[ 'show_controls' ] ) )
$curr = $opts[ 'show_controls' ];
echo '<select id="sss_show_controls" name="sss_settings[show_controls]">',
'<option ';
if( ! $curr )
echo 'selected ';
echo 'value="0">No</option><option ';
if( $curr )
echo 'selected ';
echo 'value="1">Yes</option></select>';
}
// From http://www.wpmods.com/adding-plugin-action-links
function sss_add_action_link( $links, $file ){
static $this_plugin;
if( ! $this_plugin ) {
// Adjust to reflect filename of main plugin file
$this_plugin = plugin_basename( str_replace( '-admin', '', __FILE__ ) );
}
if( $file == $this_plugin ) {
$settings_link = '<a href="' . get_bloginfo( 'wpurl' ) . '/wp-admin' .
'/options-general.php?page=simple_slideshow">Settings</a>';
array_unshift( $links, $settings_link );
}
return $links;
}
function sss_admin_menu() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient privileges to access this ' .
'page. Please contact your administrator.' , 'simple_slideshow') );
}
?>
<script type="text/javascript">
jQuery(document).ready(function($){
var transition_field = $('#sss_transition');
$('#sss_cycle_version').change(function(e){
if($(e.target).val() == 'lite'){
transition_field.attr('disabled', true).val('fade');
} else {
transition_field.attr('disabled', false);
}
});
var tablist = $("#tabs").tabs();
$("#show-attributes-tab").click(function(){
tablist.tabs('select', 2);
});
var transitions = [
'blindX',
'blindY',
'blindZ',
'cover',
'curtainX',
'curtainY',
'fade',
'fadeZoom',
'growX',
'growY',
'none',
'scrollUp',
'scrollDown',
'scrollLeft',
'scrollRight',
'scrollHorz',
'scrollVert',
'shuffle',
'slideX',
'slideY',
'toss',
'turnUp',
'turnDown',
'turnLeft',
'turnRight',
'uncover',
'wipe',
'zoom'];
$('#sss_transition').autocomplete({
source: transitions
});
});
</script>
<div class="wrap">
<div id="icon-options-general" class="icon32"></div>
<h2>Simple Slideshow</h2>
<p>Thanks for downloading Simple Slideshow. If you like it, please feel free
to give it a positive review at Wordpress.org so that others can
learn about it.</p>
<p><b>Developers:</b> Got an idea on how to make Simple Slideshow better? Fork
it from <a href="https://github.com/dlanger/simple-slideshow/">github</a> and send in a pull request!</p>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Settings</a></li>
<li><a href="#tabs-2">Instructions</a></li>
<li><a href="#tabs-3">Attributes</a></li>
</ul>
<div id="tabs-1">
<p>
<form method="post" action="options.php">
<p>Options set here become the <em>default</em>, but can still
be changed on a per-show basis by using attributes.</p>
<p>For more information about the meaning of each option, please click
the <em>Help</em> button above. For instructions on how to set these options on
a per-show basis, consult the
<em><a href='#' id='show-attributes-tab'>Attributes</a></em> tab.</p>
<?php
settings_fields( 'sss_settings' );
do_settings_sections( 'simple_slideshow' );
?>
<p class="submit">
<input type="submit" class="button-primary" value="Save Changes">
</p>
</form>
</p>
</div>
<div id="tabs-2">
<p>
<?php
global $sss_tab_help;
echo $sss_tab_help;
?>
</p>
</div>
<div id="tabs-3">
<p>
<?php
global $sss_attribute_tab_help;
echo $sss_attribute_tab_help;
?>
</p>
</div>
</div>
<?php
}
?>