*/ public static function event_types(): array { return array( self::CREATED => 'Form Created', self::UPDATED => 'Form Updated', self::TRASHED => 'Form Trashed', self::RESTORED => 'Form Restored', self::DELETED => 'Form Deleted', self::SUBMITTED => 'Form Submitted', self::ENTRY_DELETED => 'Form Entry Deleted', self::ENTRY_STATUS => 'Form Entry Status Changed', ); } /** * The `form` post-type mapping for a CPT-backed form plugin. * * @param string $noun How the summary names the form ("WPForms form"). * @param string $plugin The plugin's slug. * @return array{prefix: string, noun: string, plugin: string} */ public static function mapping( string $noun, string $plugin ): array { return array( 'prefix' => 'form', 'noun' => $noun, 'plugin' => $plugin, ); } /** * Write a submission row. * * @param string $plugin The plugin's slug. * @param string $noun How the summary names the form. * @param int $form_id The form. * @param string $title Its title. * @param int $entry_id The stored entry, 0 when the plugin keeps none. * @param array $extra More details (never a field value). */ public static function submitted( string $plugin, string $noun, int $form_id, string $title, int $entry_id, array $extra = array() ): void { if ( $form_id <= 0 ) { return; } $details = array( 'plugin' => $plugin, 'form_id' => $form_id, ); if ( $entry_id > 0 ) { $details['entry_id'] = $entry_id; } EventLogger::log( self::SUBMITTED, sprintf( '%1$s "%2$s" submitted', $noun, self::title( $title, $form_id ) ), 'form', $form_id, $details + $extra ); } /** * A form title for a summary: bounded, or the id when it has none. * * @param string $title The title. * @param int $form_id The form. */ public static function title( string $title, int $form_id ): string { $title = trim( wp_strip_all_tags( $title ) ); return '' !== $title ? EventLogger::bounded( $title, self::TITLE_LENGTH ) : '#' . $form_id; } /** * A status value for a row: a key, bounded. * * @param mixed $value A status. */ public static function status( $value ): string { return is_scalar( $value ) ? EventLogger::bounded( sanitize_key( (string) $value ), self::STATUS_LENGTH ) : ''; } }