Changeset 1755082
- Timestamp:
- 10/30/2017 09:56:23 AM (8 years ago)
- Location:
- freshchat
- Files:
-
- 4 edited
- 3 copied
-
tags/2.1.0 (copied) (copied from freshchat/trunk)
-
tags/2.1.0/Readme.txt (copied) (copied from freshchat/trunk/Readme.txt) (2 diffs)
-
tags/2.1.0/freshchat.php (copied) (copied from freshchat/trunk/freshchat.php) (2 diffs)
-
tags/2.1.0/widget-settings/add_to_page.php (modified) (2 diffs)
-
trunk/Readme.txt (modified) (2 diffs)
-
trunk/freshchat.php (modified) (2 diffs)
-
trunk/widget-settings/add_to_page.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
freshchat/tags/2.1.0/Readme.txt
r1750349 r1755082 6 6 Tested up to: 4.8.2 7 7 Requires PHP: 5.2.4 8 Stable tag: 2. 0.08 Stable tag: 2.1.0 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 74 74 == 2.0.2 == 75 75 README update 76 77 == 2.1.0 == 78 Restore user implementation -
freshchat/tags/2.1.0/freshchat.php
r1750349 r1755082 2 2 /* 3 3 Plugin Name: Freshchat 4 Version: 2. 0.24 Version: 2.1.0 5 5 Author: Freshchat 6 6 Description: Modern messaging software that your sales and customer engagement teams will love. … … 20 20 add_action('admin_enqueue_scripts', 'add_admin_style'); 21 21 22 function update_restore_id() { 23 $current_user = wp_get_current_user(); 24 update_user_meta($current_user->ID, "restore_id", $_POST['restoreId']); 25 if ( is_wp_error( $current_user->ID) ) { 26 die( "Fail" ); 27 } else { 28 die( "Success" ); 29 } 30 } 31 add_action( 'wp_ajax_update_restore_id', 'update_restore_id' ); 32 22 33 require_once(FRESHCHAT_DIR . 'widget-settings/main.php'); 23 34 require_once(FRESHCHAT_DIR . 'widget-settings/menu.php'); -
freshchat/tags/2.1.0/widget-settings/add_to_page.php
r1736154 r1755082 8 8 { 9 9 $current_user = wp_get_current_user(); 10 echo '<script>'; 11 echo 'console.log('. json_encode( $current_user ) .')'; 12 echo '</script>'; 10 $user_meta = get_user_meta($current_user->ID, "restore_id"); 13 11 if ($current_user->user_email) { 14 12 $sanitized_email = sanitize_email($current_user->user_email); 15 $null = "NULL";16 13 echo "<script>\n"; 17 echo 'console.log('. json_encode( $sanitized_email ) .');'; 18 echo "window.fcSettings.siteId ='".(sanitize_text_field($current_user->user_url) ? sanitize_text_field($current_user->user_url) : $null)."';\n"; 19 echo "window.fcSettings.externalId ='".(sanitize_text_field($current_user->user_pass) ? sanitize_text_field($current_user->user_pass) : $null)."';\n"; 20 echo "window.fcSettings.firstName ='".(sanitize_text_field($current_user->display_name) ? sanitize_text_field($current_user->display_name) : $null)."';\n"; 21 echo "window.fcSettings.email ='".($sanitized_email ? $sanitized_email : $null)."';\n"; 14 echo "window.fcSettings.externalId ='".sanitize_text_field($current_user->user_pass)."';\n"; 15 echo "window.fcSettings.restoreId ='".sanitize_text_field($user_meta[0])."';\n"; 16 echo "window.fcSettings.onInit = function() { 17 window.fcWidget.on('widget:loaded', function() { 18 window.fcWidget.user.get().then(function(resp) { 19 var status = resp && resp.status, 20 data = resp && resp.data; 21 if (status === 200) { 22 if (data.restoreId) { 23 jQuery.post( ajaxurl, { 24 action: 'update_restore_id', 25 restoreId: data.restoreId 26 }, function() { 27 console.log('Restore id is updated successfully'); 28 }); 29 } 30 } 31 }, function(err){ 32 var status = err && err.status; 33 if((status === 401 || status === 403 || status === 404) && !window.fcSettings.restoreId){ 34 window.fcWidget.user.create().then(function(resp){ 35 var data = resp && resp.data; 36 if (data.restoreId) { 37 jQuery.post( ajaxurl, { 38 action: 'update_restore_id', 39 restoreId: data.restoreId 40 }, function() { 41 console.log('Restore id is updated successfully'); 42 }); 43 } 44 },function(err){ 45 console.log('User creation is failed', err); 46 }) 47 }else if((status === 401 || status === 404 && status === 409) && window.fcSettings.restoreId){ 48 window.fcSettings.restoreId = undefined; 49 window.fcWidget.user.create().then(function(resp){ 50 var data = resp && resp.data; 51 if (data.restoreId) { 52 jQuery.post( ajaxurl, { 53 action: 'update_restore_id', 54 restoreId: data.restoreId 55 }, function() { 56 console.log('Restore id is updated successfully'); 57 }); 58 } 59 },function(err){ 60 console.log('User creation is failed', err); 61 }) 62 } 63 }); 64 }); 65 };\n"; 66 echo "window.fcSettings.firstName ='".sanitize_text_field($current_user->display_name)."';\n"; 67 echo "window.fcSettings.email ='".$sanitized_email."';\n"; 22 68 echo "</script>\n"; 23 69 } … … 26 72 function add_fc() 27 73 { 74 echo "<script>\n"; 75 echo "var ajaxurl = '".admin_url('admin-ajax.php')."';\n"; 76 echo "</script>\n"; 28 77 // Ignore admin, feed, robots or trackbacks 29 78 if ( is_feed() || is_robots() || is_trackback() ) -
freshchat/trunk/Readme.txt
r1750349 r1755082 6 6 Tested up to: 4.8.2 7 7 Requires PHP: 5.2.4 8 Stable tag: 2. 0.08 Stable tag: 2.1.0 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 74 74 == 2.0.2 == 75 75 README update 76 77 == 2.1.0 == 78 Restore user implementation -
freshchat/trunk/freshchat.php
r1750349 r1755082 2 2 /* 3 3 Plugin Name: Freshchat 4 Version: 2. 0.24 Version: 2.1.0 5 5 Author: Freshchat 6 6 Description: Modern messaging software that your sales and customer engagement teams will love. … … 20 20 add_action('admin_enqueue_scripts', 'add_admin_style'); 21 21 22 function update_restore_id() { 23 $current_user = wp_get_current_user(); 24 update_user_meta($current_user->ID, "restore_id", $_POST['restoreId']); 25 if ( is_wp_error( $current_user->ID) ) { 26 die( "Fail" ); 27 } else { 28 die( "Success" ); 29 } 30 } 31 add_action( 'wp_ajax_update_restore_id', 'update_restore_id' ); 32 22 33 require_once(FRESHCHAT_DIR . 'widget-settings/main.php'); 23 34 require_once(FRESHCHAT_DIR . 'widget-settings/menu.php'); -
freshchat/trunk/widget-settings/add_to_page.php
r1736154 r1755082 8 8 { 9 9 $current_user = wp_get_current_user(); 10 echo '<script>'; 11 echo 'console.log('. json_encode( $current_user ) .')'; 12 echo '</script>'; 10 $user_meta = get_user_meta($current_user->ID, "restore_id"); 13 11 if ($current_user->user_email) { 14 12 $sanitized_email = sanitize_email($current_user->user_email); 15 $null = "NULL";16 13 echo "<script>\n"; 17 echo 'console.log('. json_encode( $sanitized_email ) .');'; 18 echo "window.fcSettings.siteId ='".(sanitize_text_field($current_user->user_url) ? sanitize_text_field($current_user->user_url) : $null)."';\n"; 19 echo "window.fcSettings.externalId ='".(sanitize_text_field($current_user->user_pass) ? sanitize_text_field($current_user->user_pass) : $null)."';\n"; 20 echo "window.fcSettings.firstName ='".(sanitize_text_field($current_user->display_name) ? sanitize_text_field($current_user->display_name) : $null)."';\n"; 21 echo "window.fcSettings.email ='".($sanitized_email ? $sanitized_email : $null)."';\n"; 14 echo "window.fcSettings.externalId ='".sanitize_text_field($current_user->user_pass)."';\n"; 15 echo "window.fcSettings.restoreId ='".sanitize_text_field($user_meta[0])."';\n"; 16 echo "window.fcSettings.onInit = function() { 17 window.fcWidget.on('widget:loaded', function() { 18 window.fcWidget.user.get().then(function(resp) { 19 var status = resp && resp.status, 20 data = resp && resp.data; 21 if (status === 200) { 22 if (data.restoreId) { 23 jQuery.post( ajaxurl, { 24 action: 'update_restore_id', 25 restoreId: data.restoreId 26 }, function() { 27 console.log('Restore id is updated successfully'); 28 }); 29 } 30 } 31 }, function(err){ 32 var status = err && err.status; 33 if((status === 401 || status === 403 || status === 404) && !window.fcSettings.restoreId){ 34 window.fcWidget.user.create().then(function(resp){ 35 var data = resp && resp.data; 36 if (data.restoreId) { 37 jQuery.post( ajaxurl, { 38 action: 'update_restore_id', 39 restoreId: data.restoreId 40 }, function() { 41 console.log('Restore id is updated successfully'); 42 }); 43 } 44 },function(err){ 45 console.log('User creation is failed', err); 46 }) 47 }else if((status === 401 || status === 404 && status === 409) && window.fcSettings.restoreId){ 48 window.fcSettings.restoreId = undefined; 49 window.fcWidget.user.create().then(function(resp){ 50 var data = resp && resp.data; 51 if (data.restoreId) { 52 jQuery.post( ajaxurl, { 53 action: 'update_restore_id', 54 restoreId: data.restoreId 55 }, function() { 56 console.log('Restore id is updated successfully'); 57 }); 58 } 59 },function(err){ 60 console.log('User creation is failed', err); 61 }) 62 } 63 }); 64 }); 65 };\n"; 66 echo "window.fcSettings.firstName ='".sanitize_text_field($current_user->display_name)."';\n"; 67 echo "window.fcSettings.email ='".$sanitized_email."';\n"; 22 68 echo "</script>\n"; 23 69 } … … 26 72 function add_fc() 27 73 { 74 echo "<script>\n"; 75 echo "var ajaxurl = '".admin_url('admin-ajax.php')."';\n"; 76 echo "</script>\n"; 28 77 // Ignore admin, feed, robots or trackbacks 29 78 if ( is_feed() || is_robots() || is_trackback() )
Note: See TracChangeset
for help on using the changeset viewer.