Bootstrap 5 updates continued
This commit is contained in:
56
app/plugins/contact/forms.php
Normal file
56
app/plugins/contact/forms.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/contact/forms.php
|
||||
*
|
||||
* This houses all of the form checking functions for this plugin.
|
||||
*
|
||||
* @package TP Contact
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Plugins\Contact;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
|
||||
class ContactForms extends Forms {
|
||||
/**
|
||||
* Adds these functions to the form list.
|
||||
*/
|
||||
public function __construct() {
|
||||
self::addHandler( 'contact', __CLASS__, 'contact' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the contact form.
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
public static function contact() {
|
||||
if ( !Input::exists( 'name' ) ) {
|
||||
Check::addUserError( 'You must provide a name.' );
|
||||
return false;
|
||||
}
|
||||
if ( !Check::name( Input::post( 'name' ) ) ) {
|
||||
Check::addUserError( 'Invalid name.' );
|
||||
return false;
|
||||
}
|
||||
if ( !empty( Input::post( 'contactEmail' ) ) && !Check::email( Input::post( 'contactEmail' ) ) ) {
|
||||
Check::addUserError( 'Invalid Email.' );
|
||||
return false;
|
||||
}
|
||||
if ( Input::post( 'entry' ) == '' ) {
|
||||
Check::addUserError( 'Contact cannot be empty.' );
|
||||
return false;
|
||||
}
|
||||
if ( !Check::token() ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
new ContactForms;
|
Reference in New Issue
Block a user