2017 © Pedro Peláez
 

library wp-dependencies

A composer package for WordPress to help manage plugin dependencies.

image

voceconnect/wp-dependencies

A composer package for WordPress to help manage plugin dependencies.

  • Monday, July 13, 2015
  • by voceconnect
  • Repository
  • 4 Watchers
  • 5 Stars
  • 14,046 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 2 % Grown

The README.md

WP Dependencies

A composer package for WordPress to autoload plugin dependencies., (*1)

Usage

For Themes and Plugins

Require the Dependencies and WP Dependencies Package

Add a reference to wp-dependencies to your theme's or plugin's composer.json along with any other plugins that need to be active., (*2)

{
    "name": "my-account/my-theme",
    "type": "wordpress-theme",
    "authors": [
        {
            "name": "John Doe",
            "email": "john@example.com"
        }
    ],
    "repositories": [
        {
            "type": "composer",
            "url" : "http://wp-plugins.packagist.voceconnect.com/"
        },
        ...
    ],
    "config": {
        "vendor-dir": "vendor"
    },
    "require": {
        "voceconnect/wp-dependencies": "~0.1",
        "wpackagist/thermal-api: "~0.7"
        ...
    }
}

Add Composer's Autoload

For WordPress Projects

Because of the way WordPress loads, it is suggested that the mu-plugins directory be set as the vendor. This allows Composer's autoload.php to be loaded automatically after WordPress' plugin API has already been setup., (*3)

{
    ...
    "config": {
        "vendor-dir": "wp-content/mu-plugins"
    },
    ...
}

For WordPress Themes or Plugins

Include Composer's autoload.php in the theme's functions.php or in your plugin's main file. The below example assume's the plugin's or theme's vendor-dir setting composer.json is set to vendor., (*4)

// bootstrap composer autoload for dependencies
if(file_exists( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php' ) ) {
    include_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php' );
}

Load Dependencies

For dependencies or plugins that do not autoload through composer, you will need to load the dependency through one of two ways., (*5)

do_action( 'wp_load_dependency', 'some-plugin-name', 'main-plugin-file.php');

or, (*6)

if (function_exists('wp_load_dependency')) {
     wp_load_dependency('some-plugin-name', 'main-plugin-file.php');
}

The former action based loading is preferred as it provides more flexibility for future iterations., (*7)

The Versions

13/07 2015

dev-master

9999999-dev

A composer package for WordPress to help manage plugin dependencies.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.2.4

 

by Michael Prettty

13/07 2015

0.2.0

0.2.0.0

A composer package for WordPress to help manage plugin dependencies.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.2.4

 

by Michael Prettty

25/04 2014

v0.1.2

0.1.2.0

A composer package for WordPress to help manage plugin dependencies.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.2.4

 

by Mike Pretty

05/11 2013

v0.1.1

0.1.1.0

A composer package for WordPress to help manage plugin dependencies.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.2.4

 

by Mike Pretty

29/10 2013

v0.1.0

0.1.0.0

A composer package for WordPress to help manage plugin dependencies.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.2.4

 

by Mike Pretty