templates = $templates; } /** * {@inheritDoc} */ public function area(): string { return self::AREA_MAIN; } /** * {@inheritDoc} */ public function load( int $comment_id ) { return null; } /** * Render templates/form/{name}.php. * * @param string $name Template name. * @param FormContext $context Form context. * @param array $args Template data. */ protected function template( string $name, FormContext $context, array $args = array() ): string { return $this->templates->render( 'form/' . $name . '.php', $args + array( 'context' => $context ) ); } /** * Validation error tied to an input name. * * @param string $input Input name. * @param string $message Message for the reviewer. */ protected function error( string $input, string $message ): WP_Error { return new WP_Error( 'wpipr_field_invalid', $message, array( 'field' => $input ) ); } /** * A scalar input as a string. * * @param array $input Input. * @param string $key Input name. */ protected static function string( array $input, string $key ): string { return isset( $input[ $key ] ) && is_scalar( $input[ $key ] ) ? (string) $input[ $key ] : ''; } }