Skip to content

Commit

Permalink
Crowdsignal: Fix poll embeds on P2 (#14826)
Browse files Browse the repository at this point in the history
* Crowdsignal: Fix poll embeds on P2. Refs D35940

This commit syncs r203465-wpcom.

* Correct version number

Co-authored-by: Dan Roundhill <dan@automattic.com>
Co-authored-by: Brandon Kraft <public@brandonkraft.com>
  • Loading branch information
3 people authored Mar 5, 2020
1 parent 1364e80 commit 7393c78
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions modules/shortcodes/crowdsignal.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,15 @@ class_exists( 'Jetpack_AMP_Support' )
)
);

/**
* Hook into the Crowdsignal shortcode before rendering.
*
* @since 8.4.0
*
* @param int $poll Poll ID.
*/
do_action( 'crowdsignal_shortcode_before', intval( $poll ) );

return sprintf(
'<a name="pd_a_%1$d"></a><div class="CSS_Poll PDS_Poll" id="PDI_container%1$d" data-settings="%2$s" style="display:inline-block;%3$s%4$s"></div><div id="PD_superContainer"></div><noscript>%5$s</noscript>',
absint( $poll ),
Expand All @@ -464,6 +473,9 @@ class_exists( 'Jetpack_AMP_Support' )
true
);

/** This action is already documented in modules/shortcodes/crowdsignal.php */
do_action( 'crowdsignal_shortcode_before', intval( $poll ) );

return sprintf(
'<a id="pd_a_%1$s"></a><div class="CSS_Poll PDS_Poll" id="PDI_container%1$s" style="display:inline-block;%2$s%3$s"></div><div id="PD_superContainer"></div><noscript>%4$s</noscript>',
absint( $poll ),
Expand Down Expand Up @@ -729,7 +741,7 @@ public function crowdsignal_shortcode_infinite() {

if ( ! function_exists( 'crowdsignal_link' ) ) {
/**
* Replace link by embed.
* Replace link with shortcode.
* Example: http://polldaddy.com/poll/1562975/?view=results&msg=voted
*
* @param string $content Post content.
Expand All @@ -744,9 +756,8 @@ class_exists( 'Jetpack_AMP_Support' )

return jetpack_preg_replace_outside_tags(
'!(?:\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", // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
$content,
'polldaddy.com/poll'
'[crowdsignal poll=$2]',
$content
);
}

Expand Down

0 comments on commit 7393c78

Please sign in to comment.