Drift - Version 1.5

Version Description

  • Cleanup
  • New page targeting options
  • Flush Cache on setup
  • Localization
Download this release

Release Info

Developer driftcom
Plugin Icon Drift
Version 1.5
Comparing to
See all releases

Code changes from version 1.4 to 1.5

Files changed (7) hide show
  1. README.md +1 -1
  2. drift.php +15 -181
  3. includes/admin.php +70 -0
  4. includes/core.php +18 -0
  5. includes/embed.php +64 -0
  6. includes/menus.php +34 -0
  7. readme.txt +12 -6
README.md CHANGED
@@ -4,7 +4,7 @@
4
 
5
  1. Create and configure an account at [Drift](http://www.drift.com).
6
  2. Add this plugin to WordPress and enable it. See [Managing Plugins](https://codex.wordpress.org/Managing_Plugins)
7
- 3. Visit https://app.driftt.com/settings/configure and copy the code chunk
8
  4. Visit Drift Settings on your WordPress site and paste the code chunk into the textarea. Submit the settings form.
9
 
10
  # Users
4
 
5
  1. Create and configure an account at [Drift](http://www.drift.com).
6
  2. Add this plugin to WordPress and enable it. See [Managing Plugins](https://codex.wordpress.org/Managing_Plugins)
7
+ 3. Visit https://app.drift.com/customize and copy the code chunk
8
  4. Visit Drift Settings on your WordPress site and paste the code chunk into the textarea. Submit the settings form.
9
 
10
  # Users
drift.php CHANGED
@@ -1,194 +1,28 @@
1
  <?php
2
  /*
3
  * Plugin Name: Drift
4
- * Version: 1.4
5
- * Plugin URI: https://www.drift.com/?ref=wordpress
6
- * Description: Adds Drift free live chat to your website. Designed for internet businesses like yours to increase sales, conversions and better support your customers.
7
  * Author: Drift
8
- * Author URI: http://www.drift.com/
 
9
  */
10
 
11
  // Prevent Direct Access
12
  defined('ABSPATH') or die("Restricted access!");
13
 
14
- //=============================================
15
- // Define Constants
16
- //=============================================
17
- defined('DRIFT_PATH') or define('DRIFT_PATH', untrailingslashit(plugins_url('', __FILE__)));
18
-
19
- // Register settings
20
- function Drift_register_settings()
21
- {
22
- register_setting( 'Drift_settings_group', 'Drift_settings' );
23
- }
24
- add_action( 'admin_init', 'Drift_register_settings' );
25
-
26
- // Create a option page for settings
27
- add_action('admin_menu', 'add_drift_option_page');
28
-
29
- // Add top-level admin bar link
30
- add_action('admin_bar_menu', 'add_drift_link_to_admin_bar', 999);
31
-
32
-
33
- // Adds Drift link to top-level admin bar
34
- function add_drift_link_to_admin_bar()
35
- {
36
- global $wp_version;
37
- global $wp_admin_bar;
38
-
39
- $drift_icon = '<img src="' . DRIFT_PATH . '/assets/drift-icon-16x16-white.png' . '">';
40
-
41
- $args = array(
42
- 'id' => 'drift-admin-menu',
43
- 'title' => '<span class="ab-icon" ' . ($wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? ' style="margin-top: 3px;"' : '') . '>' . $drift_icon . '</span><span class="ab-label">Drift</span>', // alter the title of existing node
44
- 'parent' => FALSE, // set parent to false to make it a top level (parent) node
45
- 'href' => get_bloginfo('wpurl') . '/wp-admin/admin.php?page=drift.php',
46
- 'meta' => array('title' => 'Drift')
47
- );
48
-
49
- $wp_admin_bar->add_node($args);
50
- }
51
-
52
- // Hook in the options page functionå
53
- function add_drift_option_page()
54
- {
55
- add_options_page('Drift Options', 'Drift', 'activate_plugins', basename(__FILE__), 'drift_options_page');
56
- }
57
-
58
- // Output the options page
59
- function drift_options_page()
60
- {
61
- // Get options
62
- $options = get_option('Drift_settings');
63
-
64
- // Check to see if Drift is enabled
65
- $drift_activated = false;
66
- if ( esc_attr( $options['drift_enabled'] ) == "on" ) { $drift_activated = true; }
67
-
68
- ?>
69
- <div class="wrap">
70
- <form name="Drift-form" action="options.php" method="post" enctype="multipart/form-data">
71
- <?php settings_fields( 'Drift_settings_group' ); ?>
72
-
73
- <h1>Drift</h1>
74
- <h3>Basic Options</h3>
75
- <?php if ( ! $drift_activated ) { ?>
76
- <div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
77
- Drift Live Chat is currently <strong>DISABLED</strong>.
78
- </div>
79
- <?php } ?>
80
- <?php do_settings_sections( 'Drift_settings_group' ); ?>
81
-
82
- <table class="form-table" cellspacing="2" cellpadding="5" width="100%">
83
- <tr>
84
- <th width="30%" valign="top" style="padding-top: 10px;">
85
- <label for="drift_enabled">Drift (Live Chat) is:</label>
86
- </th>
87
- <td>
88
- <?php
89
- echo "<select name=\"Drift_settings[drift_enabled]\" id=\"drift_enabled\">\n";
90
-
91
- echo "<option value=\"on\"";
92
- if ( $drift_activated ) { echo " selected='selected'"; }
93
- echo ">Enabled</option>\n";
94
-
95
- echo "<option value=\"off\"";
96
- if ( ! $drift_activated ) { echo" selected='selected'"; }
97
- echo ">Disabled</option>\n";
98
- echo "</select>\n";
99
- ?>
100
- </td>
101
- </tr>
102
- </table>
103
- <table class="form-table" cellspacing="2" cellpadding="5" width="100%">
104
- <tr>
105
- <th valign="top" style="padding-top: 10px;">
106
- <label for="Drift_widget_code">Drift JS code snippet:</label>
107
- </th>
108
- <td>
109
- <textarea rows="8" cols="100" placeholder="<!-- Insert the Drift tag here -->" name="Drift_settings[drift_widget_code]"><?php echo esc_attr( $options['drift_widget_code'] ); ?></textarea>
110
- <p style="margin: 5px 10px;">Enter your Drift JS code snippet. You can find your <a href="https://app.driftt.com/settings/configure" target="_blank" title="Open Drift Settings">Drift JS code snippet here</a>. A Free Drift account is required to use this plugin.</p>
111
- </td>
112
- </tr>
113
- </table>
114
- <p class="submit">
115
- <?php echo submit_button('Save Changes'); ?>
116
- </p>
117
- </div>
118
- </form>
119
-
120
- <?php
121
- }
122
-
123
- // Add the script
124
- add_action('wp_head', 'add_drift');
125
-
126
- // If we can indentify the current user output
127
- function get_drift_identify()
128
- {
129
- global $current_user;
130
- get_currentuserinfo();
131
- if ($current_user->user_email) {
132
- $sanitized_email = sanitize_email($current_user->user_email);
133
- echo "<!-- Start Identify call for Drift -->\n";
134
- echo "<script>\n";
135
- echo "drift.identify(\"".md5($sanitized_email)."\", { email: \"".$sanitized_email."\", name: \"".sanitize_text_field($current_user->user_login)."\" });\n";
136
- echo "</script>\n";
137
- echo "<!-- End Identify call for Drift -->\n";
138
- } else {
139
- // See if current user is a commenter
140
- $commenter = wp_get_current_commenter();
141
- if ($commenter['comment_author_email']) {
142
- echo "<!-- Start Identify call for Drift -->\n";
143
- echo "<script>\n";
144
- echo "drift.identify(\"".md5(sanitize_email($commenter['comment_author_email']))."\", { email: \"".sanitize_email($commenter['comment_author_email'])."\", name: \"".sanitize_text_field($commenter['comment_author'])."\" });\n";
145
- echo "</script>\n";
146
- echo "<!-- End Identify call for Drift -->\n";
147
- }
148
- }
149
- }
150
-
151
- // The guts of the Drift script
152
- function add_drift()
153
- {
154
- // Ignore admin, feed, robots or trackbacks
155
- if ( is_feed() || is_robots() || is_trackback() )
156
- {
157
- return;
158
- }
159
-
160
- global $current_user;
161
- get_currentuserinfo();
162
- $options = get_option('Drift_settings');
163
-
164
- // If options is empty then exit
165
- if( empty( $options ) )
166
- {
167
- return;
168
- }
169
-
170
- // Check to see if Drift is enabled
171
- if ( esc_attr( $options['drift_enabled'] ) == "on" )
172
- {
173
- $drift_tag = $options['drift_widget_code'];
174
 
175
- // Insert tracker code
176
- if ( '' != $drift_tag )
177
- {
178
- echo "<!-- Start Drift By WP-Plugin: Drift -->\n";
179
- echo $drift_tag;
180
- echo"<!-- end: Drift Code. -->\n";
181
 
182
- // Optional
183
- get_drift_identify();
184
- }
185
- }
186
- }
187
 
188
- // Delete options on uninstall
189
- function Drift_uninstall()
190
- {
191
- delete_option( 'Drift_settings' );
192
- }
193
- register_uninstall_hook( __FILE__, 'Drift_uninstall' );
194
  ?>
1
  <?php
2
  /*
3
  * Plugin Name: Drift
4
+ * Version: 1.5
5
+ * Description: Adds 100% free live chat & targeted messages to your website. Designed for internet businesses like yours to increase sales, conversions and better support your customers.
 
6
  * Author: Drift
7
+ * Author URI: https://www.drift.com/?ref=wordpress
8
+ * Plugin URI: https://www.drift.com/?ref=wordpress
9
  */
10
 
11
  // Prevent Direct Access
12
  defined('ABSPATH') or die("Restricted access!");
13
 
14
+ /*
15
+ * Define
16
+ */
17
+ define('DRIFT_4f050d29b8BB9_VERSION', '1.5');
18
+ define('DRIFT_4f050d29b8BB9_DIR', plugin_dir_path(__FILE__));
19
+ define('DRIFT_4f050d29b8BB9_URL', plugin_dir_url(__FILE__));
20
+ defined('DRIFT_4f050d29b8BB9_PATH') or define('DRIFT_4f050d29b8BB9_PATH', untrailingslashit(plugins_url('', __FILE__)));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ require_once(DRIFT_4f050d29b8BB9_DIR . 'includes/core.php');
23
+ require_once(DRIFT_4f050d29b8BB9_DIR . 'includes/menus.php');
24
+ require_once(DRIFT_4f050d29b8BB9_DIR . 'includes/admin.php');
25
+ require_once(DRIFT_4f050d29b8BB9_DIR . 'includes/embed.php');
 
 
26
 
 
 
 
 
 
27
 
 
 
 
 
 
 
28
  ?>
includes/admin.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Output the options page
4
+ function drift_options_page()
5
+ {
6
+ // Get options
7
+ $options = get_option('Drift_settings');
8
+
9
+ // Check to see if Drift is enabled
10
+ $drift_activated = false;
11
+ if ( esc_attr( $options['drift_enabled'] ) == "on" ) {
12
+ $drift_activated = true;
13
+ wp_cache_flush();
14
+ }
15
+
16
+ ?>
17
+ <div class="wrap">
18
+ <form name="Drift-form" action="options.php" method="post" enctype="multipart/form-data">
19
+ <?php settings_fields( 'Drift_settings_group' ); ?>
20
+
21
+ <h1>Drift</h1>
22
+ <h3>Basic Options</h3>
23
+ <?php if ( ! $drift_activated ) { ?>
24
+ <div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
25
+ Drift Live Chat is currently <strong>DISABLED</strong>.
26
+ </div>
27
+ <?php } ?>
28
+ <?php do_settings_sections( 'Drift_settings_group' ); ?>
29
+
30
+ <table class="form-table" cellspacing="2" cellpadding="5" width="100%">
31
+ <tr>
32
+ <th width="30%" valign="top" style="padding-top: 10px;">
33
+ <label for="drift_enabled">Drift (Live Chat) is:</label>
34
+ </th>
35
+ <td>
36
+ <?php
37
+ echo "<select name=\"Drift_settings[drift_enabled]\" id=\"drift_enabled\">\n";
38
+
39
+ echo "<option value=\"on\"";
40
+ if ( $drift_activated ) { echo " selected='selected'"; }
41
+ echo ">Enabled</option>\n";
42
+
43
+ echo "<option value=\"off\"";
44
+ if ( ! $drift_activated ) { echo" selected='selected'"; }
45
+ echo ">Disabled</option>\n";
46
+ echo "</select>\n";
47
+ ?>
48
+ </td>
49
+ </tr>
50
+ </table>
51
+ <table class="form-table" cellspacing="2" cellpadding="5" width="100%">
52
+ <tr>
53
+ <th valign="top" style="padding-top: 10px;">
54
+ <label for="Drift_widget_code">Drift JS code snippet:</label>
55
+ </th>
56
+ <td>
57
+ <textarea rows="15" cols="100" placeholder="<!-- Insert the Drift tag here -->" name="Drift_settings[drift_widget_code]"><?php echo esc_attr( $options['drift_widget_code'] ); ?></textarea>
58
+ <p style="margin: 5px 10px;">Enter your Drift JS code snippet. You can find your <a href="https://app.drift.com/customize" target="_blank" title="Open Drift Settings">Drift JS code snippet here</a>. A Free Drift account is required to use this plugin.</p>
59
+ </td>
60
+ </tr>
61
+ </table>
62
+ <p class="submit">
63
+ <?php echo submit_button('Save Changes'); ?>
64
+ </p>
65
+ </div>
66
+ </form>
67
+
68
+ <?php
69
+ }
70
+ ?>
includes/core.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Register settings
4
+ function Drift_register_settings()
5
+ {
6
+ register_setting( 'Drift_settings_group', 'Drift_settings' );
7
+ }
8
+ add_action( 'admin_init', 'Drift_register_settings' );
9
+
10
+ // Delete options on uninstall
11
+ function Drift_uninstall()
12
+ {
13
+ delete_option( 'Drift_settings' );
14
+ }
15
+ register_uninstall_hook( __FILE__, 'Drift_uninstall' );
16
+
17
+
18
+ ?>
includes/embed.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Add the Drift Javascript
4
+ add_action('wp_head', 'add_drift');
5
+
6
+ // If we can indentify the current user output
7
+ function get_drift_identify()
8
+ {
9
+ $current_user = wp_get_current_user();
10
+ if ($current_user->user_email) {
11
+ $sanitized_email = sanitize_email($current_user->user_email);
12
+ echo "<!-- Start Identify call for Drift -->\n";
13
+ echo "<script>\n";
14
+ echo "drift.identify(\"".md5($sanitized_email)."\", { email: \"".$sanitized_email."\", name: \"".sanitize_text_field($current_user->user_login)."\" });\n";
15
+ echo "</script>\n";
16
+ echo "<!-- End Identify call for Drift -->\n";
17
+ } else {
18
+ // See if current user is a commenter
19
+ $commenter = wp_get_current_commenter();
20
+ if ($commenter['comment_author_email']) {
21
+ echo "<!-- Start Identify call for Drift -->\n";
22
+ echo "<script>\n";
23
+ echo "drift.identify(\"".md5(sanitize_email($commenter['comment_author_email']))."\", { email: \"".sanitize_email($commenter['comment_author_email'])."\", name: \"".sanitize_text_field($commenter['comment_author'])."\" });\n";
24
+ echo "</script>\n";
25
+ echo "<!-- End Identify call for Drift -->\n";
26
+ }
27
+ }
28
+ }
29
+
30
+ // The guts of the Drift script
31
+ function add_drift()
32
+ {
33
+ // Ignore admin, feed, robots or trackbacks
34
+ if ( is_feed() || is_robots() || is_trackback() )
35
+ {
36
+ return;
37
+ }
38
+
39
+ $options = get_option('Drift_settings');
40
+
41
+ // If options is empty then exit
42
+ if( empty( $options ) )
43
+ {
44
+ return;
45
+ }
46
+
47
+ // Check to see if Drift is enabled
48
+ if ( esc_attr( $options['drift_enabled'] ) == "on" )
49
+ {
50
+ $drift_tag = $options['drift_widget_code'];
51
+
52
+ // Insert tracker code
53
+ if ( '' != $drift_tag )
54
+ {
55
+ echo "<!-- Start Drift By WP-Plugin: Drift -->\n";
56
+ echo $drift_tag;
57
+ echo"<!-- end: Drift Code. -->\n";
58
+
59
+ // Optional
60
+ get_drift_identify();
61
+ }
62
+ }
63
+ }
64
+ ?>
includes/menus.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Create a option page for settings
4
+ add_action('admin_menu', 'add_drift_option_page');
5
+
6
+ // Add top-level admin bar link
7
+ add_action('admin_bar_menu', 'add_drift_link_to_admin_bar', 999);
8
+
9
+ // Adds Drift link to top-level admin bar
10
+ function add_drift_link_to_admin_bar()
11
+ {
12
+ global $wp_version;
13
+ global $wp_admin_bar;
14
+
15
+ $drift_icon = '<img src="' . DRIFT_4f050d29b8BB9_PATH . '/assets/drift-icon-16x16-white.png' . '">';
16
+
17
+ $args = array(
18
+ 'id' => 'drift-admin-menu',
19
+ 'title' => '<span class="ab-icon" ' . ($wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? ' style="margin-top: 3px;"' : '') . '>' . $drift_icon . '</span><span class="ab-label">Drift</span>', // alter the title of existing node
20
+ 'parent' => FALSE, // set parent to false to make it a top level (parent) node
21
+ 'href' => get_bloginfo('wpurl') . '/wp-admin/admin.php?page=menus.php',
22
+ 'meta' => array('title' => 'Drift')
23
+ );
24
+
25
+ $wp_admin_bar->add_node($args);
26
+ }
27
+
28
+ // Hook in the options page functionå
29
+ function add_drift_option_page()
30
+ {
31
+ add_options_page('Drift Options', 'Drift', 'activate_plugins', basename(__FILE__), 'drift_options_page');
32
+ }
33
+
34
+ ?>
readme.txt CHANGED
@@ -1,17 +1,17 @@
1
  === Drift ===
2
  Contributors: Drift
3
 
4
- Tags: customer, chat, free chat, livechat, Slack, Intercom, HubSpot, Salesforce, Zapier, hellobar, hello bar, popup, Ontraport, Pardot, Klaviyo, popup, exit intent, growth, subscribers, subscription, email form, analytics, widget, lightbox, inbound marketing, welcome mat, landing pagelivechat, olark, boldchat, online chat, online support, php live chat, snapengage, support software, Website Chat, WordPress chat, wordpress live chat, wordpress live chat plugin, zendesk, Zopim, Zopim live chat, tawk, tawk.to, tawkto, jivosite, snapengage,Chat Widget
5
 
6
  Drift enables you to chat with your website visitors, increase sales and collect feedback for Free.
7
 
8
- Requires at least: 4.0.1
9
- Tested up to: 4.5.1
10
- Stable tag: 1.4
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
14
- Drift allows you to talk to your website visitors and customers in real-time, from anywhere.
15
 
16
  == Description ==
17
 
@@ -117,12 +117,18 @@ Note: You will need a free Drift account : <a href="https://www.drift.com/?utm_s
117
  Step-by-step Guide:
118
 
119
  * Install plugin from WordPress directory and activate it.
120
- * Under Drift section, click on Settings to add your Drift embed code.
121
  * Customize the chat widget to your preference.
122
  * Finally, make full use of our Dashboard to manage your chat widget.
123
 
124
  == Changelog ==
125
 
 
 
 
 
 
 
126
  = 1.4 =
127
  * Clean up code.
128
  * Better checking of user capabilities.
1
  === Drift ===
2
  Contributors: Drift
3
 
4
+ Tags: drift, live chat, chat, communication, sales, marketing, announcements, talk to customers, customer feedback, feedback, chat plugin, free, free chat, chatra, livechat, slack, intercom, hubspot, salesforce, zapier, hellobar, hello bar, popup, ontraport, pardot, klaviyo, popup, exit intent, growth, subscribers, subscription, email form, analytics, widget, lightbox, inbound marketing, welcome mat, landing pagelivechat, olark, boldchat, online chat, online support, in-app chat, instant message, helpdesk, php live chat, snapengage, support software, website chat, wordpress chat, wordpress live chat, wordpress live chat plugin, zendesk, zopim, zopim live chat, tawk, tawk.to, tawkto, jivosite, snapengage,chat widget
5
 
6
  Drift enables you to chat with your website visitors, increase sales and collect feedback for Free.
7
 
8
+ Requires at least: 3.4
9
+ Tested up to: 4.6.1
10
+ Stable tag: 1.4.1
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
14
+ Drift is the 100% free way used by over 10,000 businesses to talk to their leads and customers in real-time, from anywhere. Try it now!
15
 
16
  == Description ==
17
 
117
  Step-by-step Guide:
118
 
119
  * Install plugin from WordPress directory and activate it.
120
+ * Under settings section, click on Drift to add your Drift embed code
121
  * Customize the chat widget to your preference.
122
  * Finally, make full use of our Dashboard to manage your chat widget.
123
 
124
  == Changelog ==
125
 
126
+ = 1.5 =
127
+ * Cleanup
128
+ * New page targeting options
129
+ * Flush Cache on setup
130
+ * Localization
131
+
132
  = 1.4 =
133
  * Clean up code.
134
  * Better checking of user capabilities.