Skip to content

Commit

Permalink
Merge pull request #282 from 10up/enhancement/193
Browse files Browse the repository at this point in the history
Replace custom build process with WP-Scripts
  • Loading branch information
ravinderk authored Oct 12, 2023
2 parents e6303cf + 003544c commit 34564ff
Show file tree
Hide file tree
Showing 24 changed files with 26,880 additions and 20,424 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

1 change: 0 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ phpcs.xml
phpunit.xml
README.md
webpack.config.js
webpack.gutenberg.config.js
4 changes: 1 addition & 3 deletions .github/workflows/build-release-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ jobs:
run: composer install --no-dev

- name: Build plugin
run: |
npm run build
npm run build:externals
run: npm run build

- name: Generate ZIP file
uses: 10up/action-wordpress-plugin-build-zip@stable
1 change: 0 additions & 1 deletion .github/workflows/deploy-to-wpdotorg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
run: |
npm install
npm run build
npm run build:externals
composer install -o --no-dev --ignore-platform-reqs
- name: WordPress Plugin Deploy
id: deploy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: npm install
run: npm install
- name: Run eslint
run: npm run lint
run: npm run lint:js
1 change: 0 additions & 1 deletion .github/workflows/update-wpdororg-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
run: |
npm install
npm run build
npm run build:externals
composer install -o --no-dev --ignore-platform-reqs
- name: WordPress.org plugin asset/readme update
uses: 10up/action-wordpress-plugin-asset-update@stable
Expand Down
2 changes: 1 addition & 1 deletion assets/css/admin-autoshare-for-twitter.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ span.over-limit {
/* Styling for post columns */
.fixed .column-is_tweeted {
width: 50px;
vertical-align: middle;
vertical-align: top;
}

.fixed .column-is_tweeted a {
Expand Down
52 changes: 17 additions & 35 deletions includes/admin/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,35 +111,6 @@ function maybe_enqueue_classic_editor_assets( $hook ) {
return;
}

$api_fetch_handle = 'wp-api-fetch';
if ( ! wp_script_is( $api_fetch_handle, 'registered' ) ) {
wp_register_script(
$api_fetch_handle,
trailingslashit( AUTOSHARE_FOR_TWITTER_URL ) . 'dist/api-fetch.js',
[],
'3.4.0',
true
);

wp_add_inline_script(
$api_fetch_handle,
sprintf(
'wp.apiFetch.use( wp.apiFetch.createNonceMiddleware( "%s" ) );',
( wp_installing() && ! is_multisite() ) ? '' : wp_create_nonce( 'wp_rest' )
),
'after'
);

wp_add_inline_script(
$api_fetch_handle,
sprintf(
'wp.apiFetch.use( wp.apiFetch.createRootURLMiddleware( "%s" ) );',
esc_url_raw( get_rest_url() )
),
'after'
);
}

$handle = 'admin_autoshare_for_twitter_classic_editor';
wp_enqueue_script(
$handle,
Expand Down Expand Up @@ -168,10 +139,11 @@ function enqueue_editor_assets() {
return;
}

wp_enqueue_script(
SCRIPT_HANDLE,
trailingslashit( AUTOSHARE_FOR_TWITTER_URL ) . 'dist/autoshare-for-twitter.js',
[
$asset_file = AUTOSHARE_FOR_TWITTER_PATH . '/dist/autoshare-for-twitter.asset.php';
// Fallback asset data.
$asset_data = array(
'version' => AUTOSHARE_FOR_TWITTER_VERSION,
'dependencies' => array(
'lodash',
'wp-components',
'wp-compose',
Expand All @@ -180,8 +152,18 @@ function enqueue_editor_assets() {
'wp-element',
'wp-i18n',
'wp-plugins',
],
AUTOSHARE_FOR_TWITTER_VERSION,
'wp-primitives',
),
);
if ( file_exists( $asset_file ) ) {
$asset_data = require $asset_file;
}

wp_enqueue_script(
SCRIPT_HANDLE,
trailingslashit( AUTOSHARE_FOR_TWITTER_URL ) . 'dist/autoshare-for-twitter.js',
$asset_data['dependencies'],
$asset_data['version'],
true
);

Expand Down
Loading

0 comments on commit 34564ff

Please sign in to comment.