diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2017-09-20 09:54:07 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2017-09-20 09:54:07 -0400 |
commit | bb31fa2d44dbbe425fa9ce92d4e7be61a1146dfb (patch) | |
tree | 33456f5889d315ad2a520fcd33fe491e612588b4 /plugins/jetpack/modules | |
parent | akismet 4.0 (diff) | |
download | blogs-gentoo-bb31fa2d44dbbe425fa9ce92d4e7be61a1146dfb.tar.gz blogs-gentoo-bb31fa2d44dbbe425fa9ce92d4e7be61a1146dfb.tar.bz2 blogs-gentoo-bb31fa2d44dbbe425fa9ce92d4e7be61a1146dfb.zip |
jetpack 5.3
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules')
74 files changed, 1425 insertions, 1690 deletions
diff --git a/plugins/jetpack/modules/after-the-deadline.php b/plugins/jetpack/modules/after-the-deadline.php index 2b7f7013..47af703f 100644 --- a/plugins/jetpack/modules/after-the-deadline.php +++ b/plugins/jetpack/modules/after-the-deadline.php @@ -274,11 +274,8 @@ function AtD_is_allowed() { function AtD_load_css() { if ( AtD_should_load_on_page() ) { - if( is_rtl() ) { - wp_enqueue_style( 'AtD_style', plugins_url( '/after-the-deadline/rtl/atd-rtl.css', __FILE__ ), null, ATD_VERSION, 'screen' ); - } else { - wp_enqueue_style( 'AtD_style', plugins_url( '/after-the-deadline/atd.css', __FILE__ ), null, ATD_VERSION, 'screen' ); - } + wp_enqueue_style( 'AtD_style', plugins_url( '/after-the-deadline/atd.css', __FILE__ ), null, ATD_VERSION, 'screen' ); + wp_style_add_data( 'AtD_style', 'rtl', 'replace' ); } } diff --git a/plugins/jetpack/modules/carousel/jetpack-carousel.php b/plugins/jetpack/modules/carousel/jetpack-carousel.php index 012b934c..58613f61 100644 --- a/plugins/jetpack/modules/carousel/jetpack-carousel.php +++ b/plugins/jetpack/modules/carousel/jetpack-carousel.php @@ -300,11 +300,8 @@ class Jetpack_Carousel { */ $localize_strings = apply_filters( 'jp_carousel_localize_strings', $localize_strings ); wp_localize_script( 'jetpack-carousel', 'jetpackCarouselStrings', $localize_strings ); - if( is_rtl() ) { - wp_enqueue_style( 'jetpack-carousel', plugins_url( '/rtl/jetpack-carousel-rtl.css', __FILE__ ), array(), $this->asset_version( '20120629' ) ); - } else { - wp_enqueue_style( 'jetpack-carousel', plugins_url( 'jetpack-carousel.css', __FILE__ ), array(), $this->asset_version( '20120629' ) ); - } + wp_enqueue_style( 'jetpack-carousel', plugins_url( 'jetpack-carousel.css', __FILE__ ), array(), $this->asset_version( '20120629' ) ); + wp_style_add_data( 'jetpack-carousel', 'rtl', 'replace' ); wp_register_style( 'jetpack-carousel-ie8fix', plugins_url( 'jetpack-carousel-ie8fix.css', __FILE__ ), array(), $this->asset_version( '20121024' ) ); $GLOBALS['wp_styles']->add_data( 'jetpack-carousel-ie8fix', 'conditional', 'lte IE 8' ); @@ -412,7 +409,6 @@ class Jetpack_Carousel { $attachment = get_post( $attachment_id ); $attachment_title = wptexturize( $attachment->post_title ); $attachment_desc = wpautop( wptexturize( $attachment->post_content ) ); - // Not yet providing geo-data, need to "fuzzify" for privacy if ( ! empty( $img_meta ) ) { foreach ( $img_meta as $k => $v ) { @@ -434,8 +430,8 @@ class Jetpack_Carousel { $attr['data-orig-size'] = $size; $attr['data-comments-opened'] = $comments_opened; $attr['data-image-meta'] = esc_attr( $img_meta ); - $attr['data-image-title'] = esc_attr( $attachment_title ); - $attr['data-image-description'] = esc_attr( $attachment_desc ); + $attr['data-image-title'] = esc_attr( htmlspecialchars( $attachment_title ) ); + $attr['data-image-description'] = esc_attr( htmlspecialchars( $attachment_desc ) ); $attr['data-medium-file'] = esc_attr( $medium_file ); $attr['data-large-file'] = esc_attr( $large_file ); diff --git a/plugins/jetpack/modules/comments/comments.php b/plugins/jetpack/modules/comments/comments.php index 1f17ec80..7465159b 100644 --- a/plugins/jetpack/modules/comments/comments.php +++ b/plugins/jetpack/modules/comments/comments.php @@ -161,7 +161,7 @@ class Jetpack_Comments extends Highlander_Comments_Base { } // Return the FB or Twitter avatar - return preg_replace( '#src=([\'"])[^\'"]+\\1#', 'src=\\1' . esc_url( $this->photon_avatar( $foreign_avatar, $size ) ) . '\\1', $avatar ); + return preg_replace( '#src=([\'"])[^\'"]+\\1#', 'src=\\1' . esc_url( set_url_scheme( $this->photon_avatar( $foreign_avatar, $size ), 'https' ) ) . '\\1', $avatar ); } /** Output Methods ********************************************************/ diff --git a/plugins/jetpack/modules/contact-form/admin.php b/plugins/jetpack/modules/contact-form/admin.php index 062a2c72..834c95c1 100644 --- a/plugins/jetpack/modules/contact-form/admin.php +++ b/plugins/jetpack/modules/contact-form/admin.php @@ -37,7 +37,7 @@ function grunion_admin_css() { if ( is_null( $current_screen ) ) { return; } - if ( ! in_array( $current_screen->id, array( 'edit-feedback', 'jetpack_page_omnisearch', 'dashboard_page_omnisearch' ) ) ) { + if ( 'edit-feedback' !== $current_screen->id ) { return; } @@ -771,15 +771,6 @@ function grunion_ajax_spam() { exit; } -add_action( 'omnisearch_add_providers', 'grunion_omnisearch_add_providers' ); -function grunion_omnisearch_add_providers() { - // Feedback uses capability_type 'page' - if ( current_user_can( 'edit_pages' ) ) { - require_once( GRUNION_PLUGIN_DIR . 'grunion-omnisearch.php' ); - new Jetpack_Omnisearch_Grunion; - } -} - /** * Add the scripts that will add the "Check for Spam" button to the Feedbacks dashboard page. */ diff --git a/plugins/jetpack/modules/contact-form/grunion-contact-form.php b/plugins/jetpack/modules/contact-form/grunion-contact-form.php index c7ff0f71..3e33b4b6 100644 --- a/plugins/jetpack/modules/contact-form/grunion-contact-form.php +++ b/plugins/jetpack/modules/contact-form/grunion-contact-form.php @@ -186,11 +186,8 @@ class Grunion_Contact_Form_Plugin { * } * add_action('wp_print_styles', 'remove_grunion_style'); */ - if ( is_rtl() ) { - wp_register_style( 'grunion.css', GRUNION_PLUGIN_URL . 'css/rtl/grunion-rtl.css', array(), JETPACK__VERSION ); - } else { - wp_register_style( 'grunion.css', GRUNION_PLUGIN_URL . 'css/grunion.css', array(), JETPACK__VERSION ); - } + wp_register_style( 'grunion.css', GRUNION_PLUGIN_URL . 'css/grunion.css', array(), JETPACK__VERSION ); + wp_style_add_data( 'grunion.css', 'rtl', 'replace' ); } /** @@ -1506,7 +1503,7 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode { } /** - * Filter the message returned after a successfull contact form submission. + * Filter the message returned after a successful contact form submission. * * @module contact-form * @@ -2133,7 +2130,7 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode { $message = join( $message, '' ); /** - * Filters the message sent via email after a successfull form submission. + * Filters the message sent via email after a successful form submission. * * @module contact-form * @@ -2170,7 +2167,7 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode { if ( $is_spam !== true && /** - * Filter to choose whether an email should be sent after each successfull contact form submission. + * Filter to choose whether an email should be sent after each successful contact form submission. * * @module contact-form * @@ -2267,7 +2264,8 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode { function add_name_to_address( $address ) { // If it's just the address, without a display name if ( is_email( $address ) ) { - $address = sprintf( '"%s" <%s>', $address, $address ); + $address_parts = explode( '@', $address ); + $address = sprintf( '"%s" <%s>', $address_parts[0], $address ); } return $address; diff --git a/plugins/jetpack/modules/contact-form/grunion-editor-view.php b/plugins/jetpack/modules/contact-form/grunion-editor-view.php index e6299d06..ce1946f8 100644 --- a/plugins/jetpack/modules/contact-form/grunion-editor-view.php +++ b/plugins/jetpack/modules/contact-form/grunion-editor-view.php @@ -8,11 +8,17 @@ */ class Grunion_Editor_View { - public static function add_hooks() { - add_action( 'admin_notices', array( __CLASS__, 'handle_editor_view_js' ) ); - add_filter( 'mce_external_plugins', array( __CLASS__, 'mce_external_plugins' ) ); - add_filter( 'mce_buttons', array( __CLASS__, 'mce_buttons' ) ); - add_action( 'admin_head', array( __CLASS__, 'admin_head' ) ); + + /** + * Add hooks according to screen. + * + * @param WP_Screen $screen Data about current screen. + */ + public static function add_hooks( $screen ) { + if ( isset( $screen->base ) && 'post' === $screen->base ) { + add_action( 'admin_notices', array( __CLASS__, 'handle_editor_view_js' ) ); + add_action( 'admin_head', array( __CLASS__, 'admin_head' ) ); + } } public static function admin_head() { @@ -21,9 +27,6 @@ class Grunion_Editor_View { } public static function grunion_media_button() { - if ( empty( $GLOBALS['pagenow'] ) || 'press-this.php' === $GLOBALS['pagenow'] ) { - return; - } $title = __( 'Add Contact Form', 'jetpack' ); ?> @@ -55,12 +58,9 @@ class Grunion_Editor_View { * WordPress Shortcode Editor View JS Code */ public static function handle_editor_view_js() { - $current_screen = get_current_screen(); - if ( ! isset( $current_screen->id ) || $current_screen->base !== 'post' ) { - return; - } - add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_view_js_templates' ), 1 ); + add_filter( 'mce_external_plugins', array( __CLASS__, 'mce_external_plugins' ) ); + add_filter( 'mce_buttons', array( __CLASS__, 'mce_buttons' ) ); wp_enqueue_style( 'grunion-editor-ui', plugins_url( 'css/editor-ui.css', __FILE__ ) ); wp_style_add_data( 'grunion-editor-ui', 'rtl', 'replace' ); @@ -274,5 +274,4 @@ class Grunion_Editor_View { } } - -Grunion_Editor_View::add_hooks(); +add_action( 'current_screen', array( 'Grunion_Editor_View', 'add_hooks' ) ); diff --git a/plugins/jetpack/modules/contact-form/grunion-omnisearch.php b/plugins/jetpack/modules/contact-form/grunion-omnisearch.php deleted file mode 100644 index 3f0a4133..00000000 --- a/plugins/jetpack/modules/contact-form/grunion-omnisearch.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php - -if( ! class_exists( 'WP_List_Table' ) ) - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); - -class Jetpack_Omnisearch_Grunion extends WP_List_Table { - static $instance; - public $post_type = 'feedback'; - - function __construct() { - self::$instance = $this; - add_filter( 'omnisearch_results', array( $this, 'search'), 12, 2 ); - - // Push 'post_type_obj' to accepted fields for WP_List_Table (since WP 4.2) - global $wp_version; - if ( version_compare( $wp_version, '4.2-z', '>=' ) && $this->compat_fields && is_array( $this->compat_fields ) ) { - array_push( $this->compat_fields, 'post_type_obj' ); - } - } - - function search( $results, $search_term ) { - parent::__construct(); - - $this->post_type_obj = get_post_type_object( $this->post_type ); - - $search_url = esc_url( admin_url( sprintf( 'edit.php?post_type=%s&s=%s', urlencode( $this->post_type_obj->name ), urlencode( $search_term ) ) ) ); - $search_link = sprintf( ' <a href="%s" class="add-new-h2">%s</a>', $search_url, esc_html( $this->post_type_obj->labels->search_items ) ); - $html = '<h2>' . esc_html( $this->post_type_obj->labels->name ) . $search_link .'</h2>'; - - $this->prepare_items( $search_term ); - - ob_start(); - $this->display(); - $html .= ob_get_clean(); - - $results[ $this->post_type_obj->labels->name ] = $html; - return $results; - } - - function get_columns() { - $columns = array( - 'feedback_from' => __('From', 'jetpack'), - 'feedback_message' => __('Message', 'jetpack'), - 'feedback_date' => __('Date', 'jetpack'), - ); - return $columns; - } - - function prepare_items( $search_term = '' ) { - $this->_column_headers = array( $this->get_columns(), array(), array() ); - /** This action is documented in modules/omnisearch/omnisearch-core.php */ - $num_results = apply_filters( 'omnisearch_num_results', 5 ); - $this->items = get_posts( array( - 's' => $search_term, - 'post_type' => $this->post_type, - 'posts_per_page' => $num_results, - ) ); - } - - function column_default( $post, $column_name ) { - // Make sure the global $post is our post. - $_post = $GLOBALS['post']; - $GLOBALS['post'] = $post; - setup_postdata( $post ); - - switch ( $column_name ) { - case 'feedback_from': - case 'feedback_message': - case 'feedback_date': - ob_start(); - grunion_manage_post_columns( $column_name, $post->ID ); - $column_contents = ob_get_clean(); - break; - default: - $column_contents = '<pre>' . print_r( $post, true ) . '</pre>'; - break; - } - - $GLOBALS['post'] = $_post; - wp_reset_postdata(); - return $column_contents; - } -} diff --git a/plugins/jetpack/modules/custom-css/custom-css-4.7.php b/plugins/jetpack/modules/custom-css/custom-css-4.7.php index 87a38ff6..60feb2dd 100644 --- a/plugins/jetpack/modules/custom-css/custom-css-4.7.php +++ b/plugins/jetpack/modules/custom-css/custom-css-4.7.php @@ -137,6 +137,7 @@ class Jetpack_Custom_CSS_Enhancements { wp_safe_redirect( self::customizer_link( array( 'return_url' => wp_get_referer(), ) ) ); + exit; } /** diff --git a/plugins/jetpack/modules/custom-post-types/comics.php b/plugins/jetpack/modules/custom-post-types/comics.php index 59d4982f..a1d8bf78 100644 --- a/plugins/jetpack/modules/custom-post-types/comics.php +++ b/plugins/jetpack/modules/custom-post-types/comics.php @@ -173,11 +173,8 @@ class Jetpack_Comic { } public function register_scripts() { - if( is_rtl() ) { - wp_enqueue_style( 'jetpack-comics-style', plugins_url( 'comics/rtl/comics-rtl.css', __FILE__ ) ); - } else { - wp_enqueue_style( 'jetpack-comics-style', plugins_url( 'comics/comics.css', __FILE__ ) ); - } + wp_enqueue_style( 'jetpack-comics-style', plugins_url( 'comics/comics.css', __FILE__ ) ); + wp_style_add_data( 'jetpack-comics-style', 'rtl', 'replace' ); wp_enqueue_script( 'jetpack-comics', plugins_url( 'comics/comics.js', __FILE__ ), array( 'jquery', 'jquery.spin' ) ); diff --git a/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.css b/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.css new file mode 100644 index 00000000..7662d7e5 --- /dev/null +++ b/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.css @@ -0,0 +1,31 @@ +/* Do not modify this file directly. It is concatenated from individual module CSS files. */ +#jetpack-comic-drop-zone .dragging, #jetpack-comic-drop-zone .uploading { + margin-top: 200px; + display: none; +} + +/* Display the appropriate loading message for each upload state. */ +body.dragging #jetpack-comic-drop-zone .dragging, body.uploading #jetpack-comic-drop-zone .uploading { + display: block; +} + +body.uploading #jetpack-comic-drop-zone .uploading .spinner { + display: inline-block; + width: 60px; +} + +/* Add the drop zone overlay. */ +body.dragging #jetpack-comic-drop-zone, body.uploading #jetpack-comic-drop-zone { + background: rgba( 0, 86, 132, 0.9 ); + border: 1px dashed #fff; + color: #fff; + display: block; + font-size: 30px; + position: fixed; + top: 10px; + right: 10px; + left: 10px; + bottom: 10px; + text-align: center; + z-index: 99999; +}
\ No newline at end of file diff --git a/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.min.css b/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.min.css new file mode 100644 index 00000000..9fa3feae --- /dev/null +++ b/plugins/jetpack/modules/custom-post-types/comics/comics-rtl.min.css @@ -0,0 +1 @@ +#jetpack-comic-drop-zone .dragging,#jetpack-comic-drop-zone .uploading{margin-top:200px;display:none}body.dragging #jetpack-comic-drop-zone .dragging,body.uploading #jetpack-comic-drop-zone .uploading{display:block}body.uploading #jetpack-comic-drop-zone .uploading .spinner{display:inline-block;width:60px}body.dragging #jetpack-comic-drop-zone,body.uploading #jetpack-comic-drop-zone{background:rgba(0,86,132,.9);border:1px dashed #fff;color:#fff;display:block;font-size:30px;position:fixed;top:10px;right:10px;left:10px;bottom:10px;text-align:center;z-index:99999}
\ No newline at end of file diff --git a/plugins/jetpack/modules/custom-post-types/comics/comics.min.css b/plugins/jetpack/modules/custom-post-types/comics/comics.min.css new file mode 100644 index 00000000..2526a81c --- /dev/null +++ b/plugins/jetpack/modules/custom-post-types/comics/comics.min.css @@ -0,0 +1,2 @@ +/* Do not modify this file directly. It is concatenated from individual module CSS files. */ +#jetpack-comic-drop-zone .dragging,#jetpack-comic-drop-zone .uploading{margin-top:200px;display:none}body.dragging #jetpack-comic-drop-zone .dragging,body.uploading #jetpack-comic-drop-zone .uploading{display:block}body.uploading #jetpack-comic-drop-zone .uploading .spinner{display:inline-block;width:60px}body.dragging #jetpack-comic-drop-zone,body.uploading #jetpack-comic-drop-zone{background:rgba(0,86,132,.9);border:1px dashed #fff;color:#fff;display:block;font-size:30px;position:fixed;top:10px;left:10px;right:10px;bottom:10px;text-align:center;z-index:99999}
\ No newline at end of file diff --git a/plugins/jetpack/modules/likes.php b/plugins/jetpack/modules/likes.php index a3e67c45..daf60d00 100644 --- a/plugins/jetpack/modules/likes.php +++ b/plugins/jetpack/modules/likes.php @@ -2,12 +2,13 @@ /** * Module Name: Likes * Module Description: Give visitors an easy way to show they appreciate your content. + * Jumpstart Description: Give visitors an easy way to show they appreciate your content. * First Introduced: 2.2 * Sort Order: 23 * Requires Connection: Yes * Auto Activate: No * Module Tags: Social - * Feature: Engagement + * Feature: Engagement, Jumpstart * Additional Search Queries: like, likes, wordpress.com */ @@ -135,10 +136,7 @@ class Jetpack_Likes { */ function load_styles_register_scripts() { if ( $this->in_jetpack ) { - if ( ! wp_style_is( 'open-sans', 'registered' ) ) { - wp_register_style( 'open-sans', 'https://fonts.googleapis.com/css?family=Open+Sans', array(), JETPACK__VERSION ); - } - wp_enqueue_style( 'jetpack_likes', plugins_url( 'likes/style.css', __FILE__ ), array( 'open-sans' ), JETPACK__VERSION ); + wp_enqueue_style( 'jetpack_likes', plugins_url( 'likes/style.css', __FILE__ ), array(), JETPACK__VERSION ); $this->register_scripts(); } } diff --git a/plugins/jetpack/modules/likes/style.css b/plugins/jetpack/modules/likes/style.css index 3dfb2207..77fc887a 100644 --- a/plugins/jetpack/modules/likes/style.css +++ b/plugins/jetpack/modules/likes/style.css @@ -162,7 +162,7 @@ div.sd-box { height: 18px; position: absolute; display: flex; - font-family: "Open Sans", sans-serif; + font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif; margin-top: 4px; } diff --git a/plugins/jetpack/modules/masterbar/masterbar.php b/plugins/jetpack/modules/masterbar/masterbar.php index 300c7bde..fde17fb6 100644 --- a/plugins/jetpack/modules/masterbar/masterbar.php +++ b/plugins/jetpack/modules/masterbar/masterbar.php @@ -122,7 +122,7 @@ class A8C_WPCOM_Masterbar { } wp_enqueue_script( 'jetpack-accessible-focus', plugins_url( '_inc/accessible-focus.js', JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION ); - wp_enqueue_script( 'a8c_wpcom_masterbar_overrides', $this->wpcom_static_url( '/wp-content/mu-plugins/admin-bar/masterbar-overrides/masterbar.js' ), array(), JETPACK__VERSION ); + wp_enqueue_script( 'a8c_wpcom_masterbar_overrides', $this->wpcom_static_url( '/wp-content/mu-plugins/admin-bar/masterbar-overrides/masterbar.js' ), array( 'jquery' ), JETPACK__VERSION ); } function wpcom_static_url( $file ) { @@ -643,76 +643,89 @@ class A8C_WPCOM_Masterbar { $wp_admin_bar->add_menu( array( 'parent' => 'publish', 'id' => 'publish-header', - 'title' => esc_html_x( 'Publish', 'admin bar menu group label', 'jetpack' ), + 'title' => esc_html_x( 'Manage', 'admin bar menu group label', 'jetpack' ), 'meta' => array( 'class' => 'ab-submenu-header', ), ) ); - // Blog Posts - $posts_title = $this->create_menu_item_pair( + // Pages + $pages_title = $this->create_menu_item_pair( array( - 'url' => 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ), - 'id' => 'wp-admin-bar-edit-post', - 'label' => esc_html__( 'Blog Posts', 'jetpack' ), + 'url' => 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ), + 'id' => 'wp-admin-bar-edit-page', + 'label' => esc_html__( 'Site Pages', 'jetpack' ), ), array( - 'url' => 'https://wordpress.com/post/' . esc_attr( $this->primary_site_slug ), - 'id' => 'wp-admin-bar-new-post', + 'url' => 'https://wordpress.com/page/' . esc_attr( $this->primary_site_slug ), + 'id' => 'wp-admin-bar-new-page', 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ), ) ); - if ( ! current_user_can( 'edit_posts' ) ) { - $posts_title = $this->create_menu_item_anchor( + if ( ! current_user_can( 'edit_pages' ) ) { + $pages_title = $this->create_menu_item_anchor( 'ab-item ab-primary mb-icon', - 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ), - esc_html__( 'Blog Posts', 'jetpack' ), - 'wp-admin-bar-edit-post' + 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ), + esc_html__( 'Site Pages', 'jetpack' ), + 'wp-admin-bar-edit-page' ); } $wp_admin_bar->add_menu( array( 'parent' => 'publish', - 'id' => 'new-post', - 'title' => $posts_title, + 'id' => 'new-page', + 'title' => $pages_title, 'meta' => array( 'class' => 'inline-action', ), ) ); - // Pages - $pages_title = $this->create_menu_item_pair( + // Blog Posts + $posts_title = $this->create_menu_item_pair( array( - 'url' => 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ), - 'id' => 'wp-admin-bar-edit-page', - 'label' => esc_html__( 'Pages', 'jetpack' ), + 'url' => 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ), + 'id' => 'wp-admin-bar-edit-post', + 'label' => esc_html__( 'Blog Posts', 'jetpack' ), ), array( - 'url' => 'https://wordpress.com/page/' . esc_attr( $this->primary_site_slug ), - 'id' => 'wp-admin-bar-new-page', + 'url' => 'https://wordpress.com/post/' . esc_attr( $this->primary_site_slug ), + 'id' => 'wp-admin-bar-new-post', 'label' => esc_html_x( 'Add', 'admin bar menu new item label', 'jetpack' ), ) ); - if ( ! current_user_can( 'edit_pages' ) ) { - $pages_title = $this->create_menu_item_anchor( + if ( ! current_user_can( 'edit_posts' ) ) { + $posts_title = $this->create_menu_item_anchor( 'ab-item ab-primary mb-icon', - 'https://wordpress.com/pages/' . esc_attr( $this->primary_site_slug ), - esc_html__( 'Pages', 'jetpack' ), - 'wp-admin-bar-edit-page' + 'https://wordpress.com/posts/' . esc_attr( $this->primary_site_slug ), + esc_html__( 'Blog Posts', 'jetpack' ), + 'wp-admin-bar-edit-post' ); } $wp_admin_bar->add_menu( array( 'parent' => 'publish', - 'id' => 'new-page', - 'title' => $pages_title, + 'id' => 'new-post', + 'title' => $posts_title, 'meta' => array( 'class' => 'inline-action', ), ) ); + // Comments + if ( current_user_can( 'moderate_comments' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'publish', + 'id' => 'comments', + 'title' => __( 'Comments' ), + 'href' => 'https://wordpress.com/comments/' . esc_attr( $this->primary_site_slug ), + 'meta' => array( + 'class' => 'mb-icon', + ), + ) ); + } + // Testimonials if ( Jetpack::is_module_active( 'custom-content-types' ) && get_option( 'jetpack_testimonial' ) ) { $testimonials_title = $this->create_menu_item_pair( diff --git a/plugins/jetpack/modules/masterbar/overrides.css b/plugins/jetpack/modules/masterbar/overrides.css index 689b283d..4440c21c 100644 --- a/plugins/jetpack/modules/masterbar/overrides.css +++ b/plugins/jetpack/modules/masterbar/overrides.css @@ -54,11 +54,3 @@ #wp-admin-bar-notes.active .noticon-bell:before { content: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ij48cmVjdCB4PSIwIiBmaWxsPSJub25lIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiLz48Zz48cGF0aCBmaWxsPSIjMjMyODJkIiBkPSJNNi4xNCAxNC45N2wyLjgyOCAyLjgyN2MtLjM2Mi4zNjItLjg2Mi41ODYtMS40MTQuNTg2LTEuMTA1IDAtMi0uODk1LTItMiAwLS41NTIuMjI0LTEuMDUyLjU4Ni0xLjQxNHptOC44NjcgNS4zMjRMMTQuMyAyMSAzIDkuN2wuNzA2LS43MDcgMS4xMDIuMTU3Yy43NTQuMTA4IDEuNjktLjEyMiAyLjA3Ny0uNTFsMy44ODUtMy44ODRjMi4zNC0yLjM0IDYuMTM1LTIuMzQgOC40NzUgMHMyLjM0IDYuMTM1IDAgOC40NzVsLTMuODg1IDMuODg2Yy0uMzg4LjM4OC0uNjE4IDEuMzIzLS41MSAyLjA3N2wuMTU3IDEuMXoiLz48L2c+PC9zdmc+") !important; } - -/* Fix changing height issue on hover in pop-up menus */ -#wpadminbar .quicklinks .menupop ul li .ab-item { - height: auto !important; -} -#wpadminbar .menupop .ab-submenu .ab-submenu-header > .ab-empty-item { - line-height: 1 !important; -} diff --git a/plugins/jetpack/modules/module-headings.php b/plugins/jetpack/modules/module-headings.php index cfbb5ac5..5e4c134b 100644 --- a/plugins/jetpack/modules/module-headings.php +++ b/plugins/jetpack/modules/module-headings.php @@ -83,6 +83,7 @@ function jetpack_get_module_i18n( $key ) { 'likes' => array(
'name' => _x( 'Likes', 'Module Name', 'jetpack' ), 'description' => _x( 'Give visitors an easy way to show they appreciate your content.', 'Module Description', 'jetpack' ), + 'recommended description' => _x( 'Give visitors an easy way to show they appreciate your content.', 'Jumpstart Description', 'jetpack' ), ),
'manage' => array(
@@ -109,6 +110,7 @@ function jetpack_get_module_i18n( $key ) { 'monitor' => array(
'name' => _x( 'Monitor', 'Module Name', 'jetpack' ), 'description' => _x( 'Receive immediate notifications if your site goes down, 24/7.', 'Module Description', 'jetpack' ), + 'recommended description' => _x( 'Receive immediate notifications if your site goes down, 24/7.', 'Jumpstart Description', 'jetpack' ), ),
'notes' => array(
@@ -116,11 +118,6 @@ function jetpack_get_module_i18n( $key ) { 'description' => _x( 'Receive instant notifications of site comments and likes.', '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' ), @@ -300,7 +297,6 @@ function jetpack_get_module_i18n_tag( $key ) { // Modules with `Developers` tag:
// - modules/json-api.php
- // - modules/omnisearch.php
// - modules/sso.php
'Developers' =>_x( 'Developers', 'Module Tag', 'jetpack' ),
diff --git a/plugins/jetpack/modules/module-info.php b/plugins/jetpack/modules/module-info.php index 19da4d38..620b5e16 100644 --- a/plugins/jetpack/modules/module-info.php +++ b/plugins/jetpack/modules/module-info.php @@ -443,23 +443,6 @@ function jetpack_likes_more_info() { ?> add_action( 'jetpack_module_more_info_likes', 'jetpack_likes_more_info' ); /** - * Omnisearch - */ -function jetpack_omnisearch_more_link() { - echo 'https://jetpack.com/support/omnisearch/'; -} -add_action( 'jetpack_learn_more_button_omnisearch', 'jetpack_omnisearch_more_link' ); - -function jetpack_omnisearch_more_info() { - esc_html_e( - 'A search to rule them all: search once, get results from everything! Omnisearch supports searching posts, - pages, comments, media, and plugins and plays nice with other plugins by letting other providers offer - results as well.' - , 'jetpack' ); -} -add_action( 'jetpack_module_more_info_omnisearch', 'jetpack_omnisearch_more_info' ); - -/** * Widget Visibility */ function jetpack_widget_visibility_more_link() { diff --git a/plugins/jetpack/modules/monitor.php b/plugins/jetpack/modules/monitor.php index 29c8851b..9f947abf 100644 --- a/plugins/jetpack/modules/monitor.php +++ b/plugins/jetpack/modules/monitor.php @@ -2,13 +2,14 @@ /** * Module Name: Monitor * Module Description: Receive immediate notifications if your site goes down, 24/7. + * Jumpstart Description: Receive immediate notifications if your site goes down, 24/7. * Sort Order: 28 * Recommendation Order: 10 * First Introduced: 2.6 * Requires Connection: Yes * Auto Activate: No * Module Tags: Recommended - * Feature: Security + * Feature: Security, Jumpstart * Additional Search Queries: monitor, uptime, downtime, monitoring */ @@ -45,6 +46,7 @@ class Jetpack_Monitor { $this->update_option_receive_jetpack_monitor_notification( isset( $_POST['receive_jetpack_monitor_notification'] ) ); Jetpack::state( 'message', 'module_configured' ); wp_safe_redirect( Jetpack::module_configuration_url( $this->module ) ); + exit; } } diff --git a/plugins/jetpack/modules/omnisearch.php b/plugins/jetpack/modules/omnisearch.php index cf24281f..88c13090 100644 --- a/plugins/jetpack/modules/omnisearch.php +++ b/plugins/jetpack/modules/omnisearch.php @@ -1,18 +1,6 @@ <?php - /** - * Module Name: Omnisearch - * Module Description: Search your entire database from a single field in your dashboard. - * Sort Order: 16 - * First Introduced: 2.3 - * Requires Connection: No - * Auto Activate: Yes - * Module Tags: Developers - * Feature: General - * Additional Search Queries: search + * Deprecated. No longer needed. + * + * @package Jetpack */ - -// Only do Jetpack Omnisearch if there isn't already a Core WP_Omnisearch Class. -if ( ! class_exists( 'WP_Omnisearch' ) ) { - require_once( dirname( __FILE__ ) . '/omnisearch/omnisearch-core.php' ); -} diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-comments.php b/plugins/jetpack/modules/omnisearch/omnisearch-comments.php deleted file mode 100644 index e5336c5b..00000000 --- a/plugins/jetpack/modules/omnisearch/omnisearch-comments.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -if( ! class_exists( 'WP_Comments_List_Table' ) ) - require_once( ABSPATH . 'wp-admin/includes/class-wp-comments-list-table.php' ); - -class Jetpack_Omnisearch_Comments extends WP_Comments_List_Table { - static $instance; - public $checkbox = false; - - function __construct() { - self::$instance = $this; - add_filter( 'omnisearch_results', array( $this, 'search'), 10, 2 ); - } - - function search( $results, $search_term ) { - $search_url = esc_url( admin_url( sprintf( 'edit-comments.php?s=%s', urlencode( $search_term ) ) ) ); - $search_link = sprintf( ' <a href="%s" class="add-new-h2">%s</a>', $search_url, esc_html__('Search Comments', 'jetpack') ); - $html = '<h2>' . esc_html__('Comments', 'jetpack') . $search_link . '</h2>'; - parent::__construct(); - - ob_start(); - $this->prepare_items(); - $this->_column_headers = array( $this->get_columns(), array(), array() ); - $this->display(); - $html .= ob_get_clean(); - - $label = __( 'Comments', 'jetpack' ); - $results[ $label ] = $html; - return $results; - } - - function get_per_page( $comment_status = 'all' ) { - /** This action is documented in modules/omnisearch/omnisearch-core.php */ - return apply_filters( 'omnisearch_num_results', 5 ); - } - - function get_sortable_columns() { - return array(); - } - - function get_bulk_actions() { - return array(); - } - - function pagination( $which ) {} - - function extra_tablenav( $which ) {} -} diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-core.php b/plugins/jetpack/modules/omnisearch/omnisearch-core.php deleted file mode 100644 index ee70473a..00000000 --- a/plugins/jetpack/modules/omnisearch/omnisearch-core.php +++ /dev/null @@ -1,227 +0,0 @@ -<?php - -// Include this here so that other plugins can extend it if they like. -require_once( dirname(__FILE__) . '/omnisearch-posts.php' ); - -class Jetpack_Omnisearch { - static $instance; - static $num_results = 5; - - function __construct() { - self::$instance = $this; - add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); - add_action( 'admin_init', array( $this, 'add_providers' ) ); - add_action( 'jetpack_admin_menu', array( $this, 'jetpack_admin_menu' ) ); - add_action( 'admin_menu', array( $this, 'admin_menu' ), 20 ); - if( ! jetpack_is_mobile() ) { - add_action( 'admin_bar_menu', array( $this, 'admin_bar_search' ), 4 ); - } - add_filter( 'omnisearch_num_results', array( $this, 'omnisearch_num_results' ) ); - } - - static function add_providers() { - // omnisearch-posts.php is included above, so that other plugins can more easily extend it. - new Jetpack_Omnisearch_Posts; - new Jetpack_Omnisearch_Posts( 'page' ); - - require_once( dirname(__FILE__) . '/omnisearch-comments.php' ); - new Jetpack_Omnisearch_Comments; - - if ( current_user_can( 'upload_files' ) ) { - require_once( dirname(__FILE__) . '/omnisearch-media.php' ); - new Jetpack_Omnisearch_Media; - } - - if ( current_user_can( 'install_plugins' ) ) { - require_once( dirname(__FILE__) . '/omnisearch-plugins.php' ); - new Jetpack_Omnisearch_Plugins; - } - - /** - * Fires after each default omnisearch provider has been required. - * - * Can be used to add your own Omnisearch provider. - * - * @module omnisearch - * - * @since 2.3.2 - */ - do_action( 'omnisearch_add_providers' ); - } - - static function omnisearch_num_results( $num ) { - return self::$num_results; - } - - function wp_loaded() { - $deps = null; - if ( wp_style_is( 'genericons', 'registered' ) ) { - $deps = array( 'genericons' ); - } - wp_register_style( 'omnisearch-admin', plugins_url( 'omnisearch.css', __FILE__ ), $deps ); - wp_style_add_data( 'omnisearch-admin', 'rtl', 'replace' ); - - } - - function jetpack_admin_menu() { - remove_submenu_page( 'index.php', 'omnisearch' ); - $this->slug = add_submenu_page( null, __( 'Omnisearch', 'jetpack' ), __( 'Omnisearch', 'jetpack' ), 'edit_posts', 'omnisearch', array( $this, 'omnisearch_page' ) ); - add_action( "admin_print_styles-{$this->slug}", array( $this, 'admin_print_styles' ) ); - } - - function admin_menu() { - $this->slug = add_dashboard_page( __( 'Omnisearch', 'jetpack' ), __( 'Omnisearch', 'jetpack' ), 'edit_posts', 'omnisearch', array( $this, 'omnisearch_page' ) ); - add_action( "admin_print_styles-{$this->slug}", array( $this, 'admin_print_styles' ) ); - } - - function admin_print_styles() { - wp_enqueue_style( 'omnisearch-admin' ); - } - - function omnisearch_page() { - $results = array(); - $s = isset( $_GET['s'] ) ? $_GET['s'] : ''; - if ( $s ) { - /** - * Filter the results returned for a given Omnisearch search query. - * - * @module omnisearch - * - * @since 2.3.0 - * - * @param array $results Array of Omnisearch results. - * @param string $s Search parameter. - */ - $results = apply_filters( 'omnisearch_results', $results, $s ); - } - /** - * Filter the number of results displayed for each Omnisearch searched section. - * - * @module omnisearch - * - * @since 2.3.0 - * - * @param int 5 Number of results displayed for each Omnisearch searched section. - */ - $num_results = intval( apply_filters( 'omnisearch_num_results', 5 ) ); - ?> - <div class="wrap"> - <h2 class="page-title"><?php esc_html_e( 'Omnisearch', 'jetpack' ); ?> <small><?php esc_html_e( 'search everything', 'jetpack' ); ?></small></h2> - <br class="clear" /> - <?php echo self::get_omnisearch_form( array( - 'form_class' => 'omnisearch-form', - 'search_class' => 'omnisearch', - 'search_placeholder' => '', - 'submit_class' => 'omnisearch-submit', - 'alternate_submit' => true, - ) ); ?> - <?php if( ! empty( $results ) ): ?> - <h3 id="results-title"><?php esc_html_e( 'Results:', 'jetpack' ); ?></h3> - <div class="jump-to"><strong><?php esc_html_e( 'Jump to:', 'jetpack' ); ?></strong> - <?php foreach( $results as $label => $result ) : ?> - <a href="#result-<?php echo sanitize_title( $label ); ?>"><?php echo esc_html( $label ); ?></a> - <?php endforeach; ?> - </div> - <br class="clear" /> - <script>var search_term = '<?php echo esc_js( $s ); ?>', num_results = <?php echo $num_results; ?>;</script> - <ul class="omnisearch-results"> - <?php foreach( $results as $label => $result ) : ?> - <li id="result-<?php echo sanitize_title( $label ); ?>" data-label="<?php echo esc_attr( $label ); ?>"> - <?php echo $result; ?> - <a class="back-to-top" href="#results-title"><?php esc_html_e( 'Back to Top ↑', 'jetpack' ); ?></a> - </li> - <?php endforeach; ?> - </ul> - <?php endif; ?> - </div><!-- /wrap --> - <?php - } - - function admin_bar_search( $wp_admin_bar ) { - if( - ! is_admin() || - ! current_user_can( 'edit_posts' ) || - ( - function_exists( 'wpcom_use_wpadmin_flows' ) && - ! wpcom_use_wpadmin_flows() - ) - ) - return; - - $form = self::get_omnisearch_form( array( - 'form_id' => 'adminbarsearch', - 'search_id' => 'adminbar-search', - 'search_class' => 'adminbar-input', - 'submit_class' => 'adminbar-button', - ) ); - - $form .= "<style> - #adminbar-search::-webkit-input-placeholder, - #adminbar-search:-moz-placeholder, - #adminbar-search::-moz-placeholder, - #adminbar-search:-ms-input-placeholder { - text-shadow: none; - } - </style>"; - - $wp_admin_bar->add_menu( array( - 'parent' => 'top-secondary', - 'id' => 'search', - 'title' => $form, - 'meta' => array( - 'class' => 'admin-bar-search', - 'tabindex' => -1, - ) - ) ); - } - - static function get_omnisearch_form( $args = array() ) { - $defaults = array( - 'form_id' => null, - 'form_class' => null, - 'search_class' => null, - 'search_id' => null, - 'search_value' => isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : null, - 'search_placeholder' => __( 'Search Everything', 'jetpack' ), - 'submit_class' => 'button', - 'submit_value' => __( 'Search', 'jetpack' ), - 'alternate_submit' => false, - ); - extract( array_map( 'esc_attr', wp_parse_args( $args, $defaults ) ) ); - - $rand = rand(); - if( empty( $form_id ) ) - $form_id = "omnisearch_form_$rand"; - if( empty( $search_id ) ) - $search_id = "omnisearch_search_$rand"; - - ob_start(); - ?> - - <form action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>" method="get" class="<?php echo $form_class; ?>" id="<?php echo $form_id; ?>"> - <input type="hidden" name="page" value="omnisearch" /> - <input name="s" type="search" class="<?php echo $search_class; ?>" id="<?php echo $search_id; ?>" value="<?php echo $search_value; ?>" placeholder="<?php echo $search_placeholder; ?>" /> - <?php if ( $alternate_submit ) : ?> - <button type="submit" class="<?php echo $submit_class; ?>"><span><?php echo $submit_value; ?></span></button> - <?php else : ?> - <input type="submit" class="<?php echo $submit_class; ?>" value="<?php echo $submit_value; ?>" /> - <?php endif; ?> - </form> - - <?php - /** - * Filters the Omnisearch search form output. - * - * @module omnisearch - * - * @since 2.3.0 - * - * @param string ob_get_clean() Omnisearch search form output. - * @param array $args Array of arguments to pass to the form to overwrite the default form parameters. - * @param array $defaults Array of default form parameters. - */ - return apply_filters( 'get_omnisearch_form', ob_get_clean(), $args, $defaults ); - } - -} -new Jetpack_Omnisearch; diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-media.php b/plugins/jetpack/modules/omnisearch/omnisearch-media.php deleted file mode 100644 index 94b62039..00000000 --- a/plugins/jetpack/modules/omnisearch/omnisearch-media.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -if( ! class_exists( 'WP_Media_List_Table' ) ) - require_once( ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php' ); - -class Jetpack_Omnisearch_Media extends WP_Media_List_Table { - static $instance; - - function __construct() { - self::$instance = $this; - add_filter( 'omnisearch_results', array( $this, 'search' ), 10, 2 ); - } - - function search( $results, $search_term ) { - $search_url = esc_url( add_query_arg( 's', $search_term, admin_url( 'upload.php' ) ) ); - $search_link = sprintf( ' <a href="%s" class="add-new-h2">%s</a>', $search_url, esc_html__( 'Search Media', 'jetpack' ) ); - $html = '<h2>' . esc_html__( 'Media', 'jetpack' ) . $search_link . '</h2>'; - parent::__construct(); - - ob_start(); - $this->prepare_items(); - $columns = $this->get_columns(); - unset( $columns['cb'] ); - $this->_column_headers = array( $columns, array(), array() ); - $this->display(); - $html .= ob_get_clean(); - - $label = __( 'Media', 'jetpack' ); - $results[ $label ] = $html; - return $results; - } - - function get_sortable_columns() { - return array(); - } - - function get_bulk_actions() { - return array(); - } - - function pagination( $which ) {} - - function extra_tablenav( $which ) {} -} diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-plugins.php b/plugins/jetpack/modules/omnisearch/omnisearch-plugins.php deleted file mode 100644 index c876e902..00000000 --- a/plugins/jetpack/modules/omnisearch/omnisearch-plugins.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - -if( ! class_exists( 'WP_Plugin_Install_List_Table' ) ) - require_once( ABSPATH . 'wp-admin/includes/class-wp-plugin-install-list-table.php' ); - -class Jetpack_Omnisearch_Plugins extends WP_Plugin_Install_List_Table { - static $instance; - - function __construct() { - self::$instance = $this; - add_filter( 'omnisearch_results', array( $this, 'search'), 10, 2 ); - add_action( 'wp_ajax_omnisearch_plugins', array( $this, 'wp_ajax_omnisearch_plugins' ) ); - } - - function search( $results, $search_term ) { - wp_enqueue_script( 'plugin-install' ); - add_thickbox(); - - $search_url = esc_url( admin_url( sprintf( 'plugin-install.php?tab=search&s=%s', urlencode( $search_term ) ) ) ); - $search_link = sprintf( ' <a href="%s" class="add-new-h2">%s</a>', $search_url, esc_html__('Search Plugins', 'jetpack') ); - $html = '<h2>' . esc_html__('Plugins', 'jetpack') . $search_link . '</h2>'; - - $html .= '<div id="' . __CLASS__ . '_results">' . esc_html__('Loading …', 'jetpack') . '</div>'; - $html .= '<script>jQuery("#' . __CLASS__ . '_results").load(ajaxurl,{action:"omnisearch_plugins",search_term:search_term,num_results:num_results});</script>'; - - $label = __( 'Plugins', 'jetpack' ); - $results[ $label ] = $html; - return $results; - } - - function results_html( $search_term, $num_results = null ) { - $_GET['tab'] = 'search'; - $GLOBALS['hook_suffix'] = 'foo'; - $_REQUEST['s'] = $search_term; - parent::__construct(); - - ob_start(); - $this->prepare_items(); - /** This action is documented in modules/omnisearch/omnisearch-core.php */ - $num_results = intval( $num_results ) ? intval( $num_results ) : apply_filters( 'omnisearch_num_results', 5 ); - $this->items = array_slice( $this->items, 0, $num_results ); - remove_action( 'install_plugins_table_header', 'install_search_form' ); - $this->display(); - $html = ob_get_clean(); - - return $html; - } - - function wp_ajax_omnisearch_plugins() { - $search_term = $_REQUEST['search_term']; - $num_results = isset( $_REQUEST['num_results'] ) ? $_REQUEST['num_results'] : null; - echo $this->results_html( $search_term, $num_results ); - exit; - } - - function get_bulk_actions() { - return array(); - } - - function pagination( $which ) {} -} diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-posts.php b/plugins/jetpack/modules/omnisearch/omnisearch-posts.php deleted file mode 100644 index 7193f1ae..00000000 --- a/plugins/jetpack/modules/omnisearch/omnisearch-posts.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php - -if( ! class_exists( 'WP_List_Table' ) ) - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); - -class Jetpack_Omnisearch_Posts extends WP_List_Table { - public $post_type = 'post', - $post_type_object; - - function __construct( $post_type = 'post' ) { - $this->post_type = $post_type; - add_filter( 'omnisearch_results', array( $this, 'search'), 10, 2 ); - - // Push 'post_type_obj' to accepted fields for WP_List_Table (since WP 4.2) - global $wp_version; - if ( version_compare( $wp_version, '4.2-z', '>=' ) && $this->compat_fields && is_array( $this->compat_fields ) ) { - array_push( $this->compat_fields, 'post_type_obj', 'posts' ); - } - } - - function search( $results, $search_term ) { - if( ! post_type_exists( $this->post_type ) ) - return $results; - - parent::__construct(); - - $this->post_type_obj = get_post_type_object( $this->post_type ); - - $search_url = esc_url( admin_url( sprintf( 'edit.php?post_type=%s&s=%s', urlencode( $this->post_type_obj->name ), urlencode( $search_term ) ) ) ); - $search_link = sprintf( ' <a href="%s" class="add-new-h2">%s</a>', $search_url, esc_html( $this->post_type_obj->labels->search_items ) ); - $html = '<h2>' . esc_html( $this->post_type_obj->labels->name ) . $search_link .'</h2>'; - - /** This action is documented in modules/omnisearch/omnisearch-core.php */ - $num_results = apply_filters( 'omnisearch_num_results', 5 ); - - $this->posts = get_posts( array( - 's' => $search_term, - 'post_type' => $this->post_type, - 'posts_per_page' => $num_results, - 'post_status' => 'any', - 'suppress_filters' => false, - ) ); - - $this->prepare_items(); - - ob_start(); - $this->display(); - $html .= ob_get_clean(); - - $results[ $this->post_type_obj->labels->name ] = $html; - return $results; - } - - function get_columns() { - $columns = array( - # 'id' => __('ID', 'jetpack'), - 'post_title' => __('Title', 'jetpack'), - 'snippet' => __('Snippet', 'jetpack'), - 'date' => __('Date', 'jetpack'), - ); - return $columns; - } - - function prepare_items() { - $columns = $this->get_columns(); - $hidden = array(); - $sortable = array(); - $this->_column_headers = array( $columns, $hidden, $sortable ); - $this->items = $this->posts; - } - - function column_post_title( $post ) { - $actions = array(); - if ( current_user_can( $this->post_type_obj->cap->edit_post, $post ) ) { - $post_title = sprintf( '<a href="%s">%s</a>', esc_url( get_edit_post_link( $post->ID ) ), wptexturize( $post->post_title ) ); - $actions['edit'] = sprintf( '<a href="%s">%s</a>', esc_url( get_edit_post_link( $post->ID ) ), esc_html( $this->post_type_obj->labels->edit_item ) ); - } else { - $post_title = wptexturize( $post->post_title ); - } - if ( current_user_can( $this->post_type_obj->cap->delete_post, $post ) ) { - $actions['delete'] = sprintf( '<a href="%s">%s</a>', esc_url( get_delete_post_link( $post->ID ) ), esc_html__('Trash', 'jetpack') ); - } - $actions['view'] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post->ID ) ), esc_html( $this->post_type_obj->labels->view_item ) ); - return $post_title . $this->row_actions( $actions ); - } - - function column_date( $post ) { - $html = ''; - - if ( '0000-00-00 00:00:00' == $post->post_date ) { - $t_time = $h_time = __('Unpublished', 'jetpack'); - $time_diff = 0; - } else { - $t_time = date( __('Y/m/d g:i:s A', 'jetpack'), mysql2date( 'G', $post->post_date ) ); - $m_time = $post->post_date; - $time = get_post_time( 'G', true, $post ); - - $time_diff = time() - $time; - - if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) - $h_time = sprintf( __('%s ago', 'jetpack'), human_time_diff( $time ) ); - else - $h_time = mysql2date( __('Y/m/d', 'jetpack'), $m_time ); - } - - $html .= '<abbr title="' . esc_attr( $t_time ) . '">' . esc_html( $h_time ) . '</abbr>'; - $html .= '<br />'; - if ( 'publish' == $post->post_status ) { - $html .= esc_html__('Published', 'jetpack'); - } elseif ( 'future' == $post->post_status ) { - if ( $time_diff > 0 ) - $html .= '<strong class="attention">' . esc_html__('Missed schedule', 'jetpack') . '</strong>'; - else - $html .= esc_html__('Scheduled', 'jetpack'); - } else { - $html .= esc_html__('Last Modified', 'jetpack'); - } - return $html; - } - - function column_default( $post, $column_name ) { - switch ( $column_name ) { - case 'id': - return $post->ID; - case 'post_title': // Will never happen, class method overrides. - return $post->post_title; - case 'snippet': - return wp_trim_words( $post->post_content, 55 ); - case 'date': // Will never happen, class method overrides. - $d = get_option('date_format'); - $t = get_option('time_format'); - return get_post_modified_time( $d, 0, $post, 1 ) . ' @ ' . get_post_modified_time( $t, 0, $post, 1 ); - default: - return print_r( $post, true ); - } - } -} diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-rtl.css b/plugins/jetpack/modules/omnisearch/omnisearch-rtl.css deleted file mode 100644 index 6ad33b2b..00000000 --- a/plugins/jetpack/modules/omnisearch/omnisearch-rtl.css +++ /dev/null @@ -1,131 +0,0 @@ -/* Do not modify this file directly. It is concatenated from individual module CSS files. */ - -h2.page-title small { - font-size: 0.6em; - font-weight: 300; - font-style: italic; - opacity: 0.6; - margin-right: 0.5em; -} - -form.omnisearch-form { - position: relative; -} - -input.omnisearch { - border-radius: 0.25em; - font-size: 2.2em; - line-height: 1.35; - padding: 0.25em 0.5em 0.25em 2em; - width: 100%; -} - -input.omnisearch::-webkit-search-cancel-button { - display: none; -} - -button.omnisearch-submit { - background: transparent; - border: 0; - cursor: pointer; - display: block; - font-size: 2.45em; - padding: 0.3em 0.5em 0.1em; - text-align: center; - position: absolute; - left: 0; - bottom: 0; -} - -button.omnisearch-submit::before { - font-family: 'Genericons', Noticons; - content: '\f400'; -} - -button.omnisearch-submit span { - display: none; -} - -#results-title, -.jump-to { - font-size: 1.2em; - line-height: 1.5; - float: right; - margin-top: 0; - padding-top: 2em; -} - -#results-title, -.jump-to strong { - font-weight: 600; -} - -.jump-to { - float: left; - text-align: left; -} - -.jump-to strong, -.jump-to a { - color: inherit; - margin-right: 0.5em; - text-decoration: none; -} - -.jump-to a:hover { - text-decoration: underline; -} - -.back-to-top { - display: block; - float: left; - margin-top: 2.5em; -} - -.omnisearch-results { - -} - -.omnisearch-results > li { - padding-top: 2.5em; -} - -.omnisearch-results > li:first-child { - padding-top: 0; -} - -.omnisearch-results .add-new-h2 { - display: inline; -} - -.wp-list-table .column-snippet { - width: 65%; -} - -.wp-list-table .column-date { - width: 15%; -} - -.wp-list-table.comments .column-author { - width: 20%; -} - -.wp-list-table.media th { - white-space: nowrap; -} - -.wp-list-table.media .column-parent { - width: 15%; -} - -.wp-list-table.media .column-comments span.vers { - display: block; -} - -.tablenav { - height: 0; -} - -.omnisearch-results .tablenav.top { - margin: 5px 0; -} diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-rtl.min.css b/plugins/jetpack/modules/omnisearch/omnisearch-rtl.min.css deleted file mode 100644 index 2234c900..00000000 --- a/plugins/jetpack/modules/omnisearch/omnisearch-rtl.min.css +++ /dev/null @@ -1 +0,0 @@ -h2.page-title small{font-size:.6em;font-weight:300;font-style:italic;opacity:.6;margin-right:.5em}form.omnisearch-form{position:relative}input.omnisearch{border-radius:.25em;font-size:2.2em;line-height:1.35;padding:.25em .5em .25em 2em;width:100%}input.omnisearch::-webkit-search-cancel-button{display:none}button.omnisearch-submit{background:0 0;border:0;cursor:pointer;display:block;font-size:2.45em;padding:.3em .5em .1em;text-align:center;position:absolute;left:0;bottom:0}button.omnisearch-submit::before{font-family:Genericons,Noticons;content:'\f400'}button.omnisearch-submit span{display:none}#results-title,.jump-to{font-size:1.2em;line-height:1.5;float:right;margin-top:0;padding-top:2em}#results-title,.jump-to strong{font-weight:600}.jump-to{float:left;text-align:left}.jump-to a,.jump-to strong{color:inherit;margin-right:.5em;text-decoration:none}.jump-to a:hover{text-decoration:underline}.back-to-top{display:block;float:left;margin-top:2.5em}.omnisearch-results>li{padding-top:2.5em}.omnisearch-results>li:first-child{padding-top:0}.omnisearch-results .add-new-h2{display:inline}.wp-list-table .column-snippet{width:65%}.wp-list-table .column-date{width:15%}.wp-list-table.comments .column-author{width:20%}.wp-list-table.media th{white-space:nowrap}.wp-list-table.media .column-parent{width:15%}.wp-list-table.media .column-comments span.vers{display:block}.tablenav{height:0}.omnisearch-results .tablenav.top{margin:5px 0}
\ No newline at end of file diff --git a/plugins/jetpack/modules/omnisearch/omnisearch.css b/plugins/jetpack/modules/omnisearch/omnisearch.css deleted file mode 100644 index cd70d9d1..00000000 --- a/plugins/jetpack/modules/omnisearch/omnisearch.css +++ /dev/null @@ -1,130 +0,0 @@ - -h2.page-title small { - font-size: 0.6em; - font-weight: 300; - font-style: italic; - opacity: 0.6; - margin-left: 0.5em; -} - -form.omnisearch-form { - position: relative; -} - -input.omnisearch { - border-radius: 0.25em; - font-size: 2.2em; - line-height: 1.35; - padding: 0.25em 2em 0.25em 0.5em; - width: 100%; -} - -input.omnisearch::-webkit-search-cancel-button { - display: none; -} - -button.omnisearch-submit { - background: transparent; - border: 0; - cursor: pointer; - display: block; - font-size: 2.45em; - padding: 0.3em 0.5em 0.1em; - text-align: center; - position: absolute; - right: 0; - bottom: 0; -} - -button.omnisearch-submit::before { - font-family: 'Genericons', Noticons; - content: '\f400'; -} - -button.omnisearch-submit span { - display: none; -} - -#results-title, -.jump-to { - font-size: 1.2em; - line-height: 1.5; - float: left; - margin-top: 0; - padding-top: 2em; -} - -#results-title, -.jump-to strong { - font-weight: 600; -} - -.jump-to { - float: right; - text-align: right; -} - -.jump-to strong, -.jump-to a { - color: inherit; - margin-left: 0.5em; - text-decoration: none; -} - -.jump-to a:hover { - text-decoration: underline; -} - -.back-to-top { - display: block; - float: right; - margin-top: 2.5em; -} - -.omnisearch-results { - -} - -.omnisearch-results > li { - padding-top: 2.5em; -} - -.omnisearch-results > li:first-child { - padding-top: 0; -} - -.omnisearch-results .add-new-h2 { - display: inline; -} - -.wp-list-table .column-snippet { - width: 65%; -} - -.wp-list-table .column-date { - width: 15%; -} - -.wp-list-table.comments .column-author { - width: 20%; -} - -.wp-list-table.media th { - white-space: nowrap; -} - -.wp-list-table.media .column-parent { - width: 15%; -} - -.wp-list-table.media .column-comments span.vers { - display: block; -} - -.tablenav { - height: 0; -} - -.omnisearch-results .tablenav.top { - margin: 5px 0; -} diff --git a/plugins/jetpack/modules/omnisearch/omnisearch.min.css b/plugins/jetpack/modules/omnisearch/omnisearch.min.css deleted file mode 100644 index 02f76991..00000000 --- a/plugins/jetpack/modules/omnisearch/omnisearch.min.css +++ /dev/null @@ -1,2 +0,0 @@ -/* Do not modify this file directly. It is concatenated from individual module CSS files. */ -h2.page-title small{font-size:.6em;font-weight:300;font-style:italic;opacity:.6;margin-left:.5em}form.omnisearch-form{position:relative}input.omnisearch{border-radius:.25em;font-size:2.2em;line-height:1.35;padding:.25em 2em .25em .5em;width:100%}input.omnisearch::-webkit-search-cancel-button{display:none}button.omnisearch-submit{background:0 0;border:0;cursor:pointer;display:block;font-size:2.45em;padding:.3em .5em .1em;text-align:center;position:absolute;right:0;bottom:0}button.omnisearch-submit::before{font-family:Genericons,Noticons;content:'\f400'}button.omnisearch-submit span{display:none}#results-title,.jump-to{font-size:1.2em;line-height:1.5;float:left;margin-top:0;padding-top:2em}#results-title,.jump-to strong{font-weight:600}.jump-to{float:right;text-align:right}.jump-to a,.jump-to strong{color:inherit;margin-left:.5em;text-decoration:none}.jump-to a:hover{text-decoration:underline}.back-to-top{display:block;float:right;margin-top:2.5em}.omnisearch-results>li{padding-top:2.5em}.omnisearch-results>li:first-child{padding-top:0}.omnisearch-results .add-new-h2{display:inline}.wp-list-table .column-snippet{width:65%}.wp-list-table .column-date{width:15%}.wp-list-table.comments .column-author{width:20%}.wp-list-table.media th{white-space:nowrap}.wp-list-table.media .column-parent{width:15%}.wp-list-table.media .column-comments span.vers{display:block}.tablenav{height:0}.omnisearch-results .tablenav.top{margin:5px 0}
\ No newline at end of file diff --git a/plugins/jetpack/modules/protect.php b/plugins/jetpack/modules/protect.php index aa9b3f6b..1677e2b9 100644 --- a/plugins/jetpack/modules/protect.php +++ b/plugins/jetpack/modules/protect.php @@ -597,6 +597,7 @@ class Jetpack_Protect_Module { // If it fails we need access to $this->api_key_error if ( $result ) { wp_safe_redirect( Jetpack::module_configuration_url( 'protect' ) ); + exit; } } diff --git a/plugins/jetpack/modules/publicize/publicize-jetpack.php b/plugins/jetpack/modules/publicize/publicize-jetpack.php index 2c8c3967..0923af21 100644 --- a/plugins/jetpack/modules/publicize/publicize-jetpack.php +++ b/plugins/jetpack/modules/publicize/publicize-jetpack.php @@ -84,6 +84,9 @@ class Publicize extends Publicize_Base { class="button-connector" id="wpcom-connect"><?php esc_html_e( 'Link account with WordPress.com', 'jetpack' ); ?></a> </p> + <p class="jetpack-install-blurb"> + <?php jetpack_render_tos_blurb(); ?> + </p> </div> </div> </div> diff --git a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php index 4ba3bf9e..3f30be59 100644 --- a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php +++ b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php @@ -1463,11 +1463,8 @@ EOT; 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 ); - } else { - wp_enqueue_style( 'jetpack_related-posts', plugins_url( 'related-posts.css', __FILE__ ), array(), self::VERSION ); - } + wp_enqueue_style( 'jetpack_related-posts', plugins_url( 'related-posts.css', __FILE__ ), array(), self::VERSION ); + wp_style_add_data( 'jetpack_related-posts', 'rtl', 'replace' ); } } diff --git a/plugins/jetpack/modules/search/class.jetpack-search.php b/plugins/jetpack/modules/search/class.jetpack-search.php index cdd10504..a216c5e4 100644 --- a/plugins/jetpack/modules/search/class.jetpack-search.php +++ b/plugins/jetpack/modules/search/class.jetpack-search.php @@ -102,24 +102,49 @@ class Jetpack_Search { * @return object|WP_Error The response from the public api, or a WP_Error */ public function search( array $es_args ) { - $service_url = 'https://public-api.wordpress.com/rest/v1/sites/' . $this->jetpack_blog_id . '/search'; + $endpoint = sprintf( '/sites/%s/search', $this->jetpack_blog_id ); + $service_url = 'https://public-api.wordpress.com/rest/v1' . $endpoint; - $start_time = microtime( true ); + $do_authenticated_request = false; + + if ( class_exists( 'Jetpack_Client' ) && + isset( $es_args['authenticated_request'] ) && + true === $es_args['authenticated_request'] ) { + $do_authenticated_request = true; + } + + unset( $es_args['authenticated_request'] ); - $request = wp_remote_post( $service_url, array( + $request_args = array( 'headers' => array( 'Content-Type' => 'application/json', ), 'timeout' => 10, 'user-agent' => 'jetpack_search', - 'body' => json_encode( $es_args ), - ) ); + ); + + $request_body = json_encode( $es_args ); + + $start_time = microtime( true ); + + if ( $do_authenticated_request ) { + $request_args['method'] = 'POST'; + + $request = Jetpack_Client::wpcom_json_api_request_as_blog( $endpoint, Jetpack_Client::WPCOM_JSON_API_VERSION, $request_args, $request_body ); + } else { + $request_args = array_merge( $request_args, array( + 'body' => $request_body, + ) ); + + $request = wp_remote_post( $service_url, $request_args ); + } $end_time = microtime( true ); if ( is_wp_error( $request ) ) { return $request; } + $response_code = wp_remote_retrieve_response_code( $request ); if ( ! $response_code || $response_code < 200 || $response_code >= 300 ) { diff --git a/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php b/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php index 26018f61..8555da37 100644 --- a/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php +++ b/plugins/jetpack/modules/shortcodes/class.filter-embedded-html-objects.php @@ -54,7 +54,7 @@ class Filter_Embedded_HTML_Objects { } static public function filter( $html ) { - if ( ! $html ) { + if ( ! $html || ! is_string( $html ) ) { return $html; } diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.css b/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.css new file mode 100644 index 00000000..52a59b19 --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.css @@ -0,0 +1,37 @@ +/* Do not modify this file directly. It is concatenated from individual module CSS files. */ +.jetpack-recipe-meta li.jetpack-recipe-print { + display: none; +} + +.jetpack-recipe-title { + font-size: 16pt; +} + +.jetpack-recipe-content img { + display: inline-block !important; + max-width: 100%; +} + +.jetpack-recipe-image { + display: none !important; +} + +.jetpack-recipe-content .aligncenter { + display: block !important; + margin: 0 auto 1em !important; + text-align: center !important; +} + +.jetpack-recipe-content .alignright { + float: left !important; + margin: 0 1em .5em 0 !important; +} + +.jetpack-recipe-content .alignleft { + float: right !important; + margin: 0 0 .5em 1em !important; +} + +.jetpack-recipe-content .alignnone { + display: inline-block; +} diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.min.css b/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.min.css new file mode 100644 index 00000000..bbea4bf2 --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/css/recipes-print-rtl.min.css @@ -0,0 +1 @@ +.jetpack-recipe-meta li.jetpack-recipe-print{display:none}.jetpack-recipe-title{font-size:16pt}.jetpack-recipe-content img{display:inline-block!important;max-width:100%}.jetpack-recipe-image{display:none!important}.jetpack-recipe-content .aligncenter{display:block!important;margin:0 auto 1em!important;text-align:center!important}.jetpack-recipe-content .alignright{float:left!important;margin:0 1em .5em 0!important}.jetpack-recipe-content .alignleft{float:right!important;margin:0 0 .5em 1em!important}.jetpack-recipe-content .alignnone{display:inline-block}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css b/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css new file mode 100644 index 00000000..52cf81bf --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/css/recipes-print.min.css @@ -0,0 +1,2 @@ +/* Do not modify this file directly. It is concatenated from individual module CSS files. */ +.jetpack-recipe-meta li.jetpack-recipe-print{display:none}.jetpack-recipe-title{font-size:16pt}.jetpack-recipe-content img{display:inline-block!important;max-width:100%}.jetpack-recipe-image{display:none!important}.jetpack-recipe-content .aligncenter{display:block!important;margin:0 auto 1em!important;text-align:center!important}.jetpack-recipe-content .alignright{float:right!important;margin:0 0 .5em 1em!important}.jetpack-recipe-content .alignleft{float:left!important;margin:0 1em .5em 0!important}.jetpack-recipe-content .alignnone{display:inline-block}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css new file mode 100644 index 00000000..8251edf5 --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.css @@ -0,0 +1,37 @@ +/* Do not modify this file directly. It is concatenated from individual module CSS files. */ +.jetpack-recipe { + border: 1px solid #f2f2f2; + border-radius: 1px; + clear: both; + margin: 1.5em 1%; + padding: 1% 2%; +} +.jetpack-recipe-title { + border-bottom: 1px solid #ccc; + margin: .25em 0; + padding: .25em 0; +} +.jetpack-recipe .jetpack-recipe-meta { + display: block; + font-size: .9em; + list-style-type: none; + margin-left: 0; + margin-right: 0; + padding: 0; + overflow: hidden; + width: 100%; +} +.jetpack-recipe .jetpack-recipe-meta li { + float: right; + list-style-type: none; + margin: 0; + padding: 0 0 0 5%; +} +.jetpack-recipe-meta li.jetpack-recipe-print { + float: left; + padding-left: 0; + text-align: left; +} +.jetpack-recipe-notes { + font-style: italic; +} diff --git a/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css new file mode 100644 index 00000000..a0492b5f --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/css/recipes-rtl.min.css @@ -0,0 +1 @@ +.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-left:0;margin-right:0;padding:0;overflow:hidden;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:right;list-style-type:none;margin:0;padding:0 0 0 5%}.jetpack-recipe-meta li.jetpack-recipe-print{float:left;padding-left:0;text-align:left}.jetpack-recipe-notes{font-style:italic}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/recipes.min.css b/plugins/jetpack/modules/shortcodes/css/recipes.min.css new file mode 100644 index 00000000..e4e36a3d --- /dev/null +++ b/plugins/jetpack/modules/shortcodes/css/recipes.min.css @@ -0,0 +1,2 @@ +/* Do not modify this file directly. It is concatenated from individual module CSS files. */ +.jetpack-recipe{border:1px solid #f2f2f2;border-radius:1px;clear:both;margin:1.5em 1%;padding:1% 2%}.jetpack-recipe-title{border-bottom:1px solid #ccc;margin:.25em 0;padding:.25em 0}.jetpack-recipe .jetpack-recipe-meta{display:block;font-size:.9em;list-style-type:none;margin-right:0;margin-left:0;padding:0;overflow:hidden;width:100%}.jetpack-recipe .jetpack-recipe-meta li{float:left;list-style-type:none;margin:0;padding:0 5% 0 0}.jetpack-recipe-meta li.jetpack-recipe-print{float:right;padding-right:0;text-align:right}.jetpack-recipe-notes{font-style:italic}
\ No newline at end of file diff --git a/plugins/jetpack/modules/shortcodes/css/rtl/slideshow-shortcode-rtl.css b/plugins/jetpack/modules/shortcodes/css/rtl/slideshow-shortcode-rtl.css index ec63975b..e69de29b 100644 --- a/plugins/jetpack/modules/shortcodes/css/rtl/slideshow-shortcode-rtl.css +++ b/plugins/jetpack/modules/shortcodes/css/rtl/slideshow-shortcode-rtl.css @@ -1,159 +0,0 @@ -/* This file was automatically generated on May 26 2015 21:25:53 */ - -.slideshow-window { - background-color: #222; - border: 20px solid #222; - border-radius: 10px; - height: 0; - margin-bottom: 20px; - overflow: hidden; - padding-top: 30px !important; - padding-bottom: 56.25% !important; - position: relative; - z-index: 1; -} - -.slideshow-window.slideshow-white { - background-color: #fff; - border-color: #fff; -} - -.slideshow-window, .slideshow-window * { - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; - box-sizing: content-box; -} - -.slideshow-loading { - height: 100%; - text-align: center; - margin: auto; -} - -body div.slideshow-window * img { - /* Override any styles that might be present in the page stylesheet */ - background-color: transparent !important; - background-image: none !important; - border-width: 0 !important; - display: block; - margin: 0 auto; - max-width: 100%; - max-height: 100%; - padding: 0 !important; - position: relative; - -webkit-transform: translateY(-50%); - -ms-transform: translateY(-50%); - transform: translateY(-50%); - top: 50%; -} - -.slideshow-loading img { - vertical-align: middle; -} - -.slideshow-slide { - display: none; - height: 100% !important; - right: 0; - margin: auto; - position: absolute; - text-align: center; - top: 0; - width: 100% !important; -} - -.slideshow-slide img { - vertical-align: middle; -} - -.slideshow-line-height-hack { - overflow: hidden; - width: 0px; - font-size: 0px; -} - -.slideshow-slide-caption { - font-size: 13px; - font-family: "Helvetica Neue", sans-serif; - color: #f7f7f7; - text-shadow: #222 2px 1px 1px; - line-height: 25px; - height: 25px; - position: absolute; - bottom: 5px; - right: 0; - z-index: 100; - width: 100%; - text-align: center; -} - -/* @noflip */ -.slideshow-controls { - z-index: 1000; - position: absolute; - bottom: 30px; - margin: auto; - text-align: center; - width: 100%; - -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; - opacity: 0.5; - direction:ltr; - -webkit-transition: 300ms opacity ease-out; - -moz-transition: 300ms opacity ease-out; - transition: 300ms opacity ease-out; -} - -.slideshow-window:hover .slideshow-controls { - -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; - opacity: 1; -} - -body div div.slideshow-controls a, -body div div.slideshow-controls a:hover { - border:2px solid rgba(255,255,255,0.1) !important; - background-color: #000 !important; - background-color: rgba(0,0,0,0.6) !important; - background-image: url('../../img/slideshow-controls.png') !important; - background-repeat: no-repeat; - background-size: 142px 16px !important; - background-position: -34px 8px !important; - color: #222 !important; - margin: 0 5px !important; - padding: 0 !important; - display: inline-block !important; - *display: inline; - zoom: 1; - height: 32px !important; - width: 32px !important; - line-height: 32px !important; - text-align: center !important; - -khtml-border-radius: 10em !important; - -webkit-border-radius: 10em !important; - -moz-border-radius: 10em !important; - border-radius: 10em !important; - -webkit-transition: 300ms border-color ease-out; - -moz-transition: 300ms border-color ease-out; - -o-transition: 300ms border-color ease-out; - transition: 300ms border-color ease-out; -} - -@media only screen and (-webkit-min-device-pixel-ratio: 1.5) { - body div div.slideshow-controls a, - body div div.slideshow-controls a:hover { - background-image: url('../../img/slideshow-controls-2x.png') !important; - } -} - -body div div.slideshow-controls a:hover { - border-color: rgba(255,255,255,1) !important; -} - -body div div.slideshow-controls a:first-child { background-position: -76px 8px !important;} -body div div.slideshow-controls a:last-child { background-position: -117px 8px !important;} -body div div.slideshow-controls a:nth-child(2) { background-position: -34px 8px !important;} -body div div.slideshow-controls a.running { background-position: -34px 8px !important;} -body div div.slideshow-controls a.paused { background-position: 9px 8px !important;} - -.slideshow-controls a img { - border: 50px dotted fuchsia; -} diff --git a/plugins/jetpack/modules/shortcodes/instagram.php b/plugins/jetpack/modules/shortcodes/instagram.php index dff94ee9..bebc19d3 100644 --- a/plugins/jetpack/modules/shortcodes/instagram.php +++ b/plugins/jetpack/modules/shortcodes/instagram.php @@ -5,7 +5,7 @@ * Embed Reversal for Instagram * * Hooked to pre_kses, converts an embed code from Instagram.com to an oEmbeddable URL. - * @return (string) the filtered or the original content + * @return string The filtered or the original content. **/ function jetpack_instagram_embed_reversal( $content ) { if ( ! is_string( $content ) || false === stripos( $content, 'instagram.com' ) ) { diff --git a/plugins/jetpack/modules/shortcodes/recipe.php b/plugins/jetpack/modules/shortcodes/recipe.php index 317e3acc..fb04f3e3 100644 --- a/plugins/jetpack/modules/shortcodes/recipe.php +++ b/plugins/jetpack/modules/shortcodes/recipe.php @@ -111,11 +111,8 @@ class Jetpack_Recipes { return; } - if ( is_rtl() ) { - wp_enqueue_style( 'jetpack-recipes-style', plugins_url( '/css/rtl/recipes-rtl.css', __FILE__ ), array(), '20130919' ); - } else { - wp_enqueue_style( 'jetpack-recipes-style', plugins_url( '/css/recipes.css', __FILE__ ), array(), '20130919' ); - } + wp_enqueue_style( 'jetpack-recipes-style', plugins_url( '/css/recipes.css', __FILE__ ), array(), '20130919' ); + wp_style_add_data( 'jetpack-recipes-style', 'rtl', 'replace' ); // add $themecolors-defined styles. wp_add_inline_style( 'jetpack-recipes-style', self::themecolor_styles() ); @@ -124,7 +121,8 @@ class Jetpack_Recipes { wp_enqueue_script( 'jetpack-recipes-js', plugins_url( '/js/recipes.js', __FILE__ ), array( 'jquery', 'jetpack-recipes-printthis' ), '20131230' ); $title_var = wp_title( '|', false, 'right' ); - $print_css_var = plugins_url( '/css/recipes-print.css', __FILE__ ); + $rtl = is_rtl() ? '-rtl' : ''; + $print_css_var = plugins_url( "/css/recipes-print{$rtl}.css", __FILE__ ); wp_localize_script( 'jetpack-recipes-js', diff --git a/plugins/jetpack/modules/shortcodes/slideshow.php b/plugins/jetpack/modules/shortcodes/slideshow.php index 9dd6f546..a4a37e11 100644 --- a/plugins/jetpack/modules/shortcodes/slideshow.php +++ b/plugins/jetpack/modules/shortcodes/slideshow.php @@ -271,11 +271,8 @@ class Jetpack_Slideshow_Shortcode { wp_enqueue_script( 'jquery-cycle', plugins_url( '/js/jquery.cycle.min.js', __FILE__ ), array( 'jquery' ), '20161231', true ); wp_enqueue_script( 'jetpack-slideshow', plugins_url( '/js/slideshow-shortcode.js', __FILE__ ), array( 'jquery-cycle' ), '20160119.1', true ); - if ( is_rtl() ) { - wp_enqueue_style( 'jetpack-slideshow', plugins_url( '/css/rtl/slideshow-shortcode-rtl.css', __FILE__ ) ); - } else { - wp_enqueue_style( 'jetpack-slideshow', plugins_url( '/css/slideshow-shortcode.css', __FILE__ ) ); - } + wp_enqueue_style( 'jetpack-slideshow', plugins_url( '/css/slideshow-shortcode.css', __FILE__ ) ); + wp_style_add_data( 'jetpack-slideshow', 'rtl', 'replace' ); wp_localize_script( 'jetpack-slideshow', diff --git a/plugins/jetpack/modules/simple-payments/simple-payments.php b/plugins/jetpack/modules/simple-payments/simple-payments.php index 7274024d..167c6008 100644 --- a/plugins/jetpack/modules/simple-payments/simple-payments.php +++ b/plugins/jetpack/modules/simple-payments/simple-payments.php @@ -35,7 +35,6 @@ class Jetpack_Simple_Payments { wp_register_script( 'paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), null, true ); wp_register_script( 'paypal-express-checkout', plugins_url( '/paypal-express-checkout.js', __FILE__ ), array( 'jquery', 'paypal-checkout-js' ), self::$version ); - wp_enqueue_style( 'simple-payments', plugins_url( '/simple-payments.css', __FILE__ ) ); } private function register_init_hook() { add_action( 'init', array( $this, 'init_hook_action' ) ); @@ -104,6 +103,9 @@ class Jetpack_Simple_Payments { if ( ! wp_script_is( 'paypal-express-checkout', 'enqueued' ) ) { wp_enqueue_script( 'paypal-express-checkout' ); } + if ( ! wp_style_is( 'simple-payments', 'enqueued' ) ) { + wp_enqueue_style( 'simple-payments', plugins_url( 'simple-payments.css', __FILE__ ) ); + } wp_add_inline_script( 'paypal-express-checkout', sprintf( "try{PaypalExpressCheckout.renderButton( '%d', '%d', '%s', '%d' );}catch(e){}", diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php new file mode 100644 index 00000000..1cf73c09 --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-fallback.php @@ -0,0 +1,146 @@ +<?php +/** + * The fallback buffer for users with no XML support. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing master sitemap xml files. + * + * @since 5.1.0 + */ +abstract class Jetpack_Sitemap_Buffer_Fallback extends Jetpack_Sitemap_Buffer { + + /** + * The buffer contents. + * + * @access protected + * @since 5.3.0 + * @var string The buffer contents. + */ + protected $buffer; + + public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) { + $this->is_full_flag = false; + $this->is_empty_flag = true; + $this->timestamp = $time; + + $this->finder = new Jetpack_Sitemap_Finder(); + + $this->item_capacity = max( 1, intval( $item_limit ) ); + $this->byte_capacity = max( 1, intval( $byte_limit ) ) - strlen( $this->contents() ); + } + + /** + * Append an item to the buffer, if there is room for it, + * and set is_empty_flag to false. If there is no room, + * we set is_full_flag to true. If $item is null, + * don't do anything and report success. + * + * @since 5.3.0 + * + * @param array $array The item to be added. + * + * @return bool True if the append succeeded, False if not. + */ + public function append( $array ) { + if ( is_null( $array ) ) { + return true; + } + + if ( $this->is_full_flag ) { + return false; + } + + if ( 0 >= $this->item_capacity || 0 >= $this->byte_capacity ) { + $this->is_full_flag = true; + return false; + } else { + $this->item_capacity -= 1; + $added_string = $this->array_to_xml_string( $array ); + $this->buffer .= $added_string; + $this->is_empty_flag = false; + + mbstring_binary_safe_encoding(); // So we can safely use strlen(). + $this->byte_capacity -= strlen( $added_string ); + reset_mbstring_encoding(); + + return true; + } + } + + /** + * Detect whether the buffer is empty. + * + * @since 5.3.0 + * + * @return bool True if the buffer is empty, false otherwise. + */ + public function is_empty() { + return $this->is_empty_flag; + } + + /** + * Retrieve the contents of the buffer. + * + * @since 5.3.0 + * + * @return string The contents of the buffer (with the footer included). + */ + public function contents() { + $root = $this->get_root_element(); + + return '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . $root[0] . $this->buffer . $root[1] . PHP_EOL; + } + + /** + * Legacy implementation of array to XML conversion without using DOMDocument. + * + * @param Array $array + * @return String $result + */ + public function array_to_xml_string( $array, $parent = null, $root = null ) { + $string = ''; + + foreach ( $array as $key => $value ) { + // Only allow a-z, A-Z, colon, underscore, and hyphen. + $tag = preg_replace( '/[^a-zA-Z:_-]/', '_', $key ); + + if ( is_array( $value ) ) { + $string .= "<$tag>"; + $string .= $this->array_to_xml_string( $value ); + $string .= "</$tag>"; + } elseif ( is_null( $value ) ) { + $string .= "<$tag />"; + } else { + $string .= "<$tag>" . htmlspecialchars( $value ) . "</$tag>"; + } + } + + return $string; + } + + /** + * Render an associative array of XML attribute key/value pairs. + * + * @access public + * @since 5.3.0 + * + * @param array $array Key/value array of attributes. + * + * @return string The rendered attribute string. + */ + public static function array_to_xml_attr_string( $array ) { + $string = ''; + + foreach ( $array as $key => $value ) { + $key = preg_replace( '/[^a-zA-Z:_-]/', '_', $key ); + $string .= ' ' . $key . '="' . esc_attr( $value ) . '"'; + } + + return $string; + } + +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-image-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-image-fallback.php new file mode 100644 index 00000000..1616574f --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-image-fallback.php @@ -0,0 +1,56 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Image + * extends the Jetpack_Sitemap_Buffer class to represent the single image sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing sitemap image xml files for users that have no libxml support. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_Image extends Jetpack_Sitemap_Buffer_Fallback { + + protected function get_root_element() { + if ( ! isset( $this->root ) ) { + + /** + * Filter the XML namespaces included in image sitemaps. + * + * @module sitemaps + * + * @since 4.8.0 + * + * @param array $namespaces Associative array with namespaces and namespace URIs. + */ + $namespaces = apply_filters( + 'jetpack_sitemap_image_ns', + array( + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', + 'xmlns:image' => 'http://www.google.com/schemas/sitemap-image/1.1', + ) + ); + + $sitemap_xsl_url = $this->finder->construct_sitemap_url( 'sitemap.xsl' ); + $jetpack_version = JETPACK__VERSION; + + $this->root = array( + "<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL + . "<?xml-stylesheet type='text/xsl' href='{$sitemap_xsl_url}'?>" . PHP_EOL + . '<urlset ' . $this->array_to_xml_attr_string( $namespaces ) . '>' . PHP_EOL, + '</urlset>' + ); + + $this->byte_capacity -= strlen( join( '', $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-image.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-image.php new file mode 100644 index 00000000..e452fcbf --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-image.php @@ -0,0 +1,68 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Image + * extends the Jetpack_Sitemap_Buffer class to represent the single image sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing sitemap image xml files. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_Image extends Jetpack_Sitemap_Buffer { + + public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) { + parent::__construct( $item_limit, $byte_limit, $time ); + + $this->doc->appendChild( + $this->doc->createComment( "generator='jetpack-" . JETPACK__VERSION . "'" ) + ); + + $this->doc->appendChild( + $this->doc->createProcessingInstruction( + 'xml-stylesheet', + 'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'image-sitemap.xsl' ) . '"' + ) + ); + } + + protected function get_root_element() { + if ( ! isset( $this->root ) ) { + + /** + * Filter the XML namespaces included in image sitemaps. + * + * @module sitemaps + * + * @since 4.8.0 + * + * @param array $namespaces Associative array with namespaces and namespace URIs. + */ + $namespaces = apply_filters( + 'jetpack_sitemap_image_ns', + array( + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', + 'xmlns:image' => 'http://www.google.com/schemas/sitemap-image/1.1', + ) + ); + + $this->root = $this->doc->createElement( 'urlset' ); + + foreach ( $namespaces as $name => $value ) { + $this->root->setAttribute( $name, $value ); + } + + $this->doc->appendChild( $this->root ); + $this->byte_capacity -= strlen( $this->doc->saveXML( $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-master-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-master-fallback.php new file mode 100644 index 00000000..af665547 --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-master-fallback.php @@ -0,0 +1,38 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Master + * extends the Jetpack_Sitemap_Buffer class to represent the master sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing master sitemap xml files for users without libxml support. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_Master extends Jetpack_Sitemap_Buffer_Fallback { + + protected function get_root_element() { + + if ( ! isset( $this->root ) ) { + + $sitemap_index_xsl_url = $this->finder->construct_sitemap_url( 'sitemap-index.xsl' ); + $jetpack_version = JETPACK__VERSION; + + $this->root = array( + "<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL + . "<?xml-stylesheet type='text/xsl' href='{$sitemap_index_xsl_url}'?>" . PHP_EOL + . "<sitemapindex xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>" . PHP_EOL, + '</sitemapindex>' + ); + + $this->byte_capacity -= strlen( join( '', $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-master.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-master.php new file mode 100644 index 00000000..fc6be602 --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-master.php @@ -0,0 +1,44 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Master + * extends the Jetpack_Sitemap_Buffer class to represent the master sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing master sitemap xml files. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_Master extends Jetpack_Sitemap_Buffer { + + public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) { + parent::__construct( $item_limit, $byte_limit, $time ); + + $this->doc->appendChild( + $this->doc->createComment( "generator='jetpack-" . JETPACK__VERSION . "'" ) + ); + + $this->doc->appendChild( + $this->doc->createProcessingInstruction( + 'xml-stylesheet', + 'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'sitemap-index.xsl' ) . '"' + ) + ); + } + + protected function get_root_element() { + if ( ! isset( $this->root ) ) { + $this->root = $this->doc->createElement( 'sitemapindex' ); + $this->root->setAttribute( 'xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9' ); + $this->doc->appendChild( $this->root ); + $this->byte_capacity -= strlen( $this->doc->saveXML( $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-news-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-news-fallback.php new file mode 100644 index 00000000..cca2c644 --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-news-fallback.php @@ -0,0 +1,56 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_News + * extends the Jetpack_Sitemap_Buffer class to represent the single news sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing sitemap image xml files for users without libxml support. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_News extends Jetpack_Sitemap_Buffer_Fallback { + + protected function get_root_element() { + if ( ! isset( $this->root ) ) { + + /** + * Filter the attribute value pairs used for namespace and namespace URI mappings. + * + * @module sitemaps + * + * @since 4.8.0 + * + * @param array $namespaces Associative array with namespaces and namespace URIs. + */ + $namespaces = apply_filters( + 'jetpack_sitemap_news_ns', + array( + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', + 'xmlns:news' => 'http://www.google.com/schemas/sitemap-news/0.9', + ) + ); + + $jetpack_version = JETPACK__VERSION; + $news_sitemap_xsl_url = $this->finder->construct_sitemap_url( 'news-sitemap.xsl' ); + + $this->root = array( + "<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL + . "<?xml-stylesheet type='text/xsl' href='{$news_sitemap_xsl_url}'?>" . PHP_EOL + . '<urlset ' . $this->array_to_xml_attr_string( $namespaces ) . '>', + '</urlset>' + ); + + $this->byte_capacity -= strlen( join( '', $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-news.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-news.php new file mode 100644 index 00000000..0e5b0327 --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-news.php @@ -0,0 +1,68 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_News + * extends the Jetpack_Sitemap_Buffer class to represent the single news sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing sitemap image xml files. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_News extends Jetpack_Sitemap_Buffer { + + public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) { + parent::__construct( $item_limit, $byte_limit, $time ); + + $this->doc->appendChild( + $this->doc->createComment( "generator='jetpack-" . JETPACK__VERSION . "'" ) + ); + + $this->doc->appendChild( + $this->doc->createProcessingInstruction( + 'xml-stylesheet', + 'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'news-sitemap.xsl' ) . '"' + ) + ); + } + + protected function get_root_element() { + if ( ! isset( $this->root ) ) { + + /** + * Filter the attribute value pairs used for namespace and namespace URI mappings. + * + * @module sitemaps + * + * @since 4.8.0 + * + * @param array $namespaces Associative array with namespaces and namespace URIs. + */ + $namespaces = apply_filters( + 'jetpack_sitemap_news_ns', + array( + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', + 'xmlns:news' => 'http://www.google.com/schemas/sitemap-news/0.9', + ) + ); + + $this->root = $this->doc->createElement( 'urlset' ); + + foreach ( $namespaces as $name => $value ) { + $this->root->setAttribute( $name, $value ); + } + + $this->doc->appendChild( $this->root ); + $this->byte_capacity -= strlen( $this->doc->saveXML( $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-page-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-page-fallback.php new file mode 100644 index 00000000..e64f31bc --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-page-fallback.php @@ -0,0 +1,55 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Page + * extends the Jetpack_Sitemap_Buffer class to represent the single page sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing sitemap page xml files for users with no libxml support. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_Page extends Jetpack_Sitemap_Buffer_Fallback { + + protected function get_root_element() { + if ( ! isset( $this->root ) ) { + + /** + * Filter the attribute value pairs used for namespace and namespace URI mappings. + * + * @module sitemaps + * + * @since 3.9.0 + * + * @param array $namespaces Associative array with namespaces and namespace URIs. + */ + $namespaces = apply_filters( + 'jetpack_sitemap_ns', + array( + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', + ) + ); + + $jetpack_version = JETPACK__VERSION; + $sitemap_xsl_url = $this->finder->construct_sitemap_url( 'sitemap.xsl' ); + + $this->root = array( + "<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL + . "<?xml-stylesheet type='text/xsl' href='{$sitemap_xsl_url}'?>" . PHP_EOL + . '<urlset ' . $this->array_to_xml_attr_string( $namespaces ) . '>', + '</urlset>' + ); + + $this->byte_capacity -= strlen( join( '', $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-page.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-page.php new file mode 100644 index 00000000..d6885900 --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-page.php @@ -0,0 +1,67 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Page + * extends the Jetpack_Sitemap_Buffer class to represent the single page sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing sitemap page xml files. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_Page extends Jetpack_Sitemap_Buffer { + + public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) { + parent::__construct( $item_limit, $byte_limit, $time ); + + $this->doc->appendChild( + $this->doc->createComment( "generator='jetpack-" . JETPACK__VERSION . "'" ) + ); + + $this->doc->appendChild( + $this->doc->createProcessingInstruction( + 'xml-stylesheet', + 'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'sitemap.xsl' ) . '"' + ) + ); + } + + protected function get_root_element() { + if ( ! isset( $this->root ) ) { + + /** + * Filter the attribute value pairs used for namespace and namespace URI mappings. + * + * @module sitemaps + * + * @since 3.9.0 + * + * @param array $namespaces Associative array with namespaces and namespace URIs. + */ + $namespaces = apply_filters( + 'jetpack_sitemap_ns', + array( + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', + ) + ); + + $this->root = $this->doc->createElement( 'urlset' ); + + foreach ( $namespaces as $name => $value ) { + $this->root->setAttribute( $name, $value ); + } + + $this->doc->appendChild( $this->root ); + $this->byte_capacity -= strlen( $this->doc->saveXML( $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php new file mode 100644 index 00000000..d211877d --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php @@ -0,0 +1,56 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Video + * extends the Jetpack_Sitemap_Buffer class to represent the single video sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing sitemap video xml files for users without libxml support. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_Video extends Jetpack_Sitemap_Buffer_Fallback { + + protected function get_root_element() { + if ( ! isset( $this->root ) ) { + + /** + * Filter the XML namespaces included in video sitemaps. + * + * @module sitemaps + * + * @since 4.8.0 + * + * @param array $namespaces Associative array with namespaces and namespace URIs. + */ + $namespaces = apply_filters( + 'jetpack_sitemap_video_ns', + array( + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', + 'xmlns:video' => 'http://www.google.com/schemas/sitemap-video/1.1', + ) + ); + + $video_sitemap_xsl_url = $this->finder->construct_sitemap_url( 'video-sitemap.xsl' ); + $jetpack_version = JETPACK__VERSION; + + $this->root = array( + "<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL + . "<?xml-stylesheet type='text/xsl' href='{$video_sitemap_xsl_url}'?>" . PHP_EOL + . '<urlset ' . $this->array_to_xml_attr_string( $namespaces ) . '>', + '</urlset>' + ); + + $this->byte_capacity -= strlen( join( '', $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-video.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video.php new file mode 100644 index 00000000..c6faff36 --- /dev/null +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video.php @@ -0,0 +1,68 @@ +<?php +/** + * Sitemaps (per the protocol) are essentially lists of XML fragments; + * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Video + * extends the Jetpack_Sitemap_Buffer class to represent the single video sitemap + * buffer. + * + * @since 5.3.0 + * @package Jetpack + */ + +/** + * A buffer for constructing sitemap video xml files. + * + * @since 5.3.0 + */ +class Jetpack_Sitemap_Buffer_Video extends Jetpack_Sitemap_Buffer { + + public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) { + parent::__construct( $item_limit, $byte_limit, $time ); + + $this->doc->appendChild( + $this->doc->createComment( "generator='jetpack-" . JETPACK__VERSION . "'" ) + ); + + $this->doc->appendChild( + $this->doc->createProcessingInstruction( + 'xml-stylesheet', + 'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'video-sitemap.xsl' ) . '"' + ) + ); + } + + protected function get_root_element() { + if ( ! isset( $this->root ) ) { + + /** + * Filter the XML namespaces included in video sitemaps. + * + * @module sitemaps + * + * @since 4.8.0 + * + * @param array $namespaces Associative array with namespaces and namespace URIs. + */ + $namespaces = apply_filters( + 'jetpack_sitemap_video_ns', + array( + 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', + 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', + 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', + 'xmlns:video' => 'http://www.google.com/schemas/sitemap-video/1.1', + ) + ); + + $this->root = $this->doc->createElement( 'urlset' ); + + foreach ( $namespaces as $name => $value ) { + $this->root->setAttribute( $name, $value ); + } + + $this->doc->appendChild( $this->root ); + $this->byte_capacity -= strlen( $this->doc->saveXML( $this->root ) ); + } + + return $this->root; + } +} diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer.php index f1a8d9b1..0853a49a 100644 --- a/plugins/jetpack/modules/sitemaps/sitemap-buffer.php +++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer.php @@ -22,70 +22,80 @@ * * @since 4.8.0 */ -class Jetpack_Sitemap_Buffer { +abstract class Jetpack_Sitemap_Buffer { /** * Largest number of items the buffer can hold. * - * @access private + * @access protected * @since 4.8.0 * @var int $item_capacity The item capacity. */ - private $item_capacity; + protected $item_capacity; /** * Largest number of bytes the buffer can hold. * - * @access private + * @access protected * @since 4.8.0 * @var int $byte_capacity The byte capacity. */ - private $byte_capacity; + protected $byte_capacity; /** - * Footer text of the buffer; stored here so it can be appended when the buffer is full. + * Flag which detects when the buffer is full. * - * @access private + * @access protected * @since 4.8.0 - * @var string $footer_text The footer text. + * @var bool $is_full_flag The flag value. This flag is set to false on construction and only flipped to true if we've tried to add something and failed. */ - private $footer_text; + protected $is_full_flag; /** - * The buffer contents. + * Flag which detects when the buffer is empty. * - * @access private + * @access protected * @since 4.8.0 - * @var string The buffer contents. + * @var bool $is_empty_flag The flag value. This flag is set to true on construction and only flipped to false if we've tried to add something and succeeded. */ - private $buffer; + protected $is_empty_flag; /** - * Flag which detects when the buffer is full. + * The most recent timestamp seen by the buffer. * - * @access private + * @access protected * @since 4.8.0 - * @var bool $is_full_flag The flag value. This flag is set to false on construction and only flipped to true if we've tried to add something and failed. + * @var string $timestamp Must be in 'YYYY-MM-DD hh:mm:ss' format. */ - private $is_full_flag; + protected $timestamp; /** - * Flag which detects when the buffer is empty. + * The DOM document object that is currently being used to construct the XML doc. * - * @access private - * @since 4.8.0 - * @var bool $is_empty_flag The flag value. This flag is set to true on construction and only flipped to false if we've tried to add something and succeeded. + * @access protected + * @since 5.3.0 + * @var DOMDocument $doc */ - private $is_empty_flag; + protected $doc = null; /** - * The most recent timestamp seen by the buffer. + * The root DOM element object that holds everything inside. Do not use directly, call + * the get_root_element getter method instead. * - * @access private - * @since 4.8.0 - * @var string $timestamp Must be in 'YYYY-MM-DD hh:mm:ss' format. + * @access protected + * @since 5.3.0 + * @var DOMElement $doc + */ + protected $root = null; + + /** + * Helper class to construct sitemap paths. + * + * @since 5.3.0 + * @protected + * @var Jetpack_Sitemap_Finder */ - private $timestamp; + protected $finder; /** * Construct a new Jetpack_Sitemap_Buffer. @@ -94,32 +104,29 @@ class Jetpack_Sitemap_Buffer { * * @param int $item_limit The maximum size of the buffer in items. * @param int $byte_limit The maximum size of the buffer in bytes. - * @param string $header The string to prepend to the entire buffer. - * @param string $footer The string to append to the entire buffer. * @param string $time The initial datetime of the buffer. Must be in 'YYYY-MM-DD hh:mm:ss' format. */ - public function __construct( - $item_limit, - $byte_limit, - $header = '', - $footer = '', - $time - ) { - $this->item_capacity = max( 1, intval( $item_limit ) ); - - mbstring_binary_safe_encoding(); // So we can safely use strlen(). - $this->byte_capacity = max( 1, intval( $byte_limit ) ) - strlen( $header ) - strlen( $footer ); - reset_mbstring_encoding(); - - $this->footer_text = $footer; - $this->buffer = $header; + public function __construct( $item_limit, $byte_limit, $time ) { $this->is_full_flag = false; - $this->is_empty_flag = true; $this->timestamp = $time; - return; + + $this->finder = new Jetpack_Sitemap_Finder(); + $this->doc = new DOMDocument( '1.0', 'UTF-8' ); + + $this->item_capacity = max( 1, intval( $item_limit ) ); + $this->byte_capacity = max( 1, intval( $byte_limit ) ) - strlen( $this->doc->saveXML() ); } /** + * Returns a DOM element that contains all sitemap elements. + * + * @access protected + * @since 5.3.0 + * @return DOMElement $root + */ + abstract protected function get_root_element(); + + /** * Append an item to the buffer, if there is room for it, * and set is_empty_flag to false. If there is no room, * we set is_full_flag to true. If $item is null, @@ -132,24 +139,45 @@ class Jetpack_Sitemap_Buffer { * @return bool True if the append succeeded, False if not. */ public function try_to_add_item( $item ) { - if ( is_null( $item ) ) { + _deprecated_function( + 'Jetpack_Sitemap_Buffer::try_to_add_item', + '5.3.0', + 'Jetpack_Sitemap_Buffer::append' + ); + $this->append( $item ); + } + + /** + * Append an item to the buffer, if there is room for it, + * and set is_empty_flag to false. If there is no room, + * we set is_full_flag to true. If $item is null, + * don't do anything and report success. + * + * @since 5.3.0 + * + * @param array $array The item to be added. + * + * @return bool True if the append succeeded, False if not. + */ + public function append( $array ) { + if ( is_null( $array ) ) { return true; + } + + if ( $this->is_full_flag ) { + return false; + } + + if ( 0 >= $this->item_capacity || 0 >= $this->byte_capacity ) { + $this->is_full_flag = true; + return false; } else { + $this->item_capacity -= 1; + $added_element = $this->array_to_xml_string( $array, $this->get_root_element(), $this->doc ); - mbstring_binary_safe_encoding(); // So we can safely use strlen(). - $item_size = strlen( $item ); // Size in bytes. - reset_mbstring_encoding(); + $this->byte_capacity -= strlen( $this->doc->saveXML( $added_element ) ); - if ( 0 >= $this->item_capacity || 0 > $this->byte_capacity - $item_size ) { - $this->is_full_flag = true; - return false; - } else { - $this->is_empty_flag = false; - $this->item_capacity -= 1; - $this->byte_capacity -= $item_size; - $this->buffer .= $item; - return true; - } + return true; } } @@ -161,7 +189,21 @@ class Jetpack_Sitemap_Buffer { * @return string The contents of the buffer (with the footer included). */ public function contents() { - return $this->buffer . $this->footer_text; + if( $this->is_empty() ) { + // The sitemap should have at least the root element added to the DOM + $this->get_root_element(); + } + return $this->doc->saveXML(); + } + + /** + * Retrieve the document object. + * + * @since 5.3.0 + * @return DOMDocument $doc + */ + public function get_document() { + return $this->doc; } /** @@ -183,7 +225,10 @@ class Jetpack_Sitemap_Buffer { * @return bool True if the buffer is empty, false otherwise. */ public function is_empty() { - return $this->is_empty_flag; + return ( + ! isset( $this->root ) + || ! $this->root->hasChildNodes() + ); } /** @@ -195,7 +240,6 @@ class Jetpack_Sitemap_Buffer { */ public function view_time( $new_time ) { $this->timestamp = max( $this->timestamp, $new_time ); - return; } /** @@ -231,56 +275,52 @@ class Jetpack_Sitemap_Buffer { * ), |</html> * ) * - * @access public + * @access protected * @since 3.9.0 * @since 4.8.0 Rename, add $depth parameter, and change return type. + * @since 5.3.0 Refactor, remove $depth parameter, add $parent and $root, make access protected. * * @param array $array A recursive associative array of tag/child relationships. - * @param string $depth String to prepend to each line. For internal use only. + * @param DOMElement $parent (optional) an element to which new children should be added. + * @param DOMDocument $root (optional) the parent document. * - * @return string The rendered XML string. + * @return string|DOMDocument The rendered XML string or an object if root element is specified. */ - public static function array_to_xml_string( $array, $depth = '' ) { - $string = ''; - - foreach ( $array as $key => $value ) { + protected function array_to_xml_string( $array, $parent = null, $root = null ) { + $return_string = false; - // Only allow a-z, A-Z, colon, underscore, and hyphen. - $tag = preg_replace( '/[^a-zA-Z:_-]/', '_', $key ); - - if ( is_array( $value ) ) { - $string .= $depth . "<$tag>\n"; - $string .= self::array_to_xml_string( $value, $depth . ' ' ); - $string .= $depth . "</$tag>\n"; - } elseif ( is_null( $value ) ) { - $string .= $depth . "<$tag />\n"; - } else { - $string .= $depth . "<$tag>" . ent2ncr( $value ) . "</$tag>\n"; - } + if ( null === $parent ) { + $return_string = true; + $parent = $root = new DOMDocument(); } - return $string; - } + if ( is_array( $array ) ) { - /** - * Render an associative array of XML attribute key/value pairs. - * - * @access public - * @since 4.8.0 - * - * @param array $array Key/value array of attributes. - * - * @return string The rendered attribute string. - */ - public static function array_to_xml_attr_string( $array ) { - $string = ''; + foreach ( $array as $key => $value ) { + $element = $root->createElement( $key ); + $parent->appendChild( $element ); - foreach ( $array as $key => $value ) { - $key = preg_replace( '/[^a-zA-Z:_-]/', '_', $key ); - $string .= ' ' . $key . '="' . esc_attr( $value ) . '"'; + if ( is_array( $value ) ) { + foreach ( $value as $child_key => $child_value ) { + $child = $root->createElement( $child_key ); + $element->appendChild( $child ); + $child->appendChild( self::array_to_xml_string( $child_value, $child, $root ) ); + } + } else { + $element->appendChild( + $root->createTextNode( $value ) + ); + } + } + } else { + $element = $root->createTextNode( $array ); + $parent->appendChild( $element ); } - return $string; + if ( $return_string ) { + return $root->saveHTML(); + } else { + return $element; + } } - } diff --git a/plugins/jetpack/modules/sitemaps/sitemap-builder.php b/plugins/jetpack/modules/sitemaps/sitemap-builder.php index cfd7b9a1..9cf91c24 100644 --- a/plugins/jetpack/modules/sitemaps/sitemap-builder.php +++ b/plugins/jetpack/modules/sitemaps/sitemap-builder.php @@ -9,6 +9,22 @@ require_once dirname( __FILE__ ) . '/sitemap-constants.php'; require_once dirname( __FILE__ ) . '/sitemap-buffer.php'; + +if ( ! class_exists( 'DOMDocument' ) ) { + require_once dirname( __FILE__ ) . '/sitemap-buffer-fallback.php'; + require_once dirname( __FILE__ ) . '/sitemap-buffer-image-fallback.php'; + require_once dirname( __FILE__ ) . '/sitemap-buffer-master-fallback.php'; + require_once dirname( __FILE__ ) . '/sitemap-buffer-news-fallback.php'; + require_once dirname( __FILE__ ) . '/sitemap-buffer-page-fallback.php'; + require_once dirname( __FILE__ ) . '/sitemap-buffer-video-fallback.php'; +} else { + require_once dirname( __FILE__ ) . '/sitemap-buffer-image.php'; + require_once dirname( __FILE__ ) . '/sitemap-buffer-master.php'; + require_once dirname( __FILE__ ) . '/sitemap-buffer-news.php'; + require_once dirname( __FILE__ ) . '/sitemap-buffer-page.php'; + require_once dirname( __FILE__ ) . '/sitemap-buffer-video.php'; +} + require_once dirname( __FILE__ ) . '/sitemap-librarian.php'; require_once dirname( __FILE__ ) . '/sitemap-finder.php'; require_once dirname( __FILE__ ) . '/sitemap-state.php'; @@ -87,8 +103,6 @@ class Jetpack_Sitemap_Builder { array( 'post', 'page' ) ) ); - - return; } /** @@ -101,6 +115,17 @@ class Jetpack_Sitemap_Builder { public function update_sitemap() { if ( $this->logger ) { $this->logger->report( '-- Updating...' ); + if ( ! class_exists( 'DOMDocument' ) ) { + $this->logger->report( + __( + '-- WARNING: Jetpack can not load necessary XML manipulation libraries. ' + . 'This can happen if XML support in PHP is not enabled on your server. ' + . 'XML support is highly recommended for WordPress and Jetpack, please enable ' + . 'it or contact your hosting provider about it.', + 'jetpack' + ) + ); + } } for ( $i = 1; $i <= JP_SITEMAP_UPDATE_SIZE; $i++ ) { @@ -201,12 +226,10 @@ class Jetpack_Sitemap_Builder { JP_PAGE_SITEMAP_TYPE ); die(); - } + } // End switch(). // Unlock the state. Jetpack_Sitemap_State::unlock(); - - return; } /** @@ -280,8 +303,6 @@ class Jetpack_Sitemap_Builder { $this->librarian->delete_numbered_sitemap_rows_after( $state['number'] + 1, $sitemap_type ); - - return; } /** @@ -387,29 +408,13 @@ class Jetpack_Sitemap_Builder { * @since 4.8.0 */ private function build_master_sitemap( $max ) { - $sitemap_index_xsl_url = $this->finder->construct_sitemap_url( 'sitemap-index.xsl' ); - $jetpack_version = JETPACK__VERSION; - if ( $this->logger ) { $this->logger->report( '-- Building Master Sitemap.' ); } - $buffer = new Jetpack_Sitemap_Buffer( + $buffer = new Jetpack_Sitemap_Buffer_Master( JP_SITEMAP_MAX_ITEMS, - JP_SITEMAP_MAX_BYTES, - <<<HEADER -<?xml version='1.0' encoding='UTF-8'?> -<!-- generator='jetpack-{$jetpack_version}' --> -<?xml-stylesheet type='text/xsl' href='{$sitemap_index_xsl_url}'?> -<sitemapindex xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'> -HEADER - , - <<<FOOTER -</sitemapindex>\n -FOOTER - , - /* epoch */ - '1970-01-01 00:00:00' + JP_SITEMAP_MAX_BYTES ); if ( 0 < $max[ JP_PAGE_SITEMAP_TYPE ]['number'] ) { @@ -424,14 +429,14 @@ FOOTER $page['last_modified'] = jp_sitemap_datetime( $max[ JP_PAGE_SITEMAP_INDEX_TYPE ]['lastmod'] ); } - $buffer->try_to_add_item( Jetpack_Sitemap_Buffer::array_to_xml_string( + $buffer->append( array( 'sitemap' => array( 'loc' => $this->finder->construct_sitemap_url( $page['filename'] ), 'lastmod' => $page['last_modified'], ), ) - ) ); + ); } if ( 0 < $max[ JP_IMAGE_SITEMAP_TYPE ]['number'] ) { @@ -446,14 +451,14 @@ FOOTER $image['last_modified'] = jp_sitemap_datetime( $max[ JP_IMAGE_SITEMAP_INDEX_TYPE ]['lastmod'] ); } - $buffer->try_to_add_item( Jetpack_Sitemap_Buffer::array_to_xml_string( + $buffer->append( array( 'sitemap' => array( 'loc' => $this->finder->construct_sitemap_url( $image['filename'] ), 'lastmod' => $image['last_modified'], ), ) - ) ); + ); } if ( 0 < $max[ JP_VIDEO_SITEMAP_TYPE ]['number'] ) { @@ -468,14 +473,14 @@ FOOTER $video['last_modified'] = $max[ JP_VIDEO_SITEMAP_INDEX_TYPE ]['lastmod']; } - $buffer->try_to_add_item( Jetpack_Sitemap_Buffer::array_to_xml_string( + $buffer->append( array( 'sitemap' => array( 'loc' => $this->finder->construct_sitemap_url( $video['filename'] ), 'lastmod' => $video['last_modified'], ), ) - ) ); + ); } $this->librarian->store_sitemap_data( @@ -484,8 +489,6 @@ FOOTER $buffer->contents(), '' ); - - return; } /** @@ -514,46 +517,9 @@ FOOTER $this->logger->report( "-- Building $debug_name" ); } - $sitemap_xsl_url = $this->finder->construct_sitemap_url( 'sitemap.xsl' ); - - $jetpack_version = JETPACK__VERSION; - - $namespaces = Jetpack_Sitemap_Buffer::array_to_xml_attr_string( - /** - * Filter the attribute value pairs used for namespace and namespace URI mappings. - * - * @module sitemaps - * - * @since 3.9.0 - * - * @param array $namespaces Associative array with namespaces and namespace URIs. - */ - apply_filters( - 'jetpack_sitemap_ns', - array( - 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', - 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', - ) - ) - ); - - $buffer = new Jetpack_Sitemap_Buffer( + $buffer = new Jetpack_Sitemap_Buffer_Page( JP_SITEMAP_MAX_ITEMS, - JP_SITEMAP_MAX_BYTES, - <<<HEADER -<?xml version='1.0' encoding='UTF-8'?> -<!-- generator='jetpack-{$jetpack_version}' --> -<?xml-stylesheet type='text/xsl' href='{$sitemap_xsl_url}'?> -<urlset{$namespaces}>\n -HEADER - , - <<<FOOTER -</urlset>\n -FOOTER - , - /* epoch */ - '1970-01-01 00:00:00' + JP_SITEMAP_MAX_BYTES ); // Add entry for the main page (only if we're at the first one). @@ -576,7 +542,7 @@ FOOTER */ $item_array = apply_filters( 'jetpack_sitemap_url_home', $item_array ); - $buffer->try_to_add_item( Jetpack_Sitemap_Buffer::array_to_xml_string( $item_array ) ); + $buffer->append( $item_array ); } // Add as many items to the buffer as possible. @@ -593,7 +559,7 @@ FOOTER foreach ( $posts as $post ) { $current_item = $this->post_to_sitemap_item( $post ); - if ( true === $buffer->try_to_add_item( $current_item['xml'] ) ) { + if ( true === $buffer->append( $current_item['xml'] ) ) { $last_post_id = $post->ID; $buffer->view_time( $current_item['last_modified'] ); } else { @@ -613,13 +579,14 @@ FOOTER * @module sitemaps * * @since 3.9.0 + * @since 5.3.0 returns an element of DOMDocument type instead of SimpleXMLElement * - * @param SimpleXMLElement $tree Data tree for sitemap. + * @param DOMDocument $doc Data tree for sitemap. * @param string $last_modified Date of last modification. */ $tree = apply_filters( 'jetpack_print_sitemap', - simplexml_load_string( $buffer->contents() ), + $buffer->get_document(), $buffer->last_modified() ); @@ -627,7 +594,7 @@ FOOTER $this->librarian->store_sitemap_data( $number, JP_PAGE_SITEMAP_TYPE, - $tree->asXML(), + $buffer->contents(), $buffer->last_modified() ); @@ -668,47 +635,9 @@ FOOTER $this->logger->report( "-- Building $debug_name" ); } - $image_sitemap_xsl_url = $this->finder->construct_sitemap_url( 'image-sitemap.xsl' ); - - $jetpack_version = JETPACK__VERSION; - - $namespaces = Jetpack_Sitemap_Buffer::array_to_xml_attr_string( - /** - * Filter the XML namespaces included in image sitemaps. - * - * @module sitemaps - * - * @since 4.8.0 - * - * @param array $namespaces Associative array with namespaces and namespace URIs. - */ - apply_filters( - 'jetpack_sitemap_image_ns', - array( - 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', - 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', - 'xmlns:image' => 'http://www.google.com/schemas/sitemap-image/1.1', - ) - ) - ); - - $buffer = new Jetpack_Sitemap_Buffer( + $buffer = new Jetpack_Sitemap_Buffer_Image( JP_SITEMAP_MAX_ITEMS, - JP_SITEMAP_MAX_BYTES, - <<<HEADER -<?xml version='1.0' encoding='UTF-8'?> -<!-- generator='jetpack-{$jetpack_version}' --> -<?xml-stylesheet type='text/xsl' href='{$image_sitemap_xsl_url}'?> -<urlset{$namespaces}>\n -HEADER - , - <<<FOOTER -</urlset>\n -FOOTER - , - /* epoch */ - '1970-01-01 00:00:00' + JP_SITEMAP_MAX_BYTES ); // Add as many items to the buffer as possible. @@ -725,7 +654,7 @@ FOOTER foreach ( $posts as $post ) { $current_item = $this->image_post_to_sitemap_item( $post ); - if ( true === $buffer->try_to_add_item( $current_item['xml'] ) ) { + if ( true === $buffer->append( $current_item['xml'] ) ) { $last_post_id = $post->ID; $buffer->view_time( $current_item['last_modified'] ); } else { @@ -784,47 +713,9 @@ FOOTER $this->logger->report( "-- Building $debug_name" ); } - $video_sitemap_xsl_url = $this->finder->construct_sitemap_url( 'video-sitemap.xsl' ); - - $jetpack_version = JETPACK__VERSION; - - $namespaces = Jetpack_Sitemap_Buffer::array_to_xml_attr_string( - /** - * Filter the XML namespaces included in video sitemaps. - * - * @module sitemaps - * - * @since 4.8.0 - * - * @param array $namespaces Associative array with namespaces and namespace URIs. - */ - apply_filters( - 'jetpack_sitemap_video_ns', - array( - 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', - 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', - 'xmlns:video' => 'http://www.google.com/schemas/sitemap-video/1.1', - ) - ) - ); - - $buffer = new Jetpack_Sitemap_Buffer( + $buffer = new Jetpack_Sitemap_Buffer_Video( JP_SITEMAP_MAX_ITEMS, - JP_SITEMAP_MAX_BYTES, - <<<HEADER -<?xml version='1.0' encoding='UTF-8'?> -<!-- generator='jetpack-{$jetpack_version}' --> -<?xml-stylesheet type='text/xsl' href='{$video_sitemap_xsl_url}'?> -<urlset{$namespaces}>\n -HEADER - , - <<<FOOTER -</urlset>\n -FOOTER - , - /* epoch */ - '1970-01-01 00:00:00' + JP_SITEMAP_MAX_BYTES ); // Add as many items to the buffer as possible. @@ -841,7 +732,7 @@ FOOTER foreach ( $posts as $post ) { $current_item = $this->video_post_to_sitemap_item( $post ); - if ( true === $buffer->try_to_add_item( $current_item['xml'] ) ) { + if ( true === $buffer->append( $current_item['xml'] ) ) { $last_post_id = $post->ID; $buffer->view_time( $current_item['last_modified'] ); } else { @@ -908,25 +799,9 @@ FOOTER $this->logger->report( "-- Building $index_debug_name" ); } - $sitemap_index_xsl_url = $this->finder->construct_sitemap_url( 'sitemap-index.xsl' ); - - $jetpack_version = JETPACK__VERSION; - - $buffer = new Jetpack_Sitemap_Buffer( + $buffer = new Jetpack_Sitemap_Buffer_Master( JP_SITEMAP_MAX_ITEMS, JP_SITEMAP_MAX_BYTES, - <<<HEADER -<?xml version='1.0' encoding='UTF-8'?> -<!-- generator='jetpack-{$jetpack_version}' --> -<?xml-stylesheet type='text/xsl' href='{$sitemap_index_xsl_url}'?> -<sitemapindex xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>\n -HEADER - , - <<<FOOTER -</sitemapindex>\n -FOOTER - , - /* initial last_modified value */ $datetime ); @@ -944,7 +819,7 @@ FOOTER ), ); - $buffer->try_to_add_item( Jetpack_Sitemap_Buffer::array_to_xml_string( $item_array ) ); + $buffer->append( $item_array ); } // Add as many items to the buffer as possible. @@ -966,7 +841,7 @@ FOOTER $current_item = $this->sitemap_row_to_index_item( (array) $post ); // Try adding this item to the buffer. - if ( true === $buffer->try_to_add_item( $current_item['xml'] ) ) { + if ( true === $buffer->append( $current_item['xml'] ) ) { $last_sitemap_id = $post['ID']; $buffer->view_time( $current_item['last_modified'] ); } else { @@ -1023,7 +898,7 @@ FOOTER ); return array( - 'xml' => Jetpack_Sitemap_Buffer::array_to_xml_string( $item_array ), + 'xml' => $item_array, 'last_modified' => $row['post_date'], ); } @@ -1046,10 +921,6 @@ FOOTER $this->logger->report( 'Beginning news sitemap generation.' ); } - $news_sitemap_xsl_url = $this->finder->construct_sitemap_url( 'news-sitemap.xsl' ); - - $jetpack_version = JETPACK__VERSION; - /** * Filter limit of entries to include in news sitemap. * @@ -1064,43 +935,9 @@ FOOTER JP_NEWS_SITEMAP_MAX_ITEMS ); - $namespaces = Jetpack_Sitemap_Buffer::array_to_xml_attr_string( - /** - * Filter the attribute value pairs used for namespace and namespace URI mappings. - * - * @module sitemaps - * - * @since 4.8.0 - * - * @param array $namespaces Associative array with namespaces and namespace URIs. - */ - apply_filters( - 'jetpack_sitemap_news_ns', - array( - 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', - 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', - 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', - 'xmlns:news' => 'http://www.google.com/schemas/sitemap-news/0.9', - ) - ) - ); - - $buffer = new Jetpack_Sitemap_Buffer( + $buffer = new Jetpack_Sitemap_Buffer_News( min( $item_limit, JP_NEWS_SITEMAP_MAX_ITEMS ), - JP_SITEMAP_MAX_BYTES, - <<<HEADER -<?xml version='1.0' encoding='UTF-8'?> -<!-- generator='jetpack-{$jetpack_version}' --> -<?xml-stylesheet type='text/xsl' href='{$news_sitemap_xsl_url}'?> -<urlset{$namespaces}>\n -HEADER - , - <<<FOOTER -</urlset>\n -FOOTER - , - /* epoch */ - '1970-01-01 00:00:00' + JP_SITEMAP_MAX_BYTES ); $posts = $this->librarian->query_most_recent_posts( JP_NEWS_SITEMAP_MAX_ITEMS ); @@ -1108,7 +945,7 @@ FOOTER foreach ( $posts as $post ) { $current_item = $this->post_to_news_sitemap_item( $post ); - if ( false === $buffer->try_to_add_item( $current_item['xml'] ) ) { + if ( false === $buffer->append( $current_item['xml'] ) ) { break; } } @@ -1124,7 +961,7 @@ FOOTER $the_stored_news_sitemap, JP_NEWS_SITEMAP_INTERVAL ); - } + } // End if(). return $the_stored_news_sitemap; } @@ -1138,7 +975,7 @@ FOOTER * * @param WP_Post $post The post to be processed. * - * @return string An XML fragment representing the post URL. + * @return array An array representing the post URL. */ private function post_to_sitemap_item( $post ) { @@ -1200,7 +1037,7 @@ FOOTER $item_array = apply_filters( 'jetpack_sitemap_url', $item_array, $post->ID ); return array( - 'xml' => Jetpack_Sitemap_Buffer::array_to_xml_string( $item_array ), + 'xml' => $item_array, 'last_modified' => $last_modified, ); } @@ -1236,11 +1073,11 @@ FOOTER ); } - $url = esc_url( wp_get_attachment_url( $post->ID ) ); + $url = wp_get_attachment_url( $post->ID ); - $parent_url = esc_url( get_permalink( get_post( $post->post_parent ) ) ); + $parent_url = get_permalink( get_post( $post->post_parent ) ); if ( '' == $parent_url ) { // WPCS: loose comparison ok. - $parent_url = esc_url( get_permalink( $post ) ); + $parent_url = get_permalink( $post ); } $item_array = array( @@ -1252,16 +1089,9 @@ FOOTER ), ), ); - /** This filter is already documented in core/wp-includes/feed.php */ - $title = apply_filters( 'the_title_rss', $post->post_title ); - if ( '' !== $title ) { - $item_array['url']['image:image']['image:title'] = htmlentities( $title ); - } - /** This filter is already documented in core/wp-includes/feed.php */ - $caption = apply_filters( 'the_excerpt_rss', $post->post_excerpt ); - if ( '' !== $caption ) { - $item_array['url']['image:image']['image:caption'] = "<![CDATA[" . $caption . "]]>"; - } + + $item_array['url']['image:image']['image:title'] = $post->post_title; + $item_array['url']['image:image']['image:caption'] = $post->post_excerpt; /** * Filter associative array with data to build <url> node @@ -1281,7 +1111,7 @@ FOOTER ); return array( - 'xml' => Jetpack_Sitemap_Buffer::array_to_xml_string( $item_array ), + 'xml' => $item_array, 'last_modified' => $post->post_modified_gmt, ); } @@ -1323,11 +1153,11 @@ FOOTER $parent_url = esc_url( get_permalink( $post ) ); } - // Prepare the content like get_the_content_feed() + // Prepare the content like get_the_content_feed(). $content = $post->post_content; /** This filter is already documented in core/wp-includes/post-template.php */ $content = apply_filters( 'the_content', $content ); - $content = str_replace(']]>', ']]>', $content); + /** This filter is already documented in core/wp-includes/feed.php */ $content = apply_filters( 'the_content_feed', $content, 'rss2' ); @@ -1339,7 +1169,7 @@ FOOTER /** This filter is already documented in core/wp-includes/feed.php */ 'video:title' => apply_filters( 'the_title_rss', $post->post_title ), 'video:thumbnail_loc' => '', - 'video:description' => '<![CDATA[' . $content . ']]>', + 'video:description' => $content, 'video:content_loc' => esc_url( wp_get_attachment_url( $post->ID ) ), ), ), @@ -1366,7 +1196,7 @@ FOOTER ); return array( - 'xml' => Jetpack_Sitemap_Buffer::array_to_xml_string( $item_array ), + 'xml' => $item_array, 'last_modified' => $post->post_modified_gmt, ); } @@ -1430,7 +1260,7 @@ FOOTER 'lastmod' => jp_sitemap_datetime( $post->post_modified_gmt ), 'news:news' => array( 'news:publication' => array( - 'news:name' => esc_html( get_bloginfo( 'name' ) ), + 'news:name' => get_bloginfo( 'name' ), 'news:language' => $language, ), /** This filter is already documented in core/wp-includes/feed.php */ @@ -1459,8 +1289,7 @@ FOOTER ); return array( - 'xml' => Jetpack_Sitemap_Buffer::array_to_xml_string( $item_array ), + 'xml' => $item_array, ); } - } diff --git a/plugins/jetpack/modules/sitemaps/sitemap-librarian.php b/plugins/jetpack/modules/sitemaps/sitemap-librarian.php index ac895749..89a86830 100644 --- a/plugins/jetpack/modules/sitemaps/sitemap-librarian.php +++ b/plugins/jetpack/modules/sitemaps/sitemap-librarian.php @@ -39,7 +39,14 @@ class Jetpack_Sitemap_Librarian { * } */ public function read_sitemap_data( $name, $type ) { - $the_post = get_page_by_title( $name, 'OBJECT', $type ); + $post_array = get_posts( array( + 'numberposts' => 1, + 'title' => $name, + 'post_type' => $type, + 'post_status' => 'draft' + ) ); + + $the_post = array_shift( $post_array ); if ( null === $the_post ) { return null; @@ -49,15 +56,14 @@ class Jetpack_Sitemap_Librarian { 'timestamp' => $the_post->post_date, 'name' => $the_post->post_title, 'type' => $the_post->post_type, - 'text' => $the_post->post_content, + 'text' => base64_decode( $the_post->post_content ), ); } } /** * Store a sitemap of given type and index in the database. - * Note that the sitemap contents are run through esc_html before - * being stored, and the timestamp reencoded as 'Y-m-d H:i:s'. + * Note that the timestamp is reencoded as 'Y-m-d H:i:s'. * * If a sitemap with that type and name does not exist, create it. * If a sitemap with that type and name does exist, update it. @@ -73,27 +79,26 @@ class Jetpack_Sitemap_Librarian { public function store_sitemap_data( $index, $type, $contents, $timestamp ) { $name = jp_sitemap_filename( $type, $index ); - $the_post = get_page_by_title( $name, 'OBJECT', $type ); + $the_post = $this->read_sitemap_data( $name, $type ); if ( null === $the_post ) { // Post does not exist. wp_insert_post(array( 'post_title' => $name, - 'post_content' => esc_html( $contents ), + 'post_content' => base64_encode( $contents ), 'post_type' => $type, 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ), )); } else { // Post does exist. wp_insert_post(array( - 'ID' => $the_post->ID, + 'ID' => $the_post['id'], 'post_title' => $name, - 'post_content' => esc_html( $contents ), + 'post_content' => base64_encode( $contents ), 'post_type' => $type, 'post_date' => date( 'Y-m-d H:i:s', strtotime( $timestamp ) ), )); } - return; } /** @@ -108,12 +113,12 @@ class Jetpack_Sitemap_Librarian { * @return bool 'true' if a row was deleted, 'false' otherwise. */ public function delete_sitemap_data( $name, $type ) { - $the_post = get_page_by_title( $name, 'OBJECT', $type ); + $the_post = $this->read_sitemap_data( $name, $type ); if ( null === $the_post ) { return false; } else { - wp_delete_post( $the_post->ID ); + wp_delete_post( $the_post['id'] ); return true; } } @@ -137,7 +142,7 @@ class Jetpack_Sitemap_Librarian { if ( null === $row ) { return ''; } else { - return wp_specialchars_decode( $row['text'], ENT_QUOTES ); + return $row['text']; } } @@ -159,8 +164,6 @@ class Jetpack_Sitemap_Librarian { $name = jp_sitemap_filename( $type, $position ); $any_left = $this->delete_sitemap_data( $name, $type ); } - - return; } /** @@ -170,35 +173,33 @@ class Jetpack_Sitemap_Librarian { * @since 4.8.0 */ public function delete_all_stored_sitemap_data() { - $this->delete_sitemap_data( - jp_sitemap_filename( JP_MASTER_SITEMAP_TYPE ), - JP_MASTER_SITEMAP_TYPE - ); - - $this->delete_numbered_sitemap_rows_after( - 0, JP_PAGE_SITEMAP_TYPE - ); - - $this->delete_numbered_sitemap_rows_after( - 0, JP_PAGE_SITEMAP_INDEX_TYPE - ); - - $this->delete_numbered_sitemap_rows_after( - 0, JP_IMAGE_SITEMAP_TYPE - ); - - $this->delete_numbered_sitemap_rows_after( - 0, JP_IMAGE_SITEMAP_INDEX_TYPE - ); - - $this->delete_numbered_sitemap_rows_after( - 0, JP_VIDEO_SITEMAP_TYPE - ); + $this->delete_sitemap_type_data( JP_MASTER_SITEMAP_TYPE ); + $this->delete_sitemap_type_data( JP_PAGE_SITEMAP_TYPE ); + $this->delete_sitemap_type_data( JP_PAGE_SITEMAP_INDEX_TYPE ); + $this->delete_sitemap_type_data( JP_IMAGE_SITEMAP_TYPE ); + $this->delete_sitemap_type_data( JP_IMAGE_SITEMAP_INDEX_TYPE ); + $this->delete_sitemap_type_data( JP_VIDEO_SITEMAP_TYPE ); + $this->delete_sitemap_type_data( JP_VIDEO_SITEMAP_INDEX_TYPE ); + } - $this->delete_numbered_sitemap_rows_after( - 0, JP_VIDEO_SITEMAP_INDEX_TYPE - ); - return; + /** + * Deletes all sitemap data of specific type + * + * @access protected + * @since 5.3.0 + * + * @param String $type + */ + protected function delete_sitemap_type_data( $type ) { + $ids = get_posts( array( + 'post_type' => $type, + 'post_status' => 'draft', + 'fields' => 'ids' + ) ); + + foreach( $ids as $id ) { + wp_trash_post( $id ); + } } /** diff --git a/plugins/jetpack/modules/sitemaps/sitemaps.php b/plugins/jetpack/modules/sitemaps/sitemaps.php index 3620957c..2c433a1d 100644 --- a/plugins/jetpack/modules/sitemaps/sitemaps.php +++ b/plugins/jetpack/modules/sitemaps/sitemaps.php @@ -108,6 +108,12 @@ class Jetpack_Sitemap_Manager { 10 ); + // In case we need to purge all sitemaps, we do this. + add_action( + 'jetpack_sitemaps_purge_data', + array( $this, 'callback_action_purge_data' ) + ); + /* * Module parameters are stored as options in the database. * This allows us to avoid having to process all of init @@ -434,6 +440,17 @@ class Jetpack_Sitemap_Manager { } /** + * Callback for resetting stored sitemap data. + * + * @access public + * @since 5.3.0 + */ + public function callback_action_purge_data() { + $this->callback_action_flush_news_sitemap_cache(); + $this->librarian->delete_all_stored_sitemap_data(); + } + + /** * Callback to set the sitemap location. * * @access public diff --git a/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php b/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php index f7c6eb92..fed7601b 100644 --- a/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php +++ b/plugins/jetpack/modules/sso/class.jetpack-sso-helpers.php @@ -191,10 +191,7 @@ class Jetpack_SSO_Helpers { $hosts[] = 'jetpack.wordpress.com'; $hosts[] = 'public-api.wordpress.com'; - if ( - ( Jetpack::is_development_mode() || Jetpack::is_development_version() ) && - ( false === strpos( $api_base, 'jetpack.wordpress.com/jetpack' ) ) - ) { + if ( false === strpos( $api_base, 'jetpack.wordpress.com/jetpack' ) ) { $base_url_parts = parse_url( esc_url_raw( $api_base ) ); if ( $base_url_parts && ! empty( $base_url_parts[ 'host' ] ) ) { $hosts[] = $base_url_parts[ 'host' ]; diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php index 0cc0b9cb..b3421aae 100644 --- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php +++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery.php @@ -90,11 +90,8 @@ class Jetpack_Tiled_Gallery { public static function default_scripts_and_styles() { wp_enqueue_script( 'tiled-gallery', plugins_url( 'tiled-gallery/tiled-gallery.js', __FILE__ ), array( 'jquery' ) ); - if( is_rtl() ) { - wp_enqueue_style( 'tiled-gallery', plugins_url( 'tiled-gallery/rtl/tiled-gallery-rtl.css', __FILE__ ), array(), '2012-09-21' ); - } else { - wp_enqueue_style( 'tiled-gallery', plugins_url( 'tiled-gallery/tiled-gallery.css', __FILE__ ), array(), '2012-09-21' ); - } + wp_enqueue_style( 'tiled-gallery', plugins_url( 'tiled-gallery/tiled-gallery.css', __FILE__ ), array(), '2012-09-21' ); + wp_style_add_data( 'tiled-gallery', 'rtl', 'replace' ); } public function gallery_shortcode( $val, $atts ) { diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php index 4898faea..a25be268 100644 --- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php +++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/templates/partials/carousel-image-args.php @@ -18,7 +18,7 @@ data-orig-file="<?php echo esc_url( wp_get_attachment_url( $item->image->ID ) ); data-orig-size="<?php echo esc_attr( $item->meta_width() ); ?>,<?php echo esc_attr( $item->meta_height() ); ?>" data-comments-opened="<?php echo esc_attr( comments_open( $item->image->ID ) ); ?>" data-image-meta="<?php echo _wp_specialchars( wp_check_invalid_utf8( $fuzzy_image_meta ), ENT_QUOTES, false, true ); ?>" -data-image-title="<?php echo esc_attr( wptexturize( $item->image->post_title ) ); ?>" -data-image-description="<?php echo esc_attr( wpautop( wptexturize( $item->image->post_content ) ) ); ?>" +data-image-title="<?php echo esc_attr( htmlspecialchars( wptexturize( $item->image->post_title ) ) ); ?>" +data-image-description="<?php echo esc_attr( htmlspecialchars( wpautop( wptexturize( $item->image->post_content ) ) ) ); ?>" data-medium-file="<?php echo esc_url( $item->medium_file() ); ?>" data-large-file="<?php echo esc_url( $item->large_file() ); ?>" diff --git a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery.js b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery.js index 44a79f71..f8f02f37 100644 --- a/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery.js +++ b/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery.js @@ -142,8 +142,12 @@ $( document ).ready( function() { var tiledGalleries = new TiledGalleryCollection(); - $( 'body' ).on( 'post-load', function() { - tiledGalleries.findAndSetupNewGalleries(); + $( 'body' ).on( 'post-load', function( e, maybeResize ) { + if ( 'string' === typeof maybeResize && 'resize' === maybeResize ) { + tiledGalleries.resizeAll(); + } else { + tiledGalleries.findAndSetupNewGalleries(); + } } ); $( document ).on( 'page-rendered.wpcom-newdash', function() { tiledGalleries.findAndSetupNewGalleries(); diff --git a/plugins/jetpack/modules/videopress/shortcode.php b/plugins/jetpack/modules/videopress/shortcode.php index 3e185bbb..8c87fee4 100644 --- a/plugins/jetpack/modules/videopress/shortcode.php +++ b/plugins/jetpack/modules/videopress/shortcode.php @@ -127,7 +127,7 @@ class VideoPress_Shortcode { $options = apply_filters( 'videopress_shortcode_options', array( 'at' => (int) $attr['at'], 'hd' => $attr['hd'], - 'loop' => $attr['autoplay'] || $attr['loop'], + 'loop' => $attr['loop'], 'freedom' => $attr['freedom'], 'autoplay' => $attr['autoplay'], 'permalink' => $attr['permalink'], diff --git a/plugins/jetpack/modules/widget-visibility/widget-conditions.php b/plugins/jetpack/modules/widget-visibility/widget-conditions.php index 5f8658f4..e85b25ae 100644 --- a/plugins/jetpack/modules/widget-visibility/widget-conditions.php +++ b/plugins/jetpack/modules/widget-visibility/widget-conditions.php @@ -21,12 +21,8 @@ class Jetpack_Widget_Conditions { } public static function widget_admin_setup() { - if( is_rtl() ) { - wp_enqueue_style( 'widget-conditions', plugins_url( 'widget-conditions/rtl/widget-conditions-rtl.css', __FILE__ ) ); - } else { - wp_enqueue_style( 'widget-conditions', plugins_url( 'widget-conditions/widget-conditions.css', __FILE__ ) ); - } wp_enqueue_style( 'widget-conditions', plugins_url( 'widget-conditions/widget-conditions.css', __FILE__ ) ); + wp_style_add_data( 'widget-conditions', 'rtl', 'replace' ); wp_enqueue_script( 'widget-conditions', plugins_url( 'widget-conditions/widget-conditions.js', __FILE__ ), array( 'jquery', 'jquery-ui-core' ), 20140721, true ); // Set up a single copy of all of the data that Widget Visibility needs. @@ -123,7 +119,22 @@ class Jetpack_Widget_Conditions { $widget_conditions_data['taxonomy'] = array(); $widget_conditions_data['taxonomy'][] = array( '', __( 'All taxonomy pages', 'jetpack' ) ); - $taxonomies = get_taxonomies( array( '_builtin' => false ), 'objects' ); + $taxonomies = get_taxonomies( + /** + * Filters args passed to get_taxonomies. + * + * @see https://developer.wordpress.org/reference/functions/get_taxonomies/ + * + * @since 5.3.0 + * + * @module widget-visibility + * + * @param array $args Widget Visibility taxonomy arguments. + */ + apply_filters( 'jetpack_widget_visibility_tax_args', array( '_builtin' => false ) ), + 'objects' + ); + usort( $taxonomies, array( __CLASS__, 'strcasecmp_name' ) ); foreach ( $taxonomies as $taxonomy ) { diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/style.css b/plugins/jetpack/modules/widgets/eu-cookie-law/style.css index 8610bbb8..b97f306d 100644 --- a/plugins/jetpack/modules/widgets/eu-cookie-law/style.css +++ b/plugins/jetpack/modules/widgets/eu-cookie-law/style.css @@ -1,4 +1,5 @@ .widget_eu_cookie_law_widget.widget { + border: none; bottom: 1em; display: none; left: 1em; diff --git a/plugins/jetpack/modules/widgets/gallery.php b/plugins/jetpack/modules/widgets/gallery.php index c41498bf..1bab5569 100644 --- a/plugins/jetpack/modules/widgets/gallery.php +++ b/plugins/jetpack/modules/widgets/gallery.php @@ -417,11 +417,8 @@ class Jetpack_Gallery_Widget extends WP_Widget { ); wp_localize_script( 'gallery-widget-admin', '_wpGalleryWidgetAdminSettings', $js_settings ); - if( is_rtl() ) { - wp_enqueue_style( 'gallery-widget-admin', plugins_url( '/gallery/css/rtl/admin-rtl.css', __FILE__ ) ); - } else { - wp_enqueue_style( 'gallery-widget-admin', plugins_url( '/gallery/css/admin.css', __FILE__ ) ); - } + wp_enqueue_style( 'gallery-widget-admin', plugins_url( '/gallery/css/admin.css', __FILE__ ) ); + wp_style_add_data( 'gallery-widget-admin', 'rtl', 'replace' ); } } } diff --git a/plugins/jetpack/modules/widgets/goodreads.php b/plugins/jetpack/modules/widgets/goodreads.php index aa0d1ab5..2b823c23 100644 --- a/plugins/jetpack/modules/widgets/goodreads.php +++ b/plugins/jetpack/modules/widgets/goodreads.php @@ -42,11 +42,8 @@ class WPCOM_Widget_Goodreads extends WP_Widget { } function enqueue_style() { - if ( is_rtl() ) { - wp_enqueue_style( 'goodreads-widget', plugins_url( 'goodreads/css/rtl/goodreads-rtl.css', __FILE__ ) ); - } else { - wp_enqueue_style( 'goodreads-widget', plugins_url( 'goodreads/css/goodreads.css', __FILE__ ) ); - } + wp_enqueue_style( 'goodreads-widget', plugins_url( 'goodreads/css/goodreads.css', __FILE__ ) ); + wp_style_add_data( 'goodreads-widget', 'rtl', 'replace' ); } function widget( $args, $instance ) { diff --git a/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php b/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php index 08a36181..e2a12ca8 100644 --- a/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php +++ b/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php @@ -198,16 +198,22 @@ function jetpack_migrate_image_widget() { wp_set_sidebars_widgets( $sidebars_widgets ); - Jetpack_Options::update_option( 'image_widget_migration', true ); - // We need to refresh on widgets page for changes to take effect. add_action( 'current_screen', 'jetpack_refresh_on_widget_page' ); + } else { + $widget_media_image = get_option( 'widget_media_image' ); + if ( is_array( $widget_media_image ) ) { + delete_option( 'widget_image' ); + } } + + Jetpack_Options::update_option( 'image_widget_migration', true ); } add_action( 'widgets_init', 'jetpack_migrate_image_widget' ); function jetpack_refresh_on_widget_page( $current ) { if ( 'widgets' === $current->base ) { wp_safe_redirect( admin_url( 'widgets.php' ) ); + exit; } } diff --git a/plugins/jetpack/modules/widgets/social-media-icons/style.css b/plugins/jetpack/modules/widgets/social-media-icons/style.css index b90c6faa..665d1c7d 100644 --- a/plugins/jetpack/modules/widgets/social-media-icons/style.css +++ b/plugins/jetpack/modules/widgets/social-media-icons/style.css @@ -3,7 +3,7 @@ margin-left: 0; } -.widget_wpcom_social_media_icons_widget li { +.widget_wpcom_social_media_icons_widget ul li { border: 0 none; display: inline; margin-right: 0.5em; diff --git a/plugins/jetpack/modules/wordads/php/networks/amazon.php b/plugins/jetpack/modules/wordads/php/networks/amazon.php index fc1edef9..19f53fbe 100644 --- a/plugins/jetpack/modules/wordads/php/networks/amazon.php +++ b/plugins/jetpack/modules/wordads/php/networks/amazon.php @@ -1,51 +1,3 @@ <?php -/** - * Amazon network class - * - * @since 4.5.0 - */ -class WordAds_Amazon { - - /** - * Instantiate - * - * @since 4.5.0 - */ - function __construct() { - add_action( 'wp_head', array( $this, 'insert_head_amazon' ), 25 ); - } - - function insert_head_amazon() { - $data_tags = ( WordAds_Params::is_cloudflare() ) ? ' data-cfasync="false"' : ''; - echo <<<HTML - <script$data_tags type="text/javascript" src="//c.amazon-adsystem.com/aax2/amzn_ads.js"></script> - <script$data_tags type="text/javascript"> - try { - amznads.getAds("3033"); - } catch(e) { /* ignore */ } - </script> - <script$data_tags type="text/javascript"> - var a9_p = amznads.getKeys(); - if ("undefined" != typeof a9_p && "" != a9_p && null !== a9_p && "[object Array]" === Object.prototype.toString.call(a9_p)) { - var a = "", - b = 0, - c = a9_p.length, - d, e; - a9_p.sort(); - for (d = 0; d < c; d+=1) { - a9_p[d - b] = a9_p[d - b].replace(/a1x6p/, "a160x600p"); - e = a9_p[d - b].split("p"); - e[0] == a && (a9_p.splice(d - b, 1), b++); - a = e[0]; - } - _ipw_custom.amznPay = a9_p; - } - document.close(); - </script> -HTML; - } -} - -global $wordads_amazon; -$wordads_amazon = new WordAds_Amazon(); +// stub diff --git a/plugins/jetpack/modules/wordads/php/params.php b/plugins/jetpack/modules/wordads/php/params.php index 79a012cc..70ed4149 100644 --- a/plugins/jetpack/modules/wordads/php/params.php +++ b/plugins/jetpack/modules/wordads/php/params.php @@ -8,13 +8,31 @@ class WordAds_Params { * @since 4.5.0 */ public function __construct() { - $this->options = array( - 'wordads_approved' => (bool) get_option( 'wordads_approved', false ), - 'wordads_active' => (bool) get_option( 'wordads_active', false ), - 'wordads_house' => (bool) get_option( 'wordads_house', true ), - 'enable_header_ad' => (bool) get_option( 'enable_header_ad', false ) + // WordAds setting => default + $settings = array( + 'wordads_approved' => false, + 'wordads_active' => false, + 'wordads_house' => true, + 'enable_header_ad' => false, + 'wordads_second_belowpost' => true, + 'wordads_display_front_page' => true, + 'wordads_display_post' => true, + 'wordads_display_page' => true, + 'wordads_display_archive' => true, ); + // grab settings, or set as default if it doesn't exist + $this->options = array(); + foreach ( $settings as $setting => $default ) { + $option = get_option( $setting, null ); + if ( is_null( $option ) ) { + update_option( $setting, $default, true ); + $option = $default; + } + + $this->options[$setting] = (bool) $option; + } + $host = 'localhost'; if ( isset( $_SERVER['HTTP_HOST'] ) ) { $host = $_SERVER['HTTP_HOST']; @@ -146,29 +164,21 @@ class WordAds_Params { * * @since 4.5.0 */ - public static function should_show() { + public function should_show() { global $wp_query; - if ( is_single() || ( is_page() && ! is_home() ) ) { - return true; + if ( ( is_front_page() || is_home() ) && ! $this->options['wordads_display_front_page'] ) { + return false; } - // TODO this would be a good place for allowing the user to specify - if ( ( is_home() || is_archive() || is_search() ) && 0 == $wp_query->current_post ) { - return true; + if ( is_single() && ! $this->options['wordads_display_post'] ) { + return false; } - return false; - } - - /** - * Logic for if we should show a mobile ad - * - * @since 4.5.0 - */ - public static function should_show_mobile() { - global $wp_query; + if ( is_page() && ! $this->options['wordads_display_page'] ) { + return false; + } - if ( ! in_the_loop() || ! did_action( 'wp_head' ) ) { + if ( is_archive() && ! $this->options['wordads_display_archive'] ) { return false; } @@ -176,7 +186,8 @@ class WordAds_Params { return true; } - if ( ( is_home() || is_archive() ) && 0 == $wp_query->current_post ) { + // TODO this would be a good place for allowing the user to specify + if ( ( is_home() || is_archive() || is_search() ) && 0 == $wp_query->current_post ) { return true; } diff --git a/plugins/jetpack/modules/wordads/wordads.php b/plugins/jetpack/modules/wordads/wordads.php index c8748e18..9ec3e07f 100644 --- a/plugins/jetpack/modules/wordads/wordads.php +++ b/plugins/jetpack/modules/wordads/wordads.php @@ -5,6 +5,7 @@ define( 'WORDADS_BASENAME', plugin_basename( __FILE__ ) ); define( 'WORDADS_FILE_PATH', WORDADS_ROOT . '/' . basename( __FILE__ ) ); define( 'WORDADS_URL', plugins_url( '/', __FILE__ ) ); define( 'WORDADS_API_TEST_ID', '26942' ); +define( 'WORDADS_API_TEST_ID2', '114160' ); require_once( WORDADS_ROOT . '/php/widgets.php' ); require_once( WORDADS_ROOT . '/php/api.php' ); @@ -91,7 +92,6 @@ class WordAds { } $this->insert_adcode(); - $this->insert_extras(); } /** @@ -131,15 +131,6 @@ class WordAds { } /** - * Add the actions/filters to insert extra-network features. - * - * @since 4.5.0 - */ - private function insert_extras() { - require_once( WORDADS_ROOT . '/php/networks/amazon.php' ); - } - - /** * Register desktop scripts and styles * * @since 4.5.0 @@ -181,7 +172,27 @@ HTML; */ function insert_head_iponweb() { $data_tags = ( $this->params->cloudflare ) ? ' data-cfasync="false"' : ''; - echo "<script$data_tags type='text/javascript' src='//s.pubmine.com/head.js'></script>"; + echo <<<HTML + <link rel='dns-prefetch' href='//s.pubmine.com' /> + <link rel='dns-prefetch' href='//x.bidswitch.net' /> + <link rel='dns-prefetch' href='//static.criteo.net' /> + <link rel='dns-prefetch' href='//ib.adnxs.com' /> + <link rel='dns-prefetch' href='//aax.amazon-adsystem.com' /> + <link rel='dns-prefetch' href='//bidder.criteo.com' /> + <link rel='dns-prefetch' href='//cas.criteo.com' /> + <link rel='dns-prefetch' href='//gum.criteo.com' /> + <link rel='dns-prefetch' href='//ads.pubmatic.com' /> + <link rel='dns-prefetch' href='//gads.pubmatic.com' /> + <link rel='dns-prefetch' href='//tpc.googlesyndication.com' /> + <link rel='dns-prefetch' href='//ad.doubleclick.net' /> + <link rel='dns-prefetch' href='//googleads.g.doubleclick.net' /> + <link rel='dns-prefetch' href='//www.googletagservices.com' /> + <link rel='dns-prefetch' href='//cdn.switchadhub.com' /> + <link rel='dns-prefetch' href='//delivery.g.switchadhub.com' /> + <link rel='dns-prefetch' href='//delivery.swid.switchadhub.com' /> + <script$data_tags type="text/javascript" src="//s.pubmine.com/head.js"></script> + <script$data_tags type="text/javascript" src="//static.criteo.net/js/ld/publishertag.js"></script> +HTML; } /** @@ -283,46 +294,123 @@ HTML; */ function get_ad( $spot, $type = 'iponweb' ) { $snippet = ''; + $blocker_unit = 'mrec'; if ( 'iponweb' == $type ) { $section_id = WORDADS_API_TEST_ID; $width = 300; $height = 250; + $second_belowpost = ''; if ( 'top' == $spot ) { // mrec for mobile, leaderboard for desktop $section_id = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID : $this->params->blog_id . '2'; $width = $this->params->mobile_device ? 300 : 728; $height = $this->params->mobile_device ? 250 : 90; - } else if ( 'belowpost' ) { + $blocker_unit = $this->params->mobile_device ? 'top_mrec' : 'top'; + } else if ( 'belowpost' == $spot ) { $section_id = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID : $this->params->blog_id . '1'; $width = 300; $height = 250; + if ( $this->option( 'wordads_second_belowpost', true ) ) { + $section_id2 = 0 === $this->params->blog_id ? WORDADS_API_TEST_ID2 : $this->params->blog_id . '4'; + $second_belowpost = + "g.__ATA.initAd({collapseEmpty:'after', sectionId:$section_id2, width:$width, height:$height});"; + } } + $data_tags = ( $this->params->cloudflare ) ? ' data-cfasync="false"' : ''; $snippet = <<<HTML - <script$data_tags type='text/javascript'> - (function(g){g.__ATA.initAd({sectionId:$section_id, width:$width, height:$height});})(window); + <script$data_tags id='s$section_id' type='text/javascript'> + (function(g){if('undefined'!=typeof g.__ATA){ + g.__ATA.initAd({collapseEmpty:'after', sectionId:$section_id, width:$width, height:$height}); + $second_belowpost + }})(window); </script> HTML; } else if ( 'house' == $type ) { $leaderboard = 'top' == $spot && ! $this->params->mobile_device; $snippet = $this->get_house_ad( $leaderboard ? 'leaderboard' : 'mrec' ); + if ( 'belowpost' == $spot && $this->option( 'wordads_second_belowpost', true ) ) { + $snippet .= $this->get_house_ad( $leaderboard ? 'leaderboard' : 'mrec' ); + } + } + + $ad_blocker_ad = 'iponweb' == $type ? $this->get_adblocker_ad( $blocker_unit ) : ''; + $second_belowpost_css = ''; + $double_mrec = ''; + if ( 'belowpost' == $spot && $this->option( 'wordads_second_belowpost', true ) ) { + if ( 'iponweb' == $type ) { + $ad_blocker_ad .= $this->get_adblocker_ad( 'mrec2' ); + } + + $double_mrec = 'wpmrec2x'; + $second_belowpost_css = <<<HTML + <style type="text/css"> + div.wpmrec2x{max-width:610px;} + div.wpmrec2x div.u > div{float:left;margin-right:10px;} + div.wpmrec2x div.u > div:nth-child(3n){margin-right:0px;} + </style> +HTML; } $header = 'top' == $spot ? 'wpcnt-header' : ''; $about = __( 'Advertisements', 'jetpack' ); return <<<HTML - <div class="wpcnt $header"> + $second_belowpost_css + <div class="wpcnt $header $double_mrec"> <div class="wpa"> <span class="wpa-about">$about</span> <div class="u $spot"> $snippet </div> + $ad_blocker_ad </div> </div> HTML; } /** + * Get Criteo Acceptable Ad unit + * @param string $unit mrec, mrec2, widesky, top, top_mrec + * + * @since 5.3 + */ + public function get_adblocker_ad( $unit = 'mrec' ) { + $criteo_id = mt_rand(); + $height = 250; + $width = 300; + $zone_id = 388248; + if ( 'mrec2' == $unit ) { // 2nd belowpost + $zone_id = 837497; + } else if ( 'widesky' == $unit ) { // sidebar + $zone_id = 563902; + $width = 160; + $height= 600; + } else if ( 'top' == $unit ) { // top leaderboard + $zone_id = 563903; + $width = 728; + $height = 90; + } else if ( 'top_mrec' == $unit ) { // top mrec + $zone_id = 563903; + } + + return <<<HTML + <div id="crt-$criteo_id" style="width:{$width}px;height:{$height}px;"></div> + <script type="text/javascript"> + var o = document.getElementById('crt-$criteo_id'); + if ("undefined"!=typeof Criteo) { + var p = o.parentNode; + p.style.setProperty('display', 'inline-block', 'important'); + o.style.setProperty('display', 'block', 'important'); + Criteo.DisplayAcceptableAdIfAdblocked({zoneid:$zone_id,containerid:"crt-$criteo_id",collapseContainerIfNotAdblocked:true,"callifnotadblocked": function () {var o = document.getElementById('crt-$criteo_id'); o.style.setProperty('display','none','important');o.style.setProperty('visbility','hidden','important'); } }); + } else { + o.style.setProperty('display', 'none', 'important'); + o.style.setProperty('visibility', 'hidden', 'important'); + } + </script> +HTML; + } + + /** * Check the reasons to bail before we attempt to insert ads. * @return true if we should bail (don't insert ads) * |