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
|
<?php
/* pluginbuddy_ui class * * Handles typical user interface items used in WordPress development. * * @author Dustin Bolton * @version 1.0.0 */ class pb_backupbuddy_ui {
private $_tab_interface_tag = ''; /* pluginbuddy_ui->start_metabox() * * Starts a metabox. Use with end_metabox(). * @see pluginbuddy_ui->end_metabox * * @param string $title Title to display for the metabox. * @param boolean $echo Echos if true; else returns. * @param boolean/string $small_or_css true: size is limited smaller. false: size is limited larger. If a string then interpreted as CSS. * @return null/string Returns null if $echo is true; else returns string with HTML. */ public function start_metabox( $title, $echo = true, $small_or_css = false ) { if ( $small_or_css === false ) { // Large size. $css = 'width: 70%; min-width: 720px;'; } elseif ( $small_or_css === true ) { // Small size. $css = 'width: 20%; min-width: 250px;'; } else { // String so interpret as CSS. $css = $small_or_css; } $css .= ' padding-top: 0; margin-top: 10px; cursor: auto;'; $response = '<div class="metabox-holder postbox" style="' . $css . '"> <h3 class="hndle" style="cursor: auto;"><span>' . $title . '</span></h3> <div class="inside">'; if ( $echo === true ) { echo $response; } else { return $response; } } // End start_metabox(). /* pluginbuddy_ui->end_metabox() * * Ends a metabox. Use with start_metabox(). * @see pluginbuddy_ui->start_metabox * * @param boolean $echo Echos if true; else returns. * @return null/string Returns null if $echo is true; else returns string with HTML. */ public function end_metabox( $echo = true ) { $response = ' </div> </div>'; if ( $echo === true ) { echo $response; } else { return $response; } } // End end_metabox(). /* pluginbuddy_ui->title() * * Displays a styled, properly formatted title for pages. * * @param string $title Title to display. * @param boolean $echo Whether or not to echo the string or return. * @return null/string Returns null if $echo is true; else returns string with HTML. */ public function title( $title, $echo = true ) { $return = '<h2><span class="backupbuddy-icon-drive" style="font-size: 1.2em; vertical-align: -4px;"></span> ' . $title . '</h2><br />'; if ( $echo === true ) { echo $return; } else { return $return; } } // End title(). /* pluginbuddy_ui->button() * * Displays a nice pretty styled button. How nice. Always returns. * * @param string $url URL (href) for the button to link to. * @param string $text Text to display in the button. * @param string $title Optional title text to display on hover in the title tag. * @param boolean $primary (optional) Whether or not this is a primary button. Primary buttons are blue and strong where default non-primary is grey and gentle. * @param string $additional_class (optional) Additional CSS class to apply to button. Useful for thickbox or other JS stuff. * @param string $id (optional) HTML ID to apply. Useful for JS. * @return string HTML string for the button. */ public function button( $url, $text, $title = '', $primary = false, $additional_class = '', $id = '' ) { if ( $primary === false ) { return '<a class="button secondary-button ' . $additional_class . '" style="margin-top: 3px;" id="' . $id . '" title="' . $title . '" href="' . $url . '">' . $text . '</a>'; } else { return '<a class="button button-primary ' . $additional_class . '" style="margin-top: 3px;" id="' . $id . '" title="' . $title . '" href="' . $url . '">' . $text . '</a>'; } } // End button(). /* pluginbuddy_ui->note() * * Display text in a subtle way. * * @param string $text Text of note. * @param boolean $echo Whether or not to echo the string or return. * @return null/string Returns null if $echo is true; else returns string with HTML. */ public static function note( $text, $echo = true ) { $return = '<span class="description"><i>' . $text . '</i></span>'; if ( $echo === true ) { echo $return; } else { return $return; } } // End note(). /* pluginbuddy_ui->list_table() * * Displays a nice table with multiple columns, rows, bulk actions, hover actions, etc similar to WordPress posts table. * Currently only supports echo of output. * * @param array $items Array of rows to display. Each row array contains an array with the columns. Typically set in controller. * Ex: array( array( 'blue', 'red' ), array( 'brown', 'green' ) ). * If the value for an item is an array then the first value will be assigned to the rel tag of any hover actions. If not * an array then the value itself will be put in the rel tag. If an array the second value will be the one displayed in the column. * BackupBuddy needed the displayed item in the column to be a link (for downloading backups) but the backup file as the rel. * @param array $settings Array of all the various settings. Merged with defaults prior to usage. Typically set in view. * See $default_settings at beginning of function for available settings. * Ex: $settings = array( * 'action' => pb_backupbuddy::plugin_url(), * 'columns' => array( 'Group Name', 'Images', 'Shortcode' ), * 'hover_actions' => array( 'edit' => 'Edit Group Settings' ), // Slug can be a URL. In this case the value of the hovered row will be appended to the end of the URL. TODO: Make the first hover action be the link for the first listed item. * 'bulk_actions' => array( 'delete_images' => 'Delete' ), * ); * @return null */ public static function list_table( $items, $settings ) { $default_settings = array( 'columns' => array(), 'hover_actions' => array(), 'bulk_actions' => array(), 'hover_action_column_key' => '', // int of column to set value= in URL and rel tag= for using in JS. 'action' => '', 'reorder' => '', 'after_bulk' => '', 'css' => '', ); // Merge defaults. $settings = array_merge( $default_settings, $settings ); // Function to iterate through bulk actions. Top and bottom set are the same. if ( !function_exists( 'bulk_actions' ) ) { function bulk_actions( $settings, $hover_note = false ) { if ( count( $settings['bulk_actions'] ) > 0 ) { echo '<div style="padding-bottom: 3px; padding-top: 3px;">'; if ( count( $settings['bulk_actions'] ) == 1 ) { foreach( $settings['bulk_actions'] as $action_slug => $action_title ) { echo '<input type="hidden" name="bulk_action" value="' . $action_slug . '">'; echo '<input type="submit" name="do_bulk_action" value="' . $action_title . '" class="button secondary-button backupbuddy-do_bulk_action">'; } } else { echo '<select name="bulk_action" class="actions">'; foreach ( $settings['bulk_actions'] as $action_slug => $action_title ) { echo '<option>Bulk Actions</option>'; echo '<option value="' . $action_slug . '">' . $action_title . '</option>'; } echo '</select> '; //echo self::button( '#', 'Apply' ); echo '<input type="submit" name="do_bulk_action" value="Apply" class="button secondary-button backupbuddy-do_bulk_action">'; } echo ' '; echo $settings['after_bulk']; echo '<div class="alignright actions">'; if ( $hover_note === true ) { echo pb_backupbuddy::$ui->note( 'Hover over items above for additional options.' ); } if ( $settings['reorder'] != '' ) { echo ' <input type="submit" name="save_order" id="save_order" value="Save Order" class="button-secondary" />'; } echo '</div>'; echo '</div>'; } } // End subfunction bulk_actions(). } // End if function does not exist. if ( $settings['action'] != '' ) { echo '<form method="post" action="' . $settings['action'] . '">'; pb_backupbuddy::nonce(); if ( $settings['reorder'] != '' ) { echo '<input type="hidden" name="order" value="" id="pb_order">'; } } echo '<div style="width: 70%; min-width: 720px; ' . $settings['css'] . '">'; // Display bulk actions (top). bulk_actions( $settings ); echo '<table class="widefat"'; echo ' id="test">'; echo ' <thead> <tr class="thead">'; if ( count( $settings['bulk_actions'] ) > 0 ) { echo' <th scope="col" class="check-column"><input type="checkbox" class="check-all-entries" /></th>'; } foreach ( $settings['columns'] as $column ) { echo '<th>' . $column . '</th>'; } echo ' </tr> </thead> <tfoot> <tr class="thead">'; if ( count( $settings['bulk_actions'] ) > 0 ) { echo' <th scope="col" class="check-column"><input type="checkbox" class="check-all-entries" /></th>'; } foreach ( $settings['columns'] as $column ) { echo '<th>' . $column . '</th>'; } echo ' </tr> </tfoot> <tbody'; if ( $settings['reorder'] != '' ) { echo ' class="pb_reorder"'; } echo '>'; // LOOP THROUGH EACH ROW. foreach ( (array)$items as $item_id => $item ) { echo ' <tr class="entry-row alternate" id="pb_rowitem-' . $item_id . '">'; if ( count( $settings['bulk_actions'] ) > 0 ) { echo' <th scope="row" class="check-column"><input type="checkbox" name="items[]" class="entries" value="' . $item_id . '"></th>'; } echo ' <td>'; if ( is_array( $item['0'] ) ) { if ( $item['0'][1] == '' ) { echo ' '; } else { echo $item['0'][1]; } } else { if ( $item['0'] == '' ) { echo ' '; } else { echo $item['0']; } } echo ' <div class="row-actions" style="margin-top: 10px;">'; // style="margin:0; padding:0;" $i = 0; foreach ( $settings['hover_actions'] as $action_slug => $action_title ) { // Display all hover actions. $i++; if ( $settings['hover_action_column_key'] != '' ) { if ( is_array( $item[$settings['hover_action_column_key']] ) ) { $hover_action_column_value = $item[$settings['hover_action_column_key']][0]; } else { $hover_action_column_value = $item[$settings['hover_action_column_key']]; } } else { $hover_action_column_value = ''; } if ( strstr( $action_slug, 'http' ) === false ) { // Word hover action slug. $hover_link= pb_backupbuddy::page_url() . '&' . $action_slug . '=' . $item_id . '&value=' . $hover_action_column_value; } else { // URL hover action slug so just append value to URL. $hover_link = $action_slug . $hover_action_column_value; } echo '<a href="' . $hover_link . '" class="pb_' . pb_backupbuddy::settings( 'slug' ) . '_hoveraction_' . $action_slug . '" rel="' . $hover_action_column_value . '">' . $action_title . '</a>'; if ( $i < count( $settings['hover_actions'] ) ) { echo ' | '; } } echo ' </div> </td>'; if ( $settings['reorder'] != '' ) { $count = count( $item ) + 1; // Extra row for reordering. } else { $count = count( $item ); } // LOOP THROUGH COLUMNS FOR THIS ROW. for ( $i = 1; $i < $count; $i++ ) { if ( ! isset( $item[$i] ) ) { continue; } // This row does not have a corresponding index-based item. It is probably a named key not for use in table? echo '<td'; if ( $settings['reorder'] != '' ) { if ( $i == $settings['reorder'] ) { echo ' class="pb_draghandle" align="center"'; } } echo '>'; if ( ( $settings['reorder'] != '' ) && ( $i == ( $settings['reorder'] ) ) ) { echo '<img src="' . pb_backupbuddy::plugin_url() . '/pluginbuddy/images/draghandle.png" alt="Click and drag to reorder">'; } else { if ( $item[$i] == '' ) { echo ' '; } else { echo $item[$i]; } } echo '</td>'; }
echo ' </tr>'; }
echo ' </tbody>'; echo '</table>'; // Display bulk actions (bottom). bulk_actions( $settings, true ); echo '</div>'; if ( $settings['action'] != '' ) { echo '</form>'; } } // End list_table(). /** * pb_backupbuddy::get_feed() * * Gets an RSS or other feed and inserts it as a list of links... * * @param string $feed URL to the feed. * @param int $limit Number of items to retrieve. * @param string $append HTML to include in the list. Should usually be <li> items including the <li> code. * @param string $replace String to replace in every title returned. ie twitter includes your own username at the beginning of each line. * @return string */ public function get_feed( $feed, $limit, $append = '', $replace = '' ) { $return = ''; $feed_html = get_transient( md5( $feed ) ); if ( false === $feed_html ) { $feed_html = ''; require_once(ABSPATH.WPINC.'/feed.php'); $rss = fetch_feed( $feed ); if ( is_wp_error( $rss ) ) { $return .= '{Temporarily unable to load feed.}'; return $return; } $maxitems = $rss->get_item_quantity( $limit ); // Limit $rss_items = $rss->get_items(0, $maxitems); } $return .= '<ul class="pluginbuddy-nodecor" style="margin-left: 10px;">';
if ( $feed_html == '' ) { foreach ( (array) $rss_items as $item ) { $feed_html .= '<li style="list-style-type: none;"><a href="' . $item->get_permalink() . '" target="_new">'; $title = $item->get_title(); //, ENT_NOQUOTES, 'UTF-8'); if ( $replace != '' ) { $title = str_replace( $replace, '', $title ); } if ( strlen( $title ) < 30 ) { $feed_html .= $title; } else { $feed_html .= substr( $title, 0, 32 ) . ' ...'; } $feed_html .= '</a></li>'; } set_transient( md5( $feed ), $feed_html, 300 ); // expires in 300secs aka 5min } else { //echo 'CACHED'; } $return .= $feed_html; $return .= $append; $return .= '</ul>'; return $return; } // End get_feed(). /** * pb_backupbuddy::tip() * * Displays a message to the user when they hover over the question mark. Gracefully falls back to normal tooltip. * HTML is supposed within tooltips. * * @param string $message Actual message to show to user. * @param string $title Title of message to show to user. This is displayed at top of tip in bigger letters. Default is blank. (optional) * @param boolean $echo_tip Whether to echo the tip (default; true), or return the tip (false). (optional) * @return string/null If not echoing tip then the string will be returned. When echoing there is no return. */ public function tip( $message, $title = '', $echo_tip = true ) { $tip = ' <a class="pluginbuddy_tip" title="' . $title . ' - ' . $message . '"><img src="' . pb_backupbuddy::plugin_url() . '/pluginbuddy/images/pluginbuddy_tip.png" alt="(?)" /></a>'; if ( $echo_tip === true ) { echo $tip; } else { return $tip; } } // End tip(). /** * pb_backupbuddy::alert() * * Displays a message to the user at the top of the page when in the dashboard. * * @param string $message Message you want to display to the user. * @param boolean $error OPTIONAL! true indicates this alert is an error and displays as red. Default: false * @param int $error_code OPTIONAL! Error code number to use in linking in the wiki for easy reference. * @return null */ public function alert( $message, $error = false, $error_code = '', $rel_tag = '' ) { $log_error = false;
echo '<div id="message" style="padding: 9px;" rel="' . $rel_tag . '" class="pb_backupbuddy_alert '; if ( $error === false ) { echo 'updated fade'; } else { echo 'error'; $log_error = true; } if ( $error_code != '' ) { $message .= ' <a href="http://ithemes.com/codex/page/BackupBuddy:_Error_Codes#' . $error_code . '" target="_new"><i>' . pb_backupbuddy::settings( 'name' ) . ' Error Code ' . $error_code . ' - Click for more details.</i></a>'; $log_error = true; } if ( $log_error === true ) { pb_backupbuddy::log( $message . ' Error Code: ' . $error_code, 'error' ); } echo '" >' . $message . '</div>'; } // End alert(). /** * pb_backupbuddy::disalert() * * Displays a DISMISSABLE message to the user at the top of the page when in the dashboard. * * @param string $message Message you want to display to the user. * @param boolean $error OPTIONAL! true indicates this alert is an error and displays as red. Default: false * @param int $error_code OPTIONAL! Error code number to use in linking in the wiki for easy reference. * @return null */ public function disalert( $unique_id, $message, $error = false ) { if ( ! isset( pb_backupbuddy::$options['disalerts'][$unique_id] ) ) { $message = '<a style="float: right;" class="pb_backupbuddy_disalert" href="#" title="' . __( 'Dismiss this alert. Unhide dismissed alerts on the Settings page.', 'it-l10n-backupbuddy' ) . '" alt="' . pb_backupbuddy::ajax_url( 'disalert' ) . '"><b>' . __( 'Dismiss', 'it-l10n-backupbuddy' ) . '</b></a><div style="margin-right: 60px;">' . $message . '</div>'; $this->alert( $message, $error, '', $unique_id ); } else { echo '<!-- Previously Dismissed Alert: `' . htmlentities( $message ) . '` -->'; } return; } // End alert(). /** * pb_backupbuddy::video() * * Displays a YouTube video to the user when they hover over the question video mark. * HTML is supposed within tooltips. * * @param string $video_key YouTube video key from the URL ?v=VIDEO_KEY_HERE -- To jump to a certain timestamp add #SECONDS to the end of the key, where SECONDS is the number of seconds into the video to start at. Example to start 65 seconds into a video: 9ZHWGjBr84s#65. This must be in seconds format. * @param string $title Title of message to show to user. This is displayed at top of tip in bigger letters. Default is blank. (optional) * @param boolean $echo_tip Whether to echo the tip (default; true), or return the tip (false). (optional) * @return string/null If not echoing tip then the string will be returned. When echoing there is no return. */ public function video( $video_key, $title = '', $echo_tip = true ) { if ( !defined( 'PB_IMPORTBUDDY' ) ) { global $wp_scripts; if ( is_object( $wp_scripts ) ) { if ( !in_array( 'thickbox', $wp_scripts->done ) ) { wp_enqueue_script( 'thickbox' ); wp_print_scripts( 'thickbox' ); wp_print_styles( 'thickbox' ); } } } if ( strstr( $video_key, '#' ) ) { $video = explode( '#', $video_key ); $video[1] = '&start=' . $video[1]; } else { $video[0] = $video_key; $video[1] = ''; }
$tip = '<a target="_new" href="http://www.youtube.com/embed/' . urlencode( $video[0] ) . '?autoplay=1' . $video[1] . '&TB_iframe=1&width=600&height=400" class="thickbox pluginbuddy_tip" title="Video Tutorial - ' . $title . '"><img src="' . pb_backupbuddy::plugin_url() . '/pluginbuddy/images/pluginbuddy_play.png" alt="(video)" /></a>'; if ( $echo_tip === true ) { echo $tip; } else { return $tip; } } // End video(). /* start_tabs() * * Starts a tabbed interface. * @see end_tabs(). * * @param string $interface_tag Tag/slug for this entire tabbed interface. Should be unique. * @param array $tabs Array containing an array of settings for this tabbed interface. Ex: array( array( 'title'> 'my title', 'slug' => 'mytabs' ) ); * Optional setting with key `ajax_url` may define a URL for AJAX loading. * @param string $css Additional CSS to apply to main outer div. (optional) * @param boolean $echo Echo output instead of returning. (optional) * @param int $active_tab_index Tab to start as active/selected. * @return null/string null if $echo = false, all data otherwise. */ public function start_tabs( $interface_tag, $tabs, $css = '', $echo = true, $active_tab_index = 0 ) { $this->_tab_interface_tag = $interface_tag; pb_backupbuddy::load_script( 'pb_tabs.js', true ); $prefix = 'pb_' . pb_backupbuddy::settings( 'slug' ) . '_'; // pb_PLUGINSLUG_ $return = ''; /* $return .= '<script type="text/javascript">'; $return .= ' jQuery(document).ready(function() {'; $return .= ' jQuery("#' . $prefix . $this->_tab_interface_tag . '_tabs").tabs({ active: ' . $active_tab_index . ' });'; $return .= ' });'; $return .= '</script>'; */ $return .= '<div class="backupbuddy-tabs-wrap">'; $return .= '<h2 class="nav-tab-wrapper">'; $i = 0; foreach( $tabs as $tab ) { if ( ! isset( $tab['css'] ) ) { $tab['css'] = ''; } $active_tab_class = ''; if ( $active_tab_index == $i ) { $active_tab_class = 'nav-tab-active'; } if ( isset( $tab['ajax'] ) && ( $tab['ajax_url'] != '' ) ) { // AJAX tab. $return .= '<a class="nav-tab nav-tab-' . $i . ' ' . $active_tab_class . ' bb-tab-' . $tab['slug'] . '" href="javascript:void(0)" data-ajax="' . $tab['ajax_url'] . '">' . $tab['title'] . '</a>'; } elseif ( isset( $tab['url'] ) && ( $tab['url'] != '' ) ) { $return .= '<a class="nav-tab nav-tab-' . $i . ' ' . $active_tab_class . ' bb-tab-' . $tab['slug'] . '" href="' . $tab['url'] . '">' . $tab['title'] . '</a>'; } else { // Standard; NO AJAX. $return .= '<a class="nav-tab nav-tab-' . $i . ' ' . $active_tab_class . ' bb-tab-' . $tab['slug'] . '" style="' . $tab['css'] . '" href="#' . $prefix . $this->_tab_interface_tag . '_tab_' . $tab['slug'] . '">' . $tab['title'] . '</a>'; } $i++; } $return .= '</h2>'; /* $return .= '<div id="' . $prefix . $this->_tab_interface_tag . '_tabs" style="' . $css . '">'; $return .= '<ul>'; foreach( $tabs as $tab ) { if ( ! isset( $tab['css'] ) ) { $tab['css'] = ''; } if ( isset( $tab['ajax'] ) && ( $tab['ajax_url'] != '' ) ) { // AJAX tab. $return .= '<li><a href="' . $tab['ajax_url'] . '"><span>' . $tab['title'] . '</span></a></li>'; } else { // Standard; NO AJAX. $return .= '<li style="' . $tab['css'] . '"><a href="#' . $prefix . $this->_tab_interface_tag . '_tab_' . $tab['slug'] . '"><span>' . $tab['title'] . '</span></a></li>'; } } $return .= '</ul>'; $return .= '<br>'; $return .= '<div class="tabs-borderwrap">'; */ $return .= '<div class="backupbuddy-tab-blocks">'; if ( $echo === true ) { echo $return; } else { return $return; } } // End start_tabs(). /* end_tabs() * * Closes off a tabbed interface. * @see start_tabs(). * * @param boolean $echo Echo output instead of returning. (optional) * @return null/string null if $echo = false, all data otherwise. */ public function end_tabs( $echo = true ) { /* $return = ''; $return .= ' </div>'; $return .= '</div>'; */ $return = '</div></div>'; $this->_tab_interface_tag = ''; if ( $echo === true ) { echo $return; } else { return $return; } } // End end_tabs(). /* start_tab() * * Opens the start of an individual page to be loaded by a tab. * @see end_tab(). * * @param string $tab_tag Unique tag for this tab section. Must match the tag defined when creating the tab interface. * @param boolean $echo Echo output instead of returning. (optional) * @return null/string null if $echo = false, all data otherwise. */ public function start_tab( $tab_tag, $echo = true ) { $prefix = 'pb_' . pb_backupbuddy::settings( 'slug' ) . '_'; // pb_PLUGINSLUG_ $return = ''; $return .= '<div class="backupbuddy-tab" id="' . $prefix . $this->_tab_interface_tag . '_tab_' . $tab_tag . '">'; if ( $echo === true ) { echo $return; } else { return $return; } } // End start_tab(). /* end_tab() * * Closes this tab section. * @see start_tab(). * * @param string $tab_tag Unique tag for this tab section. Must match the tag defined when creating the tab interface. * @param boolean $echo Echo output instead of returning. (optional) * @return null/string null if $echo = false, all data otherwise. */ public function end_tab( $echo = true ) { $return = '</div>'; if ( $echo === true ) { echo $return; } else { return $return; } } // End end_tab(). /* ajax_header() * * Output HTML headers when using AJAX. * * @param boolean $js Whether or not to load javascript. Default false. * @param bool $padding Whether or not to padd wrapper div. Default has padding. * @return */ function ajax_header( $js = true, $padding = true ) { echo '<head>'; echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'; echo '<title>PluginBuddy</title>'; wp_print_styles( 'wp-admin' ); wp_print_styles( 'dashicons' ); wp_print_styles( 'buttons' ); wp_print_styles( 'colors' ); if ( $js === true ) { wp_enqueue_script( 'jquery' ); wp_print_scripts( 'jquery' ); } pb_backupbuddy::load_style( 'wp-admin.css' ); pb_backupbuddy::load_style( 'thickboxed.css' ); //echo '<link rel="stylesheet" href="' . pb_backupbuddy::plugin_url(); . '/css/admin.css" type="text/css" media="all" />'; pb_backupbuddy::load_script( 'admin.js', true ); pb_backupbuddy::load_style( 'admin.css', true ); pb_backupbuddy::load_script( 'tooltip.js', true ); echo '<body class="wp-core-ui" style="background: inherit;">'; if ( $padding === true ) { echo '<div style="padding: 8px; padding-left: 0; padding-right: 0;">'; } else { echo '<div>'; } } // End ajax_header(). function ajax_footer() { echo '</body>'; echo '</div>'; echo '</head>'; echo '</html>'; } // End ajax_footer(). } // End class pluginbuddy_ui.
?>
|