Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
feat(injector): add a filter for the js injector
Browse files Browse the repository at this point in the history
  • Loading branch information
luisherranz committed Dec 10, 2018
1 parent dd8df13 commit b6d9fd9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions injector/wp-pwa-injector.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,23 @@
$inject = false;
}
}

?>

<?php if ($inject) { ?>
<script type='text/javascript'>window['wp-pwa']={siteId:'<?php echo $siteId; ?>',type:'<?php echo $type; ?>',id:'<?php echo $id; ?>',<?php if ($page) echo 'page:\'' . $page . '\',' ?>env:'<?php echo $env; ?>',dev:'<?php echo $dev; ?>',perPage:'<?php echo $perPage; ?>',ssr:'<?php echo $ssr; ?>',initialUrl:'<?php echo $initialUrl; ?>',static:'<?php echo $static; ?>'<?php if ($break) echo ',break:true' ?><?php if (sizeof($excludes) !== 0) echo ',excludes:["' . str_replace('\\\\', '\\', implode('", "', $excludes)) . '"]' ?>};
<?php if ($break) {
echo 'debugger;';
require(WP_PLUGIN_DIR . $GLOBALS['wp_pwa_path'] . '/injector/injector.js');
ob_start();
include(WP_PLUGIN_DIR . $GLOBALS['wp_pwa_path'] . '/injector/injector.js');
$buffer = ob_get_clean();
$buffer = apply_filters('frontity_javascript_injector', $buffer);
echo $buffer;
} else {
require(WP_PLUGIN_DIR . $GLOBALS['wp_pwa_path'] . '/injector/injector.min.js');
ob_start();
include(WP_PLUGIN_DIR . $GLOBALS['wp_pwa_path'] . '/injector/injector.min.js');
$buffer = ob_get_clean();
$buffer = apply_filters('frontity_javascript_injector', $buffer);
echo $buffer;
} ?></script>
<?php } ?>

0 comments on commit b6d9fd9

Please sign in to comment.