Plugin Directory

Changeset 1168115


Ignore:
Timestamp:
05/27/2015 03:16:48 AM (10 years ago)
Author:
userdeck
Message:

Tagging version 1.1.0

Location:
userdeck
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • userdeck/trunk/readme.txt

    r1168111 r1168115  
    11=== UserDeck Customer Support ===
    22Contributors: userdeck
    3 Tags: userdeck, customer support, customer service, knowledge base, faq, frequently asked questions, documentation, docs, widgets
     3Tags: userdeck, customer support, customer service, help, support, helpdesk, help desk, ticket, ticketing, knowledge base, knowledgebase, faq, frequently asked questions, documentation, docs, answers, widgets, zendesk
    44Requires at least: 3.7
    55Tested up to: 4.2.2
    6 Stable tag: 1.0.7
     6Stable tag: 1.1.0
    77
    88Easily integrate UserDeck's embedded support software into your WordPress website.
     
    1313
    1414= 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)
    1522
    1623**Guides**
     
    30373. Go to the settings page.
    31384. 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.
     395. 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.
    3340
    3441== Screenshots ==
     
    3946
    4047== Upgrade Notice ==
     48
     49= 1.1.0 =
     50Added new Conversations ticketing system integration.
    4151
    4252= 1.0.7 =
     
    5363
    5464== Changelog ==
     65
     66= 1.1.0 =
     67* Added integration with Conversations
    5568
    5669= 1.0.7 =
  • userdeck/trunk/userdeck.js

    r1050517 r1168115  
    22   
    33    connected: false,
     4
     5    account_key: null,
     6
     7    mailbox_id: null,
    48   
    59    guides_key: null,
    610   
    7     showConnect : function (type) {
     11    showConnect : function (type, start) {
    812        var wrapper = jQuery('#connect-frame');
     13       
     14        if (!start) {
     15            start = 'install';
     16        }
     17        else {
     18            start = 'install/' + start;
     19        }
    920
    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>')
    1122
    1223        wrapper.append(iframe);
     
    2839    },
    2940   
     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   
    3050    _receiveMessage : function (event) {
    3151        if (event.data && 'string' === typeof event.data && 'ud:' == event.data.substr(0, 3)) {
    3252            var msg = jQuery.parseJSON(event.data.substr(3));
    3353           
    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) {
    3594                var guides_key = msg.message;
    3695               
     
    4099               
    41100                UserDeck.disableConnect();
    42                
    43101                UserDeck.hideConnect();
    44102               
    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});
    48104            }
    49105        }
  • userdeck/trunk/userdeck.php

    r1168111 r1168115  
    44 * Plugin URI: http://wordpress.org/plugins/userdeck
    55 * 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.7
     6 * Version: 1.1.0
    77 * Author: UserDeck
    88 * Author URI: http://userdeck.com?utm_source=wordpress&utm_medium=link&utm_campaign=website
     
    3939        if ( is_admin() ) {
    4040            add_action( 'admin_menu', array( $this, 'create_menu_page') );
     41            add_action( 'admin_menu', array( $this, 'create_tickets_page' ) );
    4142            add_action( 'admin_init', array( $this, 'settings_init') );
    4243            add_action( 'admin_init', array( $this, 'migrate_guides_shortcodes') );
    4344            add_action( 'admin_notices', array( $this, 'admin_notice') );
    4445        }
     46       
     47        add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 99 );
    4548
    4649        add_action( 'wp_head', array( $this, 'output_escaped_fragment_meta' ) );
    4750       
     51        add_action( 'wp_footer', array( $this, 'output_conversations_overlay_code' ) );
     52       
     53        add_filter( 'the_content', array( $this, 'output_conversations_page' ) );
    4854        add_filter( 'the_content', array( $this, 'output_guides_page' ) );
    4955       
     
    9298        }
    9399       
    94         $options['migrate_guides_shortcodes'] = 1;
    95        
    96         $this->update_settings($options);
     100        $this->update_settings(array('migrate_guides_shortcodes' => 1));
    97101       
    98102    }
     
    104108    public function get_settings() {
    105109       
    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        );
    107117       
    108118        $options = get_option( 'userdeck', $defaults );
     
    120130     */
    121131    public function update_settings( $options ) {
     132       
     133        $options = wp_parse_args($options, $this->get_settings());
    122134
    123135        update_option( 'userdeck', $options );
     
    136148       
    137149        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        ));
    138169       
    139170    }
     
    210241    }
    211242   
     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   
    212346    public function output_guides_page( $content ) {
    213347       
     
    293427       
    294428    }
    295 
     429   
    296430    public function output_escaped_fragment_meta() {
    297431
     
    313447     */
    314448    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        }
    315459       
    316460        if ( isset( $_GET['page'] ) && $_GET['page'] == 'userdeck' && isset( $_GET['page_added'] ) ) {
     
    366510    }
    367511   
     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   
    368546    /**
    369547     * output the options page
     
    381559        }
    382560
     561        $account_key = $options['account_key'];
     562        $mailbox_id = $options['mailbox_id'];
    383563        $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;
    385569        $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        }
    386578       
    387579        if ($guides_key) {
    388580            $show_guides_options = true;
    389581        }
    390        
     582
     583        if ( isset( $_GET['tab'] ) ) {
     584            $tab = $_GET['tab'];
     585        }
     586        else {
     587            $tab = 'conversations';
     588        }
    391589        ?>
    392590       
     
    396594            <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>
    397595           
    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>
    400601               
    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>
    437606                       
    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%;">
    440609                                <form method="post" action="<?php echo admin_url('admin.php?page=userdeck') ?>">
    441610                                    <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>
    443612                                       
    444613                                        <div class="inside">
    445                                             <p>Add the Guides knowledge base inline widget to an existing page.</p>
    446                                            
    447614                                            <table class="form-table">
    448615                                                <tbody>
    449616                                                    <tr valign="top">
    450617                                                        <th scope="row">
    451                                                             <label for="page-id">Page</label>
     618                                                            Ticket Portal
    452619                                                        </th>
    453620                                                        <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>
    459623                                                            <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>
    461636                                                        </td>
    462637                                                    </tr>
     
    465640                                           
    466641                                            <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" />
    470644                                            </p>
    471645                                        </div>
    472646                                    </div>
    473647                                </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; ?>
    478884            <?php else: ?>
    479885                <p>
     
    547953            if ( isset( $_POST['userdeck-submit'] ) ) {
    548954                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 );
    550970                    $this->update_settings( $options );
    551971                    exit;
     
    553973            }
    554974           
     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           
    5551003            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' ) ) {
    5581029                        $page_title = wp_kses( trim( $_POST['page_title'] ), array() );
    5591030                        $guides_key = $_POST['guides_key'];
     
    5701041                            update_post_meta( $page_id, 'userdeck_guides_key', $guides_key );
    5711042                           
    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' ) );
    5731044                            exit;
    5741045                        }
     
    5781049           
    5791050            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' ) ) {
    5821068                        $page_id = absint( $_POST['page_id'] );
    5831069                        $guides_key = $_POST['guides_key'];
     
    5861072                            update_post_meta( $page_id, 'userdeck_guides_key', $guides_key );
    5871073                           
    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' ) );
    5891075                            exit;
    5901076                        }
     
    6031089    public function validate_settings( $input ) {
    6041090
    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        }
    6061098
    6071099        return $input;
Note: See TracChangeset for help on using the changeset viewer.