diff options
Diffstat (limited to 'plugins/jetpack/modules/related-posts')
5 files changed, 104 insertions, 66 deletions
diff --git a/plugins/jetpack/modules/related-posts/class.related-posts-customize.php b/plugins/jetpack/modules/related-posts/class.related-posts-customize.php index 8f15ca69..c6dd4788 100644 --- a/plugins/jetpack/modules/related-posts/class.related-posts-customize.php +++ b/plugins/jetpack/modules/related-posts/class.related-posts-customize.php @@ -1,5 +1,7 @@ <?php +use Automattic\Jetpack\Assets; + // Exit if file is accessed directly if ( ! defined( 'ABSPATH' ) ) { exit; @@ -268,7 +270,7 @@ class Jetpack_Related_Posts_Customize { function customize_controls_enqueue_scripts() { wp_enqueue_script( 'jetpack_related-posts-customizer', - Jetpack::get_file_url_for_environment( + Assets::get_file_url_for_environment( '_inc/build/related-posts/related-posts-customizer.min.js', 'modules/related-posts/related-posts-customizer.js' ), @@ -297,4 +299,4 @@ class Jetpack_Message_Control extends WP_Customize_Control { } // class end // Initialize controls -new Jetpack_Related_Posts_Customize; +new Jetpack_Related_Posts_Customize(); diff --git a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php index d1d4855f..aa9adefb 100644 --- a/plugins/jetpack/modules/related-posts/jetpack-related-posts.php +++ b/plugins/jetpack/modules/related-posts/jetpack-related-posts.php @@ -1,6 +1,10 @@ <?php + +use Automattic\Jetpack\Assets; +use Automattic\Jetpack\Sync\Settings; + class Jetpack_RelatedPosts { - const VERSION = '20190204'; + const VERSION = '20191011'; const SHORTCODE = 'jetpack-related-posts'; private static $instance = null; @@ -51,6 +55,7 @@ class Jetpack_RelatedPosts { * Constructor for Jetpack_RelatedPosts. * * @uses get_option, add_action, apply_filters + * * @return null */ public function __construct() { @@ -115,7 +120,7 @@ class Jetpack_RelatedPosts { */ public function action_frontend_init() { // Add a shortcode handler that outputs nothing, this gets overridden later if we can display related content - add_shortcode( self::SHORTCODE, array( $this, 'get_target_html_unsupported' ) ); + add_shortcode( self::SHORTCODE, array( $this, 'get_client_rendered_html_unsupported' ) ); if ( ! $this->_enabled_for_request() ) return; @@ -158,25 +163,53 @@ class Jetpack_RelatedPosts { /** * Adds a target to the post content to load related posts into if a shortcode for it did not already exist. - * Will skip adding the target if the post content contains a Related Posts block. + * Will skip adding the target if the post content contains a Related Posts block or if the 'get_the_excerpt' + * hook is in the current filter list. * * @filter the_content - * @param string $content + * + * @param string $content Post content. + * * @returns string */ public function filter_add_target_to_dom( $content ) { - if ( has_block( 'jetpack/related-posts', $content ) ) { + if ( has_block( 'jetpack/related-posts' ) ) { return $content; } - if ( ! $this->_found_shortcode ) { - $content .= "\n" . $this->get_target_html(); + if ( ! $this->_found_shortcode && ! doing_filter( 'get_the_excerpt' ) ) { + if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) { + $content .= "\n" . $this->get_server_rendered_html(); + } else { + $content .= "\n" . $this->get_client_rendered_html(); + } } return $content; } /** + * Render static markup based on the Gutenberg block code + * + * @return string Rendered related posts HTML. + */ + public function get_server_rendered_html() { + $rp_settings = Jetpack_Options::get_option( 'relatedposts', array() ); + $block_rp_settings = array( + 'displayThumbnails' => $rp_settings['show_thumbnails'], + 'showHeadline' => $rp_settings['show_headline'], + 'displayDate' => isset( $rp_settings['show_date'] ) ? (bool) $rp_settings['show_date'] : true, + 'displayContext' => isset( $rp_settings['show_context'] ) && $rp_settings['show_context'], + 'postLayout' => isset( $rp_settings['layout'] ) ? $rp_settings['layout'] : 'grid', + 'postsToShow' => isset( $rp_settings['size'] ) ? $rp_settings['size'] : 3, + /** This filter is already documented in modules/related-posts/jetpack-related-posts.php */ + 'headline' => apply_filters( 'jetpack_relatedposts_filter_headline', $this->get_headline() ), + ); + + return $this->render_block( $block_rp_settings ); + } + + /** * Looks for our shortcode on the unfiltered content, this has to execute early. * * @filter the_content @@ -196,9 +229,8 @@ class Jetpack_RelatedPosts { * @uses esc_html__, apply_filters * @returns string */ - public function get_target_html() { - require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php'; - if ( Jetpack_Sync_Settings::is_syncing() ) { + public function get_client_rendered_html() { + if ( Settings::is_syncing() ) { return ''; } @@ -231,9 +263,8 @@ EOT; * * @returns string */ - public function get_target_html_unsupported() { - require_once JETPACK__PLUGIN_DIR . '/sync/class.jetpack-sync-settings.php'; - if ( Jetpack_Sync_Settings::is_syncing() ) { + public function get_client_rendered_html_unsupported() { + if ( Settings::is_syncing() ) { return ''; } return "\n\n<!-- Jetpack Related Posts is not supported in this context. -->\n\n"; @@ -262,18 +293,18 @@ EOT; ); $item_markup .= sprintf( - '<li class="jp-related-posts-i2__post-link"><a id="%1$s" href="%2$s" rel="%4$s">%3$s</a></li>', + '<li class="jp-related-posts-i2__post-link"><a id="%1$s" href="%2$s" %4$s>%3$s</a></li>', esc_attr( $label_id ), esc_url( $related_post['url'] ), esc_attr( $related_post['title'] ), - esc_attr( $related_post['rel'] ) + ( ! empty( $related_post['rel'] ) ? 'rel="' . esc_attr( $related_post['rel'] ) . '"' : '' ) ); if ( ! empty( $block_attributes['show_thumbnails'] ) && ! empty( $related_post['img']['src'] ) ) { $img_link = sprintf( - '<li class="jp-related-posts-i2__post-img-link"><a href="%1$s" rel="%2$s"><img src="%3$s" width="%4$s" alt="%5$s" /></a></li>', + '<li class="jp-related-posts-i2__post-img-link"><a href="%1$s" %2$s><img src="%3$s" width="%4$s" alt="%5$s" /></a></li>', esc_url( $related_post['url'] ), - esc_attr( $related_post['rel'] ), + ( ! empty( $related_post['rel'] ) ? 'rel="' . esc_attr( $related_post['rel'] ) . '"' : '' ), esc_url( $related_post['img']['src'] ), esc_attr( $related_post['img']['width'] ), esc_attr( $related_post['img']['alt_text'] ) @@ -331,6 +362,7 @@ EOT; */ public function render_block( $attributes ) { $block_attributes = array( + 'headline' => isset( $attributes['headline'] ) ? $attributes['headline'] : null, 'show_thumbnails' => isset( $attributes['displayThumbnails'] ) && $attributes['displayThumbnails'], 'show_date' => isset( $attributes['displayDate'] ) ? (bool) $attributes['displayDate'] : true, 'show_context' => isset( $attributes['displayContext'] ) && $attributes['displayContext'], @@ -338,7 +370,8 @@ EOT; 'size' => ! empty( $attributes['postsToShow'] ) ? absint( $attributes['postsToShow'] ) : 3, ); - $excludes = $this->parse_numeric_get_arg( 'relatedposts_origin' ); + $excludes = $this->parse_numeric_get_arg( 'relatedposts_origin' ); + $related_posts = $this->get_for_post_id( get_the_ID(), array( @@ -373,33 +406,26 @@ EOT; $rows_markup .= $this->render_block_row( $lower_row_posts, $block_attributes ); } - $target_to_dom_priority = has_filter( - 'the_content', - array( $this, 'filter_add_target_to_dom' ) - ); - remove_filter( - 'the_content', - array( $this, 'filter_add_target_to_dom' ), - $target_to_dom_priority - ); - /* - Below is a hack to get the block content to render correctly. - - This functionality should be covered in /inc/blocks.php but due to an error, - this has not been fixed as of this writing. - - Alda has submitted a patch to Core in order to have this issue fixed at - https://core.trac.wordpress.org/attachment/ticket/45495/do_blocks.diff and - hopefully it makes to to the final RC of WP 5.1. - */ + * Below is a hack to get the block content to render correctly. + * + * This functionality should be covered in /inc/blocks.php but due to an error, + * this has not been fixed as of this writing. + * + * Alda has submitted a patch to Core in order to have this issue fixed at + * https://core.trac.wordpress.org/ticket/45495 and + * made it into WordPress 5.2. + * + * @todo update when WP 5.2 is the minimum support version. + */ $priority = has_filter( 'the_content', 'wpautop' ); remove_filter( 'the_content', 'wpautop', $priority ); add_filter( 'the_content', '_restore_wpautop_hook', $priority + 1 ); return sprintf( - '<nav class="jp-relatedposts-i2" data-layout="%1$s">%2$s</nav>', + '<nav class="jp-relatedposts-i2" data-layout="%1$s">%2$s%3$s</nav>', esc_attr( $block_attributes['layout'] ), + $block_attributes['headline'], $rows_markup ); } @@ -417,7 +443,7 @@ EOT; * * @uses absint * - * @param string $arg Name of the GET variable + * @param string $arg Name of the GET variable. * @return array $result Parsed value(s) */ public function parse_numeric_get_arg( $arg ) { @@ -1187,11 +1213,12 @@ EOT; * @module related-posts * * @since 3.7.0 + * @since 7.9.0 - Change Default value to empty. * - * @param string nofollow Link rel attribute for Related Posts' link. Default is nofollow. - * @param int $post->ID Post ID. + * @param string $link_rel Link rel attribute for Related Posts' link. Default is empty. + * @param int $post->ID Post ID. */ - 'rel' => apply_filters( 'jetpack_relatedposts_filter_post_link_rel', 'nofollow', $post->ID ), + 'rel' => apply_filters( 'jetpack_relatedposts_filter_post_link_rel', '', $post->ID ), /** * Filter the context displayed below each Related Post. * @@ -1604,16 +1631,10 @@ EOT; */ protected function _enabled_for_request() { $enabled = is_single() + && ! is_attachment() && ! is_admin() && ( ! $this->_allow_feature_toggle() || $this->get_option( 'enabled' ) ); - if ( - class_exists( 'Jetpack_AMP_Support' ) - && Jetpack_AMP_Support::is_amp_request() - ) { - $enabled = false; - } - /** * Filter the Enabled value to allow related posts to be shown on pages as well. * @@ -1633,7 +1654,9 @@ EOT; * @return null */ protected function _action_frontend_init_page() { - $this->_enqueue_assets( true, true ); + + $enqueue_script = ! ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ); + $this->_enqueue_assets( $enqueue_script, true ); $this->_setup_shortcode(); add_filter( 'the_content', array( $this, 'filter_add_target_to_dom' ), 40 ); @@ -1650,7 +1673,7 @@ EOT; if ( $script ) { wp_enqueue_script( 'jetpack_related-posts', - Jetpack::get_file_url_for_environment( + Assets::get_file_url_for_environment( '_inc/build/related-posts/related-posts.min.js', 'modules/related-posts/related-posts.js' ), @@ -1672,9 +1695,14 @@ EOT; if ( $style ){ wp_enqueue_style( 'jetpack_related-posts', plugins_url( 'related-posts.css', __FILE__ ), array(), self::VERSION ); wp_style_add_data( 'jetpack_related-posts', 'rtl', 'replace' ); + add_action( 'amp_post_template_css', array( $this, 'render_amp_reader_mode_css' ) ); } } + public function render_amp_reader_mode_css() { + echo file_get_contents( plugin_dir_path( __FILE__ ) . 'related-posts.css' ); + } + /** * Sets up the shortcode processing. * @@ -1684,7 +1712,7 @@ EOT; protected function _setup_shortcode() { add_filter( 'the_content', array( $this, 'test_for_shortcode' ), 0 ); - add_shortcode( self::SHORTCODE, array( $this, 'get_target_html' ) ); + add_shortcode( self::SHORTCODE, array( $this, 'get_client_rendered_html' ) ); } protected function _allow_feature_toggle() { @@ -1719,14 +1747,19 @@ EOT; * @return null */ public function rest_register_related_posts() { - register_rest_field( 'post', - 'jetpack-related-posts', - array( - 'get_callback' => array( $this, 'rest_get_related_posts' ), - 'update_callback' => null, - 'schema' => null, - ) - ); + /** This filter is already documented in class.json-api-endpoints.php */ + $post_types = apply_filters( 'rest_api_allowed_post_types', array( 'post', 'page', 'revision' ) ); + foreach ( $post_types as $post_type ) { + register_rest_field( + $post_type, + 'jetpack-related-posts', + array( + 'get_callback' => array( $this, 'rest_get_related_posts' ), + 'update_callback' => null, + 'schema' => null, + ) + ); + } } /** diff --git a/plugins/jetpack/modules/related-posts/related-posts-rtl.css b/plugins/jetpack/modules/related-posts/related-posts-rtl.css index 21f37004..69ce02fb 100644 --- a/plugins/jetpack/modules/related-posts/related-posts-rtl.css +++ b/plugins/jetpack/modules/related-posts/related-posts-rtl.css @@ -1 +1 @@ -.jp-related-posts-i2__row{display:flex;margin-top:1.5rem}.jp-related-posts-i2__row:first-child{margin-top:0}.jp-related-posts-i2__post{flex-grow:1;flex-basis:0;margin:0 10px;display:flex;flex-direction:column;padding-right:0}.jp-related-posts-i2__row[data-post-count="3"] .jp-related-posts-i2__post{max-width:calc(33% - 20px)}.jp-related-posts-i2__row[data-post-count="1"] .jp-related-posts-i2__post,.jp-related-posts-i2__row[data-post-count="2"] .jp-related-posts-i2__post{max-width:calc(50% - 20px)}.jp-related-posts-i2__post-context,.jp-related-posts-i2__post-date,.jp-related-posts-i2__post-heading,.jp-related-posts-i2__post-img-link{flex-direction:row;display:block}.jp-related-posts-i2__post-heading{margin:.5rem 0;font-size:1rem;line-height:1.2em}.jp-related-posts-i2__post-link{display:block;width:100%;line-height:1.2em}.jp-related-posts-i2__post-img-link{order:-1;line-height:1em}.jp-related-posts-i2__post-img-link img{width:100%}.jp-relatedposts-i2[data-layout=list] .jp-related-posts-i2__row{margin-top:0;display:block}.jp-relatedposts-i2[data-layout=list] .jp-related-posts-i2__post{max-width:none;margin:0}.jp-relatedposts-i2[data-layout=list].jp-related-posts-i2__post-img-link{margin-top:1rem}@media only screen and (max-width:640px){.jp-related-posts-i2__row{margin-top:0;display:block}.jp-related-posts-i2__row[data-post-count] .jp-related-posts-i2__post{max-width:none;margin:0;margin-top:1rem}.jp-related-posts-i2__post-img-link{margin-top:1rem}.jp-related-posts-i2__post-img-link img{width:350px}}#jp-relatedposts{display:none;padding-top:1em;margin:1em 0;position:relative;clear:both}.jp-relatedposts:after{content:'';display:block;clear:both}#jp-relatedposts h3.jp-relatedposts-headline{margin:0 0 1em 0;display:inline-block;float:right;font-size:9pt;font-weight:700;font-family:inherit}#jp-relatedposts h3.jp-relatedposts-headline em:before{content:"";display:block;width:100%;min-width:30px;border-top:1px solid #ddd;border-top:1px solid rgba(0,0,0,.2);margin-bottom:1em}#jp-relatedposts h3.jp-relatedposts-headline em{font-style:normal;font-weight:700}#jp-relatedposts .jp-relatedposts-items{clear:right}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:-20px}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{float:right;width:33%;margin:0 0 1em;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post{padding-left:20px;-moz-opacity:.8;opacity:.8}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n+4),#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post:nth-child(3n+4){clear:both}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:hover .jp-relatedposts-post-title a{text-decoration:underline}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:hover{-moz-opacity:1;opacity:1}#jp-relatedposts .jp-relatedposts-items p,#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{font-size:14px;line-height:20px;margin:0}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs{position:relative}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs a.jp-relatedposts-post-aoverlay{position:absolute;top:0;bottom:0;right:0;left:0;display:block;border-bottom:0}#jp-relatedposts .jp-relatedposts-items p{margin-bottom:0}#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{text-transform:none;margin:0;font-family:inherit;display:block;max-width:100%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title a{font-size:inherit;font-weight:400;text-decoration:none;-moz-opacity:1;opacity:1}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title a:hover{text-decoration:underline}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post span{display:block;max-width:90%;overflow:hidden;text-overflow:ellipsis}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post span{max-width:100%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-context,#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{opacity:.6}.jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{display:none}#jp-relatedposts .jp-relatedposts-items-visual div.jp-relatedposts-post-thumbs p.jp-relatedposts-post-excerpt{display:none}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs p.jp-relatedposts-post-excerpt{overflow:hidden}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs span{margin-bottom:1em}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post{clear:both;width:100%}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post img.jp-relatedposts-post-img{float:right;overflow:hidden;max-width:33%;margin-left:3%}#jp-relatedposts .jp-relatedposts-list h4.jp-relatedposts-post-title{display:inline-block;max-width:63%}@media only screen and (max-width:640px){#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{width:50%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n){clear:right}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:20px}}@media only screen and (max-width:320px){#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{width:100%;clear:both;margin:0 0 1em}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-list h4.jp-relatedposts-post-title{float:none;max-width:100%;margin-left:0}}
\ No newline at end of file +.jp-related-posts-i2__row{display:flex;margin-top:1.5rem}.jp-related-posts-i2__row:first-child{margin-top:0}.jp-related-posts-i2__post{flex-grow:1;flex-basis:0;margin:0 10px;display:flex;flex-direction:column;padding-right:0}.jp-related-posts-i2__row[data-post-count="3"] .jp-related-posts-i2__post{max-width:calc(33% - 20px)}.jp-related-posts-i2__row[data-post-count="1"] .jp-related-posts-i2__post,.jp-related-posts-i2__row[data-post-count="2"] .jp-related-posts-i2__post{max-width:calc(50% - 20px)}.jp-related-posts-i2__post-context,.jp-related-posts-i2__post-date,.jp-related-posts-i2__post-heading,.jp-related-posts-i2__post-img-link{flex-direction:row;display:block}.jp-related-posts-i2__post-heading{margin:.5rem 0;font-size:1rem;line-height:1.2em}.jp-related-posts-i2__post-link{display:block;width:100%;line-height:1.2em}.jp-related-posts-i2__post-img-link{order:-1}.jp-related-posts-i2__post-img-link img{width:100%}.jp-relatedposts-i2[data-layout=list] .jp-related-posts-i2__row{margin-top:0;display:block}.jp-relatedposts-i2[data-layout=list] .jp-related-posts-i2__post{max-width:none;margin:0}.jp-relatedposts-i2[data-layout=list].jp-related-posts-i2__post-img-link{margin-top:1rem}@media only screen and (max-width:640px){.jp-related-posts-i2__row{margin-top:0;display:block}.jp-related-posts-i2__row[data-post-count] .jp-related-posts-i2__post{max-width:none;margin:0;margin-top:1rem}.jp-related-posts-i2__post-img-link{margin-top:1rem}.jp-related-posts-i2__post-img-link img{width:350px}}#jp-relatedposts{display:none;padding-top:1em;margin:1em 0;position:relative;clear:both}.jp-relatedposts:after{content:'';display:block;clear:both}#jp-relatedposts h3.jp-relatedposts-headline{margin:0 0 1em 0;display:inline-block;float:right;font-size:9pt;font-weight:700;font-family:inherit}#jp-relatedposts h3.jp-relatedposts-headline em:before{content:"";display:block;width:100%;min-width:30px;border-top:1px solid #ddd;border-top:1px solid rgba(0,0,0,.2);margin-bottom:1em}#jp-relatedposts h3.jp-relatedposts-headline em{font-style:normal;font-weight:700}#jp-relatedposts .jp-relatedposts-items{clear:right}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:-20px}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{float:right;width:33%;margin:0 0 1em;box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post{padding-left:20px;-moz-opacity:.8;opacity:.8}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n+4),#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post:nth-child(3n+4){clear:both}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:hover .jp-relatedposts-post-title a{text-decoration:underline}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:hover{-moz-opacity:1;opacity:1}#jp-relatedposts .jp-relatedposts-items p,#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{font-size:14px;line-height:20px;margin:0}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs{position:relative}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs a.jp-relatedposts-post-aoverlay{position:absolute;top:0;bottom:0;right:0;left:0;display:block;border-bottom:0}#jp-relatedposts .jp-relatedposts-items p{margin-bottom:0}#jp-relatedposts .jp-relatedposts-items-visual h4.jp-relatedposts-post-title{text-transform:none;margin:0;font-family:inherit;display:block;max-width:100%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title a{font-size:inherit;font-weight:400;text-decoration:none;-moz-opacity:1;opacity:1}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-title a:hover{text-decoration:underline}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post span{display:block;max-width:90%;overflow:hidden;text-overflow:ellipsis}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post span{max-width:100%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-context,#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{opacity:.6}.jp-relatedposts-items .jp-relatedposts-post .jp-relatedposts-post-date{display:none}#jp-relatedposts .jp-relatedposts-items-visual div.jp-relatedposts-post-thumbs p.jp-relatedposts-post-excerpt{display:none}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs p.jp-relatedposts-post-excerpt{overflow:hidden}#jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post-nothumbs span{margin-bottom:1em}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post{clear:both;width:100%}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post img.jp-relatedposts-post-img{float:right;overflow:hidden;max-width:33%;margin-left:3%}#jp-relatedposts .jp-relatedposts-list h4.jp-relatedposts-post-title{display:inline-block;max-width:63%}@media only screen and (max-width:640px){#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{width:50%}#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n){clear:right}#jp-relatedposts .jp-relatedposts-items-visual{margin-left:20px}}@media only screen and (max-width:320px){#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post{width:100%;clear:both;margin:0 0 1em}#jp-relatedposts .jp-relatedposts-list .jp-relatedposts-post img.jp-relatedposts-post-img,#jp-relatedposts .jp-relatedposts-list h4.jp-relatedposts-post-title{float:none;max-width:100%;margin-left:0}}
\ No newline at end of file diff --git a/plugins/jetpack/modules/related-posts/related-posts.css b/plugins/jetpack/modules/related-posts/related-posts.css index 763dfcdb..fa9e84e6 100644 --- a/plugins/jetpack/modules/related-posts/related-posts.css +++ b/plugins/jetpack/modules/related-posts/related-posts.css @@ -53,7 +53,6 @@ .jp-related-posts-i2__post-img-link { order: -1; - line-height: 1em; } .jp-related-posts-i2__post-img-link img { width: 100%; diff --git a/plugins/jetpack/modules/related-posts/related-posts.js b/plugins/jetpack/modules/related-posts/related-posts.js index f8fa781b..76f7d33d 100644 --- a/plugins/jetpack/modules/related-posts/related-posts.js +++ b/plugins/jetpack/modules/related-posts/related-posts.js @@ -1,4 +1,3 @@ -/* jshint onevar: false */ /* globals related_posts_js_options */ /** @@ -69,11 +68,16 @@ class: classNames, href: post.url, title: anchor_title, - rel: post.rel, 'data-origin': post.url_meta.origin, 'data-position': post.url_meta.position, } ); + if ( '' !== post.rel ) { + anchor.attr( { + rel: post.rel, + } ); + } + var anchor_html = $( '<div>' ) .append( anchor ) .html(); |