Skip to content

In addition to the OpenWOO plugin, the OpenWOO theme implementation is required to handle and process submissions into OpenWOO posts via GravityForms.

License

Notifications You must be signed in to change notification settings

OpenWebconcept/openwoo-theme-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

OpenWOO theme implementation

First, install and activate the OpenWOO plugin. This plugin will handle the registration of the custom post type (CPT) and the API REST routes. Ensure the OpenWOO directory is present in your theme. The code within this directory will process submissions when someone submits an OpenWOO via a GravityForms form.

Set-up

Add the following action to your functions.php file:

use OpenWOO\SubmissionHandler;

\add_action('gform_after_submission', function ($entry, $form) {
    SubmissionHandler::make(array $entry, array $form)->handle();
}, 10, 2);

Additional configuration

Within the SubmissionHandler class, you'll find the isCorrectForm() method. This method ensures that a form has the CSS class 'openwoo', which is used to validate if the current form is intended for creating OpenWOO posts. So make sure you'll configure the css class properly for the used form.

private function isCorrectForm(): bool
{
    return 'openwoo' === $this->form['cssClass'] ?? '';
}

Namespacing

In the OpenWOO directory, namespacing is used to organize and autoload classes efficiently. While some organizations use Composer for this, you can achieve the same without Composer by manually including the files using an autoloader. The autoloader function can be placed in your functions.php file:

spl_autoload_register(function ($class) {
    // Adjust the base directory as needed
    $base_dir = __DIR__ . '/OpenWOO/';
    $class = str_replace('\\', '/', $class);
    $file = $base_dir . $class . '.php';

    if (file_exists($file)) {
        require $file;
    }
});

About

In addition to the OpenWOO plugin, the OpenWOO theme implementation is required to handle and process submissions into OpenWOO posts via GravityForms.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages