diff options
author | Yury German <blueknight@gentoo.org> | 2019-04-28 17:39:03 -0400 |
---|---|---|
committer | Yury German <blueknight@gentoo.org> | 2019-04-28 17:39:03 -0400 |
commit | 2ab16973706e120bc344c83be6295b54fd908c57 (patch) | |
tree | 358267a52d9542c77c90e3663cea32d13b8cb639 /plugins/jetpack/modules/shortcodes/crowdsignal.php | |
parent | Update twentysixteen 1.7 (diff) | |
download | blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.tar.gz blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.tar.bz2 blogs-gentoo-2ab16973706e120bc344c83be6295b54fd908c57.zip |
Updating packages for 5.1.1
Signed-off-by: Yury German <blueknight@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/shortcodes/crowdsignal.php')
-rw-r--r-- | plugins/jetpack/modules/shortcodes/crowdsignal.php | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/plugins/jetpack/modules/shortcodes/crowdsignal.php b/plugins/jetpack/modules/shortcodes/crowdsignal.php index 4359040c..e2078a68 100644 --- a/plugins/jetpack/modules/shortcodes/crowdsignal.php +++ b/plugins/jetpack/modules/shortcodes/crowdsignal.php @@ -124,6 +124,32 @@ CONTAINER; global $post; global $content_width; + /** + * Variables extracted from $atts. + * + * @var string $survey + * @var string $link_text + * @var string $poll + * @var string $rating + * @var string $unique_id + * @var string $item_id + * @var string $title + * @var string $permalink + * @var int $cb + * @var string $type + * @var string $body + * @var string $button + * @var string $text_color + * @var string $back_color + * @var string $align + * @var string $style + * @var int $width + * @var int $height + * @var int $delay + * @var string $visit + * @var string $domain + * @var string $id + */ extract( shortcode_atts( array( 'survey' => null, 'link_text' => 'Take Our Survey', @@ -209,7 +235,9 @@ CONTAINER; $item_id = esc_js( $item_id ); - if ( $inline ) { + if ( Jetpack_AMP_Support::is_amp_request() ) { + return sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $permalink ), esc_html( trim( $title ) ) ); + } elseif ( $inline ) { return <<<SCRIPT <div class="cs-rating pd-rating" id="pd_rating_holder_{$rating}{$item_id}"></div> <script type="text/javascript" charset="UTF-8"><!--//--><![CDATA[//><!-- @@ -242,12 +270,16 @@ CONTAINER; } } elseif ( intval( $poll ) > 0 ) { //poll embed + if ( empty( $title ) ) { + $title = __( 'Take Our Poll', 'jetpack' ); + } + $poll = intval( $poll ); $poll_url = sprintf( 'https://poll.fm/%d', $poll ); $poll_js = sprintf( 'https://secure.polldaddy.com/p/%d.js', $poll ); - $poll_link = sprintf( '<a href="%s" target="_blank">Take Our Poll</a>', $poll_url ); + $poll_link = sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $poll_url ), esc_html( $title ) ); - if ( $no_script ) { + if ( $no_script || Jetpack_AMP_Support::is_amp_request() ) { return $poll_link; } else { if ( $type == 'slider' && !$inline ) { @@ -359,7 +391,7 @@ CONTAINER; $settings = array(); // Do we want a full embed code or a link? - if ( $no_script || $inline || $infinite_scroll ) { + if ( $no_script || $inline || $infinite_scroll || Jetpack_AMP_Support::is_amp_request() ) { return $survey_link; } @@ -554,6 +586,10 @@ new CrowdsignalShortcode(); if ( ! function_exists( 'crowdsignal_link' ) ) { // http://polldaddy.com/poll/1562975/?view=results&msg=voted function crowdsignal_link( $content ) { + if ( Jetpack_AMP_Support::is_amp_request() ) { + return $content; + } + return preg_replace( '!(?:\n|\A)https?://(polldaddy\.com/poll|poll\.fm)/([0-9]+?)(/.*)?(?:\n|\Z)!i', "\n<script type='text/javascript' charset='utf-8' src='//static.polldaddy.com/p/$2.js'></script><noscript> <a href='https://poll.fm/$2'>View Poll</a></noscript>\n", $content ); } @@ -562,8 +598,13 @@ if ( ! function_exists( 'crowdsignal_link' ) ) { add_filter( 'the_content_rss', 'crowdsignal_link', 1 ); } -wp_oembed_add_provider( '#https?://(.+\.)?polldaddy\.com/.*#i', 'https://api.crowdsignal.com/oembed', true ); + /** + * Note that Core has the oembed of '#https?://survey\.fm/.*#i' as of 5.1. + * This should be removed after Core has the current regex is in our minimum version. + * + * @see https://core.trac.wordpress.org/ticket/46467 + * @todo Confirm patch landed and remove once 5.2 is the minimum version. + */ wp_oembed_add_provider( '#https?://.+\.survey\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true ); -wp_oembed_add_provider( '#https?://poll\.fm/.*#i', 'https://api.crowdsignal.com/oembed', true ); } |