andle The script handle. * * @return string Modified script tag. */ public function add_amp_dev_mode_attributes( $tag, $handle ) { if ( ! in_array( $handle, [ 'rank-math', 'jquery-core', 'jquery-migrate' ], true ) ) { return $tag; } return preg_replace( '/(?<=)/i', ' data-ampdevmode', $tag ); } /** * Add data-ampdevmode attributes to the elements that need it. * * @since 1.0.45 * * @param string[] $xpaths XPath queries for elements that should get the data-ampdevmode attribute. * * @return string[] XPath queries. */ public function add_amp_dev_mode_xpaths( $xpaths ) { $xpaths[] = '//script[ contains( text(), "var rankMath" ) ]'; $xpaths[] = '//*[ @id = "rank-math-css" ]'; $xpaths[] = '//a[starts-with(@href, "tel://")]'; return $xpaths; } /** * Inserts the RSS header and footer messages in the RSS feed item. * * @param string $content Feed item content. * @param string $context Feed item context, 'excerpt' or 'full'. * * @return string */ private function embed_rss( $content, $context = 'full' ) { if ( false === $this->can_embed_footer( $content, $context ) ) { return $content; } $before = $this->get_rss_content( 'before' ); $after = $this->get_rss_content( 'after' ); if ( '' === $before && '' === $after ) { return $content; } if ( 'excerpt' === $context && '' !== trim( $content ) ) { $content = wpautop( $content ); } return $before . $content . $after; } /** * Check if we can add the RSS footer and/or header to the RSS feed item. * * @copyright Copyright (C) 2008-2019, Yoast BV * The following code is a derivative work of the code from the Yoast(https://github.com/Yoast/wordpress-seo/), which is licensed under GPL v3. * * @param string $content Feed item content. * @param string $context Feed item context, either 'excerpt' or 'full'. * * @return bool */ private function can_embed_footer( $content, $context ) { /** * Allow the RSS footer to be dynamically shown/hidden. * * @param bool $show_embed Indicates if the RSS footer should be shown or not. * @param string $context The context of the RSS content - 'full' or 'excerpt'. */ if ( false === $this->do_filter( 'frontend/rss/include_footer', true, $context ) ) { return false; } return is_feed(); } /** * Get RSS content for specified location. * * @param string $which Location ID. * * @return string */ private function get_rss_content( $which ) { $content = $this->do_filter( 'frontend/rss/' . $which . '_content', Helper::get_settings( 'general.rss_' . $which . '_content' ) ); return '' !== $content ? wpautop( $this->rss_replace_vars( $content ) ) : $content; } /** * Replace variables with the actual values in RSS header and footer messages. * * @param string $content The RSS content. * * @return string */ private function rss_replace_vars( $content ) { global $post; /** * Add nofollow for the links in the RSS header and footer messages. Default: true. * * @param bool $unsigned Whether or not to follow the links in RSS feed, defaults to true. */ $no_follow = $this->do_filter( 'frontend/rss/nofollow_links', true ); $no_follow = true === $no_follow ? 'rel="nofollow" ' : ''; $author_link = ''; if ( is_object( $post ) ) { $author_link = '' . esc_html( get_the_author() ) . ''; } $post_link = '' . esc_html( get_the_title() ) . ''; $blog_link = '' . esc_html( get_bloginfo( 'name' ) ) . ''; $blog_desc_link = '' . esc_html( get_bloginfo( 'name' ) ) . ' - ' . esc_html( get_bloginfo( 'description' ) ) . ''; // Featured image. $image = Helper::get_thumbnail_with_fallback( $post->ID, 'full' ); $image = isset( $image[0] ) ? '' : ''; $content = stripslashes( trim( $content ) ); $content = str_replace( '%AUTHORLINK%', $author_link, $content ); $content = str_replace( '%POSTLINK%', $post_link, $content ); $content = str_replace( '%BLOGLINK%', $blog_link, $content ); $content = str_replace( '%BLOGDESCLINK%', $blog_desc_link, $content ); $content = str_replace( '%FEATUREDIMAGE%', $image, $content ); return $content; } }