Plugin Directory

Changeset 1738626


Ignore:
Timestamp:
09/29/2017 09:44:38 PM (8 years ago)
Author:
dsmart
Message:

Jetpack 5.4-beta3

https://github.com/Automattic/jetpack/releases/tag/5.4-beta3

Location:
jetpack/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • jetpack/trunk/class.json-api-endpoints.php

    r1736680 r1738626  
    10701070            $last_name   = '';
    10711071            $URL         = $author->comment_author_url;
    1072             $avatar_URL  = $this->api->get_avatar_url( $email );
     1072            $avatar_URL  = $this->api->get_avatar_url( $author );
    10731073            $profile_URL = 'https://en.gravatar.com/' . md5( strtolower( trim( $email ) ) );
    10741074            $nice        = '';
  • jetpack/trunk/css/jetpack-rtl.css

    r1724973 r1738626  
    2323.widgets-multi-column-grid ul{overflow:hidden;padding:0;margin:0;list-style-type:none}.widgets-multi-column-grid ul li{background:100% 0;clear:none;float:right;margin:0 0 -3px -5px;padding:0 0 6px 8px;border:none;list-style-type:none!important}.widgets-multi-column-grid ul li a{background:100% 0;margin:0;padding:0;border:0}.widgets-multi-column-grid .avatar{vertical-align:middle}.widget_jetpack_my_community .avatar-240,.widget_jetpack_my_community .avatar-48{max-width:48px;max-height:48px}
    2424.widget.widget_authors li>ul,.widget_authors>ul{margin-right:inherit;padding-right:0}.widget_authors ul li li{padding-right:0}.widget_authors>ul>li{margin-bottom:1em;list-style:none}.widget_authors>ul>li+li{border-top:0}.widget.widget_authors img{margin-left:5px;margin-bottom:5px;vertical-align:middle;box-shadow:none}
    25 /*!
    26 * Do not modify this file directly.  It is compiled SASS code.
    27 */#wp-admin-bar-jetpack-idc.hide{display:none}#wp-admin-bar-jetpack-idc .jp-idc-admin-bar{background:#fff;border-radius:2px;color:#23282d;padding:4px 8px;font-size:12px}#wpadminbar #wp-admin-bar-jetpack-idc .dashicons{color:#23282d;font-family:dashicons}#wpadminbar #wp-admin-bar-jetpack-idc .dashicons:before{font-size:16px}#wpadminbar #wp-admin-bar-jetpack-idc:hover .ab-item{background:inherit}#wpadminbar #wp-admin-bar-jetpack-idc:hover .jp-idc-admin-bar{background:#eee}
    2825.wpcnt{text-align:center;line-height:2}.wpa{position:relative;overflow:hidden;display:inline-block;max-width:100%}.wpa-about{position:absolute;top:5px;right:0;left:0;display:block;margin-top:0;color:#888;font:10px/1 "Open Sans",Arial,sans-serif!important;text-align:right!important;text-decoration:none!important;opacity:.85;border-bottom:none!important;box-shadow:none!important}.wpa .u>div{display:block;margin-top:5px;margin-bottom:1em}div.wpa>div{margin-top:20px}.wpa .u .adsbygoogle{display:block;margin-top:17px;margin-bottom:1em;background-color:transparent}
    2926.widget_eu_cookie_law_widget.widget{border:none;bottom:1em;display:none;right:1em;margin:0;padding:0;position:fixed;left:1em;width:auto;z-index:50001}#eu-cookie-law{background-color:#fff;border:1px solid #dedede;color:#2e4467;font-size:12px;line-height:1.5;overflow:hidden;padding:6px 15px 6px 6px;position:relative}#eu-cookie-law a,#eu-cookie-law a:active,#eu-cookie-law a:visited{color:inherit;cursor:inherit;text-decoration:underline}#eu-cookie-law a:hover{cursor:pointer;text-decoration:none}#eu-cookie-law.negative{background-color:#000;border:none;color:#fff}#eu-cookie-law input,#eu-cookie-law input:focus,#eu-cookie-law input:hover{background:#f3f3f3;border:1px solid #dedede;border-radius:4px;-moz-border-radius:3px;-webkit-border-radius:3px;color:#2e4453;cursor:pointer;display:inline;float:left;font-family:inherit;font-size:14px;font-weight:inherit;line-height:inherit;margin:0 5% 0 0;padding:8px 12px;position:static;text-transform:none}#eu-cookie-law.negative input,#eu-cookie-law.negative input:focus,#eu-cookie-law.negative input:hover{background:#282828;border-color:#535353;color:#fff}@media (max-width:600px){#eu-cookie-law{padding-bottom:55px}#eu-cookie-law input.accept{bottom:8px;position:absolute;left:8px}}
  • jetpack/trunk/css/jetpack.css

    r1738590 r1738626  
    2323.widgets-multi-column-grid ul{overflow:hidden;padding:0;margin:0;list-style-type:none}.widgets-multi-column-grid ul li{background:0 0;clear:none;float:left;margin:0 -5px -3px 0;padding:0 8px 6px 0;border:none;list-style-type:none!important}.widgets-multi-column-grid ul li a{background:0 0;margin:0;padding:0;border:0}.widgets-multi-column-grid .avatar{vertical-align:middle}.widget_jetpack_my_community .avatar-240,.widget_jetpack_my_community .avatar-48{max-width:48px;max-height:48px}
    2424.widget.widget_authors li>ul,.widget_authors>ul{margin-left:inherit;padding-left:0}.widget_authors ul li li{padding-left:0}.widget_authors>ul>li{margin-bottom:1em;list-style:none}.widget_authors>ul>li+li{border-top:0}.widget.widget_authors img{margin-right:5px;margin-bottom:5px;vertical-align:middle;box-shadow:none}
    25 /*!
    26 * Do not modify this file directly.  It is compiled SASS code.
    27 */#wp-admin-bar-jetpack-idc.hide{display:none}#wp-admin-bar-jetpack-idc .jp-idc-admin-bar{background:#fff;border-radius:2px;color:#23282d;padding:4px 8px;font-size:12px}#wpadminbar #wp-admin-bar-jetpack-idc .dashicons{color:#23282d;font-family:dashicons}#wpadminbar #wp-admin-bar-jetpack-idc .dashicons:before{font-size:16px}#wpadminbar #wp-admin-bar-jetpack-idc:hover .ab-item{background:inherit}#wpadminbar #wp-admin-bar-jetpack-idc:hover .jp-idc-admin-bar{background:#eee}
    2825.wpcnt{text-align:center;line-height:2}.wpa{position:relative;overflow:hidden;display:inline-block;max-width:100%}.wpa-about{position:absolute;top:5px;left:0;right:0;display:block;margin-top:0;color:#888;font:10px/1 "Open Sans",Arial,sans-serif!important;text-align:left!important;text-decoration:none!important;opacity:.85;border-bottom:none!important;box-shadow:none!important}.wpa .u>div{display:block;margin-top:5px;margin-bottom:1em}div.wpa>div{margin-top:20px}.wpa .u .adsbygoogle{display:block;margin-top:17px;margin-bottom:1em;background-color:transparent}
    2926.widget_eu_cookie_law_widget.widget{border:none;bottom:1em;display:none;left:1em;margin:0;padding:0;position:fixed;right:1em;width:auto;z-index:50001}#eu-cookie-law{background-color:#fff;border:1px solid #dedede;color:#2e4467;font-size:12px;line-height:1.5;overflow:hidden;padding:6px 6px 6px 15px;position:relative}#eu-cookie-law a,#eu-cookie-law a:active,#eu-cookie-law a:visited{color:inherit;cursor:inherit;text-decoration:underline}#eu-cookie-law a:hover{cursor:pointer;text-decoration:none}#eu-cookie-law.negative{background-color:#000;border:none;color:#fff}#eu-cookie-law input,#eu-cookie-law input:focus,#eu-cookie-law input:hover{background:#f3f3f3;border:1px solid #dedede;border-radius:4px;-moz-border-radius:3px;-webkit-border-radius:3px;color:#2e4453;cursor:pointer;display:inline;float:right;font-family:inherit;font-size:14px;font-weight:inherit;line-height:inherit;margin:0 0 0 5%;padding:8px 12px;position:static;text-transform:none}#eu-cookie-law.negative input,#eu-cookie-law.negative input:focus,#eu-cookie-law.negative input:hover{background:#282828;border-color:#535353;color:#fff}@media (max-width:600px){#eu-cookie-law{padding-bottom:55px}#eu-cookie-law input.accept{bottom:8px;position:absolute;right:8px}}
  • jetpack/trunk/jetpack.php

    r1738590 r1738626  
    66 * Description: Bring the power of the WordPress.com cloud to your self-hosted WordPress. Jetpack enables you to connect your blog to a WordPress.com account to use the powerful features normally only available to WordPress.com users.
    77 * Author: Automattic
    8  * Version: 5.4-beta2
     8 * Version: 5.4-beta3
    99 * Author URI: https://jetpack.com
    1010 * License: GPL2+
     
    1515define( 'JETPACK__MINIMUM_WP_VERSION', '4.7' );
    1616
    17 define( 'JETPACK__VERSION',            '5.4-beta2' );
     17define( 'JETPACK__VERSION',            '5.4-beta3' );
    1818define( 'JETPACK_MASTER_USER',         true );
    1919define( 'JETPACK__API_VERSION',        1 );
  • jetpack/trunk/modules/google-analytics/wp-google-analytics.php

    r1590103 r1738626  
    3636     */
    3737    private function __construct() {
     38        add_filter( 'jetpack_wga_classic_custom_vars', array( $this, 'jetpack_wga_classic_anonymize_ip' ) );
     39        add_filter( 'jetpack_wga_classic_custom_vars', array( $this, 'jetpack_wga_classic_track_purchases' ) );
    3840        add_action( 'wp_footer', array( $this, 'insert_code' ) );
     41        add_action( 'wp_footer', array( $this, 'jetpack_wga_classic_track_add_to_cart' ) );
    3942    }
    4043
     
    116119        if ( is_404() ) {
    117120            // This is a 404 and we are supposed to track them.
    118             $custom_vars[] = "_gaq.push( [ '_trackEvent', '404', document.location.href, document.referrer ] );";
     121            $custom_vars[] = "_gaq.push(['_trackEvent', '404', document.location.href, document.referrer]);";
    119122        } elseif ( is_search() ) {
    120123            // Set track for searches, if it's a search, and we are supposed to.
     
    132135        }
    133136
     137        /**
     138         * Allow for additional elements to be added to the classic Google Analytics queue (_gaq) array
     139         *
     140         * @since 5.4.0
     141         *
     142         * @param array $custom_vars Array of classic Google Analytics queue elements
     143         */
     144        $custom_vars = apply_filters( 'jetpack_wga_classic_custom_vars', $custom_vars );
     145
     146        // Ref: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce#Example
    134147        $async_code = "<!-- Jetpack Google Analytics -->
    135         <script type='text/javascript'>
    136                             var _gaq = _gaq || [];
    137                             %custom_vars%
    138 
    139                             (function() {
    140                                 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    141                                 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    142                                 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    143                             })();
    144                         </script>";
     148            <script type='text/javascript'>
     149                var _gaq = _gaq || [];
     150                %custom_vars%
     151
     152                (function() {
     153                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     154                    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
     155                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     156                })();
     157            </script>";
    145158
    146159        $custom_vars_string = implode( "\r\n", $custom_vars );
     
    164177        return '';
    165178    }
     179
     180    /**
     181     * Used to filter in the anonymize IP snippet to the custom vars array for classic analytics
     182     * Ref https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gat#_gat._anonymizelp
     183     * @param array custom vars to be filtered
     184     * @return array possibly updated custom vars
     185     */
     186    public function jetpack_wga_classic_anonymize_ip( $custom_vars ) {
     187        $o = get_option( 'jetpack_wga' );
     188        $anonymize_ip = isset( $o[ 'anonymize_ip' ] ) ? $o[ 'anonymize_ip' ] : false;
     189        if ( $anonymize_ip ) {
     190            array_push( $custom_vars, "_gaq.push(['_gat._anonymizeIp']);" );
     191        }
     192
     193        return $custom_vars;
     194    }
     195
     196    /**
     197     * Used to filter in the order details to the custom vars array for classic analytics
     198     * @param array custom vars to be filtered
     199     * @return array possibly updated custom vars
     200     */
     201    public function jetpack_wga_classic_track_purchases( $custom_vars ) {
     202        global $wp;
     203
     204        // Ref: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce#Example
     205        $o = get_option( 'jetpack_wga' );
     206        $ec_track_purchases = isset( $o[ 'ec_track_purchases' ] ) ? $o[ 'ec_track_purchases' ] : false;
     207        $minimum_woocommerce_active = class_exists( 'WooCommerce' ) && version_compare( WC_VERSION, '3.0', '>=' );
     208        if ( $ec_track_purchases && $minimum_woocommerce_active && is_order_received_page() ) {
     209            $order_id = isset( $wp->query_vars['order-received'] ) ? $wp->query_vars['order-received'] : 0;
     210            if ( 0 < $order_id && 1 != get_post_meta( $order_id, '_ga_tracked', true ) ) {
     211                $order = new WC_Order( $order_id );
     212
     213                // [ '_add_Trans', '123', 'Site Title', '21.00', '1.00', '5.00', 'Snohomish', 'WA', 'USA' ]
     214                array_push(
     215                    $custom_vars,
     216                    sprintf(
     217                        '_gaq.push( %s );', json_encode(
     218                            array(
     219                                '_addTrans',
     220                                (string) $order->get_order_number(),
     221                                get_bloginfo( 'name' ),
     222                                (string) $order->get_total(),
     223                                (string) $order->get_total_tax(),
     224                                (string) $order->get_total_shipping(),
     225                                (string) $order->get_billing_city(),
     226                                (string) $order->get_billing_state(),
     227                                (string) $order->get_billing_country()
     228                            )
     229                        )
     230                    )
     231                );
     232
     233                // Order items
     234                if ( $order->get_items() ) {
     235                    foreach ( $order->get_items() as $item ) {
     236                        $product = $order->get_product_from_item( $item );
     237                        $product_sku_or_id = $product->get_sku() ? $product->get_sku() : $product->get_id();
     238
     239                        array_push(
     240                            $custom_vars,
     241                            sprintf(
     242                                '_gaq.push( %s );', json_encode(
     243                                    array(
     244                                        '_addItem',
     245                                        (string) $order->get_order_number(),
     246                                        (string) $product_sku_or_id,
     247                                        $item['name'],
     248                                        self::get_product_categories_concatenated( $product ),
     249                                        (string) $order->get_item_total( $item ),
     250                                        (string) $item['qty']
     251                                    )
     252                                )
     253                            )
     254                        );
     255                    }
     256                } // get_items
     257
     258                // Mark the order as tracked
     259                update_post_meta( $order_id, '_ga_tracked', 1 );
     260                array_push( $custom_vars, "_gaq.push(['_trackTrans']);" );
     261            } // order not yet tracked
     262        } // is order received page
     263
     264        return $custom_vars;
     265    }
     266
     267    /**
     268     * Gets product categories or varation attributes as a formatted concatenated string
     269     * @param WC_Product
     270     * @return string
     271     */
     272    public function get_product_categories_concatenated( $product ) {
     273        $variation_data = $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : '';
     274        if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
     275            $line = wc_get_formatted_variation( $variation_data, true );
     276        } else {
     277            $out = array();
     278            $categories = get_the_terms( $product->get_id(), 'product_cat' );
     279            if ( $categories ) {
     280                foreach ( $categories as $category ) {
     281                    $out[] = $category->name;
     282                }
     283            }
     284            $line = join( "/", $out );
     285        }
     286        return $line;
     287    }
     288
     289    /**
     290     * Used to add footer javascript to track user clicking on add-to-cart buttons
     291     * on single views (.single_add_to_cart_button) and list views (.add_to_cart_button)
     292     */
     293    public function jetpack_wga_classic_track_add_to_cart() {
     294        $tracking_id = $this->_get_tracking_code();
     295        if ( empty( $tracking_id ) ) {
     296            return;
     297        }
     298
     299        $o = get_option( 'jetpack_wga' );
     300        $ec_track_add_to_cart = isset( $o[ 'ec_track_add_to_cart' ] ) ? $o[ 'ec_track_add_to_cart' ] : false;
     301        if ( $ec_track_add_to_cart ) {
     302            if ( is_product() ) { // product page
     303                global $product;
     304                $product_sku_or_id = $product->get_sku() ? $product->get_sku() : "#" + $product->get_id();
     305                wc_enqueue_js(
     306                    "jQuery( function( $ ) {
     307                        $( '.single_add_to_cart_button' ).click( function() {
     308                            _gaq.push(['_trackEvent', 'Products', 'Add to Cart', '#" . esc_js( $product_sku_or_id ) . "']);
     309                        } );
     310                    } );"
     311                );
     312            } else if ( is_woocommerce() ) { // any other page that uses templates (like product lists, archives, etc)
     313                wc_enqueue_js(
     314                    "jQuery( function( $ ) {
     315                        $( '.add_to_cart_button:not(.product_type_variable, .product_type_grouped)' ).click( function() {
     316                            var label = $( this ).data( 'product_sku' ) ? $( this ).data( 'product_sku' ) : '#' + $( this ).data( 'product_id' );
     317                            _gaq.push(['_trackEvent', 'Products', 'Add to Cart', label]);
     318                        } );
     319                    } );"
     320                );
     321            }
     322        }
     323    }
    166324}
    167325
  • jetpack/trunk/readme.txt

    r1736680 r1738626  
    115115**Enhancements**
    116116* Add Schema.org markup to the Contact Info Widget.
    117 * Add a new "Date" field to the Contact Form.
     117* Add a new "Date" field to the Contact Form.
     118* Added support in the Google Analytics feature for IP anonymization and basic WooCommerce tracking.
    118119* Do not show any update notices when in [development mode](http://jetpack.com/support/development-mode).
    119120* Improve our documentation to help contributors set up a unit testing environment.
Note: See TracChangeset for help on using the changeset viewer.