Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #417 from Automattic/playbuzz
Browse files Browse the repository at this point in the history
Support for Playbuzz plugin
  • Loading branch information
philipjohn committed Oct 11, 2016
2 parents 53fb17e + 5e4314f commit 614020e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
14 changes: 8 additions & 6 deletions compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
* @package default
*/

if ( !function_exists( 'is_plugin_active' ) ) {
require_once ( ABSPATH . '/wp-admin/includes/plugin.php' );
}


// Load compat layer for Co-Authors Plus.
if ( function_exists( 'get_coauthors' ) && ! defined( 'CAP_IA_COMPAT' ) ) {
include( dirname( __FILE__ ) . '/compat/class-instant-articles-co-authors-plus.php' );
Expand Down Expand Up @@ -41,8 +36,15 @@
}

// Load support for Get The Image plugin
if ( is_plugin_active( 'get-the-image/get-the-image.php' ) ) {
if ( function_exists( 'get_the_image' ) ) {
include( dirname( __FILE__ ) . '/compat/class-instant-articles-get-the-image.php' );
$gti = new Instant_Articles_Get_The_Image;
$gti->init();
}

// Load support for Playbuzz plugin
if ( function_exists( 'playbuzz_settings_link' ) ) {
include( dirname( __FILE__ ) . '/compat/class-instant-articles-playbuzz.php' );
$playbuzz = new Instant_Articles_Playbuzz;
$playbuzz->init();
}
27 changes: 27 additions & 0 deletions compat/class-instant-articles-playbuzz.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* Support class for Playbuzz
*
* @since 3.1.1
*
*/
class Instant_Articles_Playbuzz {

/**
* Init the compat layer
*
*/
function init() {
add_filter( 'instant_articles_transformer_rules_loaded', array( 'Instant_Articles_Playbuzz', 'transformer_loaded' ) );
}

public static function transformer_loaded( $transformer ) {
// Appends more rules to transformer
$file_path = plugin_dir_path( __FILE__ ) . 'playbuzz-rules-configuration.json';
$configuration = file_get_contents( $file_path );
$transformer->loadRules( $configuration );

return $transformer;
}
}
23 changes: 23 additions & 0 deletions compat/playbuzz-rules-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"rules": [{
"class" : "IgnoreRule",
"selector": "//p/script[contains(@src,'playbuzz')]"
}, {
"class": "InteractiveRule",
"selector" : "div.pb_feed",
"properties" : {
"interactive.iframe" : {
"type" : "multiple",
"children": [{
"type": "fragment",
"fragment": "<script type='text/javascript' src='//cdn.playbuzz.com/widget/feed.js'></script>"
}, {
"type": "element",
"selector": "div.pb_feed"
}
]
}
}
}
]
}

0 comments on commit 614020e

Please sign in to comment.