Download the PHP package morningtrain/wp-enqueue without Composer

On this page you can find all versions of the php package morningtrain/wp-enqueue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-enqueue

WP Enqueue

For easy script and style enqueueing in WordPress. With Laravel Mix Manifest and WP-Scripts asset file support!

Table of Contents

Introduction

This tool is made for making the enqueueing and registering of WordPress scripts a bit more expressive and to make using laravel Mix Manifest much easier to manage.

This tool lets you:

Getting Started

Fist install the package!

Then from here on your entry point will be \Morningtrain\WP\Enqueue\Enqueue.

Installation

This tool is available as a package and can be installed through composer:

Usage

Here is a quick example of how this package works!

Before you start

All relative paths should match paths in webpack.mix.js.

So if you have the following in your mix:

Then your public directory would be public/build and all assets would use a source relative to this path. So in the above example, you would enqueue app.js like this:

Note: Enqueueing assets before the wp_enqueue_scripts hook will automatically delay the enqueueing until WordPress is ready. You should, of course, still enqueue properly in the right hook.

Defining the root Url

You may define the root URL of your build directory.

By doing this you can now enqueue assets using a relative path. This should match the one defined in webpack.mix.js if you are using Laravel Mix

You may also get the url by calling Enqueue::getRootUrl()

Adding a MixManifest file

If you are using Laravel Mix then you can add the generated mix-manifest.json file. By doing this all enqueued assets will automatically use the hashed sources.

This is an easy and convenient way to clear client cached assets without worry.

You may also retrieve the manifest content

Loading scripts and styles

Loading a script or a style is almost the same! Construct either a Script or a Style from Enqueue

Then, using a fluid api, you can configure your asset and then either enqueue or register at the end.

Note: These methods act the same as, and wraps, WordPress methods wp_enqueue_script() and wp_enqueue_style() and their register equivalents.

After this inspect the instance returned. All options are available as chainable methods!

Enqueueing

To enqueue simply end your chain by calling enqueue()

Registering

To register instead of enqueueing use register()

Then later you can enqueue your asset this way:

Options

There are the same options as the methods these classes wrap.

Note: deps() also accepts a string and if you call it multiple times in the same chain then every call pushes its value to the list.

Script

Here is an example using all available options:

See wp_enqueue_script on developer.wordpress.org

Style

Here is an example using all available options:

See wp_enqueue_style on developer.wordpress.org

Namespacing

You may register a namespace for a set of scripts or styles that live somewhere else in your codebase.

To do this simple add the namespace and then use this namespace in your handles. Namespacing is especially useful when writing a plugin.

Adding a namespace

Using a namespace

Credits

Testing

License

The MIT License (MIT). Please see License File for more information.


All versions of wp-enqueue with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package morningtrain/wp-enqueue contains the following files

Loading the files please wait ....