Changeset 1168115
- Timestamp:
- 05/27/2015 03:16:48 AM (10 years ago)
- Location:
- userdeck
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
userdeck/trunk/readme.txt
r1168111 r1168115 1 1 === UserDeck Customer Support === 2 2 Contributors: userdeck 3 Tags: userdeck, customer support, customer service, knowledge base, faq, frequently asked questions, documentation, docs, widgets3 Tags: userdeck, customer support, customer service, help, support, helpdesk, help desk, ticket, ticketing, knowledge base, knowledgebase, faq, frequently asked questions, documentation, docs, answers, widgets, zendesk 4 4 Requires at least: 3.7 5 5 Tested up to: 4.2.2 6 Stable tag: 1. 0.76 Stable tag: 1.1.0 7 7 8 8 Easily integrate UserDeck's embedded support software into your WordPress website. … … 13 13 14 14 = Features = 15 16 **Conversations** 17 * A ticketing system to allow your customers to contact you through email and embedded widgets. 18 * Inline widget can be used as a contact form or a ticket portal to let users manage tickets from inside the WordPress control panel. 19 * Integrates with WordPress for authenticated sessions to track user name and email on tickets. 20 21 [Learn more about Conversations](http://userdeck.com/conversations?utm_source=wordpress&utm_medium=link&utm_campaign=website) 15 22 16 23 **Guides** … … 30 37 3. Go to the settings page. 31 38 4. Connect to UserDeck. 32 5. Choose one of the integration methods for Guides on the page by either creating a new page or by adding to an existing page.39 5. Choose one of the integration methods for Conversations or Guides on the page by either creating a new page or by adding to an existing page. 33 40 34 41 == Screenshots == … … 39 46 40 47 == Upgrade Notice == 48 49 = 1.1.0 = 50 Added new Conversations ticketing system integration. 41 51 42 52 = 1.0.7 = … … 53 63 54 64 == Changelog == 65 66 = 1.1.0 = 67 * Added integration with Conversations 55 68 56 69 = 1.0.7 = -
userdeck/trunk/userdeck.js
r1050517 r1168115 2 2 3 3 connected: false, 4 5 account_key: null, 6 7 mailbox_id: null, 4 8 5 9 guides_key: null, 6 10 7 showConnect : function (type ) {11 showConnect : function (type, start) { 8 12 var wrapper = jQuery('#connect-frame'); 13 14 if (!start) { 15 start = 'install'; 16 } 17 else { 18 start = 'install/' + start; 19 } 9 20 10 var iframe = jQuery('<iframe id="iframe-guides" src="https://app.userdeck.com/' + type + '?redir= install/guides" width="400" height="600" frameborder="0" ALLOWTRANSPARENCY="true"></iframe>')21 var iframe = jQuery('<iframe id="iframe-guides" src="https://app.userdeck.com/' + type + '?redir=' + start + '" width="400" height="600" frameborder="0" ALLOWTRANSPARENCY="true"></iframe>') 11 22 12 23 wrapper.append(iframe); … … 28 39 }, 29 40 41 updateSettings : function (options) { 42 options['userdeck-submit'] = 1; 43 options['_wpnonce'] = plugin_settings_nonce; 44 45 jQuery.post(plugin_url, options, function () { 46 window.location.reload(); 47 }); 48 }, 49 30 50 _receiveMessage : function (event) { 31 51 if (event.data && 'string' === typeof event.data && 'ud:' == event.data.substr(0, 3)) { 32 52 var msg = jQuery.parseJSON(event.data.substr(3)); 33 53 34 if ('guideKeyDetected' == msg.event) { 54 if ('installDetected' == msg.event) { 55 var account_key = msg.message.account_key; 56 var mailbox_id = msg.message.mailbox_id; 57 var guides_key = msg.message.guide_key; 58 var data = { 59 account_key: account_key, 60 mailbox_id: mailbox_id, 61 guides_key: guides_key 62 }; 63 64 UserDeck.connected = true; 65 66 UserDeck.account_key = account_key; 67 UserDeck.mailbox_id = mailbox_id; 68 UserDeck.guides_key = guides_key; 69 70 UserDeck.disableConnect(); 71 UserDeck.hideConnect(); 72 73 UserDeck.updateSettings(data); 74 } 75 else if ('conversationKeysDetected' == msg.event) { 76 var account_key = msg.message.account_key; 77 var mailbox_id = msg.message.mailbox_id; 78 var data = { 79 account_key: account_key, 80 mailbox_id: mailbox_id 81 }; 82 83 UserDeck.connected = true; 84 85 UserDeck.account_key = account_key; 86 UserDeck.mailbox_id = mailbox_id; 87 88 UserDeck.disableConnect(); 89 UserDeck.hideConnect(); 90 91 UserDeck.updateSettings(data); 92 } 93 else if ('guideKeyDetected' == msg.event) { 35 94 var guides_key = msg.message; 36 95 … … 40 99 41 100 UserDeck.disableConnect(); 42 43 101 UserDeck.hideConnect(); 44 102 45 jQuery.post(plugin_url, {'userdeck-submit': 1, guides_key: guides_key, _wpnonce: plugin_settings_nonce}, function () { 46 window.location.reload(); 47 }); 103 UserDeck.updateSettings({guides_key: guides_key}); 48 104 } 49 105 } -
userdeck/trunk/userdeck.php
r1168111 r1168115 4 4 * Plugin URI: http://wordpress.org/plugins/userdeck 5 5 * Description: Embedded customer support from <a href="http://userdeck.com?utm_source=wordpress&utm_medium=link&utm_campaign=website">UserDeck</a> that embeds into your website. 6 * Version: 1. 0.76 * Version: 1.1.0 7 7 * Author: UserDeck 8 8 * Author URI: http://userdeck.com?utm_source=wordpress&utm_medium=link&utm_campaign=website … … 39 39 if ( is_admin() ) { 40 40 add_action( 'admin_menu', array( $this, 'create_menu_page') ); 41 add_action( 'admin_menu', array( $this, 'create_tickets_page' ) ); 41 42 add_action( 'admin_init', array( $this, 'settings_init') ); 42 43 add_action( 'admin_init', array( $this, 'migrate_guides_shortcodes') ); 43 44 add_action( 'admin_notices', array( $this, 'admin_notice') ); 44 45 } 46 47 add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 99 ); 45 48 46 49 add_action( 'wp_head', array( $this, 'output_escaped_fragment_meta' ) ); 47 50 51 add_action( 'wp_footer', array( $this, 'output_conversations_overlay_code' ) ); 52 53 add_filter( 'the_content', array( $this, 'output_conversations_page' ) ); 48 54 add_filter( 'the_content', array( $this, 'output_guides_page' ) ); 49 55 … … 92 98 } 93 99 94 $options['migrate_guides_shortcodes'] = 1; 95 96 $this->update_settings($options); 100 $this->update_settings(array('migrate_guides_shortcodes' => 1)); 97 101 98 102 } … … 104 108 public function get_settings() { 105 109 106 $defaults = array('guides_key' => null); 110 $defaults = array( 111 'account_key' => null, 112 'mailbox_id' => null, 113 'guides_key' => null, 114 'ticket_portal' => 0, 115 'overlay_widget' => 0, 116 ); 107 117 108 118 $options = get_option( 'userdeck', $defaults ); … … 120 130 */ 121 131 public function update_settings( $options ) { 132 133 $options = wp_parse_args($options, $this->get_settings()); 122 134 123 135 update_option( 'userdeck', $options ); … … 136 148 137 149 return false; 150 151 } 152 153 public function admin_bar_menu() 154 { 155 156 $options = $this->get_settings(); 157 158 if ( $options['ticket_portal'] != 1 ) { 159 return; 160 } 161 162 global $wp_admin_bar; 163 164 $wp_admin_bar->add_menu(array( 165 'title' => 'Tickets', 166 'href' => admin_url( 'admin.php?page=userdeck_tickets' ), 167 'id' => 'userdeck_admin_bar_menu', 168 )); 138 169 139 170 } … … 210 241 } 211 242 243 public function output_conversations_page( $content, $hide_list = true ) { 244 245 global $post; 246 247 if ( isset( $post ) && is_page() ) { 248 249 $account_key = get_post_meta($post->ID, 'userdeck_account_key', true); 250 $mailbox_id = get_post_meta($post->ID, 'userdeck_mailbox_id', true); 251 252 if (!empty($account_key) && !empty($mailbox_id)) { 253 return $this->output_conversations_inline_code($account_key, $mailbox_id, $hide_list); 254 } 255 256 } 257 258 return $content; 259 260 } 261 262 /** 263 * output the userdeck conversations overlay javascript install code 264 * @return null 265 */ 266 public function output_conversations_overlay_code($hide_list = false) { 267 268 $options = $this->get_settings(); 269 270 if ( $options['overlay_widget'] != 1 ) { 271 return; 272 } 273 274 $account_key = $options['account_key']; 275 $mailbox_id = $options['mailbox_id']; 276 277 ?> 278 <script> 279 userdeck_settings = { 280 <?php 281 if ( is_user_logged_in() ) : 282 $current_user = wp_get_current_user(); 283 ?> 284 customer_email: '<?php echo $current_user->user_email ?>', 285 customer_name: '<?php echo $current_user->user_firstname . ' ' . $current_user->user_lastname ?>', 286 customer_external_id: '<?php echo $current_user->ID ?>', 287 <?php 288 endif; 289 ?> 290 mailbox_id: '<?php echo $mailbox_id ?>', 291 conversations_overlay: {"key":"<?php echo $account_key ?>","settings":{ 292 <?php if ($hide_list): ?> 293 "hide_conversation_list":true 294 <?php endif; ?> 295 }} 296 }; 297 298 (function(s,o,g,a,m){a=s.createElement(o),m=s.getElementsByTagName(o)[0]; 299 a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 300 })(document,'script','//widgets.userdeck.com/conversations.js'); 301 </script> 302 <noscript><a href="http://userdeck.com">Customer Support Software</a></noscript>', $mailbox_id, $account_key); 303 <?php 304 305 } 306 307 /** 308 * output the userdeck conversations inline javascript install code 309 * @return null 310 */ 311 public function output_conversations_inline_code($account_key, $mailbox_id, $hide_list = true) { 312 313 ob_start(); 314 ?> 315 <div id="ud-contact"></div> 316 <script src="//widgets.userdeck.com/conversations.js"></script> 317 <script> 318 userdeck_settings = { 319 <?php 320 if ( is_user_logged_in() ) : 321 $current_user = wp_get_current_user(); 322 ?> 323 customer_email: '<?php echo $current_user->user_email ?>', 324 customer_name: '<?php echo $current_user->user_firstname . ' ' . $current_user->user_lastname ?>', 325 customer_external_id: '<?php echo $current_user->ID ?>', 326 <?php 327 endif; 328 ?> 329 mailbox_id: '<?php echo $mailbox_id ?>' 330 }; 331 332 UserDeck.factory("conversations", {"key":"<?php echo $account_key ?>","settings":{ 333 <?php if ($hide_list): ?> 334 "hide_conversation_list":true 335 <?php endif; ?> 336 },"el":"#ud-contact"}); 337 </script> 338 <noscript><a href="http://userdeck.com">Customer Support Software</a></noscript> 339 <?php 340 $content = ob_get_clean(); 341 342 return $content; 343 344 } 345 212 346 public function output_guides_page( $content ) { 213 347 … … 293 427 294 428 } 295 429 296 430 public function output_escaped_fragment_meta() { 297 431 … … 313 447 */ 314 448 public function admin_notice() { 449 450 if ( isset( $_GET['page'] ) && $_GET['page'] == 'userdeck' && isset( $_GET['settings_updated'] ) ) { 451 452 ?> 453 <div class="updated"> 454 <p>Settings successfully saved.</p> 455 </div> 456 <?php 457 458 } 315 459 316 460 if ( isset( $_GET['page'] ) && $_GET['page'] == 'userdeck' && isset( $_GET['page_added'] ) ) { … … 366 510 } 367 511 512 public function create_tickets_page() { 513 514 $options = $this->get_settings(); 515 516 if ( $options['ticket_portal'] != 1 ) { 517 return; 518 } 519 520 add_object_page( 'Tickets', 'Tickets', 'read', 'userdeck_tickets', array($this, 'render_tickets_page'), 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iNjNweCIgaGVpZ2h0PSI2M3B4IiB2aWV3Qm94PSIwIDAgNjMgNjMiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDYzIDYzIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBmaWxsPSIjOTk5OTk5IiBkPSJNMzEsMy45QzE1LjgsMy45LDMuNCwxNi4yLDMuNCwzMS41YzAsMTUuMywxMi40LDI3LjYsMjcuNiwyNy42YzE1LjMsMCwyNy42LTEyLjQsMjcuNi0yNy42QzU4LjcsMTYuMiw0Ni4zLDMuOSwzMSwzLjl6IE00Ni45LDM3LjVjMCwzLjEtMi40LDUuMy01LjEsNS4zaC02LjVMMzIsNDguM2MtMC4zLDAuNC0wLjcsMC44LTEuMSwwLjhjLTAuNCwwLTAuOS0wLjQtMS4xLTAuOGwtMy4zLTUuNGgtNi4xYy0yLjcsMC01LjQtMi4yLTUuNC01LjN2LTEzYzAtMy4xLDIuNy01LjcsNS40LTUuN2gyMS41YzIuNywwLDUuMSwyLjYsNS4xLDUuN1YzNy41eiIvPjwvc3ZnPg==' ); 521 522 } 523 524 public function render_tickets_page() { 525 526 $options = $this->get_settings(); 527 528 $account_key = $options['account_key']; 529 $mailbox_id = $options['mailbox_id']; 530 ?> 531 532 <div class="wrap"> 533 <h2>Tickets</h2> 534 535 <div id="poststuff"> 536 <div class="postbox-container" style="width:65%;"> 537 538 <?php echo $this->output_conversations_inline_code($account_key, $mailbox_id, false); ?> 539 540 </div> 541 </div> 542 </div> 543 <?php 544 } 545 368 546 /** 369 547 * output the options page … … 381 559 } 382 560 561 $account_key = $options['account_key']; 562 $mailbox_id = $options['mailbox_id']; 383 563 $guides_key = $options['guides_key']; 384 564 $ticket_portal = $options['ticket_portal']; 565 $overlay_widget = $options['overlay_widget']; 566 567 $show_options = false; 568 $show_conversations_options = false; 385 569 $show_guides_options = false; 570 571 if ($account_key || $guides_key) { 572 $show_options = true; 573 } 574 575 if ($account_key) { 576 $show_conversations_options = true; 577 } 386 578 387 579 if ($guides_key) { 388 580 $show_guides_options = true; 389 581 } 390 582 583 if ( isset( $_GET['tab'] ) ) { 584 $tab = $_GET['tab']; 585 } 586 else { 587 $tab = 'conversations'; 588 } 391 589 ?> 392 590 … … 396 594 <p><a href="http://userdeck.com?utm_source=wordpress&utm_medium=link&utm_campaign=website" target="_blank">UserDeck</a> provides customer support software that embeds into your WordPress website.</p> 397 595 398 <?php if ($show_guides_options): ?> 399 <h2>Guides</h2> 596 <?php if ($show_options): ?> 597 <h2 class="nav-tab-wrapper" id="userdeck-tabs"> 598 <a href="<?php echo admin_url('admin.php?page=userdeck&tab=conversations') ?>" id="conversations-tab" class="nav-tab <?php if ($tab == 'conversations'): ?>nav-tab-active<?php endif; ?>">Conversations</a> 599 <a href="<?php echo admin_url('admin.php?page=userdeck&tab=guides') ?>" id="guides-tab" class="nav-tab <?php if ($tab == 'guides'): ?>nav-tab-active<?php endif; ?>">Guides</a> 600 </h2> 400 601 401 <p>Guides is a knowledge base widget that embeds inline into any page of your WordPress pages and inherits the styling and blends in.</p> 402 403 <div id="poststuff"> 404 <div class="postbox-container" style="width:65%;"> 405 <?php if (current_user_can('publish_pages')) : ?> 406 <form method="post" action="<?php echo admin_url('admin.php?page=userdeck') ?>"> 407 <div class="postbox"> 408 <h3 class="hndle" style="cursor: auto;"><span>Create a Knowledge Base Page</span></h3> 409 410 <div class="inside"> 411 <p>Create a new page with the Guides knowledge base inline widget.</p> 412 413 <table class="form-table"> 414 <tbody> 415 <tr valign="top"> 416 <th scope="row"> 417 <label for="page-title">Page Title</label> 418 </th> 419 <td> 420 <input name="page_title" type="text" value="" placeholder="Support" id="page-title" /> 421 <br class="clear"> 422 <p class="description">The title of the new knowledge base page to create.</p> 423 </td> 424 </tr> 425 </tbody> 426 </table> 427 428 <p> 429 <?php wp_nonce_field('userdeck-page-create'); ?> 430 <input type="hidden" name="guides_key" value="<?php echo $guides_key ?>" /> 431 <input class="button-primary" name="userdeck-page-create" type="submit" value="Create Page" /> 432 </p> 433 </div> 434 </div> 435 </form> 436 <?php endif; ?> 602 <?php if ($tab == 'conversations'): ?> 603 <?php if ($show_conversations_options): ?> 604 <p>Conversations is ticketing system that embeds either inline on any page of your WordPress site as a contact form or an overlay widget.</p> 605 <p>You can also allow your users to manage tickets from the WordPress control panel as a ticket portal.</p> 437 606 438 < ?php if (current_user_can('edit_pages')) : ?>439 < ?php if (count($pages) > 0): ?>607 <div id="poststuff"> 608 <div class="postbox-container" style="width:65%;"> 440 609 <form method="post" action="<?php echo admin_url('admin.php?page=userdeck') ?>"> 441 610 <div class="postbox"> 442 <h3 class="hndle" style="cursor: auto;"><span> Add Knowledge Base to Page</span></h3>611 <h3 class="hndle" style="cursor: auto;"><span>Global Settings</span></h3> 443 612 444 613 <div class="inside"> 445 <p>Add the Guides knowledge base inline widget to an existing page.</p>446 447 614 <table class="form-table"> 448 615 <tbody> 449 616 <tr valign="top"> 450 617 <th scope="row"> 451 <label for="page-id">Page</label>618 Ticket Portal 452 619 </th> 453 620 <td> 454 <select name="page_id" id="page-id"> 455 <?php foreach ($pages as $id => $title): ?> 456 <option value="<?php echo $id ?>"><?php echo $title ?></option> 457 <?php endforeach; ?> 458 </select> 621 <input name="ticket_portal" type="checkbox" value="on" id="ticket-portal" class="checkbox double"<?php if ($ticket_portal == 1): ?> checked<?php endif; ?> /> 622 <label for="ticket-portal">Enable Ticket Portal</label> 459 623 <br class="clear"> 460 <p class="description">The title of the existing page to update with a knowledge base.</p> 624 <p class="description">Enable to allow your WordPress users to manage tickets if logged in from the control panel menu.</p> 625 </td> 626 </tr> 627 <tr valign="top"> 628 <th scope="row"> 629 Overlay Widget 630 </th> 631 <td> 632 <input name="overlay_widget" type="checkbox" value="on" id="overlay-widget" class="checkbox double"<?php if ($overlay_widget == 1): ?> checked<?php endif; ?> /> 633 <label for="overlay-widget">Enable Overlay Widget</label> 634 <br class="clear"> 635 <p class="description">Enable to show an overlay widget which lets website visitors contact you on any page of your WordPress site and manage conversations.</p> 461 636 </td> 462 637 </tr> … … 465 640 466 641 <p> 467 <?php wp_nonce_field('userdeck-page-add'); ?> 468 <input type="hidden" name="guides_key" value="<?php echo $guides_key ?>" /> 469 <input class="button-primary" name="userdeck-page-add" type="submit" value="Add to Page" /> 642 <?php wp_nonce_field('userdeck-page-settings'); ?> 643 <input class="button-primary" name="userdeck-page-settings" type="submit" value="Save Changes" /> 470 644 </p> 471 645 </div> 472 646 </div> 473 647 </form> 474 <?php endif; ?> 475 <?php endif; ?> 476 </div> 477 </div> 648 649 <?php if (current_user_can('publish_pages')) : ?> 650 <form method="post" action="<?php echo admin_url('admin.php?page=userdeck') ?>"> 651 <div class="postbox"> 652 <h3 class="hndle" style="cursor: auto;"><span>Create a Contact Form Page</span></h3> 653 654 <div class="inside"> 655 <p>Create a new page with the Conversations inline widget as a contact form.</p> 656 657 <table class="form-table"> 658 <tbody> 659 <tr valign="top"> 660 <th scope="row"> 661 <label for="conversations-page-title">Page Title</label> 662 </th> 663 <td> 664 <input name="page_title" type="text" value="" placeholder="Contact" id="conversations-page-title" /> 665 <br class="clear"> 666 <p class="description">The title of the new contact form page to create.</p> 667 </td> 668 </tr> 669 </tbody> 670 </table> 671 672 <p> 673 <?php wp_nonce_field('userdeck-page-conversations-create'); ?> 674 <input type="hidden" name="account_key" value="<?php echo $account_key ?>" /> 675 <input type="hidden" name="mailbox_id" value="<?php echo $mailbox_id ?>" /> 676 <input class="button-primary" name="userdeck-page-conversations-create" type="submit" value="Create Page" /> 677 </p> 678 </div> 679 </div> 680 </form> 681 <?php endif; ?> 682 683 <?php if (current_user_can('edit_pages')) : ?> 684 <?php if (count($pages) > 0): ?> 685 <form method="post" action="<?php echo admin_url('admin.php?page=userdeck') ?>"> 686 <div class="postbox"> 687 <h3 class="hndle" style="cursor: auto;"><span>Add Contact Form to Page</span></h3> 688 689 <div class="inside"> 690 <p>Add the Conversations inline widget as a contact form to an existing page.</p> 691 692 <table class="form-table"> 693 <tbody> 694 <tr valign="top"> 695 <th scope="row"> 696 <label for="conversations-page-id">Page</label> 697 </th> 698 <td> 699 <select name="page_id" id="conversations-page-id"> 700 <?php foreach ($pages as $id => $title): ?> 701 <option value="<?php echo $id ?>"><?php echo $title ?></option> 702 <?php endforeach; ?> 703 </select> 704 <br class="clear"> 705 <p class="description">The title of the existing page to update with a contact form.</p> 706 </td> 707 </tr> 708 </tbody> 709 </table> 710 711 <p> 712 <?php wp_nonce_field('userdeck-page-conversations-add'); ?> 713 <input type="hidden" name="account_key" value="<?php echo $account_key ?>" /> 714 <input type="hidden" name="mailbox_id" value="<?php echo $mailbox_id ?>" /> 715 <input class="button-primary" name="userdeck-page-conversations-add" type="submit" value="Add to Page" /> 716 </p> 717 </div> 718 </div> 719 </form> 720 <?php endif; ?> 721 <?php endif; ?> 722 </div> 723 </div> 724 <?php else: ?> 725 <div id="button-connect"> 726 <h3>Enable Conversations</h3> 727 <p>Your account does not have the Conversations enabled. You can enable it below to start a free trial.</p> 728 <a href="javascript:void(0)" onclick="UserDeck.showConnect('login', 'conversations')" class="button button-primary button-hero">Enable Conversations</a> 729 </div> 730 731 <div id="connect-frame"></div> 732 733 <div id="feature-wrapper"> 734 <h2>Converations Features</h2> 735 736 <ul> 737 <li> 738 A ticketing system to allow your customers to contact you through email and embedded widgets. 739 </li> 740 <li> 741 Inline widget can be used as a contact form or a ticket portal to let users manage tickets from inside the WordPress control panel. 742 </li> 743 <li> 744 Integrates with WordPress for authenticated sessions to track user name and email on tickets. 745 </li> 746 </ul> 747 748 <p> 749 <a href="http://userdeck.com/conversations?utm_source=wordpress&utm_medium=link&utm_campaign=website" target="_blank">Learn more about Conversations</a> 750 </p> 751 </div> 752 753 <script type="text/javascript"> 754 var plugin_settings_nonce = "<?php echo wp_create_nonce('userdeck-options'); ?>"; 755 var plugin_url = "<?php echo get_admin_url() . add_query_arg( array('page' => 'userdeck'), 'admin.php' ); ?>"; 756 </script> 757 758 <style type="text/css"> 759 #button-connect { margin: 40px 0; } 760 #iframe-guides { display: none; box-shadow: 0 1px 1px rgba(0,0,0,.04); border: 1px solid #e5e5e5; padding: 2px; background: #fff; } 761 #feature-wrapper ul { list-style-type: disc; padding-left: 20px; } 762 </style> 763 <?php endif; ?> 764 <?php elseif ($tab == 'guides'): ?> 765 <p>Guides is a knowledge base widget that embeds inline into any page of your WordPress pages and inherits the styling and blends in.</p> 766 767 <?php if ($show_guides_options): ?> 768 <div id="poststuff"> 769 <div class="postbox-container" style="width:65%;"> 770 <?php if (current_user_can('publish_pages')) : ?> 771 <form method="post" action="<?php echo admin_url('admin.php?page=userdeck') ?>"> 772 <div class="postbox"> 773 <h3 class="hndle" style="cursor: auto;"><span>Create a Knowledge Base Page</span></h3> 774 775 <div class="inside"> 776 <p>Create a new page with the Guides knowledge base inline widget.</p> 777 778 <table class="form-table"> 779 <tbody> 780 <tr valign="top"> 781 <th scope="row"> 782 <label for="guides-page-title">Page Title</label> 783 </th> 784 <td> 785 <input name="page_title" type="text" value="" placeholder="Support" id="guides-page-title" /> 786 <br class="clear"> 787 <p class="description">The title of the new knowledge base page to create.</p> 788 </td> 789 </tr> 790 </tbody> 791 </table> 792 793 <p> 794 <?php wp_nonce_field('userdeck-page-guides-create'); ?> 795 <input type="hidden" name="guides_key" value="<?php echo $guides_key ?>" /> 796 <input class="button-primary" name="userdeck-page-guides-create" type="submit" value="Create Page" /> 797 </p> 798 </div> 799 </div> 800 </form> 801 <?php endif; ?> 802 803 <?php if (current_user_can('edit_pages')) : ?> 804 <?php if (count($pages) > 0): ?> 805 <form method="post" action="<?php echo admin_url('admin.php?page=userdeck') ?>"> 806 <div class="postbox"> 807 <h3 class="hndle" style="cursor: auto;"><span>Add Knowledge Base to Page</span></h3> 808 809 <div class="inside"> 810 <p>Add the Guides knowledge base inline widget to an existing page.</p> 811 812 <table class="form-table"> 813 <tbody> 814 <tr valign="top"> 815 <th scope="row"> 816 <label for="guides-page-id">Page</label> 817 </th> 818 <td> 819 <select name="page_id" id="guides-page-id"> 820 <?php foreach ($pages as $id => $title): ?> 821 <option value="<?php echo $id ?>"><?php echo $title ?></option> 822 <?php endforeach; ?> 823 </select> 824 <br class="clear"> 825 <p class="description">The title of the existing page to update with a knowledge base.</p> 826 </td> 827 </tr> 828 </tbody> 829 </table> 830 831 <p> 832 <?php wp_nonce_field('userdeck-page-guides-add'); ?> 833 <input type="hidden" name="guides_key" value="<?php echo $guides_key ?>" /> 834 <input class="button-primary" name="userdeck-page-guides-add" type="submit" value="Add to Page" /> 835 </p> 836 </div> 837 </div> 838 </form> 839 <?php endif; ?> 840 <?php endif; ?> 841 </div> 842 </div> 843 <?php else: ?> 844 <div id="button-connect"> 845 <h3>Enable Guides</h3> 846 <p>Your account does not have the Guides enabled. You can enable it below to start a free trial.</p> 847 <a href="javascript:void(0)" onclick="UserDeck.showConnect('login', 'guides')" class="button button-primary button-hero">Enable Guides</a> 848 </div> 849 850 <div id="connect-frame"></div> 851 852 <div id="feature-wrapper"> 853 <h2>Converations Features</h2> 854 855 <ul> 856 <li> 857 A ticketing system to allow your customers to contact you through email and embedded widgets. 858 </li> 859 <li> 860 Inline widget can be used as a contact form or a ticket portal to let users manage tickets from inside the WordPress control panel. 861 </li> 862 <li> 863 Integrates with WordPress for authenticated sessions to track user name and email on tickets. 864 </li> 865 </ul> 866 867 <p> 868 <a href="http://userdeck.com/guides?utm_source=wordpress&utm_medium=link&utm_campaign=website" target="_blank">Learn more about Guides</a> 869 </p> 870 </div> 871 872 <script type="text/javascript"> 873 var plugin_settings_nonce = "<?php echo wp_create_nonce('userdeck-options'); ?>"; 874 var plugin_url = "<?php echo get_admin_url() . add_query_arg( array('page' => 'userdeck'), 'admin.php' ); ?>"; 875 </script> 876 877 <style type="text/css"> 878 #button-connect { margin: 40px 0; } 879 #iframe-guides { display: none; box-shadow: 0 1px 1px rgba(0,0,0,.04); border: 1px solid #e5e5e5; padding: 2px; background: #fff; } 880 #feature-wrapper ul { list-style-type: disc; padding-left: 20px; } 881 </style> 882 <?php endif; ?> 883 <?php endif; ?> 478 884 <?php else: ?> 479 885 <p> … … 547 953 if ( isset( $_POST['userdeck-submit'] ) ) { 548 954 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'userdeck-options' ) ) { 549 $options = $this->validate_settings( array('guides_key' => $_POST['guides_key']) ); 955 $options = array(); 956 957 if ( isset( $_POST['account_key'] ) ) { 958 $options['account_key'] = $_POST['account_key']; 959 } 960 961 if ( isset( $_POST['mailbox_id'] ) ) { 962 $options['mailbox_id'] = $_POST['mailbox_id']; 963 } 964 965 if ( isset( $_POST['guides_key'] ) ) { 966 $options['guides_key'] = $_POST['guides_key']; 967 } 968 969 $options = $this->validate_settings( $options ); 550 970 $this->update_settings( $options ); 551 971 exit; … … 553 973 } 554 974 975 if ( isset( $_POST['userdeck-page-settings'] ) ) { 976 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'userdeck-page-settings' ) ) { 977 $options = array(); 978 979 if ( isset( $_POST['ticket_portal'] ) && $_POST['ticket_portal'] == 'on' ) { 980 $ticket_portal = 1; 981 } 982 else { 983 $ticket_portal = 0; 984 } 985 986 if ( isset( $_POST['overlay_widget'] ) && $_POST['overlay_widget'] == 'on' ) { 987 $overlay_widget = 1; 988 } 989 else { 990 $overlay_widget = 0; 991 } 992 993 $options['ticket_portal'] = $ticket_portal; 994 $options['overlay_widget'] = $overlay_widget; 995 996 $this->update_settings($options); 997 998 wp_redirect( add_query_arg( array('page' => 'userdeck', 'settings_updated' => 1), 'admin.php' ) ); 999 exit; 1000 } 1001 } 1002 555 1003 if (current_user_can('publish_pages')) { 556 if ( isset( $_POST['userdeck-page-create'] ) ) { 557 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'userdeck-page-create' ) ) { 1004 if ( isset( $_POST['userdeck-page-conversations-create'] ) ) { 1005 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'userdeck-page-conversations-create' ) ) { 1006 $page_title = wp_kses( trim( $_POST['page_title'] ), array() ); 1007 $account_key = $_POST['account_key']; 1008 $mailbox_id = $_POST['mailbox_id']; 1009 1010 if (!empty($page_title) && !empty($account_key) && !empty($mailbox_id)) { 1011 $page_id = wp_insert_post( array( 1012 'post_title' => $page_title, 1013 'post_status' => 'publish', 1014 'post_author' => get_current_user_id(), 1015 'post_type' => 'page', 1016 'comment_status' => 'closed', 1017 ) ); 1018 1019 update_post_meta( $page_id, 'userdeck_account_key', $account_key ); 1020 update_post_meta( $page_id, 'userdeck_mailbox_id', $mailbox_id ); 1021 1022 wp_redirect( add_query_arg( array('page' => 'userdeck', 'page_added' => 1, 'page_id' => $page_id, 'tab' => 'conversations'), 'admin.php' ) ); 1023 exit; 1024 } 1025 } 1026 } 1027 elseif ( isset( $_POST['userdeck-page-guides-create'] ) ) { 1028 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'userdeck-page-guides-create' ) ) { 558 1029 $page_title = wp_kses( trim( $_POST['page_title'] ), array() ); 559 1030 $guides_key = $_POST['guides_key']; … … 570 1041 update_post_meta( $page_id, 'userdeck_guides_key', $guides_key ); 571 1042 572 wp_redirect( add_query_arg( array('page' => 'userdeck', 'page_added' => 1, 'page_id' => $page_id ), 'admin.php' ) );1043 wp_redirect( add_query_arg( array('page' => 'userdeck', 'page_added' => 1, 'page_id' => $page_id, 'tab' => 'guides'), 'admin.php' ) ); 573 1044 exit; 574 1045 } … … 578 1049 579 1050 if (current_user_can('edit_pages')) { 580 if ( isset( $_POST['userdeck-page-add'] ) ) { 581 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'userdeck-page-add' ) ) { 1051 if ( isset( $_POST['userdeck-page-conversations-add'] ) ) { 1052 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'userdeck-page-conversations-add' ) ) { 1053 $page_id = absint( $_POST['page_id'] ); 1054 $account_key = $_POST['account_key']; 1055 $mailbox_id = absint( $_POST['mailbox_id'] ); 1056 1057 if (!empty($page_id) && !empty($account_key) && !empty($mailbox_id)) { 1058 update_post_meta( $page_id, 'userdeck_account_key', $account_key ); 1059 update_post_meta( $page_id, 'userdeck_mailbox_id', $mailbox_id ); 1060 1061 wp_redirect( add_query_arg( array('page' => 'userdeck', 'page_updated' => 1, 'page_id' => $page_id, 'tab' => 'conversations'), 'admin.php' ) ); 1062 exit; 1063 } 1064 } 1065 } 1066 elseif ( isset( $_POST['userdeck-page-guides-add'] ) ) { 1067 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'userdeck-page-guides-add' ) ) { 582 1068 $page_id = absint( $_POST['page_id'] ); 583 1069 $guides_key = $_POST['guides_key']; … … 586 1072 update_post_meta( $page_id, 'userdeck_guides_key', $guides_key ); 587 1073 588 wp_redirect( add_query_arg( array('page' => 'userdeck', 'page_updated' => 1, 'page_id' => $page_id ), 'admin.php' ) );1074 wp_redirect( add_query_arg( array('page' => 'userdeck', 'page_updated' => 1, 'page_id' => $page_id, 'tab' => 'guides'), 'admin.php' ) ); 589 1075 exit; 590 1076 } … … 603 1089 public function validate_settings( $input ) { 604 1090 605 $input['guides_key'] = wp_kses( trim( $input['guides_key'] ), array() ); 1091 if ( isset( $input['account_key'] ) ) { 1092 $input['account_key'] = wp_kses( trim( $input['account_key'] ), array() ); 1093 } 1094 1095 if ( isset( $input['guides_key'] ) ) { 1096 $input['guides_key'] = wp_kses( trim( $input['guides_key'] ), array() ); 1097 } 606 1098 607 1099 return $input;
Note: See TracChangeset
for help on using the changeset viewer.