| .. | ||
| bootstrap.php | ||
| oauth.php | ||
| README.md | ||
| remote-installer-skin.php | ||
Ninja Forms Services
Requires PHP v5.6+.
Definition of Terms
- Client: The WordPress installation where the Ninja Forms plugin is installed.
- Server: The site providing service functionality, ie My.NinjaForms.com.
Registering Service Integrations
- Filter:
ninja_forms_services
Note: This filter is implemented during an AJAX request, which is used to "live update" the current state of a service from the Ninja Forms Dashboard. The below properties can be set dynamically to correspond to the current "state" of the service.
Example
add_filter( 'ninja_forms_services', function( $services ){
$services[ 'my-service' ] => [
'name' => esc_html__( 'My Service', 'textdomain' ),
'slug' => 'my-service', // Duplicate of the array key.
'description' => esc_html__( 'This is my service.', 'textdomain' ),
'enabled' => true,
'installPath' => 'my-plugin/my-plugin.php',
];
return $services;
});
Properties:
namestring (required) The translatable, human-readable name of the service.slugstring (required) The programatic reference for the registered service.descriptionstring (required) The short description to display on the services tab.enabledbool|null (required) Passnullto disable the toggle.installPathstring (required) The expected plugin install path (inside of/wp-content/plugins).learnMorestring (required) The content of the "Learn More" modal.
Additional properties for installed service plugins:
serviceLinkarray (required) Properties for the external link to manage the service.textstring The content of the service link.hrefstring The URL of the service link.classesstring Add additional classes to the link, ie 'nf-button primary'.targetstring Specify the anchor target.
connect_urlstring Override the OAuth connection URL.successMessagestring The content of the modal after the service is setup.- The success message can be triggered by passing the
?successquery string in the OAuth redirect with theslugof the service.
- The success message can be triggered by passing the
OAuth Connection to My.NinjaForms.com
Ninja Forms services are provided via a secure OAuth connection to My.NinjaForms.com.
The client generates a local secret key which is passed to the server when connecting a service.
The server accepts the passed secret key, registers an new OAuth Client, and returns the OAuth Client ID.
Communication between the server and the client requires a hash of the combined OAuth Client ID and OAuth Client Secret.
Registered services have access to OAuth connection data via the \NinjaForms\OAuth class.
::is_connected()::get_client_id()::get_client_secret()::connect_url()
Customizing the OAuth Connect Flow
The OAuth flow can be customized the a specific service (for an optimization experience) by passing a connect_url (See above).
Remote Plugin Installation
Service integrations are provided as additional plugins, which are installed remotely from the WordPress.org plugin directory.
This remote plugin installation uses a custom Plugin_Installer_Skin in order to suppress any output feedback text - since this process happens asynchronously.
See services/remote-installer-skin.php.
Local Development
When developing with a local copy the Ninja Forms Server, specify the NF_SERVER_URL.
Example:
define('NF_SERVER_URL', 'https://my.ninjaforms.test');