industrious / wp-helpers
A WP Helpers package.
v1.0
2023-02-04 20:39 UTC
Requires
- php: ^8.0
- ext-openssl: *
- guzzlehttp/guzzle: ^7
- hashids/hashids: ^4.1
- illuminate/filesystem: ^9
- illuminate/translation: ^9
- illuminate/validation: ^9
- j7mbo/twitter-api-php: ^1.0
README
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()
]);
}