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
<?php
require_once plugin_dir_path( __DIR__ ). 'ts-wp-functions.php';
class ts_google_calendar_sync_settings {
public function __construct() {
add_action( 'admin_init', array( &$this, 'ts_google_calendar_sync_settings' ) );
}
public function ts_google_calendar_sync_settings() {
add_settings_section(
'ts_calendar_sync_general_settings_section',
__( 'General Settings', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_calendar_sync_general_settings_callback' ),
'ts_google_calendar_sync_page'
);
add_settings_field(
'ts_calendar_event_location',
__( 'Event Location', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_calendar_event_location_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_general_settings_section',
array ( __( '<br>Enter the text that will be used as location field in event of the Calendar. If left empty, website description is sent instead. <br><i>Note: You can use ADDRESS, FULL_ADDRESS and CITY placeholders which will be replaced by their real values.</i>', 'ts' ) )
);
add_settings_field(
'ts_calendar_event_summary',
__( 'Event summary (name)', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_calendar_event_summary_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_general_settings_section'
);
add_settings_field(
'ts_calendar_event_description',
__( 'Event Description', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_calendar_event_description_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_general_settings_section',
array( __( '<br>For the above 2 fields, you can use the following placeholders which will be replaced by their real values: SITE_NAME, CLIENT, PRODUCTS, PRODUCT_WITH_QTY, ORDER_DATE_TIME, ORDER_DATE, ORDER_NUMBER, PRICE, PHONE, NOTE, ADDRESS, FULL_ADDRESS , EMAIL (Client\'s email) ', 'ts' ) )
);
add_settings_section(
'prdd_calendar_sync_customer_settings_section',
__( 'Customer Add to Calendar button Settings', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'prdd_calendar_sync_customer_settings_section_callback' ),
'ts_google_calendar_sync_page'
);
add_settings_field(
'prdd_add_to_calendar_order_received_page',
__( 'Show Add to Calendar button on Order received page', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'prdd_add_to_calendar_order_received_page_callback' ),
'ts_google_calendar_sync_page',
'prdd_calendar_sync_customer_settings_section',
array ( __( 'Show Add to Calendar button on the Order Received page for the customers.', 'ts' ) )
);
add_settings_field(
'prdd_add_to_calendar_customer_email',
__( 'Show Add to Calendar button in the Customer notification email', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'prdd_add_to_calendar_customer_email_callback' ),
'ts_google_calendar_sync_page',
'prdd_calendar_sync_customer_settings_section',
array ( __( 'Show Add to Calendar button in the Customer notification email.', 'ts' ) )
);
add_settings_field(
'prdd_add_to_calendar_my_account_page',
__( 'Show Add to Calendar button on My account', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'prdd_add_to_calendar_my_account_page_callback' ),
'ts_google_calendar_sync_page',
'prdd_calendar_sync_customer_settings_section',
array ( __( 'Show Add to Calendar button on My account page for the customers.', 'ts' ) )
);
add_settings_field(
'prdd_calendar_in_same_window',
__( 'Open Calendar in Same Window', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'prdd_calendar_in_same_window_callback' ),
'ts_google_calendar_sync_page',
'prdd_calendar_sync_customer_settings_section',
array ( __( 'As default, the Calendar is opened in a new tab or window. If you check this option, user will be redirected to the Calendar from the same page, without opening a new tab or window.', 'ts' ) )
);
add_settings_section(
'ts_calendar_sync_admin_settings_section',
__( 'Admin Calendar Sync Settings', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_calendar_sync_admin_settings_section_callback' ),
'ts_google_calendar_sync_page'
);
add_settings_field(
'ts_calendar_sync_integration_mode',
__( 'Integration Mode', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_calendar_sync_integration_mode_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_admin_settings_section',
array ( __( '<br>Select method of integration. "Sync Automatically" will add the events to the Google calendar, which is set in the "Calendar to be used" field, automatically when a customer places an order. <br>"Sync Manually" will add an "Add to Calendar" button in emails received by admin on New customer order and on the Delivery Calendar page.<br>"Disabled" will disable the integration with Google Calendar.', 'ts' ) )
);
add_settings_field(
'ts_sync_calendar_instructions',
__( 'Instructions', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_sync_calendar_instructions_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_admin_settings_section'
);
add_settings_field(
'ts_calendar_key_file_name',
__( 'Key file name', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_calendar_key_file_name_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_admin_settings_section',
array( __( '<br>Enter key file name here without extention, e.g. ab12345678901234567890-privatekey.', 'ts' ) )
);
add_settings_field(
'ts_calendar_service_acc_email_address',
__( 'Service account email address', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_calendar_service_acc_email_address_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_admin_settings_section',
array( __( '<br>Enter Service account email address here, e.g. 1234567890@developer.gserviceaccount.com.', 'ts' ) )
);
add_settings_field(
'ts_calendar_id',
__( 'Calendar to be used', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'ts_calendar_id_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_admin_settings_section',
array( __( '<br>Enter the ID of the calendar in which your deliveries will be saved, e.g. abcdefg1234567890@group.calendar.google.com.', 'ts' ) )
);
add_settings_field(
'ts_calendar_test_connection',
'',
array( 'ts_google_calendar_sync_settings', 'ts_calendar_test_connection_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_admin_settings_section'
);
add_settings_field(
'prdd_admin_add_to_calendar_delivery_calendar',
__( 'Show Add to Calendar button on Delivery Calendar page', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'prdd_admin_add_to_calendar_delivery_calendar_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_admin_settings_section',
array( __( 'Show "Add to Calendar" button on the Product Delivery Date -> View Deliveries.<br><i>Note: This button can be used to export the already placed orders with future deliveries from the current date to the calendar used above.</i>', 'ts' ) )
);
add_settings_field(
'prdd_admin_add_to_calendar_email_notification',
__( 'Show Add to Calendar button in New Order email notification', 'ts' ),
array( 'ts_google_calendar_sync_settings', 'prdd_admin_add_to_calendar_email_notification_callback' ),
'ts_google_calendar_sync_page',
'ts_calendar_sync_admin_settings_section',
array( __( 'Show "Add to Calendar" button in the New Order email notification.', 'ts' ) )
);
register_setting(
'ts_google_calendar_sync',
'ts_calendar_event_location'
);
register_setting(
'ts_google_calendar_sync',
'ts_calendar_event_summary'
);
register_setting(
'ts_google_calendar_sync',
'ts_calendar_event_description'
);
register_setting(
'ts_google_calendar_sync',
'prdd_add_to_calendar_order_received_page'
);
register_setting(
'ts_google_calendar_sync',
'prdd_add_to_calendar_customer_email'
);
register_setting(
'ts_google_calendar_sync',
'prdd_add_to_calendar_my_account_page'
);
register_setting(
'ts_google_calendar_sync',
'prdd_calendar_in_same_window'
);
register_setting(
'ts_google_calendar_sync',
'ts_calendar_sync_integration_mode'
);
register_setting(
'ts_google_calendar_sync',
'ts_calendar_details_1'
);
register_setting(
'ts_google_calendar_sync',
'prdd_admin_add_to_calendar_email_notification'
);
register_setting(
'ts_google_calendar_sync',
'prdd_admin_add_to_calendar_delivery_calendar'
);
}
public static function ts_calendar_sync_general_settings_callback() {
}
public static function ts_calendar_event_location_callback( $args ) {
$google_calendar_location = ts_get_option( "ts_calendar_event_location" );
echo '<input type="text" name="ts_calendar_event_location" id="ts_calendar_event_location" value="' . $google_calendar_location . '" />';
$html = '<label for="ts_calendar_event_location"> ' . $args[0] . '</label>';
echo $html;
}
public static function ts_calendar_event_summary_callback( $args ) {
$gcal_summary = ts_get_option( 'ts_calendar_event_summary' );
echo '<input id="ts_calendar_event_summary" name="ts_calendar_event_summary" value="' . $gcal_summary . '" size="90" type="text"/>';
}
public static function ts_calendar_event_description_callback( $args ) {
$gcal_description = ts_get_option( 'ts_calendar_event_description' );
echo '<textarea id="ts_calendar_event_description" name="ts_calendar_event_description" cols="90" rows="4">' . $gcal_description .'</textarea>';
$html = '<label for="ts_calendar_event_description"> ' . $args[0] . '</label>';
echo $html;
}
public static function prdd_calendar_sync_customer_settings_section_callback() {}
public static function prdd_add_to_calendar_order_received_page_callback( $args ) {
$prdd_add_to_calendar_order_received_page = "";
if ( get_option( 'prdd_add_to_calendar_order_received_page' ) == 'on' ) {
$prdd_add_to_calendar_order_received_page = "checked";
}
echo '<input type="checkbox" name="prdd_add_to_calendar_order_received_page" id="prdd_add_to_calendar_order_received_page" class="day-checkbox" value="on" ' . $prdd_add_to_calendar_order_received_page . ' />';
$html = '<label for="prdd_add_to_calendar_order_received_page"> ' . $args[0] . '</label>';
echo $html;
}
public static function prdd_add_to_calendar_customer_email_callback( $args ) {
$prdd_add_to_calendar_customer_email = "";
if ( get_option( 'prdd_add_to_calendar_customer_email' ) == 'on' ) {
$prdd_add_to_calendar_customer_email = "checked";
}
echo '<input type="checkbox" name="prdd_add_to_calendar_customer_email" id="prdd_add_to_calendar_customer_email" class="day-checkbox" value="on" ' . $prdd_add_to_calendar_customer_email . ' />';
$html = '<label for="prdd_add_to_calendar_customer_email"> ' . $args[0] . '</label>';
echo $html;
}
public static function prdd_add_to_calendar_my_account_page_callback( $args ) {
$prdd_add_to_calendar_my_account_page = "";
if ( get_option( 'prdd_add_to_calendar_my_account_page' ) == 'on' ) {
$prdd_add_to_calendar_my_account_page = "checked";
}
echo '<input type="checkbox" name="prdd_add_to_calendar_my_account_page" id="prdd_add_to_calendar_my_account_page" class="day-checkbox" value="on" ' . $prdd_add_to_calendar_my_account_page . ' />';
$html = '<label for="prdd_add_to_calendar_my_account_page"> ' . $args[0] . '</label>';
echo $html;
}
public static function prdd_calendar_in_same_window_callback( $args ) {
$prdd_calendar_in_same_window = "";
if ( get_option( 'prdd_calendar_in_same_window' ) == 'on' ) {
$prdd_calendar_in_same_window = "checked";
}
echo '<input type="checkbox" name="prdd_calendar_in_same_window" id="prdd_calendar_in_same_window" class="day-checkbox" value="on" ' . $prdd_calendar_in_same_window . ' />';
$html = '<label for="prdd_calendar_in_same_window"> ' . $args[0] . '</label>';
echo $html;
}
public static function ts_calendar_sync_admin_settings_section_callback() {}
public static function ts_calendar_sync_integration_mode_callback( $args ) {
$sync_directly = "";
$sync_manually = "";
$sync_disable = "checked";
$integration_mode = ts_get_option( 'ts_calendar_sync_integration_mode' );
if ( $integration_mode == 'manually' ) {
$sync_manually = "checked";
$sync_disable = "";
} else if( $integration_mode == 'directly' ) {
$sync_directly = "checked";
$sync_disable = "";
}
echo '<input type="radio" name="ts_calendar_sync_integration_mode" id="ts_calendar_sync_integration_mode" value="directly" ' . $sync_directly . '/>' . __( 'Sync Automatically', 'order-delivery-date' ) . '
<input type="radio" name="ts_calendar_sync_integration_mode" id="ts_calendar_sync_integration_mode" value="manually" ' . $sync_manually . '/>' . __( 'Sync Manually', 'order-delivery-date' ) . '
<input type="radio" name="ts_calendar_sync_integration_mode" id="ts_calendar_sync_integration_mode" value="disabled" ' . $sync_disable . '/>' . __( 'Disabled', 'order-delivery-date' );
$html = '<label for="ts_calendar_sync_integration_mode"> ' . $args[0] . '</label>';
echo $html;
print( '<script type="text/javascript">
jQuery( document ).ready( function() {
var isChecked = jQuery( "#ts_calendar_sync_integration_mode:checked" ).val();
if( isChecked == "directly" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k == 7 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
} );
} else if( isChecked == "manually" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k != 7 && k != 0 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
});
} else if( isChecked == "disabled" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k != 0 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
});
}
jQuery( "input[type=radio][id=ts_calendar_sync_integration_mode]" ).change( function() {
var isChecked = jQuery( this ).val();
if( isChecked == "directly" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k == 7 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
} );
} else if( isChecked == "manually" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k != 7 && k != 0 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
});
} else if( isChecked == "disabled" ) {
i = 0;
jQuery( ".form-table" ).each( function() {
if( i == 2 ) {
k = 0;
var row = jQuery( this ).find( "tr" );
jQuery.each( row , function() {
if( k != 0 ) {
jQuery( this ).fadeOut();
} else {
jQuery( this ).fadeIn();
}
k++;
});
} else {
jQuery( this ).fadeIn();
}
i++;
});
}
})
});
</script>');
}
public static function ts_sync_calendar_instructions_callback() {
echo '' . __( 'To set up Google Calendar API, please click on "Show me how" link and carefully follow these steps:', '' ) . '
<span class="description" ><a href="#ts-instructions" id="show_instructions" data-target="api-instructions" class="ts-info_trigger" title="' . __ ( 'Click to toggle instructions', 'ts' ) . '">' . __( 'Show me how', 'ts' ) . '</a></span>';
?> <div class="description ts-info_target api-instructions" style="display: none;">
<ul style="list-style-type:decimal;">
<li><?php _e( 'Google Calendar API requires php V5.3+ and some php extensions.', 'order-delivery-date' ) ?> </li>
<li><?php printf( __( 'Go to Google APIs console by clicking %s. Login to your Google account if you are not already logged in.', 'order-delivery-date' ), '<a href="https://code.google.com/apis/console/" target="_blank">https://code.google.com/apis/console/</a>' ) ?></li>
<li><?php _e( 'Create a new project using the left side pane. Click on \'Home\' option. Name the project "Deliveries" (or use your chosen name instead).', 'ts' ) ?></li>
<li><?php _e( 'Click on API Manager from left side pane.', 'ts' ) ?></li>
<li><?php _e( 'Click "Calendar API" under Google Apps APIs and Enable the API.', 'ts' ) ?></li>
<li><?php _e( 'Go to "Credentials" menu in the left side pane and click on "New Credentials" dropdown.', 'ts' ) ?></li>
<li><?php _e( 'Click on "OAuth client ID" option. Then click on Configure consent screen.', 'ts' )?></li>
<li><?php _e( 'Enter a Product Name, e.g. Product Delivery Date, inside the opening pop-up. Click Save.', 'ts' ) ?></li>
<li><?php _e( 'Select "Web Application" option, enter the Web client name and create the client ID.', 'ts' )?></li>
<li><?php _e( 'Click on New Credentials dropdown and select "Service account key".', 'ts' ) ?></li>
<li><?php _e( 'Click "Service account" and select "New service account" and enter the name. Now select key type as "P12" and create the service account.', 'ts' ) ?></li>
<li><?php _e( 'A file with extension .p12 will be downloaded.', 'ts' ) ?></li>
<li><?php printf( __( 'Using your FTP client program, copy this key file to folder: %s . This file is required as you will grant access to your Google Calendar account even if you are not online. So this file serves as a proof of your consent to access to your Google calendar account. Note: This file cannot be uploaded in any other way. If you do not have FTP access, ask the website admin to do it for you.', 'ts' ), plugin_dir_path( __FILE__ ) .'gcal/key/' ) ?></li>
<li><?php _e( 'Enter the name of the key file to "Key file name" setting of Order Delivery Date. Exclude the extention .p12.', 'ts' ) ?></li>
<li><?php _e( 'Copy "Email address" setting from Manage service account of Google apis console and paste it to "Service account email address" setting of Product Delivery Date.', 'ts' ) ?></li>
<li><?php printf( __( 'Open your Google Calendar by clicking this link: %s', 'ts' ), '<a href="https://www.google.com/calendar/render" target="_blank">https://www.google.com/calendar/render</a>' ) ?></li>
<li><?php _e( 'Create a new Calendar by selecting "my Calendars > Create new calendar" on left side pane. <b>Try NOT to use your primary calendar.</b>', 'ts' ) ?></li>
<li><?php _e( 'Give a name to the new calendar, e.g. Product Delivery Date calendar. <b>Check that Calendar Time Zone setting matches with time zone setting of your WordPress website.</b> Otherwise there will be a time shift.', 'ts' ) ?></li>
<li><?php _e( 'Paste already copied "Email address" setting from Manage service account of Google apis console to "Person" field under "Share with specific person".', 'ts' ) ?></li>
<li><?php _e( 'Set "Permission Settings" of this person as "Make changes to events".', 'ts' ) ?></li>
<li><?php _e( 'Click "Add Person".', 'ts' ) ?></li>
<li><?php _e( 'Click "Create Calendar".', 'ts' ) ?></li>
<li><?php _e( 'Select the created calendar and click "Calendar settings".', 'ts' ) ?></li>
<li><?php _e( 'Copy "Calendar ID" value on Calendar Address row.', 'ts' ) ?></li>
<li><?php _e( 'Paste this value to "Calendar to be used" field.', 'ts' ) ?></li>
<li><?php _e( 'Click "Save Settings".', 'ts' ) ?></li>
<li><?php _e( 'After these stages, you have set up Google Calendar API. To test the connection, click the "Test Connection" link.', 'ts' ) ?></li>
<li><?php _e( 'If you get a success message, you should see a test event inserted to the Google Calendar and you are ready to go. If you get an error message, double check your settings.', 'ts' ) ?></li>
</ul>
</div>
<script type="text/javascript">
function toggle_target (e) {
if ( e && e.preventDefault ) {
e.preventDefault();
}
if ( e && e.stopPropagation ) {
e.stopPropagation();
}
var target = jQuery(".ts-info_target.api-instructions" );
if ( !target.length ) {
return false;
}
if ( target.is( ":visible" ) ) {
target.hide( "fast" );
} else {
target.show( "fast" );
}
return false;
}
jQuery(function () {
jQuery(document).on("click", ".ts-info_trigger", toggle_target);
});
</script>
<?php
}
public static function ts_calendar_key_file_name_callback( $args ) {
$gcal_key_file_arr = ts_get_option( 'ts_calendar_details_1' );
if( isset( $gcal_key_file_arr[ 'ts_calendar_key_file_name' ] ) ) {
$gcal_key_file = $gcal_key_file_arr[ 'ts_calendar_key_file_name' ];
} else {
$gcal_key_file = '';
}
echo '<input id="ts_calendar_key_file_name" name= "ts_calendar_details_1[ts_calendar_key_file_name]" value="' . $gcal_key_file .'" size="90" type="text" />';
$html = '<label for="ts_calendar_key_file_name"> ' . $args[0] . '</label>';
echo $html;
}
public static function ts_calendar_service_acc_email_address_callback( $args ) {
$gcal_service_account_arr = ts_get_option( 'ts_calendar_details_1' );
if( isset( $gcal_service_account_arr[ 'ts_calendar_service_acc_email_address' ] ) ) {
$gcal_service_account = $gcal_service_account_arr[ 'ts_calendar_service_acc_email_address' ];
} else {
$gcal_service_account = '';
}
echo '<input id="orddd_calendar_service_acc_email_address" name="ts_calendar_details_1[ts_calendar_service_acc_email_address]" value="' . $gcal_service_account . '" size="90" type="text"/>';
$html = '<label for="ts_calendar_service_acc_email_address"> ' . $args[0] . '</label>';
echo $html;
}
public static function ts_calendar_id_callback( $args ) {
$gcal_selected_calendar_arr = ts_get_option( 'ts_calendar_details_1' );
if( isset( $gcal_selected_calendar_arr[ 'ts_calendar_id' ] ) ) {
$gcal_selected_calendar = $gcal_selected_calendar_arr[ 'ts_calendar_id' ];
} else {
$gcal_selected_calendar = '';
}
echo '<input id="ts_calendar_id" name="ts_calendar_details_1[ts_calendar_id]" value="' . $gcal_selected_calendar . '" size="90" type="text" />';
$html = '<label for="ts_calendar_id"> ' . $args[0] . '</label>';
echo $html;
}
public static function ts_calendar_test_connection_callback() {
echo "<script type='text/javascript'>
jQuery( document ).on( 'click', '#test_connection', function( e ) {
e.preventDefault();
var data = {
gcal_api_test_result: '',
gcal_api_pre_test: '',
gcal_api_test: 1,
action: 'ts_display_nag'
};
jQuery( '#test_connection_ajax_loader' ).show();
jQuery.post( '" . get_admin_url() . "/admin-ajax.php', data, function( response ) {
jQuery( '#test_connection_message' ).html( response );
jQuery( '#test_connection_ajax_loader' ).hide();
});
});
</script>";
print "<a href='admin.php?page=woocommerce_prdd_page&action=prdd_google_calendar_sync' id='test_connection'>" . __( 'Test Connection', 'order-delivery-date' ) . "</a>
<img src='" . plugins_url() . "/product-delivery-date/images/ajax-loader.gif' id='test_connection_ajax_loader' style='display:none;'>";
print "<div id='test_connection_message'></div>";
}
public static function prdd_admin_add_to_calendar_email_notification_callback( $args ) {
$prdd_admin_add_to_calendar_email_notification = "";
if( get_option( 'prdd_admin_add_to_calendar_email_notification' ) == "on" ) {
$prdd_admin_add_to_calendar_email_notification = "checked";
}
echo '<input type="checkbox" name="prdd_admin_add_to_calendar_email_notification" id="prdd_admin_add_to_calendar_email_notification" value="on" ' . $prdd_admin_add_to_calendar_email_notification . ' />';
$html = '<label for="prdd_admin_add_to_calendar_email_notification"> ' . $args[0] . '</label>';
echo $html;
}
public static function prdd_admin_add_to_calendar_delivery_calendar_callback( $args ) {
$prdd_admin_add_to_calendar_delivery_calendar = "";
if( get_option( 'prdd_admin_add_to_calendar_delivery_calendar' ) == "on" ) {
$prdd_admin_add_to_calendar_delivery_calendar = "checked";
}
echo '<input type="checkbox" name="prdd_admin_add_to_calendar_delivery_calendar" id="prdd_admin_add_to_calendar_delivery_calendar" value="on" ' . $prdd_admin_add_to_calendar_delivery_calendar . ' />';
$html = '<label for="prdd_admin_add_to_calendar_delivery_calendar"> ' . $args[0] . '</label>';
echo $html;
}
}
$ts_google_calendar_sync_settings = new ts_google_calendar_sync_settings();