# TalkJS #
**Contributors:** TalkJS  
**Donate link:** https://talkjs.com/  
**Tags:** chat, customer support  
**Requires at least:** 4.4  
**Tested up to:** 4.8.2
**Stable tag:** 0.1.0  
**License:** GPLv2 or later  
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html  

The TalkJS plugin integrates TalkJS' messaging platform with your WordPress website. 

## Description ##

The TalkJS plugin allows you to add user-to-user chat to your marketplace, on-demand app, or social platform. You'll have it up and running in 5 minutes. It integrates fully with WooCommerce and plugins like WCVendors.

This plugin offers you shortcodes and template tags for our three basic views: The inbox, the chatbox and the chat pop-up. It also adds a chatbox widget and an inbox-page. 


## Installation ##

Follow these simple steps to get started:

1. Upload `talkjs` to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Follow the on-screen instructions to initiate the test version of the plugin
4. If you're satisfied with the plugin, consider updating to a paid account.


## Screenshots ##

### 1. The TalkJS settings page


## Changelog ##

### 1.0.0 ###
* First public release
* Adds \[talkjs_chat\], \[talkjs_inbox\], \[talkjs_popup\] shortcodes
* Adds a chatbox widget
* Adds template tags for talkjs_chat() talkjs_inbox() and talkjs_popup()


## For developers ##

If you're looking to integrate the TalkJS messaging platform to your WordPress site, this is the easiest way to do it.
You can use three methods of implementation:

1. Shortcodes
2. Widgets
3. Template tags

### Shortcodes
You can use shortcodes on a post-by-post basis. The following three shortcodes are available: 
* [talkjs_chat]
* [talkjs_inbox]
* [talkjs_popup]

You can pass along the default conversation partner for the chat and the popup. You do this by adding a user ID to the shortcode: [talkjs_chat user="2"]
If you wish to get the author of the post as your conversation partner you can use the following: [talkjs_chat userType="author"]. You don't need to fill in the user ID in this case.

With all three you can pass along a custom welcome message like this: [talkjs_chat welcomeMessage="Hi there!"]

### Widgets
There's currently only one widget available: The TalkJS Chatbox widget. In it you can set a title, a welcome message and the conversation partner (a user, or the current post author)

### Template tags
You can use template tags if you want to display the chatbox, inbox or popup on certain templates. You use them in your code like so:

`<?php talkjs_chat();?>`
`<?php talkjs_popup();?>`
`<?php talkjs_inbox();?>`

You can pass along the same attributes as in the shortcode-version. You add them in an array, like this:
`<?php 
talkjs_chat([
    'welcomeMessage' => "Hi there, let\'s chat!",
    'userType' => 'author'
]);
?>
`

### Welcome Message customization

You can add custom variables to your welcome message. These variables are available:

* {{first_name}} -> logged in users' first name.
* {{last_name}} -> logged in users' last name.
* {{name}} -> logged in users' full name.


### Available filters

There are a couple of filters available for developers:

#### talkjs_app_mode
Force the app mode (test or live). If you're working with multiple dev environments, this can be very handy to force a certain environment
`
    <?php
    add_filter( 'talkjs_app_mode', function( $mode ){

        if( get_env( 'live' ) ){
            return 'live';
        }else{
            return 'test';
        }

    });
    ?>
`


#### talkjs_hidden_post_types_for_chat_popup
Hide your custom post-type as a viable chat option.

`
    <?php
    add_filter( 'talkjs_hidden_post_types_for_chat_popup', function( $postTypes ){

        $postTypes[] = 'my-custom-post-type';
        return $postTypes;

    });
    ?>
`