forked from brainstormforce/wp-freshdesk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin-settings.php
737 lines (653 loc) · 23.7 KB
/
admin-settings.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
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
class FreshDeskSettingsPage{
/**
* Holds the values to be used in the fields callbacks
*/
private $options;
private $url_options;
/**
* Start up
*/
public function __construct(){
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'page_init' ) );
}
/*
* Add options page
*/
public function add_plugin_page(){
// This page will be under "Settings"
add_options_page(
'Settings Admin',
'WP Freshdesk',
'manage_options',
'wp-freshdesk',
array( $this, 'create_admin_page' )
);
}
/*
* Options page callback
*/
public function create_admin_page(){
// Set class property
$this->options = get_option( 'fd_apikey' );
if( $this->options ){
$this->options['freshdesk_url'] = ( isset( $this->options['freshdesk_url'] ) ) ? rtrim( $this->options['freshdesk_url'], '/' ) . '/' : '';
}
if( isset( $this->options['freshdesk_url'] ) ) {
$this->options['freshdesk_url'] = rtrim( $this->options['freshdesk_url'], '/' ) . '/';
} else {
$this->options['freshdesk_url'] = '';
}
if ( !preg_match( "/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $this->options['freshdesk_url'] ) ) {
$this->options['freshdesk_url'] = '';
} else {
$this->options['freshdesk_url'];
}
$this->url_options = get_option( 'fd_url' );
$this->display_option = get_option( 'fd_display' );
?>
<div class="wrap about-wrap">
<div class="fd-heading-section">
<h1><?php echo __( 'WP Freshdesk Settings', 'freshdesk-api' ); ?></h1>
<div class="fd-about-text"><?php echo __( 'Now your users won\'t have to remember one more username and password! Configure your WordPress website and Freshdesk to work together to give your users Freshdesk Remote Authentication!', 'freshdesk-api' ); ?></div>
<div class="fd-badge"></div>
<h2 class="nav-tab-wrapper">
<a href="javascript:void(0);" id="tab-api" class="nav-tab nav-tab-active"><?php echo __( 'General Configuration', 'freshdesk-api' ); ?></a>
<a href="javascript:void(0);" id="tab-shortcode" class="nav-tab"><?php echo __( 'Shortcodes', 'freshdesk-api' ); ?></a>
<a href="javascript:void(0);" id="tab-url" class="nav-tab"><?php echo __( 'Freshdesk SSO', 'freshdesk-api' ); ?></a>
<a href="javascript:void(0);" id="tab-display" class="nav-tab"><?php echo __( 'Display Settings', 'freshdesk-api' ); ?></a>
</h2>
<div id="api-tab" class="fd-tabs">
<form method="post" action="options.php" autocomplete="off">
<?php
// This prints out all hidden setting fields
settings_fields( 'my_option_group' );
do_settings_sections( 'my-setting-admin' );
submit_button();?>
</form>
</div>
<div id="shortcode-tab" style="display:none;" class="fd-tabs">
<p><?php echo __( 'Paste the below shortcode on your page. This shortcode will display all the tickets on your page. It also provides filter options and search options. You can filter tickets with respect to:', 'freshdesk-api' ); ?></p>
<table>
<tr>
<td><?php echo __( 'All tickets', 'freshdesk-api' ); ?></td>
<td><code>[fd_fetch_tickets]</code></td>
</tr>
<tr>
<td><?php echo __( 'Open', 'freshdesk-api' ); ?></td>
<td><code>[fd_fetch_tickets filter="Open"]</code></td>
</tr>
<tr>
<td><?php echo __( 'Resolved', 'freshdesk-api' ); ?></td>
<td><code>[fd_fetch_tickets filter="Resolved"]</code></td>
</tr>
<tr>
<td><?php echo __( 'Closed', 'freshdesk-api' ); ?></td>
<td><code>[fd_fetch_tickets filter="Closed"]</code></td>
</tr>
<tr>
<td><?php echo __( 'Pending', 'freshdesk-api' ); ?></td>
<td><code>[fd_fetch_tickets filter="Pending"]</code></td>
</tr>
<tr>
<td><?php echo __( 'Waiting on Customer', 'freshdesk-api' ); ?></td>
<td><code>[fd_fetch_tickets filter="Waiting on Customer"]</code></td>
</tr>
<tr>
<td><?php echo __( 'Waiting on Third Party', 'freshdesk-api' ); ?></td>
<td><code>[fd_fetch_tickets filter="Waiting on Third Party"]</code></td>
</tr>
</table>
</div>
<div id="url-tab" style="display:none;" class="fd-tabs">
<form method="post" action="options.php" id="url_form" autocomplete="off">
<?php
// This prints out all hidden setting fields
settings_fields( 'url_option' );
do_settings_sections( 'url-admin-setting' );
submit_button();?>
</form>
</div>
<div id="display-tab" style="display:none;" class="fd-tabs">
<form method="post" action="options.php" id="display_form" autocomplete="off">
<?php
// This prints out all hidden setting fields
settings_fields( 'display_option' );
do_settings_sections( 'display-admin-setting' );
submit_button();?>
</form>
</div>
</div>
<?php
}
/*
* Register and add settings
*/
public function page_init(){
//Enqueue all styles and scripts.
wp_register_script( 'fd-script', plugins_url('js/fd-script.js', __FILE__), array('jquery'), '1.1', true );
wp_enqueue_script( 'fd-script' );
wp_register_style( 'fd-style', plugins_url('css/fd-style.css', __FILE__) );
wp_enqueue_style( 'fd-style' );
// Register the setting tab
register_setting(
'my_option_group', // Option group
'fd_apikey', // Option name
array( $this, 'sanitize' ) // Sanitize
);
add_settings_section(
'setting_section_id', // ID
'', // Title
array( $this, 'print_section_info' ), // Callback
'my-setting-admin' // Page
);
add_settings_field(
'freshdesk_url', // ID
'Base Freshdesk URL', // Title
array( $this, 'freshdesk_url_callback' ), // Callback
'my-setting-admin', // Page
'setting_section_id' // Section
);
add_settings_field(
'freshdesk_apikey', // ID
'API Key', // Title
array( $this, 'freshdesk_apikey_callback' ), // Callback
'my-setting-admin', // Page
'setting_section_id' // Section
);
add_settings_field(
'use_apikey', // ID
'Use only API key?', // Title
array( $this, 'use_apikey_callback' ), // Callback
'my-setting-admin', // Page
'setting_section_id' // Section
);
add_settings_field(
'api_username', // ID
'Username', // Title
array( $this, 'api_username_callback' ), // Callback
'my-setting-admin', // Page
'setting_section_id' // Section
);
add_settings_field(
'api_pwd', // ID
'Password', // Title
array( $this, 'api_pwd_callback' ), // Callback
'my-setting-admin', // Page
'setting_section_id' // Section
);
// Register the setting tab
register_setting(
'url_option', // Option group
'fd_url' // Option name
);
add_settings_section(
'freshdesk_url_section', // ID
'', // Title
array( $this, 'print_section_info' ), // Callback
'url-admin-setting' // Page
);
add_settings_field(
'freshdesk_enable', // ID
'Enable SSO', // Title
array( $this, 'freshdesk_enable_callback' ), // Callback
'url-admin-setting', // Page
'freshdesk_url_section' // Section
);
add_settings_field(
'freshdesk_sharedkey', // ID
'Secret Shared Key', // Title
array( $this, 'freshdesk_sharedkey_callback' ), // Callback
'url-admin-setting', // Page
'freshdesk_url_section' // Section
);
add_settings_field(
'freshdesk_login_url', // ID
'Remote Login URL', // Title
array( $this, 'freshdesk_loginurl_callback' ), // Callback
'url-admin-setting', // Page
'freshdesk_url_section' // Section
);
add_settings_field(
'freshdesk_logout_url', // ID
'Remote Logout URL', // Title
array( $this, 'freshdesk_logouturl_callback' ), // Callback
'url-admin-setting', // Page
'freshdesk_url_section' // Section
);
// Register the display setting tab
register_setting(
'display_option', // Option group
'fd_display' // Option name
);
add_settings_section(
'freshdesk_display_section', // ID
'', // Title
array( $this, 'print_section_info' ), // Callback
'display-admin-setting' // Page
);
add_settings_field(
'fd_display_use_css', // ID
'Use Predefined CSS', // Title
array( $this, 'fd_display_use_css_callback' ), // Callback
'display-admin-setting', // Page
'freshdesk_display_section' // Section
);
add_settings_field(
'fd_display_description', // ID
'Show Description', // Title
array( $this, 'fd_display_description_callback' ), // Callback
'display-admin-setting', // Page
'freshdesk_display_section' // Section
);
add_settings_field(
'fd_display_priority_name', // ID
'Show Priority', // Title
array( $this, 'fd_display_priority_name_callback' ), // Callback
'display-admin-setting', // Page
'freshdesk_display_section' // Section
);
add_settings_field(
'fd_display_updated_at', // ID
'Show Updated Date', // Title
array( $this, 'fd_display_updated_at_callback' ), // Callback
'display-admin-setting', // Page
'freshdesk_display_section' // Section
);
add_settings_field(
'no_tickets_msg', // ID
'No Tickets Error Message', // Title
array( $this, 'no_tickets_msg_callback' ), // Callback
'display-admin-setting', // Page
'freshdesk_display_section' // Section
);
}
/*
* Sanitize each setting field as needed
*
* @param array $input Contains all settings fields as array keys
*/
public function sanitize( $input ){
$new_input = array();
if( isset( $input['freshdesk_apikey'] ) )
$new_input['freshdesk_apikey'] = sanitize_text_field( $input['freshdesk_apikey'] );
if( isset( $input['freshdesk_url'] ) )
$new_input['freshdesk_url'] = sanitize_text_field( $input['freshdesk_url'] );
if( isset( $input['freshdesk_sharedkey'] ) )
$new_input['freshdesk_sharedkey'] = sanitize_text_field( $input['freshdesk_sharedkey'] );
if( isset( $input['api_username'] ) )
$new_input['api_username'] = sanitize_text_field( $input['api_username'] );
if( isset( $input['api_pwd'] ) )
$new_input['api_pwd'] = sanitize_text_field( $input['api_pwd'] );
if( isset( $input['use_apikey'] ) )
$new_input['use_apikey'] = sanitize_text_field( $input['use_apikey'] );
if( isset( $input['no_tickets_msg'] ) )
$new_input['no_tickets_msg'] = ( $input['no_tickets_msg'] );
if( isset( $input['fd_display_description'] ) )
$new_input['fd_display_description'] = sanitize_text_field( $input['fd_display_description'] );
if( isset( $input['fd_display_priority_name'] ) )
$new_input['fd_display_priority_name'] = sanitize_text_field( $input['fd_display_priority_name'] );
if( isset( $input['fd_display_updated_at'] ) )
$new_input['fd_display_updated_at'] = sanitize_text_field( $input['fd_display_updated_at'] );
return $new_input;
}
/*
* Print the Section text
*/
public function print_section_info(){
//Nothing to do here
}
/*
* Callback function for "Freshdesk API Key"
*/
public function freshdesk_apikey_callback(){
$val1 = $val2 = '';
if( isset( $this->options['freshdesk_apikey'] ) ) {
$val1 = esc_attr( $this->options['freshdesk_apikey']);
} else {
$val1 = '';
}
if( isset( $this->options['use_apikey'] ) ) {
$val2 = ( $this->options['use_apikey'] != 'on' ) ? 'readonly="readonly"' : '';
} else {
$val2 = 'readonly="readonly"';
}
if( empty( $this->options ) ) {
$val1 = '';
$val2 = '';
}
printf(
'<input autocomplete="off" type="text" id="freshdesk_apikey" name="fd_apikey[freshdesk_apikey]" value="%s" class="regular-text" %s />', $val1, $val2
);
printf( '<p id="timezone-description" class="description"><strong>Where can I find my API Key?</strong><br/>You can find the API key under,<br/>"User Profile" (top right options of your helpdesk) >> "Profile Settings" >> Your API Key</p>' );
}
/*
* Callback function for "Freshdesk Shared Secret Key"
*/
public function freshdesk_sharedkey_callback(){
$val1 = $val2 = '';
if( isset( $this->url_options['freshdesk_sharedkey'] ) ) {
$val1 = esc_attr( $this->url_options['freshdesk_sharedkey']);
} else {
$val1 = '';
}
if( isset( $this->url_options['freshdesk_enable'] ) ) {
$val2 = '';
} else {
$val2 = 'readonly="readonly"';
}
if( isset( $this->options['freshdesk_url'] ) && strlen( $this->options['freshdesk_url'] ) > 5 ) {
$val = $this->options['freshdesk_url'];
} else {
$val = 'https://your_domain.freshdesk.com/';
}
printf(
'<input autocomplete="off" type="text" id="freshdesk_sharedkey" name="fd_url[freshdesk_sharedkey]" value="%s" class="regular-text" %s />', $val1, $val2
);
printf( '<p id="timezone-description" class="description">Your shared token could be obtained on the <a target="_blank" href="%sadmin/security">Account Security page</a> in the <br> Single Sign-On >> "Simple SSO" section.</p>', $val
);
}
/*
* Callback function for "Freshdesk Admin Username"
*/
public function use_apikey_callback(){
$val = '';
$class = '';
$yesno = '';
if( isset( $this->options['use_apikey'] ) ) {
$val = ( $this->options['use_apikey'] == 'on' ) ? 'checked="checked"' : '';
} else {
$val = '';
}
if( !$this->options ){
$val = 'checked="checked"';
}
if( empty( $this->options ) ) {
$val = 'checked="checked"';
}
if( $val == '' ) {
$class = ' fd-use-apikey-no';
$yesno = 'No';
} else {
$class = ' fd-use-apikey-yes';
$yesno = 'Yes';
}
printf(
'<div id="fd-wrapper">
<div id="fd-main">
<div class="fd-container">
<div class="fd-settings">
<div class="fd-row">
<div class="fd-switch">
<input id="use_apikey" class="fd-toggle fd-toggle-round" type="checkbox" name="fd_apikey[use_apikey]" %s>
<label for="use_apikey"><p class="fd-use-apikey-yesno %s">%s</p></label>
</div>
</div>
</div>
</div>
</div>
</div>', $val, $class, $yesno
);
printf( '<p><strong>OR</strong></p>' );
}
/*
* Callback function for "Freshdesk Admin Username"
*/
public function api_username_callback(){
$val1 = $val2 = '';
if( !isset( $this->options['use_apikey'] ) ) {
if( isset( $this->options['api_username'] ) ) {
$val1 = esc_attr( $this->options['api_username'] );
$val2 = '';
}
} else {
if( isset( $this->options['api_username'] ) ) {
$val1 = esc_attr( $this->options['api_username'] );
}
$val2 = 'readonly="readonly"';
}
if( empty( $this->options ) ) {
$val1 = '';
$val2 = 'readonly="readonly"';
}
printf(
'<input type="text" autocomplete="off" placeholder="Username" id="api_username" name="fd_apikey[api_username]" value="%s" class="regular-text" %s>', $val1, $val2
);
}
/*
* Callback function for "Freshdesk Admin Password"
*/
public function api_pwd_callback(){
$val1 = $val2 = '';
if( !isset( $this->options['use_apikey'] ) ) {
if( isset( $this->options['api_pwd'] ) ) {
$val1 = esc_attr( $this->options['api_pwd'] );
$val2 = '';
}
} else {
if( isset( $this->options['api_pwd'] ) ) {
$val1 = esc_attr( $this->options['api_pwd'] );
}
$val2 = 'readonly="readonly"';
}
if( empty( $this->options ) ) {
$val1 = '';
$val2 = 'readonly="readonly"';
}
printf(
'<input type="password" autocomplete="off" placeholder="Password" id="api_pwd" name="fd_apikey[api_pwd]" class="regular-text" value="%s" %s>', $val1, $val2
);
}
/*
* Callback function for "Freshdesk URL"
*/
public function freshdesk_url_callback(){
$val = '';
if( isset( $this->options['freshdesk_url'] ) && strlen( $this->options['freshdesk_url'] ) > 5 ) {
$val = esc_attr( $this->options['freshdesk_url']);
} else {
$val = '';
}
printf(
'<input type="text" autocomplete="off" id="freshdesk_url" name="fd_apikey[freshdesk_url]" value="%s" class="regular-text" placeholder="Ex: https://your_domain_name.freshdesk.com/" />', $val
);
printf( '<p id="timezone-description" class="description">This is the base Freshdesk support URL.</p>' );
}
/*
* Callback function for "Login URL" for SSO
*/
public function freshdesk_loginurl_callback(){
printf(
'<code>' . site_url() . '/wp-login.php?action=fd-remote-login' . '</code>'
);
printf(
'<p class="description">The settings that need to be configured in your Freshdesk account.</p>'
);
}
/*
* Callback function for "Logout URL" for SSO
*/
public function freshdesk_logouturl_callback(){
$val = '';
if( isset( $this->options['freshdesk_url'] ) && strlen( $this->options['freshdesk_url'] ) > 5 ) {
$val = $this->options['freshdesk_url'];
} else {
$val = 'https://your_domain.freshdesk.com/';
}
printf(
'<code>' . site_url() . '/wp-login.php?action=fd-remote-logout' . '</code>'
);
printf(
'<p class="description">The settings that need to be configured in your Freshdesk account.</p><br/>
<p class="description">Remember that you can always go to:
<a href="%slogin/normal" target="_blank">%saccess/normal</a><br/>
to use the regular login in case you get unlucky and somehow lock yourself out of Freshdesk. </p>', $val, $val
);
}
/*
* Callback function for "Enable SSO" checkbox
*/
public function freshdesk_enable_callback(){
$val = '';
if( isset( $this->url_options['freshdesk_enable'] ) ){
$val = ( $this->url_options['freshdesk_enable'] == 'on' ) ? 'checked="checked"' : '';
} else {
$val = '';
}
if( $val == '' ) {
$class = ' fd-use-apikey-no';
$yesno = 'No';
} else {
$class = ' fd-use-apikey-yes';
$yesno = 'Yes';
}
printf(
'<div id="fd-wrapper">
<div id="fd-main">
<div class="fd-container">
<div class="fd-settings">
<div class="fd-row">
<div class="fd-switch">
<input id="freshdesk_enable" class="fd-toggle fd-toggle-round" type="checkbox" name="fd_url[freshdesk_enable]" %s>
<label for="freshdesk_enable"><p id="freshdesk_enable-p" class="fd-use-apikey-yesno %s">%s</p></label>
</div>
</div>
</div>
</div>
</div>
</div>', $val, $class, $yesno
);
}
/*
* Callback function for no ticket message text box
*/
public function no_tickets_msg_callback(){
$val = '';
if( isset( $this->display_option['no_tickets_msg'] ) ){
$val = ( $this->display_option['no_tickets_msg'] != '' ) ? htmlentities( $this->display_option['no_tickets_msg'] ) : '';
}
printf(
'<textarea autocomplete="off" placeholder="Eg: Sorry! No Tickets!" id="no_tickets_msg" name="fd_display[no_tickets_msg]" class="regular-text" rows="10" cols="50">%s</textarea>', $val
);
}
/*
* Callback function for display description text box
*/
public function fd_display_description_callback(){
$val = ( isset( $this->display_option['fd_display_description'] ) ) ? 'checked="checked"' : '';
if( $val == '' ) {
$class = ' fd-use-apikey-no';
$yesno = 'No';
} else {
$class = ' fd-use-apikey-yes';
$yesno = 'Yes';
}
printf(
'<div id="fd-wrapper">
<div id="fd-main">
<div class="fd-container">
<div class="fd-settings">
<div class="fd-row">
<div class="fd-switch">
<input id="fd_display_description" class="fd-toggle fd-toggle-round" type="checkbox" name="fd_display[fd_display_description]" %s>
<label for="fd_display_description"><p id="fd_display_description-p" class="fd-use-apikey-yesno %s">%s</p></label>
</div>
</div>
</div>
</div>
</div>
</div>', $val, $class, $yesno
);
}
/*
* Callback function for display ticket priority text box
*/
public function fd_display_priority_name_callback(){
$val = ( isset( $this->display_option['fd_display_priority_name'] ) ) ? 'checked="checked"' : '';
if( $val == '' ) {
$class = ' fd-use-apikey-no';
$yesno = 'No';
} else {
$class = ' fd-use-apikey-yes';
$yesno = 'Yes';
}
printf(
'<div id="fd-wrapper">
<div id="fd-main">
<div class="fd-container">
<div class="fd-settings">
<div class="fd-row">
<div class="fd-switch">
<input id="fd_display_priority_name" class="fd-toggle fd-toggle-round" type="checkbox" name="fd_display[fd_display_priority_name]" %s>
<label for="fd_display_priority_name"><p id="fd_display_priority_name-p" class="fd-use-apikey-yesno %s">%s</p></label>
</div>
</div>
</div>
</div>
</div>
</div>', $val, $class, $yesno
);
}
/*
* Callback function for display ticket updated at date text box
*/
public function fd_display_updated_at_callback(){
$val = ( isset( $this->display_option['fd_display_updated_at'] ) ) ? 'checked="checked"' : '';
if( $val == '' ) {
$class = ' fd-use-apikey-no';
$yesno = 'No';
} else {
$class = ' fd-use-apikey-yes';
$yesno = 'Yes';
}
printf(
'<div id="fd-wrapper">
<div id="fd-main">
<div class="fd-container">
<div class="fd-settings">
<div class="fd-row">
<div class="fd-switch">
<input id="fd_display_updated_at" class="fd-toggle fd-toggle-round" type="checkbox" name="fd_display[fd_display_updated_at]" %s>
<label for="fd_display_updated_at"><p id="fd_display_updated_at-p" class="fd-use-apikey-yesno %s">%s</p></label>
</div>
</div>
</div>
</div>
</div>
</div>',$val, $class, $yesno
);
}
/*
* Callback function to use/not use plugin css
*/
public function fd_display_use_css_callback(){
$val = ( isset( $this->display_option['fd_display_use_css'] ) ) ? 'checked="checked"' : '';
if( $val == '' ) {
$class = ' fd-use-apikey-no';
$yesno = 'No';
} else {
$class = ' fd-use-apikey-yes';
$yesno = 'Yes';
}
printf(
'<div id="fd-wrapper">
<div id="fd-main">
<div class="fd-container">
<div class="fd-settings">
<div class="fd-row">
<div class="fd-switch">
<input id="fd_display_use_css" class="fd-toggle fd-toggle-round" type="checkbox" name="fd_display[fd_display_use_css]" %s>
<label for="fd_display_use_css"><p id="fd_display_use_css-p" class="fd-use-apikey-yesno %s">%s</p></label>
</div>
</div>
</div>
</div>
</div>
</div>',$val, $class, $yesno
);
}
}
if( is_admin() )
new FreshDeskSettingsPage();
?>