diff options
Diffstat (limited to 'plugins/jetpack/_inc/lib')
-rw-r--r-- | plugins/jetpack/_inc/lib/admin-pages/class.jetpack-landing-page.php | 2 | ||||
-rw-r--r-- | plugins/jetpack/_inc/lib/class.color.php | 17 | ||||
-rw-r--r-- | plugins/jetpack/_inc/lib/markdown/extra.php | 4 | ||||
-rw-r--r-- | plugins/jetpack/_inc/lib/markdown/gfm.php | 16 | ||||
-rw-r--r-- | plugins/jetpack/_inc/lib/tracks/tracks-ajax.js | 49 |
5 files changed, 79 insertions, 9 deletions
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 ); |