From d946d0ca50778c9baa09f05d09cb2e92720b82fe Mon Sep 17 00:00:00 2001 From: Yury German Date: Sun, 19 Mar 2017 02:02:42 -0400 Subject: Jetpack version 4.7.1 --- plugins/jetpack/_inc/jetpack-strings.php | 16 +-- plugins/jetpack/changelog.txt | 86 ++++++++++++++ plugins/jetpack/class.jetpack.php | 36 +++++- plugins/jetpack/css/jetpack-rtl.css | 3 + plugins/jetpack/css/jetpack.css | 3 + plugins/jetpack/jetpack.php | 4 +- .../jetpack/modules/carousel/jetpack-carousel.js | 5 + plugins/jetpack/modules/markdown.php | 14 +++ .../jetpack/modules/sharedaddy/sharing-service.php | 6 - plugins/jetpack/modules/sso.php | 74 ++++++++++-- .../modules/videopress/class.videopress-xmlrpc.php | 13 ++- .../modules/videopress/utility-functions.php | 128 ++++++++++++++++++++- .../widget-visibility/widget-conditions.php | 76 ++++++++++++ .../rtl/widget-conditions-rtl.css | 59 ++++++++-- .../widget-conditions/widget-conditions.js | 5 +- plugins/jetpack/modules/widgets/image-widget.php | 14 +-- plugins/jetpack/readme.txt | 20 +++- 17 files changed, 503 insertions(+), 59 deletions(-) diff --git a/plugins/jetpack/_inc/jetpack-strings.php b/plugins/jetpack/_inc/jetpack-strings.php index 7e177b74..3c626a22 100644 --- a/plugins/jetpack/_inc/jetpack-strings.php +++ b/plugins/jetpack/_inc/jetpack-strings.php @@ -131,11 +131,11 @@ __( "Security Scanning", "jetpack" ), // _inc/client/at-a-glance/scan.jsx:29 __( "{{a}}Activate Site Verification{{/a}} to verify your site and increase ranking with Google, Bing, and Pinterest.", "jetpack" ), // _inc/client/at-a-glance/site-verification.jsx:43 __( "Site Verification Tools are active. Ensure your site is verified with Google, Bing, and Pinterest for more accurate indexing and ranking. {{a}}Verify now{{/a}}", "jetpack" ), // _inc/client/at-a-glance/site-verification.jsx:27 __( "Site Verification Tools", "jetpack" ), // _inc/client/at-a-glance/site-verification.jsx:21 -__( "By activating ads, you agree to the Automattic Ads {{link}}Terms of Service{{/link}}.", "jetpack" ), // _inc/client/engagement/index.jsx:276 -__( "View your earnings", "jetpack" ), // _inc/client/engagement/index.jsx:251 -__( "View your {{a}}Email Followers{{/a}}", "jetpack" ), // _inc/client/engagement/index.jsx:232 -__( "View {{a}}All Stats{{/a}}", "jetpack" ), // _inc/client/engagement/index.jsx:217 -__( "Learn More", "jetpack" ), // _inc/client/engagement/index.jsx:210 +__( "By activating ads, you agree to the Automattic Ads {{link}}Terms of Service{{/link}}.", "jetpack" ), // _inc/client/engagement/index.jsx:279 +__( "View your earnings", "jetpack" ), // _inc/client/engagement/index.jsx:254 +__( "View your {{a}}Email Followers{{/a}}", "jetpack" ), // _inc/client/engagement/index.jsx:235 +__( "View {{a}}All Stats{{/a}}", "jetpack" ), // _inc/client/engagement/index.jsx:220 +__( "Learn More", "jetpack" ), // _inc/client/engagement/index.jsx:213 __( "Paid", "jetpack" ), // _inc/client/engagement/index.jsx:158 __( "Unavailable in Dev Mode", "jetpack" ), // _inc/client/engagement/index.jsx:128 __( "Your site must be accessible by search engines for this feature to work properly. You can change this in {{a}}Reading Settings{{/a}}.", "jetpack" ), // _inc/client/engagement/index.jsx:55 @@ -279,14 +279,14 @@ __( "Something happened while loading stats. Please try again later or {{a}}view __( "Click to view detailed stats.", "jetpack" ), // _inc/client/at-a-glance/stats/index.jsx:92 __( "Views: %(numberOfViews)s", "jetpack" ), // _inc/client/at-a-glance/stats/index.jsx:90 __( "Week of %(date)s", "jetpack" ), // _inc/client/at-a-glance/stats/index.jsx:74 -__( "Paid", "jetpack" ), // _inc/client/components/dash-item/index.jsx:98 -__( "Active", "jetpack" ), // _inc/client/components/dash-item/index.jsx:87 -__( "Updates Needed", "jetpack" ), // _inc/client/components/dash-item/index.jsx:81 __( "Connect Jetpack", "jetpack" ), // _inc/client/components/connect-button/index.jsx:101 __( "Disconnect Jetpack", "jetpack" ), // _inc/client/components/connect-button/index.jsx:86 __( "Do you really want to disconnect your site from WordPress.com?", "jetpack" ), // _inc/client/components/connect-button/index.jsx:71 __( "Link to WordPress.com", "jetpack" ), // _inc/client/components/connect-button/index.jsx:65 __( "Unlink me from WordPress.com", "jetpack" ), // _inc/client/components/connect-button/index.jsx:48 +__( "Paid", "jetpack" ), // _inc/client/components/dash-item/index.jsx:98 +__( "Active", "jetpack" ), // _inc/client/components/dash-item/index.jsx:87 +__( "Updates Needed", "jetpack" ), // _inc/client/components/dash-item/index.jsx:81 _x( "Settings", "Noun. Displayed to screen readers.", "jetpack" ), // _inc/client/components/dash-section-header/index.jsx:43 _x( "Privacy", "Shorthand for Privacy Policy.", "jetpack" ), // _inc/client/components/footer/index.jsx:126 __( "Automattic's Privacy Policy", "jetpack" ), // _inc/client/components/footer/index.jsx:124 diff --git a/plugins/jetpack/changelog.txt b/plugins/jetpack/changelog.txt index 3412325c..c47593d1 100644 --- a/plugins/jetpack/changelog.txt +++ b/plugins/jetpack/changelog.txt @@ -1,5 +1,91 @@ == Changelog == += 4.7 = + +* Release date: March 7th, 2017 +* Release post: http://wp.me/p1moTy-46L + +**Enhancements** + +* Quickly jump to post specific stats on WordPress.com with a new link. +* We've added more information to our debug tools to improve your support experience. +* New HTML5 versions of our house ads are out. +* Display custom copyright EXIF information in the Carousel with this new filter. +* We've highlighted the ability to export Contact Form feedback as it was being overlooked. +* If you have images on WordPress.com we're going to skip using Photon when the images include resize parameters. +* It is now possible to use the Sharing filter to customize the emails sent from the Email Sharing button. +* We've updated the library powering the Print link in the Recipe shortcode. +* Customize the speed and display of your slideshows with new Slideshow shortcode filters. +* The Twitch.tv shortcode now uses Twitch's new embedded player. +* Social Menus now come with the option to use SVG icons. +* Customize the content of the Display Posts Widget with a new filter. +* We've added a new email field to the Contact Info Widget. +* The Image and the Text widgets now use Photon if it is enabled. +* The WordPress.com REST API got several updates including using `register_rest_route()` consistently for registering, new date and time format settings, a filter for theme info results, new links and endpoints, and more. +* We cleaned up the Google+ Shortcode JS library and added a way to filter the SlideShare shortcode. + +**Performance Improvements** + +* Experience better performance with single page load caching of the media summary. +* We made some improvements to avoid slow queries on sites with thousands of images. +* The Top Posts widget now utilizes an endpoint from the WP.com REST API improving performance. +* Improve development mode performance by only calling `site_url()` once. +* We rewrote the way major/minor rules lists are generated to save bandwidth, and memory for sites using Widget Visibility. +* We've removed sync options that weren't needed to save memory during the sync process. + +**Accessibility** + +* We've improved the highlight of the stats range for a better visual experience and to make it consistent with other areas of the dashboard. +* Added a missing label to one of the fields in the Email sharing dialog. +* We've enabled keyboard focus styling in the new admin interface. +* Increased padding to sharing buttons on mobile to avoid usability issues. +* We've replaced Widget Visibility text labels with icons to improve usability on smaller devices. + +**Slightly Less Exciting Enhancements:** + +* We've added a filter to allow you to remove the Comment Form title. +* The Development Mode notice got an update to include all possible options to activate Development mode. +* Jetpack registration function got an update and cleanup. +* A notice displayed to WooCommerce store owners now detects when WooCommerce Services is installed, but not active. +* We've removed the Holiday Snow settings until you need them. +* Improved Infinite Scroll settings to reduce confusion. +* The HTML classes `infinite-scroll` and `neverending` are now applied using JS instead of PHP. +* We've updated the support link appearing when you're locked out of your site. +* New Unit Tests were added to make sure Publicize doesn't break when making changes to the Publicize process. +* We've added a sync filter to allow customizing timeout. +* The Top Posts widget now supports non-square image sizes. +* Added the Video GUID to the media API endpoint. + +**Improved Compatibility** + +* Fixed some W3C validation errors in Comments. +* Infinite Scroll now works beautifully with the Twenty Seventeen Theme. +* Translate new terms easier with an improvement to the translator comments. +* We switched to use Core functions to retrieve the list of sites in a multisite network for more accurate results. +* We added Product visibility to post meta whitelist, for better control of products displayed in Related Posts. +* We no longer sync specific post meta data added by Postman or WP RSS Mutli Importer to avoid performance issues during the sync process. +* We're now avoiding conflicts with plugins adding the core Video upload library to the post editor. +* Removed deprecated compatibility code for older versions of WordPress. +* We had some Shortcode conflicts with WordPress Post embeds, but that's been fixed. + +**Bug Fixes** + +* The Carousel `jp_carousel_load_for_images_linked_to_file` filter wasn't working well with Photon, this has been fixed. +* Carousel is now working well when loaded from infinite scroll. +* We removed double slashes from file paths in the Contact Form to avoid errors in specific server environments. +* Fixed a problem where CSS was being stripped when migrating from Jetpack's Custom CSS to Core's CSS editor. +* Our Debug Tool is now reporting the correct URL when WordPress lives in a subdirectory. +* Found and fixed a PHP error when uninstalling Jetpack. +* Infinite Scroll is no longer buggy when displaying the last page, and is more compatible with certain themes that were returning posts when there were none left to show. +* We're now skipping Photon for .ashx files. +* The Twitter character counter in Publicize got a fix to display info correctly. +* Related Posts are now displaying correctly for everyone, and we brought back the `jetpack_sharing_headline_html` filter. +* We've improved Sharing to render custom sharing services correctly, include Open Graph Meta Tags, and avoid JavaScript errors when jQuery is enqueued in the footer. +* Synchronization scheduling issues have been resolved. +* We're now trimming spaces in URLs for Image and Display Posts Widgets. +* Widget Visibility wasn't playing nice on taxonomy pages, this is no longer the case. +* The WordPress.com REST API received a couple of fixes to remove PHP errors when editing via the WordPress.com interface, authentication errors when using third-party apps, and permission errors when trying to preview edited posts in the WordPress.com editor. + = 4.6 = * Release date: February 7, 2017 diff --git a/plugins/jetpack/class.jetpack.php b/plugins/jetpack/class.jetpack.php index c3473223..0cd3870d 100644 --- a/plugins/jetpack/class.jetpack.php +++ b/plugins/jetpack/class.jetpack.php @@ -335,7 +335,7 @@ class Jetpack { list( $version ) = explode( ':', Jetpack_Options::get_option( 'version' ) ); if ( JETPACK__VERSION != $version ) { - // Check which active modules actually exist and remove others from active_modules list + // check which active modules actually exist and remove others from active_modules list $unfiltered_modules = Jetpack::get_active_modules(); $modules = array_filter( $unfiltered_modules, array( 'Jetpack', 'is_module' ) ); if ( array_diff( $unfiltered_modules, $modules ) ) { @@ -349,11 +349,43 @@ class Jetpack { Jetpack_Options::delete_option( 'identity_crisis_whitelist' ); } - Jetpack::maybe_set_version_option(); + // Make sure Markdown for posts gets turned back on + if ( ! get_option( 'wpcom_publish_posts_with_markdown' ) ) { + update_option( 'wpcom_publish_posts_with_markdown', true ); + } + + if ( did_action( 'wp_loaded' ) ) { + self::upgrade_on_load(); + } else { + add_action( + 'wp_loaded', + array( __CLASS__, 'upgrade_on_load' ) + ); + } } } } + /** + * Runs upgrade routines that need to have modules loaded. + */ + static function upgrade_on_load() { + + // Not attempting any upgrades if jetpack_modules_loaded did not fire. + // This can happen in case Jetpack has been just upgraded and is + // being initialized late during the page load. In this case we wait + // until the next proper admin page load with Jetpack active. + if ( ! did_action( 'jetpack_modules_loaded' ) ) { + return; + } + + Jetpack::maybe_set_version_option(); + + if ( class_exists( 'Jetpack_Widget_Conditions' ) ) { + Jetpack_Widget_Conditions::migrate_post_type_rules(); + } + } + static function activate_manage( ) { if ( did_action( 'init' ) || current_filter() == 'init' ) { self::activate_module( 'manage', false, false ); diff --git a/plugins/jetpack/css/jetpack-rtl.css b/plugins/jetpack/css/jetpack-rtl.css index 5358ab7c..168d7e72 100644 --- a/plugins/jetpack/css/jetpack-rtl.css +++ b/plugins/jetpack/css/jetpack-rtl.css @@ -22,4 +22,7 @@ div[class^=gr_custom_container]{border:1px solid gray;border-radius:10px;padding .jetpack-image-container:after{clear:both}.jetpack-image-container:after,.jetpack-image-container:before{display:table;content:""} .widgets-multi-column-grid ul{overflow:hidden;padding:0;margin:0;list-style-type:none}.widgets-multi-column-grid ul li{background:100% 0;clear:none;float:right;margin:0 0 -3px -5px;padding:0 0 6px 8px;border:none;list-style-type:none!important}.widgets-multi-column-grid ul li a{background:100% 0;margin:0;padding:0;border:0}.widgets-multi-column-grid .avatar{vertical-align:middle}.widget_jetpack_my_community .avatar-240,.widget_jetpack_my_community .avatar-48{max-width:48px;max-height:48px} .widget.widget_authors li>ul,.widget_authors>ul{margin-right:inherit;padding-right:0}.widget_authors ul li li{padding-right:0}.widget_authors>ul>li{margin-bottom:1em;list-style:none}.widget_authors>ul>li+li{border-top:0}.widget.widget_authors img{margin-left:5px;margin-bottom:5px;vertical-align:middle;box-shadow:none} +/*! +* Do not modify this file directly. It is compiled SASS code. +*/#wp-admin-bar-jetpack-idc.hide{display:none}#wp-admin-bar-jetpack-idc .jp-idc-admin-bar{background:#fff;border-radius:2px;color:#23282d;padding:4px 8px;font-size:12px}#wpadminbar #wp-admin-bar-jetpack-idc .dashicons{color:#23282d;font-family:dashicons}#wpadminbar #wp-admin-bar-jetpack-idc .dashicons:before{font-size:16px}#wpadminbar #wp-admin-bar-jetpack-idc:hover .ab-item{background:inherit}#wpadminbar #wp-admin-bar-jetpack-idc:hover .jp-idc-admin-bar{background:#eee} .wpcnt{text-align:center;line-height:2}.wpa{position:relative;overflow:hidden;display:inline-block;max-width:100%}.wpa-about{position:absolute;top:5px;right:0;left:0;display:block;margin-top:0;color:#888;font:10px/1 "Open Sans",Arial,sans-serif!important;text-align:right!important;text-decoration:none!important;opacity:.85;border-bottom:none!important;box-shadow:none!important}.wpa .u>div{display:block;margin-top:5px;margin-bottom:1em}div.wpa>div{margin-top:20px}.wpa .u .adsbygoogle{display:block;margin-top:17px;margin-bottom:1em;background-color:transparent} \ No newline at end of file diff --git a/plugins/jetpack/css/jetpack.css b/plugins/jetpack/css/jetpack.css index 02408480..a56d0e35 100644 --- a/plugins/jetpack/css/jetpack.css +++ b/plugins/jetpack/css/jetpack.css @@ -22,4 +22,7 @@ div[class^=gr_custom_container]{border:1px solid gray;border-radius:10px;padding .jetpack-image-container:after{clear:both}.jetpack-image-container:after,.jetpack-image-container:before{display:table;content:""} .widgets-multi-column-grid ul{overflow:hidden;padding:0;margin:0;list-style-type:none}.widgets-multi-column-grid ul li{background:0 0;clear:none;float:left;margin:0 -5px -3px 0;padding:0 8px 6px 0;border:none;list-style-type:none!important}.widgets-multi-column-grid ul li a{background:0 0;margin:0;padding:0;border:0}.widgets-multi-column-grid .avatar{vertical-align:middle}.widget_jetpack_my_community .avatar-240,.widget_jetpack_my_community .avatar-48{max-width:48px;max-height:48px} .widget.widget_authors li>ul,.widget_authors>ul{margin-left:inherit;padding-left:0}.widget_authors ul li li{padding-left:0}.widget_authors>ul>li{margin-bottom:1em;list-style:none}.widget_authors>ul>li+li{border-top:0}.widget.widget_authors img{margin-right:5px;margin-bottom:5px;vertical-align:middle;box-shadow:none} +/*! +* Do not modify this file directly. It is compiled SASS code. +*/#wp-admin-bar-jetpack-idc.hide{display:none}#wp-admin-bar-jetpack-idc .jp-idc-admin-bar{background:#fff;border-radius:2px;color:#23282d;padding:4px 8px;font-size:12px}#wpadminbar #wp-admin-bar-jetpack-idc .dashicons{color:#23282d;font-family:dashicons}#wpadminbar #wp-admin-bar-jetpack-idc .dashicons:before{font-size:16px}#wpadminbar #wp-admin-bar-jetpack-idc:hover .ab-item{background:inherit}#wpadminbar #wp-admin-bar-jetpack-idc:hover .jp-idc-admin-bar{background:#eee} .wpcnt{text-align:center;line-height:2}.wpa{position:relative;overflow:hidden;display:inline-block;max-width:100%}.wpa-about{position:absolute;top:5px;left:0;right:0;display:block;margin-top:0;color:#888;font:10px/1 "Open Sans",Arial,sans-serif!important;text-align:left!important;text-decoration:none!important;opacity:.85;border-bottom:none!important;box-shadow:none!important}.wpa .u>div{display:block;margin-top:5px;margin-bottom:1em}div.wpa>div{margin-top:20px}.wpa .u .adsbygoogle{display:block;margin-top:17px;margin-bottom:1em;background-color:transparent} \ No newline at end of file diff --git a/plugins/jetpack/jetpack.php b/plugins/jetpack/jetpack.php index 71df606b..79109e01 100644 --- a/plugins/jetpack/jetpack.php +++ b/plugins/jetpack/jetpack.php @@ -5,7 +5,7 @@ * Plugin URI: http://jetpack.com * Description: Bring the power of the WordPress.com cloud to your self-hosted WordPress. Jetpack enables you to connect your blog to a WordPress.com account to use the powerful features normally only available to WordPress.com users. * Author: Automattic - * Version: 4.7 + * Version: 4.7.1 * Author URI: http://jetpack.com * License: GPL2+ * Text Domain: jetpack @@ -14,7 +14,7 @@ define( 'JETPACK__MINIMUM_WP_VERSION', '4.6' ); -define( 'JETPACK__VERSION', '4.7' ); +define( 'JETPACK__VERSION', '4.7.1' ); define( 'JETPACK_MASTER_USER', true ); define( 'JETPACK__API_VERSION', 1 ); define( 'JETPACK__PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.js b/plugins/jetpack/modules/carousel/jetpack-carousel.js index b32cc843..dbb83150 100644 --- a/plugins/jetpack/modules/carousel/jetpack-carousel.js +++ b/plugins/jetpack/modules/carousel/jetpack-carousel.js @@ -445,6 +445,11 @@ jQuery(document).ready(function($) { return; } + // skip if the container is not a link + if ( 'undefined' === typeof( $( container ).attr( 'href' ) ) ) { + return; + } + var valid = false; // if link points to 'Media File' (ignoring GET parameters) and flag is set allow it diff --git a/plugins/jetpack/modules/markdown.php b/plugins/jetpack/modules/markdown.php index b173ffb1..e572eff3 100644 --- a/plugins/jetpack/modules/markdown.php +++ b/plugins/jetpack/modules/markdown.php @@ -13,3 +13,17 @@ */ include dirname( __FILE__ ) . '/markdown/easy-markdown.php'; + +/** + * Remove checkbox set in modules/markdown/easy-markdown.php. + * We don't just remove the register_setting call there because the checkbox is + * needed on WordPress.com, where the file is sync'ed verbatim. + */ +function jetpack_markdown_posting_always_on() { + // why oh why isn't there a remove_settings_field? + global $wp_settings_fields; + if ( isset( $wp_settings_fields['writing']['default'][ WPCom_Markdown::POST_OPTION ] ) ) { + unset( $wp_settings_fields['writing']['default'][ WPCom_Markdown::POST_OPTION ] ); + } +} +add_action( 'admin_init', 'jetpack_markdown_posting_always_on', 11 ); diff --git a/plugins/jetpack/modules/sharedaddy/sharing-service.php b/plugins/jetpack/modules/sharedaddy/sharing-service.php index f89d8592..a3a3e6d8 100644 --- a/plugins/jetpack/modules/sharedaddy/sharing-service.php +++ b/plugins/jetpack/modules/sharedaddy/sharing-service.php @@ -548,9 +548,6 @@ function sharing_add_footer() { ); wp_localize_script( 'sharing-js', 'sharing_js_options', $sharing_js_options); } -} - -function sharing_add_footer_scripts_inline() { $sharer = new Sharing_Service(); $enabled = $sharer->get_blog_services(); foreach ( array_merge( $enabled['visible'], $enabled['hidden'] ) AS $service ) { @@ -779,9 +776,6 @@ function sharing_display( $text = '', $echo = false ) { // Enqueue scripts for the footer add_action( 'wp_footer', 'sharing_add_footer' ); - - // Print inline scripts that depend on jQuery - add_action( 'wp_footer', 'sharing_add_footer_scripts_inline', 25 ); } } diff --git a/plugins/jetpack/modules/sso.php b/plugins/jetpack/modules/sso.php index 43134477..578e7538 100644 --- a/plugins/jetpack/modules/sso.php +++ b/plugins/jetpack/modules/sso.php @@ -31,8 +31,8 @@ class Jetpack_SSO { add_action( 'init', array( $this, 'maybe_logout_user' ), 5 ); add_action( 'jetpack_modules_loaded', array( $this, 'module_configure_button' ) ); add_action( 'login_form_logout', array( $this, 'store_wpcom_profile_cookies_on_logout' ) ); - add_action( 'wp_login', array( 'Jetpack_SSO', 'clear_wpcom_profile_cookies' ) ); add_action( 'jetpack_unlinked_user', array( $this, 'delete_connection_for_user') ); + add_action( 'wp_login', array( 'Jetpack_SSO', 'clear_cookies_after_login' ) ); // Adding this action so that on login_init, the action won't be sanitized out of the $action global. add_action( 'login_form_jetpack-sso', '__return_true' ); @@ -554,6 +554,44 @@ class Jetpack_SSO { } } + /** + * Clear cookies that are no longer needed once the user has logged in. + * + * @since 4.8.0 + */ + static function clear_cookies_after_login() { + self::clear_wpcom_profile_cookies(); + if ( isset( $_COOKIE[ 'jetpack_sso_nonce' ] ) ) { + setcookie( + 'jetpack_sso_nonce', + ' ', + time() - YEAR_IN_SECONDS, + COOKIEPATH, + COOKIE_DOMAIN + ); + } + + if ( isset( $_COOKIE[ 'jetpack_sso_original_request' ] ) ) { + setcookie( + 'jetpack_sso_original_request', + ' ', + time() - YEAR_IN_SECONDS, + COOKIEPATH, + COOKIE_DOMAIN + ); + } + + if ( isset( $_COOKIE[ 'jetpack_sso_redirect_to' ] ) ) { + setcookie( + 'jetpack_sso_redirect_to', + ' ', + time() - YEAR_IN_SECONDS, + COOKIEPATH, + COOKIE_DOMAIN + ); + } + } + static function delete_connection_for_user( $user_id ) { if ( ! $wpcom_user_id = get_user_meta( $user_id, 'wpcom_user_id', true ) ) { return; @@ -577,17 +615,33 @@ class Jetpack_SSO { } static function request_initial_nonce() { - Jetpack::load_xml_rpc_client(); - $xml = new Jetpack_IXR_Client( array( - 'user_id' => get_current_user_id(), - ) ); - $xml->query( 'jetpack.sso.requestNonce' ); + $nonce = ! empty( $_COOKIE[ 'jetpack_sso_nonce' ] ) + ? $_COOKIE[ 'jetpack_sso_nonce' ] + : false; - if ( $xml->isError() ) { - return new WP_Error( $xml->getErrorCode(), $xml->getErrorMessage() ); + if ( ! $nonce ) { + Jetpack::load_xml_rpc_client(); + $xml = new Jetpack_IXR_Client( array( + 'user_id' => get_current_user_id(), + ) ); + $xml->query( 'jetpack.sso.requestNonce' ); + + if ( $xml->isError() ) { + return new WP_Error( $xml->getErrorCode(), $xml->getErrorMessage() ); + } + + $nonce = $xml->getResponse(); + + setcookie( + 'jetpack_sso_nonce', + $nonce, + time() + ( 10 * MINUTE_IN_SECONDS ), + COOKIEPATH, + COOKIE_DOMAIN + ); } - return $xml->getResponse(); + return sanitize_key( $nonce ); } /** @@ -727,8 +781,6 @@ class Jetpack_SSO { if ( ! empty( $_COOKIE['jetpack_sso_redirect_to'] ) ) { // Set that as the requested redirect to $redirect_to = $_request_redirect_to = esc_url_raw( $_COOKIE['jetpack_sso_redirect_to'] ); - // And then purge it - setcookie( 'jetpack_sso_redirect_to', ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); } $json_api_auth_environment = Jetpack_SSO_Helpers::get_json_api_auth_environment(); diff --git a/plugins/jetpack/modules/videopress/class.videopress-xmlrpc.php b/plugins/jetpack/modules/videopress/class.videopress-xmlrpc.php index 72e88c8f..6537b438 100644 --- a/plugins/jetpack/modules/videopress/class.videopress-xmlrpc.php +++ b/plugins/jetpack/modules/videopress/class.videopress-xmlrpc.php @@ -155,18 +155,21 @@ class VideoPress_XMLRPC { return false; } + // We add ssl => 1 to make sure that the videos.files.wordpress.com domain is parsed as photon. + $poster = apply_filters( 'jetpack_photon_url', $poster, array( 'ssl' => 1 ), 'https' ); + + $meta = wp_get_attachment_metadata( $post_id ); + $meta['videopress']['poster'] = $poster; + wp_update_attachment_metadata( $post_id, $meta ); + // Update the poster in the VideoPress info. $thumbnail_id = videopress_download_poster_image( $poster, $post_id ); - if ( !is_int( $thumbnail_id ) ) { + if ( ! is_int( $thumbnail_id ) ) { return false; } update_post_meta( $post_id, '_thumbnail_id', $thumbnail_id ); - $meta = wp_get_attachment_metadata( $post_id ); - - $meta['videopress']['poster'] = $poster; - wp_update_attachment_metadata( $post_id, $meta ); return true; } diff --git a/plugins/jetpack/modules/videopress/utility-functions.php b/plugins/jetpack/modules/videopress/utility-functions.php index c6903165..e9f597a5 100644 --- a/plugins/jetpack/modules/videopress/utility-functions.php +++ b/plugins/jetpack/modules/videopress/utility-functions.php @@ -558,17 +558,22 @@ function videopress_make_media_upload_path( $blog_id ) { function video_get_info_by_blogpostid( $blog_id, $post_id ) { $post = get_post( $post_id ); + $video_info = new stdClass(); + $video_info->post_id = $post_id; + $video_info->blog_id = $blog_id; + $video_info->guid = null; + $video_info->finish_date_gmt = '0000-00-00 00:00:00'; + if ( is_wp_error( $post ) ) { - return false; + return $video_info; } if ( 'video/videopress' !== $post->post_mime_type ) { - return false; + return $video_info; } - $video_info = new stdClass(); + // Since this is a VideoPress post, lt's fill out the rest of the object. $video_info->guid = get_post_meta( $post_id, 'videopress_guid', true ); - $video_info->finish_date_gmt = '0000-00-00 00:00:00'; if ( videopress_is_finished_processing( $post_id ) ) { $video_info->finish_date_gmt = date( 'Y-m-d H:i:s' ); @@ -576,3 +581,118 @@ function video_get_info_by_blogpostid( $blog_id, $post_id ) { return $video_info; } + + +/** + * Check that a VideoPress video format has finished processing. + * + * This uses the info object, because that is what the WPCOM endpoint + * uses, however we don't have a complete info object in the same way + * WPCOM does, so we pull the meta information out of the post + * options instead. + * + * Note: This mimics the WPCOM function of the same name and helps the media + * API endpoint add all needed VideoPress data. + * + * @param stdClass $info + * @param string $format + * @return bool + */ +function video_format_done( $info, $format ) { + + // Avoids notice when a non-videopress item is found. + if ( ! is_object( $info ) ) { + return false; + } + + $post_id = $info->post_id; + + if ( get_post_mime_type( $post_id ) !== 'video/videopress' ) { + return false; + } + + $post = get_post( $post_id ); + + if ( is_wp_error( $post ) ) { + return false; + } + + $meta = wp_get_attachment_metadata( $post->ID ); + + switch ( $format ) { + case 'fmt_hd': + return isset( $meta['videopress']['files']['hd']['mp4'] ); + break; + + case 'fmt_dvd': + return isset( $meta['videopress']['files']['dvd']['mp4'] ); + break; + + case 'fmt_std': + return isset( $meta['videopress']['files']['std']['mp4'] ); + break; + + case 'fmt_ogg': + return isset( $meta['videopress']['files']['std']['ogg'] ); + break; + } + + return false; +} + +/** + * Get the image URL for the given VideoPress GUID + * + * We look up by GUID, because that is what WPCOM does and this needs to be + * parameter compatible with that. + * + * Note: This mimics the WPCOM function of the same name and helps the media + * API endpoint add all needed VideoPress data. + * + * @param string $guid + * @param string $format + * @return string + */ +function video_image_url_by_guid( $guid, $format ) { + + $post = video_get_post_by_guid( $guid ); + + if ( is_wp_error( $post ) ) { + return null; + } + + $meta = wp_get_attachment_metadata( $post->ID ); + + // We add ssl => 1 to make sure that the videos.files.wordpress.com domain is parsed as photon. + $poster = apply_filters( 'jetpack_photon_url', $meta['videopress']['poster'], array( 'ssl' => 1 ), 'https' ); + + return $poster; +} + +/** + * Using a GUID, find a post. + * + * @param string $guid + * @return WP_Post + */ +function video_get_post_by_guid( $guid ) { + $args = array( + 'post_type' => 'attachment', + 'post_mime_type' => 'video/videopress', + 'post_status' => 'inherit', + 'meta_query' => array( + array( + 'key' => 'videopress_guid', + 'value' => $guid, + 'compare' => '=', + ) + ) + ); + + $query = new WP_Query( $args ); + + $post = $query->next_post(); + + return $post; +} + diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions.php b/plugins/jetpack/modules/widget-visibility/widget-conditions.php index 9f65b08d..f2492c4c 100644 --- a/plugins/jetpack/modules/widget-visibility/widget-conditions.php +++ b/plugins/jetpack/modules/widget-visibility/widget-conditions.php @@ -91,13 +91,17 @@ class Jetpack_Widget_Conditions { $post_types = get_post_types( array( 'public' => true ), 'objects' ); $widget_conditions_post_types = array(); + $widget_conditions_post_type_archives = array(); foreach ( $post_types as $post_type ) { $widget_conditions_post_types[] = array( 'post_type-' . $post_type->name, $post_type->labels->singular_name ); + $widget_conditions_post_type_archives[] = array( 'post_type_archive-' . $post_type->name, $post_type->labels->name ); } $widget_conditions_data['page'][] = array( __( 'Post type:', 'jetpack' ), $widget_conditions_post_types ); + $widget_conditions_data['page'][] = array( __( 'Post type Archives:', 'jetpack' ), $widget_conditions_post_type_archives ); + $pages_dropdown = preg_replace( '/<\/?select[^>]*?>/i', '', wp_dropdown_pages( array( 'echo' => false ) ) ); preg_match_all( '/value=.([0-9]+).[^>]*>([^<]+)is_posts_page; @@ -690,6 +696,76 @@ class Jetpack_Widget_Conditions { return $term_id; } + + /** + * Upgrade routine to go through all widgets and move the Post Type + * setting to its newer location. + * + * @since 4.7.1 + * + */ + static function migrate_post_type_rules() { + global $wp_registered_widgets; + + $sidebars_widgets = get_option( 'sidebars_widgets' ); + + // Going through all sidebars and through inactive and orphaned widgets + foreach ( $sidebars_widgets as $s => $sidebar ) { + if ( ! is_array( $sidebar ) ) { + continue; + } + + foreach ( $sidebar as $w => $widget ) { + // $widget is the id of the widget + if ( empty( $wp_registered_widgets[ $widget ] ) ) { + continue; + } + + $opts = $wp_registered_widgets[ $widget ]; + $instances = get_option( $opts['callback'][0]->option_name ); + + // Going through each instance of the widget + foreach( $instances as $number => $instance ) { + if ( + ! is_array( $instance ) || + empty( $instance['conditions'] ) || + empty( $instance['conditions']['rules'] ) + ) { + continue; + } + + // Going through all visibility rules + foreach( $instance['conditions']['rules'] as $index => $rule ) { + + // We only need Post Type rules + if ( 'post_type' !== $rule['major'] ) { + continue; + } + + $rule_type = false; + + // Post type or type archive rule + if ( 0 === strpos( $rule['minor'], 'post_type_archive' ) ) { + $rule_type = 'post_type_archive'; + } else if ( 0 === strpos( $rule['minor'], 'post_type' ) ) { + $rule_type = 'post_type'; + } + + if ( $rule_type ) { + $post_type = substr( $rule['minor'], strlen( $rule_type ) + 1 ); + $rule['minor'] = $rule_type . '-' . $post_type; + $rule['major'] = 'page'; + + $instances[ $number ]['conditions']['rules'][ $index ] = $rule; + } + } + } + + update_option( $opts['callback'][0]->option_name, $instances ); + } + } + } + } add_action( 'init', array( 'Jetpack_Widget_Conditions', 'init' ) ); diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions/rtl/widget-conditions-rtl.css b/plugins/jetpack/modules/widget-visibility/widget-conditions/rtl/widget-conditions-rtl.css index 94cf4502..d2770de6 100644 --- a/plugins/jetpack/modules/widget-visibility/widget-conditions/rtl/widget-conditions-rtl.css +++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/rtl/widget-conditions-rtl.css @@ -1,10 +1,7 @@ -/* This file was automatically generated on Jul 14 2014 00:47:30 */ - +/* Do not modify this file directly. It is concatenated from individual module CSS files. */ .wp-customizer .expanded .widget-conditional .widget-conditional-inner { - width: 98%; - -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ - -moz-box-sizing: border-box; /* Firefox, other Gecko */ - box-sizing: border-box; + width: 98%; /* Safari/Chrome, other WebKit */ /* Firefox, other Gecko */ + box-sizing: border-box; } .wp-customizer .expanded .widget-conditional .form{ @@ -35,9 +32,12 @@ } .widget-conditional .condition { padding-top: 12px; + position: relative; } .widget-conditional .condition select { width: 120px; + position: relative; + z-index: 2; } .widget-conditional .condition-top select { width: auto; @@ -48,22 +48,51 @@ margin-top: -20px; } .widget-conditional .selection { - margin-left: 70px; + margin-left: 50px; + margin-right: 20px; +} +.widget-conditional .conditions-rule-has-children { + display: block; } .widget-conditional .condition .actions { margin-top: -28px; +}.widget-conditional .condition .actions { + margin-top: -28px; } .widget-conditional .condition-control a { text-decoration: none; + position: absolute; + top: 17px; + text-indent: -9999px; + z-index: 1; +} +.widget-conditional .condition-control a:before { + position: absolute; + text-indent: 0; + right: 0; } -.widget-conditional .condition:last-child .condition-conjunction { +.widget-conditional .condition-control .delete-condition { + right: 0; + color: #f11; +} +.widget-conditional .condition-control .add-condition { + left: 0; +} + +.widget-conditional .condition:last-child .condition-conjunction, +.widget-conditional .condition:last-child .condition-intersection { display: none; } -.widget-control-actions .alignright { - text-align: left; - color:#999; + +.widget-conditional.conjunction .condition-intersection { + display: none; +} + +.widget-conditional.intersection .condition-conjunction { + display: none; } + .wp-core-ui .button.display-options { margin-left: 5px; } @@ -76,3 +105,11 @@ max-width: none; height: auto; } +.wp-customizer .widget-conditional .condition-control a { + top: 15px; +} +@media screen and ( max-width: 782px ) { + .widget-conditional .condition-control a { + top: 20px; + } +} 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 9217e67a..658c4270 100644 --- a/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.js +++ b/plugins/jetpack/modules/widget-visibility/widget-conditions/widget-conditions.js @@ -200,7 +200,10 @@ jQuery( function( $ ) { select = condition.find( '.conditions-rule-minor' ).html( '' ), major = condition.data( 'rule-major' ); - if ( ! major ) { + // Disable the select, if major rule is empty or if it's a `post_type`. + // "Post Type" rule has been removed in Jetpack 4.7, and + // because it breaks all other rules we should `return`. + if ( ! major || 'post_type' === major ) { select.attr( 'disabled', 'disabled' ); return; } diff --git a/plugins/jetpack/modules/widgets/image-widget.php b/plugins/jetpack/modules/widgets/image-widget.php index 82039e7d..10ba8ccd 100644 --- a/plugins/jetpack/modules/widgets/image-widget.php +++ b/plugins/jetpack/modules/widgets/image-widget.php @@ -69,14 +69,7 @@ class Jetpack_Image_Widget extends WP_Widget { if ( '' != $instance['img_url'] ) { - $image_url = Jetpack::is_module_active( 'photon' ) - ? jetpack_photon_url( $instance['img_url'], array( - 'w' => $instance['img_width'], - 'h' => $instance['img_height'], - ) ) - : $instance['img_url']; - - $output = '