industrious/wp-helpers

A WP Helpers package.

v1.0 2023-02-04 20:39 UTC

README

Build Status Total Downloads Latest Stable Version License

Introduction

industrious/wp-helpers is a [[]].

License

industrious/wp-helpers is open-sourced software licensed under the MIT license

Installation

To get started with industrious/wp-helpers, use Composer to add the package to your project's dependencies:

composer require industrious-mouse/wp-helpers

Examples

Validation Helpers

Below is an example of how you might be able to use the ValidatesRequests trait, to validate a form.

use ValidatesRequests;

/**
 *
 */
public function __construct()
{
    $data = [
        'abc' => '123',
        'def' => '123',
    ];

    $rules = [
        'abc' => 'required',
        'def' => 'required',
    ];

    $errors = $this->validate($data, $rules);

    if (! $errors) {
        wp_send_json_success();
    }

    wp_send_json_error([
        'errors' => $errors->toArray()
    ]);
}