summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules')
-rw-r--r--plugins/jetpack/modules/after-the-deadline/config-options.php4
-rw-r--r--plugins/jetpack/modules/after-the-deadline/config-unignore.php2
-rw-r--r--plugins/jetpack/modules/carousel/jetpack-carousel.js8
-rw-r--r--plugins/jetpack/modules/comments/comments.php2
-rw-r--r--plugins/jetpack/modules/contact-form/grunion-contact-form.php31
-rw-r--r--plugins/jetpack/modules/contact-form/grunion-form-view.php22
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css.php10
-rw-r--r--plugins/jetpack/modules/likes/queuehandler.js48
-rw-r--r--plugins/jetpack/modules/post-by-email.php101
-rw-r--r--plugins/jetpack/modules/post-by-email/post-by-email.js254
-rw-r--r--plugins/jetpack/modules/protect.php18
-rw-r--r--plugins/jetpack/modules/related-posts/jetpack-related-posts.php5
-rw-r--r--plugins/jetpack/modules/sharedaddy/sharing.js7
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-xsl.php20
-rw-r--r--plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.min.js107
-rw-r--r--plugins/jetpack/modules/videopress/js/editor-view.js3
-rw-r--r--plugins/jetpack/modules/widgets.php2
17 files changed, 294 insertions, 350 deletions
diff --git a/plugins/jetpack/modules/after-the-deadline/config-options.php b/plugins/jetpack/modules/after-the-deadline/config-options.php
index 2b325146..ef0ba8c9 100644
--- a/plugins/jetpack/modules/after-the-deadline/config-options.php
+++ b/plugins/jetpack/modules/after-the-deadline/config-options.php
@@ -55,7 +55,7 @@ function AtD_display_options_form() {
AtD_print_option( 'onupdate', __('a post or page is updated', 'jetpack'), $options_check_when );
?></p>
- <p style="font-weight: bold"><?php _e('English Options', 'jetpack'); ?></font>
+ <p style="font-weight: bold"><?php _e('English Options', 'jetpack'); ?></p>
<p><?php _e('Enable proofreading for the following grammar and style rules when writing posts and pages:', 'jetpack'); ?></p>
@@ -83,7 +83,7 @@ function AtD_display_options_form() {
<p><?php printf( __( '<a href="%s" target="_blank">Learn more</a> about these options.', 'jetpack' ), 'http://support.wordpress.com/proofreading/' );
?></p>
- <p style="font-weight: bold"><?php _e( 'Language', 'jetpack' ); ?></font>
+ <p style="font-weight: bold"><?php _e( 'Language', 'jetpack' ); ?></p>
<p><?php
_e( 'The proofreader supports English, French, German, Portuguese, and Spanish. Your user interface language (see above) is the default proofreading language.', 'jetpack' );
diff --git a/plugins/jetpack/modules/after-the-deadline/config-unignore.php b/plugins/jetpack/modules/after-the-deadline/config-unignore.php
index 43c36a72..9a7b9217 100644
--- a/plugins/jetpack/modules/after-the-deadline/config-unignore.php
+++ b/plugins/jetpack/modules/after-the-deadline/config-unignore.php
@@ -128,7 +128,7 @@ else
</script>
<input type="hidden" name="AtD_ignored_phrases" id="AtD_ignored_phrases" value="<?php echo esc_attr( $ignores ); ?>">
- <p style="font-weight: bold"><?php _e( 'Ignored Phrases', 'jetpack' ); ?></font>
+ <p style="font-weight: bold"><?php _e( 'Ignored Phrases', 'jetpack' ); ?></p>
<p><?php _e( 'Identify words and phrases to ignore while proofreading your posts and pages:', 'jetpack' ); ?></p>
diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.js b/plugins/jetpack/modules/carousel/jetpack-carousel.js
index dd586866..c7531d2e 100644
--- a/plugins/jetpack/modules/carousel/jetpack-carousel.js
+++ b/plugins/jetpack/modules/carousel/jetpack-carousel.js
@@ -1083,8 +1083,8 @@ jQuery(document).ready(function($) {
desc = gallery.jp_carousel('parseTitleDesc', data.desc) || '';
if ( title.length || desc.length ) {
- // $('<div />').text(sometext).html() is a trick to go to HTML to plain text (including HTML entities decode, etc)
- if ( $('<div />').text(title).html() === $('<div />').text(desc).html() ) {
+ // Convert from HTML to plain text (including HTML entities decode, etc)
+ if ( $('<div />').html( title ).text() === $('<div />').html( desc ).text() ) {
title = '';
}
@@ -1398,8 +1398,8 @@ jQuery(document).ready(function($) {
matches, attachmentId, galleries, selectedThumbnail;
if ( ! window.location.hash || ! hashRegExp.test( window.location.hash ) ) {
- if ( gallery.opened ) {
- container.jp_carousel('close');
+ if ( gallery && gallery.opened ) {
+ container.jp_carousel( 'close' );
}
return;
diff --git a/plugins/jetpack/modules/comments/comments.php b/plugins/jetpack/modules/comments/comments.php
index 5330cb7a..1143eb71 100644
--- a/plugins/jetpack/modules/comments/comments.php
+++ b/plugins/jetpack/modules/comments/comments.php
@@ -257,7 +257,7 @@ class Jetpack_Comments extends Highlander_Comments_Base {
*/
'greeting_reply' => apply_filters( 'jetpack_comment_form_prompt_reply', __( 'Leave a Reply to %s' , 'jetpack' ) ),
'color_scheme' => get_option( 'jetpack_comment_form_color_scheme', $this->default_color_scheme ),
- 'lang' => get_bloginfo( 'language' ),
+ 'lang' => get_locale(),
'jetpack_version' => JETPACK__VERSION,
);
diff --git a/plugins/jetpack/modules/contact-form/grunion-contact-form.php b/plugins/jetpack/modules/contact-form/grunion-contact-form.php
index 13b25ad3..343cd2f4 100644
--- a/plugins/jetpack/modules/contact-form/grunion-contact-form.php
+++ b/plugins/jetpack/modules/contact-form/grunion-contact-form.php
@@ -1505,22 +1505,29 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode {
if ( $field_ids['extra'] ) {
// array indexed by field label (not field id)
$extra_fields = get_post_meta( $feedback_id, '_feedback_extra_fields', true );
- $extra_field_keys = array_keys( $extra_fields );
- $i = 0;
- foreach ( $field_ids['extra'] as $field_id ) {
- $field = $form->fields[$field_id];
- $field_index = array_search( $field_id, $field_ids['all'] );
+ /**
+ * Only get data for the compiled form if `$extra_fields` is a valid and non-empty array.
+ */
+ if ( is_array( $extra_fields ) && ! empty( $extra_fields ) ) {
- $label = $field->get_attribute( 'label' );
+ $extra_field_keys = array_keys( $extra_fields );
- $compiled_form[ $field_index ] = sprintf(
- '<b>%1$s:</b> %2$s<br /><br />',
- wp_kses( $label, array() ),
- nl2br( wp_kses( $extra_fields[$extra_field_keys[$i]], array() ) )
- );
+ $i = 0;
+ foreach ( $field_ids['extra'] as $field_id ) {
+ $field = $form->fields[ $field_id ];
+ $field_index = array_search( $field_id, $field_ids['all'] );
+
+ $label = $field->get_attribute( 'label' );
+
+ $compiled_form[ $field_index ] = sprintf(
+ '<b>%1$s:</b> %2$s<br /><br />',
+ wp_kses( $label, array() ),
+ nl2br( wp_kses( $extra_fields[ $extra_field_keys[ $i ] ], array() ) )
+ );
- $i++;
+ $i++;
+ }
}
}
diff --git a/plugins/jetpack/modules/contact-form/grunion-form-view.php b/plugins/jetpack/modules/contact-form/grunion-form-view.php
index 54617fc9..e9c9a736 100644
--- a/plugins/jetpack/modules/contact-form/grunion-form-view.php
+++ b/plugins/jetpack/modules/contact-form/grunion-form-view.php
@@ -3,6 +3,17 @@
* Template for form builder
*/
+/**
+ * Filter to modify the limit of 5 additional contact form fields.
+ *
+ * @module contact-form
+ *
+ * @since 3.2.0
+ *
+ * @param int 5 Maximum number of additional fields.
+ */
+$max_new_fields = apply_filters( 'grunion_max_new_fields', 5 );
+
wp_register_script( 'grunion', GRUNION_PLUGIN_URL . 'js/grunion.js', array( 'jquery-ui-sortable', 'jquery-ui-draggable' ), JETPACK__VERSION );
wp_localize_script( 'grunion', 'GrunionFB_i18n', array(
'nameLabel' => esc_attr( _x( 'Name', 'Label for HTML form "Name" field in contact form builder', 'jetpack' ) ),
@@ -20,16 +31,7 @@ wp_localize_script( 'grunion', 'GrunionFB_i18n', array(
'savedMessage' => esc_attr__( 'Saved successfully', 'jetpack' ),
'requiredLabel' => esc_attr( _x( '(required)', 'This HTML form field is marked as required by the user in contact form builder', 'jetpack' ) ),
'exitConfirmMessage' => esc_attr__( 'Are you sure you want to exit the form editor without saving? Any changes you have made will be lost.', 'jetpack' ),
- /**
- * Filter to modify the limit of 5 additional contact form fields.
- *
- * @module contact-form
- *
- * @since 3.2.0
- *
- * @param int 5 Maximum number of additional fields.
- */
- 'maxNewFields' => intval( apply_filters( 'grunion_max_new_fields', 5 ) ),
+ 'maxNewFields' => intval( $max_new_fields ),
) );
?>
diff --git a/plugins/jetpack/modules/custom-css/custom-css.php b/plugins/jetpack/modules/custom-css/custom-css.php
index e3e6fbff..48428e9e 100644
--- a/plugins/jetpack/modules/custom-css/custom-css.php
+++ b/plugins/jetpack/modules/custom-css/custom-css.php
@@ -108,7 +108,7 @@ class Jetpack_Custom_CSS {
check_admin_referer( 'safecss' );
$save_result = self::save( array(
- 'css' => $_POST['safecss'],
+ 'css' => stripslashes( $_POST['safecss'] ),
'is_preview' => isset( $_POST['action'] ) && $_POST['action'] == 'preview',
'preprocessor' => isset( $_POST['custom_css_preprocessor'] ) ? $_POST['custom_css_preprocessor'] : '',
'add_to_existing' => isset( $_POST['add_to_existing'] ) ? $_POST['add_to_existing'] == 'true' : true,
@@ -214,6 +214,8 @@ class Jetpack_Custom_CSS {
$css = $orig = $args['css'];
$css = preg_replace( '/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $prev = $css );
+ // prevent content: '\3434' from turning into '\\3434'
+ $css = str_replace( array( '\'\\\\', '"\\\\' ), array( '\'\\', '"\\' ), $css );
if ( $css != $prev )
$warnings[] = 'preg_replace found stuff';
@@ -429,11 +431,11 @@ class Jetpack_Custom_CSS {
return false;
$post = array();
- $post['post_content'] = $css;
+ $post['post_content'] = wp_slash( $css );
$post['post_title'] = 'safecss';
$post['post_status'] = 'publish';
$post['post_type'] = 'safecss';
- $post['post_content_filtered'] = $compressed_css;
+ $post['post_content_filtered'] = wp_slash( $compressed_css );
// Set excerpt to current theme, for display in revisions list
if ( function_exists( 'wp_get_theme' ) ) {
@@ -471,6 +473,8 @@ class Jetpack_Custom_CSS {
// Do not update post if we are only saving a preview
if ( false === $is_preview ) {
+ $safecss_post['post_content'] = wp_slash( $safecss_post['post_content'] );
+ $safecss_post['post_content_filtered'] = wp_slash( $safecss_post['post_content_filtered'] );
$post_id = wp_update_post( $safecss_post );
wp_cache_set( 'custom_css_post_id', $post_id );
return $post_id;
diff --git a/plugins/jetpack/modules/likes/queuehandler.js b/plugins/jetpack/modules/likes/queuehandler.js
index cd619266..031bb0df 100644
--- a/plugins/jetpack/modules/likes/queuehandler.js
+++ b/plugins/jetpack/modules/likes/queuehandler.js
@@ -57,11 +57,19 @@ function JetpackLikesBatchHandler() {
}
}
-function JetpackLikesMessageListener( event ) {
+function JetpackLikesMessageListener( event, message ) {
+ var allowedOrigin, $container, $list, offset, rowLength, height, scrollbarWidth;
+
if ( 'undefined' === typeof event.event ) {
return;
}
+ // We only allow messages from one origin
+ allowedOrigin = window.location.protocol + '//widgets.wp.com';
+ if ( allowedOrigin !== message.origin ) {
+ return;
+ }
+
if ( 'masterReady' === event.event ) {
jQuery( document ).ready( function() {
jetpackLikesMasterReady = true;
@@ -127,9 +135,8 @@ function JetpackLikesMessageListener( event ) {
}
if ( 'showOtherGravatars' === event.event ) {
- var $container = jQuery( '#likes-other-gravatars' ),
- $list = $container.find( 'ul' ),
- offset, rowLength, height, scrollbarWidth;
+ $container = jQuery( '#likes-other-gravatars' );
+ $list = $container.find( 'ul' );
$container.hide();
$list.html( '' );
@@ -137,7 +144,36 @@ function JetpackLikesMessageListener( event ) {
$container.find( '.likes-text span' ).text( event.total );
jQuery.each( event.likers, function( i, liker ) {
- $list.append( '<li class="' + liker.css_class + '"><a href="' + liker.profile_URL + '" class="wpl-liker" rel="nofollow" target="_parent"><img src="' + liker.avatar_URL + '" alt="' + liker.name + '" width="30" height="30" style="padding-right: 3px;" /></a></li>');
+ var element;
+
+ if ( 'http' !== liker.profile_URL.substr( 0, 4 ) ) {
+ // We only display gravatars with http or https schema
+ return;
+ }
+
+ element = jQuery( '<li><a><img /></a></li>' );
+ element.addClass( liker.css_class );
+
+ element.find( 'a' ).
+ attr({
+ href: liker.profile_URL,
+ rel: 'nofollow',
+ target: '_parent'
+ }).
+ addClass( 'wpl-liker' );
+
+ element.find( 'img' ).
+ attr({
+ src: liker.avatar_URL,
+ alt: liker.name
+ }).
+ css({
+ width: '30px',
+ height: '30px',
+ paddingRight: '3px'
+ });
+
+ $list.append( element );
} );
offset = jQuery( '[name=\'' + event.parent + '\']' ).offset();
@@ -166,7 +202,7 @@ function JetpackLikesMessageListener( event ) {
}
}
-pm.bind( 'likesMessage', function(e) { JetpackLikesMessageListener(e); } );
+pm.bind( 'likesMessage', JetpackLikesMessageListener );
jQuery( document ).click( function( e ) {
var $container = jQuery( '#likes-other-gravatars' );
diff --git a/plugins/jetpack/modules/post-by-email.php b/plugins/jetpack/modules/post-by-email.php
index c30596be..6a7bae26 100644
--- a/plugins/jetpack/modules/post-by-email.php
+++ b/plugins/jetpack/modules/post-by-email.php
@@ -57,6 +57,13 @@ class Jetpack_Post_By_Email {
function profile_scripts() {
wp_enqueue_script( 'post-by-email', plugins_url( 'post-by-email/post-by-email.js', __FILE__ ), array( 'jquery' ) );
+ wp_localize_script( 'post-by-email', 'pbeVars', array(
+ 'nonces' => array(
+ 'enable' => wp_create_nonce( 'jetpack.createPostByEmailAddress' ),
+ 'regenerate' => wp_create_nonce( 'jetpack.regeneratePostByEmailAddress' ),
+ 'disable' => wp_create_nonce( 'jetpack.deletePostByEmailAddress' ),
+ ),
+ ));
wp_enqueue_style( 'post-by-email', plugins_url( 'post-by-email/post-by-email.css', __FILE__ ) );
wp_style_add_data( 'post-by-email', 'jetpack-inline', true );
// Do we really need `admin_styles`? With the new admin UI, it's breaking some bits.
@@ -151,86 +158,54 @@ class Jetpack_Post_By_Email {
}
function create_post_by_email_address() {
- Jetpack::load_xml_rpc_client();
- $xml = new Jetpack_IXR_Client( array(
- 'user_id' => get_current_user_id(),
- ) );
- $xml->query( 'jetpack.createPostByEmailAddress' );
-
- if ( $xml->isError() ) {
- echo json_encode( array(
- 'response' => 'error',
- 'message' => __( 'Unable to create your Post By Email address. Please try again later.', 'jetpack' )
- ) );
- die();
- }
-
- $response = $xml->getResponse();
- if ( empty( $response ) ) {
- echo json_encode( array(
- 'response' => 'error',
- 'message' => __( 'Unable to create your Post By Email address. Please try again later.', 'jetpack' )
- ) );
- die();
- }
-
- echo $response;
- die();
+ self::__process_ajax_proxy_request(
+ 'jetpack.createPostByEmailAddress',
+ __( 'Unable to create your Post By Email address. Please try again later.', 'jetpack' )
+ );
}
function regenerate_post_by_email_address() {
- Jetpack::load_xml_rpc_client();
- $xml = new Jetpack_IXR_Client( array(
- 'user_id' => get_current_user_id(),
- ) );
- $xml->query( 'jetpack.regeneratePostByEmailAddress' );
-
- if ( $xml->isError() ) {
- echo json_encode( array(
- 'response' => 'error',
- 'message' => __( 'Unable to regenerate your Post By Email address. Please try again later.', 'jetpack' )
- ) );
- die();
- }
-
- $response = $xml->getResponse();
- if ( empty( $response ) ) {
- echo json_encode( array(
- 'response' => 'error',
- 'message' => __( 'Unable to regenerate your Post By Email address. Please try again later.', 'jetpack' )
- ) );
- die();
- }
-
- echo $response;
- die();
+ self::__process_ajax_proxy_request(
+ 'jetpack.regeneratePostByEmailAddress',
+ __( 'Unable to regenerate your Post By Email address. Please try again later.', 'jetpack' )
+ );
}
function delete_post_by_email_address() {
+ self::__process_ajax_proxy_request(
+ 'jetpack.deletePostByEmailAddress',
+ __( 'Unable to disable your Post By Email address. Please try again later.', 'jetpack' )
+ );
+ }
+
+ /**
+ * Backend function to abstract the xmlrpc function calls to wpcom.
+ *
+ * @param $endpoint
+ * @param $error_message
+ */
+ function __process_ajax_proxy_request( $endpoint, $error_message ) {
+ if ( ! current_user_can( 'edit_posts' ) ) {
+ wp_send_json_error( $error_message );
+ }
+ if ( empty( $_REQUEST['pbe_nonce'] ) || ! wp_verify_nonce( $_REQUEST['pbe_nonce'], $endpoint ) ) {
+ wp_send_json_error( $error_message );
+ }
Jetpack::load_xml_rpc_client();
$xml = new Jetpack_IXR_Client( array(
'user_id' => get_current_user_id(),
) );
- $xml->query( 'jetpack.deletePostByEmailAddress' );
+ $xml->query( $endpoint );
if ( $xml->isError() ) {
- echo json_encode( array(
- 'response' => 'error',
- 'message' => __( 'Unable to disable your Post By Email address. Please try again later.', 'jetpack' )
- ) );
- die();
+ wp_send_json_error( $error_message );
}
$response = $xml->getResponse();
if ( empty( $response ) ) {
- echo json_encode( array(
- 'response' => 'error',
- 'message' => __( 'Unable to disable your Post By Email address. Please try again later.', 'jetpack' )
- ) );
- die();
+ wp_send_json_error( $error_message );
}
- echo $response;
- die();
+ wp_send_json_success( $response );
}
}
diff --git a/plugins/jetpack/modules/post-by-email/post-by-email.js b/plugins/jetpack/modules/post-by-email/post-by-email.js
index ed8df7fd..0933f825 100644
--- a/plugins/jetpack/modules/post-by-email/post-by-email.js
+++ b/plugins/jetpack/modules/post-by-email/post-by-email.js
@@ -1,128 +1,128 @@
-/* global jetpack_post_by_email:true, ajaxurl */
-
-jetpack_post_by_email = {
- init: function() {
- jQuery( '#jp-pbe-enable' ).click( jetpack_post_by_email.enable );
- jQuery( '#jp-pbe-regenerate' ).click( jetpack_post_by_email.regenerate );
- jQuery( '#jp-pbe-disable' ).click( jetpack_post_by_email.disable );
- },
-
- enable: function() {
- jQuery( '#jp-pbe-enable' ).attr( 'disabled', 'disabled' );
- jQuery( '#jp-pbe-error' ).fadeOut();
- jQuery( '#jp-pbe-spinner' ).fadeIn();
-
- var data = {
- action: 'jetpack_post_by_email_enable'
- };
-
- jQuery.post( ajaxurl, data, jetpack_post_by_email.handle_enabled );
- },
-
- handle_enabled: function( response ) {
- var enabled = false, error;
- try {
- error = JSON.parse( response );
- } catch ( e ) {
- enabled = true;
+/* global jetpack_post_by_email:true, ajaxurl, pbeVars */
+
+(function($) {
+ var $pbeDisable,
+ $pbeEmail,
+ $pbeEmailWrapper,
+ $pbeEnable,
+ $pbeError,
+ $pbeInfo,
+ $pbeRegenerate,
+ $pbeSpinner;
+
+ jetpack_post_by_email = {
+ init: function () {
+ $pbeEnable.click( jetpack_post_by_email.enable );
+ $pbeRegenerate.click( jetpack_post_by_email.regenerate );
+ $pbeDisable.click( jetpack_post_by_email.disable );
+ },
+
+ enable: function () {
+ $pbeEnable.attr('disabled', 'disabled');
+ $pbeError.fadeOut();
+ $pbeSpinner.fadeIn();
+
+ var data = {
+ action: 'jetpack_post_by_email_enable',
+ pbe_nonce: pbeVars.nonces.enable
+ };
+
+ $.post( ajaxurl, data, jetpack_post_by_email.handle_enabled );
+ },
+
+ handle_enabled: function( response ) {
+ $pbeRegenerate.removeAttr( 'disabled' );
+ $pbeDisable.removeAttr( 'disabled' );
+
+ if ( response.success ) {
+ $pbeEnable.fadeOut( 400, function() {
+ $pbeEnable.removeAttr( 'disabled' );
+ $pbeEmail.val( response.data );
+ $pbeInfo.fadeIn();
+ });
+ } else {
+ $pbeError.text( response.data );
+ $pbeError.fadeIn();
+ $pbeEnable.removeAttr( 'disabled' );
+ }
+
+ $pbeSpinner.fadeOut();
+ },
+
+ regenerate: function() {
+ $pbeRegenerate.attr( 'disabled', 'disabled' );
+ $pbeDisable.attr( 'disabled', 'disabled' );
+ $pbeError.fadeOut();
+ $pbeSpinner.fadeIn();
+
+ var data = {
+ action: 'jetpack_post_by_email_regenerate',
+ pbe_nonce: pbeVars.nonces.regenerate
+ };
+
+ $.post( ajaxurl, data, jetpack_post_by_email.handle_regenerated );
+ },
+
+ handle_regenerated: function( response ) {
+ if ( response.success ) {
+ $pbeEmailWrapper.fadeOut( 400, function() {
+ $pbeEmail.val( response.data );
+ $pbeEmailWrapper.fadeIn();
+ });
+ } else {
+ $pbeError.text( response.data );
+ $pbeError.fadeIn();
+ }
+
+ $pbeRegenerate.removeAttr( 'disabled' );
+ $pbeDisable.removeAttr( 'disabled' );
+ $pbeSpinner.fadeOut();
+ },
+
+ disable: function () {
+ $pbeRegenerate.attr( 'disabled', 'disabled' );
+ $pbeDisable.attr( 'disabled', 'disabled' );
+ $pbeError.fadeOut();
+ $pbeSpinner.fadeIn();
+
+ var data = {
+ action: 'jetpack_post_by_email_disable',
+ pbe_nonce: pbeVars.nonces.disable
+ };
+
+ $.post( ajaxurl, data, jetpack_post_by_email.handle_disabled );
+ },
+
+ handle_disabled: function( response ) {
+ if ( response.success ) {
+ $pbeEnable.removeAttr( 'disabled' );
+ $pbeInfo.fadeOut( 400, function() {
+ $pbeRegenerate.removeAttr( 'disabled' );
+ $pbeDisable.removeAttr( 'disabled' );
+ $pbeEnable.fadeIn();
+ });
+ } else {
+ $pbeRegenerate.removeAttr( 'disabled' );
+ $pbeDisable.removeAttr( 'disabled' );
+
+ $pbeError.text( response.data );
+ $pbeError.fadeIn();
+ }
+
+ $pbeSpinner.fadeOut();
}
-
- jQuery( '#jp-pbe-regenerate' ).removeAttr( 'disabled' );
- jQuery( '#jp-pbe-disable' ).removeAttr( 'disabled' );
-
- if ( enabled ) {
- jQuery( '#jp-pbe-enable' ).fadeOut( 400, function() {
- jQuery( '#jp-pbe-enable' ).removeAttr( 'disabled' );
- jQuery( '#jp-pbe-email' ).val( response );
- jQuery( '#jp-pbe-info' ).fadeIn();
- });
- } else {
- jQuery( '#jp-pbe-error' ).text( error.message );
- jQuery( '#jp-pbe-error' ).fadeIn();
- jQuery( '#jp-pbe-enable' ).removeAttr( 'disabled' );
- }
-
- jQuery( '#jp-pbe-spinner' ).fadeOut();
- },
-
- regenerate: function() {
- jQuery( '#jp-pbe-regenerate' ).attr( 'disabled', 'disabled' );
- jQuery( '#jp-pbe-disable' ).attr( 'disabled', 'disabled' );
- jQuery( '#jp-pbe-error' ).fadeOut();
- jQuery( '#jp-pbe-spinner' ).fadeIn();
-
- var data = {
- action: 'jetpack_post_by_email_regenerate'
- };
-
- jQuery.post( ajaxurl, data, jetpack_post_by_email.handle_regenerated );
- },
-
- handle_regenerated: function( response ) {
- var regenerated = false, error;
- try {
- error = JSON.parse( response );
- } catch ( e ) {
- regenerated = true;
- }
-
- if ( regenerated ) {
- jQuery( '#jp-pbe-email-wrapper' ).fadeOut( 400, function() {
- jQuery( '#jp-pbe-email' ).val( response );
- jQuery( '#jp-pbe-email-wrapper' ).fadeIn();
- });
- } else {
- jQuery( '#jp-pbe-error' ).text( error.message );
- jQuery( '#jp-pbe-error' ).fadeIn();
- }
-
- jQuery( '#jp-pbe-regenerate' ).removeAttr( 'disabled' );
- jQuery( '#jp-pbe-disable' ).removeAttr( 'disabled' );
- jQuery( '#jp-pbe-spinner' ).fadeOut();
- },
-
- disable: function() {
- jQuery( '#jp-pbe-regenerate' ).attr( 'disabled', 'disabled' );
- jQuery( '#jp-pbe-disable' ).attr( 'disabled', 'disabled' );
- jQuery( '#jp-pbe-error' ).fadeOut();
- jQuery( '#jp-pbe-spinner' ).fadeIn();
-
- var data = {
- action: 'jetpack_post_by_email_disable'
- };
-
- jQuery.post( ajaxurl, data, jetpack_post_by_email.handle_disabled );
- },
-
- handle_disabled: function( response ) {
- var disabled = false, error;
- try {
- error = JSON.parse( response );
- } catch ( e ) {
- disabled = true;
- }
-
- if ( 'error' !== error.response ) {
- disabled = true;
- }
-
- if ( disabled ) {
- jQuery( '#jp-pbe-enable' ).removeAttr( 'disabled' );
- jQuery( '#jp-pbe-info' ).fadeOut( 400, function() {
- jQuery( '#jp-pbe-regenerate' ).removeAttr( 'disabled' );
- jQuery( '#jp-pbe-disable' ).removeAttr( 'disabled' );
- jQuery( '#jp-pbe-enable' ).fadeIn();
- });
- } else {
- jQuery( '#jp-pbe-regenerate' ).removeAttr( 'disabled' );
- jQuery( '#jp-pbe-disable' ).removeAttr( 'disabled' );
-
- jQuery( '#jp-pbe-error' ).text( error.message );
- jQuery( '#jp-pbe-error' ).fadeIn();
- }
-
- jQuery( '#jp-pbe-spinner' ).fadeOut();
- }
-};
-
-jQuery( function() { jetpack_post_by_email.init(); } );
+ };
+
+ $( function() {
+ $pbeDisable = $('#jp-pbe-disable');
+ $pbeEmail = $('#jp-pbe-email');
+ $pbeEmailWrapper = $('#jp-pbe-email-wrapper');
+ $pbeEnable = $('#jp-pbe-enable');
+ $pbeError = $('#jp-pbe-error');
+ $pbeInfo = $('#jp-pbe-info');
+ $pbeRegenerate = $('#jp-pbe-regenerate');
+ $pbeSpinner = $('#jp-pbe-spinner');
+
+ jetpack_post_by_email.init();
+ } );
+})(jQuery);
diff --git a/plugins/jetpack/modules/protect.php b/plugins/jetpack/modules/protect.php
index 7f0bcb48..4829e016 100644
--- a/plugins/jetpack/modules/protect.php
+++ b/plugins/jetpack/modules/protect.php
@@ -51,7 +51,7 @@ class Jetpack_Protect_Module {
add_action( 'jetpack_deactivate_module_protect', array ( $this, 'on_deactivation' ) );
add_action( 'init', array ( $this, 'maybe_get_protect_key' ) );
add_action( 'jetpack_modules_loaded', array ( $this, 'modules_loaded' ) );
- add_action( 'login_head', array ( $this, 'check_use_math' ) );
+ add_action( 'init', array ( $this, 'check_use_math' ) );
add_filter( 'authenticate', array ( $this, 'check_preauth' ), 10, 3 );
add_action( 'wp_login', array ( $this, 'log_successful_login' ), 10, 2 );
add_action( 'wp_login_failed', array ( $this, 'log_failed_attempt' ) );
@@ -174,7 +174,7 @@ class Jetpack_Protect_Module {
<p><?php printf( __( 'Thanks for activating Protect! To start protecting your site, please network activate Jetpack on your Multisite installation and activate Protect on your primary site. Due to the way logins are handled on WordPress Multisite, Jetpack must be network-enabled in order for Protect to work properly. <a href="%s" target="_blank">Learn More</a>', 'jetpack' ), 'http://jetpack.com/support/multisite-protect' ); ?></p>
</div>
<div class="jp-banner__action-container is-opt-in">
- <a href="<?php echo network_admin_url( 'plugins.php' ); ?>" class="jp-banner__button"
+ <a href="<?php echo esc_url( network_admin_url( 'plugins.php' ) ); ?>" class="jp-banner__button"
id="wpcom-connect"><?php _e( 'View Network Admin', 'jetpack' ); ?></a>
</div>
</div>
@@ -666,11 +666,23 @@ class Jetpack_Protect_Module {
$request['multisite'] = get_blog_count();
}
+
+ /**
+ * Filter controls maximum timeout in waiting for reponse from Protect servers.
+ *
+ * @module protect
+ *
+ * @since 4.0.4
+ *
+ * @param int $timeout Max time (in seconds) to wait for a response.
+ */
+ $timeout = apply_filters( 'jetpack_protect_connect_timeout', 30 );
+
$args = array (
'body' => $request,
'user-agent' => $user_agent,
'httpversion' => '1.0',
- 'timeout' => 15
+ 'timeout' => absint( $timeout )
);
$response_json = wp_remote_post( $this->get_api_host(), $args );
diff --git a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php
index fa1524fa..d61d4e75 100644
--- a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php
+++ b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php
@@ -361,6 +361,11 @@ EOT;
// only dislay the Related Posts JavaScript on the Reading Settings Admin Page
$current_screen = get_current_screen();
+
+ if ( is_null( $current_screen ) ) {
+ return;
+ }
+
if( 'options-reading' != $current_screen->id )
return;
diff --git a/plugins/jetpack/modules/sharedaddy/sharing.js b/plugins/jetpack/modules/sharedaddy/sharing.js
index 1c1d6aa0..96a26b4b 100644
--- a/plugins/jetpack/modules/sharedaddy/sharing.js
+++ b/plugins/jetpack/modules/sharedaddy/sharing.js
@@ -1,4 +1,5 @@
/* global WPCOM_sharing_counts, grecaptcha */
+/* jshint unused:false */
var sharing_js_options;
if ( sharing_js_options && sharing_js_options.counts ) {
var WPCOMSharing = {
@@ -20,7 +21,7 @@ if ( sharing_js_options && sharing_js_options.counts ) {
requests = {
// LinkedIn actually gets the share count for both the http and https version automatically -- so we don't need to do extra magic
linkedin: [
- 'https://www.linkedin.com/countserv/count/share?format=jsonp&callback=WPCOMSharing.update_linkedin_count&url=' +
+ 'https://www.linkedin.com/countserv/count/share?format=jsonp&callback=updateLinkedInCount&url=' +
encodeURIComponent( url )
],
// Pinterest, like LinkedIn, handles share counts for both http and https
@@ -114,6 +115,10 @@ if ( sharing_js_options && sharing_js_options.counts ) {
};
}
+var updateLinkedInCount = function( data ) {
+ WPCOMSharing.update_linkedin_count( data );
+};
+
(function($){
var $body, $sharing_email;
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-xsl.php b/plugins/jetpack/modules/sitemaps/sitemap-xsl.php
index fc97d291..906f11fb 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-xsl.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-xsl.php
@@ -16,7 +16,7 @@ $xsl = '<?xml version="1.0" encoding="UTF-8"?>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>' . esc_html__( 'XML Sitemap', 'jetpack' ) . '</title>
+ <title>' . esc_html( ent2ncr( __( 'XML Sitemap', 'jetpack' ) ) ) . '</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
body {
@@ -89,18 +89,18 @@ $xsl = '<?xml version="1.0" encoding="UTF-8"?>
</head>
<body>
<div id="description">
- <h1>' . esc_html__( 'XML Sitemap', 'jetpack' ) . '</h1>
- <p>' . wp_kses( sprintf( __( 'This is an XML Sitemap generated by <a href="%s" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%s" target="_blank">Google</a> or <a href="%s" target="_blank">Bing</a>.', 'jetpack' ), 'http://jetpack.com/', 'https://www.google.com', 'https://www.bing.com/' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) . '</p>
- <p>' . wp_kses( sprintf( __( 'You can find more information on XML sitemaps at <a href="%s" target="_blank">sitemaps.org</a>', 'jetpack' ), 'http://sitemaps.org' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) . '</p>
+ <h1>' . esc_html( ent2ncr( __( 'XML Sitemap', 'jetpack' ) ) ) . '</h1>
+ <p>' . wp_kses( sprintf( ent2ncr( __( 'This is an XML Sitemap generated by <a href="%s" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%s" target="_blank">Google</a> or <a href="%s" target="_blank">Bing</a>.', 'jetpack' ), 'http://jetpack.com/', 'https://www.google.com', 'https://www.bing.com/' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) ) . '</p>
+ <p>' . wp_kses( sprintf( ent2ncr( __( 'You can find more information on XML sitemaps at <a href="%s" target="_blank">sitemaps.org</a>', 'jetpack' ), 'http://sitemaps.org' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) ) . '</p>
</div>
<div id="content">
<table>
<tr>
- <th>' . esc_html__( 'URL', 'jetpack' ) . '</th>
- <th>' . esc_html__( 'Images', 'jetpack' ) . '</th>';
+ <th>' . esc_html( ent2ncr( __( 'URL', 'jetpack' ) ) ) . '</th>
+ <th>' . esc_html( ent2ncr( __( 'Images', 'jetpack' ) ) ) . '</th>';
if ( empty( $type ) ) :
-$xsl .= ' <th>' . esc_html__( 'Change Frequency', 'jetpack' ) . '</th>
- <th>' . esc_html__( 'Last Updated', 'jetpack' ) . '</th>';
+$xsl .= ' <th>' . esc_html( ent2ncr( __( 'Change Frequency', 'jetpack' ) ) ) . '</th>
+ <th>' . esc_html( ent2ncr( __( 'Last Updated', 'jetpack' ) ) ) . '</th>';
endif;
$xsl .= ' </tr>
<xsl:variable name="lower" select="\'abcdefghijklmnopqrstuvwxyz\'"/>
@@ -136,9 +136,9 @@ $xsl .= ' </tr>
</table>
</div>
<div id="footer">
- <p>' . wp_kses( sprintf( __( '<em>Generated</em> by <a href="%s" target="_blank">Jetpack for WordPress</a>', 'jetpack' ), 'https://jetpack.com' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) . '</p>
+ <p>' . wp_kses( sprintf( ent2ncr( __( '<em>Generated</em> by <a href="%s" target="_blank">Jetpack for WordPress</a>', 'jetpack' ) ), 'https://jetpack.com' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) . '</p>
</div>
</body>
</html>
</xsl:template>
-</xsl:stylesheet>'; \ No newline at end of file
+</xsl:stylesheet>';
diff --git a/plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.min.js b/plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.min.js
index e315891f..ee468c33 100644
--- a/plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.min.js
+++ b/plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.min.js
@@ -1,106 +1 @@
-/**
- * This file was unminified in Jetpack 4.0 to address an issue wherein ClamAV
- * was flagging the minified version of this file with a false-positive virus warning.
- *
- * This file will be re-minified in a future Jetpack release once ClamAV corrects their
- * incorrect definition.
- */
-
-( function( $ ) {
-
- /**
- * A function to help debouncing.
- */
- var debounce = function( func, wait ) {
-
- var timeout, args, context, timestamp;
-
- return function() {
-
- context = this;
- args = [].slice.call( arguments, 0 );
- timestamp = new Date();
-
- var later = function() {
-
- var last = ( new Date() ) - timestamp;
-
- if ( last < wait ) {
- timeout = setTimeout( later, wait - last );
- } else {
- timeout = null;
- func.apply( context, args );
- }
-
- };
-
- if ( ! timeout ) {
- timeout = setTimeout( later, wait );
- }
-
- };
-
- };
-
- /**
- * A function to resize videos.
- */
- function responsive_videos() {
-
- $( '.jetpack-video-wrapper' ).find( 'embed, iframe, object' ).each( function() {
- var video_element, video_width, video_height, video_ratio, video_wrapper, video_margin, container_width;
-
- video_element = $( this );
- video_margin = 0;
-
- if ( video_element.parents( '.jetpack-video-wrapper' ).prev( 'p' ).css( 'text-align' ) === 'center' ) {
- video_margin = '0 auto';
- }
-
- if ( ! video_element.attr( 'data-ratio' ) ) {
- video_element
- .attr( 'data-ratio', this.height / this.width )
- .attr( 'data-width', this.width )
- .attr( 'data-height', this.height )
- .css( {
- 'display' : 'block',
- 'margin' : video_margin
- } );
- }
-
- video_width = video_element.attr( 'data-width' );
- video_height = video_element.attr( 'data-height' );
- video_ratio = video_element.attr( 'data-ratio' );
- video_wrapper = video_element.parent();
- container_width = video_wrapper.width();
-
- if ( video_ratio === 'Infinity' ) {
- video_width = '100%';
- }
-
- video_element
- .removeAttr( 'height' )
- .removeAttr( 'width' );
-
- if ( video_width > container_width ) {
- video_element
- .width( container_width )
- .height( container_width * video_ratio );
- } else {
- video_element
- .width( video_width )
- .height( video_height );
- }
-
- } );
-
- }
-
- /**
- * Load responsive_videos().
- * Trigger resize to make sure responsive_videos() is loaded after IS.
- */
- $( window ).load( responsive_videos ).resize( debounce( responsive_videos, 100 ) ).trigger( 'resize' );
- $( document ).on( 'post-load', responsive_videos );
-
-} )( jQuery );
+!function(t){function a(){t(".jetpack-video-wrapper").find("embed, iframe, object").each(function(){var a,e,i,r,h,n,d;a=t(this),n=0,"center"===a.parents(".jetpack-video-wrapper").prev("p").css("text-align")&&(n="0 auto"),a.attr("data-ratio")||a.attr("data-ratio",this.height/this.width).attr("data-width",this.width).attr("data-height",this.height).css({display:"block",margin:n}),e=a.attr("data-width"),i=a.attr("data-height"),r=a.attr("data-ratio"),h=a.parent(),d=h.width(),"Infinity"===r&&(e="100%"),a.removeAttr("height").removeAttr("width"),e>d?a.width(d).height(d*r):a.width(e).height(i)})}var e=function(t,a){var e,i,r,h;return function(){r=this,i=[].slice.call(arguments,0),h=new Date;var n=function(){var d=new Date-h;a>d?e=setTimeout(n,a-d):(e=null,t.apply(r,i))};e||(e=setTimeout(n,a))}};t(window).load(a).resize(e(a,100)).trigger("resize"),t(document).on("post-load",a)}(jQuery);
diff --git a/plugins/jetpack/modules/videopress/js/editor-view.js b/plugins/jetpack/modules/videopress/js/editor-view.js
index c77f5b6a..9f64859f 100644
--- a/plugins/jetpack/modules/videopress/js/editor-view.js
+++ b/plugins/jetpack/modules/videopress/js/editor-view.js
@@ -1,6 +1,9 @@
/* global tinyMCE, vpEditorView */
(function( $, wp, vpEditorView ){
wp.mce = wp.mce || {};
+ if ( 'undefined' === typeof wp.mce.views ) {
+ return;
+ }
wp.mce.videopress_wp_view_renderer = {
shortcode_string : 'videopress',
shortcode_data : {},
diff --git a/plugins/jetpack/modules/widgets.php b/plugins/jetpack/modules/widgets.php
index 288b985b..2af7d166 100644
--- a/plugins/jetpack/modules/widgets.php
+++ b/plugins/jetpack/modules/widgets.php
@@ -62,6 +62,6 @@ jetpack_load_widgets();
* @since 4.0.0
*/
function jetpack_widgets_customizer_assets() {
- wp_enqueue_script( 'jetpack-customizer-widget-utils', plugins_url( '/widgets/customizer-utils.js', __FILE__ ), array( 'jquery' ) );
+ wp_enqueue_script( 'jetpack-customizer-widget-utils', plugins_url( '/widgets/customizer-utils.js', __FILE__ ), array( 'customize-base' ) );
}
add_action( 'customize_preview_init', 'jetpack_widgets_customizer_assets' ); \ No newline at end of file