summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/_inc')
-rw-r--r--plugins/jetpack/_inc/facebook-embed.js57
-rw-r--r--plugins/jetpack/_inc/footer.php6
-rw-r--r--plugins/jetpack/_inc/header.php2
-rw-r--r--plugins/jetpack/_inc/jetpack-jitm.js14
-rw-r--r--plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php2
-rw-r--r--plugins/jetpack/_inc/lib/class.color.php17
-rw-r--r--plugins/jetpack/_inc/lib/markdown/extra.php4
-rw-r--r--plugins/jetpack/_inc/lib/markdown/gfm.php16
-rw-r--r--plugins/jetpack/_inc/lib/tracks/tracks-ajax.js49
-rw-r--r--plugins/jetpack/_inc/twitter-timeline.js39
10 files changed, 189 insertions, 17 deletions
diff --git a/plugins/jetpack/_inc/facebook-embed.js b/plugins/jetpack/_inc/facebook-embed.js
new file mode 100644
index 00000000..d4284acf
--- /dev/null
+++ b/plugins/jetpack/_inc/facebook-embed.js
@@ -0,0 +1,57 @@
+/* global FB, jpfbembed */
+(function( window ) {
+ var facebookEmbed = function() {
+ var fbroot, src;
+
+ if ( 'undefined' !== typeof FB && FB.XFBML ) {
+ FB.XFBML.parse();
+ } else {
+ fbroot = document.createElement( 'div' );
+ fbroot.id = 'fb-root';
+ document.getElementsByTagName( 'body' )[0].appendChild( fbroot );
+
+ src = '//connect.facebook.net/' + jpfbembed.locale + '/sdk.js#xfbml=1';
+ if ( jpfbembed.appid ) {
+ src += '&appId=' + jpfbembed.appid;
+ }
+ src += '&version=v2.3';
+ jQuery.getScript( src );
+ }
+ };
+
+ window.fbAsyncInit = function() {
+ FB.init( {
+ appId : jpfbembed.appid,
+ version: 'v2.3'
+ } );
+
+ FB.XFBML.parse();
+ };
+
+ if ( 'undefined' !== typeof infiniteScroll ) {
+ jQuery( document.body ).on( 'post-load', facebookEmbed );
+ }
+
+ // Re-render Facebook XFBML when partials are re-rendered in the Customizer.
+ jQuery( function() {
+ var hasSelectiveRefresh = (
+ 'undefined' !== typeof wp &&
+ wp.customize &&
+ wp.customize.selectiveRefresh &&
+ wp.customize.widgetsPreview &&
+ wp.customize.widgetsPreview.WidgetPartial
+ );
+ if ( ! hasSelectiveRefresh ) {
+ return;
+ }
+
+ // Render Facebook widget in rendered partial.
+ wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) {
+ if ( placement.container ) {
+ FB.XFBML.parse( placement.container[0] );
+ }
+ } );
+ } );
+
+ facebookEmbed();
+})( this );
diff --git a/plugins/jetpack/_inc/footer.php b/plugins/jetpack/_inc/footer.php
index e04d187f..033be34d 100644
--- a/plugins/jetpack/_inc/footer.php
+++ b/plugins/jetpack/_inc/footer.php
@@ -13,12 +13,12 @@
<nav class="secondary nav-horizontal">
<div class="secondary-footer">
- <a href="http://jetpack.me">Jetpack <?php echo JETPACK__VERSION; ?></a>
+ <a href="http://jetpack.com">Jetpack <?php echo JETPACK__VERSION; ?></a>
<a href="http://wordpress.com/tos/"><?php esc_html_e( 'Terms', 'jetpack' ); ?></a>
<a href="http://automattic.com/privacy/"><?php esc_html_e( 'Privacy', 'jetpack' ); ?></a>
<?php if ( current_user_can( 'jetpack_manage_modules' ) ) : ?><a href="<?php echo esc_url( Jetpack::admin_url( 'page=jetpack-debugger' ) ); ?>" title="<?php esc_attr_e( 'Test your site&#8217;s compatibility with Jetpack.', 'jetpack' ); ?>"><?php _e( 'Debug', 'jetpack' ); ?><?php endif; ?></a>
- <a href="http://jetpack.me/contact-support/" title="<?php esc_attr_e( 'Contact the Jetpack Happiness Squad.', 'jetpack' ); ?>"><?php _e( 'Support', 'jetpack' ); ?></a>
- <a href="http://jetpack.me/survey/?rel=<?php echo JETPACK__VERSION; ?>" title="<?php esc_attr_e( 'Take a survey. Tell us how we&#8217;re doing.', 'jetpack' ); ?>"><?php _e( 'Give Us Feedback', 'jetpack' ); ?></a>
+ <a href="http://jetpack.com/contact-support/" title="<?php esc_attr_e( 'Contact the Jetpack Happiness Squad.', 'jetpack' ); ?>"><?php _e( 'Support', 'jetpack' ); ?></a>
+ <a href="http://jetpack.com/survey/?rel=<?php echo JETPACK__VERSION; ?>" title="<?php esc_attr_e( 'Take a survey. Tell us how we&#8217;re doing.', 'jetpack' ); ?>"><?php _e( 'Give Us Feedback', 'jetpack' ); ?></a>
<?php if ( Jetpack::is_active() && current_user_can( 'jetpack_disconnect' ) ) : ?>
<a href="<?php echo esc_url( Jetpack::admin_url( 'page=my_jetpack#disconnect' ) ); ?>"><?php esc_html_e( 'Disconnect Jetpack', 'jetpack' ); ?></a>
<?php endif; ?>
diff --git a/plugins/jetpack/_inc/header.php b/plugins/jetpack/_inc/header.php
index a15e3313..f83d5184 100644
--- a/plugins/jetpack/_inc/header.php
+++ b/plugins/jetpack/_inc/header.php
@@ -11,7 +11,7 @@
<a href="<?php echo Jetpack::admin_url( 'page=jetpack_modules' ); ?>" class="jp-button--settings <?php if ( 'jetpack_modules' == $current ) { echo 'current'; } ?>"><?php esc_html_e( 'Settings', 'jetpack' ); ?></a>
</li>
<li class="jetpack-modules">
- <a href="http://jetpack.me/survey/?rel=<?php echo JETPACK__VERSION; ?>" class="jp-button--settings"><?php esc_html_e( 'Feedback', 'jetpack' ); ?></a>
+ <a href="http://jetpack.com/survey/?rel=<?php echo JETPACK__VERSION; ?>" class="jp-button--settings"><?php esc_html_e( 'Feedback', 'jetpack' ); ?></a>
</li>
<?php endif; // End if connected or dev mode and is admin ?>
diff --git a/plugins/jetpack/_inc/jetpack-jitm.js b/plugins/jetpack/_inc/jetpack-jitm.js
index 79b2f24a..321238bf 100644
--- a/plugins/jetpack/_inc/jetpack-jitm.js
+++ b/plugins/jetpack/_inc/jetpack-jitm.js
@@ -90,9 +90,15 @@
});
$body.on( 'click', '.jp-jitm .launch', function() {
+ var $jitm = $(this).closest( '.jp-jitm' );
+
+ if ( $jitm.data( 'stats_url' ) ) {
+ data.jitm_stats_url = $jitm.data( 'stats_url' );
+ new Image().src = data.jitm_stats_url;
+ }
+
+ data.jitmModule = $jitm.data( 'track' ) ? $jitm.data( 'track' ) : $(this).data( 'module' );
data.jitmActionToTake = 'launch';
- module_slug = $(this).data( 'module' );
- data.jitmModule = module_slug;
// ajax request to save click in stat
$.post( jitmL10n.ajaxurl, data );
} );
@@ -110,7 +116,7 @@
var jitmTemplate = wp.template( 'jitm-photon' ),
$menu = wp.media.frame.$el.find( '.media-menu' ),
$jitm;
- if ( $menu.length > 0 ) {
+ if ( $menu.length > 0 && 0 === $menu.find( '.jp-jitm' ).length ) {
$jitm = $menu.append( jitmTemplate() ).find( '.jp-jitm' );
// JITM is visible to user, track it.
@@ -126,4 +132,4 @@
}
}
-})(jQuery, jitmL10n); \ No newline at end of file
+})(jQuery, jitmL10n);
diff --git a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php
index ec00730b..3f26ba86 100644
--- a/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php
+++ b/plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php
@@ -283,7 +283,7 @@ class Jetpack_Landing_Page extends Jetpack_Admin_Page {
'ays_dismiss' => __( "This will deactivate Jetpack.\nAre you sure you want to deactivate Jetpack?", 'jetpack' ),
'view_all_features' => __( 'View all Jetpack features', 'jetpack' ),
'no_modules_found' => sprintf( __( 'Sorry, no modules were found for the search term "%s"', 'jetpack' ), '{term}' ),
- 'modules' => array_values( Jetpack_Admin::init()->get_modules() ),
+ 'modules' => Jetpack::get_translated_modules( array_values( Jetpack_Admin::init()->get_modules() ) ),
'currentVersion' => JETPACK__VERSION,
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'jumpstart_modules' => $this->jumpstart_module_tag( 'Jumpstart' ),
diff --git a/plugins/jetpack/_inc/lib/class.color.php b/plugins/jetpack/_inc/lib/class.color.php
index 25f0e67d..a57f2009 100644
--- a/plugins/jetpack/_inc/lib/class.color.php
+++ b/plugins/jetpack/_inc/lib/class.color.php
@@ -419,7 +419,7 @@ class Jetpack_Color {
}
$rgb = $rgb_new;
- //Observer. = 2°, Illuminant = D65
+ // Observer. = 2°, Illuminant = D65
$xyz = array(
'x' => ($rgb['red'] * 0.4124) + ($rgb['green'] * 0.3576) + ($rgb['blue'] * 0.1805),
'y' => ($rgb['red'] * 0.2126) + ($rgb['green'] * 0.7152) + ($rgb['blue'] * 0.0722),
@@ -536,8 +536,12 @@ class Jetpack_Color {
}
public function toLuminosity() {
- extract( $this->toRgbInt() );
- return 0.2126 * pow( $red / 255, 2.2 ) + 0.7152 * pow( $green / 255, 2.2 ) + 0.0722 * pow( $blue / 255, 2.2);
+ $lum = array();
+ foreach( $this->toRgbInt() as $slot => $value ) {
+ $chan = $value / 255;
+ $lum[ $slot ] = ( $chan <= 0.03928 ) ? $chan / 12.92 : pow( ( ( $chan + 0.055 ) / 1.055 ), 2.4 );
+ }
+ return 0.2126 * $lum['red'] + 0.7152 * $lum['green'] + 0.0722 * $lum['blue'];
}
/**
@@ -547,7 +551,7 @@ class Jetpack_Color {
* @param Jetpack_Color $color Another color
* @return float
*/
- public function getDistanceLuminosityFrom(Jetpack_Color $color) {
+ public function getDistanceLuminosityFrom( Jetpack_Color $color ) {
$L1 = $this->toLuminosity();
$L2 = $color->toLuminosity();
if ( $L1 > $L2 ) {
@@ -559,9 +563,10 @@ class Jetpack_Color {
}
public function getMaxContrastColor() {
- $lum = $this->toLuminosity();
+ $withBlack = $this->getDistanceLuminosityFrom( new Jetpack_Color( '#000') );
+ $withWhite = $this->getDistanceLuminosityFrom( new Jetpack_Color( '#fff') );
$color = new Jetpack_Color;
- $hex = ( $lum >= 0.5 ) ? '000000' : 'ffffff';
+ $hex = ( $withBlack >= $withWhite ) ? '#000000' : '#ffffff';
return $color->fromHex( $hex );
}
diff --git a/plugins/jetpack/_inc/lib/markdown/extra.php b/plugins/jetpack/_inc/lib/markdown/extra.php
index 4f52171f..3ca8cdc8 100644
--- a/plugins/jetpack/_inc/lib/markdown/extra.php
+++ b/plugins/jetpack/_inc/lib/markdown/extra.php
@@ -2949,7 +2949,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
$text .= "<hr". $this->empty_element_suffix ."\n";
$text .= "<ol>\n\n";
- $attr = " rev=\"footnote\"";
+ $attr = "";
if ($this->fn_backlink_class != "") {
$class = $this->fn_backlink_class;
$class = $this->encodeAttribute($class);
@@ -3018,7 +3018,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
$ref_count_mark = $this->footnotes_ref_count[$node_id] += 1;
}
- $attr = " rel=\"footnote\"";
+ $attr = "";
if ($this->fn_link_class != "") {
$class = $this->fn_link_class;
$class = $this->encodeAttribute($class);
diff --git a/plugins/jetpack/_inc/lib/markdown/gfm.php b/plugins/jetpack/_inc/lib/markdown/gfm.php
index 6cd208af..bdcd1c48 100644
--- a/plugins/jetpack/_inc/lib/markdown/gfm.php
+++ b/plugins/jetpack/_inc/lib/markdown/gfm.php
@@ -93,6 +93,22 @@ class WPCom_GHF_Markdown_Parser extends MarkdownExtra_Parser {
// escape line-beginning # chars that do not have a space after them.
$text = preg_replace_callback( '|^#{1,6}( )?|um', array( $this, '_doEscapeForHashWithoutSpacing' ), $text );
+ /**
+ * Allow third-party plugins to define custom patterns that won't be processed by Markdown.
+ *
+ * @module markdown
+ *
+ * @since 3.9.2
+ *
+ * @param array $custom_patterns Array of custom patterns to be ignored by Markdown.
+ */
+ $custom_patterns = apply_filters( 'jetpack_markdown_preserve_pattern', array() );
+ if ( is_array( $custom_patterns ) && ! empty( $custom_patterns ) ) {
+ foreach ( $custom_patterns as $pattern ) {
+ $text = preg_replace_callback( $pattern, array( $this, '_doRemoveText'), $text );
+ }
+ }
+
// run through core Markdown
$text = parent::transform( $text );
diff --git a/plugins/jetpack/_inc/lib/tracks/tracks-ajax.js b/plugins/jetpack/_inc/lib/tracks/tracks-ajax.js
new file mode 100644
index 00000000..316aef44
--- /dev/null
+++ b/plugins/jetpack/_inc/lib/tracks/tracks-ajax.js
@@ -0,0 +1,49 @@
+/* global jpTracksAJAX, jQuery */
+
+(function( $, jpTracksAJAX ) {
+
+ $( document ).ready( function () {
+ $( 'body' ).on( 'click', '.jptracks a, a.jptracks', function( event ) {
+
+ // We know that the jptracks element is either this, or its ancestor
+ var $jptracks = $( this ).closest( '.jptracks' );
+
+ var data = {
+ tracksNonce: jpTracksAJAX.jpTracksAJAX_nonce,
+ action: 'jetpack_tracks',
+ tracksEventType: 'click',
+ tracksEventName: $jptracks.attr( 'data-jptracks-name' ),
+ tracksEventProp: $jptracks.attr( 'data-jptracks-prop' ) || false
+ };
+
+ // We need an event name at least
+ if ( undefined === data.tracksEventName ) {
+ return;
+ }
+
+ var url = $( this ).attr( 'href' );
+ var target = $( this ).get( 0 ).target;
+ if ( url && target && '_self' !== target ) {
+ var newTabWindow = window.open( '', target );
+ }
+
+ event.preventDefault();
+
+ $.ajax( {
+ type: 'POST',
+ url: jpTracksAJAX.ajaxurl,
+ data: data
+ } ).always( function() {
+ // Continue on to whatever url they were trying to get to.
+ if ( url ) {
+ if ( newTabWindow ) {
+ newTabWindow.location = url;
+ return;
+ }
+ window.location = url;
+ }
+ } );
+ });
+ });
+
+})( jQuery, jpTracksAJAX );
diff --git a/plugins/jetpack/_inc/twitter-timeline.js b/plugins/jetpack/_inc/twitter-timeline.js
new file mode 100644
index 00000000..e463363d
--- /dev/null
+++ b/plugins/jetpack/_inc/twitter-timeline.js
@@ -0,0 +1,39 @@
+/* global twttr */
+
+/* jshint ignore:start */
+!function(d,s,id){
+ var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
+ if(!d.getElementById(id)){
+ js=d.createElement(s);
+ js.id=id;js.src=p+"://platform.twitter.com/widgets.js";
+ fjs.parentNode.insertBefore(js,fjs);
+ }
+}(document,"script","twitter-wjs");
+/* jshint ignore:end */
+
+jQuery( function() {
+ var hasSelectiveRefresh = (
+ 'undefined' !== typeof wp &&
+ wp.customize &&
+ wp.customize.selectiveRefresh &&
+ wp.customize.widgetsPreview &&
+ wp.customize.widgetsPreview.WidgetPartial
+ );
+ if ( ! hasSelectiveRefresh ) {
+ return;
+ }
+
+ // Re-load Twitter widgets when a partial is rendered.
+ wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) {
+ if ( placement.container ) {
+ twttr.widgets.load( placement.container[0] );
+ }
+ } );
+
+ // Refresh a moved partial containing a Twitter timeline iframe, since it has to be re-built.
+ wp.customize.selectiveRefresh.bind( 'partial-content-moved', function( placement ) {
+ if ( placement.container && placement.container.find( 'iframe.twitter-timeline:not([src]):first' ).length ) {
+ placement.partial.refresh();
+ }
+ } );
+} );