Download the PHP package wrd/wp-objective without Composer
On this page you can find all versions of the php package wrd/wp-objective. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wrd/wp-objective
More information about wrd/wp-objective
Files in wrd/wp-objective
Package wp-objective
Short Description A set of classes for building consistent WordPress plugins.
License MIT
Informations about the package wp-objective
WP-Objective
:warning: This package is currently experimental.
Objective is a batteries-included framework for building consistent WordPress plugins.
It includes setup for many common plugin requirements - such as Custom Post Types, Admin Actions, HTTP Clients, Rest API Development, Migrations - all wrapped in a Laravel inspired API.
Created by Kyle Cooper at WRD Studio.
Installation
This project is available for installation via Composer.
Getting Started
Objective uses a global plugin which serves as a container to manage global objects. You can use the plugin() utility to grab the current instance.
The plugin is a container responsible for instantiating objects & injecting their dependencies, using it's bindings to do so.
Bindings
You can also register bindings, allowing every part of Objective to use the correct object/class when looking for it. Objective comes with a range a default bindings to provide sensible defaults and will also look for unbound classes directly when needed.
You can use this functionality override the default Plugin instance or any other piece of functionality. For example, by switching the Logging_Manager to store to the database.
:warning: You should always bind your own extension of the base
Pluginclass. This allows Objective to keep track of your plugin file/directory.
Service Providers
You can add in your service providers which come with convenient methods for the WordPress plugin lifecycle. Your service providers allow ways for separate 'components' too hook into the plugin lifecycle without needing to define loose hooks.
Configuration
You can configure your plugin's bindings & service providers by create an extension of the Plugin class, like below. In your plugin's entrypoint file you can then create a global instance and boot it.
Plugin Class
Your plugin should include your own extension of the base Plugin class. This is the only item that is required be bound in your config.
The plugin class is primarily responsible for storing your plugin file, directory and version.
It also comes with a range of pre-built hooks for you enqueue assets or spin off any effects need (though it's recommended to use service providers if possible).
Facades
Many of the Plugin's bindings can be easily accessed via Laravel-style Facades. Simply call these statically and your call will be mapped to the function in the current instance.
Deeper Dive
Actions
It's common for plugins to need to allow their users to perform actions that can be triggered from WordPress. Objective includes the 'Action' class to make this easier.
A permissions callback is required to ensure the user is allowed to perform the action.
You can provide the URL the user should be redirected to upon successful completion.
You can provide arguments, in the same format as the REST API. These will be sanitized & validated before they react your handle function.
Define your action like so,
You'll need to make sure you either bind or provide your class. Objects that inherit from the Service_Provider class (which Action does) will automatically be provided when they're bound.
Collections
Many of Objective's methods will return a Collection object, rather than an array. This is a class which includes many utility functions for manipulating the data in a fluent API.
You can create your own collection like so,
If you need to access the raw array underneath, you can always call $collection->all().
Migrations
Migrations allow you to lay out the steps your plugin needs to make for every new version. For example, you might want to create a database table in version 1.0.0 and then you may need to add an additional column to the table in version 1.1.0.
You simply define a migration for each new plugin version that needs to be migrated and Objective will handle running through them upon activation and storing the version currently migrated to.
Learn More
More documentation is coming soon. In the meantime dive into the code to learn more about,
- Post States
- Flashes
- List Tables
- Metaboxes
- Notices
- API Routes
- API Endpoints
- API Objects
- Emails
- HTTP Requests, Responses & Clients
- Money & Currency
- Post Types
- Posts
- Templates
- Settings
- HTML Building
All versions of wp-objective with dependencies
phpdocumentor/reflection-docblock Version ^5.6
adhocore/cli Version v1.0.0