Skip to content

Commit

Permalink
Merge pull request #40 from shortlist-digital/instant-articles-whitelist
Browse files Browse the repository at this point in the history
Bring changes into master & widget white list
  • Loading branch information
Leo authored Oct 5, 2018
2 parents 56232bc + b3c3cb6 commit 4d4bbc5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace AgreableInstantArticlesPlugin\Generators;

class Telemetry_acquisition implements GeneratorInterface
class TelemetryAcquisition implements GeneratorInterface
{
public function get( $widget ) {

$site = \getenv('FACEBOOK_IA_DOMAIN');
$url = \getenv('WEB_BASE_URL');

Expand Down
31 changes: 30 additions & 1 deletion app/Services/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ private function get_content_components( $post ) {

foreach ( get_field( 'widgets', $post->ID ) as $widget ) {
$widget_name = $widget['acf_fc_layout'];

if ($this->compatible_widget($widget_name) !== true) {
continue;
}

$generator = GeneratorFactory::create( $widget_name );
$widget_components = $generator->get($widget, $post);

Expand All @@ -59,4 +62,30 @@ private function get_footer_components( $post ) {

return $components;
}

// Currently ignored
// 'image-carousel',
// 'product-carousel',
// 'content-group',
// 'quick-links'
// related-articles
// polls
private function compatible_widget($widget) {
$compatible_widgets = [
'button',
'divider',
'embed',
'gallery',
'heading',
'html',
'image',
'listicle',
'newsletter_signup',
'paragraph',
'pull-quote',
'telemetry_acquisition'
];

return in_array( $widget, $compatible_widgets, true );
}
}

0 comments on commit 4d4bbc5

Please sign in to comment.