Changeset 2606796
- Timestamp:
- 09/29/2021 01:36:20 PM (5 years ago)
- Location:
- segment-for-wp-by-in8-io/trunk
- Files:
-
- 4 edited
-
README.txt (modified) (2 diffs)
-
includes/class-segment-for-wp-by-in8-io-identify.php (modified) (2 diffs)
-
includes/class-segment-for-wp-by-in8-io.php (modified) (1 diff)
-
segment-for-wp-by-in8-io.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
segment-for-wp-by-in8-io/trunk/README.txt
r2606659 r2606796 6 6 Tested up to: 5.8.1 7 7 Requires PHP: 7.0.0 8 Stable tag: 2.1. 08 Stable tag: 2.1.1 9 9 License: GPLv3 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 72 72 == Changelog == 73 73 74 = 2.1.1 = 75 * Fixes for Logged In event and fallback identify call 76 74 77 = 2.1.0 = 75 78 * Adding filter hooks and hook documentation -
segment-for-wp-by-in8-io/trunk/includes/class-segment-for-wp-by-in8-io-identify.php
r2606659 r2606796 3 3 class Segment_For_Wp_By_In8_Io_Identify { 4 4 5 /**6 * The ID of this plugin.7 *8 * @since 1.0.09 * @access private10 * @var string $plugin_name The ID of this plugin.11 */12 private $plugin_name;5 /** 6 * The ID of this plugin. 7 * 8 * @since 1.0.0 9 * @access private 10 * @var string $plugin_name The ID of this plugin. 11 */ 12 private $plugin_name; 13 13 14 /**15 * The version of this plugin.16 *17 * @since 1.0.018 * @access private19 * @var string $version The current version of this plugin.20 */21 private $version;22 /**23 * @var24 */25 private $settings;14 /** 15 * The version of this plugin. 16 * 17 * @since 1.0.0 18 * @access private 19 * @var string $version The current version of this plugin. 20 */ 21 private $version; 22 /** 23 * @var 24 */ 25 private $settings; 26 26 27 public function __construct( $plugin_name, $version, $settings ) {28 $this->plugin_name = $plugin_name;29 $this->version = $version;30 $this->settings = $settings;31 }27 public function __construct( $plugin_name, $version, $settings ) { 28 $this->plugin_name = $plugin_name; 29 $this->version = $version; 30 $this->settings = $settings; 31 } 32 32 33 function render_segment_identify() {34 if ( isset( $_SERVER["HTTP_X_REQUESTED_WITH"] ) ) { //Only render these for actual browsers35 return;36 }33 function render_segment_identify() { 34 if ( isset( $_SERVER["HTTP_X_REQUESTED_WITH"] ) ) { //Only render these for actual browsers 35 return; 36 } 37 37 38 if (Segment_For_Wp_By_In8_Io_Cookie::check_cookie( 'identify' ) || Segment_For_Wp_By_In8_Io_Cookie::check_cookie( 'wp_logout' ) ) {39 $settings = $this->settings;40 if ( isset( $settings['js_api_key'] ) && $settings['js_api_key'] !== '' && $settings['js_api_key'] !== null ) {41 $current_user = wp_get_current_user();42 $current_post = get_post();43 $trackable_user = Segment_For_Wp_By_In8_Io::check_trackable_user( $current_user );44 $trackable_post = Segment_For_Wp_By_In8_Io::check_trackable_post( $current_post );45 if ( $trackable_user && $trackable_post ) {46 if ( Segment_For_Wp_By_In8_Io_Cookie::check_cookie( 'identify' ) ) {47 $cookie_data = Segment_For_Wp_By_In8_Io_Cookie::get_cookie( 'identify' );48 $cookie_name = Segment_For_Wp_By_In8_Io_Cookie::get_cookie_name( 'identify' );49 $user_info = Segment_For_Wp_By_In8_Io::get_user_info_from_cookie( $cookie_data, $cookie_name );50 $wp_user_id = $user_info["wp_user_id"];51 $user_id = $user_info['user_id'];52 if ( ! isset( $wp_user_id ) || ! isset( $user_id ) || $wp_user_id == null || $wp_user_id == 0 ) {53 ?>38 if (Segment_For_Wp_By_In8_Io_Cookie::check_cookie( 'identify' ) || Segment_For_Wp_By_In8_Io_Cookie::check_cookie( 'wp_logout' ) ) { 39 $settings = $this->settings; 40 if ( isset( $settings['js_api_key'] ) && $settings['js_api_key'] !== '' && $settings['js_api_key'] !== null ) { 41 $current_user = wp_get_current_user(); 42 $current_post = get_post(); 43 $trackable_user = Segment_For_Wp_By_In8_Io::check_trackable_user( $current_user ); 44 $trackable_post = Segment_For_Wp_By_In8_Io::check_trackable_post( $current_post ); 45 if ( $trackable_user && $trackable_post ) { 46 if ( Segment_For_Wp_By_In8_Io_Cookie::check_cookie( 'identify' ) ) { 47 $cookie_data = Segment_For_Wp_By_In8_Io_Cookie::get_cookie( 'identify' ); 48 $cookie_name = Segment_For_Wp_By_In8_Io_Cookie::get_cookie_name( 'identify' ); 49 $user_info = Segment_For_Wp_By_In8_Io::get_user_info_from_cookie( $cookie_data, $cookie_name ); 50 $wp_user_id = $user_info["wp_user_id"]; 51 $user_id = $user_info['user_id']; 52 if ( ! isset( $wp_user_id ) || ! isset( $user_id ) || $wp_user_id == null || $wp_user_id == 0 ) { 53 ?> 54 54 <script type="text/javascript"> 55 55 Cookies.remove("<?php echo sanitize_text_field( $cookie_name )?>"); 56 56 </script> 57 <?php58 Segment_For_Wp_By_In8_Io_Cookie::delete_matching_cookies($cookie_name);59 return;60 }57 <?php 58 Segment_For_Wp_By_In8_Io_Cookie::delete_matching_cookies($cookie_name); 59 return; 60 } 61 61 62 $traits = Segment_For_Wp_By_In8_Io::get_user_traits( $wp_user_id );62 $traits = Segment_For_Wp_By_In8_Io::get_user_traits( $wp_user_id ); 63 63 $traits = array_filter($traits); 64 64 $traits = apply_filters('segment_for_wp_change_user_traits', $traits, $user_info); 65 65 $user_id = apply_filters('segment_for_wp_change_user_id', $user_id); 66 66 67 ?>67 ?> 68 68 <script type="text/javascript"> 69 69 console.log(<?php echo sanitize_text_field( json_encode( $traits ) )?>) 70 70 analytics.identify("<?php echo sanitize_text_field( $user_id ) ?>", 71 <?php echo json_encode( $traits ) ?>,71 <?php echo json_encode( $traits ) ?>, 72 72 {}, 73 73 function () { … … 76 76 ); 77 77 </script> 78 <?php79 Segment_For_Wp_By_In8_Io_Cookie::delete_matching_cookies($cookie_name);78 <?php 79 Segment_For_Wp_By_In8_Io_Cookie::delete_matching_cookies($cookie_name); 80 80 81 }81 } 82 82 83 83 else { 84 $wp_user_id = $current_user->ID;85 if ( $wp_user_id && $wp_user_id != 0 ) {86 $user_id = Segment_For_Wp_By_In8_Io::get_user_id( $wp_user_id );87 if ( $user_id && $user_id !== 0 ) {88 $traits = Segment_For_Wp_By_In8_Io::get_user_traits( $wp_user_id );84 $wp_user_id = $current_user->ID; 85 if ( $wp_user_id && $wp_user_id != 0 ) { 86 $user_id = Segment_For_Wp_By_In8_Io::get_user_id( $wp_user_id ); 87 if ( $user_id && $user_id !== 0 ) { 88 $traits = Segment_For_Wp_By_In8_Io::get_user_traits( $wp_user_id ); 89 89 $traits = array_filter($traits); 90 90 $traits = apply_filters('segment_for_wp_change_user_traits', $traits, $current_user); 91 91 $user_id = apply_filters('segment_for_wp_change_user_id', $user_id); 92 ?>92 ?> 93 93 <script type="text/javascript"> 94 94 analytics.identify("<?php echo sanitize_text_field( $user_id ) ?>", 95 <?php echo sanitize_text_field( json_encode( $traits ) )?>,95 <?php echo sanitize_text_field( json_encode( $traits ) )?>, 96 96 ); 97 97 </script> 98 <?php 99 } 100 } 101 } 102 } 103 if (Segment_For_Wp_By_In8_Io_Cookie::check_cookie( 'wp_logout' )) { 104 $cookie_name = Segment_For_Wp_By_In8_Io_Cookie::get_cookie_name( 'wp_logout' ); 105 Segment_For_Wp_By_In8_Io_Cookie::delete_matching_cookies($cookie_name); 106 } 107 } 108 } 98 <?php 99 } 100 } 101 } 102 } 103 if (Segment_For_Wp_By_In8_Io_Cookie::check_cookie( 'wp_logout' )) { 104 $cookie_name = Segment_For_Wp_By_In8_Io_Cookie::get_cookie_name( 'wp_logout' ); 105 Segment_For_Wp_By_In8_Io_Cookie::delete_matching_cookies($cookie_name); 106 } 107 } 108 } 109 else{ 110 if(is_user_logged_in() && !isset($_COOKIE["ajs_user_id"])) { 109 111 110 } 112 if ( isset( $settings['js_api_key'] ) && $settings['js_api_key'] !== '' && $settings['js_api_key'] !== null ) { 113 $current_user = wp_get_current_user(); 114 $current_post = get_post(); 115 $trackable_user = Segment_For_Wp_By_In8_Io::check_trackable_user( $current_user ); 116 $trackable_post = Segment_For_Wp_By_In8_Io::check_trackable_post( $current_post ); 117 if ( $trackable_user && $trackable_post ) { 118 $wp_user_id = get_current_user_id(); 119 $user_id = Segment_For_Wp_By_In8_Io::get_user_id($wp_user_id); 120 $traits = Segment_For_Wp_By_In8_Io::get_user_traits( $wp_user_id ); 121 $traits = array_filter($traits); 122 $traits = apply_filters('segment_for_wp_change_user_traits', $traits, $current_user); 123 $user_id = apply_filters('segment_for_wp_change_user_id', $user_id); 124 125 ?> 126 <script type="text/javascript"> 127 console.log(<?php echo sanitize_text_field( json_encode( $traits ) )?>) 128 analytics.identify("<?php echo sanitize_text_field( $user_id ) ?>", 129 <?php echo json_encode( $traits ) ?>, 130 {}, 131 function () { 132 } 133 ); 134 </script> 135 <?php 136 137 } 138 } 139 140 } 141 142 } 143 144 } 111 145 112 146 } -
segment-for-wp-by-in8-io/trunk/includes/class-segment-for-wp-by-in8-io.php
r2606659 r2606796 284 284 285 285 //LOGINS 286 if (array_key_exists('track_ ninja_forms_fieldset', $settings)) {286 if (array_key_exists('track_logins_fieldset', $settings)) { 287 287 if ($settings["track_logins_fieldset"]["track_logins"] == "yes") { 288 288 $this->loader->add_action('wp_login', $plugin_public, 'wp_login', 1, 2); -
segment-for-wp-by-in8-io/trunk/segment-for-wp-by-in8-io.php
r2606659 r2606796 10 10 * Plugin URI: https://github.com/omgwtfwow/segment-for-wp-by-in8-io 11 11 * Description: Segment Analytics for WordPress 12 * Version: 2.1. 012 * Version: 2.1.1 13 13 * Author: Juan 14 14 * Author URI: https://juangonzalez.com.au … … 27 27 * Currently plugin version. 28 28 */ 29 define( 'SEGMENT_FOR_WP_BY_IN8_IO_VERSION', '2.1. 0' );29 define( 'SEGMENT_FOR_WP_BY_IN8_IO_VERSION', '2.1.1' ); 30 30 31 31 /**
Note: See TracChangeset
for help on using the changeset viewer.