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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
|
<?php /** * SMOF Options Machine Class * * @package WordPress * @subpackage SMOF * @since 1.0.0 * @author Syamil MJ */ class Options_Machine {
/** * PHP5 contructor * * @since 1.0.0 */ function __construct($options) { $return = $this->optionsframework_machine($options); $this->Inputs = $return[0]; $this->Menu = $return[1]; $this->Defaults = $return[2]; }
/** * Sanitize option * * Sanitize & returns default values if don't exist * * Notes: - For further uses, you can check for the $value['type'] and performs more speficic sanitization on the option - The ultimate objective of this function is to prevent the "undefined index" errors some authors are having due to malformed options array */ static function sanitize_option( $value ) { $defaults = array( "name" => "", "desc" => "", "id" => "", "std" => "", "mod" => "", "type" => "" );
$value = wp_parse_args( $value, $defaults );
return $value;
}
/** * Process options data and build option fields * * @uses get_theme_mod() * * @access public * @since 1.0.0 * * @return array */ public static function optionsframework_machine($options) { global $smof_output, $smof_details, $smof_data; if (empty($options)) return; if (empty($smof_data)) $smof_data = of_get_options(); $data = $smof_data;
$defaults = array(); $counter = 0; $menu = ''; $output = ''; $update_data = false;
do_action('optionsframework_machine_before', array( 'options' => $options, 'smof_data' => $smof_data, )); if ($smof_output != "") { $output .= $smof_output; $smof_output = ""; }
foreach ($options as $value) { // sanitize option if ($value['type'] != "heading") $value = self::sanitize_option($value);
$counter++; $val = ''; //create array of defaults if ($value['type'] == 'multicheck'){ if (is_array($value['std'])){ foreach($value['std'] as $i=>$key){ $defaults[$value['id']][$key] = true; } } else { $defaults[$value['id']][$value['std']] = true; } } else { if (isset($value['id'])) $defaults[$value['id']] = $value['std']; } /* condition start */ if(!empty($smof_data) || !empty($data)){ if (array_key_exists('id', $value) && !isset($smof_data[$value['id']])) { $smof_data[$value['id']] = $value['std']; if ($value['type'] == "checkbox" && $value['std'] == 0) { $smof_data[$value['id']] = 0; } else { $update_data = true; } } if (array_key_exists('id', $value) && !isset($smof_details[$value['id']])) { $smof_details[$value['id']] = $smof_data[$value['id']]; }
//Start Heading if ( $value['type'] != "heading" ) { $class = ''; if(isset( $value['class'] )) { $class = $value['class']; } //hide items in checkbox group $fold=''; if (array_key_exists("fold",$value)) { if (isset($smof_data[$value['fold']]) && $smof_data[$value['fold']]) { $fold="f_".$value['fold']." "; } else { $fold="f_".$value['fold']." temphide "; } } $output .= '<div id="section-'.$value['id'].'" class="'.$fold.'section section-'.$value['type'].' '. $class .'">'."\n"; //only show header if 'name' value exists if($value['name']) $output .= '<h3 class="heading">'. $value['name'] .'</h3>'."\n"; $output .= '<div class="option">'."\n" . '<div class="controls">'."\n"; } //End Heading
//if (!isset($smof_data[$value['id']]) && $value['type'] != "heading") // continue; //switch statement to handle various options type switch ( $value['type'] ) {
//text input case 'text': $t_value = ''; $t_value = stripslashes($smof_data[$value['id']]); $t_value = str_replace('"',"'",$t_value); $mini =''; if(!isset($value['mod'])) $value['mod'] = ''; if($value['mod'] == 'mini') { $mini = 'mini';} $output .= '<input class="of-input '.$mini.'" name="'.$value['id'].'" id="'. $value['id'] .'" type="'. $value['type'] .'" value="'. $t_value .'" />'; break; //select option case 'select': $mini =''; if(!isset($value['mod'])) $value['mod'] = ''; if($value['mod'] == 'mini') { $mini = 'mini';} $output .= '<div class="select_wrapper ' . $mini . '">'; $output .= '<select class="select of-input" name="'.$value['id'].'" id="'. $value['id'] .'">';
foreach ($value['options'] as $select_ID => $option) { $theValue = $option; if (!is_numeric($select_ID)) $theValue = $select_ID; $output .= '<option id="' . $select_ID . '" value="'.$theValue.'" ' . selected($smof_data[$value['id']], $theValue, false) . ' />'.$option.'</option>'; } $output .= '</select></div>'; break;
case 'presets': $output .= '<a href="#" class="button-primary">Load presets</a>'; $output .= '<div class="pre_select_wrapper">'; foreach ($value['options'] as $select_ID => $option) { $output .= '<a href="#" data-preset="'.$option.'"><img class="pre-select-img" style="width:100%;" src="'.$select_ID.'"/></a>'; } $output .= '<a href="#" class="button reset-button cancel">Cancel</a></div>'; break; //textarea option case 'textarea': $cols = '8'; $ta_value = ''; if(isset($value['options'])){ $ta_options = $value['options']; if(isset($ta_options['cols'])){ $cols = $ta_options['cols']; } } $ta_value = stripslashes($smof_data[$value['id']]); $output .= '<textarea class="of-input" name="'.$value['id'].'" id="'. $value['id'] .'" cols="'. $cols .'" rows="8">'.$ta_value.'</textarea>'; break; //radiobox option case "radio": $checked = (isset($smof_data[$value['id']])) ? checked($smof_data[$value['id']], $option, false) : ''; foreach($value['options'] as $option=>$name) { $output .= '<input class="of-input of-radio" name="'.$value['id'].'" type="radio" value="'.$option.'" ' . checked($smof_data[$value['id']], $option, false) . ' /><label class="radio">'.$name.'</label><br/>'; } break; //checkbox option case 'checkbox': if (!isset($smof_data[$value['id']])) { $smof_data[$value['id']] = 0; } $fold = ''; if (array_key_exists("folds",$value)) $fold="fld "; $output .= '<input type="hidden" class="'.$fold.'checkbox of-input" name="'.$value['id'].'" id="'. $value['id'] .'" value="0"/>'; $output .= '<input type="checkbox" class="'.$fold.'checkbox of-input" name="'.$value['id'].'" id="'. $value['id'] .'" value="1" '. checked($smof_data[$value['id']], 1, false) .' />'; break; //multiple checkbox option case 'multicheck': (isset($smof_data[$value['id']]))? $multi_stored = $smof_data[$value['id']] : $multi_stored=""; foreach ($value['options'] as $key => $option) { if (!isset($multi_stored[$key])) {$multi_stored[$key] = '';} $of_key_string = $value['id'] . '_' . $key; $output .= '<input type="checkbox" class="checkbox of-input" name="'.$value['id'].'['.$key.']'.'" id="'. $of_key_string .'" value="1" '. checked($multi_stored[$key], 1, false) .' /><label class="multicheck" for="'. $of_key_string .'">'. $option .'</label><br />'; } break; // Color picker case "color": $default_color = ''; if ( isset($value['std']) ) { $default_color = ' data-default-color="' .$value['std'] . '" '; } $output .= '<input name="' . $value['id'] . '" id="' . $value['id'] . '" class="of-color" type="text" value="' . $smof_data[$value['id']] . '"' . $default_color .' />'; break;
//typography option case 'typography': $typography_stored = isset($smof_data[$value['id']]) ? $smof_data[$value['id']] : $value['std']; /* Font Size */ if(isset($typography_stored['size'])) { $output .= '<div class="select_wrapper typography-size" original-title="Font size">'; $output .= '<select class="of-typography of-typography-size select" name="'.$value['id'].'[size]" id="'. $value['id'].'_size">'; for ($i = 9; $i < 20; $i++){ $test = $i.'px'; $output .= '<option value="'. $i .'px" ' . selected($typography_stored['size'], $test, false) . '>'. $i .'px</option>'; } $output .= '</select></div>'; } /* Line Height */ if(isset($typography_stored['height'])) { $output .= '<div class="select_wrapper typography-height" original-title="Line height">'; $output .= '<select class="of-typography of-typography-height select" name="'.$value['id'].'[height]" id="'. $value['id'].'_height">'; for ($i = 20; $i < 38; $i++){ $test = $i.'px'; $output .= '<option value="'. $i .'px" ' . selected($typography_stored['height'], $test, false) . '>'. $i .'px</option>'; } $output .= '</select></div>'; } /* Font Face */ if(isset($typography_stored['face'])) { $output .= '<div class="select_wrapper typography-face" original-title="Font family">'; $output .= '<select class="of-typography of-typography-face select" name="'.$value['id'].'[face]" id="'. $value['id'].'_face">'; $faces = array('arial'=>'Arial', 'verdana'=>'Verdana, Geneva', 'trebuchet'=>'Trebuchet', 'georgia' =>'Georgia', 'times'=>'Times New Roman', 'tahoma'=>'Tahoma, Geneva', 'palatino'=>'Palatino', 'helvetica'=>'Helvetica' ); foreach ($faces as $i=>$face) { $output .= '<option value="'. $i .'" ' . selected($typography_stored['face'], $i, false) . '>'. $face .'</option>'; } $output .= '</select></div>'; } /* Font Weight */ if(isset($typography_stored['style'])) { $output .= '<div class="select_wrapper typography-style" original-title="Font style">'; $output .= '<select class="of-typography of-typography-style select" name="'.$value['id'].'[style]" id="'. $value['id'].'_style">'; $styles = array('normal'=>'Normal', 'italic'=>'Italic', 'bold'=>'Bold', 'bold italic'=>'Bold Italic'); foreach ($styles as $i=>$style){ $output .= '<option value="'. $i .'" ' . selected($typography_stored['style'], $i, false) . '>'. $style .'</option>'; } $output .= '</select></div>'; } /* Font Color */ if(isset($typography_stored['color'])) { $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector typography-color"><div style="background-color: '.$typography_stored['color'].'"></div></div>'; $output .= '<input class="of-color of-typography of-typography-color" original-title="Font color" name="'.$value['id'].'[color]" id="'. $value['id'] .'_color" type="text" value="'. $typography_stored['color'] .'" />'; } break; //border option case 'border': /* Border Width */ $border_stored = $smof_data[$value['id']]; $output .= '<div class="select_wrapper border-width">'; $output .= '<select class="of-border of-border-width select" name="'.$value['id'].'[width]" id="'. $value['id'].'_width">'; for ($i = 0; $i < 21; $i++){ $output .= '<option value="'. $i .'" ' . selected($border_stored['width'], $i, false) . '>'. $i .'</option>'; } $output .= '</select></div>'; /* Border Style */ $output .= '<div class="select_wrapper border-style">'; $output .= '<select class="of-border of-border-style select" name="'.$value['id'].'[style]" id="'. $value['id'].'_style">'; $styles = array('none'=>'None', 'solid'=>'Solid', 'dashed'=>'Dashed', 'dotted'=>'Dotted'); foreach ($styles as $i=>$style){ $output .= '<option value="'. $i .'" ' . selected($border_stored['style'], $i, false) . '>'. $style .'</option>'; } $output .= '</select></div>'; /* Border Color */ $output .= '<div id="' . $value['id'] . '_color_picker" class="colorSelector"><div style="background-color: '.$border_stored['color'].'"></div></div>'; $output .= '<input class="of-color of-border of-border-color" name="'.$value['id'].'[color]" id="'. $value['id'] .'_color" type="text" value="'. $border_stored['color'] .'" />'; break; //images checkbox - use image as checkboxes case 'images': $i = 0; $select_value = (isset($smof_data[$value['id']])) ? $smof_data[$value['id']] : ''; foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if(NULL!=checked($select_value, $key, false)) { $checked = checked($select_value, $key, false); $selected = 'of-radio-img-selected'; } $output .= '<span>'; $output .= '<input type="radio" id="of-radio-img-' . $value['id'] . $i . '" class="checkbox of-radio-img-radio" value="'.$key.'" name="'.$value['id'].'" '.$checked.' />'; $output .= '<div class="of-radio-img-label">'. $key .'</div>'; $output .= '<img src="'.$option.'" alt="" class="of-radio-img-img '. $selected .'" onClick="document.getElementById(\'of-radio-img-'. $value['id'] . $i.'\').checked = true;" />'; $output .= '</span>'; } break; //info (for small intro box etc) case "info": $info_text = $value['std']; $output .= '<div class="of-info">'.$info_text.'</div>'; break; //display a single image case "image": $src = $value['std']; $output .= '<img src="'.$src.'">'; break; //tab heading case 'heading': if($counter >= 2){ $output .= '</div>'."\n"; } //custom icon $icon = ''; if(isset($value['icon'])){ $icon = ' style="background-image: url('. $value['icon'] .');"'; } $header_class = str_replace(' ','',strtolower($value['name'])); $jquery_click_hook = str_replace(' ', '', strtolower($value['name']) ); $jquery_click_hook = "of-option-" . trim(preg_replace('/ +/', '', preg_replace('/[^A-Za-z0-9 ]/', '', urldecode(html_entity_decode(strip_tags($jquery_click_hook)))))); $menu .= '<li class="'. $header_class .'"><a title="'. $value['name'] .'" href="#'. $jquery_click_hook .'"'. $icon .'>'. $value['name'] .'</a></li>'; $output .= '<div class="group" id="'. $jquery_click_hook .'"><h2>'.$value['name'].'</h2>'."\n"; break; //drag & drop slide manager case 'slider': $output .= '<div class="slider"><ul id="'.$value['id'].'">'; $slides = $smof_data[$value['id']]; $count = count($slides); if ($count < 2) { $oldorder = 1; $order = 1; $output .= Options_Machine::optionsframework_slider_function($value['id'],$value['std'],$oldorder,$order); } else { $i = 0; foreach ($slides as $slide) { $oldorder = $slide['order']; $i++; $order = $i; $output .= Options_Machine::optionsframework_slider_function($value['id'],$value['std'],$oldorder,$order); } } $output .= '</ul>'; $output .= '<a href="#" class="button slide_add_button">Add New Slide</a></div>'; break; //drag & drop block manager case 'sorter':
// Make sure to get list of all the default blocks first $all_blocks = $value['std'];
$temp = array(); // holds default blocks $temp2 = array(); // holds saved blocks
foreach($all_blocks as $blocks) { $temp = array_merge($temp, $blocks); }
$sortlists = isset($data[$value['id']]) && !empty($data[$value['id']]) ? $data[$value['id']] : $value['std'];
foreach( $sortlists as $sortlist ) { $temp2 = array_merge($temp2, $sortlist); }
// now let's compare if we have anything missing foreach($temp as $k => $v) { if(!array_key_exists($k, $temp2)) { $sortlists['disabled'][$k] = $v; } }
// now check if saved blocks has blocks not registered under default blocks foreach( $sortlists as $key => $sortlist ) { foreach($sortlist as $k => $v) { if(!array_key_exists($k, $temp)) { unset($sortlist[$k]); } } $sortlists[$key] = $sortlist; }
// assuming all sync'ed, now get the correct naming for each block foreach( $sortlists as $key => $sortlist ) { foreach($sortlist as $k => $v) { $sortlist[$k] = $temp[$k]; } $sortlists[$key] = $sortlist; }
$output .= '<div id="'.$value['id'].'" class="sorter">';
if ($sortlists) {
foreach ($sortlists as $group=>$sortlist) {
$output .= '<ul id="'.$value['id'].'_'.$group.'" class="sortlist_'.$value['id'].'">'; $output .= '<h3>'.$group.'</h3>';
foreach ($sortlist as $key => $list) {
$output .= '<input class="sorter-placebo" type="hidden" name="'.$value['id'].'['.$group.'][placebo]" value="placebo">';
if ($key != "placebo") {
$output .= '<li id="'.$key.'" class="sortee">'; $output .= '<input class="position" type="hidden" name="'.$value['id'].'['.$group.']['.$key.']" value="'.$list.'">'; $output .= $list; $output .= '</li>';
}
}
$output .= '</ul>'; } }
$output .= '</div>'; break; //background images option case 'tiles': $i = 0; $select_value = isset($smof_data[$value['id']]) && !empty($smof_data[$value['id']]) ? $smof_data[$value['id']] : ''; if (is_array($value['options'])) { foreach ($value['options'] as $key => $option) { $i++; $checked = ''; $selected = ''; if(NULL!=checked($select_value, $option, false)) { $checked = checked($select_value, $option, false); $selected = 'of-radio-tile-selected'; } $output .= '<span>'; $output .= '<input type="radio" id="of-radio-tile-' . $value['id'] . $i . '" class="checkbox of-radio-tile-radio" value="'.$option.'" name="'.$value['id'].'" '.$checked.' />'; $output .= '<div class="of-radio-tile-img '. $selected .'" style="background: url('.$option.')" onClick="document.getElementById(\'of-radio-tile-'. $value['id'] . $i.'\').checked = true;"></div>'; $output .= '</span>'; } } break; //backup and restore options data case 'backup': $instructions = $value['desc']; $backup = of_get_options(BACKUPS); $init = of_get_options('smof_init');
if(!isset($backup['backup_log'])) { $log = 'No backups yet'; } else { $log = $backup['backup_log']; } $output .= '<div class="backup-box">'; $output .= '<div class="instructions">'.$instructions."\n"; $output .= '<p><strong>'. __('Last Backup : ').'<span class="backup-log">'.$log.'</span></strong></p></div>'."\n"; $output .= '<a href="#" id="of_backup_button" class="button" title="Backup Options">Backup Options</a>'; $output .= '<a href="#" id="of_restore_button" class="button" title="Restore Options">Restore Options</a>'; $output .= '</div>'; break; //export or import data between different installs case 'transfer': $instructions = $value['desc']; $output .= '<textarea id="export_data" rows="8">'.base64_encode(serialize($smof_data)) /* 100% safe - ignore theme check nag */ .'</textarea>'."\n"; $output .= '<a href="#" id="of_import_button" class="button" title="Restore Options">Import Options</a>'; break; // google font field case 'select_google_font': $output .= '<div class="select_wrapper">'; $output .= '<select class="select of-input google_font_select" name="'.$value['id'].'" id="'. $value['id'] .'">'; foreach ($value['options'] as $select_key => $option) { $output .= '<option value="'.$select_key.'" ' . selected((isset($smof_data[$value['id']]))? $smof_data[$value['id']] : "", $option, false) . ' />'.$option.'</option>'; } $output .= '</select></div>'; if(isset($value['preview']['text'])){ $g_text = $value['preview']['text']; } else { $g_text = '0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'; } if(isset($value['preview']['size'])) { $g_size = 'style="font-size: '. $value['preview']['size'] .';"'; } else { $g_size = ''; } $hide = " hide"; if ($smof_data[$value['id']] != "none" && $smof_data[$value['id']] != "") $hide = ""; $output .= '<p class="'.$value['id'].'_ggf_previewer google_font_preview'.$hide.'" '. $g_size .'>'. $g_text .'</p>'; break; //JQuery UI Slider case 'sliderui': $s_val = $s_min = $s_max = $s_step = $s_edit = '';//no errors, please $s_val = stripslashes($smof_data[$value['id']]); if(!isset($value['min'])){ $s_min = '0'; }else{ $s_min = $value['min']; } if(!isset($value['max'])){ $s_max = $s_min + 1; }else{ $s_max = $value['max']; } if(!isset($value['step'])){ $s_step = '1'; }else{ $s_step = $value['step']; } if(!isset($value['edit'])){ $s_edit = ' readonly="readonly"'; } else { $s_edit = ''; } if ($s_val == '') $s_val = $s_min; //values $s_data = 'data-id="'.$value['id'].'" data-val="'.$s_val.'" data-min="'.$s_min.'" data-max="'.$s_max.'" data-step="'.$s_step.'"'; //html output $output .= '<input type="text" name="'.$value['id'].'" id="'.$value['id'].'" value="'. $s_val .'" class="mini" '. $s_edit .' />'; $output .= '<div id="'.$value['id'].'-slider" class="smof_sliderui" style="margin-left: 7px;" '. $s_data .'></div>'; break; //Switch option case 'switch': if (!isset($smof_data[$value['id']])) { $smof_data[$value['id']] = 0; } $fold = ''; if (array_key_exists("folds",$value)) $fold="s_fld "; $cb_enabled = $cb_disabled = '';//no errors, please //Get selected if ($smof_data[$value['id']] == 1){ $cb_enabled = ' selected'; $cb_disabled = ''; }else{ $cb_enabled = ''; $cb_disabled = ' selected'; } //Label ON if(!isset($value['on'])){ $on = "On"; }else{ $on = $value['on']; } //Label OFF if(!isset($value['off'])){ $off = "Off"; }else{ $off = $value['off']; } $output .= '<p class="switch-options">'; $output .= '<label class="'.$fold.'cb-enable'. $cb_enabled .'" data-id="'.$value['id'].'"><span>'. $on .'</span></label>'; $output .= '<label class="'.$fold.'cb-disable'. $cb_disabled .'" data-id="'.$value['id'].'"><span>'. $off .'</span></label>'; $output .= '<input type="hidden" class="'.$fold.'checkbox of-input" name="'.$value['id'].'" id="'. $value['id'] .'" value="0"/>'; $output .= '<input type="checkbox" id="'.$value['id'].'" class="'.$fold.'checkbox of-input main_checkbox" name="'.$value['id'].'" value="1" '. checked($smof_data[$value['id']], 1, false) .' />'; $output .= '</p>'; break;
// Uploader 3.5 case "upload": case "media":
if(!isset($value['mod'])) $value['mod'] = ''; $u_val = ''; if($smof_data[$value['id']]){ $u_val = stripslashes($smof_data[$value['id']]); }
$output .= Options_Machine::optionsframework_media_uploader_function($value['id'],$u_val, $value['mod']); break; }
do_action('optionsframework_machine_loop', array( 'options' => $options, 'smof_data' => $smof_data, 'defaults' => $defaults, 'counter' => $counter, 'menu' => $menu, 'output' => $output, 'value' => $value )); if ($smof_output != "") { $output .= $smof_output; $smof_output = ""; } //description of each option if ( $value['type'] != 'heading') { if(!isset($value['desc'])){ $explain_value = ''; } else{ $explain_value = '<div class="explain">'. $value['desc'] .'</div>'."\n"; } $output .= '</div>'.$explain_value."\n"; $output .= '<div class="clear"> </div></div></div>'."\n"; } } /* condition empty end */ }
if ($update_data == true) { of_save_options($smof_data); } $output .= '</div>';
do_action('optionsframework_machine_after', array( 'options' => $options, 'smof_data' => $smof_data, 'defaults' => $defaults, 'counter' => $counter, 'menu' => $menu, 'output' => $output, 'value' => $value )); if ($smof_output != "") { $output .= $smof_output; $smof_output = ""; } return array($output,$menu,$defaults); }
/** * Native media library uploader * * @uses get_theme_mod() * * @access public * @since 1.0.0 * * @return string */ public static function optionsframework_media_uploader_function($id,$std,$mod){
$data = of_get_options(); $smof_data = of_get_options(); $uploader = ''; $upload = ""; if (isset($smof_data[$id])) $upload = $smof_data[$id]; $hide = ''; if ($mod == "min") {$hide ='hide';} if ( $upload != "") { $val = $upload; } else {$val = $std;} $uploader .= '<input class="'.$hide.' upload of-input" name="'. $id .'" id="'. $id .'_upload" value="'. $val .'" />'; //Upload controls DIV $uploader .= '<div class="upload_button_div">'; //If the user has WP3.5+ show upload/remove button if ( function_exists( 'wp_enqueue_media' ) ) { $uploader .= '<span class="button media_upload_button" id="'.$id.'">Upload</span>'; if(!empty($upload)) {$hide = '';} else { $hide = 'hide';} $uploader .= '<span class="button remove-image '. $hide.'" id="reset_'. $id .'" title="' . $id . '">Remove</span>'; } else { $output .= '<p class="upload-notice"><i>Upgrade your version of WordPress for full media support.</i></p>'; }
$uploader .='</div>' . "\n";
//Preview $uploader .= '<div class="screenshot">'; if(!empty($upload)){ $uploader .= '<a class="of-uploaded-image" href="'. $upload . '">'; $uploader .= '<img class="of-option-image" id="image_'.$id.'" src="'.$upload.'" alt="" />'; $uploader .= '</a>'; } $uploader .= '</div>'; $uploader .= '<div class="clear"></div>' . "\n"; return $uploader; }
/** * Drag and drop slides manager * * @uses get_theme_mod() * * @access public * @since 1.0.0 * * @return string */ public static function optionsframework_slider_function($id,$std,$oldorder,$order){ $data = of_get_options(); $smof_data = of_get_options(); $slider = ''; $slide = array(); if (isset($smof_data[$id])) $slide = $smof_data[$id]; if (isset($slide[$oldorder])) { $val = $slide[$oldorder]; } else {$val = $std;} //initialize all vars $slidevars = array('title','url','link','description'); foreach ($slidevars as $slidevar) { if (!isset($val[$slidevar])) { $val[$slidevar] = ''; } } //begin slider interface if (!empty($val['title'])) { $slider .= '<li><div class="slide_header"><strong>'.stripslashes($val['title']).'</strong>'; } else { $slider .= '<li><div class="slide_header"><strong>Slide '.$order.'</strong>'; } $slider .= '<input type="hidden" class="slide of-input order" name="'. $id .'['.$order.'][order]" id="'. $id.'_'.$order .'_slide_order" value="'.$order.'" />'; $slider .= '<a class="slide_edit_button" href="#">Edit</a></div>'; $slider .= '<div class="slide_body">'; $slider .= '<label>Title</label>'; $slider .= '<input class="slide of-input of-slider-title" name="'. $id .'['.$order.'][title]" id="'. $id .'_'.$order .'_slide_title" value="'. stripslashes($val['title']) .'" />'; $slider .= '<label>Image URL</label>'; $slider .= '<input class="upload slide of-input" name="'. $id .'['.$order.'][url]" id="'. $id .'_'.$order .'_slide_url" value="'. $val['url'] .'" />'; $slider .= '<div class="upload_button_div"><span class="button media_upload_button" id="'.$id.'_'.$order .'">Upload</span>'; if(!empty($val['url'])) {$hide = '';} else { $hide = 'hide';} $slider .= '<span class="button remove-image '. $hide.'" id="reset_'. $id .'_'.$order .'" title="' . $id . '_'.$order .'">Remove</span>'; $slider .='</div>' . "\n"; $slider .= '<div class="screenshot">'; if(!empty($val['url'])){ $slider .= '<a class="of-uploaded-image" href="'. $val['url'] . '">'; $slider .= '<img class="of-option-image" id="image_'.$id.'_'.$order .'" src="'.$val['url'].'" alt="" />'; $slider .= '</a>'; } $slider .= '</div>'; $slider .= '<label>Link URL (optional)</label>'; $slider .= '<input class="slide of-input" name="'. $id .'['.$order.'][link]" id="'. $id .'_'.$order .'_slide_link" value="'. $val['link'] .'" />'; $slider .= '<label>Description (optional)</label>'; $slider .= '<textarea class="slide of-input" name="'. $id .'['.$order.'][description]" id="'. $id .'_'.$order .'_slide_description" cols="8" rows="8">'.stripslashes($val['description']).'</textarea>'; $slider .= '<a class="slide_delete_button" href="#">Delete</a>'; $slider .= '<div class="clear"></div>' . "\n"; $slider .= '</div>'; $slider .= '</li>'; return $slider; }
}//end Options Machine class
?>
|