10quality/wpmvc-addon-resources

WordPress MVC add-on resources (common assets).

Installs: 2 964

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 1

Open Issues: 2

Language:JavaScript

v1.0.5 2023-01-05 22:08 UTC

This package is auto-updated.

Last update: 2024-10-06 02:18:50 UTC


README

Latest Stable Version Total Downloads License

This package provides resources (in the form of assets) that may be shared by different add-ons or WordPress MVC projects.

Setup

Via composer

Install the package via composer:

composer install 10quality/wpmvc-addon-resources --no-plugins

Via composer.json

Add this package as your add-on dependencies ("require"):

{
    "require": {
        "10quality/wpmvc-addon-resources": "1.0.*"
    },
}

And run:

composer update --no-plugins

Resources

Usage

This package provides 2 global functions:

wpmvc_register_addon_resource

wpmvc_register_addon_resource() is used to register the asset.

wpmvc_register_addon_resource( $resource_id );

And:

wpmvc_enqueue_addon_resource() is used to force enqueue the asset.

wpmvc_enqueue_addon_resource( $resource_id );

Resources list

Samples:

add_action( 'wp_enqueue_scripts', function() {
    
    wpmvc_register_addon_resource( 'font-awesome' );
    wpmvc_register_addon_resource( 'select2' );
    wpmvc_register_addon_resource( 'wpmvc-select2' );

} );

Or:

add_action( 'wp_enqueue_scripts', function() {
    
    wpmvc_enqueue_addon_resource( 'font-awesome' );
    wpmvc_register_addon_resource( 'select2' );
    wpmvc_enqueue_addon_resource( 'wpmvc-select2' );

} );

You can also use regular WordPress enqueue functions after the resources have been registered:

wp_enqueue_style( 'font-awesome' );
wp_enqueue_style( 'wpmvc-select2' );
wp_enqueue_script( 'wpmvc-select2' );

Coding Guidelines

PSR-2 coding guidelines.

License

MIT License. (c) 2020 10 Quality.