Changeset 980785
- Timestamp:
- 09/04/2014 11:52:03 PM (12 years ago)
- Location:
- segmentio/trunk
- Files:
-
- 8 added
- 6 edited
-
.travis.yml (added)
-
Readme.md (modified) (1 diff)
-
analytics-wordpress.php (modified) (9 diffs)
-
bin/install-wp-tests.sh (added)
-
includes/class.segment-cookie.php (modified) (2 diffs)
-
includes/class.segment-settings.php (modified) (1 diff, 1 prop)
-
integrations/ecommerce/woocommerce.php (modified) (2 diffs)
-
phpunit.xml (added)
-
readme.txt (modified) (2 diffs)
-
tests (added)
-
tests/bootstrap.php (added)
-
tests/test-segment-analytics-wordpress.php (added)
-
tests/test-segment-analytics.php (added)
-
tests/test-segment-settings.php (added)
Legend:
- Unmodified
- Added
- Removed
-
segmentio/trunk/Readme.md
r949997 r980785 18 18 ``` 19 19 20 ## Contributing 21 22 We'd love to have you contribute to the Segment WordPress plugin. We'll gladly review any pull request, but pull requests that have followed recommended practices are more likely to be merged: 23 24 1. Our recommended development environment for contributing to the Segment WordPress plugin is called [VVV](https://github.com/Varying-Vagrant-Vagrants/VVV). It's a community-developed Vagrant environment for WordPress. If you do any WordPress development at all, you won't find a better development environment. We highly recommend using it. 25 1. After you've installed VVV, `vagrant up`, change directories to whichever WordPress install you're developing against, and `git clone https://github.com/your-user-account/analytics-wordpress.git` into the plugins directory. This assumes you've already forked the Segment WordPress plugin. If you haven't, be sure to do so. 26 1. Boom, you're ready to go! Go to the WordPress instance you're using (consult the [VVV documentation](https://github.com/Varying-Vagrant-Vagrants/VVV/blob/master/README.md#wordpress-stable) if you're not sure which to use) and activate the Segment plugin. 27 1. Now you're ready to make your changes. Fixing a bug? Awesome! Write unit tests. Adding a feature? Sweet! Write unit tests. Check out our [current tests in the tests folder](https://github.com/segmentio/analytics-wordpress/tree/master/tests) for reference. 28 1. Once your changes are made and tests are written, confirm that all tests and assertions are passing by running `phpunit` from the command line in the plugin directory. 29 1. Commit, send your pull request, and pat yourself on the back for contributing to open source software! 20 30 21 31 ## Support -
segmentio/trunk/analytics-wordpress.php
r950002 r980785 4 4 Plugin URI: https://segment.io/plugins/wordpress 5 5 Description: The hassle-free way to integrate any analytics service into your WordPress site. 6 Version: 1.0. 36 Version: 1.0.4 7 7 License: GPLv2 8 8 Author: Segment.io … … 135 135 136 136 /** 137 * Render a Javascript ` track` call137 * Render a Javascript `page` call 138 138 * 139 139 * @since 1.0.0 … … 179 179 * Current plugin version. 180 180 */ 181 const VERSION = '1.0. 3';181 const VERSION = '1.0.4'; 182 182 183 183 /** … … 242 242 'track_comments' => 1, 243 243 244 // Whether or not we should use Intercom's Secure Mode 245 'use_intercom_secure_mode' => '', 246 247 // Whether or not we should track custom events for searches 248 'track_searches' => 1, 249 244 250 // Whether or not we should track custom events for users logging in 245 251 'track_logins' => 1, … … 293 299 */ 294 300 public function admin_hooks() { 295 296 if ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 297 298 add_action( 'admin_menu' , array( $this, 'admin_menu' ) ); 299 add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 ); 300 add_filter( 'plugin_row_meta' , array( $this, 'plugin_row_meta' ) , 10, 2 ); 301 add_action( 'admin_init' , array( $this, 'register_settings' ) ); 302 } 303 301 add_action( 'admin_menu' , array( self::$instance, 'admin_menu' ) ); 302 add_filter( 'plugin_action_links', array( self::$instance, 'plugin_action_links' ), 10, 2 ); 303 add_filter( 'plugin_row_meta' , array( self::$instance, 'plugin_row_meta' ) , 10, 2 ); 304 add_action( 'admin_init' , array( self::$instance, 'register_settings' ) ); 304 305 } 305 306 … … 332 333 public function frontend_hooks() { 333 334 334 add_action( 'wp_head' , array( $this, 'wp_head' ) , 9 ); 335 add_action( 'admin_head' , array( $this, 'wp_head' ) , 9 ); 336 add_action( 'login_head' , array( $this, 'wp_head' ) , 9 ); 337 add_action( 'wp_footer' , array( $this, 'wp_footer' ) , 9 ); 338 add_action( 'login_footer' , array( $this, 'wp_footer' ) , 9 ); 339 add_action( 'admin_footer' , array( $this, 'wp_footer' ) , 9 ); 340 add_action( 'wp_insert_comment', array( $this, 'insert_comment' ), 9, 2 ); 341 add_action( 'wp_login' , array( $this, 'login_event' ), 9, 2 ); 342 add_action( 'user_register' , array( $this, 'user_register' ), 9 ); 343 } 344 345 /** 346 * Registers our settings, fields and sections using the WordPress Settings API. 347 * 348 * Developers should use the `segment_default_settings` filter to add settings. 349 * They should also use the `segm.ent_settings_core_validation` filter to validate 350 * any settings they add. 351 * 352 * @since 1.0.0 353 * @return void 354 */ 355 public function register_settings() { 356 357 $settings = apply_filters( 'segment_default_settings', array( 335 add_action( 'wp_head' , array( self::$instance, 'wp_head' ) , 9 ); 336 add_action( 'admin_head' , array( self::$instance, 'wp_head' ) , 9 ); 337 add_action( 'login_head' , array( self::$instance, 'wp_head' ) , 9 ); 338 add_action( 'wp_footer' , array( self::$instance, 'wp_footer' ) , 9 ); 339 add_action( 'login_footer' , array( self::$instance, 'wp_footer' ) , 9 ); 340 add_action( 'admin_footer' , array( self::$instance, 'wp_footer' ) , 9 ); 341 add_action( 'wp_insert_comment', array( self::$instance, 'insert_comment' ), 9, 2 ); 342 add_action( 'wp_login' , array( self::$instance, 'login_event' ), 9, 2 ); 343 add_action( 'user_register' , array( self::$instance, 'user_register' ), 9 ); 344 } 345 346 /** 347 * Returns array of settings. 348 * 349 * @since 1.0.4 350 */ 351 public function _get_default_settings() { 352 return apply_filters( 'segment_default_settings', array( 358 353 'general' => array( 359 354 'title' => __( 'General', 'segment' ), … … 431 426 ) 432 427 ); 428 } 429 430 /** 431 * Registers our settings, fields and sections using the WordPress Settings API. 432 * 433 * Developers should use the `segment_default_settings` filter to add settings. 434 * They should also use the `segment_settings_core_validation` filter to validate 435 * any settings they add. 436 * 437 * @since 1.0.0 438 * @return void 439 */ 440 public function register_settings() { 441 442 $settings = $this->_get_default_settings(); 433 443 434 444 register_setting( self::SLUG, $this->get_option_name(), array( 'Segment_Settings', 'core_validation' ) ); 435 445 436 446 foreach ( $settings as $section_name => $section ) { 447 437 448 add_settings_section( 438 449 $section_name, … … 714 725 * An array of the user ID and traits if there is an authenticated user. 715 726 */ 716 p rivatefunction get_current_user_identify() {727 public function get_current_user_identify() { 717 728 $settings = $this->get_settings(); 718 729 719 730 $user = wp_get_current_user(); 720 $commenter = wp_get_current_commenter();731 $commenter = array_filter( wp_get_current_commenter() ); 721 732 $identify = false; 722 733 … … 880 891 if ( $settings['track_comments'] ) { 881 892 882 $commenter = wp_get_current_commenter(); 883 $hash = md5( json_encode( $commenter ) ); 884 885 if ( Segment_Cookie::get_cookie( 'left_comment', $hash ) ) { 886 887 $track = array( 888 'event' => __( 'Commented', 'segment' ), 889 'properties' => array( 890 'commenter' => $commenter 891 ), 892 'http_event' => 'left_comment' 893 ); 893 $commenter = array_filter( wp_get_current_commenter() ); 894 895 if ( $commenter ) { 896 $hash = md5( json_encode( $commenter ) ); 897 898 if ( Segment_Cookie::get_cookie( 'left_comment', $hash ) ) { 899 900 $track = array( 901 'event' => __( 'Commented', 'segment' ), 902 'properties' => array( 903 'commenter' => $commenter 904 ), 905 'http_event' => 'left_comment' 906 ); 907 } 894 908 } 895 909 -
segmentio/trunk/includes/class.segment-cookie.php
r948394 r980785 24 24 */ 25 25 public static function set_cookie( $key, $value ) { 26 setcookie( 'segment_' . $key . '_' . COOKIEHASH, $value, time() + DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );26 @ setcookie( 'segment_' . $key . '_' . COOKIEHASH, $value, time() + DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); 27 27 $_COOKIE[ 'segment_' . $key . '_' . COOKIEHASH ] = $value; 28 28 } … … 64 64 } 65 65 66 setcookie( 'segment_' . $key . '_' . COOKIEHASH, '', time() - DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );66 @ setcookie( 'segment_' . $key . '_' . COOKIEHASH, '', time() - DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); 67 67 unset( $_COOKIE[ 'segment_' . $key . '_' . COOKIEHASH ] ); 68 68 -
segmentio/trunk/includes/class.segment-settings.php
-
Property
svn:executable
set to
*
r948394 r980785 216 216 $input[ $int ] = isset( $input[ $int ] ) ? absint( $input[ $int ] ) : ''; 217 217 218 219 220 218 return apply_filters( 'segment_settings_core_validation', $input ); 221 219 } -
Property
svn:executable
set to
-
segmentio/trunk/integrations/ecommerce/woocommerce.php
r949997 r980785 147 147 } 148 148 149 $items = WC()->cart->get_cart();150 149 $_product = json_decode( $cookie ); 151 150 … … 229 228 return $track; 230 229 } 231 232 $items = WC()->cart->get_cart();233 230 234 231 $_product = json_decode( $cookie ); -
segmentio/trunk/readme.txt
r950002 r980785 1 === Analytics for WordPress — by Segment .io===2 Contributors: segmentio 1 === Analytics for WordPress — by Segment === 2 Contributors: segmentio, JustinSainton 3 3 Tags: analytics, web analytics, segment.io, google analytics, kissmetrics, mixpanel, chartbeat, hubspot, marketo, quantcast, tag manager 4 4 Requires at least: 3.6 5 Tested up to: 3.9.26 Stable tag: 1.0. 35 Tested up to: 4.0 6 Stable tag: 1.0.4 7 7 License: GPLv2 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 9 10 Analytics for WordPress is the easiest way to integrate analytics into your WordPress site.10 Analytics for WordPress lets you integrate more than 100 analytics and marketing tools with the flick of a switch. 11 11 12 12 13 13 == Description == 14 14 15 Analytics for WordPress is the easiest way to integrate analytics into your WordPress site.15 Analytics for WordPress is the easiest way to integrate analytics and marketing tools into your WordPress site. 16 16 17 By installing Segment.io's WordPress plugin you can add any analytics service to your site without touching any code. 17 Instead of installing each tool individually, just install Segment's WordPress plugin and use Segment to integrate third-party analytics and marketing tools. Once you're setup, you can swap and add new analytics services with the flick of a switch! 18 18 19 Segment.io lets you send your analytics data to Google Analytics, Mixpanel, KISSmetrics, Chartbeat, and more... without having to integrate with each and every one, saving you time. 19 Here's how it works: 20 * Install the Segment plugin 21 * Segment will automatically start tracking how people are using your site – what pages they view and the information they provide to you, like their emails 22 * Go to the Segment control panel, and toggle on any tool you want to try like Google Analytics, KISSmetrics and Facebook Audiences 23 * Segment will send this data along to each tool 24 * The service is fully integrated into your site–zero code required! 20 25 21 Once you're setup, you can swap and add new analytics services with the click of a button! 26 You can use Segment to try out more than a hundred vendors in a number of categories. Here are just a few of our most popular integrations: 27 * **Advertising** – AdRoll, Google Adwords, Facebook Audiences, Twitter Ads, Quantcast, AppNexus 28 * **Analytics** – Google Analytics, KISSmetrics, Mixpanel, Amplitude, Chartbeat, Go Squared 29 * **CRM** – Salesforce, Zendesk, Gainsight, Frontleaf 30 * **Email** – Customer.io, Outbound, Vero, Marketo, MailChimp, Hubspot 31 * **Optimization** – Optimizely, CrazyEgg, Visual Website Optimizer 22 32 33 Get started with Analytics for WordPress today! 23 34 24 35 == Installation == 25 36 26 37 1. Go to the **Plugins > Add New** page in your WordPress admin. 27 1. Search for "Segment .io" and install **Analytics for WordPress — by Segment.io**.38 1. Search for "Segment" and install **Analytics for WordPress — by Segment.io**. 28 39 1. Click **Activate Plugin**. 29 1. Go to **Settings > Analytics** and enter your Segment .io API key. (If you haven't signed up for Segment.ioyet, now's the time!)40 1. Go to **Settings > Analytics** and enter your Segment API key. (If you haven't signed up for Segment yet, now's the time!) 30 41 31 That's it! You can now turn on any analytics service with the click of a button in the Segment.io interface.42 That's it! You can now turn on any analytics service with the flick of a switch in the Segment control panel. 32 43 33 44 … … 64 75 65 76 == Changelog == 77 78 = 1.0.4 = 79 * Fixed identify() method to only be called for logged-in users and commenters. 80 81 = 1.0.3 = 82 * Fixed deployment logic 66 83 67 84 = 1.0.2 =
Note: See TracChangeset
for help on using the changeset viewer.