Skip to content

Commit dc44002

Browse files
committed
Added Bower
1 parent 0fc40b5 commit dc44002

5 files changed

Lines changed: 55 additions & 16 deletions

File tree

.bowerrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"directory" : "assets/components",
3+
"ignoredDependencies": [
4+
"jquery"
5+
]
6+
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ package-lock.json
4949

5050
# Bower #
5151
#########
52-
assets/bower_components/*
52+
assets/components/
5353

5454
# Codekit #
5555
###########

README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ It may also be used as the means of [separating custom code](http://www.billeric
1414

1515
* Namespaces & dependency autoloading
1616
* Version checking (PHP, Carbon Fields)
17-
* [Gulp](https://gulpjs.com/) for JavaScript/SASS processing & minification (see [Gulp](https://github.com/dmhendricks/wordpress-base-plugin/wiki#gulp) notes)
17+
* Powered by [Composer](https://getcomposer.org/), [Gulp](https://gulpjs.com/) and [Bower](https://bower.io/)
1818
* Object caching (where available; [usage examples](https://github.com/dmhendricks/wordpress-toolkit/wiki/ObjectCache))
1919
* Automatic translation file (`.pot`) creation. See [Translation](https://github.com/dmhendricks/wordpress-base-plugin/wiki#translation).
2020
* Shortcodes, widgets and custom post type (via [PostTypes](https://github.com/jjgrainger/PostTypes/)) examples
@@ -36,8 +36,29 @@ It may also be used as the means of [separating custom code](http://www.billeric
3636

3737
### Composer
3838

39-
1. Modify `composer.json` to suit your needs
40-
1. Run `composer install` to install dependencies and autoload namespace
39+
1. Modify `composer.json` to suit your needs.
40+
1. Run `composer install` to install dependencies and autoload namespace.
41+
42+
### NPM
43+
44+
1. Modify `package.json` to suit your needs. Specifically, change the `config` section.
45+
1. Run `npm install` to install dependencies.
46+
47+
### Bower
48+
49+
This step is only necessary for the "Clear Cache" Ajax example. Whether or not you choose to use Bower is up to you. Alternatively, you may put JavaScript dependencies in `src/vendor` and enqueue `assets/js/wordpress-base-plugin-vendor.js` as needed.
50+
51+
```
52+
$ bower install
53+
```
54+
55+
### Gulp
56+
57+
Using Gulp is also optional (but recommended). If you wish to try the base plugin with all of its examples, you will need to run Gulp to process the JavaScripts:
58+
59+
```
60+
$ gulp
61+
```
4162

4263
### Next Steps
4364

@@ -49,13 +70,17 @@ This plugin loads many of its defaults & settings from `plugin.json`. See [Confi
4970

5071
## Planned Features & TODO
5172

73+
#### Before 3.0 Pre-Release
74+
5275
* Update documentation to reflect recent changes
53-
* Add encrypt/decrypt example (`password` field with encrypted `hidden` field)
76+
* Add gulp task to package plugin as ZIP file; move NPM scripts to gulp tasks
77+
* Use [TGMPA](http://tgmpluginactivation.com/) for Carbon Fields dependency checking
78+
* Simplify/clean-up version checking in general
79+
80+
#### Future Releases
81+
5482
* Add Customizer example
5583
* Add dynamically-created CSS/JS files based on settings
56-
* Add gulp task to package plugin as zip file
57-
* Use [Bower](https://bower.io/) to manage vendor scripts and move `./src/js/vendor` to `./src/components`
58-
* Use [TGMPA](http://tgmpluginactivation.com/) for Carbon Fields dependency checking
5984

6085
## Change Log
6186

@@ -65,6 +90,7 @@ Release changes are noted on the [Releases](https://github.com/dmhendricks/wordp
6590

6691
* Bumped minimum PHP version check to 5.6
6792
* Added [Gulp](https://gulpjs.com/) for task automation (SASS, JS processing)
93+
* Added [Bower](https://bower.io/) to (optionally) load third-party scripts
6894
* Drastically refactored configuration management
6995
* Split out settings pages, shortcodes, CPT & widgets into separate files/classes (thanks [obstschale](https://github.com/obstschale/wordpress-base-plugin))
7096
* Added `wp-pot-cli` to `package.json` to create `.pot` translation file

app/EnqueueScripts.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ function __construct() {
3131
public function enqueue_frontend_scripts() {
3232

3333
// Enqueue script dependencies
34-
$this->enqueue_vendor_scripts();
34+
$this->enqueue_bower_scripts();
3535

3636
// Enqueuing custom CSS for child theme (Twentysixteen was used for testing)
3737
wp_enqueue_style( 'wordpress-base-plugin', $this->get_script_url('assets/css/wordpress-base-plugin.css'), null, $this->get_script_version('assets/css/wordpress-base-plugin.css') );
3838

3939
// Enqueue frontend JavaScript
40-
wp_enqueue_script( 'wordpress-base-plugin', $this->get_script_url('assets/js/wordpress-base-plugin.js'), array('jquery', 'wordpress-base-plugin-vendor'), $this->get_script_version('assets/js/wordpress-base-plugin.js'), true );
40+
wp_enqueue_script( 'wordpress-base-plugin', $this->get_script_url('assets/js/wordpress-base-plugin.js'), array('jquery', 'jquery-waituntilexists'), $this->get_script_version('assets/js/wordpress-base-plugin.js'), true );
4141
wp_localize_script( 'wordpress-base-plugin', 'wpbp_ajax_filter_params', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
4242

4343
}
@@ -49,25 +49,25 @@ public function enqueue_frontend_scripts() {
4949
public function enqueue_admin_scripts() {
5050

5151
// Enqueue script dependencies
52-
$this->enqueue_vendor_scripts();
52+
$this->enqueue_bower_scripts();
5353

5454
// Enqueuing custom CSS for child theme (Twentysixteen was used for testing)
5555
wp_enqueue_style( 'wordpress-base-plugin', $this->get_script_url('assets/css/wordpress-base-plugin-admin.css'), null, $this->get_script_version('assets/css/wordpress-base-plugin-admin.css') );
5656

5757
// Enqueue WP Admin JavaScript
58-
wp_enqueue_script( 'wordpress-base-plugin-admin', $this->get_script_url('assets/js/wordpress-base-plugin-admin.js'), array('jquery', 'wordpress-base-plugin-vendor'), $this->get_script_version('assets/js/wordpress-base-plugin-admin.js'), true );
58+
wp_enqueue_script( 'wordpress-base-plugin-admin', $this->get_script_url('assets/js/wordpress-base-plugin-admin.js'), array('jquery', 'jquery-waituntilexists'), $this->get_script_version('assets/js/wordpress-base-plugin-admin.js'), true );
5959
wp_localize_script( 'wordpress-base-plugin-admin', 'wpbp_ajax_filter_params', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
6060

6161
}
6262

6363
/**
64-
* Enqueue vendor scripts compiled from src/js/vendor
64+
* Enqueue Bower components from assets/components
6565
* @since 0.3.0
6666
*/
67-
private function enqueue_vendor_scripts() {
67+
private function enqueue_bower_scripts() {
6868

6969
// Enqueue common (frontend/backend) JavaScript
70-
wp_enqueue_script( 'wordpress-base-plugin-vendor', $this->get_script_url('assets/js/wordpress-base-plugin-vendor.js'), array('jquery'), $this->get_script_version('assets/js/wordpress-base-plugin-vendor.js'), true );
70+
wp_enqueue_script( 'jquery-waituntilexists', $this->get_script_url('assets/components/jq.waituntilexists/jquery.waitUntilExists.min.js', false), array('jquery'), '0.1.0' );
7171

7272
}
7373

@@ -77,7 +77,7 @@ private function enqueue_vendor_scripts() {
7777
*/
7878
public function enqueue_font_awesome() {
7979

80-
wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', null, '4.7.0' );
80+
wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', null, '4.7.0', true );
8181

8282
}
8383

bower.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "wordpress-base-plugin",
3+
"dependencies": {
4+
"jq.waituntilexists": "*"
5+
},
6+
"private": true
7+
}

0 commit comments

Comments
 (0)