Skip to content

Commit

Permalink
Somewhat tidier way of doing the script.
Browse files Browse the repository at this point in the history
This lets it be inline on the page, with the other scripts -- rather
than printed at the very bottom.

Leaving the `script` tags there but commented out so PHPStorm still
syntax highlights it as js.
  • Loading branch information
georgestephanis committed Aug 5, 2017
1 parent 1fbb0d4 commit 6817940
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions modules/shortcodes/tweet.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,23 @@ static public function jetpack_tweet_shortcode_script() {
}

static public function enqueue_block_editor_assets() {
wp_enqueue_script( 'wp-blocks' );
wp_enqueue_script( 'wp-i18n' );
wp_enqueue_script( 'wp-element' );
wp_enqueue_script( 'shortcode' );
add_action( 'admin_print_footer_scripts', array( __CLASS__, 'admin_footer' ), 999 );
wp_register_script(
'jetpack-shortcode-tweet-gutenberg',
null,
array( 'wp-blocks', 'wp-i18n', 'wp-element', 'shortcode' )
);
wp_enqueue_script( 'jetpack-shortcode-tweet-gutenberg' );

ob_start();
self::jetpack_shortcode_tweet_gutenberg_script();
$content = ob_get_clean();

wp_script_add_data( 'jetpack-shortcode-tweet-gutenberg', 'data', $content );
}

static public function admin_footer() {
static public function jetpack_shortcode_tweet_gutenberg_script() {
?>
<script>
// <script>
( function( wp ) {
var blockStyle = {
backgroundColor: '#900',
Expand Down Expand Up @@ -203,7 +210,7 @@ static public function admin_footer() {

} );
} )( window.wp );
</script>
// </script>
<?php
}

Expand Down

0 comments on commit 6817940

Please sign in to comment.