diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2016-04-18 11:52:28 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2016-04-18 11:52:28 -0400 |
commit | 097e7d91b32dd6d27ea47e5d7cd8d6bdcf1e50a2 (patch) | |
tree | edf0e0c9fcd6ce7c922593a4df301d624e9faeb1 /plugins/jetpack/modules | |
parent | Update pluging wordpress-mobile-pack to 2.2.2 (diff) | |
download | blogs-gentoo-097e7d91b32dd6d27ea47e5d7cd8d6bdcf1e50a2.tar.gz blogs-gentoo-097e7d91b32dd6d27ea47e5d7cd8d6bdcf1e50a2.tar.bz2 blogs-gentoo-097e7d91b32dd6d27ea47e5d7cd8d6bdcf1e50a2.zip |
Update plugin jetpack to 3.9.6
Diffstat (limited to 'plugins/jetpack/modules')
71 files changed, 1806 insertions, 1230 deletions
diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.js b/plugins/jetpack/modules/carousel/jetpack-carousel.js index 95b6c4b0..a4b6aac4 100644 --- a/plugins/jetpack/modules/carousel/jetpack-carousel.js +++ b/plugins/jetpack/modules/carousel/jetpack-carousel.js @@ -86,7 +86,7 @@ jQuery(document).ready(function($) { buttons = $('<div class="jp-carousel-buttons">' + buttons + '</div>'); - caption = $('<h2></h2>'); + caption = $('<h2 itemprop="caption description"></h2>'); photo_info = $('<div class="jp-carousel-photo-info"></div>').append(caption); imageMeta = $('<div></div>') @@ -226,11 +226,14 @@ jQuery(document).ready(function($) { container = $('<div></div>') .addClass('jp-carousel-wrap') .addClass( 'jp-carousel-transitions' ); - if ( 'white' === jetpackCarouselStrings.background_color ) { container.addClass('jp-carousel-light'); } + container.attr('itemscope', ''); + + container.attr('itemtype', 'http://schema.org/ImageGallery'); + container.css({ 'position' : 'fixed', 'top' : 0, @@ -902,7 +905,7 @@ jQuery(document).ready(function($) { .css( 'width', '100%' ) .css( 'height', '100%' ); - var slide = $('<div class="jp-carousel-slide"></div>') + var slide = $('<div class="jp-carousel-slide" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"></div>') .hide() .css({ //'position' : 'fixed', @@ -987,7 +990,7 @@ jQuery(document).ready(function($) { if ( medium_width >= args.max_width || medium_height >= args.max_height ) { return args.medium_file; } - + if ( isPhotonUrl ) { // args.orig_file doesn't point to a Photon url, so in this case we use args.large_file // to return the photon url of the original image. @@ -1016,7 +1019,7 @@ jQuery(document).ready(function($) { if ( '9999' === size_parts[0] ) { size_parts[0] = '0'; } - + if ( '9999' === size_parts[1] ) { size_parts[1] = '0'; } @@ -1230,12 +1233,23 @@ jQuery(document).ready(function($) { if(!current || !current.data) { return false; } - var original = current.data('orig-file').replace(/\?.+$/, ''), - origSize = current.data('orig-size').split(','), - permalink = $( '<a>'+gallery.jp_carousel('format', {'text': jetpackCarouselStrings.download_original, 'replacements': origSize})+'</a>' ) - .addClass( 'jp-carousel-image-download' ) - .attr( 'href', original ) - .attr( 'target', '_blank' ); + var original, + origSize = current.data('orig-size').split(',' ), + imageLinkParser = document.createElement( 'a' ); + + imageLinkParser.href = current.data( 'src' ).replace( /\?.+$/, '' ); + + // Is this a Photon URL? + if ( imageLinkParser.hostname.match( /^i[\d]{1}.wp.com$/i ) !== null ) { + original = imageLinkParser.href; + } else { + original = current.data('orig-file').replace(/\?.+$/, ''); + } + + var permalink = $( '<a>'+gallery.jp_carousel('format', {'text': jetpackCarouselStrings.download_original, 'replacements': origSize})+'</a>' ) + .addClass( 'jp-carousel-image-download' ) + .attr( 'href', original ) + .attr( 'target', '_blank' ); // Update (replace) the content of the anchor $( 'div.jp-carousel-image-meta a.jp-carousel-image-download' ).replaceWith( permalink ); @@ -1436,9 +1450,9 @@ jQuery(document).ready(function($) { } ); if ( ! slide.data( 'preview-image' ) || ( slide.data( 'thumb-size' ) && slide.width() > slide.data( 'thumb-size' ).width ) ) { - image.attr( 'src', image.closest( '.jp-carousel-slide' ).data( 'src' ) ); + image.attr( 'src', image.closest( '.jp-carousel-slide' ).data( 'src' ) ).attr('itemprop', 'image'); } else { - image.attr( 'src', slide.data( 'preview-image' ) ); + image.attr( 'src', slide.data( 'preview-image' ) ).attr('itemprop', 'image'); } image.data( 'loaded', 1 ); diff --git a/plugins/jetpack/modules/comments/comments.php b/plugins/jetpack/modules/comments/comments.php index 493c749b..5330cb7a 100644 --- a/plugins/jetpack/modules/comments/comments.php +++ b/plugins/jetpack/modules/comments/comments.php @@ -279,8 +279,7 @@ class Jetpack_Comments extends Highlander_Comments_Base { } $params['sig'] = $signature; - $url_origin = set_url_scheme( 'http://jetpack.wordpress.com' ); - $url = "{$url_origin}/jetpack-comment/?" . http_build_query( $params ); + $url = "https://jetpack.wordpress.com/jetpack-comment/?" . http_build_query( $params ); $url = "{$url}#parent=" . urlencode( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) ); $this->signed_url = $url; $height = $params['comment_registration'] || is_user_logged_in() ? '315' : '430'; // Iframe can be shorter if we're not allowing guest commenting @@ -295,9 +294,9 @@ class Jetpack_Comments extends Highlander_Comments_Base { <div id="respond" class="comment-respond"> <h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( esc_html( $params['greeting'] ), esc_html( $params['greeting_reply'] ) ); ?> <small><?php cancel_comment_reply_link( esc_html__( 'Cancel reply' , 'jetpack') ); ?></small></h3> - <div id="commentform" class="comment-form"> - <iframe src="<?php echo esc_url( $url ); ?>" allowtransparency="<?php echo $transparent; ?>" style="width:100%; height: <?php echo $height; ?>px;border:0px;" frameBorder="0" scrolling="no" name="jetpack_remote_comment" id="jetpack_remote_comment"></iframe> - </div> + <form id="commentform" class="comment-form"> + <iframe src="<?php echo esc_url( $url ); ?>" allowtransparency="<?php echo $transparent; ?>" style="width:100%; height: <?php echo $height; ?>px;border:0;" frameBorder="0" scrolling="no" name="jetpack_remote_comment" id="jetpack_remote_comment"></iframe> + </form> </div> <?php // Below is required for comment reply JS to work ?> @@ -313,7 +312,7 @@ class Jetpack_Comments extends Highlander_Comments_Base { * @since JetpackComments (1.4) */ public function watch_comment_parent() { - $url_origin = set_url_scheme( 'http://jetpack.wordpress.com' ); + $url_origin = 'https://jetpack.wordpress.com'; ?> <!--[if IE]> diff --git a/plugins/jetpack/modules/contact-form/grunion-contact-form.php b/plugins/jetpack/modules/contact-form/grunion-contact-form.php index b8161e97..faa8fca1 100644 --- a/plugins/jetpack/modules/contact-form/grunion-contact-form.php +++ b/plugins/jetpack/modules/contact-form/grunion-contact-form.php @@ -33,12 +33,32 @@ class Grunion_Contact_Form_Plugin { if ( !$instance ) { $instance = new Grunion_Contact_Form_Plugin; + + // Schedule our daily cleanup + add_action( 'wp_scheduled_delete', array( $instance, 'daily_akismet_meta_cleanup' ) ); } return $instance; } /** + * Runs daily to clean up spam detection metadata after 15 days. Keeps your DB squeaky clean. + */ + public function daily_akismet_meta_cleanup() { + global $wpdb; + + $feedback_ids = $wpdb->get_col( "SELECT p.ID FROM {$wpdb->posts} as p INNER JOIN {$wpdb->postmeta} as m on m.post_id = p.ID WHERE p.post_type = 'feedback' AND m.meta_key = '_feedback_akismet_values' > p.post_date_gmt LIMIT 10000" ); + + if ( empty( $feedback_ids ) ) { + return; + } + + foreach ( $feedback_ids as $feedback_id ) { + delete_post_meta( $feedback_id, '_feedback_akismet_values' ); + } + } + + /** * Strips HTML tags from input. Output is NOT HTML safe. * * @param mixed $data_with_tags @@ -107,6 +127,7 @@ class Grunion_Contact_Form_Plugin { 'rewrite' => FALSE, 'query_var' => FALSE, 'capability_type' => 'page', + 'show_in_rest' => true, 'capabilities' => array( 'create_posts' => false, 'publish_posts' => 'publish_pages', @@ -391,11 +412,22 @@ class Grunion_Contact_Form_Plugin { $form['referrer'] = $_SERVER['HTTP_REFERER']; $form['blog'] = get_option( 'home' ); - $ignore = array( 'HTTP_COOKIE' ); - - foreach ( $_SERVER as $k => $value ) - if ( !in_array( $k, $ignore ) && is_string( $value ) ) - $form["$k"] = $value; + foreach ( $_SERVER as $key => $value ) { + if ( ! is_string( $value ) ) { + continue; + } + if ( in_array( $key, array( 'HTTP_COOKIE', 'HTTP_COOKIE2', 'HTTP_USER_AGENT', 'HTTP_REFERER' ) ) ) { + // We don't care about cookies, and the UA and Referrer were caught above. + continue; + } elseif ( in_array( $key, array( 'REMOTE_ADDR', 'REQUEST_URI', 'DOCUMENT_URI' ) ) ) { + // All three of these are relevant indicators and should be passed along. + $form[ $key ] = $value; + } elseif ( wp_startswith( $key, 'HTTP_' ) ) { + // Any other HTTP header indicators. + // `wp_startswith()` is a wpcom helper function and is included in Jetpack via `functions.compat.php` + $form[ $key ] = $value; + } + } return $form; } @@ -623,19 +655,6 @@ class Grunion_Contact_Form_Plugin { foreach ( $post_ids as $post_id ) { /** - * Fetch post meta data. - */ - $post_meta_data = $this->get_post_meta_for_csv_export( $post_id ); - - /** - * If `$post_meta_data` is not an array or if it is empty, then there is no - * feedback to work with. Skip it. - */ - if ( ! is_array( $post_meta_data ) || empty( $post_meta_data ) ) { - continue; - } - - /** * Fetch post main data, because we need the subject and author data for the feedback form. */ $post_real_data = $this->get_parsed_field_contents_of_post( $post_id ); @@ -663,6 +682,19 @@ class Grunion_Contact_Form_Plugin { $mapped_fields = $this->map_parsed_field_contents_of_post_to_field_names( $post_real_data ); /** + * Fetch post meta data. + */ + $post_meta_data = $this->get_post_meta_for_csv_export( $post_id ); + + /** + * If `$post_meta_data` is not an array or if it is empty, then there is no + * extra feedback to work with. Create an empty array. + */ + if ( ! is_array( $post_meta_data ) || empty( $post_meta_data ) ) { + $post_meta_data = array(); + } + + /** * Prepend the feedback subject to the list of fields. */ $post_meta_data = array_merge( @@ -1758,6 +1790,12 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode { foreach ( array_merge( $field_ids['all'], $field_ids['extra'] ) as $field_id ) { $field = $this->fields[$field_id]; + // Skip any fields that are just a choice from a pre-defined list. They wouldn't have any value + // from a spam-filtering point of view. + if ( in_array( $field->get_attribute( 'type' ), array( 'select', 'checkbox', 'checkbox-multiple', 'radio' ) ) ) { + continue; + } + // Normalize the label into a slug. $field_slug = trim( // Strip all leading/trailing dashes. preg_replace( // Normalize everything to a-z0-9_- @@ -1867,7 +1905,10 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode { remove_filter( 'wp_insert_post_data', array( $plugin, 'insert_feedback_filter' ), 10, 2 ); update_post_meta( $post_id, '_feedback_extra_fields', $this->addslashes_deep( $extra_values ) ); - update_post_meta( $post_id, '_feedback_akismet_values', $this->addslashes_deep( $akismet_values ) ); + + if ( Jetpack::is_plugin_active( 'akismet/akismet.php' ) ) { + update_post_meta( $post_id, '_feedback_akismet_values', $this->addslashes_deep( $akismet_values ) ); + } $message = self::get_compiled_form( $post_id, $this ); @@ -1893,7 +1934,7 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode { array_push( $message, __( 'Sent by an unverified visitor to your site.', 'jetpack' ) ); } - $message = join( $message, "" ); + $message = join( $message, "\n" ); /** * Filters the message sent via email after a successfull form submission. * diff --git a/plugins/jetpack/modules/contact-form/js/grunion-frontend.js b/plugins/jetpack/modules/contact-form/js/grunion-frontend.js index c87c1640..25f0e911 100644 --- a/plugins/jetpack/modules/contact-form/js/grunion-frontend.js +++ b/plugins/jetpack/modules/contact-form/js/grunion-frontend.js @@ -1,3 +1,5 @@ jQuery( function ( $ ) { - $( '.contact-form input[type="date"]' ).datepicker( { dateFormat : 'yy-mm-dd' } ); + if ( 'function' === typeof $.fn.datepicker ) { + $( '.contact-form input[type="date"]' ).datepicker( { dateFormat : 'yy-mm-dd' } ); + } } );
\ No newline at end of file diff --git a/plugins/jetpack/modules/custom-content-types.php b/plugins/jetpack/modules/custom-content-types.php index df4eabd4..af615b10 100644 --- a/plugins/jetpack/modules/custom-content-types.php +++ b/plugins/jetpack/modules/custom-content-types.php @@ -44,7 +44,7 @@ function jetpack_cpt_section_callback() { ?> <p> <?php esc_html_e( 'Use these settings to display different types of content on your site.', 'jetpack' ); ?> - <a target="_blank" href="http://jetpack.me/support/custom-content-types/"><?php esc_html_e( 'Learn More', 'jetpack' ); ?></a> + <a target="_blank" href="http://jetpack.com/support/custom-content-types/"><?php esc_html_e( 'Learn More', 'jetpack' ); ?></a> </p> <?php } diff --git a/plugins/jetpack/modules/custom-css/custom-css.php b/plugins/jetpack/modules/custom-css/custom-css.php index bcd66293..999b7f3e 100644 --- a/plugins/jetpack/modules/custom-css/custom-css.php +++ b/plugins/jetpack/modules/custom-css/custom-css.php @@ -1053,7 +1053,7 @@ class Jetpack_Custom_CSS { * * @param string $url Custom CSS limited width's support doc URL. */ - apply_filters( 'safecss_limit_width_link', 'http://jetpack.me/support/custom-css/#limited-width' ) + apply_filters( 'safecss_limit_width_link', 'http://jetpack.com/support/custom-css/#limited-width' ) ); ?> diff --git a/plugins/jetpack/modules/custom-post-types/comics.php b/plugins/jetpack/modules/custom-post-types/comics.php index 97e1a980..dfc52b45 100644 --- a/plugins/jetpack/modules/custom-post-types/comics.php +++ b/plugins/jetpack/modules/custom-post-types/comics.php @@ -257,6 +257,7 @@ class Jetpack_Comic { 'map_meta_cap' => true, 'has_archive' => true, 'query_var' => 'comic', + 'show_in_rest' => true, ) ); } diff --git a/plugins/jetpack/modules/custom-post-types/js/many-items.js b/plugins/jetpack/modules/custom-post-types/js/many-items.js index 3da1bc33..3483f6cd 100644 --- a/plugins/jetpack/modules/custom-post-types/js/many-items.js +++ b/plugins/jetpack/modules/custom-post-types/js/many-items.js @@ -97,7 +97,7 @@ var tbody = this.find( 'tbody:last' ), row = tbody.find( 'tr:first' ).clone(); - $( row ).find( 'input' ).attr( 'value', '' ); + $( row ).find( 'input, textarea' ).val( '' ); $( row ).appendTo( tbody ); }; diff --git a/plugins/jetpack/modules/custom-post-types/portfolios.php b/plugins/jetpack/modules/custom-post-types/portfolios.php index 1c299341..21ef1488 100644 --- a/plugins/jetpack/modules/custom-post-types/portfolios.php +++ b/plugins/jetpack/modules/custom-post-types/portfolios.php @@ -263,6 +263,7 @@ class Jetpack_Portfolio { 'taxonomies' => array( self::CUSTOM_TAXONOMY_TYPE, self::CUSTOM_TAXONOMY_TAG ), 'has_archive' => true, 'query_var' => 'portfolio', + 'show_in_rest' => true, ) ); register_taxonomy( self::CUSTOM_TAXONOMY_TYPE, self::CUSTOM_POST_TYPE, array( diff --git a/plugins/jetpack/modules/custom-post-types/testimonial.php b/plugins/jetpack/modules/custom-post-types/testimonial.php index 780ba0be..bca9fdbb 100644 --- a/plugins/jetpack/modules/custom-post-types/testimonial.php +++ b/plugins/jetpack/modules/custom-post-types/testimonial.php @@ -327,6 +327,7 @@ class Jetpack_Testimonial { 'map_meta_cap' => true, 'has_archive' => true, 'query_var' => 'testimonial', + 'show_in_rest' => true, ) ); } diff --git a/plugins/jetpack/modules/infinite-scroll/infinity.js b/plugins/jetpack/modules/infinite-scroll/infinity.js index e4095fa2..b19817db 100644 --- a/plugins/jetpack/modules/infinite-scroll/infinity.js +++ b/plugins/jetpack/modules/infinite-scroll/infinity.js @@ -186,7 +186,7 @@ Scroller.prototype.thefooter = function() { */ Scroller.prototype.refresh = function() { var self = this, - query, jqxhr, load, loader, color; + query, jqxhr, load, loader, color, customized; // If we're disabled, ready, or don't pass the check, bail. if ( this.disabled || ! this.ready || ! this.check() ) @@ -214,6 +214,20 @@ Scroller.prototype.refresh = function() { action: 'infinite_scroll' }, this.query() ); + // Inject Customizer state. + if ( 'undefined' !== typeof wp && wp.customize && wp.customize.settings.theme ) { + customized = {}; + query.wp_customize = 'on'; + query.theme = wp.customize.settings.theme.stylesheet; + wp.customize.each( function( setting ) { + if ( setting._dirty ) { + customized[ setting.id ] = setting(); + } + } ); + query.customized = JSON.stringify( customized ); + query.nonce = wp.customize.settings.nonce.preview; + } + // Fire the ajax request. jqxhr = $.post( infiniteScroll.settings.ajaxurl, query ); @@ -234,13 +248,9 @@ Scroller.prototype.refresh = function() { } // Check for and parse our response. - if ( ! response ) - return; - - response = $.parseJSON( response ); - - if ( ! response || ! response.type ) + if ( ! response || ! response.type ) { return; + } // If there are no remaining posts... if ( response.type == 'empty' ) { @@ -654,6 +664,54 @@ $( document ).ready( function() { } , 250 ); }); } + + // Integrate with Selective Refresh in the Customizer. + if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) { + + /** + * Handle rendering of selective refresh partials. + * + * Make sure that when a partial is rendered, the Jetpack post-load event + * will be triggered so that any dynamic elements will be re-constructed, + * such as ME.js elements, Photon replacements, social sharing, and more. + * Note that this is applying here not strictly to posts being loaded. + * If a widget contains a ME.js element and it is previewed via selective + * refresh, the post-load would get triggered allowing any dynamic elements + * therein to also be re-constructed. + * + * @param {wp.customize.selectiveRefresh.Placement} placement + */ + wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { + var content; + if ( 'string' === typeof placement.addedContent ) { + content = placement.addedContent; + } else if ( placement.container ) { + content = $( placement.container ).html(); + } + + if ( content ) { + $( document.body ).trigger( 'post-load', { html: content } ); + } + } ); + + /* + * Add partials for posts added via infinite scroll. + * + * This is unnecessary when MutationObserver is supported by the browser + * since then this will be handled by Selective Refresh in core. + */ + if ( 'undefined' === typeof MutationObserver ) { + $( document.body ).on( 'post-load', function( e, response ) { + var rootElement = null; + if ( response.html && -1 !== response.html.indexOf( 'data-customize-partial' ) ) { + if ( infiniteScroll.settings.id ) { + rootElement = $( '#' + infiniteScroll.settings.id ); + } + wp.customize.selectiveRefresh.addPartials( rootElement ); + } + } ); + } + } }); diff --git a/plugins/jetpack/modules/infinite-scroll/infinity.php b/plugins/jetpack/modules/infinite-scroll/infinity.php index 2c00f448..f98d8a75 100644 --- a/plugins/jetpack/modules/infinite-scroll/infinity.php +++ b/plugins/jetpack/modules/infinite-scroll/infinity.php @@ -229,6 +229,14 @@ class The_Neverending_Home_Page { } } + // If IS is set to click, and if the site owner changed posts_per_page, let's use that + if ( + 'click' == $settings['type'] + && ( '10' !== get_option( 'posts_per_page' ) ) + ) { + $settings['posts_per_page'] = (int) get_option( 'posts_per_page' ); + } + // Force display of the click handler and attendant bits when the type isn't `click` if ( 'click' !== $settings['type'] ) { $settings['click_handle'] = true; @@ -247,7 +255,8 @@ class The_Neverending_Home_Page { self::$settings = apply_filters( 'infinite_scroll_settings', $settings ); } - return (object) self::$settings; + /** This filter is documented in modules/infinite-scroll/infinity.php */ + return (object) apply_filters( 'infinite_scroll_settings', self::$settings ); } /** @@ -367,7 +376,7 @@ class The_Neverending_Home_Page { add_filter( 'body_class', array( $this, 'body_class' ) ); // Add our scripts. - wp_enqueue_script( 'the-neverending-homepage', plugins_url( 'infinity.js', __FILE__ ), array( 'jquery' ), 20141016, true ); + wp_enqueue_script( 'the-neverending-homepage', plugins_url( 'infinity.js', __FILE__ ), array( 'jquery' ), '3.10', true ); // Add our default styles. wp_enqueue_style( 'the-neverending-homepage', plugins_url( 'infinity.css', __FILE__ ), array(), '20140422' ); @@ -1098,6 +1107,7 @@ class The_Neverending_Home_Page { * @return string or null */ function query() { + global $wp_customize; if ( ! isset( $_REQUEST['page'] ) || ! current_theme_supports( 'infinite-scroll' ) ) die; @@ -1248,7 +1258,11 @@ class The_Neverending_Home_Page { $results['type'] = 'empty'; } - echo wp_json_encode( + if ( is_customize_preview() ) { + $wp_customize->remove_preview_signature(); + } + + wp_send_json( /** * Filter the Infinite Scroll results. * @@ -1262,7 +1276,6 @@ class The_Neverending_Home_Page { */ apply_filters( 'infinite_scroll_results', $results, $query_args, self::wp_query() ) ); - die; } /** @@ -1528,149 +1541,3 @@ if ( The_Neverending_Home_Page::got_infinity() ) { // Don't load the admin bar when doing the AJAX response. show_admin_bar( false ); } - -/** - * Include the wp_json_encode functions for pre-wordpress-4.1 - */ - -if ( ! function_exists( 'wp_json_encode' ) ) : - /** - * Encode a variable into JSON, with some sanity checks. - * - * @since 4.1.0 - * - * @param mixed $data Variable (usually an array or object) to encode as JSON. - * @param int $options Optional. Options to be passed to json_encode(). Default 0. - * @param int $depth Optional. Maximum depth to walk through $data. Must be - * greater than 0. Default 512. - * @return bool|string The JSON encoded string, or false if it cannot be encoded. - */ - function wp_json_encode( $data, $options = 0, $depth = 512 ) { - /* - * json_encode() has had extra params added over the years. - * $options was added in 5.3, and $depth in 5.5. - * We need to make sure we call it with the correct arguments. - */ - if ( version_compare( PHP_VERSION, '5.5', '>=' ) ) { - $args = array( $data, $options, $depth ); - } elseif ( version_compare( PHP_VERSION, '5.3', '>=' ) ) { - $args = array( $data, $options ); - } else { - $args = array( $data ); - } - - $json = call_user_func_array( 'json_encode', $args ); - - // If json_encode() was successful, no need to do more sanity checking. - // ... unless we're in an old version of PHP, and json_encode() returned - // a string containing 'null'. Then we need to do more sanity checking. - if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) { - return $json; - } - - try { - $args[0] = _wp_json_sanity_check( $data, $depth ); - } catch ( Exception $e ) { - return false; - } - - return call_user_func_array( 'json_encode', $args ); - } -endif; - -if ( ! function_exists( '_wp_json_sanity_check' ) ) : - /** - * Perform sanity checks on data that shall be encoded to JSON. - * - * @see wp_json_encode() - * - * @since 4.1.0 - * @access private - * @internal - * - * @param mixed $data Variable (usually an array or object) to encode as JSON. - * @param int $depth Maximum depth to walk through $data. Must be greater than 0. - * @return mixed The sanitized data that shall be encoded to JSON. - */ - function _wp_json_sanity_check( $data, $depth ) { - if ( $depth < 0 ) { - throw new Exception( 'Reached depth limit' ); - } - - if ( is_array( $data ) ) { - $output = array(); - foreach ( $data as $id => $el ) { - // Don't forget to sanitize the ID! - if ( is_string( $id ) ) { - $clean_id = _wp_json_convert_string( $id ); - } else { - $clean_id = $id; - } - - // Check the element type, so that we're only recursing if we really have to. - if ( is_array( $el ) || is_object( $el ) ) { - $output[ $clean_id ] = _wp_json_sanity_check( $el, $depth - 1 ); - } elseif ( is_string( $el ) ) { - $output[ $clean_id ] = _wp_json_convert_string( $el ); - } else { - $output[ $clean_id ] = $el; - } - } - } elseif ( is_object( $data ) ) { - $output = new stdClass; - foreach ( $data as $id => $el ) { - if ( is_string( $id ) ) { - $clean_id = _wp_json_convert_string( $id ); - } else { - $clean_id = $id; - } - - if ( is_array( $el ) || is_object( $el ) ) { - $output->$clean_id = _wp_json_sanity_check( $el, $depth - 1 ); - } elseif ( is_string( $el ) ) { - $output->$clean_id = _wp_json_convert_string( $el ); - } else { - $output->$clean_id = $el; - } - } - } elseif ( is_string( $data ) ) { - return _wp_json_convert_string( $data ); - } else { - return $data; - } - - return $output; - } -endif; - -if ( ! function_exists( '_wp_json_convert_string' ) ) : - /** - * Convert a string to UTF-8, so that it can be safely encoded to JSON. - * - * @see _wp_json_sanity_check() - * - * @since 4.1.0 - * @access private - * @internal - * - * @param string $string The string which is to be converted. - * @return string The checked string. - */ - function _wp_json_convert_string( $string ) { - static $use_mb = null; - if ( is_null( $use_mb ) ) { - $use_mb = function_exists( 'mb_convert_encoding' ); - } - - if ( $use_mb ) { - $encoding = mb_detect_encoding( $string, mb_detect_order(), true ); - if ( $encoding ) { - return mb_convert_encoding( $string, 'UTF-8', $encoding ); - } else { - return mb_convert_encoding( $string, 'UTF-8', 'UTF-8' ); - } - } else { - return wp_check_invalid_utf8( $string, true ); - } - } -endif; diff --git a/plugins/jetpack/modules/latex.php b/plugins/jetpack/modules/latex.php index cec2065c..41567b4b 100644 --- a/plugins/jetpack/modules/latex.php +++ b/plugins/jetpack/modules/latex.php @@ -21,6 +21,8 @@ */ function latex_markup( $content ) { + $textarr = wp_html_split( $content ); + $regex = '% \$latex(?:=\s*|\s+) ((?: @@ -30,7 +32,20 @@ function latex_markup( $content ) { )+) (?<!\\\\)\$ # Dollar preceded by zero slashes %ix'; - return preg_replace_callback( $regex, 'latex_src', $content ); + + foreach ( $textarr as &$element ) { + if ( '' == $element || '<' === $element[0] ) { + continue; + } + + if ( false === stripos( $element, '$latex' ) ) { + continue; + } + + $element = preg_replace_callback( $regex, 'latex_src', $element ); + } + + return implode( '', $textarr ); } function latex_src( $matches ) { diff --git a/plugins/jetpack/modules/manage/confirm-admin.php b/plugins/jetpack/modules/manage/confirm-admin.php index 4020e6b1..da0dce95 100644 --- a/plugins/jetpack/modules/manage/confirm-admin.php +++ b/plugins/jetpack/modules/manage/confirm-admin.php @@ -93,12 +93,12 @@ switch( $section ) { </div> <h1 class="manage__title"><span class="genericon genericon-checkmark"></span><?php esc_html_e( __( 'Jetpack Manage Enabled', 'jetpack' ) ); ?></h1> <p class="manage__description"> - <?php esc_html_e( $description, 'jetpack' ); ?> + <?php echo esc_html( $description ); ?> </p> <p class="manage__description"> <a class="manage__link" href="<?php echo esc_url( $link ); ?>"> <span class="genericon genericon-previous"></span> - <?php esc_html_e( $link_title, 'jetpack' ); ?> + <?php echo esc_html( $link_title ); ?> </a> </p> </div> diff --git a/plugins/jetpack/modules/minileven.php b/plugins/jetpack/modules/minileven.php index 909ec7c1..2da8345a 100644 --- a/plugins/jetpack/modules/minileven.php +++ b/plugins/jetpack/modules/minileven.php @@ -100,8 +100,8 @@ function minileven_configuration_screen() { </form> <h3><?php _e( 'Mobile Apps', 'jetpack' ); ?></h3> <p><?php _e( 'Take WordPress with you.', 'jetpack' ); ?></p> - <a href="http://wordpress.org/extend/mobile/"><img src="<?php echo plugin_dir_url( __FILE__ ); ?>/minileven/images/wp-app-devices.png" width="332" height="73" /></a> - <p><?php printf( __( 'We have apps for <a href="%s">iOS (iPhone, iPad, iPod Touch)</a>, <a href="%s">Android</a>, <a href="%s">BlackBerry</a>, and <a href="%s">more</a>!', 'jetpack' ), 'http://ios.wordpress.org/', 'http://android.wordpress.org/', 'http://blackberry.wordpress.org/', 'http://wordpress.org/mobile/' ); ?></p> + <a href="https://wordpress.org/mobile/"><img src="<?php echo plugin_dir_url( __FILE__ ); ?>/minileven/images/wp-app-devices.png" width="332" height="73" /></a> + <p><?php printf( __( 'We have apps for <a href="%s">iOS (iPhone, iPad, iPod Touch) and Android</a>!', 'jetpack' ), 'https://apps.wordpress.org/' ); ?></p> <?php } diff --git a/plugins/jetpack/modules/module-headings.php b/plugins/jetpack/modules/module-headings.php index 9c6821aa..6dc2e8ae 100644 --- a/plugins/jetpack/modules/module-headings.php +++ b/plugins/jetpack/modules/module-headings.php @@ -1,249 +1,308 @@ -<?php return; +<?php +// Do not edit this file. It's generated by jetpack/tools/build-module-headings-translations.php /** - * This file exists soley to store the module - * header translation strings, that exist ordinarily - * in comments on files in this directory. + * For a given module, return an array with translated name, description and recommended description. * - * It is never included anywhere, and is used for parsing. + * @param string $key Module file name without .php + * + * @return array */ -
-// modules/after-the-deadline.php
-_x( 'Spelling and Grammar', 'Module Name', 'jetpack' );
-_x( 'Check your spelling, style, and grammar with the After the Deadline proofreading service.', 'Module Description', 'jetpack' );
-
-// modules/carousel.php
-_x( 'Carousel', 'Module Name', 'jetpack' );
-_x( 'Transform standard image galleries into full-screen slideshows.', 'Module Description', 'jetpack' );
-_x( 'Brings your photos and images to life as full-size, easily navigable galleries.', 'Jumpstart Description', 'jetpack' );
-
-// modules/comments.php
-_x( 'Comments', 'Module Name', 'jetpack' );
-_x( 'Let readers comment with WordPress.com, Twitter, Facebook, or Google+ accounts.', 'Module Description', 'jetpack' );
-
-// modules/contact-form.php
-_x( 'Contact Form', 'Module Name', 'jetpack' );
-_x( 'Insert a contact form anywhere on your site.', 'Module Description', 'jetpack' );
-_x( 'Adds a button to your post and page editors, allowing you to build simple forms to help visitors stay in touch.', 'Jumpstart Description', 'jetpack' );
-
-// modules/custom-content-types.php
-_x( 'Custom Content Types', 'Module Name', 'jetpack' );
-_x( 'Organize and display different types of content on your site, separate from posts and pages.', 'Module Description', 'jetpack' );
-
-// modules/custom-css.php
-_x( 'Custom CSS', 'Module Name', 'jetpack' );
-_x( 'Customize your site’s CSS without modifying your theme.', 'Module Description', 'jetpack' );
-
-// modules/enhanced-distribution.php
-_x( 'Enhanced Distribution', 'Module Name', 'jetpack' );
-_x( 'Increase reach and traffic.', 'Module Description', 'jetpack' );
-
-// modules/gravatar-hovercards.php
-_x( 'Gravatar Hovercards', 'Module Name', 'jetpack' );
-_x( 'Enable pop-up business cards over commenters’ Gravatars.', 'Module Description', 'jetpack' );
-_x( 'Let commenters link their profiles to their Gravatar accounts, making it easy for your visitors to learn more about your community.', 'Jumpstart Description', 'jetpack' );
-
-// modules/infinite-scroll.php
-_x( 'Infinite Scroll', 'Module Name', 'jetpack' );
-_x( 'Add support for infinite scroll to your theme.', 'Module Description', 'jetpack' );
-
-// modules/json-api.php
-_x( 'JSON API', 'Module Name', 'jetpack' );
-_x( 'Allow applications to securely access your content through the cloud.', 'Module Description', 'jetpack' );
-
-// modules/latex.php
-_x( 'Beautiful Math', 'Module Name', 'jetpack' );
-_x( 'Use LaTeX markup language in posts and pages for complex equations and other geekery.', 'Module Description', 'jetpack' );
-
-// modules/likes.php
-_x( 'Likes', 'Module Name', 'jetpack' );
-_x( 'Give visitors an easy way to show their appreciation for your content.', 'Module Description', 'jetpack' );
-
-// modules/manage.php
-_x( 'Manage', 'Module Name', 'jetpack' );
-_x( 'Manage all your sites from a centralized place, https://wordpress.com/sites.', 'Module Description', 'jetpack' );
-_x( 'Helps you remotely manage plugins, turn on automated updates, and more from <a href="https://wordpress.com/plugins/" target="_blank">wordpress.com</a>.', 'Jumpstart Description', 'jetpack' );
-
-// modules/markdown.php
-_x( 'Markdown', 'Module Name', 'jetpack' );
-_x( 'Write posts or pages in plain-text Markdown syntax.', 'Module Description', 'jetpack' );
-
-// modules/minileven.php
-_x( 'Mobile Theme', 'Module Name', 'jetpack' );
-_x( 'Optimize your site with a mobile-friendly theme for smartphones.', 'Module Description', 'jetpack' );
-
-// modules/monitor.php
-_x( 'Monitor', 'Module Name', 'jetpack' );
-_x( 'Reports on site downtime.', 'Module Description', 'jetpack' );
-
-// modules/notes.php
-_x( 'Notifications', 'Module Name', 'jetpack' );
-_x( 'Receive notification of site activity via the admin toolbar and your Mobile devices.', 'Module Description', 'jetpack' );
-
-// modules/omnisearch.php
-_x( 'Omnisearch', 'Module Name', 'jetpack' );
-_x( 'Search your entire database from a single field in your Dashboard.', 'Module Description', 'jetpack' );
-
-// modules/photon.php
-_x( 'Photon', 'Module Name', 'jetpack' );
-_x( 'Speed up images and photos.', 'Module Description', 'jetpack' );
-_x( 'Mirrors and serves your images from our free and fast image CDN, improving your site’s performance with no additional load on your servers.', 'Jumpstart Description', 'jetpack' );
-
-// modules/post-by-email.php
-_x( 'Post by Email', 'Module Name', 'jetpack' );
-_x( 'Publish posts by email, using any device and email client.', 'Module Description', 'jetpack' );
-
-// modules/protect.php
-_x( 'Protect', 'Module Name', 'jetpack' );
-_x( 'Prevent brute force attacks.', 'Module Description', 'jetpack' );
-
-// modules/publicize.php
-_x( 'Publicize', 'Module Name', 'jetpack' );
-_x( 'Automatically promote content.', 'Module Description', 'jetpack' );
-
-// modules/related-posts.php
-_x( 'Related Posts', 'Module Name', 'jetpack' );
-_x( 'Display similar content.', 'Module Description', 'jetpack' );
-_x( 'Keep visitors engaged on your blog by highlighting relevant and new content at the bottom of each published post.', 'Jumpstart Description', 'jetpack' );
-
-// modules/sharedaddy.php
-_x( 'Sharing', 'Module Name', 'jetpack' );
-_x( 'Visitors can share your content.', 'Module Description', 'jetpack' );
-_x( 'Twitter, Facebook and Google+ buttons at the bottom of each post, making it easy for visitors to share your content.', 'Jumpstart Description', 'jetpack' );
-
-// modules/shortcodes.php
-_x( 'Shortcode Embeds', 'Module Name', 'jetpack' );
-_x( 'Embed content from YouTube, Vimeo, SlideShare, and more, no coding necessary.', 'Module Description', 'jetpack' );
-
-// modules/shortlinks.php
-_x( 'WP.me Shortlinks', 'Module Name', 'jetpack' );
-_x( 'Enable WP.me-powered shortlinks for all posts and pages.', 'Module Description', 'jetpack' );
-
-// modules/site-icon.php
-_x( 'Site Icon', 'Module Name', 'jetpack' );
-_x( 'Add a site icon to your site.', 'Module Description', 'jetpack' );
-
-// modules/sitemaps.php
-_x( 'Sitemaps', 'Module Name', 'jetpack' );
-_x( 'Creates sitemaps to allow your site to be easily indexed by search engines.', 'Module Description', 'jetpack' );
-
-// modules/sso.php
-_x( 'Single Sign On', 'Module Name', 'jetpack' );
-_x( 'Secure user authentication.', 'Module Description', 'jetpack' );
-_x( 'Lets you log in to all your Jetpack-enabled sites with one click using your WordPress.com account.', 'Jumpstart Description', 'jetpack' );
-
-// modules/stats.php
-_x( 'Site Stats', 'Module Name', 'jetpack' );
-_x( 'Collect traffic stats and insights.', 'Module Description', 'jetpack' );
-
-// modules/subscriptions.php
-_x( 'Subscriptions', 'Module Name', 'jetpack' );
-_x( 'Allow users to subscribe to your posts and comments and receive notifications via email.', 'Module Description', 'jetpack' );
-_x( 'Give visitors two easy subscription options — while commenting, or via a separate email subscription widget you can display.', 'Jumpstart Description', 'jetpack' );
-
-// modules/tiled-gallery.php
-_x( 'Tiled Galleries', 'Module Name', 'jetpack' );
-_x( 'Display your image galleries in a variety of sleek, graphic arrangements.', 'Module Description', 'jetpack' );
-
-// modules/vaultpress.php
-_x( 'Data Backups', 'Module Name', 'jetpack' );
-_x( 'Daily or real-time backups.', 'Module Description', 'jetpack' );
-
-// modules/verification-tools.php
-_x( 'Site Verification', 'Module Name', 'jetpack' );
-_x( 'Verify your site or domain with Google Search Console, Pinterest, and others.', 'Module Description', 'jetpack' );
-
-// modules/videopress.php
-_x( 'VideoPress', 'Module Name', 'jetpack' );
-_x( 'Upload and embed videos right on your site. (Subscription required.)', 'Module Description', 'jetpack' );
-
-// modules/widget-visibility.php
-_x( 'Widget Visibility', 'Module Name', 'jetpack' );
-_x( 'Specify which widgets appear on which pages of your site.', 'Module Description', 'jetpack' );
-
-// modules/widgets.php
-_x( 'Extra Sidebar Widgets', 'Module Name', 'jetpack' );
-_x( 'Add images, Twitter streams, your site’s RSS links, and more to your sidebar.', 'Module Description', 'jetpack' );
-
-// Modules with `Other` tag:
-// - modules/contact-form.php
-// - modules/notes.php
-// - modules/site-icon.php
-_x( 'Other', 'Module Tag', 'jetpack' );
-
-// Modules with `Writing` tag:
-// - modules/after-the-deadline.php
-// - modules/custom-content-types.php
-// - modules/enhanced-distribution.php
-// - modules/json-api.php
-// - modules/latex.php
-// - modules/markdown.php
-// - modules/post-by-email.php
-// - modules/shortcodes.php
-_x( 'Writing', 'Module Tag', 'jetpack' );
-
-// Modules with `Photos and Videos` tag:
-// - modules/carousel.php
-// - modules/photon.php
-// - modules/shortcodes.php
-// - modules/tiled-gallery.php
-// - modules/videopress.php
-_x( 'Photos and Videos', 'Module Tag', 'jetpack' );
-
-// Modules with `Social` tag:
-// - modules/comments.php
-// - modules/gravatar-hovercards.php
-// - modules/likes.php
-// - modules/publicize.php
-// - modules/sharedaddy.php
-// - modules/shortcodes.php
-// - modules/shortlinks.php
-// - modules/subscriptions.php
-// - modules/widgets.php
-_x( 'Social', 'Module Tag', 'jetpack' );
-
-// Modules with `Appearance` tag:
-// - modules/custom-css.php
-// - modules/gravatar-hovercards.php
-// - modules/infinite-scroll.php
-// - modules/minileven.php
-// - modules/photon.php
-// - modules/shortcodes.php
-// - modules/widget-visibility.php
-// - modules/widgets.php
-_x( 'Appearance', 'Module Tag', 'jetpack' );
-
-// Modules with `Developers` tag:
-// - modules/json-api.php
-// - modules/omnisearch.php
-// - modules/sso.php
-_x( 'Developers', 'Module Tag', 'jetpack' );
-
-// Modules with `Centralized Management` tag:
-// - modules/manage.php
-_x( 'Centralized Management', 'Module Tag', 'jetpack' );
-
-// Modules with `Recommended` tag:
-// - modules/manage.php
-// - modules/minileven.php
-// - modules/monitor.php
-// - modules/photon.php
-// - modules/protect.php
-// - modules/publicize.php
-// - modules/related-posts.php
-// - modules/sharedaddy.php
-// - modules/sitemaps.php
-// - modules/stats.php
-_x( 'Recommended', 'Module Tag', 'jetpack' );
-
-// Modules with `Mobile` tag:
-// - modules/minileven.php
-_x( 'Mobile', 'Module Tag', 'jetpack' );
-
-// Modules with `Traffic` tag:
-// - modules/sitemaps.php
-_x( 'Traffic', 'Module Tag', 'jetpack' );
-
-// Modules with `Site Stats` tag:
-// - modules/stats.php
-_x( 'Site Stats', 'Module Tag', 'jetpack' );
+function jetpack_get_module_i18n( $key ) { + static $modules; + if ( ! isset( $modules ) ) { + $modules = array(
+ 'after-the-deadline' => array(
+ 'name' => _x( 'Spelling and Grammar', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Check your spelling, style, and grammar with the After the Deadline proofreading service.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'carousel' => array(
+ 'name' => _x( 'Carousel', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Transform standard image galleries into full-screen slideshows.', 'Module Description', 'jetpack' ),
+ 'recommended description' => _x( 'Brings your photos and images to life as full-size, easily navigable galleries.', 'Jumpstart Description', 'jetpack' ),
+ ),
+
+ 'comments' => array(
+ 'name' => _x( 'Comments', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Let readers comment with WordPress.com, Twitter, Facebook, or Google+ accounts.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'contact-form' => array(
+ 'name' => _x( 'Contact Form', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Insert a contact form anywhere on your site.', 'Module Description', 'jetpack' ),
+ 'recommended description' => _x( 'Adds a button to your post and page editors, allowing you to build simple forms to help visitors stay in touch.', 'Jumpstart Description', 'jetpack' ),
+ ),
+
+ 'custom-content-types' => array(
+ 'name' => _x( 'Custom Content Types', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Organize and display different types of content on your site, separate from posts and pages.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'custom-css' => array(
+ 'name' => _x( 'Custom CSS', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Customize your site’s CSS without modifying your theme.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'enhanced-distribution' => array(
+ 'name' => _x( 'Enhanced Distribution', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Increase reach and traffic.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'gravatar-hovercards' => array(
+ 'name' => _x( 'Gravatar Hovercards', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Enable pop-up business cards over commenters’ Gravatars.', 'Module Description', 'jetpack' ),
+ 'recommended description' => _x( 'Let commenters link their profiles to their Gravatar accounts, making it easy for your visitors to learn more about your community.', 'Jumpstart Description', 'jetpack' ),
+ ),
+
+ 'infinite-scroll' => array(
+ 'name' => _x( 'Infinite Scroll', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Add support for infinite scroll to your theme.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'json-api' => array(
+ 'name' => _x( 'JSON API', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Allow applications to securely access your content through the cloud.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'latex' => array(
+ 'name' => _x( 'Beautiful Math', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Use LaTeX markup language in posts and pages for complex equations and other geekery.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'likes' => array(
+ 'name' => _x( 'Likes', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Give visitors an easy way to show their appreciation for your content.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'manage' => array(
+ 'name' => _x( 'Manage', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Manage all your sites from a centralized place, https://wordpress.com/sites.', 'Module Description', 'jetpack' ),
+ 'recommended description' => _x( 'Helps you remotely manage plugins, turn on automated updates, and more from <a href="https://wordpress.com/plugins/" target="_blank">wordpress.com</a>.', 'Jumpstart Description', 'jetpack' ),
+ ),
+
+ 'markdown' => array(
+ 'name' => _x( 'Markdown', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Write posts or pages in plain-text Markdown syntax.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'minileven' => array(
+ 'name' => _x( 'Mobile Theme', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Optimize your site with a mobile-friendly theme for smartphones.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'monitor' => array(
+ 'name' => _x( 'Monitor', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Reports on site downtime.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'notes' => array(
+ 'name' => _x( 'Notifications', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Receive notification of site activity via the admin toolbar and your Mobile devices.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'omnisearch' => array(
+ 'name' => _x( 'Omnisearch', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Search your entire database from a single field in your Dashboard.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'photon' => array(
+ 'name' => _x( 'Photon', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Speed up images and photos.', 'Module Description', 'jetpack' ),
+ 'recommended description' => _x( 'Mirrors and serves your images from our free and fast image CDN, improving your site’s performance with no additional load on your servers.', 'Jumpstart Description', 'jetpack' ),
+ ),
+
+ 'post-by-email' => array(
+ 'name' => _x( 'Post by Email', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Publish posts by email, using any device and email client.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'protect' => array(
+ 'name' => _x( 'Protect', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Prevent brute force attacks.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'publicize' => array(
+ 'name' => _x( 'Publicize', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Automatically promote content.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'related-posts' => array(
+ 'name' => _x( 'Related Posts', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Display similar content.', 'Module Description', 'jetpack' ),
+ 'recommended description' => _x( 'Keep visitors engaged on your blog by highlighting relevant and new content at the bottom of each published post.', 'Jumpstart Description', 'jetpack' ),
+ ),
+
+ 'sharedaddy' => array(
+ 'name' => _x( 'Sharing', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Visitors can share your content.', 'Module Description', 'jetpack' ),
+ 'recommended description' => _x( 'Twitter, Facebook and Google+ buttons at the bottom of each post, making it easy for visitors to share your content.', 'Jumpstart Description', 'jetpack' ),
+ ),
+
+ 'shortcodes' => array(
+ 'name' => _x( 'Shortcode Embeds', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Embed content from YouTube, Vimeo, SlideShare, and more, no coding necessary.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'shortlinks' => array(
+ 'name' => _x( 'WP.me Shortlinks', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Enable WP.me-powered shortlinks for all posts and pages.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'site-icon' => array(
+ 'name' => _x( 'Site Icon', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Add a site icon to your site.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'sitemaps' => array(
+ 'name' => _x( 'Sitemaps', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Creates sitemaps to allow your site to be easily indexed by search engines.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'sso' => array(
+ 'name' => _x( 'Single Sign On', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Secure user authentication.', 'Module Description', 'jetpack' ),
+ 'recommended description' => _x( 'Lets you log in to all your Jetpack-enabled sites with one click using your WordPress.com account.', 'Jumpstart Description', 'jetpack' ),
+ ),
+
+ 'stats' => array(
+ 'name' => _x( 'Site Stats', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Collect traffic stats and insights.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'subscriptions' => array(
+ 'name' => _x( 'Subscriptions', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Allow users to subscribe to your posts and comments and receive notifications via email.', 'Module Description', 'jetpack' ),
+ 'recommended description' => _x( 'Give visitors two easy subscription options — while commenting, or via a separate email subscription widget you can display.', 'Jumpstart Description', 'jetpack' ),
+ ),
+
+ 'tiled-gallery' => array(
+ 'name' => _x( 'Tiled Galleries', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Display your image galleries in a variety of sleek, graphic arrangements.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'vaultpress' => array(
+ 'name' => _x( 'Data Backups', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Daily or real-time backups.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'verification-tools' => array(
+ 'name' => _x( 'Site Verification', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Verify your site or domain with Google Search Console, Pinterest, and others.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'videopress' => array(
+ 'name' => _x( 'VideoPress', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Upload and embed videos right on your site. (Subscription required.)', 'Module Description', 'jetpack' ),
+ ),
+
+ 'widget-visibility' => array(
+ 'name' => _x( 'Widget Visibility', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Specify which widgets appear on which pages of your site.', 'Module Description', 'jetpack' ),
+ ),
+
+ 'widgets' => array(
+ 'name' => _x( 'Extra Sidebar Widgets', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Add images, Twitter streams, your site’s RSS links, and more to your sidebar.', 'Module Description', 'jetpack' ),
+ ),
+ ); + }
+ return $modules[ $key ]; +} +/** + * For a given module tag, return its translated version. + * + * @param string $key Module tag as is in each module heading. + * + * @return string + */
+function jetpack_get_module_i18n_tag( $key ) { + static $module_tags; + if ( ! isset( $module_tags ) ) {
+ $module_tags = array(
+ // Modules with `Other` tag:
+ // - modules/contact-form.php
+ // - modules/notes.php
+ // - modules/site-icon.php
+ 'Other' =>_x( 'Other', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Writing` tag:
+ // - modules/after-the-deadline.php
+ // - modules/custom-content-types.php
+ // - modules/enhanced-distribution.php
+ // - modules/json-api.php
+ // - modules/latex.php
+ // - modules/markdown.php
+ // - modules/post-by-email.php
+ // - modules/shortcodes.php
+ 'Writing' =>_x( 'Writing', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Photos and Videos` tag:
+ // - modules/carousel.php
+ // - modules/photon.php
+ // - modules/shortcodes.php
+ // - modules/tiled-gallery.php
+ // - modules/videopress.php
+ 'Photos and Videos' =>_x( 'Photos and Videos', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Social` tag:
+ // - modules/comments.php
+ // - modules/gravatar-hovercards.php
+ // - modules/likes.php
+ // - modules/publicize.php
+ // - modules/sharedaddy.php
+ // - modules/shortcodes.php
+ // - modules/shortlinks.php
+ // - modules/subscriptions.php
+ // - modules/widgets.php
+ 'Social' =>_x( 'Social', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Appearance` tag:
+ // - modules/custom-css.php
+ // - modules/gravatar-hovercards.php
+ // - modules/infinite-scroll.php
+ // - modules/minileven.php
+ // - modules/photon.php
+ // - modules/shortcodes.php
+ // - modules/widget-visibility.php
+ // - modules/widgets.php
+ 'Appearance' =>_x( 'Appearance', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Developers` tag:
+ // - modules/json-api.php
+ // - modules/omnisearch.php
+ // - modules/sso.php
+ 'Developers' =>_x( 'Developers', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Centralized Management` tag:
+ // - modules/manage.php
+ 'Centralized Management' =>_x( 'Centralized Management', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Recommended` tag:
+ // - modules/manage.php
+ // - modules/minileven.php
+ // - modules/monitor.php
+ // - modules/photon.php
+ // - modules/protect.php
+ // - modules/publicize.php
+ // - modules/related-posts.php
+ // - modules/sharedaddy.php
+ // - modules/sitemaps.php
+ // - modules/stats.php
+ 'Recommended' =>_x( 'Recommended', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Mobile` tag:
+ // - modules/minileven.php
+ 'Mobile' =>_x( 'Mobile', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Traffic` tag:
+ // - modules/sitemaps.php
+ 'Traffic' =>_x( 'Traffic', 'Module Tag', 'jetpack' ),
+
+ // Modules with `Site Stats` tag:
+ // - modules/stats.php
+ 'Site Stats' =>_x( 'Site Stats', 'Module Tag', 'jetpack' ),
+ ); + }
+ return $module_tags[ $key ]; +}
\ No newline at end of file diff --git a/plugins/jetpack/modules/module-info.php b/plugins/jetpack/modules/module-info.php index b5b75350..857900a8 100644 --- a/plugins/jetpack/modules/module-info.php +++ b/plugins/jetpack/modules/module-info.php @@ -96,7 +96,7 @@ function jetpack_shortcodes_more_info() { ?> 'gist' => 'http://en.support.wordpress.com/gist/', 'googlemaps' => 'http://support.wordpress.com/google-maps/', 'instagram' => 'https://en.support.wordpress.com/instagram/instagram-images/', - 'jetpack_subscription_form' => 'http://jetpack.me/support/subscriptions/#display', + 'jetpack_subscription_form' => 'http://jetpack.com/support/subscriptions/#display', 'polldaddy' => 'http://support.polldaddy.com/wordpress-shortcodes/', 'presentation' => 'http://en.support.wordpress.com/presentations/', 'recipes' => 'http://en.support.wordpress.com/recipes/', @@ -172,7 +172,7 @@ add_action( 'jetpack_module_more_info_stats', 'stats_more_info' ); * Publicize */ function publicize_load_more_link( $description ) { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/publicize/">' . esc_html__( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/publicize/">' . esc_html__( 'Learn More', 'jetpack' ) . '</a>'; } add_filter( 'jetpack_learn_more_button_publicize', 'publicize_load_more_link' ); @@ -192,7 +192,7 @@ function publicize_more_info() { ?> <?php endif; ?> - <p>→ <a href="http://jetpack.me/support/publicize/"><?php esc_html_e( 'More information on using Publicize.', 'jetpack' ); ?></a></p> + <p>→ <a href="http://jetpack.com/support/publicize/"><?php esc_html_e( 'More information on using Publicize.', 'jetpack' ); ?></a></p> <?php } add_action( 'jetpack_module_more_info_publicize', 'publicize_more_info' ); @@ -378,7 +378,7 @@ add_action( 'jetpack_module_more_info_enhanced-distribution', 'jetpack_enhanced_ * Protect */ function jetpack_protect_more_link() { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/protect/">' . esc_html__( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/protect/">' . esc_html__( 'Learn More', 'jetpack' ) . '</a>'; } add_action( 'jetpack_learn_more_button_protect', 'jetpack_protect_more_link' ); @@ -396,7 +396,7 @@ add_action( 'jetpack_module_more_info_protect', 'jetpack_protect_more_info' ); * JSON API */ function jetpack_json_api_more_link() { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/json-api/">' . esc_html__( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/json-api/">' . esc_html__( 'Learn More', 'jetpack' ) . '</a>'; } add_action( 'jetpack_learn_more_button_json-api', 'jetpack_json_api_more_link' ); @@ -430,7 +430,10 @@ function jetpack_contact_form_more_info() { echo '</p>'; echo '<p>'; - _e( 'Each contact form can easily be customized to fit your needs. When a user submits your contact form, the feedback will be filtered through <a href="http://akismet.com/">Akismet</a> (if it is active on your site) to make sure it’s not spam. Any legitimate feedback will then be emailed to you, and added to your feedback management area.', 'jetpack' ); + printf( + __( 'Each contact form can easily be customized to fit your needs. When a user submits your contact form, the feedback will be filtered through <a href="http://akismet.com/">Akismet</a> (if it is <a href="%s">active on your site</a>) to make sure it’s not spam. Any legitimate feedback will then be emailed to you, and added to your feedback management area.', 'jetpack' ), + admin_url( 'plugin-install.php?tab=search&s=akismet' ) + ); echo '</p>'; } add_action( 'jetpack_module_more_info_contact-form', 'jetpack_contact_form_more_info' ); @@ -493,8 +496,16 @@ function jetpack_custom_css_more_info() { ?> </div> <p><?php esc_html_e( "The Custom CSS editor gives you the ability to add to or replace your theme's CSS, all while supplying syntax coloring, auto-indentation, and immediate feedback on the validity of the CSS you're writing.", 'jetpack' ); ?></p> - <p><?php printf( __( 'To use the CSS editor, go to Appearance → <a href="%s">Edit CSS</a>.', 'jetpack' ), admin_url( 'themes.php?page=editcss' ) ); ?></p> -<?php + + <?php if ( Jetpack::is_module_active( 'custom-css' ) ) : ?> + + <p><?php printf( __( 'To use the CSS editor, go to Appearance → <a href="%s">Edit CSS</a>.', 'jetpack' ), admin_url( 'themes.php?page=editcss' ) ); ?></p> + + <?php else : ?> + + <p><?php esc_html_e( 'After activating this module, find the editor in Appearance → Edit CSS.', 'jetpack' ); ?></p> + + <?php endif; } add_action( 'jetpack_module_more_info_custom-css', 'jetpack_custom_css_more_info' ); @@ -527,7 +538,7 @@ function jetpack_infinite_scroll_more_button() { add_action( 'jetpack_learn_more_button_infinite-scroll', 'jetpack_infinite_scroll_more_button' ); function jetpack_infinite_scroll_more_info() { - $support_text = sprintf( __( 'If you are a theme author, you can learn about adding support for Infinite Scroll at <a href="%1$s">%1$s</a>.', 'jetpack' ), 'http://jetpack.me/support/infinite-scroll/' ); + $support_text = sprintf( __( 'If you are a theme author, you can learn about adding support for Infinite Scroll at <a href="%1$s">%1$s</a>.', 'jetpack' ), 'http://jetpack.com/support/infinite-scroll/' ); ?> @@ -564,7 +575,7 @@ add_action( 'jetpack_module_more_info_infinite-scroll', 'jetpack_infinite_scroll * Post by Email */ function jetpack_post_by_email_more_link() { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/post-by-email/">' . __( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/post-by-email/">' . __( 'Learn More', 'jetpack' ) . '</a>'; } add_action( 'jetpack_learn_more_button_post-by-email', 'jetpack_post_by_email_more_link' ); @@ -577,7 +588,7 @@ function jetpack_post_by_email_more_info() { ?> <p><?php printf( __( 'Manage your Post By Email address from your <a href="%s">profile settings</a>.', 'jetpack' ), esc_url( get_edit_profile_url( get_current_user_id() ) . '#post-by-email' ) ); ?> - <p>→ <a href="http://jetpack.me/support/post-by-email/"><?php esc_html_e( 'More information on sending emails, attachments, and customizing your posts.', 'jetpack' ); ?></a></p> + <p>→ <a href="http://jetpack.com/support/post-by-email/"><?php esc_html_e( 'More information on sending emails, attachments, and customizing your posts.', 'jetpack' ); ?></a></p> <?php } @@ -628,7 +639,7 @@ add_action( 'jetpack_learn_more_button_likes', 'jetpack_likes_more_link' ); function jetpack_likes_more_info() { ?> <div class="jp-info-img"> - <a href="http://jetpack.me/support/likes/"> + <a href="http://jetpack.com/support/likes/"> <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/images/screenshots/likes.jpg' ) ?>" alt="<?php esc_attr_e( 'Likes', 'jetpack' ) ?>" width="323" height="69" /> </a> </div> @@ -643,7 +654,7 @@ function jetpack_likes_more_info() { ?> <li><?php esc_html_e( 'Ensure that "WordPress.com Likes are…" is set to "On for all posts"', 'jetpack' ); ?></li> </ol> <?php endif; ?> - <p>→ <a href="http://jetpack.me/support/likes/"><?php esc_html_e( 'More information on using Likes.', 'jetpack' ); ?></a></p> + <p>→ <a href="http://jetpack.com/support/likes/"><?php esc_html_e( 'More information on using Likes.', 'jetpack' ); ?></a></p> <?php } @@ -653,7 +664,7 @@ add_action( 'jetpack_module_more_info_likes', 'jetpack_likes_more_info' ); * Omnisearch */ function jetpack_omnisearch_more_link() { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/omnisearch/">' . __( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/omnisearch/">' . __( 'Learn More', 'jetpack' ) . '</a>'; } add_action( 'jetpack_learn_more_button_omnisearch', 'jetpack_omnisearch_more_link' ); @@ -675,7 +686,7 @@ add_action( 'jetpack_module_more_info_omnisearch', 'jetpack_omnisearch_more_inf * Widget Visibility */ function jetpack_widget_visibility_more_link() { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/widget-visibility/">' . __( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/widget-visibility/">' . __( 'Learn More', 'jetpack' ) . '</a>'; } add_action( 'jetpack_learn_more_button_widget-visibility', 'jetpack_widget_visibility_more_link' ); @@ -710,7 +721,7 @@ add_action( 'jetpack_module_more_info_videopress', 'jetpack_videopress_more_info * SSO */ function jetpack_sso_more_link() { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/sso/">' . __( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/sso/">' . __( 'Learn More', 'jetpack' ) . '</a>'; } add_action( 'jetpack_learn_more_button_sso', 'jetpack_sso_more_link' ); @@ -727,7 +738,7 @@ add_action( 'jetpack_module_more_info_sso', 'jetpack_sso_more_info' ); * Monitor */ function jetpack_monitor_more_link() { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/monitor/">' . esc_html__( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/monitor/">' . esc_html__( 'Learn More', 'jetpack' ) . '</a>'; } add_action( 'jetpack_learn_more_button_monitor', 'jetpack_monitor_more_link' ); @@ -752,13 +763,13 @@ add_action( 'jetpack_learn_more_button_related-posts', 'jetpack_related_posts_mo function jetpack_related_posts_more_info() { $template = <<<EOT <div class="jp-info-img"> - <a href="http://jetpack.me/support/related-posts/"> + <a href="http://jetpack.com/support/related-posts/"> <img class="jp-info-img" src="%s" alt="%s" width="300" height="98" /> </a> </div> <p>%s</p> - <p>→ <a href="http://jetpack.me/support/related-posts/">%s</a></p> + <p>→ <a href="http://jetpack.com/support/related-posts/">%s</a></p> <hr /> <p><a href="%s#sync-related-posts">%s</a></p> EOT; @@ -818,21 +829,32 @@ function jetpack_custom_content_types_more_info() { ?> <img class="jp-info-img" src="<?php echo plugins_url( basename( dirname( dirname( __FILE__ ) ) ) . '/images/screenshots/custom-content-types.jpg' ) ?>" alt="<?php esc_attr_e( 'Custom Content Type', 'jetpack' ) ?>" width="300" height="150" /> </div> - <p><?php esc_html_e( 'Organize and display different types of content on your site, separate from posts and pages.', 'jetpack' ); ?></p> - <p><?php printf( __( 'To enable a custom content type, head over to <a href="%s">Settings → Writing → Your Custom Content Types</a> to activate either "Portfolio Projects” or “Testimonials” by checking the corresponding checkbox. You can now add projects and testimonials under the new "Portfolio” or “Testimonials” menu item in your sidebar.', 'jetpack' ), admin_url( 'options-writing.php#cpt-options' ) ); ?></p> - <p><?php - /* translators: all variables are URLs */ - printf( - __( - 'Once added, your custom content will be visible on your website at %1$s or %2$s, or you may add them with <a href="%3$s" target="_blank">shortcodes</a>.', - 'jetpack' - ), - get_site_url() . '/portfolio/', - get_site_url() . '/testimonial/', - 'http://jetpack.me/support/custom-content-types/' - ); - ?></p> -<?php + <p><?php esc_html_e( 'Organize and display different types of content on your site, such as Portfolio Projects and Testimonials. These content types are separate from Posts and Pages.', 'jetpack' ); ?></p> + + <?php if ( Jetpack::is_module_active( 'custom-content-types' ) ) : ?> + + <p><?php printf( __( 'To enable a custom content type, head over to <a href="%s">Settings → Writing → Your Custom Content Types</a> and activate either "Portfolio Projects” or “Testimonials” by checking the corresponding checkbox. You can now add projects and testimonials under the new "Portfolio” and “Testimonials” menu items in your sidebar.', 'jetpack' ), admin_url( 'options-writing.php#cpt-options' ) ); ?></p> + + <p><?php + /* translators: all variables are URLs */ + printf( + __( + 'Once added, your custom content will be visible on your website at <a href="%1$s">%1$s</a> or <a href="%2$s">%2$s</a>, or you may add them with <a href="%3$s" target="_blank">shortcodes</a>.', + 'jetpack' + ), + get_site_url() . '/portfolio/', + get_site_url() . '/testimonial/', + 'http://jetpack.com/support/custom-content-types/' + ); + ?></p> + + <?php else : ?> + + <p><?php esc_html_e( 'Once activated, you can selectively activate the content types you need at Settings → Writing → Your Custom Content Types.'); ?></p> + + <p><?php echo wp_kses( sprintf( __( 'Full details can be found on the <a href="%s" title="Custom Content Types support page" target="_blank">Custom Content Types support page</a>.', 'jetpack' ), 'https://jetpack.com/support/custom-content-types/' ), array( 'a' => array( 'href' => true, 'title' => true, 'target' => true ) ) ); ?></p> + + <?php endif; } add_action( 'jetpack_module_more_info_custom-content-types', 'jetpack_custom_content_types_more_info' ); @@ -840,7 +862,7 @@ add_action( 'jetpack_module_more_info_custom-content-types', 'jetpack_custom_con * Site Icon */ function jetpack_site_icon_more_link() { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/site-icon">' . __( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/site-icon">' . __( 'Learn More', 'jetpack' ) . '</a>'; } add_action( 'jetpack_learn_more_button_site-icon', 'jetpack_site_icon_more_link' ); @@ -861,7 +883,7 @@ add_action( 'jetpack_module_more_info_site-icon', 'jetpack_custom_site_icon' ); * Manage */ function jetpack_manage_more_link() { - echo '<a class="button-secondary more-info-link" href="http://jetpack.me/support/site-management/">' . __( 'Learn More', 'jetpack' ) . '</a>'; + echo '<a class="button-secondary more-info-link" href="http://jetpack.com/support/site-management/">' . __( 'Learn More', 'jetpack' ) . '</a>'; } add_action( 'jetpack_learn_more_button_manage', 'jetpack_manage_more_link' ); @@ -887,13 +909,39 @@ add_action( 'jetpack_module_more_info_manage', 'jetpack_custom_jetpack_manage' ) // XML Sitemap: START function jetpack_xml_sitemap_more_info() { ?> - <p><?php esc_html_e( 'This module creates an XML sitemap file that lists the URLs of posts and pages in your site with important information about each one.', 'jetpack' ); ?></p> - <p><?php esc_html_e( 'This file is accessed by search engines like Google or Bing so they can crawl and understand your site.', 'jetpack' ); ?></p> - <p>→ <a href="http://jetpack.me/support/sitemaps/"><?php esc_html_e( 'More information on Sitemaps.', 'jetpack' ); ?></a></p> + <p><?php esc_html_e( 'This module creates two XML sitemap files that list the URLs of posts and pages in your site with important information about each one. This files can be accessed by search engines like Google or Bing so they can crawl and understand your site.', 'jetpack' ); ?></p> <?php if ( '0' == get_option( 'blog_public' ) ) : ?> - <p><strong><?php esc_html_e( 'Your site is currently set to discourage search engines from indexing it so the sitemap will not be accesible.', 'jetpack' ); ?></strong></p> + <p><strong><?php esc_html_e( 'Your site is currently set to discourage search engines from indexing it so the sitemap will not be accessible.', 'jetpack' ); ?></strong></p> + <?php else : + if ( get_option( 'permalink_structure' ) ) { + /** This filter is documented in modules/sitemaps/sitemaps.php */ + $sitemap_url = apply_filters( 'jetpack_sitemap_location', home_url( '/sitemap.xml' ) ); + /** This filter is documented in modules/sitemaps/sitemaps.php */ + $news_sitemap_url = apply_filters( 'jetpack_news_sitemap_location', home_url( '/news-sitemap.xml' ) ); + } else { + /** This filter is documented in modules/sitemaps/sitemaps.php */ + $sitemap_url = apply_filters( 'jetpack_sitemap_location', home_url( '/?jetpack-sitemap=true' ) ); + /** This filter is documented in modules/sitemaps/sitemaps.php */ + $news_sitemap_url = apply_filters( 'jetpack_news_sitemap_location', home_url( '/?jetpack-news-sitemap=true' ) ); + } + if ( Jetpack::is_module_active( 'sitemaps' ) ) : ?> + <p><?php esc_html_e( 'Your sitemaps are accessible at:', 'jetpack' ); ?></p> + <?php else : ?> + <p><?php esc_html_e( 'After activating the module, your sitemaps will be accessible at:', 'jetpack' ); ?></p> + <?php endif; ?> + <ul> + <li> + <?php /* translators: the placeholder is an URL of a sitemap */ ?> + <?php printf( __( '<a href="%1$s" target="_blank">%1$s</a> – a standard sitemap for use with any search engine;', 'jetpack' ), esc_url( $sitemap_url ) ); ?> + </li> + <li> + <?php /* translators: the placeholder is an URL of a sitemap */ ?> + <?php printf( __( '<a href="%1$s" target="_blank">%1$s</a> – a sitemap specially tailored for Google News.', 'jetpack' ), esc_url( $news_sitemap_url ) ); ?> + </li> + </ul> <?php endif; ?> - <?php + <p>→ <a href="http://jetpack.com/support/sitemaps/"><?php esc_html_e( 'More information on Sitemaps.', 'jetpack' ); ?></a></p> +<?php } add_action( 'jetpack_module_more_info_sitemaps', 'jetpack_xml_sitemap_more_info' ); -// XML Sitemap: STOP
\ No newline at end of file +// XML Sitemap: STOP diff --git a/plugins/jetpack/modules/monitor.php b/plugins/jetpack/modules/monitor.php index 4fd2d671..812e41ce 100644 --- a/plugins/jetpack/modules/monitor.php +++ b/plugins/jetpack/modules/monitor.php @@ -151,6 +151,26 @@ class Jetpack_Monitor { return true; } + /* + * Returns date of the last downtime. + * + * @since 4.0 + * @return date in YYYY-MM-DD HH:mm:ss format + */ + public function monitor_get_last_downtime() { + Jetpack::load_xml_rpc_client(); + $xml = new Jetpack_IXR_Client( array( + 'user_id' => get_current_user_id() + ) ); + + $xml->query( 'jetpack.monitor.getLastDowntime' ); + + if ( $xml->isError() ) { + return new WP_Error( 'monitor-downtime', $xml->getErrorMessage() ); + } + return $xml->getResponse(); + } + } new Jetpack_Monitor; diff --git a/plugins/jetpack/modules/post-by-email.php b/plugins/jetpack/modules/post-by-email.php index fff3f186..c30596be 100644 --- a/plugins/jetpack/modules/post-by-email.php +++ b/plugins/jetpack/modules/post-by-email.php @@ -104,7 +104,7 @@ class Jetpack_Post_By_Email { <div id="jp-pbe-info"<?php echo $info_hidden; ?>> <p id="jp-pbe-email-wrapper"> <input type="text" id="jp-pbe-email" value="<?php echo esc_attr( $email ); ?>" readonly="readonly" class="regular-text" /> - <span class="description"><a target="_blank" href="http://jetpack.me/support/post-by-email/"><?php esc_html_e( 'More information', 'jetpack' ); ?></a></span> + <span class="description"><a target="_blank" href="http://jetpack.com/support/post-by-email/"><?php esc_html_e( 'More information', 'jetpack' ); ?></a></span> </p> <p> <input type="button" name="jp-pbe-regenerate" id="jp-pbe-regenerate" class="button" value="<?php esc_attr_e( 'Regenerate Address', 'jetpack' ); ?> " /> diff --git a/plugins/jetpack/modules/protect.php b/plugins/jetpack/modules/protect.php index 400328f7..d1b92de7 100644 --- a/plugins/jetpack/modules/protect.php +++ b/plugins/jetpack/modules/protect.php @@ -174,7 +174,7 @@ class Jetpack_Protect_Module { <div class="jp-banner__content"> <h2><?php esc_html_e( 'Protect cannot keep your site secure.', 'jetpack' ); ?></h2> - <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.me/support/multisite-protect' ); ?></p> + <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" @@ -522,7 +522,7 @@ class Jetpack_Protect_Module { * @param string $ip IP flagged by Protect. */ do_action( 'jpp_kill_login', $ip ); - $help_url = 'http://jetpack.me/support/security/'; + $help_url = 'http://jetpack.com/support/security/'; $die_string = sprintf( __( 'Your IP (%1$s) has been flagged for potential security violations. <a href="%2$s">Find out more...</a>', 'jetpack' ), str_replace( 'http://', '', esc_url( 'http://' . $ip ) ), esc_url( $help_url ) ); diff --git a/plugins/jetpack/modules/publicize/ui.php b/plugins/jetpack/modules/publicize/ui.php index 6847c6d4..92551f1b 100644 --- a/plugins/jetpack/modules/publicize/ui.php +++ b/plugins/jetpack/modules/publicize/ui.php @@ -22,8 +22,8 @@ class Publicize_UI { } function init() { - // Show only to users with the capability required to create/delete global connections. - if ( ! current_user_can( $this->publicize->GLOBAL_CAP ) ) { + // Show only to users with the capability required to manage their Publicize connections. + if ( ! current_user_can( 'publish_posts' ) ) { return; } @@ -130,7 +130,7 @@ class Publicize_UI { <?php if ( $this->in_jetpack ) { - $doc_link = "http://jetpack.me/support/publicize/"; + $doc_link = "http://jetpack.com/support/publicize/"; } else { $doc_link = "http://en.support.wordpress.com/publicize/"; } diff --git a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php index 565759be..d7560729 100644 --- a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php +++ b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php @@ -123,7 +123,7 @@ class Jetpack_RelatedPosts { $this->_action_frontend_init_ajax( $excludes ); } else { - if ( isset( $_GET['relatedposts_hit'] ) ) { + if ( isset( $_GET['relatedposts_hit'], $_GET['relatedposts_origin'], $_GET['relatedposts_position'] ) ) { $this->_log_click( $_GET['relatedposts_origin'], get_the_ID(), $_GET['relatedposts_position'] ); $this->_previous_post_id = (int) $_GET['relatedposts_origin']; } @@ -1223,8 +1223,20 @@ EOT; * @return null */ protected function _enqueue_assets( $script, $style ) { - if ( $script ) + if ( $script ) { wp_enqueue_script( 'jetpack_related-posts', plugins_url( 'related-posts.js', __FILE__ ), array( 'jquery' ), self::VERSION ); + $related_posts_js_options = array( + /** + * Filter each Related Post Heading structure. + * + * @since 4.0.0 + * + * @param string $str Related Post Heading structure. Default to h4. + */ + 'post_heading' => apply_filters( 'jetpack_relatedposts_filter_post_heading', esc_attr( 'h4' ) ), + ); + wp_localize_script( 'jetpack_related-posts', 'related_posts_js_options', $related_posts_js_options ); + } if ( $style ){ if( is_rtl() ) { wp_enqueue_style( 'jetpack_related-posts', plugins_url( 'rtl/related-posts-rtl.css', __FILE__ ), array(), self::VERSION ); diff --git a/plugins/jetpack/modules/related-posts/related-posts.js b/plugins/jetpack/modules/related-posts/related-posts.js index 4c7f314c..dd30a1ea 100644 --- a/plugins/jetpack/modules/related-posts/related-posts.js +++ b/plugins/jetpack/modules/related-posts/related-posts.js @@ -1,4 +1,5 @@ /* jshint onevar: false */ +/* globals related_posts_js_options */ /** * Load related posts @@ -108,7 +109,7 @@ var anchor_overlay = self.getAnchor( post, 'jp-relatedposts-post-a jp-relatedposts-post-aoverlay' ); html += anchor_overlay[0] + anchor_overlay[1]; } - html += '<h4 class="jp-relatedposts-post-title">' + anchor[0] + post.title + anchor[1] + '</h4>'; + html += '<' + related_posts_js_options.post_heading + ' class="jp-relatedposts-post-title">' + anchor[0] + post.title + anchor[1] + '</' + related_posts_js_options.post_heading + '>'; html += '<p class="jp-relatedposts-post-excerpt">' + $( '<p>' ).text( post.excerpt ).html() + '</p>'; html += '<p class="jp-relatedposts-post-date">' + post.date + '</p>'; html += '<p class="jp-relatedposts-post-context">' + post.context + '</p>'; diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png Binary files differindex dcbee893..299c7d88 100644 --- a/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png +++ b/plugins/jetpack/modules/sharedaddy/images/smart-twitter.png diff --git a/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png b/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png Binary files differindex 7015cf60..0be96c46 100644 --- a/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png +++ b/plugins/jetpack/modules/sharedaddy/images/smart-twitter@2x.png diff --git a/plugins/jetpack/modules/shortcodes/archives.php b/plugins/jetpack/modules/shortcodes/archives.php index 28a0ad52..9ebd7f6e 100644 --- a/plugins/jetpack/modules/shortcodes/archives.php +++ b/plugins/jetpack/modules/shortcodes/archives.php @@ -8,9 +8,10 @@ add_shortcode( 'archives', 'archives_shortcode' ); -function archives_shortcode( $attr ) { - if ( is_feed() ) +function archives_shortcode( $atts ) { + if ( is_feed() ) { return '[archives]'; + } global $allowedposttags; @@ -23,49 +24,50 @@ function archives_shortcode( $attr ) { 'after' => '', 'order' => 'desc', ); - extract( shortcode_atts( $default_atts, $attr, 'archives' ) ); - if ( ! in_array( $type, array( 'yearly', 'monthly', 'daily', 'weekly', 'postbypost' ) ) ) - $type = 'postbypost'; + $attr = shortcode_atts( $default_atts, $atts, 'archives' ); - if ( ! in_array( $format, array( 'html', 'option', 'custom' ) ) ) - $format = 'html'; + if ( ! in_array( $attr['type'], array( 'yearly', 'monthly', 'daily', 'weekly', 'postbypost' ) ) ) { + $attr['type'] = 'postbypost'; + } - if ( '' != $limit ) { - $limit = ( int ) $limit; - // A Limit of 0 makes no sense so revert back to the default. - if ( 0 == $limit ) { - $limit = ''; - } + if ( ! in_array( $attr['format'], array( 'html', 'option', 'custom' ) ) ) { + $attr['format'] = 'html'; } + $limit = intval( $attr['limit'] ); + // A Limit of 0 makes no sense so revert back to the default. + if ( empty( $limit ) ) { + $limit = ''; + } - $showcount = ( bool ) $showcount; - $before = wp_kses( $before, $allowedposttags ); - $after = wp_kses( $after, $allowedposttags ); + $showcount = ( false !== $attr['showcount'] && 'false' !== $attr['showcount'] ) ? true : false; + $before = wp_kses( $attr['before'], $allowedposttags ); + $after = wp_kses( $attr['after'], $allowedposttags ); // Get the archives $archives = wp_get_archives( array( - 'type' => $type, + 'type' => $attr['type'], 'limit' => $limit, - 'format' => $format, + 'format' => $attr['format'], 'echo' => false, 'show_post_count' => $showcount, 'before' => $before, - 'after' => $after + 'after' => $after, ) ); - if ( 'asc' == $order ) + if ( 'asc' === $attr['order'] ) { $archives = implode( "\n", array_reverse( explode( "\n", $archives ) ) ); - + } // Check to see if there are any archives - if ( empty( $archives ) ) - $archives = '<p>' . __( 'Your blog does not currently have any published posts.' , 'jetpack' ) . '</p>'; - elseif ( 'option' == $format ) - $archives = "<select name='archive-dropdown' onchange='document.location.href=this.options[this.selectedIndex].value;'><option value='" . get_permalink() . "'>--</option>" . $archives . "</select>"; - elseif ( 'html' == $format ) + if ( empty( $archives ) ) { + $archives = '<p>' . __( 'Your blog does not currently have any published posts.', 'jetpack' ) . '</p>'; + } else if ( 'option' === $attr['format'] ) { + $archives = '<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;"><option value="' . get_permalink() . '">--</option>' . $archives . '</select>'; + } else if ( 'html' === $attr['format'] ) { $archives = '<ul>' . $archives . '</ul>'; + } return $archives; } diff --git a/plugins/jetpack/modules/shortcodes/codepen.php b/plugins/jetpack/modules/shortcodes/codepen.php new file mode 100644 index 00000000..45efa774 --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/codepen.php @@ -0,0 +1,10 @@ +<?php + +/* + * CodePen embed + * + * example URL: http://codepen.io/css-tricks/pen/wFeaG +*/ + +// Register oEmbed provider +wp_oembed_add_provider( '#https?://codepen.io/([^/]+)/pen/([^/]+)/?#', 'https://codepen.io/api/oembed', true ); diff --git a/plugins/jetpack/modules/shortcodes/dailymotion.php b/plugins/jetpack/modules/shortcodes/dailymotion.php index 24f7fcb2..d538ba38 100644 --- a/plugins/jetpack/modules/shortcodes/dailymotion.php +++ b/plugins/jetpack/modules/shortcodes/dailymotion.php @@ -14,7 +14,7 @@ * </object><br /><b><a href="http://www.dailymotion.com/video/xen4ms_ghinzu-cold-love-mirror-mirror_music">Ghinzu - Cold Love (Mirror Mirror)</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/GhinzuTV">GhinzuTV</a>. - <a href="http://www.dailymotion.com/us/channel/music">Watch more music videos, in HD!</a></i> * * Code as of 01.01.11: - * <object width="560" height="421"><param name="movie" value="http://www.dailymotion.com/swf/video/xaose5?width=560&theme=denim&foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xaose5?width=560&theme=denim&foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0" width="560" height="421" allowfullscreen="true" allowscriptaccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/xaose5_sexy-surprise_na">Sexy Surprise</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/GilLavie">GilLavie</a>. - <a target="_self" href="http://www.dailymotion.com/channel/sexy/featured/1">Find more steamy, sexy videos.</a></i> + * <object width="560" height="421"><param name="movie" value="http://www.dailymotion.com/swf/video/xaose5?width=560&theme=denim&foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xaose5?width=560&theme=denim&foreground=%2392ADE0&highlight=%23A2ACBF&background=%23202226&start=&animatedTitle=&iframe=0&additionalInfos=0&autoPlay=0&hideInfos=0" width="560" height="421" allowfullscreen="true" allowscriptaccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x29zm17_funny-videos-of-cats-and-babies-compilation-2015_fun">Funny cats and babies!</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/GilLavie">GilLavie</a>. - <a target="_self" href="http://www.dailymotion.com/channel/funny/featured/1">Find more funny videos.</a></i> * movie param enforces anti-xss protection * * Scroll down for the new <iframe> embed code handler. diff --git a/plugins/jetpack/modules/shortcodes/facebook.php b/plugins/jetpack/modules/shortcodes/facebook.php index c054ecc6..778fc543 100644 --- a/plugins/jetpack/modules/shortcodes/facebook.php +++ b/plugins/jetpack/modules/shortcodes/facebook.php @@ -37,21 +37,9 @@ function jetpack_facebook_embed_handler( $matches, $attr, $url ) { // since Facebook is a faux embed, we need to load the JS SDK in the wpview embed iframe if ( defined( 'DOING_AJAX' ) && DOING_AJAX && ! empty( $_POST['action'] ) && 'parse-embed' == $_POST['action'] ) { - return $embed . '<script src="//connect.facebook.net/en_US/all.js#xfbml=1"></script>'; + return $embed . wp_scripts()->do_items( array( 'jetpack-facebook-embed' ) ); } else { - wp_enqueue_script( 'jetpack-facebook-embed', plugins_url( 'js/facebook.js', __FILE__ ), array( 'jquery' ), null, true ); - /** This filter is documented in modules/sharedaddy/sharing-sources.php */ - $fb_app_id = apply_filters( 'jetpack_sharing_facebook_app_id', '249643311490' ); - if ( ! is_numeric( $fb_app_id ) ) { - $fb_app_id = ''; - } - wp_localize_script( - 'jetpack-facebook-embed', - 'jpfbembed', - array( - 'appid' => $fb_app_id - ) - ); + wp_enqueue_script( 'jetpack-facebook-embed' ); return $embed; } } diff --git a/plugins/jetpack/modules/shortcodes/flickr.php b/plugins/jetpack/modules/shortcodes/flickr.php index bdc28f0e..d145dde7 100644 --- a/plugins/jetpack/modules/shortcodes/flickr.php +++ b/plugins/jetpack/modules/shortcodes/flickr.php @@ -17,10 +17,11 @@ */ function flickr_embed_to_shortcode( $content ) { - if ( false === stripos( $content, '/www.flickr.com/apps/video/stewart.swf' ) ) + if ( false === stripos( $content, '/www.flickr.com/apps/video/stewart.swf' ) ) { return $content; + } - $regexp = '%(<object.*?(?:<(?!/?(?:object|embed)\s+).*?)*?)?<embed((?:\s+\w+="[^"]*")*)\s+src="http(?:\:|�*58;)//www.flickr.com/apps/video/stewart.swf[^"]*"((?:\s+\w+="[^"]*")*)\s*(?:/>|>\s*</embed>)(?(1)\s*</object>)%'; + $regexp = '%(<object.*?(?:<(?!/?(?:object|embed)\s+).*?)*?)?<embed((?:\s+\w+="[^"]*")*)\s+src="http(?:\:|�*58;)//www.flickr.com/apps/video/stewart.swf[^"]*"((?:\s+\w+="[^"]*")*)\s*(?:/>|>\s*</embed>)(?(1)\s*</object>)%'; $regexp_ent = str_replace( array( '&#0*58;', @@ -36,40 +37,49 @@ function flickr_embed_to_shortcode( $content ) { ); foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) { - if ( !preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) + if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) { continue; + } foreach ( $matches as $match ) { $params = $match[2] . $match[3]; - if ( 'regexp_ent' == $reg ) + if ( 'regexp_ent' == $reg ) { $params = html_entity_decode( $params ); + } $params = wp_kses_hair( $params, array( 'http' ) ); - if ( ! isset( $params['type'] ) || 'application/x-shockwave-flash' != $params['type']['value'] || ! isset( $params['flashvars'] ) ) + if ( ! isset( $params['type'] ) || 'application/x-shockwave-flash' != $params['type']['value'] || ! isset( $params['flashvars'] ) ) { continue; + } wp_parse_str( html_entity_decode( $params['flashvars']['value'] ), $flashvars ); - if ( ! isset( $flashvars['photo_id'] ) ) + if ( ! isset( $flashvars['photo_id'] ) ) { continue; + } $code_atts = array( 'video' => $flashvars['photo_id'], ); - if ( isset( $flashvars['flickr_show_info_box'] ) && 'true' == $flashvars['flickr_show_info_box'] ) + if ( isset( $flashvars['flickr_show_info_box'] ) && 'true' == $flashvars['flickr_show_info_box'] ) { $code_atts['show_info'] = 'true'; + } - if ( ! empty( $flashvars['photo_secret'] ) ) - $code_atts['secret'] = $flashvars['photo_secret'] ; + if ( ! empty( $flashvars['photo_secret'] ) ) { + $code_atts['secret'] = $flashvars['photo_secret']; + } - if ( ! empty( $params['width']['value'] ) ) + if ( ! empty( $params['width']['value'] ) ) { $code_atts['w'] = (int) $params['width']['value']; + } - if ( ! empty( $params['height']['value'] ) ) + if ( ! empty( $params['height']['value'] ) ) { $code_atts['h'] = (int) $params['height']['value']; + } $code = '[flickr'; - foreach ( $code_atts as $k => $v ) + foreach ( $code_atts as $k => $v ) { $code .= " $k=$v"; + } $code .= ']'; $content = str_replace( $match[0], $code, $content ); @@ -80,25 +90,28 @@ function flickr_embed_to_shortcode( $content ) { return $content; } + add_filter( 'pre_kses', 'flickr_embed_to_shortcode' ); function flickr_shortcode_handler( $atts ) { - $atts = shortcode_atts( array( - 'video' => 0, - 'photo' => 0, - 'show_info' => 0, - 'w' => 400, - 'h' => 300, - 'secret' => 0, - 'size' => 0, - ), $atts, 'flickr' ); + $atts = shortcode_atts( + array( + 'video' => 0, + 'photo' => 0, + 'show_info' => 0, + 'w' => 400, + 'h' => 300, + 'secret' => 0, + 'size' => 0, + ), $atts, 'flickr' + ); if ( ! empty( $atts['video'] ) ) { $showing = 'video'; - $src = $atts['video']; + $src = $atts['video']; } elseif ( ! empty( $atts['photo'] ) ) { $showing = 'photo'; - $src = $atts['photo']; + $src = $atts['photo']; } else { return ''; } @@ -107,19 +120,19 @@ function flickr_shortcode_handler( $atts ) { $src = str_replace( 'http://', 'https://', $src ); } - if ( $showing == 'video' ) { + if ( 'video' === $showing ) { if ( ! is_numeric( $src ) && ! preg_match( '~^(https?:)?//([\da-z\-]+\.)*?((static)?flickr\.com|flic\.kr)/.*~i', $src ) ) { return ''; } - if ( preg_match( "!photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/([0-9]+)/?$!", $src, $m ) ) { + if ( preg_match( '!photos/(([0-9a-zA-Z-_]+)|([0-9]+@N[0-9]+))/([0-9]+)/?$!', $src, $m ) ) { $atts['photo_id'] = $m[4]; } else { $atts['photo_id'] = $atts['video']; } - if ( ! isset( $atts['show_info'] ) || in_array( $atts['show_info'], array('yes', 'true') ) ) { + if ( ! isset( $atts['show_info'] ) || in_array( $atts['show_info'], array( 'yes', 'true' ) ) ) { $atts['show_info'] = 'true'; } elseif ( in_array( $atts['show_info'], array( 'false', 'no' ) ) ) { $atts['show_info'] = 'false'; @@ -141,6 +154,7 @@ function flickr_shortcode_handler( $atts ) { return sprintf( '<iframe src="%s" height="%s" width="%s" frameborder="0" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen></iframe>', esc_url( $src ), esc_attr( $atts['h'] ), esc_attr( $atts['w'] ) ); } + return false; } function flickr_shortcode_video_markup( $atts ) { @@ -148,8 +162,9 @@ function flickr_shortcode_video_markup( $atts ) { $http = ( is_ssl() ) ? 'https://' : 'http://'; $photo_vars = "photo_id=$atts[photo_id]"; - if ( isset( $atts['secret'] ) ) + if ( isset( $atts['secret'] ) ) { $photo_vars .= "&photo_secret=$atts[secret]"; + } return <<<EOD <object type="application/x-shockwave-flash" width="$atts[w]" height="$atts[h]" data="{$http}www.flickr.com/apps/video/stewart.swf?v=1.161" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="$photo_vars&flickr_show_info_box=$atts[show_info]"></param><param name="movie" value="{$http}www.flickr.com/apps/video/stewart.swf?v=1.161"></param><param name="bgcolor" value="#000000"></param><param name="allowFullScreen" value="true"></param><param name="wmode" value="opaque"></param><embed type="application/x-shockwave-flash" src="{$http}www.flickr.com/apps/video/stewart.swf?v=1.161" bgcolor="#000000" allowfullscreen="true" flashvars="$photo_vars&flickr_show_info_box=$atts[show_info]" wmode="opaque" height="$atts[h]" width="$atts[w]"></embed></object> @@ -166,8 +181,8 @@ function jetpack_flickr_oembed_handler( $matches, $attr, $url ) { // e.g. http://www.flickr.com/photos/yarnaholic/sets/72157615194738969/show/ if ( '/show/' !== substr( $url, -strlen( '/show/' ) ) ) { // These lookups need cached, as they don't use WP_Embed (which caches) - $cache_key = md5( $url . serialize( $attr ) ); - $cache_group = 'oembed_flickr'; + $cache_key = md5( $url . serialize( $attr ) ); + $cache_group = 'oembed_flickr'; $html = wp_cache_get( $cache_key, $cache_group ); diff --git a/plugins/jetpack/modules/shortcodes/gist.php b/plugins/jetpack/modules/shortcodes/gist.php index ed01a78f..b5f2c038 100644 --- a/plugins/jetpack/modules/shortcodes/gist.php +++ b/plugins/jetpack/modules/shortcodes/gist.php @@ -1,58 +1,92 @@ <?php - /** * GitHub's Gist site supports oEmbed but their oembed provider only * returns raw HTML (no styling) and the first little bit of the code. * * Their JavaScript-based embed method is a lot better, so that's what we're using. */ -wp_embed_register_handler( 'github-gist', '#https?://gist\.github\.com/([a-zA-Z0-9]+)#', 'github_gist_embed_handler' ); + +wp_embed_register_handler( 'github-gist', '#https?://gist\.github\.com/([a-zA-Z0-9/]+)(\#file\-[a-zA-Z0-9\_\-]+)?#', 'github_gist_embed_handler' ); add_shortcode( 'gist', 'github_gist_shortcode' ); +/** + * Handle gist embeds. + * + * @since 2.8.0 + * + * @global WP_Embed $wp_embed + * + * @param array $matches Results after parsing the URL using the regex in wp_embed_register_handler(). + * @param array $attr Embed attributes. + * @param string $url The original URL that was matched by the regex. + * @param array $rawattr The original unmodified attributes. + * @return string The embed HTML. + */ function github_gist_embed_handler( $matches, $attr, $url, $rawattr ) { - wp_enqueue_script( 'jetpack-gist-embed', plugins_url( 'js/gist.js', __FILE__ ), array( 'jquery' ), false, true ); - // Let the shortcode callback do all the work - return github_gist_shortcode( $attr, $url ); + return github_gist_shortcode( $matches, $url ); } +/** + * Callback for gist shortcode. + * + * @since 2.8.0 + * + * @param array $atts Attributes found in the shortcode. + * @param string $content Content enclosed by the shortcode. + * + * @return string The gist HTML. + */ function github_gist_shortcode( $atts, $content = '' ) { - if ( empty( $atts[0] ) && empty( $content ) ) + if ( empty( $atts[0] ) && empty( $content ) ) { return '<!-- Missing Gist ID -->'; + } $id = ( ! empty( $content ) ) ? $content : $atts[0]; // Parse a URL - if ( ! is_numeric( $id ) ) + if ( ! is_numeric( $id ) ) { $id = preg_replace( '#https?://gist.github.com/([a-zA-Z0-9]+)#', '$1', $id ); + } - if ( ! $id ) + if ( ! $id ) { return '<!-- Invalid Gist ID -->'; + } - if ( ! empty( $atts['file'] ) ) { - $file = '?file=' . urlencode( $atts['file'] ); + wp_enqueue_script( 'jetpack-gist-embed', plugins_url( 'js/gist.js', __FILE__ ), array( 'jquery' ), false, true ); + + if ( false !== strpos( $id, '#file-' ) ) { + // URL points to a specific file in the gist + $id = str_replace( '#file-', '.json?file=', $id ); + $id = preg_replace( '/\-(?!.*\-)/', '.', $id ); } else { - $file = ''; + $file = ( ! empty( $atts['file'] ) ) ? '?file=' . urlencode( $atts['file'] ) : ''; + // URL points to the entire gist + $id .= ".json$file"; } - $embed_url = "{$id}.json" . $file; - // inline style to prevent the bottom margin to the embed that themes like TwentyTen, et al., add to tables - $return = '<style>.gist table { margin-bottom: 0; }</style>' . - '<div class="gist-oembed" data-gist="' . esc_attr( $embed_url ) . '"></div>'; - - if ( isset( $_POST[ 'type' ]) && 'embed' === $_POST[ 'type' ] && - isset( $_POST[ 'action' ] ) && 'parse-embed' === $_POST['action'] ) { + $return = '<style>.gist table { margin-bottom: 0; }</style><div class="gist-oembed" data-gist="' . esc_attr( $id ) . '"></div>'; - return github_gist_simple_embed( $id, $file ); + if ( isset( $_POST[ 'type' ] ) && 'embed' === $_POST[ 'type' ] && + isset( $_POST[ 'action' ] ) && 'parse-embed' === $_POST['action'] ) { + return github_gist_simple_embed( $id ); } - return $return; + return $return; } -function github_gist_simple_embed( $id, $file ) { - $embed_url = $id . '.js' . $file; - - return '<script type="text/javascript" src="//gist.github.com/' . $embed_url . '"></script>'; +/** + * Use script tag to load shortcode in editor. + * + * @since 3.9.0 + * + * @param string $id The ID of the gist. + * + * @return string + */ +function github_gist_simple_embed( $id ) { + $id = str_replace( 'json', 'js', $id ); + return '<script type="text/javascript" src="https://gist.github.com/' . $id . '"></script>'; }
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/houzz.php b/plugins/jetpack/modules/shortcodes/houzz.php new file mode 100644 index 00000000..7e31c50e --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/houzz.php @@ -0,0 +1,29 @@ +<?php + +/* + * Houzz Embed + * + * Examples: + * Post content: + * - [houzz=http://www.houzz.com/pro/james-crisp] + * - http://www.houzz.com/pro/james-crisp + * Blog sidebar: [houzz=http://www.houzz.com/profile/alon w=200 h=300] + */ + +// Register oEmbed provider +wp_oembed_add_provider( '#https?://(.+?\.)?houzz\.(com|co\.uk|com\.au|de|fr|ru|jp|it|es|dk|se)/.*#i', 'https://www.houzz.com/oembed', true ); + +// Create Shortcode +function jetpack_houzz_shortcode( $atts, $content=null ) { + $url = substr( $atts[0], 1 ); + $args = array(); + if ( isset( $atts['w'] ) && is_numeric( $atts['w'] ) ) { + $args['width'] = $atts['w']; + } + if ( isset( $atts['h'] ) && is_numeric( $atts['h'] ) ) { + $args['height'] = $atts['h']; + } + $oembed = _wp_oembed_get_object(); + return $oembed->get_html( $url, $args ); +} +add_shortcode( 'houzz', 'jetpack_houzz_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/instagram.php b/plugins/jetpack/modules/shortcodes/instagram.php index 43d7d28a..08c8ceb0 100644 --- a/plugins/jetpack/modules/shortcodes/instagram.php +++ b/plugins/jetpack/modules/shortcodes/instagram.php @@ -8,8 +8,9 @@ * @return (string) the filtered or the original content **/ function jetpack_instagram_embed_reversal( $content ) { - if ( false === stripos( $content, 'instagram.com' ) ) + if ( false === stripos( $content, 'instagram.com' ) ) { return $content; + } /* Sample embed code: <blockquote class="instagram-media" data-instgrm-captioned data-instgrm-version="2" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:8px;"><div style=" background:#F8F8F8; line-height:0; margin-top:40px; padding-bottom:55%; padding-top:45%; text-align:center; width:100%;"><div style="position:relative;"><div style=" -webkit-animation:dkaXkpbBxI 1s ease-out infinite; animation:dkaXkpbBxI 1s ease-out infinite; background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAAGFBMVEUiIiI9PT0eHh4gIB4hIBkcHBwcHBwcHBydr+JQAAAACHRSTlMABA4YHyQsM5jtaMwAAADfSURBVDjL7ZVBEgMhCAQBAf//42xcNbpAqakcM0ftUmFAAIBE81IqBJdS3lS6zs3bIpB9WED3YYXFPmHRfT8sgyrCP1x8uEUxLMzNWElFOYCV6mHWWwMzdPEKHlhLw7NWJqkHc4uIZphavDzA2JPzUDsBZziNae2S6owH8xPmX8G7zzgKEOPUoYHvGz1TBCxMkd3kwNVbU0gKHkx+iZILf77IofhrY1nYFnB/lQPb79drWOyJVa/DAvg9B/rLB4cC+Nqgdz/TvBbBnr6GBReqn/nRmDgaQEej7WhonozjF+Y2I/fZou/qAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-44px; width:44px;"></div><span style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:12px; font-style:normal; font-weight:bold; position:relative; top:15px;">Loading</span></div></div><p style=" font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin:8px 0 0 0; padding:0 4px; word-wrap:break-word;"> Balloons</p><p style=" line-height:32px; margin-bottom:0; margin-top:8px; padding:0; text-align:center;"> <a href="https://instagram.com/p/r9vfPrmjeB/" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; text-decoration:none;" target="_top"> View on Instagram</a></p></div><style>@-webkit-keyframes"dkaXkpbBxI"{ 0%{opacity:0.5;} 50%{opacity:1;} 100%{opacity:0.5;} } @keyframes"dkaXkpbBxI"{ 0%{opacity:0.5;} 50%{opacity:1;} 100%{opacity:0.5;} }</style></blockquote> @@ -31,16 +32,18 @@ function jetpack_instagram_embed_reversal( $content ) { $regexes[] = '#<iframe(?:[^&]|&(?!gt;))+?src="(?:https?:)?//instagram\.com/p/([^"\'/]++)[^"\']*?"(?:[^&]|&(?!gt;))*+>\s*?</iframe>#i'; foreach ( $regexes as $regex ) { - if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) - continue; + if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { + continue; + } foreach ( $matches as $match ) { - if ( ! preg_match( '#(https?:)?//instagr(\.am|am\.com)/p/([^/]*)#i', $match[2], $url_matches ) ) + if ( ! preg_match( '#(https?:)?//instagr(\.am|am\.com)/p/([^/]*)#i', $match[2], $url_matches ) ) { continue; + } // Since we support Instagram via oEmbed, we simply leave a link on a line by itself. $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) ); - $url = esc_url( $url_matches[0] ); + $url = esc_url( $url_matches[0] ); $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $url ), $content ); /** This action is documented in modules/shortcodes/youtube.php */ @@ -50,14 +53,14 @@ function jetpack_instagram_embed_reversal( $content ) { return $content; } -add_filter( 'pre_kses', 'jetpack_instagram_embed_reversal' ); +add_filter( 'pre_kses', 'jetpack_instagram_embed_reversal' ); /** * Instagram */ -wp_oembed_remove_provider( '#http://instagr(\.am|am\.com)/p/.*#i' ); // remove core's oEmbed support so we can override -wp_embed_register_handler( 'jetpack_instagram', '#http(s?)://instagr(\.am|am\.com)/p/([^/]*)#i', 'jetpack_instagram_handler' ); +wp_oembed_remove_provider( '#https?://(www\.)?instagr(\.am|am\.com)/p/.*#i' ); // remove core's oEmbed support so we can override +wp_embed_register_handler( 'jetpack_instagram', '#http(s?)://(www\.)?instagr(\.am|am\.com)/p/([^/]*)#i', 'jetpack_instagram_handler' ); function jetpack_instagram_handler( $matches, $atts, $url ) { global $content_width; @@ -69,19 +72,19 @@ function jetpack_instagram_handler( $matches, $atts, $url ) { $min_width = 320; if ( is_feed() ) { - $media_url = sprintf( 'http://instagr.am/p/%s/media/?size=l', $matches[3] ); + $media_url = sprintf( 'http://instagr.am/p/%s/media/?size=l', $matches[4] ); return sprintf( '<a href="%s" title="%s"><img src="%s" alt="Instagram Photo" /></a>', esc_url( $url ), esc_attr__( 'View on Instagram', 'jetpack' ), esc_url( $media_url ) ); } $atts = shortcode_atts( array( - 'width' => isset( $content_width ) ? $content_width : $max_width, + 'width' => isset( $content_width ) ? $content_width : $max_width, 'hidecaption' => false, ), $atts ); $atts['width'] = absint( $atts['width'] ); - if ( $atts['width'] > $max_width || $min_width > $atts['width'] ) + if ( $atts['width'] > $max_width || $min_width > $atts['width'] ) { $atts['width'] = $max_width; - + } // remove the modal param from the URL $url = remove_query_arg( 'modal', $url ); @@ -90,11 +93,11 @@ function jetpack_instagram_handler( $matches, $atts, $url ) { $url = str_replace( 'instagr.am', 'instagram.com', $url ); // The oembed endpoint expects HTTP, but HTTP requests 301 to HTTPS - $instagram_http_url = str_replace( 'https://', 'http://', $url ); + $instagram_http_url = str_replace( 'https://', 'http://', $url ); $instagram_https_url = str_replace( 'http://', 'https://', $url ); $url_args = array( - 'url' => $instagram_http_url, + 'url' => $instagram_http_url, 'maxwidth' => $atts['width'], ); @@ -111,17 +114,17 @@ function jetpack_instagram_handler( $matches, $atts, $url ) { * * @module shortcodes * - * @since 3.3.0 + * @since 3.3.0 * - * @param bool false Object caching is off by default. - * @param array $matches Array of Instagram URLs found in the post. - * @param array $atts Instagram Shortcode attributes. + * @param bool false Object caching is off by default. + * @param array $matches Array of Instagram URLs found in the post. + * @param array $atts Instagram Shortcode attributes. * @param string $passed_url Instagram API URL. */ $response_body_use_cache = apply_filters( 'instagram_cache_oembed_api_response_body', false, $matches, $atts, $passed_url ); - $response_body = false; + $response_body = false; if ( $response_body_use_cache ) { - $cache_key = 'oembed_response_body_' . md5( $url ); + $cache_key = 'oembed_response_body_' . md5( $url ); $response_body = wp_cache_get( $cache_key, 'instagram_embeds' ); } @@ -129,7 +132,7 @@ function jetpack_instagram_handler( $matches, $atts, $url ) { // Not using cache (default case) or cache miss $instagram_response = wp_remote_get( $url, array( 'redirection' => 0 ) ); if ( is_wp_error( $instagram_response ) || 200 != $instagram_response['response']['code'] || empty( $instagram_response['body'] ) ) { - return "<!-- instagram error: invalid instagram resource -->"; + return '<!-- instagram error: invalid instagram resource -->'; } $response_body = json_decode( $instagram_response['body'] ); @@ -143,24 +146,24 @@ function jetpack_instagram_handler( $matches, $atts, $url ) { wp_enqueue_script( 'jetpack-instagram-embed', plugins_url( 'js/instagram.js', __FILE__ ), array( 'jquery' ), false, true ); // there's a script in the response, which we strip on purpose since it's added by this ^ script $ig_embed = preg_replace( '@<(script)[^>]*?>.*?</\\1>@si', '', $response_body->html ); + return $ig_embed; } return '<!-- instagram error: no embed found -->'; } - // filters instagram's username format to the expected format that matches the embed handler wp_embed_register_handler( 'jetpack_instagram_alternate_format', '#http(s?)://instagr(\.am|am\.com)/([^/]*)/p/([^/]*)#i', 'jetpack_instagram_alternate_format_handler' ); function jetpack_instagram_alternate_format_handler( $matches, $atts, $url ) { - $url = esc_url_raw( 'https://instagram.com/p/' . $matches[4] ); + $url = esc_url_raw( 'https://instagram.com/p/' . $matches[4] ); $matches[0] = $url; $matches[3] = $matches[4]; unset( $matches[4] ); + return jetpack_instagram_handler( $matches, $atts, $url ); } - // [instagram url="http://instagram.com/p/PSbF9sEIGP/"] // [instagram url="http://instagram.com/p/PSbF9sEIGP/" width="300"] add_shortcode( 'instagram', 'jetpack_shortcode_instagram' ); diff --git a/plugins/jetpack/modules/shortcodes/js/facebook.js b/plugins/jetpack/modules/shortcodes/js/facebook.js deleted file mode 100644 index f955effc..00000000 --- a/plugins/jetpack/modules/shortcodes/js/facebook.js +++ /dev/null @@ -1,29 +0,0 @@ -/* global FB, jpfbembed */ -(function( window ) { - var facebookEmbed = function() { - if ( 'undefined' !== typeof FB && FB.XFBML ) { - FB.XFBML.parse(); - } else { - var fbroot = document.createElement( 'div' ); - fbroot.id = 'fb-root'; - document.getElementsByTagName( 'body' )[0].appendChild( fbroot ); - - jQuery.getScript( '//connect.facebook.net/en_US/sdk.js' ); - } - }; - - 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 ); - } - - facebookEmbed(); -})( this ); diff --git a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js b/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js index 38531e0c..d2a04c5e 100644 --- a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js +++ b/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js @@ -36,12 +36,17 @@ JetpackSlideshow.prototype.init = function() { img.title = typeof( imageInfo.title ) !== 'undefined' ? imageInfo.title : ''; img.alt = typeof( imageInfo.alt ) !== 'undefined' ? imageInfo.alt : ''; img.align = 'middle'; + img.setAttribute('itemprop','image'); img.nopin = 'nopin'; var caption = document.createElement( 'div' ); caption.className = 'slideshow-slide-caption'; + caption.setAttribute('itemprop','caption description'); caption.innerHTML = imageInfo.caption; var container = document.createElement('div'); container.className = 'slideshow-slide'; + container.setAttribute('itemprop','associatedMedia'); + container.setAttribute('itemscope',''); + container.setAttribute('itemtype','http://schema.org/ImageObject'); // Hide loading image once first image has loaded. if ( i === 0 ) { diff --git a/plugins/jetpack/modules/shortcodes/presentations.php b/plugins/jetpack/modules/shortcodes/presentations.php index aa4f42ee..aac538b7 100644 --- a/plugins/jetpack/modules/shortcodes/presentations.php +++ b/plugins/jetpack/modules/shortcodes/presentations.php @@ -76,7 +76,6 @@ presentation unless overridden by individual slides. */ if ( ! class_exists( 'Presentations' ) ) : - class Presentations { private $presentation_settings; @@ -88,23 +87,24 @@ class Presentations { */ function __construct() { // Bail without 3.0. - if ( ! function_exists( '__return_false' ) ) + if ( ! function_exists( '__return_false' ) ) { return; + } - $this->presentation_initialized = false; + $this->presentation_initialized = false; $this->scripts_and_style_included = false; // Registers shortcodes add_action( 'wp_head', array( &$this, 'add_scripts' ), 1 ); add_shortcode( 'presentation', array( &$this, 'presentation_shortcode' ) ); - add_shortcode( 'slide', array( &$this, 'slide_shortcode' ) ); + add_shortcode( 'slide', array( &$this, 'slide_shortcode' ) ); } function add_scripts() { $this->scripts_and_style_included = false; - if ( empty( $GLOBALS['posts'] ) || !is_array( $GLOBALS['posts'] ) ) { + if ( empty( $GLOBALS['posts'] ) || ! is_array( $GLOBALS['posts'] ) ) { return; } @@ -115,45 +115,40 @@ class Presentations { } } - if ( ! $this->scripts_and_style_included ) + if ( ! $this->scripts_and_style_included ) { return; + } $plugin = plugin_dir_url( __FILE__ ); // Add CSS - wp_enqueue_style('presentations', $plugin . 'css/style.css'); + wp_enqueue_style( 'presentations', $plugin . 'css/style.css' ); // Add JavaScript - wp_enqueue_script('jquery'); - wp_enqueue_script('jmpress', - $plugin . 'js/jmpress.min.js', - array('jquery'), - '0.4.5', - true); - wp_enqueue_script('presentations', - $plugin . 'js/main.js', - array('jquery', 'jmpress'), - false, - true); + wp_enqueue_script( 'jquery' ); + wp_enqueue_script( 'jmpress', $plugin . 'js/jmpress.min.js', array( 'jquery' ), '0.4.5', true ); + wp_enqueue_script( 'presentations', $plugin . 'js/main.js', array( 'jquery', 'jmpress' ), false, true ); } - function presentation_shortcode( $atts, $content='' ) { + function presentation_shortcode( $atts, $content = '' ) { // Mark that we've found a valid [presentation] shortcode $this->presentation_initialized = true; - $atts = shortcode_atts( array( - 'duration' => '', - 'height' => '', - 'width' => '', - 'bgcolor' => '', - 'bgimg' => '', - 'autoplay' => '', - - // Settings - 'transition' => '', - 'scale' => '', - 'rotate' => '', - 'fade' => '', - 'fadebullets' => '', - ), $atts, 'presentation' ); + $atts = shortcode_atts( + array( + 'duration' => '', + 'height' => '', + 'width' => '', + 'bgcolor' => '', + 'bgimg' => '', + 'autoplay' => '', + + // Settings + 'transition' => '', + 'scale' => '', + 'rotate' => '', + 'fade' => '', + 'fadebullets' => '', + ), $atts, 'presentation' + ); $this->presentation_settings = array( 'transition' => 'down', @@ -162,51 +157,60 @@ class Presentations { 'fade' => 'on', 'fadebullets' => 0, 'last' => array( - 'x' => 0, - 'y' => 0, - 'scale' => 1, - 'rotate' => 0, + 'x' => 0, + 'y' => 0, + 'scale' => 1, + 'rotate' => 0, ), ); // Set the presentation-wide settings - if ( '' != trim( $atts['transition'] ) ) + if ( '' != trim( $atts['transition'] ) ) { $this->presentation_settings['transition'] = $atts['transition']; + } - if ( '' != trim( $atts['scale'] ) ) + if ( '' != trim( $atts['scale'] ) ) { $this->presentation_settings['scale'] = floatval( $atts['scale'] ); + } - if ( '' != trim( $atts['rotate'] ) ) + if ( '' != trim( $atts['rotate'] ) ) { $this->presentation_settings['rotate'] = floatval( $atts['rotate'] ); + } - if ( '' != trim( $atts['fade'] ) ) + if ( '' != trim( $atts['fade'] ) ) { $this->presentation_settings['fade'] = $atts['fade']; + } - if ( '' != trim( $atts['fadebullets'] ) ) + if ( '' != trim( $atts['fadebullets'] ) ) { $this->presentation_settings['fadebullets'] = $atts['fadebullets']; + } // Set any settings the slides don't care about - if ( '' != trim( $atts['duration'] ) ) + if ( '' != trim( $atts['duration'] ) ) { $duration = floatval( $atts['duration'] ) . 's'; - else + } else { $duration = '1s'; + } // Autoplay durations are set in milliseconds - if ( '' != trim( $atts['autoplay'] ) ) + if ( '' != trim( $atts['autoplay'] ) ) { $autoplay = floatval( $atts['autoplay'] ) * 1000; - else - $autoplay = 0; // No autoplay + } else { + $autoplay = 0; + } // No autoplay // Set the presentation size as specified or with some nicely sized dimensions - if ( '' != trim( $atts['width'] ) ) + if ( '' != trim( $atts['width'] ) ) { $this->presentation_settings['width'] = intval( $atts['width'] ); - else + } else { $this->presentation_settings['width'] = 480; + } - if ( '' != trim( $atts['height'] ) ) + if ( '' != trim( $atts['height'] ) ) { $this->presentation_settings['height'] = intval( $atts['height'] ); - else + } else { $this->presentation_settings['height'] = 370; + } // Hide the content by default in case the scripts fail $style = 'display: none; width: ' . $this->presentation_settings['width'] . 'px; height: ' . $this->presentation_settings['height'] . 'px;'; @@ -223,99 +227,115 @@ class Presentations { // Not supported message style is inlined incase the style sheet doesn't get included $out = "<section class='presentation-wrapper'>"; - $out.= "<p class='not-supported-msg' style='display: inherit; padding: 25%; text-align: center;'>"; - $out.= __( 'This slideshow could not be started. Try refreshing the page or viewing it in another browser.' , 'jetpack' ) . '</p>'; + $out .= "<p class='not-supported-msg' style='display: inherit; padding: 25%; text-align: center;'>"; + $out .= __( 'This slideshow could not be started. Try refreshing the page or viewing it in another browser.', 'jetpack' ) . '</p>'; // Bail out unless the scripts were added if ( $this->scripts_and_style_included ) { - $out.= sprintf( + $out .= sprintf( '<div class="presentation" duration="%s" data-autoplay="%s" style="%s">', esc_attr( $duration ), esc_attr( $autoplay ), esc_attr( $style ) ); - $out.= "<div class='nav-arrow-left'></div>"; - $out.= "<div class='nav-arrow-right'></div>"; - $out.= "<div class='nav-fullscreen-button'></div>"; + $out .= "<div class='nav-arrow-left'></div>"; + $out .= "<div class='nav-arrow-right'></div>"; + $out .= "<div class='nav-fullscreen-button'></div>"; if ( $autoplay ) { - $out.= "<div class='autoplay-overlay' style='display: none'><p class='overlay-msg'>"; - $out.= __( 'Click to autoplay the presentation!' , 'jetpack' ); - $out.= "</p></div>"; + $out .= '<div class="autoplay-overlay" style="display: none;"><p class="overlay-msg">'; + $out .= __( 'Click to autoplay the presentation!', 'jetpack' ); + $out .= '</p></div>'; } - $out.= do_shortcode( $content ); + $out .= do_shortcode( $content ); } - $out.= "</section>"; + $out .= '</section>'; $this->presentation_initialized = false; + return $out; } function slide_shortcode( $atts, $content = '' ) { // Bail out unless wrapped by a [presentation] shortcode - if ( ! $this->presentation_initialized ) + if ( ! $this->presentation_initialized ) { return $content; + } - $atts = shortcode_atts( array( - 'transition' => '', - 'scale' => '', - 'rotate' => '', - 'fade' => '', - 'fadebullets'=> '', - 'bgcolor' => '', - 'bgimg' => '', - ), $atts, 'slide' ); + $atts = shortcode_atts( + array( + 'transition' => '', + 'scale' => '', + 'rotate' => '', + 'fade' => '', + 'fadebullets' => '', + 'bgcolor' => '', + 'bgimg' => '', + ), $atts, 'slide' + ); // Determine positioning based on transition - if ( '' == trim( $atts['transition'] ) ) + if ( '' == trim( $atts['transition'] ) ) { $atts['transition'] = $this->presentation_settings['transition']; + } // Setting the content scale - if ( '' == trim( $atts['scale'] ) ) + if ( '' == trim( $atts['scale'] ) ) { $atts['scale'] = $this->presentation_settings['scale']; + } - if( '' == trim( $atts['scale'] ) ) + if ( '' == trim( $atts['scale'] ) ) { $scale = 1; - else + } else { $scale = floatval( $atts['scale'] ); + } - if ( $scale < 0 ) + if ( $scale < 0 ) { $scale *= -1; + } // Setting the content rotation - if ( '' == trim( $atts['rotate'] ) ) + if ( '' == trim( $atts['rotate'] ) ) { $atts['rotate'] = $this->presentation_settings['rotate']; + } - if( '' == trim( $atts['rotate'] ) ) + if ( '' == trim( $atts['rotate'] ) ) { $rotate = 0; - else + } else { $rotate = floatval( $atts['rotate'] ); + } // Setting if the content should fade - if ( '' == trim( $atts['fade'] ) ) + if ( '' == trim( $atts['fade'] ) ) { $atts['fade'] = $this->presentation_settings['fade']; + } - if ( 'on' == $atts['fade'] || 'true' == $atts['fade'] ) + if ( 'on' == $atts['fade'] || 'true' == $atts['fade'] ) { $fade = 'fade'; - else + } else { $fade = ''; + } // Setting if bullets should fade on step changes - if ( '' == trim( $atts['fadebullets'] ) ) + if ( '' == trim( $atts['fadebullets'] ) ) { $atts['fadebullets'] = $this->presentation_settings['fadebullets']; + } - if ( 'on' == $atts['fadebullets'] || 'true' == $atts['fadebullets'] ) + if ( 'on' == $atts['fadebullets'] || 'true' == $atts['fadebullets'] ) { $fadebullets = 'fadebullets'; - else + } else { $fadebullets = ''; + } - $coords = $this->get_coords( array( - 'transition' => $atts['transition'], - 'scale' => $scale, - 'rotate' => $rotate, - )); + $coords = $this->get_coords( + array( + 'transition' => $atts['transition'], + 'scale' => $scale, + 'rotate' => $rotate, + ) + ); $x = $coords['x']; $y = $coords['y']; @@ -342,31 +362,33 @@ class Presentations { esc_attr( $style ) ); - $out.= "<div class='slide-content'>"; - $out.= do_shortcode( $content ); - $out.= "</div></div>"; + $out .= '<div class="slide-content">'; + $out .= do_shortcode( $content ); + $out .= '</div></div>'; + return $out; } /** * Determines the position of the next slide based on the position and scaling of the previous slide. * - * @param array $args: an array with the following key-value pairs - * string $transition: the transition name, "up", "down", "left", or "right" - * float $scale: the scale of the next slide (used to determine the position of the slide after that) + * @param array $args : an array with the following key-value pairs + * string $transition: the transition name, "up", "down", "left", or "right" + * float $scale: the scale of the next slide (used to determine the position of the slide after that) * * @return array with the 'x' and 'y' coordinates of the slide */ function get_coords( $args ) { - if ( 0 == $args['scale'] ) + if ( 0 == $args['scale'] ) { $args['scale'] = 1; + } $width = $this->presentation_settings['width']; $height = $this->presentation_settings['height']; $last = $this->presentation_settings['last']; $scale = $last['scale']; - $next = array( + $next = array( 'x' => $last['x'], 'y' => $last['y'], 'scale' => $args['scale'], @@ -375,7 +397,7 @@ class Presentations { // All angles are measured from the vertical axis, so everything is backwards! $diagAngle = atan2( $width, $height ); - $diagonal = sqrt( pow( $width, 2 ) + pow( $height, 2 ) ); + $diagonal = sqrt( pow( $width, 2 ) + pow( $height, 2 ) ); // We offset the angles by the angle formed by the diagonal so that // we can multiply the sines directly against the diagonal length @@ -383,21 +405,21 @@ class Presentations { $phi = deg2rad( $next['rotate'] ) - $diagAngle; // We start by displacing by the slide dimensions - $totalHorizDisp = $width * $scale; + $totalHorizDisp = $width * $scale; $totalVertDisp = $height * $scale; // If the previous slide was rotated, we add the incremental offset from the rotation // Namely the difference between the regular dimension (no rotation) and the component // of the diagonal for that angle - $totalHorizDisp += ( ( ( abs( sin( $theta ) ) * $diagonal) - $width ) / 2) * $scale; - $totalVertDisp += ( ( ( abs( cos( $theta ) ) * $diagonal) - $height) / 2) * $scale; + $totalHorizDisp += ( ( ( abs( sin( $theta ) ) * $diagonal ) - $width ) / 2 ) * $scale; + $totalVertDisp += ( ( ( abs( cos( $theta ) ) * $diagonal ) - $height ) / 2 ) * $scale; // Similarly, we check if the current slide has been rotated and add whatever additional // offset has been added. This is so that two rotated corners don't clash with each other. // Note: we are checking the raw angle relative to the vertical axis, NOT the diagonal angle. - if ( $next['rotate'] % 180 != 0 ){ - $totalHorizDisp += ( abs( ( sin( $phi ) * $diagonal ) - $width ) / 2) * $next['scale']; - $totalVertDisp += ( abs( ( cos( $phi ) * $diagonal ) - $height ) / 2) * $next['scale']; + if ( 0 !== $next['rotate'] % 180 ) { + $totalHorizDisp += ( abs( ( sin( $phi ) * $diagonal ) - $width ) / 2 ) * $next['scale']; + $totalVertDisp += ( abs( ( cos( $phi ) * $diagonal ) - $height ) / 2 ) * $next['scale']; } switch ( trim( $args['transition'] ) ) { @@ -423,6 +445,7 @@ class Presentations { } $this->presentation_settings['last'] = $next; + return $next; } } diff --git a/plugins/jetpack/modules/shortcodes/scribd.php b/plugins/jetpack/modules/shortcodes/scribd.php index a334fd55..7a278ea1 100644 --- a/plugins/jetpack/modules/shortcodes/scribd.php +++ b/plugins/jetpack/modules/shortcodes/scribd.php @@ -15,7 +15,7 @@ function scribd_shortcode_handler( $atts ) { $atts = shortcode_atts( array( 'id' => 0, 'key' => 0, - 'mode' => "", + 'mode' => '', ), $atts, 'scribd' ); $modes = array( 'list', 'book', 'slide', 'slideshow', 'tile' ); @@ -24,8 +24,9 @@ function scribd_shortcode_handler( $atts ) { if ( preg_match( '/^[A-Za-z0-9-]+$/', $atts['key'], $m ) ) { $atts['key'] = $m[0]; - if ( !in_array( $atts['mode'], $modes ) ) + if ( ! in_array( $atts['mode'], $modes ) ) { $atts['mode'] = ''; + } return scribd_shortcode_markup( $atts ); } else { @@ -41,6 +42,7 @@ EOD; return $markup; } + add_shortcode( 'scribd', 'scribd_shortcode_handler' ); // Scribd supports HTTPS, so use that endpoint to get HTTPS-compatible embeds @@ -48,6 +50,8 @@ function scribd_https_oembed( $providers ) { if ( isset( $providers['#https?://(www\.)?scribd\.com/doc/.*#i'] ) ) { $providers['#https?://(www\.)?scribd\.com/doc/.*#i'][0] = 'https://www.scribd.com/services/oembed'; } + return $providers; } + add_filter( 'oembed_providers', 'scribd_https_oembed' ); diff --git a/plugins/jetpack/modules/shortcodes/slideshare.php b/plugins/jetpack/modules/shortcodes/slideshare.php index 6b452039..f2278935 100644 --- a/plugins/jetpack/modules/shortcodes/slideshare.php +++ b/plugins/jetpack/modules/shortcodes/slideshare.php @@ -10,13 +10,15 @@ wp_oembed_add_provider( '#https?://(www\.)?slideshare\.net/.*#i', 'https://www.s * New style: [slideshare id=5342235&w=300&h=200&fb=0&mw=0&mh=0&sc=no] * * Legend: - * id = Document ID provided by Slideshare - * w = Width of iFrame (int) - * h = Height of iFrame (int) - * fb = iFrame frameborder (int) - * mw = iFrame marginwidth (int) - * mh = iFrame marginheight (int) - * sc = iFrame Scrollbar (yes/no) + * id = Document ID provided by Slideshare + * w = Width of iFrame (int) + * h = Height of iFrame (int) + * fb = iFrame frameborder (int) + * mw = iFrame marginwidth (int) + * mh = iFrame marginheight (int) + * sc = iFrame Scrollbar (yes/no) + * pro = Slideshare Pro (yes/no) + * style = Inline CSS (string) **/ add_shortcode( 'slideshare', 'slideshare_shortcode' ); @@ -27,60 +29,85 @@ function slideshare_shortcode( $atts ) { $params = shortcode_new_to_old_params( $atts ); parse_str( $params, $arguments ); - if ( empty( $arguments ) ) + if ( empty( $arguments ) ) { return '<!-- SlideShare error: no arguments -->'; + } - extract( $arguments ); + $attr = shortcode_atts( + array( + 'id' => '', + 'w' => '', + 'h' => '', + 'fb' => '', + 'mw' => '', + 'mh' => '', + 'sc' => '', + 'pro' => '', + 'style' => '', + ), $arguments + ); // check that the Slideshare ID contains letters, numbers and query strings $pattern = '/[^-_a-zA-Z0-9?=&]/'; - if ( empty( $id ) || preg_match( $pattern, $id ) ) + if ( empty( $attr['id'] ) || preg_match( $pattern, $attr['id'] ) ) { return '<!-- SlideShare error: id is missing or has illegal characters -->'; + } // check the width/height - if ( empty( $w ) && ! empty( $content_width ) ) + $w = $attr['w']; + if ( empty( $w ) && ! empty( $content_width ) ) { $w = intval( $content_width ); - elseif ( ! ( $w = intval( $w ) ) || $w < 300 || $w > 1600 ) + } elseif ( ! ( $w = intval( $w ) ) || $w < 300 || $w > 1600 ) { $w = 425; - else + } else { $w = intval( $w ); + } - $h = ceil( $w * 348 / 425 ); + $h = ceil( $w * 348 / 425 ); // Note: user-supplied height is ignored. - if ( isset( $pro ) ) { - $source = "https://www.slideshare.net/slidesharepro/$id"; + if ( isset( $attr['pro'] ) && $attr['pro'] ) { + $source = 'https://www.slideshare.net/slidesharepro/' . $attr['id']; } else { - $source = "https://www.slideshare.net/slideshow/embed_code/$id"; + $source = 'https://www.slideshare.net/slideshow/embed_code/' . $attr['id']; } - if ( isset( $rel ) ) + if ( isset( $rel ) ) { $source = add_query_arg( 'rel', intval( $rel ), $source ); + } - if ( isset( $startSlide ) ) + if ( isset( $startSlide ) ) { $source = add_query_arg( 'startSlide', intval( $startSlide ), $source ); + } $player = sprintf( "<iframe src='%s' width='%d' height='%d'", esc_url( $source ), $w, $h ); // check the frameborder - if ( isset( $fb ) ) - $player .= " frameborder='" . intval( $fb ) . "'"; + if ( ! empty( $attr['fb'] ) || '0' === $attr['fb'] ) { + $player .= " frameborder='" . intval( $attr['fb'] ) . "'"; + } // check the margin width; if not empty, cast as int - if ( isset( $mw ) ) - $player .= " marginwidth='" . intval( $mw ) . "'"; + if ( ! empty( $attr['mw'] ) || '0' === $attr['mw'] ) { + $player .= " marginwidth='" . intval( $attr['mw'] ) . "'"; + } // check the margin height, if not empty, cast as int - if ( isset( $mh ) ) - $player .= " marginheight='" . intval( $mh ) . "'"; + if ( ! empty( $attr['mh'] ) || '0' === $attr['mh'] ) { + $player .= " marginheight='" . intval( $attr['mh'] ) . "'"; + } - if ( ! empty( $style ) ) - $player .= " style='" . $style . "'"; + if ( ! empty( $attr['style'] ) ) { + $player .= " style='" . esc_attr( $attr['style'] ) . "'"; + } // check the scrollbar; cast as a lowercase string for comparison - $sc = isset( $sc ) ? strtolower( $sc ) : ''; + if ( ! empty( $attr['sc'] ) ) { + $sc = strtolower( $attr['sc'] ); - if ( in_array( $sc, array( 'yes', 'no' ) ) ) - $player .= " scrolling='" . $sc . "'"; + if ( in_array( $sc, array( 'yes', 'no' ) ) ) { + $player .= " scrolling='" . $sc . "'"; + } + } $player .= ' allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>'; diff --git a/plugins/jetpack/modules/shortcodes/slideshow.php b/plugins/jetpack/modules/shortcodes/slideshow.php index 8132de8c..0ff568d3 100644 --- a/plugins/jetpack/modules/shortcodes/slideshow.php +++ b/plugins/jetpack/modules/shortcodes/slideshow.php @@ -190,6 +190,7 @@ class Jetpack_Slideshow_Shortcode { 'title' => (string) esc_attr( $attachment_image_title ), 'alt' => (string) esc_attr( $attachment_image_alt ), 'caption' => (string) $caption, + 'itemprop' => 'image', ); } @@ -241,7 +242,7 @@ class Jetpack_Slideshow_Shortcode { $output .= '<p class="jetpack-slideshow-noscript robots-nocontent">' . esc_html__( 'This slideshow requires JavaScript.', 'jetpack' ) . '</p>'; $output .= sprintf( - '<div id="%s" class="slideshow-window jetpack-slideshow slideshow-%s" data-trans="%s" data-autostart="%s" data-gallery="%s"></div>', + '<div id="%s" class="slideshow-window jetpack-slideshow slideshow-%s" data-trans="%s" data-autostart="%s" data-gallery="%s" itemscope itemtype="http://schema.org/ImageGallery"></div>', esc_attr( $attr['selector'] . '-slideshow' ), esc_attr( $attr['color'] ), esc_attr( $attr['trans'] ), diff --git a/plugins/jetpack/modules/shortcodes/soundcloud.php b/plugins/jetpack/modules/shortcodes/soundcloud.php index d3fb9f68..3295bf01 100644 --- a/plugins/jetpack/modules/shortcodes/soundcloud.php +++ b/plugins/jetpack/modules/shortcodes/soundcloud.php @@ -27,27 +27,28 @@ All custom modifs are annoted with "A8C" keyword in comment. * Register oEmbed provider */ -wp_oembed_add_provider('#https?://(?:api\.)?soundcloud\.com/.*#i', 'http://soundcloud.com/oembed', true); +wp_oembed_add_provider( '#https?://(?:api\.)?soundcloud\.com/.*#i', 'http://soundcloud.com/oembed', true ); /** * Register SoundCloud shortcode */ -add_shortcode("soundcloud", "soundcloud_shortcode"); - +add_shortcode( 'soundcloud', 'soundcloud_shortcode' ); /** * SoundCloud shortcode handler - * @param {string|array} $atts The attributes passed to the shortcode like [soundcloud attr1="value" /]. + * + * @param string|array $atts The attributes passed to the shortcode like [soundcloud attr1="value" /]. * Is an empty string when no arguments are given. - * @param {string} $content The content between non-self closing [soundcloud]…[/soundcloud] tags. - * @return {string} Widget embed code HTML + * @param string $content The content between non-self closing [soundcloud]...[/soundcloud] tags. + * + * @return string Widget embed code HTML */ function soundcloud_shortcode( $atts, $content = null ) { // Custom shortcode options - $shortcode_options = array_merge( array('url' => trim( $content ) ), is_array( $atts ) ? $atts : array() ); + $shortcode_options = array_merge( array( 'url' => trim( $content ) ), is_array( $atts ) ? $atts : array() ); // Turn shortcode option "param" (param=value¶m2=value) into array $shortcode_params = array(); @@ -61,17 +62,21 @@ function soundcloud_shortcode( $atts, $content = null ) { $isVisual = ! $player_type || $player_type === 'visual' || $shortcode_options['visual']; // User preference options - $plugin_options = array_filter(array( - 'iframe' => $isIframe, - 'width' => soundcloud_get_option( 'player_width' ), - 'height' => soundcloud_url_has_tracklist( $shortcode_options['url'] ) ? soundcloud_get_option( 'player_height_multi' ) : soundcloud_get_option( 'player_height' ), - 'params' => array_filter( array( - 'auto_play' => soundcloud_get_option( 'auto_play' ), - 'show_comments' => soundcloud_get_option( 'show_comments' ), - 'color' => soundcloud_get_option( 'color' ), - 'visual' => ( $isVisual ? 'true' : 'false' ) - )), - )); + $plugin_options = array_filter( + array( + 'iframe' => $isIframe, + 'width' => soundcloud_get_option( 'player_width' ), + 'height' => soundcloud_url_has_tracklist( $shortcode_options['url'] ) ? soundcloud_get_option( 'player_height_multi' ) : soundcloud_get_option( 'player_height' ), + 'params' => array_filter( + array( + 'auto_play' => soundcloud_get_option( 'auto_play' ), + 'show_comments' => soundcloud_get_option( 'show_comments' ), + 'color' => soundcloud_get_option( 'color' ), + 'visual' => ( $isVisual ? 'true' : 'false' ), + ) + ), + ) + ); // Needs to be an array if ( ! isset( $plugin_options['params'] ) ) { @@ -98,11 +103,11 @@ function soundcloud_shortcode( $atts, $content = null ) { } // Both "width" and "height" need to be integers - if (isset( $options['width'] ) && ! preg_match( '/^(\d+)(%)?$/', $options['width'] ) ) { + if ( isset( $options['width'] ) && ! preg_match( '/^\d+$/', $options['width'] ) ) { // set to 0 so oEmbed will use the default 100% and WordPress themes will leave it alone $options['width'] = 0; } - if ( isset( $options['height'] ) && ! preg_match( '/^(\d+)(%)?$/', $options['height'] ) ) { + if ( isset( $options['height'] ) && ! preg_match( '/^\d+$/', $options['height'] ) ) { unset( $options['height'] ); } @@ -115,9 +120,11 @@ function soundcloud_shortcode( $atts, $content = null ) { } // Merge in "url" value - $options['params'] = array_merge( array( - 'url' => $options['url'] - ), $options['params'] ); + $options['params'] = array_merge( + array( + 'url' => $options['url'], + ), $options['params'] + ); // Return html embed code if ( $iframe ) { @@ -129,19 +136,24 @@ function soundcloud_shortcode( $atts, $content = null ) { /** * Plugin options getter - * @param {string|array} $option Option name - * @param {mixed} $default Default value - * @return {mixed} Option value + * + * @param string|array $option Option name + * @param mixed $default Default value + * + * @return mixed Option value */ function soundcloud_get_option( $option, $default = false ) { $value = get_option( 'soundcloud_' . $option ); + return $value === '' ? $default : $value; } /** * Booleanize a value - * @param {boolean|string} $value - * @return {boolean} + * + * @param boolean|string $value + * + * @return boolean */ function soundcloud_booleanize( $value ) { return is_bool( $value ) ? $value : $value === 'true' ? true : false; @@ -149,8 +161,10 @@ function soundcloud_booleanize( $value ) { /** * Decide if a url has a tracklist - * @param {string} $url - * @return {boolean} + * + * @param string $url + * + * @return boolean */ function soundcloud_url_has_tracklist( $url ) { return preg_match( '/^(.+?)\/(sets|groups|playlists)\/(.+?)$/', $url ); @@ -158,8 +172,10 @@ function soundcloud_url_has_tracklist( $url ) { /** * Parameterize url - * @param {array} $match Matched regex - * @return {string} Parameterized url + * + * @param array $match Matched regex + * + * @return string Parameterized url */ function soundcloud_oembed_params_callback( $match ) { global $soundcloud_oembed_params; @@ -176,54 +192,65 @@ function soundcloud_oembed_params_callback( $match ) { /** * Iframe widget embed code - * @param {array} $options Parameters - * @return {string} Iframe embed code + * + * @param array $options Parameters + * + * @return string Iframe embed code */ function soundcloud_iframe_widget( $options ) { // Build URL $url = set_url_scheme( 'https://w.soundcloud.com/player/?' . http_build_query( $options['params'] ) ); // Set default width if not defined - $width = isset($options['width']) && $options['width'] !== 0 ? $options['width'] : '100%'; + $width = isset( $options['width'] ) && $options['width'] !== 0 ? $options['width'] : '100%'; // Set default height if not defined - $height = isset($options['height']) && $options['height'] !== 0 - ? $options['height'] - : ( soundcloud_url_has_tracklist( $options['url']) || ( isset( $options['params']['visual'] ) && soundcloud_booleanize( $options['params']['visual'] ) ) ? '450' : '166'); + $height = isset( $options['height'] ) && $options['height'] !== 0 + ? $options['height'] + : ( soundcloud_url_has_tracklist( $options['url'] ) || ( isset( $options['params']['visual'] ) && soundcloud_booleanize( $options['params']['visual'] ) ) ? '450' : '166' ); return sprintf( '<iframe width="%s" height="%s" scrolling="no" frameborder="no" src="%s"></iframe>', $width, $height, $url ); } /** * Legacy Flash widget embed code - * @param {array} $options Parameters - * @return {string} Flash embed code + * + * @param array $options Parameters + * + * @return string Flash embed code */ function soundcloud_flash_widget( $options ) { - // Build URL - $url = set_url_scheme( 'https://player.soundcloud.com/player.swf?' . http_build_query($options['params']) ); + $url = set_url_scheme( 'https://player.soundcloud.com/player.swf?' . http_build_query( $options['params'] ) ); // Set default width if not defined $width = isset( $options['width'] ) && $options['width'] !== 0 ? $options['width'] : '100%'; // Set default height if not defined - $height = isset( $options['height'] ) && $options['height'] !== 0 ? $options['height'] : ( soundcloud_url_has_tracklist( $options['url'] ) ? '255' : '81'); - - return preg_replace( '/\s\s+/', "", sprintf( '<object width="%s" height="%s"> - <param name="movie" value="%s"></param> - <param name="allowscriptaccess" value="always"></param> - <embed width="%s" height="%s" src="%s" allowscriptaccess="always" type="application/x-shockwave-flash"></embed> - </object>', $width, $height, $url, $width, $height, $url ) ); + $height = isset( $options['height'] ) && $options['height'] !== 0 ? $options['height'] : ( soundcloud_url_has_tracklist( $options['url'] ) ? '255' : '81' ); + + return preg_replace( + '/\s\s+/', '', sprintf( + '<object width="%s" height="%s"> + <param name="movie" value="%s" /> + <param name="allowscriptaccess" value="always" /> + <embed width="%s" height="%s" src="%s" allowscriptaccess="always" type="application/x-shockwave-flash"></embed> + </object>', $width, $height, $url, $width, $height, $url + ) + ); } - /** * SoundCloud Embed Reversal * * Converts a generic HTML embed code from SoundClound into a * WordPress.com-compatibly shortcode. + * + * @param string $content HTML content. + * + * @return string Parsed content. */ function jetpack_soundcloud_embed_reversal( $content ) { - if ( false === stripos( $content, 'w.soundcloud.com/player' ) ) + if ( false === stripos( $content, 'w.soundcloud.com/player' ) ) { return $content; + } /* Sample embed code: @@ -236,8 +263,9 @@ function jetpack_soundcloud_embed_reversal( $content ) { $regexes[] = '#<iframe(?:[^&]|&(?!gt;))+?src="((?:https?:)?//w\.soundcloud\.com/player/[^"\']++)"(?:[^&]|&(?!gt;))*+>\s*?</iframe>#i'; foreach ( $regexes as $regex ) { - if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) + if ( ! preg_match_all( $regex, $content, $matches, PREG_SET_ORDER ) ) { continue; + } foreach ( $matches as $match ) { @@ -247,13 +275,14 @@ function jetpack_soundcloud_embed_reversal( $content ) { $args = parse_url( html_entity_decode( $match[1] ), PHP_URL_QUERY ); $args = wp_parse_args( $args ); - if ( ! preg_match( '#^(?:https?:)?//api\.soundcloud\.com/.+$#i', $args['url'], $url_matches ) ) + if ( ! preg_match( '#^(?:https?:)?//api\.soundcloud\.com/.+$#i', $args['url'], $url_matches ) ) { continue; + } if ( ! preg_match( '#height="(\d+)"#i', $match[0], $hmatch ) ) { $height = ''; } else { - $height = " height='" . intval( $hmatch[1] ) . "'"; + $height = ' height="' . intval( $hmatch[1] ) . '"'; } unset( $args['url'] ); @@ -269,7 +298,7 @@ function jetpack_soundcloud_embed_reversal( $content ) { $shortcode = '[soundcloud url="' . esc_url( $url_matches[0] ) . '" ' . $params . ' width="100%"' . $height . ' iframe="true" /]'; $replace_regex = sprintf( '#\s*%s\s*#', preg_quote( $match[0], '#' ) ); - $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $shortcode ), $content ); + $content = preg_replace( $replace_regex, sprintf( "\n\n%s\n\n", $shortcode ), $content ); /** This action is documented in modules/shortcodes/youtube.php */ do_action( 'jetpack_embed_to_shortcode', 'soundcloud', $url_matches[0] ); } @@ -278,5 +307,4 @@ function jetpack_soundcloud_embed_reversal( $content ) { return $content; } - add_filter( 'pre_kses', 'jetpack_soundcloud_embed_reversal' ); diff --git a/plugins/jetpack/modules/shortcodes/ted.php b/plugins/jetpack/modules/shortcodes/ted.php index f49184ef..d5386109 100644 --- a/plugins/jetpack/modules/shortcodes/ted.php +++ b/plugins/jetpack/modules/shortcodes/ted.php @@ -18,42 +18,47 @@ function jetpack_shortcode_get_ted_id( $atts ) { } add_shortcode( 'ted', 'shortcode_ted' ); -function shortcode_ted( $atts, $content = '' ) { +function shortcode_ted( $atts ) { global $wp_embed; $defaults = array( - 'id' => '', - 'width' => '', - 'height' => '', - 'lang' => 'en', - ); - $atts = shortcode_atts( $defaults, $atts, 'ted' ); + 'id' => '', + 'width' => '', + 'height' => '', + 'lang' => 'en', + ); + $atts = shortcode_atts( $defaults, $atts, 'ted' ); - if ( empty( $atts['id'] ) ) + if ( empty( $atts['id'] ) ) { return '<!-- Missing TED ID -->'; + } - if ( preg_match( "#^[\d]+$#", $atts['id'], $matches ) ) + $url = ''; + if ( preg_match( '#^[\d]+$#', $atts['id'], $matches ) ) { $url = 'http://ted.com/talks/view/id/' . $matches[0]; - elseif ( preg_match( "#^https?://(www\.)?ted\.com/talks/view/id/[0-9]+$#", $atts['id'], $matches ) ) + } elseif ( preg_match( '#^https?://(www\.)?ted\.com/talks/view/id/[0-9]+$#', $atts['id'], $matches ) ) { $url = $matches[0]; + } unset( $atts['id'] ); $args = array(); - if ( is_numeric( $atts['width'] ) ) + if ( is_numeric( $atts['width'] ) ) { $args['width'] = $atts['width']; - else if ( $embed_size_w = get_option( 'embed_size_w' ) ) + } else if ( $embed_size_w = get_option( 'embed_size_w' ) ) { $args['width'] = $embed_size_w; - else if ( ! empty( $GLOBALS['content_width'] ) ) - $args['width'] = (int)$GLOBALS['content_width']; - else + } else if ( ! empty( $GLOBALS['content_width'] ) ) { + $args['width'] = (int) $GLOBALS['content_width']; + } else { $args['width'] = 500; + } // Default to a 16x9 aspect ratio if there's no height set - if ( is_numeric( $atts['height'] ) ) + if ( is_numeric( $atts['height'] ) ) { $args['height'] = $atts['height']; - else + } else { $args['height'] = $args['width'] * 0.5625; + } if ( ! empty( $atts['lang'] ) ) { $args['lang'] = sanitize_key( $atts['lang'] ); @@ -61,6 +66,7 @@ function shortcode_ted( $atts, $content = '' ) { } $retval = $wp_embed->shortcode( $args, $url ); remove_filter( 'oembed_fetch_url', 'ted_filter_oembed_fetch_url', 10 ); + return $retval; } diff --git a/plugins/jetpack/modules/shortcodes/twitter-timeline.php b/plugins/jetpack/modules/shortcodes/twitter-timeline.php index 4f12d067..adde0367 100644 --- a/plugins/jetpack/modules/shortcodes/twitter-timeline.php +++ b/plugins/jetpack/modules/shortcodes/twitter-timeline.php @@ -4,28 +4,35 @@ add_shortcode( 'twitter-timeline', 'twitter_timeline_shortcode' ); function twitter_timeline_shortcode( $attr ) { $default_atts = array( - 'username' => '', - 'id' => '', - 'height' => 282, - 'width' => 450, - + 'username' => '', + 'id' => '', + 'height' => '282', + 'width' => '450', ); $attr = shortcode_atts( $default_atts, $attr, 'twitter-timeline' ); - if ( $attr['username'] != preg_replace( '/[^A-Za-z0-9_]+/', '', $attr['username'] ) ) - return '<!--' . __( 'Invalid username', 'jetpack' ) . '-->'; + $attr['username'] = preg_replace( '/[^A-Za-z0-9_]+/', '', $attr['username'] ); + + if ( empty( $attr['username'] ) ) { + return '<!-- ' . __( 'Invalid Twitter Timeline username', 'jetpack' ) . ' -->'; + } - if ( ! is_numeric( $attr['id'] ) ) - return '<!--' . __( 'Invalid id', 'jetpack' ) . '-->'; + if ( ! is_numeric( $attr['id'] ) ) { + return '<!-- ' . __( 'Invalid Twitter Timeline id', 'jetpack' ) . ' -->'; + } $tweets_by = sprintf( __( 'Tweets by @%s', 'jetpack' ), $attr['username'] ); - $output = '<a class="twitter-timeline" width="' . (int)$attr['width'] . '" height="' . (int)$attr['height'] . '" href="' . esc_url( 'https://twitter.com/'. $attr['username'] ) . '" data-widget-id="' . esc_attr( $attr['id'] ) . '">' . esc_html( $tweets_by ) . '</a>'; - add_action( 'wp_footer', 'twitter_timeline_js' ); + $output = '<a class="twitter-timeline" width="' . esc_attr( $attr['width'] ) . '" height="' . esc_attr( $attr['height'] ) . '" href="' . esc_url( 'https://twitter.com/' . $attr['username'] ) . '/" data-widget-id="' . esc_attr( $attr['id'] ) . '">' . esc_html( $tweets_by ) . '</a>'; + + wp_enqueue_script( 'jetpack-twitter-timeline' ); return $output; } function twitter_timeline_js() { - echo '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>'; + if ( is_customize_preview() ) { + wp_enqueue_script( 'jetpack-twitter-timeline' ); + } } +add_action( 'wp_enqueue_scripts', 'twitter_timeline_js' ); diff --git a/plugins/jetpack/modules/shortcodes/vimeo.php b/plugins/jetpack/modules/shortcodes/vimeo.php index 64869111..f63367d8 100644 --- a/plugins/jetpack/modules/shortcodes/vimeo.php +++ b/plugins/jetpack/modules/shortcodes/vimeo.php @@ -11,16 +11,19 @@ function jetpack_shortcode_get_vimeo_id( $atts ) { if ( isset( $atts[0] ) ) { - $atts[0] = trim( $atts[0] , '=' ); - $id = false; - if ( is_numeric( $atts[0] ) ) + $atts[0] = trim( $atts[0], '=' ); + $id = false; + if ( is_numeric( $atts[0] ) ) { $id = (int) $atts[0]; - elseif ( preg_match( '|vimeo\.com/(\d+)/?$|i', $atts[0], $match ) ) + } elseif ( preg_match( '|vimeo\.com/(\d+)/?$|i', $atts[0], $match ) ) { $id = (int) $match[1]; - elseif ( preg_match( '|player\.vimeo\.com/video/(\d+)/?$|i', $atts[0], $match ) ) + } elseif ( preg_match( '|player\.vimeo\.com/video/(\d+)/?$|i', $atts[0], $match ) ) { $id = (int) $match[1]; + } + return $id; } + return 0; } @@ -28,41 +31,53 @@ function jetpack_shortcode_get_vimeo_id( $atts ) { * Convert a Vimeo shortcode into an embed code. * * @param array $atts An array of shortcode attributes. + * * @return string The embed code for the Vimeo video. */ function vimeo_shortcode( $atts ) { global $content_width; - extract( array_map( 'intval', shortcode_atts( array( - 'id' => 0, - 'width' => 400, - 'height' => 300, - 'autoplay' => 0, - 'loop' => 0, - ), $atts, 'vimeo' ) ) ); + $attr = array_map( + 'intval', + shortcode_atts( + array( + 'id' => 0, + 'width' => 0, + 'height' => 0, + 'autoplay' => 0, + 'loop' => 0, + ), $atts + ) + ); if ( isset( $atts[0] ) ) { - $id = jetpack_shortcode_get_vimeo_id( $atts ); + $attr['id'] = jetpack_shortcode_get_vimeo_id( $atts ); } - if ( ! $id ) return "<!-- vimeo error: not a vimeo video -->"; + if ( ! $attr['id'] ) { + return '<!-- vimeo error: not a vimeo video -->'; + } // [vimeo 141358 h=500&w=350] $params = shortcode_new_to_old_params( $atts ); // h=500&w=350 $params = str_replace( array( '&', '&' ), '&', $params ); parse_str( $params, $args ); - if ( isset( $args['w'] ) ) { - $width = (int) $args['w']; + $width = intval( $attr['width'] ); + $height = intval( $attr['height'] ); + + // Support w and h argument as fallback. + if ( empty( $width ) && isset( $args['w'] ) ) { + $width = intval( $args['w'] ); - if ( ! isset( $args['h'] ) ) { + if ( empty( $height ) && ! isset( $args['h'] ) ) { // The case where w=300 is specified without h=200, otherwise $height // will always equal the default of 300, no matter what w was set to. $height = round( ( $width / 640 ) * 360 ); } } - if ( isset( $args['h'] ) ) { + if ( empty( $height ) && isset( $args['h'] ) ) { $height = (int) $args['h']; if ( ! isset( $args['w'] ) ) { @@ -70,10 +85,15 @@ function vimeo_shortcode( $atts ) { } } - if ( ! $width ) { + if ( ! $width && ! empty( $content_width ) ) { $width = absint( $content_width ); } + // If setting the width with content_width has failed, defaulting + if ( ! $width ) { + $width = 640; + } + if ( ! $height ) { $height = round( ( $width / 640 ) * 360 ); } @@ -100,20 +120,31 @@ function vimeo_shortcode( $atts ) { */ $height = (int) apply_filters( 'vimeo_height', $height ); - $url = esc_url( "https://player.vimeo.com/video/$id" ); + $url = esc_url( 'https://player.vimeo.com/video/' . $attr['id'] ); - // $args['autoplay'] is parsed from the embedded url. - // $autoplay is parsed from shortcode arguments. - // in_array( 'autoplay', $atts ) catches the argument passed without a value. - if ( ! empty( $args['autoplay'] ) || ! empty( $autoplay ) || in_array( 'autoplay', $atts ) ) { + // Handle autoplay and loop arguments. + if ( + isset( $args['autoplay'] ) && '1' === $args['autoplay'] // Parsed from the embedded URL. + || $attr['autoplay'] // Parsed from shortcode arguments. + || in_array( 'autoplay', $atts ) // Catch the argument passed without a value. + ) { $url = add_query_arg( 'autoplay', 1, $url ); } - if ( ! empty( $args['loop'] ) || ! empty( $loop ) || in_array( 'loop', $atts ) ) { + if ( + isset( $args['loop'] ) && '1' === $args['loop'] // Parsed from the embedded URL. + || $attr['loop'] // Parsed from shortcode arguments. + || in_array( 'loop', $atts ) // Catch the argument passed without a value. + ) { $url = add_query_arg( 'loop', 1, $url ); } - $html = sprintf( '<div class="embed-vimeo" style="text-align:center;"><iframe src="%1$s" width="%2$u" height="%3$u" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>', esc_url( $url ), $width, $height ); + $html = sprintf( + '<div class="embed-vimeo" style="text-align: center;"><iframe src="%1$s" width="%2$u" height="%3$u" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>', + esc_url( $url ), + esc_attr( $width ), + esc_attr( $height ) + ); /** * Filter the Vimeo player HTML. @@ -162,35 +193,39 @@ function wpcom_vimeo_embed_url_init() { add_action( 'init', 'wpcom_vimeo_embed_url_init' ); function vimeo_embed_to_shortcode( $content ) { - if ( false === stripos( $content, 'player.vimeo.com/video/' ) ) + if ( false === stripos( $content, 'player.vimeo.com/video/' ) ) { return $content; + } - $regexp = '!<iframe\s+src=[\'"](https?:)?//player\.vimeo\.com/video/(\d+)[\w=&;?]*[\'"]((?:\s+\w+=[\'"][^\'"]*[\'"])*)((?:[\s\w]*))></iframe>!i'; + $regexp = '!<iframe\s+src=[\'"](https?:)?//player\.vimeo\.com/video/(\d+)[\w=&;?]*[\'"]((?:\s+\w+=[\'"][^\'"]*[\'"])*)((?:[\s\w]*))></iframe>!i'; $regexp_ent = str_replace( '&#0*58;', '&#0*58;|�*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) ); foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) { - if ( !preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) + if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) { continue; + } foreach ( $matches as $match ) { $id = (int) $match[2]; $params = $match[3]; - if ( 'regexp_ent' == $reg ) + if ( 'regexp_ent' == $reg ) { $params = html_entity_decode( $params ); + } $params = wp_kses_hair( $params, array( 'http' ) ); - $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0; + $width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0; $height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0; $wh = ''; - if ( $width && $height ) + if ( $width && $height ) { $wh = ' w=' . $width . ' h=' . $height; + } $shortcode = '[vimeo ' . $id . $wh . ']'; - $content = str_replace( $match[0], $shortcode, $content ); + $content = str_replace( $match[0], $shortcode, $content ); } } @@ -200,15 +235,44 @@ function vimeo_embed_to_shortcode( $content ) { add_filter( 'pre_kses', 'vimeo_embed_to_shortcode' ); /** - * Replaces plain-text links to Vimeo videos with Vimeo embeds. + * Replaces shortcodes and plain-text URLs to Vimeo videos with Vimeo embeds. + * Covers shortcode usage [vimeo 1234] | [vimeo https://vimeo.com/1234] | [vimeo http://vimeo.com/1234] + * Or plain text URLs https://vimeo.com/1234 | vimeo.com/1234 | //vimeo.com/1234 + * Links are left intact. * * @since 3.7.0 + * @since 3.9.5 One regular expression matches shortcodes and plain URLs. * * @param string $content HTML content * @return string The content with embeds instead of URLs */ function vimeo_link( $content ) { - return preg_replace_callback( '#https://vimeo.com/\d*#', 'vimeo_link_callback', $content ); + /** + * [vimeo 12345] + * [vimeo http://vimeo.com/12345] + */ + $shortcode = "(?:\[vimeo\s+[^0-9]*)([0-9]+)(?:\])"; + + /** + * http://vimeo.com/12345 + * https://vimeo.com/12345 + * //vimeo.com/12345 + * vimeo.com/some/descender/12345 + * + * Should not capture inside HTML attributes + * [Not] <a href="vimeo.com/12345">Cool Video</a> + * [Not] <a href="https://vimeo.com/12345">vimeo.com/12345</a> + * + * Could erroneously capture: + * <a href="some.link/maybe/even/vimeo">This video (vimeo.com/12345) is teh cat's meow!</a> + */ + $plain_url = "(?:[^'\">]?\/?(?:https?:\/\/)?vimeo\.com[^0-9]+)([0-9]+)(?:[^'\"0-9<]|$)"; + + return preg_replace_callback( + sprintf( '#%s|%s#i', $shortcode, $plain_url ), + 'vimeo_link_callback', + $content + ); } /** @@ -217,19 +281,14 @@ function vimeo_link( $content ) { * @since 3.7.0 * * @param array $matches An array containing a Vimeo URL. - * @return string THe Vimeo HTML embed code. + * @return string The Vimeo HTML embed code. */ function vimeo_link_callback( $matches ) { - // Grab the Vimeo ID from the URL - if ( preg_match( '|vimeo\.com/(\d+)/?$|i', $matches[0], $match ) ) { - $id = (int) $match[1]; - } - - // Pass that ID to the Vimeo shortcode function. - if ( $id ) { - $atts = array( 'id' => $id ); + $id = isset( $matches[ 2 ] ) ? $matches[ 2 ] : $matches[ 1 ]; + if ( isset( $id ) && ctype_digit( $id ) ) { + return "\n" . vimeo_shortcode( array( 'id' => $id ) ) . "\n"; } - return "\n" . vimeo_shortcode( $atts ) . "\n"; + return $matches[ 0 ]; } /** This filter is documented in modules/shortcodes/youtube.php */ diff --git a/plugins/jetpack/modules/shortcodes/wufoo.php b/plugins/jetpack/modules/shortcodes/wufoo.php index fb8cce6d..4020c5ea 100644 --- a/plugins/jetpack/modules/shortcodes/wufoo.php +++ b/plugins/jetpack/modules/shortcodes/wufoo.php @@ -10,72 +10,73 @@ http://wufoo.com/docs/code-manager/wordpress-shortcode-plugin/ function wufoo_shortcode( $atts ) { - extract( shortcode_atts( array( - 'username' => '', - 'formhash' => '', - 'autoresize' => true, - 'height' => '500', - 'header' => 'show', - 'ssl' => '' - ), $atts ) ); + $attr = shortcode_atts( + array( + 'username' => '', + 'formhash' => '', + 'autoresize' => true, + 'height' => '500', + 'header' => 'show', + 'ssl' => '', + ), $atts + ); - //Check username and formhash to ensure they only have alphanumeric characters or underscores, and aren't empty - if ( !preg_match( "/^[a-zA-Z0-9_]+$/", $username) || !preg_match( "/^[a-zA-Z0-9_]+$/", $formhash ) ) { + // Check username and formhash to ensure they only have alphanumeric characters or underscores, and aren't empty. + if ( ! preg_match( '/^[a-zA-Z0-9_]+$/', $attr['username'] ) || ! preg_match( '/^[a-zA-Z0-9_]+$/', $attr['formhash'] ) ) { - /** - * Return an error to the users with instructions if one of these params is invalid - * They don't have default values because they are user/form-specific - */ - $return_error = sprintf( __( 'Something is wrong with your Wufoo shortcode. If you copy and paste it from the %sWufoo Code Manager%s, you should be golden.', 'jetpack' ), "<a href='http://wufoo.com/docs/code-manager/'>", "</a>" ); + /** + * Return an error to the users with instructions if one of these params is invalid + * They don't have default values because they are user/form-specific + */ + $return_error = sprintf( __( 'Something is wrong with your Wufoo shortcode. If you copy and paste it from the %sWufoo Code Manager%s, you should be golden.', 'jetpack' ), '<a href="http://wufoo.com/docs/code-manager/">', '</a>' ); - return " - <div style='border: 20px solid red; border-radius: 40px; padding: 40px; margin: 50px 0 70px;'> + return ' + <div style="border: 20px solid red; border-radius: 40px; padding: 40px; margin: 50px 0 70px;"> <h3>Uh oh!</h3> - <p style='margin: 0;'>$return_error</p> - </div>"; + <p style="margin: 0;">' . $return_error . '</p> + </div>'; } /** - * Required parameters are present - * An error will be returned inside the form if they are invalid - */ - + * Required parameters are present. + * An error will be returned inside the form if they are invalid. + */ $js_embed = '<script type="text/javascript">var host = (("https:" == document.location.protocol) ? "https://secure." : "http://");document.write(unescape("%3Cscript src=\'" + host + "wufoo.com/scripts/embed/form.js\' type=\'text/javascript\'%3E%3C/script%3E"));</script>'; $js_embed .= "<script type='text/javascript'>"; - $js_embed .= "var wufoo_$formhash = new WufooForm();"; - $js_embed .= "wufoo_$formhash.initialize({"; - $js_embed .= "'userName':'$username', "; - $js_embed .= "'formHash':'$formhash', "; - $js_embed .= "'autoResize':".(bool)( $autoresize ).","; - $js_embed .= "'height':'". (int) $height ."',"; - $js_embed .= "'header':'".esc_js( $header )."' "; + $js_embed .= 'var wufoo_' . $attr['formhash'] . ' = new WufooForm();'; + $js_embed .= 'wufoo_' . $attr['formhash'] . ' .initialize({'; + $js_embed .= "'userName':'" . $attr['username'] . "', "; + $js_embed .= "'formHash':'" . $attr['formhash'] . "', "; + $js_embed .= "'autoResize':" . (bool) ( $attr['autoresize'] ) . ','; + $js_embed .= "'height':'" . (int) $attr['height'] . "',"; + $js_embed .= "'header':'" . esc_js( $attr['header'] ) . "' "; /** - * Only output SSL value if passes as param - * Lower tier plans don't show this param (don't offer SSL) - */ - $js_embed .= ( $ssl ) ? ",'ssl':".(bool) $ssl : ""; - $js_embed .= "});"; - $js_embed .= "wufoo_$formhash.display();"; - $js_embed .= "</script>"; + * Only output SSL value if passes as param. + * Lower tier plans don't show this param (don't offer SSL). + */ + $js_embed .= ( $attr['ssl'] ) ? ",'ssl':" . (bool) $attr['ssl'] : ''; + $js_embed .= '});'; + $js_embed .= 'wufoo_' . $attr['formhash'] . '.display();'; + $js_embed .= '</script>'; /** - * iframe embed, loaded inside <noscript> tags - */ + * iframe embed, loaded inside <noscript> tags. + */ $iframe_embed = '<iframe '; - $iframe_embed .= 'height="'. (int) $height .'" '; + $iframe_embed .= 'height="' . (int) $attr['height'] . '" '; $iframe_embed .= 'allowTransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none;"'; - $iframe_embed .= 'src="https://'. $username .'.wufoo.com/embed/'. $formhash .'/">'; - $iframe_embed .= '<a href="https://'. $username .'.wufoo.com/forms/'. $formhash .'/" '; + $iframe_embed .= 'src="https://' . $attr['username'] . '.wufoo.com/embed/' . $attr['formhash'] . '/">'; + $iframe_embed .= '<a href="https://' . $attr['username'] . '.wufoo.com/forms/' . $attr['formhash'] . '/" '; $iframe_embed .= 'rel="nofollow">Fill out my Wufoo form!</a></iframe>'; /** This action is already documented in modules/widgets/gravatar-profile.php */ do_action( 'jetpack_stats_extra', 'embeds', 'wufoo' ); /** - * Return embed in JS and iframe - */ + * Return embed in JS and iframe. + */ return "$js_embed <noscript> $iframe_embed </noscript>"; } -add_shortcode('wufoo', 'wufoo_shortcode'); +add_shortcode( 'wufoo', 'wufoo_shortcode' ); diff --git a/plugins/jetpack/modules/shortcodes/youtube.php b/plugins/jetpack/modules/shortcodes/youtube.php index 601427ba..2ea76dd6 100644 --- a/plugins/jetpack/modules/shortcodes/youtube.php +++ b/plugins/jetpack/modules/shortcodes/youtube.php @@ -292,22 +292,32 @@ function youtube_id( $url ) { if ( apply_filters( 'jetpack_youtube_allow_autoplay', false ) && isset( $qargs['autoplay'] ) ) $autoplay = '&autoplay=' . (int)$qargs['autoplay']; - $alignmentcss = 'text-align:center;'; - if ( isset( $qargs['align'] ) ) { - switch ( $qargs['align'] ) { - case 'left': - $alignmentcss = "float:left; width:{$w}px; height:{$h}px; margin-right:10px; margin-bottom: 10px;"; - break; - case 'right': - $alignmentcss = "float:right; width:{$w}px; height:{$h}px; margin-left:10px; margin-bottom: 10px;"; - break; - } - } - if ( ( isset( $url['path'] ) && '/videoseries' == $url['path'] ) || isset( $qargs['list'] ) ) { - $html = "<span class='embed-youtube' style='$alignmentcss display: block;'><iframe class='youtube-player' type='text/html' width='$w' height='$h' src='" . esc_url( set_url_scheme( "http://www.youtube.com/embed/videoseries?list=$id&hl=en_US" ) ) . "' frameborder='0' allowfullscreen='true'></iframe></span>"; + $html = "<iframe class='youtube-player' type='text/html' width='$w' height='$h' src='" . esc_url( set_url_scheme( "http://www.youtube.com/embed/videoseries?list=$id&hl=en_US" ) ) . "' allowfullscreen='true' style='border:0;'></iframe>"; } else { - $html = "<span class='embed-youtube' style='$alignmentcss display: block;'><iframe class='youtube-player' type='text/html' width='$w' height='$h' src='" . esc_url( set_url_scheme( "http://www.youtube.com/embed/$id?version=3&rel=$rel&fs=1$fmt$autohide&showsearch=$search&showinfo=$info&iv_load_policy=$iv$start$end$hd&wmode=$wmode$theme$autoplay{$cc}{$cc_lang}" ) ) . "' frameborder='0' allowfullscreen='true'></iframe></span>"; + $html = "<iframe class='youtube-player' type='text/html' width='$w' height='$h' src='" . esc_url( set_url_scheme( "http://www.youtube.com/embed/$id?version=3&rel=$rel&fs=1$fmt$autohide&showsearch=$search&showinfo=$info&iv_load_policy=$iv$start$end$hd&wmode=$wmode$theme$autoplay{$cc}{$cc_lang}" ) ) . "' allowfullscreen='true' style='border:0;'></iframe>"; + } + + // Let's do some alignment wonder in a span, unless we're producing a feed + if ( ! is_feed() ) { + $alignmentcss = 'text-align:center;'; + if ( isset( $qargs['align'] ) ) { + switch ( $qargs['align'] ) { + case 'left': + $alignmentcss = "float:left; width:{$w}px; height:{$h}px; margin-right:10px; margin-bottom: 10px;"; + break; + case 'right': + $alignmentcss = "float:right; width:{$w}px; height:{$h}px; margin-left:10px; margin-bottom: 10px;"; + break; + } + } + + $html = sprintf( + '<span class="embed-youtube" style="%s display: block;">%s</span>', + esc_attr( $alignmentcss ), + $html + ); + } /** @@ -363,7 +373,7 @@ if ( apply_filters( 'jetpack_comments_allow_oembed', get_option('embed_autourls' /** * Core changes to do_shortcode (https://core.trac.wordpress.org/changeset/34747) broke "improper" shortcodes - * with the format [shortcode=http://url.com]. + * with the format [shortcode=http://url.com]. * * This removes the "=" from the shortcode so it can be parsed. * diff --git a/plugins/jetpack/modules/sitemaps/sitemap-xsl.php b/plugins/jetpack/modules/sitemaps/sitemap-xsl.php index 427d64a5..7f40d1cf 100644 --- a/plugins/jetpack/modules/sitemaps/sitemap-xsl.php +++ b/plugins/jetpack/modules/sitemaps/sitemap-xsl.php @@ -90,14 +90,14 @@ $xsl = '<?xml version="1.0" encoding="UTF-8"?> <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">Jetpack</a>, meant to be consumed by search engines like <a href="%s">Google</a> or <a href="%s">Bing</a>.', 'jetpack' ), 'http://jetpack.me/', 'https://www.google.com', 'https://www.bing.com/' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) . '</p>
+ <p>' . wp_kses( sprintf( __( 'This is an XML Sitemap generated by <a href="%s">Jetpack</a>, meant to be consumed by search engines like <a href="%s">Google</a> or <a href="%s">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">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__( 'Featured Image', 'jetpack' ) . '</th>';
+ <th>' . esc_html__( 'Images', 'jetpack' ) . '</th>';
if ( empty( $type ) ) :
$xsl .= ' <th>' . esc_html__( 'Change Frequency', 'jetpack' ) . '</th>
<th>' . esc_html__( 'Last Updated', 'jetpack' ) . '</th>';
@@ -121,10 +121,7 @@ $xsl .= ' </tr> </a>
</td>
<td>
- <xsl:choose>
- <xsl:when test="count(image:image) > 0">' . esc_html__( 'Yes', 'jetpack' ) . '</xsl:when>
- <xsl:otherwise>' . esc_html__( 'No', 'jetpack' ) . '</xsl:otherwise>
- </xsl:choose>
+ <xsl:value-of select="count(image:image)"/>
</td>';
if ( empty( $type ) ) :
$xsl .= ' <td>
@@ -139,7 +136,7 @@ $xsl .= ' </tr> </table>
</div>
<div id="footer">
- <p>' . wp_kses( sprintf( __( '<em>Generated</em> by <a href="%s">Jetpack for WordPress</a>', 'jetpack' ), 'https://jetpack.me' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) . '</p>
+ <p>' . wp_kses( sprintf( __( '<em>Generated</em> by <a href="%s">Jetpack for WordPress</a>', 'jetpack' ), 'https://jetpack.com' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) . '</p>
</div>
</body>
</html>
diff --git a/plugins/jetpack/modules/sitemaps/sitemaps.php b/plugins/jetpack/modules/sitemaps/sitemaps.php index 74b97409..b316ef4d 100644 --- a/plugins/jetpack/modules/sitemaps/sitemaps.php +++ b/plugins/jetpack/modules/sitemaps/sitemaps.php @@ -105,18 +105,25 @@ function jetpack_sitemap_array_to_simplexml( $data, &$tree ) { foreach ( $data as $key => $value ) { // Allow namespaced keys by use of colon in $key, namespaces must be part of the document $namespace = null; - if ( false !== strpos( $key, ':' ) ) { + if ( false !== strpos( $key, ':' ) && 'image' != $key ) { list( $namespace_prefix, $key ) = explode( ':', $key ); if ( isset( $doc_namespaces[ $namespace_prefix ] ) ) { $namespace = $doc_namespaces[ $namespace_prefix ]; } } - if ( is_array( $value ) ) { - $child = $tree->addChild( $key, null, $namespace ); - jetpack_sitemap_array_to_simplexml( $value, $child ); - } else { - $tree->addChild( $key, esc_html( $value ), $namespace ); + if ( 'image' != $key ) { + if ( is_array( $value ) ) { + $child = $tree->addChild( $key, null, $namespace ); + jetpack_sitemap_array_to_simplexml( $value, $child ); + } else { + $tree->addChild( $key, esc_html( $value ), $namespace ); + } + } elseif ( is_array( $value ) ) { + foreach ( $value as $image ) { + $child = $tree->addChild( $key, null, $namespace ); + jetpack_sitemap_array_to_simplexml( $image, $child ); + } } } @@ -281,45 +288,6 @@ function jetpack_print_sitemap() { $tree = simplexml_load_string( $initstr ); } - // Acquire necessary attachment data for all of the posts in a performant manner - $attachment_parents = wp_list_pluck( $posts, 'ID' ); - $post_attachments = array(); - while ( $sub_posts = array_splice( $attachment_parents, 0, 100 ) ) { - $post_parents = implode( ',', array_map( 'intval', $sub_posts ) ); - - // Get the attachment IDs for all posts. We need to see how many - // attachments each post parent has and limit it to 5. - $query = "SELECT ID, post_parent FROM {$wpdb->posts} WHERE post_parent IN ({$post_parents}) AND post_type='attachment' AND ( post_mime_type='image/jpeg' OR post_mime_type='image/png' ) LIMIT 0,1000;"; - $all_attachments = $wpdb->get_results( $query ); - $selected_attachments = array(); - $attachment_count = array(); - - foreach ( $all_attachments as $attachment ) { - if ( ! isset( $attachment_count[ $attachment->post_parent ] ) ) { - $attachment_count[ $attachment->post_parent ] = 0; - } - - // Skip this particular attachment if we already have 5 for the post - if ( $attachment_count[ $attachment->post_parent ] >= 5 ) { - continue; - } - - $selected_attachments[] = $attachment->ID; - $attachment_count[ $attachment->post_parent ] ++; - } - - // bail if there weren't any attachments to avoid an extra query - if ( empty( $selected_attachments ) ) { - continue; - } - - // Get more of the attachment object for the attachments we actually care about - $attachment_ids = implode( ',', array_map( 'intval', $selected_attachments ) ); - $query = "SELECT p.ID, p.post_parent, p.post_title, p.post_excerpt, p.guid FROM {$wpdb->posts} as p WHERE p.ID IN ({$attachment_ids}) AND p.post_type='attachment' AND ( p.post_mime_type='image/jpeg' OR p.post_mime_type='image/png' ) LIMIT 500;"; - $attachments = $wpdb->get_results( $query ); - $post_attachments = array_merge( $post_attachments, $attachments ); - } - unset( $initstr ); $latest_mod = ''; foreach ( $posts as $post ) { @@ -351,28 +319,43 @@ function jetpack_print_sitemap() { // Image node specified in http://support.google.com/webmasters/bin/answer.py?hl=en&answer=178636 // These attachments were produced with batch SQL earlier in the script - if ( ! post_password_required( $post->ID ) && $attachments = wp_filter_object_list( $post_attachments, array( 'post_parent' => $post->ID ) ) ) { - - $url['image:image'] = array(); + if ( ! post_password_required( $post->ID ) ) { + + $media = array(); + $methods = array( + 'from_thumbnail' => false, + 'from_slideshow' => false, + 'from_gallery' => false, + 'from_attachment' => false, + 'from_html' => false, + ); + foreach ( $methods as $method => $value ) { + $methods[ $method ] = true; + $images_collected = Jetpack_PostImages::get_images( $post->ID, $methods ); + if ( is_array( $images_collected ) ) { + $media = array_merge( $media, $images_collected ); + } + $methods[ $method ] = false; + } - foreach ( $attachments as $attachment ) { - $attachment_url = wp_get_attachment_url( $attachment->ID ); + $images = array(); - if ( $attachment_url ) { - $url['image:image']['loc'] = esc_url( $attachment_url ); + foreach ( $media as $item ) { + if ( ! isset( $item['type'] ) || 'image' != $item['type'] ) { + continue; } + $one_image = array(); - // Only include title if not empty. - /** This filter is documented in wp-includes/feed.php */ - if ( $attachment_title = apply_filters( 'the_title_rss', $attachment->post_title ) ) { - $url['image:image']['title'] = html_entity_decode( esc_html( $attachment_title ), ENT_XML1 ); + if ( isset( $item['src'] ) ) { + $one_image['image:loc'] = esc_url( $item['src'] ); + $one_image['image:title'] = sanitize_title_with_dashes( $name = pathinfo( $item['src'], PATHINFO_FILENAME ) ); } - // Only include caption if not empty. - /** This filter is documented in wp-includes/feed.php */ - if ( $attachment_caption = apply_filters( 'the_excerpt_rss', $attachment->post_excerpt ) ) { - $url['image:image']['caption'] = html_entity_decode( esc_html( $attachment_caption ), ENT_XML1 ); - } + $images[] = $one_image; + } + + if ( ! empty( $images ) ) { + $url['image:image'] = $images; } } @@ -524,6 +507,15 @@ function jetpack_print_news_sitemap() { // URL to XSLT $xsl = get_option( 'permalink_structure' ) ? home_url( 'news-sitemap.xsl' ) : home_url( '/?jetpack-news-sitemap-xsl=true' ); + // Unless it's zh-cn for Simplified Chinese or zh-tw for Traditional Chinese, + // trim national variety so an ISO 639 language code as required by Google. + $language_code = strtolower( get_locale() ); + if ( in_array( $language_code, array( 'zh_tw', 'zh_cn' ) ) ) { + $language_code = str_replace( '_', '-', $language_code ); + } else { + $language_code = preg_replace( '/(_.*)$/i', '', $language_code ); + } + header( 'Content-Type: application/xml' ); ob_start(); echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; @@ -560,9 +552,7 @@ function jetpack_print_news_sitemap() { $url['loc'] = get_permalink( $post->ID ); $news = array(); $news['news:publication']['news:name'] = get_bloginfo_rss( 'name' ); - if ( function_exists( 'get_blog_lang_code' ) ) { - $news['news:publication']['news:language'] = get_blog_lang_code(); - } + $news['news:publication']['news:language'] = $language_code; $news['news:publication_date'] = jetpack_w3cdate_from_mysql( $post->post_date_gmt ); $news['news:title'] = get_the_title_rss(); if ( $post->keywords ) { @@ -709,8 +699,18 @@ function jetpack_sitemap_initialize() { if ( $discover_sitemap ) { add_action( 'do_robotstxt', 'jetpack_sitemap_discovery', 5, 0 ); + if ( get_option( 'permalink_structure' ) ) { + /** This filter is documented in modules/sitemaps/sitemaps.php */ + $sitemap = apply_filters( 'jetpack_sitemap_location', home_url( '/sitemap.xml' ) ); + $sitemap = parse_url( $sitemap, PHP_URL_PATH ); + } else { + /** This filter is documented in modules/sitemaps/sitemaps.php */ + $sitemap = apply_filters( 'jetpack_sitemap_location', home_url( '/?jetpack-sitemap=true' ) ); + $sitemap = preg_replace( '/(=.*?)$/i', '', parse_url( $sitemap, PHP_URL_QUERY ) ); + } + // Sitemap XML - if ( preg_match( '#(/sitemap\.xml)$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET['jetpack-sitemap'] ) && 'true' == $_GET['jetpack-sitemap'] ) ) { + if ( preg_match( '#(' . $sitemap . ')$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET[ $sitemap ] ) && 'true' == $_GET[ $sitemap ] ) ) { // run later so things like custom post types have been registered add_action( 'init', 'jetpack_print_sitemap', 999 ); } @@ -734,8 +734,18 @@ function jetpack_sitemap_initialize() { if ( $discover_news_sitemap ) { add_action( 'do_robotstxt', 'jetpack_news_sitemap_discovery', 5, 0 ); + if ( get_option( 'permalink_structure' ) ) { + /** This filter is documented in modules/sitemaps/sitemaps.php */ + $sitemap = apply_filters( 'jetpack_news_sitemap_location', home_url( '/news-sitemap.xml' ) ); + $sitemap = parse_url( $sitemap, PHP_URL_PATH ); + } else { + /** This filter is documented in modules/sitemaps/sitemaps.php */ + $sitemap = apply_filters( 'jetpack_news_sitemap_location', home_url( '/?jetpack-news-sitemap=true' ) ); + $sitemap = preg_replace( '/(=.*?)$/i', '', parse_url( $sitemap, PHP_URL_QUERY ) ); + } + // News Sitemap XML - if ( preg_match( '#(/news-sitemap\.xml)$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET['jetpack-news-sitemap'] ) && 'true' == $_GET['jetpack-news-sitemap'] ) ) { + if ( preg_match( '#(' . $sitemap . ')$#i', $_SERVER['REQUEST_URI'] ) || ( isset( $_GET[ $sitemap ] ) && 'true' == $_GET[ $sitemap ] ) ) { // run later so things like custom post types have been registered add_action( 'init', 'jetpack_print_news_sitemap', 999 ); } diff --git a/plugins/jetpack/modules/sso.php b/plugins/jetpack/modules/sso.php index d479d509..d822e28d 100644 --- a/plugins/jetpack/modules/sso.php +++ b/plugins/jetpack/modules/sso.php @@ -219,8 +219,11 @@ class Jetpack_SSO { * @since 2.7 **/ public function render_require_two_step() { + /** This filter is documented in modules/sso.php */ + $require_two_step = 1 == apply_filters( 'jetpack_sso_require_two_step', get_option( 'jetpack_sso_require_two_step' ) ); + $disabled = $require_two_step ? ' disabled="disabled"' : ''; echo '<label>'; - echo '<input type="checkbox" name="jetpack_sso_require_two_step" ' . checked( 1 == get_option( 'jetpack_sso_require_two_step' ), true, false ) . '> '; + echo '<input type="checkbox" name="jetpack_sso_require_two_step" ' . checked( $require_two_step, true, false ) . "$disabled>"; esc_html_e( 'Require Two-Step Authentication' , 'jetpack' ); echo '</label>'; } @@ -242,8 +245,10 @@ class Jetpack_SSO { * @since 2.9 **/ public function render_match_by_email() { + $match_by_email = 1 == $this->match_by_email(); + $disabled = $match_by_email ? ' disabled="disabled"' : ''; echo '<label>'; - echo '<input type="checkbox" name="jetpack_sso_match_by_email"' . checked( 1 == get_option( 'jetpack_sso_match_by_email' ), true, false) . '> '; + echo '<input type="checkbox" name="jetpack_sso_match_by_email"' . checked( $match_by_email, true, false ) . "$disabled>"; esc_html_e( 'Match by Email', 'jetpack' ); echo '</label>'; } diff --git a/plugins/jetpack/modules/stats.php b/plugins/jetpack/modules/stats.php index c80ed09e..9dca3975 100644 --- a/plugins/jetpack/modules/stats.php +++ b/plugins/jetpack/modules/stats.php @@ -130,7 +130,7 @@ function stats_map_meta_caps( $caps, $cap, $user_id, $args ) { } function stats_template_redirect() { - global $wp_the_query, $current_user, $stats_footer; + global $current_user, $stats_footer; if ( is_feed() || is_robots() || is_trackback() || is_preview() ) return; @@ -145,6 +145,24 @@ function stats_template_redirect() { add_action( 'wp_footer', 'stats_footer', 101 ); add_action( 'wp_head', 'stats_add_shutdown_action' ); + $script = set_url_scheme( '//stats.wp.com/e-' . gmdate( 'YW' ) . '.js' ); + $data = stats_build_view_data(); + $data_stats_array = stats_array( $data ); + + $stats_footer = <<<END +<script type='text/javascript' src='{$script}' async defer></script> +<script type='text/javascript'> + _stq = window._stq || []; + _stq.push([ 'view', {{$data_stats_array}} ]); + _stq.push([ 'clickTrackerInit', '{$data['blog']}', '{$data['post']}' ]); +</script> + +END; +} + +function stats_build_view_data() { + global $wp_the_query; + $blog = Jetpack_Options::get_option( 'id' ); $tz = get_option( 'gmt_offset' ); $v = 'ext'; @@ -169,18 +187,7 @@ function stats_template_redirect() { $post = '0'; } - $script = set_url_scheme( '//stats.wp.com/e-' . gmdate( 'YW' ) . '.js' ); - $data = stats_array( compact( 'v', 'j', 'blog', 'post', 'tz', 'srv' ) ); - - $stats_footer = <<<END -<script type='text/javascript' src='{$script}' async defer></script> -<script type='text/javascript'> - _stq = window._stq || []; - _stq.push([ 'view', {{$data}} ]); - _stq.push([ 'clickTrackerInit', '{$blog}', '{$post}' ]); -</script> - -END; + return compact( 'v', 'j', 'blog', 'post', 'tz', 'srv' ); } function stats_add_shutdown_action() { @@ -366,14 +373,14 @@ if ( -1 == document.location.href.indexOf( 'noheader' ) ) { <?php } -function stats_reports_page() { +function stats_reports_page( $main_chart_only = false ) { if ( isset( $_GET['dashboard'] ) ) return stats_dashboard_widget_content(); $blog_id = stats_get_option( 'blog_id' ); $domain = Jetpack::build_raw_urls( get_home_url() ); - if ( !isset( $_GET['noheader'] ) && empty( $_GET['nojs'] ) && empty( $_COOKIE['stnojs'] ) ) { + if ( ! $main_chart_only && !isset( $_GET['noheader'] ) && empty( $_GET['nojs'] ) && empty( $_COOKIE['stnojs'] ) ) { $nojs_url = add_query_arg( 'nojs', '1' ); $http = is_ssl() ? 'https' : 'http'; // Loading message @@ -409,6 +416,8 @@ echo esc_url( apply_filters( 'jetpack_static_url', "{$http}://en.wordpress.com/i if ( get_locale() !== 'en_US' ) { $q['jp_lang'] = get_locale(); } + // Only show the main chart, without extra header data, or metaboxes. + $q['main_chart_only'] = $main_chart_only; $args = array( 'view' => array( 'referrers', 'postviews', 'searchterms', 'clicks', 'post', 'table' ), 'numdays' => 'int', diff --git a/plugins/jetpack/modules/subscriptions/subscriptions.css b/plugins/jetpack/modules/subscriptions/subscriptions.css index c70bee05..feda9836 100644 --- a/plugins/jetpack/modules/subscriptions/subscriptions.css +++ b/plugins/jetpack/modules/subscriptions/subscriptions.css @@ -1,6 +1,5 @@ #subscribe-email input { width: 95%; - padding: 1px 2px; } .comment-subscription-form .subscribe-label { diff --git a/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.php b/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.php index 848ce2e5..5f93adb6 100644 --- a/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.php +++ b/plugins/jetpack/modules/theme-tools/compat/twentyfifteen.php @@ -1,7 +1,7 @@ <?php /** * Jetpack Compatibility File - * See: http://jetpack.me/ + * See: http://jetpack.com/ */ function twentyfifteen_jetpack_setup() { diff --git a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php index 7cf80f66..2881790b 100644 --- a/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php +++ b/plugins/jetpack/modules/theme-tools/compat/twentysixteen.php @@ -1,7 +1,7 @@ <?php /** * Jetpack Compatibility File - * See: http://jetpack.me/ + * See: http://jetpack.com/ */ function twentysixteen_jetpack_setup() { diff --git a/plugins/jetpack/modules/theme-tools/random-redirect.php b/plugins/jetpack/modules/theme-tools/random-redirect.php index 82990ec3..de6c5d43 100644 --- a/plugins/jetpack/modules/theme-tools/random-redirect.php +++ b/plugins/jetpack/modules/theme-tools/random-redirect.php @@ -17,21 +17,21 @@ function jetpack_matt_random_redirect() { } // Set default post type. - $post_type = get_post_type(); + $post_type = get_post_type(); // Set default category type - if ( is_category() ) { - $category = get_the_category(); - if ( isset( $category ) && ! empty( $category ) ) { - $random_cat_id = $category[0]->term_id; - } + if ( is_category() ) { + $category = get_the_category(); + if ( isset( $category ) && ! empty( $category ) ) { + $random_cat_id = $category[0]->term_id; } + } // Set author name if we're on an author archive. - if ( is_author() ) { - $random_author_name = get_the_author_meta( 'user_login' ); - $random_author_query = 'AND user_login = "' . $random_author_name . '"'; - } + if ( is_author() ) { + $random_author_name = get_the_author_meta( 'user_login' ); + $random_author_query = 'AND user_login = "' . $random_author_name . '"'; + } // Acceptable URL formats: /[...]/?random=[post type], /?random, /&random, /&random=1 if ( ! isset( $_GET['random'] ) && ! in_array( strtolower( $_SERVER['REQUEST_URI'] ), array( '/&random', '/&random=1' ) ) ) @@ -53,6 +53,11 @@ function jetpack_matt_random_redirect() { if ( isset( $_GET['random_post_type'] ) && post_type_exists( $_GET['random_post_type'] ) ) $post_type = $_GET['random_post_type']; + // Don't show a random page if 'page' isn't specified as the post type specifically. + if ( 'page' === $post_type && is_front_page() && ! isset( $_GET['random_post_type'] ) ) { + $post_type = 'post'; + } + global $wpdb; if ( isset( $random_cat_id ) ) { diff --git a/plugins/jetpack/modules/theme-tools/responsive-videos.php b/plugins/jetpack/modules/theme-tools/responsive-videos.php index 9bc4b2e4..59913a96 100644 --- a/plugins/jetpack/modules/theme-tools/responsive-videos.php +++ b/plugins/jetpack/modules/theme-tools/responsive-videos.php @@ -1,4 +1,5 @@ <?php + /** * Load the Responsive videos plugin */ diff --git a/plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.js b/plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.js index 51ac1363..e9f31ba8 100644 --- a/plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.js +++ b/plugins/jetpack/modules/theme-tools/responsive-videos/responsive-videos.js @@ -38,7 +38,7 @@ * 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; diff --git a/plugins/jetpack/modules/theme-tools/site-logo.php b/plugins/jetpack/modules/theme-tools/site-logo.php index 410344fc..d6510c2b 100644 --- a/plugins/jetpack/modules/theme-tools/site-logo.php +++ b/plugins/jetpack/modules/theme-tools/site-logo.php @@ -1,7 +1,7 @@ <?php /* * Site Logo. - * @see http://jetpack.me/support/site-logo/ + * @see http://jetpack.com/support/site-logo/ * * This feature will only be activated for themes that declare their support. * This can be done by adding code similar to the following during the @@ -25,6 +25,12 @@ * @since 3.2 */ function site_logo_init() { + // For transferring existing site logo from Jetpack -> Core + if ( current_theme_supports( 'custom-logo' ) && ! get_theme_mod( 'custom_logo' ) && $jp_logo = get_option( 'site_logo' ) ) { + set_theme_mod( 'custom_logo', $jp_logo['id'] ); + delete_option( 'site_logo' ); + } + // Only load our code if our theme declares support, and the standalone plugin is not activated. if ( current_theme_supports( 'site-logo' ) && ! class_exists( 'Site_Logo', false ) ) { // Load our class for namespacing. diff --git a/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo.php b/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo.php index a2ffae30..728a1548 100644 --- a/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo.php +++ b/plugins/jetpack/modules/theme-tools/site-logo/inc/class-site-logo.php @@ -51,6 +51,11 @@ class Site_Logo { * @uses add_filter */ public function register_hooks() { + // This would only happen if a theme supports BOTH site-logo and custom-logo for some reason + if ( current_theme_supports( 'custom-logo' ) ) { + return; + } + add_action( 'wp_head', array( $this, 'head_text_styles' ) ); add_action( 'customize_register', array( $this, 'customize_register' ) ); add_action( 'customize_preview_init', array( $this, 'preview_enqueue' ) ); diff --git a/plugins/jetpack/modules/theme-tools/site-logo/inc/functions.php b/plugins/jetpack/modules/theme-tools/site-logo/inc/functions.php index 2117bf88..12817e5f 100644 --- a/plugins/jetpack/modules/theme-tools/site-logo/inc/functions.php +++ b/plugins/jetpack/modules/theme-tools/site-logo/inc/functions.php @@ -102,6 +102,8 @@ function jetpack_has_site_logo() { */ function jetpack_the_site_logo() { $logo = site_logo()->logo; + $logo_id = get_theme_mod( 'custom_logo' ); // Check for WP 4.5 Site Logo + $logo_id = $logo_id ? $logo_id : $logo['id']; // Use WP Core logo if present, otherwise use Jetpack's. $size = site_logo()->theme_size(); $html = ''; @@ -120,7 +122,7 @@ function jetpack_the_site_logo() { $html = sprintf( '<a href="%1$s" class="site-logo-link" rel="home" itemprop="url">%2$s</a>', esc_url( home_url( '/' ) ), wp_get_attachment_image( - $logo['id'], + $logo_id, $size, false, array( diff --git a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.js b/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.js index e44c3923..133fd9b9 100644 --- a/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.js +++ b/plugins/jetpack/modules/theme-tools/site-logo/js/site-logo-control.js @@ -87,10 +87,11 @@ */ pick: function() { // get the attachment from the modal frame - var attachment = this.frame.state().get( 'selection' ).first().toJSON(); - attachment = this.reduceMembers( attachment ); - // set the setting - the callback will take care of rendering - this.setting( attachment ); + var attachment = this.frame.state().get( 'selection' ).single(); + if ( 'image' === attachment.get( 'type' ) ) { + // set the setting - the callback will take care of rendering + this.setting( this.reduceMembers( attachment.toJSON() ) ); + } }, /** * Reduces the attachment object to just the few desired members. diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/carousel-container.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/carousel-container.php index 38f16dfc..c873d092 100644 --- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/carousel-container.php +++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/carousel-container.php @@ -13,6 +13,7 @@ if ( defined( 'JSON_HEX_AMP' ) ) { <?php if ( isset( $extra ) ): ?> data-carousel-extra='<?php echo _wp_specialchars( wp_check_invalid_utf8( $extra ), ENT_QUOTES, false, true ); ?>' <?php endif; ?> + itemscope itemtype="http://schema.org/ImageGallery" > <?php $this->template( "$this->type-layout", $context ); ?> </div> diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/item.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/item.php index 2bbd2ce6..f569cb50 100644 --- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/item.php +++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/item.php @@ -6,10 +6,12 @@ if ( empty( $item->image_alt ) && ! empty( $item->image_title ) ) { $item->image_alt = $item->image_title; } ?> -<div class="tiled-gallery-item<?php if ( isset( $item->size ) ) echo " tiled-gallery-item-$item->size"; ?>"> +<div class="tiled-gallery-item<?php if ( isset( $item->size ) ) echo " tiled-gallery-item-$item->size"; ?>" itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject"> <?php if ( $add_link ): ?> - <a href="<?php echo $item->link; ?>" border="0"> + <a href="<?php echo $item->link; ?>" border="0" itemprop="url"> <?php endif; ?> + <meta itemprop="width" content="<?php echo esc_attr( $item->image->width ); ?>"> + <meta itemprop="height" content="<?php echo esc_attr( $item->image->height ); ?>"> <img <?php $this->partial( 'carousel-image-args', array( 'item' => $item ) ); ?> src="<?php echo esc_url( $item->img_src ); ?>" @@ -17,6 +19,7 @@ if ( empty( $item->image_alt ) && ! empty( $item->image_title ) ) { height="<?php echo esc_attr( $item->image->height ); ?>" data-original-width="<?php echo esc_attr( $item->image->width ); ?>" data-original-height="<?php echo esc_attr( $item->image->height ); ?>" + itemprop="http://schema.org/image" title="<?php echo esc_attr( $item->image_title ); ?>" alt="<?php echo esc_attr( $item->image_alt ); ?>" style="width: <?php echo esc_attr( $item->image->width ); ?>px; height: <?php echo esc_attr( $item->image->height ); ?>px;" @@ -27,8 +30,10 @@ if ( empty( $item->image_alt ) && ! empty( $item->image_title ) ) { <?php if ( $this->grayscale == true ): ?> <?php if ( $add_link ): ?> - <a href="<?php echo $item->link; ?>" border="0"> + <a href="<?php echo $item->link; ?>" border="0" itemprop="url"> <?php endif; ?> + <meta itemprop="width" content="<?php echo esc_attr( $item->image->width ); ?>"> + <meta itemprop="height" content="<?php echo esc_attr( $item->image->height ); ?>"> <img class="grayscale" src="<?php echo esc_url( $item->img_src_grayscale ); ?>" @@ -36,6 +41,7 @@ if ( empty( $item->image_alt ) && ! empty( $item->image_title ) ) { height="<?php echo esc_attr( $item->image->height ); ?>" data-original-width="<?php echo esc_attr( $item->image->width ); ?>" data-original-height="<?php echo esc_attr( $item->image->height ); ?>" + itemprop="http://schema.org/image" title="<?php echo esc_attr( $item->image_title ); ?>" align="left" alt="<?php echo esc_attr( $item->image_alt ); ?>" @@ -47,9 +53,8 @@ if ( empty( $item->image_alt ) && ! empty( $item->image_title ) ) { <?php endif; ?> <?php if ( trim( $item->image->post_excerpt ) ): ?> - <div class="tiled-gallery-caption"> + <div class="tiled-gallery-caption" itemprop="caption description"> <?php echo wptexturize( $item->image->post_excerpt ); ?> </div> <?php endif; ?> </div> - diff --git a/plugins/jetpack/modules/videopress/videopress.php b/plugins/jetpack/modules/videopress/videopress.php index c3542a45..1f7236a1 100644 --- a/plugins/jetpack/modules/videopress/videopress.php +++ b/plugins/jetpack/modules/videopress/videopress.php @@ -22,7 +22,7 @@ class Jetpack_VideoPress { function __construct() { $this->version = time(); // <s>ghost</s> cache busters! - add_action( 'jetpack_modules_loaded', array( $this, 'jetpack_modules_loaded' ) ); + add_action( 'init', array( $this, 'on_init' ) ); add_action( 'jetpack_activate_module_videopress', array( $this, 'jetpack_module_activated' ) ); add_action( 'jetpack_deactivate_module_videopress', array( $this, 'jetpack_module_deactivated' ) ); @@ -30,9 +30,9 @@ class Jetpack_VideoPress { } /** - * After all modules have been loaded. + * Fires on init since is_connection_owner should wait until the user is initialized by $wp->init(); */ - function jetpack_modules_loaded() { + function on_init() { $options = $this->get_options(); // Only the connection owner can configure this module. diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions.php b/plugins/jetpack/modules/widget-visibility/widget-conditions.php index 0878f56d..c6241dea 100644 --- a/plugins/jetpack/modules/widget-visibility/widget-conditions.php +++ b/plugins/jetpack/modules/widget-visibility/widget-conditions.php @@ -252,6 +252,7 @@ class Jetpack_Widget_Conditions { <?php foreach ( $conditions['rules'] as $rule ) { + $rule = wp_parse_args( $rule, array( 'major' => '', 'minor' => '', 'has_children' => '' ) ); ?> <div class="condition"> <div class="selection alignleft"> @@ -311,6 +312,10 @@ class Jetpack_Widget_Conditions { * @return array Modified settings. */ public static function widget_update( $instance, $new_instance, $old_instance ) { + if ( empty( $_POST['conditions'] ) ) { + return $instance; + } + $conditions = array(); $conditions['action'] = $_POST['conditions']['action']; $conditions['rules'] = array(); @@ -513,7 +518,8 @@ class Jetpack_Widget_Conditions { $condition_result = $wp_query->is_posts_page; } else { // $rule['minor'] is a page ID - $condition_result = is_page( $rule['minor'] ); + $condition_result = is_page() && ( $rule['minor'] == get_the_ID() ); + // Check if $rule['minor'] is parent of page ID if ( ! $condition_result && isset( $rule['has_children'] ) && $rule['has_children'] ) $condition_result = wp_get_post_parent_id( get_the_ID() ) == $rule['minor']; diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.js b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.js index e6749e4b..34dc4dd9 100644 --- a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.js +++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.js @@ -48,9 +48,8 @@ jQuery( function( $ ) { } } - $( 'a.display-options' ).each( function() { - var $displayOptionsButton = $( this ), - $widget = $displayOptionsButton.closest( 'div.widget' ); + function moveWidgetVisibilityButton( $widget ) { + var $displayOptionsButton = $widget.find( 'a.display-options' ).first(); $displayOptionsButton.insertBefore( $widget.find( 'input.widget-control-save' ) ); // Widgets with no configurable options don't show the Save button's container. @@ -61,7 +60,16 @@ jQuery( function( $ ) { .remove() .css( 'float', 'left' ) .prependTo( $displayOptionsButton.parent() ); + } + $( '.widget' ).each( function() { + moveWidgetVisibilityButton( $( this ) ); + } ); + + $( document ).on( 'widget-added', function( e, $widget ) { + if ( $widget.find( 'div.widget-control-actions a.display-options' ).length === 0 ) { + moveWidgetVisibilityButton( $widget ); + } } ); widgets_shell.on( 'click.widgetconditions', 'a.add-condition', function( e ) { diff --git a/plugins/jetpack/modules/widgets/contact-info.php b/plugins/jetpack/modules/widgets/contact-info.php index dcf2878e..5457f525 100644 --- a/plugins/jetpack/modules/widgets/contact-info.php +++ b/plugins/jetpack/modules/widgets/contact-info.php @@ -24,7 +24,8 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { function __construct() { $widget_ops = array( 'classname' => 'widget_contact_info', - 'description' => __( 'Display your location, hours, and contact information.', 'jetpack' ) + 'description' => __( 'Display your location, hours, and contact information.', 'jetpack' ), + 'customize_selective_refresh' => true, ); parent::__construct( 'widget_contact_info', @@ -33,8 +34,21 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { $widget_ops ); $this->alt_option_name = 'widget_contact_info'; + + if ( is_customize_preview() ) { + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); + } } + /** + * Enqueue scripts and styles. + */ + public function enqueue_scripts() { + wp_enqueue_script( 'jquery' ); + wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?sensor=false' ); + wp_enqueue_script( 'contact-info-map-js', plugins_url( 'contact-info/contact-info-map.js', __FILE__ ), array( 'jquery', 'google-maps' ), 20150127 ); + wp_enqueue_style( 'contact-info-map-css', plugins_url( 'contact-info/contact-info-map.css', __FILE__ ), null, 20150127 ); + } /** * Return an associative array of default values @@ -71,6 +85,14 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { if ( $instance['title'] != '' ) echo $before_title . $instance['title'] . $after_title; + /** + * Fires at the beginning of the Contact Info widget, after the title. + * + * @module widgets + * + * @since 3.9.2 + */ + do_action( 'jetpack_contact_info_widget_start' ); $map_link = 0; @@ -111,6 +133,16 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { } + /** + * Fires at the end of Contact Info widget. + * + * @module widgets + * + * @since 3.9.2 + */ + do_action( 'jetpack_contact_info_widget_end' ); + + echo $after_widget; } @@ -227,11 +259,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { function build_map( $lat, $lon ) { - - wp_enqueue_script( "jquery" ); - wp_enqueue_script( "google-maps", "https://maps.googleapis.com/maps/api/js?sensor=false" ); - wp_enqueue_script( "contact-info-map-js", plugins_url( 'contact-info/contact-info-map.js', __FILE__ ), array( 'jquery', 'google-maps' ), 20150127 ); - wp_enqueue_style( "contact-info-map-css", plugins_url( 'contact-info/contact-info-map.css', __FILE__ ), null, 20150127 ); + $this->enqueue_scripts(); $lat = esc_attr( $lat ); $lon = esc_attr( $lon ); diff --git a/plugins/jetpack/modules/widgets/contact-info/contact-info-map.js b/plugins/jetpack/modules/widgets/contact-info/contact-info-map.js index 11a85fdb..3b5a0de7 100644 --- a/plugins/jetpack/modules/widgets/contact-info/contact-info-map.js +++ b/plugins/jetpack/modules/widgets/contact-info/contact-info-map.js @@ -1,8 +1,13 @@ /* global google */ /* jshint unused:false */ -if (jQuery) { - jQuery().ready(function() { - jQuery('div.contact-map').each(function(){ +jQuery( function( $ ) { + var hasSelectiveRefresh; + + function setupContactMaps( rootElement ) { + rootElement = $( rootElement || document.body ); + + rootElement.find( 'div.contact-map' ).each( function() { + // get lat and lon from hidden input values var lat = jQuery(this).find('.contact-info-map-lat').val(), lon = jQuery(this).find('.contact-info-map-lon').val(), @@ -18,10 +23,27 @@ if (jQuery) { position: lat_lon }); - google.maps.event.addListenerOnce(map, 'mouseover', function() { - google.maps.event.trigger(map, 'resize'); - }); + google.maps.event.addListenerOnce(map, 'mouseover', function() { + google.maps.event.trigger(map, 'resize'); + }); }); - }); -} + } + + setupContactMaps(); + + hasSelectiveRefresh = ( + 'undefined' !== typeof wp && + wp.customize && + wp.customize.selectiveRefresh && + wp.customize.widgetsPreview && + wp.customize.widgetsPreview.WidgetPartial + ); + if ( hasSelectiveRefresh ) { + wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { + if ( placement.partial.widgetId && /^widget_contact_info-\d+$/.test( placement.partial.widgetId ) ) { + setupContactMaps( placement.container ); + } + } ); + } +} ); diff --git a/plugins/jetpack/modules/widgets/facebook-likebox.php b/plugins/jetpack/modules/widgets/facebook-likebox.php index 2943bc09..4bf00713 100644 --- a/plugins/jetpack/modules/widgets/facebook-likebox.php +++ b/plugins/jetpack/modules/widgets/facebook-likebox.php @@ -38,9 +38,23 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { apply_filters( 'jetpack_widget_name', __( 'Facebook Page Plugin', 'jetpack' ) ), array( 'classname' => 'widget_facebook_likebox', - 'description' => __( 'Use the Facebook Page Plugin to connect visitors to your Facebook Page', 'jetpack' ) + 'description' => __( 'Use the Facebook Page Plugin to connect visitors to your Facebook Page', 'jetpack' ), + 'customize_selective_refresh' => true, ) ); + + if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) { + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); + } + } + + /** + * Enqueue scripts. + */ + public function enqueue_scripts() { + wp_enqueue_script( 'jetpack-facebook-embed' ); + wp_enqueue_style( 'jetpack_facebook_likebox', plugins_url( 'facebook-likebox/style.css', __FILE__ ) ); + wp_style_add_data( 'jetpack_facebook_likebox', 'jetpack-inline', true ); } function widget( $args, $instance ) { @@ -49,9 +63,6 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { $like_args = $this->normalize_facebook_args( $instance['like_args'] ); - wp_enqueue_style( 'jetpack_facebook_likebox', plugins_url( 'facebook-likebox/style.css', __FILE__ ) ); - wp_style_add_data( 'jetpack_facebook_likebox', 'jetpack-inline', true ); - if ( empty( $like_args['href'] ) || ! $this->is_valid_facebook_url( $like_args['href'] ) ) { if ( current_user_can('edit_theme_options') ) { echo $before_widget; @@ -70,16 +81,6 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { $like_args['stream'] = (bool) $like_args['stream'] ? 'true' : 'false'; $like_args['cover'] = (bool) $like_args['cover'] ? 'false' : 'true'; - $locale = $this->get_locale(); - - /** This filter is documented in modules/sharedaddy/sharing-sources.php */ - $fb_app_id = apply_filters( 'jetpack_sharing_facebook_app_id', '249643311490' ); - if ( is_numeric( $fb_app_id ) ) { - $fb_app_id = '&appId=' . $fb_app_id; - } else { - $fb_app_id = ''; - } - echo $before_widget; if ( ! empty( $title ) ) : @@ -108,8 +109,8 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { <div class="fb-page" data-href="<?php echo esc_url( $page_url ); ?>" data-width="<?php echo intval( $like_args['width'] ); ?>" data-height="<?php echo intval( $like_args['height'] ); ?>" data-hide-cover="<?php echo esc_attr( $like_args['cover'] ); ?>" data-show-facepile="<?php echo esc_attr( $like_args['show_faces'] ); ?>" data-show-posts="<?php echo esc_attr( $like_args['stream'] ); ?>"> <div class="fb-xfbml-parse-ignore"><blockquote cite="<?php echo esc_url( $page_url ); ?>"><a href="<?php echo esc_url( $page_url ); ?>"><?php echo esc_html( $title ); ?></a></blockquote></div> </div> - <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = '//connect.facebook.net/<?php echo esc_html( $locale ); ?>/sdk.js#xfbml=1<?php echo $fb_app_id; ?>&version=v2.3'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <?php + wp_enqueue_script( 'jetpack-facebook-embed' ); echo $after_widget; /** This action is already documented in modules/widgets/gravatar-profile.php */ @@ -283,54 +284,20 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget { return $value; } + /** + * @deprecated + */ function guess_locale_from_lang( $lang ) { - if ( 'en' == $lang || 'en_US' == $lang || !$lang ) { - return 'en_US'; - } - - if ( !class_exists( 'GP_Locales' ) ) { - if ( !defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) || !file_exists( JETPACK__GLOTPRESS_LOCALES_PATH ) ) { - return false; - } - - require JETPACK__GLOTPRESS_LOCALES_PATH; - } - - if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { - // WP.com: get_locale() returns 'it' - $locale = GP_Locales::by_slug( $lang ); - } else { - // Jetpack: get_locale() returns 'it_IT'; - $locale = GP_Locales::by_field( 'facebook_locale', $lang ); - } - - if ( ! $locale ) { - return false; - } - - if ( empty( $locale->facebook_locale ) ) { - if ( empty( $locale->wp_locale ) ) { - return false; - } else { - // Facebook SDK is smart enough to fall back to en_US if a - // locale isn't supported. Since supported Facebook locales - // can fall out of sync, we'll attempt to use the known - // wp_locale value and rely on said fallback. - return $locale->wp_locale; - } - } - - return $locale->facebook_locale; + _deprecated_function( __METHOD__, '3.10', 'Jetpack::guess_locale_from_lang()' ); + Jetpack::$instance->get_locale_from_lang( $lang ); } + /** + * @deprecated + */ function get_locale() { - $locale = $this->guess_locale_from_lang( get_locale() ); - - if ( ! $locale ) { - $locale = 'en_US'; - } - - return $locale; + _deprecated_function( __METHOD__, '3.10', 'Jetpack::get_locale()' ); + Jetpack::$instance->get_locale(); } } diff --git a/plugins/jetpack/modules/widgets/social-media-icons.php b/plugins/jetpack/modules/widgets/social-media-icons.php index 30908669..f46ef290 100644 --- a/plugins/jetpack/modules/widgets/social-media-icons.php +++ b/plugins/jetpack/modules/widgets/social-media-icons.php @@ -18,7 +18,10 @@ class WPCOM_social_media_icons_widget extends WP_Widget { 'wpcom_social_media_icons_widget', /** This filter is documented in modules/widgets/facebook-likebox.php */ apply_filters( 'jetpack_widget_name', esc_html__( 'Social Media Icons', 'jetpack' ) ), - array( 'description' => __( 'A simple widget that displays social media icons.', 'jetpack' ), ) + array( + 'description' => __( 'A simple widget that displays social media icons.', 'jetpack' ), + 'customize_selective_refresh' => true, + ) ); $this->defaults = array( @@ -46,7 +49,7 @@ class WPCOM_social_media_icons_widget extends WP_Widget { 'googleplus' => array( 'Google+', 'https://plus.google.com/u/0/%s/' ), ); - if ( is_active_widget( false, false, $this->id_base ) ) { + if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) ); } } diff --git a/plugins/jetpack/modules/widgets/top-posts.php b/plugins/jetpack/modules/widgets/top-posts.php index e14b4434..3bf12b7c 100644 --- a/plugins/jetpack/modules/widgets/top-posts.php +++ b/plugins/jetpack/modules/widgets/top-posts.php @@ -44,6 +44,15 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { if ( is_active_widget( false, false, $this->id_base ) ) { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) ); } + + /** + * Add explanation about how the statistics are calculated. + * + * @module widgets + * + * @since 3.9.3 + */ + add_action( 'jetpack_widget_top_posts_after_fields', array( $this, 'stats_explanation' ) ); } function enqueue_style() { @@ -52,10 +61,9 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { } function form( $instance ) { - $title = isset( $instance['title' ] ) ? $instance['title'] : false; - if ( false === $title ) { - $title = $this->default_title; - } + $instance = wp_parse_args( (array) $instance, $this->defaults() ); + + $title = stripslashes( $instance['title'] ); $count = isset( $instance['count'] ) ? (int) $instance['count'] : 10; if ( $count < 1 || 10 < $count ) { @@ -65,6 +73,9 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { $allowed_post_types = array_values( get_post_types( array( 'public' => true ) ) ); $types = isset( $instance['types'] ) ? (array) $instance['types'] : array( 'post', 'page' ); + // 'likes' are not available in Jetpack + $ordering = isset( $instance['ordering'] ) && 'likes' === $instance['ordering'] ? 'likes' : 'views'; + if ( isset( $instance['display'] ) && in_array( $instance['display'], array( 'grid', 'list', 'text' ) ) ) { $display = $instance['display']; } else { @@ -83,6 +94,16 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { <input id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>" type="number" value="<?php echo (int) $count; ?>" min="1" max="10" /> </p> + <?php if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) : ?> + <p> + <label><?php esc_html_e( 'Order Top Posts & Pages By:', 'jetpack' ); ?></label> + <ul> + <li><label><input id="<?php echo $this->get_field_id( 'ordering' ); ?>-likes" name="<?php echo $this->get_field_name( 'ordering' ); ?>" type="radio" value="likes" <?php checked( 'likes', $ordering ); ?> /> <?php esc_html_e( 'Likes', 'jetpack' ); ?></label></li> + <li><label><input id="<?php echo $this->get_field_id( 'ordering' ); ?>-views" name="<?php echo $this->get_field_name( 'ordering' ); ?>" type="radio" value="views" <?php checked( 'views', $ordering ); ?> /> <?php esc_html_e( 'Views', 'jetpack' ); ?></label></li> + </ul> + </p> + <?php endif; ?> + <p> <label for="<?php echo $this->get_field_id( 'types' ); ?>"><?php esc_html_e( 'Types of pages to display:', 'jetpack' ); ?></label> <ul> @@ -112,11 +133,32 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { <li><label><input id="<?php echo $this->get_field_id( 'display' ); ?>-list" name="<?php echo $this->get_field_name( 'display' ); ?>" type="radio" value="list" <?php checked( 'list', $display ); ?> /> <?php esc_html_e( 'Image List', 'jetpack' ); ?></label></li> <li><label><input id="<?php echo $this->get_field_id( 'display' ); ?>-grid" name="<?php echo $this->get_field_name( 'display' ); ?>" type="radio" value="grid" <?php checked( 'grid', $display ); ?> /> <?php esc_html_e( 'Image Grid', 'jetpack' ); ?></label></li> </ul> - </p> + </p><?php - <p><?php esc_html_e( 'Top Posts & Pages by views are calculated from 24-48 hours of stats. They take a while to change.', 'jetpack' ); ?></p> + /** + * Fires after the fields are displayed in the Top Posts Widget settings in wp-admin. + * + * Allow adding extra content after the fields are displayed. + * + * @module widgets + * + * @since 3.9.3 + * + * @param array $args { + * @param array $instance The widget instance. + * @param object $this The class object. + * } + */ + do_action( 'jetpack_widget_top_posts_after_fields', array( $instance, $this ) ); + } + + /** + * Explains how the statics are calculated. + */ + function stats_explanation() { + ?> - <?php + <p><?php esc_html_e( 'Top Posts & Pages by views are calculated from 24-48 hours of stats. They take a while to change.', 'jetpack' ); ?></p><?php } function update( $new_instance, $old_instance ) { @@ -131,6 +173,9 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { $instance['count'] = 10; } + // 'likes' are not available in Jetpack + $instance['ordering'] = isset( $new_instance['ordering'] ) && 'likes' == $new_instance['ordering'] ? 'likes' : 'views'; + $allowed_post_types = array_values( get_post_types( array( 'public' => true ) ) ); $instance['types'] = $new_instance['types']; foreach( $new_instance['types'] as $key => $type ) { @@ -145,10 +190,24 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { $instance['display'] = 'text'; } + /** + * Filters Top Posts Widget settings before they're saved. + * + * @module widgets + * + * @since 3.9.3 + * + * @param array $instance The santized widget instance. Only contains data processed by the current widget. + * @param array $new_instance The new widget instance before sanitization. + */ + $instance = apply_filters( 'jetpack_top_posts_saving', $instance, $new_instance ); + return $instance; } function widget( $args, $instance ) { + $instance = wp_parse_args( (array) $instance, $this->defaults() ); + $title = isset( $instance['title' ] ) ? $instance['title'] : false; if ( false === $title ) { $title = $this->default_title; @@ -173,6 +232,9 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { $types = isset( $instance['types'] ) ? (array) $instance['types'] : array( 'post', 'page' ); + // 'likes' are not available in Jetpack + $ordering = isset( $instance['ordering'] ) && 'likes' == $instance['ordering'] ? 'likes' : 'views'; + if ( isset( $instance['display'] ) && in_array( $instance['display'], array( 'grid', 'list', 'text' ) ) ) { $display = $instance['display']; } else { @@ -207,7 +269,11 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { $get_image_options = apply_filters( 'jetpack_top_posts_widget_image_options', $get_image_options ); } - $posts = $this->get_by_views( $count ); + if ( function_exists( 'wpl_get_blogs_most_liked_posts' ) && 'likes' == $ordering ) { + $posts = $this->get_by_likes( $count ); + } else { + $posts = $this->get_by_views( $count, $args ); + } // Filter the returned posts. Remove all posts that do not match the chosen Post Types. if ( isset( $types ) ) { @@ -343,17 +409,55 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { echo $args['after_widget']; } - function get_by_views( $count ) { + public static function defaults() { + return array( + 'title' => esc_html__( 'Top Posts & Pages', 'jetpack' ), + 'count' => absint( 10 ), + 'types' => array( 'post', 'page' ), + 'ordering' => 'views', + 'display' => 'text', + ); + } + + /* + * Get most liked posts + * + * ONLY TO BE USED IN WPCOM + */ + function get_by_likes( $count ) { + $post_likes = wpl_get_blogs_most_liked_posts(); + if ( !$post_likes ) { + return array(); + } + + return $this->get_posts( array_keys( $post_likes ), $count ); + } + + function get_by_views( $count, $args ) { + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { + global $wpdb; + + $post_views = wp_cache_get( "get_top_posts_$count", 'stats' ); + if ( false === $post_views ) { + $post_views = array_shift( stats_get_daily_history( false, get_current_blog_id(), 'postviews', 'post_id', false, 2, '', $count * 2 + 10, true ) ); + unset( $post_views[0] ); + wp_cache_add( "get_top_posts_$count", $post_views, 'stats', 1200); + } + + return $this->get_posts( array_keys( $post_views ), $count ); + } + /** * Filter the number of days used to calculate Top Posts for the Top Posts widget. * * @module widgets * - * @since 2.8.0 + * @since 3.9.3 * * @param int 2 Number of days. Default is 2. + * @param array $args The widget arguments. */ - $days = (int) apply_filters( 'jetpack_top_posts_days', 2 ); + $days = (int) apply_filters( 'jetpack_top_posts_days', 2, $args ); if ( $days < 1 ) { $days = 2; @@ -448,3 +552,33 @@ class Jetpack_Top_Posts_Widget extends WP_Widget { return apply_filters( 'jetpack_widget_get_top_posts', $posts, $post_ids, $count ); } } + +/** + * Create a shortcode to display the widget anywhere. + * + * @since 3.9.2 + */ +function jetpack_do_top_posts_widget( $instance ) { + // Post Types can't be entered as an array in the shortcode parameters. + if ( isset( $instance['types'] ) && is_array( $instance['types'] ) ) { + $instance['types'] = implode( ',', $instance['types'] ); + } + + $instance = shortcode_atts( + Jetpack_Top_Posts_Widget::defaults(), + $instance, + 'jetpack_top_posts_widget' + ); + + // Add a class to allow styling + $args = array( + 'before_widget' => sprintf( '<div class="%s">', 'jetpack_top_posts_widget' ), + ); + + ob_start(); + the_widget( 'Jetpack_Top_Posts_Widget', $instance, $args ); + $output = ob_get_clean(); + + return $output; +} +add_shortcode( 'jetpack_top_posts_widget', 'jetpack_do_top_posts_widget' ); diff --git a/plugins/jetpack/modules/widgets/twitter-timeline.php b/plugins/jetpack/modules/widgets/twitter-timeline.php index 9301f639..76719043 100644 --- a/plugins/jetpack/modules/widgets/twitter-timeline.php +++ b/plugins/jetpack/modules/widgets/twitter-timeline.php @@ -25,31 +25,31 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget { apply_filters( 'jetpack_widget_name', esc_html__( 'Twitter Timeline', 'jetpack' ) ), array( 'classname' => 'widget_twitter_timeline', - 'description' => __( 'Display an official Twitter Embedded Timeline widget.', 'jetpack' ) + 'description' => __( 'Display an official Twitter Embedded Timeline widget.', 'jetpack' ), + 'customize_selective_refresh' => true, ) ); - if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) ) { - add_action( 'wp_footer', array( $this, 'library' ) ); + if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) { + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); } } /** - * Enqueue Twitter's widget library + * Enqueue scripts. + */ + public function enqueue_scripts() { + wp_enqueue_script( 'jetpack-twitter-timeline' ); + } + + /** + * Enqueue Twitter's widget library. + * + * @deprecated */ public function library() { - ?> - <script type="text/javascript"> - !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"); - </script> - <?php + _deprecated_function( __METHOD__, '3.10' ); + wp_print_scripts( array( 'jetpack-twitter-timeline' ) ); } /** @@ -203,7 +203,7 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget { </p> <p> - <label for="<?php echo $this->get_field_id( 'width' ); ?>"><?php esc_html_e( 'Width (px):', 'jetpack' ); ?></label> + <label for="<?php echo $this->get_field_id( 'width' ); ?>"><?php esc_html_e( 'Maximum Width (px):', 'jetpack' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'width' ); ?>" name="<?php echo $this->get_field_name( 'width' ); ?>" type="text" value="<?php echo esc_attr( $instance['width'] ); ?>" /> </p> diff --git a/plugins/jetpack/modules/widgets/wordpress-post-widget.php b/plugins/jetpack/modules/widgets/wordpress-post-widget.php index 198effc4..f06753bc 100644 --- a/plugins/jetpack/modules/widgets/wordpress-post-widget.php +++ b/plugins/jetpack/modules/widgets/wordpress-post-widget.php @@ -597,21 +597,22 @@ class Jetpack_Display_Posts_Widget extends WP_Widget { return false; } - /** - * If Jetpack is not active or in development mode, we don't want to update widget data. - */ - if ( ! Jetpack::is_active() && ! Jetpack::is_development_mode() ) { - return false; - } + if ( ! defined( 'IS_WPCOM' ) || ! IS_WPCOM ) { + /** + * If Jetpack is not active or in development mode, we don't want to update widget data. + */ + if ( ! Jetpack::is_active() && ! Jetpack::is_development_mode() ) { + return false; + } - /** - * If Extra Sidebar Widgets module is not active, we don't need to update widget data. - */ - if ( ! Jetpack::is_module_active( 'widgets' ) ) { - return false; + /** + * If Extra Sidebar Widgets module is not active, we don't need to update widget data. + */ + if ( ! Jetpack::is_module_active( 'widgets' ) ) { + return false; + } } - - + /** * If none of the above checks failed, then we definitely want to update widget data. */ @@ -790,7 +791,7 @@ class Jetpack_Display_Posts_Widget extends WP_Widget { * @param array $args Array of Photon Parameters. */ $image_params = apply_filters( 'jetpack_display_posts_widget_image_params', array() ); - echo '<a title="' . esc_attr( $post_title ) . '" href="' . esc_url( $single_post['url'] ) . '"><img src="' . jetpack_photon_url( $featured_image, $image_params ) . '" alt="' . esc_attr( $post_title ) . '"/></a>'; + echo '<a title="' . esc_attr( $post_title ) . '" href="' . esc_url( $single_post['url'] ) . '"' . $target . '><img src="' . jetpack_photon_url( $featured_image, $image_params ) . '" alt="' . esc_attr( $post_title ) . '"/></a>'; } if ( $instance['show_excerpts'] == true ) { @@ -926,7 +927,12 @@ class Jetpack_Display_Posts_Widget extends WP_Widget { <?php _e( "Enter a WordPress.com or Jetpack WordPress site URL.", 'jetpack' ); ?> </i> <?php - if ( empty( $url ) ) { + /** + * Show an error if the URL field was left empty. + * + * The error is shown only when the widget was already saved. + */ + if ( empty( $url ) && ! preg_match( '/__i__|%i%/', $this->id ) ) { ?> <br /> <i class="error-message"><?php echo __( 'You must specify a valid blog URL!', 'jetpack' ); ?></i> @@ -968,10 +974,10 @@ class Jetpack_Display_Posts_Widget extends WP_Widget { * Prepare the error messages. */ - $what_broke_down = ''; + $where_message = ''; switch ( $update_errors['where'] ) { case 'posts': - $what_broke_down .= __( 'posts list', 'jetpack' ); + $where_message .= __( 'An error occurred while downloading blog posts list', 'jetpack' ); break; /** @@ -981,19 +987,13 @@ class Jetpack_Display_Posts_Widget extends WP_Widget { */ case 'site_info': default: - $what_broke_down .= __( 'information', 'jetpack' ); + $where_message .= __( 'An error occurred while downloading blog information', 'jetpack' ); break; } - $where_message = sprintf( - __( 'An error occurred while downloading blog %s', 'jetpack' ), - $what_broke_down - ); - - ?> <p class="error-message"> - <?php echo $where_message; ?>: + <?php echo esc_html( $where_message ); ?>: <br /> <i> <?php echo esc_html( $update_errors['message'] ); ?> @@ -1005,7 +1005,7 @@ class Jetpack_Display_Posts_Widget extends WP_Widget { ?> <br /> <br /> - <?php echo __( 'Detailed information', 'jetpack' ); ?>: + <?php esc_html_e( 'Detailed information', 'jetpack' ); ?>: <br /> <?php echo esc_html( $update_errors['debug'] ); ?> <?php @@ -1124,4 +1124,4 @@ class Jetpack_Display_Posts_Widget extends WP_Widget { public function wp_wp_remote_get( $url, $args = array() ) { return wp_remote_get( $url, $args ); } -}
\ No newline at end of file +} |