* @link https://TheTempusProject.com * @license https://opensource.org/licenses/MIT [MIT LICENSE] */ namespace TheTempusProject\Plugins\Blog; use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Classes\Forms; class BlogForms extends Forms { /** * Adds these functions to the form list. */ public function __construct() { self::addHandler( 'newBlogPost', __CLASS__, 'newBlogPost' ); self::addHandler( 'editBlogPost', __CLASS__, 'editBlogPost' ); } /** * Validates the new blog post form. * * @return {bool} */ public static function newBlogPost() { if ( !Input::exists( 'title' ) ) { self::addUserError( 'You must specify title' ); return false; } if ( !self::dataTitle( Input::post( 'title' ) ) ) { self::addUserError( 'Invalid title' ); return false; } if ( !Input::exists( 'blogPost' ) ) { self::addUserError( 'You must specify a post' ); return false; } /** You cannot use the token check due to how tinymce reloads the page if (!self::token()) { return false; } */ return true; } /** * Validates the edit blog post form. * * @return {bool} */ public static function editBlogPost() { if ( !Input::exists( 'title' ) ) { self::addUserError( 'You must specify title' ); return false; } if ( !self::dataTitle( Input::post( 'title' ) ) ) { self::addUserError( 'Invalid title' ); return false; } if ( !Input::exists( 'blogPost' ) ) { self::addUserError( 'You must specify a post' ); return false; } /** You cannot use the token check due to how tinymce reloads the page if (!self::token()) { return false; } */ return true; } } new BlogForms;