-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
complete rewrite #2
Draft
davidmondok
wants to merge
6
commits into
master
Choose a base branch
from
dev
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d0bde8a
complete rewrite
davidmondok e16694f
remove .idea folder
davidmondok 181623a
implemented feedback
davidmondok a455b2e
full test coverage
davidmondok b5a296a
clean up tests
davidmondok 9b3a4e7
wip rewrite
davidmondok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,16 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
|
||
[*.php] | ||
indent_size = 4 | ||
|
||
[*.md] | ||
indent_size = 4 | ||
trim_trailing_whitespace = false |
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,31 @@ | ||
name: Tests | ||
on: [push, pull_request] | ||
jobs: | ||
bedrock: | ||
name: ScriptsStylesLoader (PHP ${{ matrix.php-versions }}) | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-versions: ['7.2', '7.3'] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup PHP, with composer and extensions | ||
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
# Use composer.json for key, if composer.lock is not committed. | ||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install Composer dependencies | ||
run: composer install -n --prefer-dist | ||
- name: PHP test | ||
run: composer check |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,18 @@ | ||
### Plugin ### | ||
assets | ||
|
||
# GulpPress Local Config | ||
gulppress.local.config.ts | ||
|
||
### Logs ### | ||
*.log | ||
|
||
### Dotenv ### | ||
.env | ||
.env.* | ||
!.env.example | ||
|
||
### Composer ### | ||
/vendor | ||
|
||
### WP-CLI ### | ||
wp-cli.local.yml | ||
|
||
### Database dumps ### | ||
db-sync | ||
*.sql | ||
/assets/* | ||
!/assets/src/ | ||
/wordpress/ | ||
|
||
### Composer ### | ||
vendor | ||
/vendor/ | ||
/composer.lock | ||
|
||
### Node ### | ||
.node/ | ||
node_modules/ | ||
npm-debug.log | ||
.npmrc | ||
|
||
### Log files ### | ||
**/log | ||
npm-debug.log* | ||
yarn-error.log* | ||
|
||
### Mac OSX + Windows ### | ||
.DS_Store | ||
Thumbs.db | ||
|
||
### Vim ### | ||
*.sw[op] | ||
*.un~ | ||
/node_modules/ | ||
/yarn.lock | ||
|
||
### Editor directory ### | ||
.idea | ||
.vscode | ||
**/.idea | ||
**/.vscode | ||
### GulpPress Local Config ### | ||
/gulppress.local.config.ts | ||
|
||
### Archives ### | ||
*.tar.gz | ||
*.zip | ||
## Tests ### | ||
/infection-log.txt |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1,84 @@ | ||
# wplib-AssetLoader | ||
# WordPress Plugin - Woda Scripts Styles Loader | ||
|
||
> Load assets without the hassle | ||
|
||
## Installation | ||
|
||
You can install the plugin by uploading it in the WordPress Admin or via `composer`. | ||
|
||
```bash | ||
composer require woda/wp-scripts-styles-loader | ||
``` | ||
|
||
## Configure | ||
|
||
Pass the settings to the init function or hook into the supplied filter | ||
|
||
```php | ||
use Woda\WordPress\ScriptsStylesLoader\HashFile; | ||
use Woda\WordPress\ScriptsStylesLoader\Script; | ||
use Woda\WordPress\ScriptsStylesLoader\Style; | ||
|
||
// Import a json containing cache busting hash values, versions, etc. | ||
$scriptsHashFile = new HashFile(get_stylesheet_directory() . '/assets/js/.assets.json'); | ||
|
||
/** | ||
* Create a Script Helper | ||
* | ||
* @param string $src Full URL of the script, or path of the script relative to the WordPress root directory. | ||
* @param string[] $deps Optional. An array of registered script handles this script depends on. Default empty array. | ||
* @param string $handle Optional. Name of the script. Should be unique. | ||
* If empty, handle will be generated from prefix and file name. | ||
* @param string|bool|null $ver Optional. String specifying script version number, if it has one, which is added to the URL | ||
* as a query string for cache busting purposes. If version is set to false, a version | ||
* number is automatically added equal to current installed WordPress version. | ||
* If set to null, no version is added. | ||
* @param string $inFooter Optional. Whether to enqueue the script before </body> instead of in the <head>. | ||
* Default 'false'. | ||
*/ | ||
(new Script(get_stylesheet_directory_uri() . '/assets/js/main.js', ['jquery'], null, null, true)) | ||
// Cache busting via a hash file | ||
->addHashFile($scriptsHashFile) | ||
// Enqueue in the frontend. | ||
->enqueue() | ||
// Enqueue in the backend. | ||
->enqueueAdmin(); | ||
|
||
// Replace jQuery in the frontend with your own version | ||
(new Script(get_stylesheet_directory_uri() . '/assets/js/vendor/jquery.js', ['jquery-core', 'jquery-migrate'], 'jquery')) | ||
// Calculate an md5 hash value for cache busting purposes. | ||
->calculateHashValue() | ||
// Deregister the handle we are about to reregister | ||
->deregister() | ||
// Register our replacement | ||
->register(); | ||
|
||
|
||
$stylesHashFile = new HashFile(get_stylesheet_directory() . '/assets/css/.assets.json'); | ||
/** | ||
* Create a Style Helper | ||
* | ||
* @param string $src Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. | ||
* @param string[] $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array. | ||
* @param string $handle Optional. Name of the stylesheet. Should be unique. | ||
* If empty, handle will be generated from prefix and file name. | ||
* @param string|bool|null $ver Optional. String specifying stylesheet version number, if it has one, which is added to the URL | ||
* as a query string for cache busting purposes. If version is set to false, a version | ||
* number is automatically added equal to current installed WordPress version. | ||
* If set to null, no version is added. | ||
* @param string $media Optional. The media for which this stylesheet has been defined. | ||
* Default 'all'. Accepts media types like 'all', 'print' and 'screen', or media queries like | ||
* '(orientation: portrait)' and '(max-width: 640px)'. | ||
*/ | ||
(new Style(get_stylesheet_directory_uri() . '/assets/css/main.css')) | ||
->addHashFile($stylesHashFile) | ||
->enqueue(); | ||
(new Style(get_stylesheet_directory_uri() . '/assets/css/admin.css')) | ||
->addHashFile($stylesHashFile) | ||
->enqueueAdmin(); | ||
(new Style(get_stylesheet_directory_uri() . '/assets/css/editor2.css')) | ||
->addHashFile($stylesHashFile) | ||
// Add an editor style | ||
// https://codex.wordpress.org/Editor_Style | ||
->enqueueEditor(); | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe describe format of
assets.json
or reference the node package that is creating thisand maybe reference to gulppress