-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from WordPress/refactor/react-app
Refactor react app code for general purpose
- Loading branch information
Showing
7 changed files
with
44 additions
and
39 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
class React_App { | ||
public static function bootstrap() { | ||
// Load the required WordPress packages. | ||
// Automatically load imported dependencies and assets version. | ||
$asset_file = include plugin_dir_path( __DIR__ ) . 'build/index.asset.php'; | ||
|
||
// Enqueue CSS dependencies of the scripts included in the build. | ||
foreach ( $asset_file['dependencies'] as $style ) { | ||
wp_enqueue_style( $style ); | ||
} | ||
|
||
// Enqueue CSS of the app | ||
wp_enqueue_style( 'create-block-theme-app', plugins_url( 'build/index.css', __DIR__ ), array(), $asset_file['version'] ); | ||
|
||
// Load our app.js. | ||
array_push( $asset_file['dependencies'], 'wp-i18n' ); | ||
wp_enqueue_script( 'create-block-theme-app', plugins_url( 'build/index.js', __DIR__ ), $asset_file['dependencies'], $asset_file['version'] ); | ||
|
||
// Set google fonts json file url. | ||
wp_localize_script( | ||
'create-block-theme-app', | ||
'createBlockTheme', | ||
array( | ||
'googleFontsDataUrl' => plugins_url( 'assets/google-fonts/fallback-fonts-list.json', __DIR__ ), | ||
'adminUrl' => admin_url(), | ||
'themeUrl' => get_stylesheet_directory_uri(), | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters