AnsPress::form_exists( string $name )
Description #
Check if a form exists in AnsPress, if not then tries to register.
Parameters #
- $namestring (Required) Name of form.
Source #
File: anspress-question-answer.php
public function form_exists( $name ) {
$name = preg_replace( '/^form_/i', '', $name );
if ( isset( $this->forms[ $name ] ) ) {
return true;
}
/**
* Register a form in AnsPress.
*
* @param array $form {
* Form options and fields. Check @see `AnsPress\Form` for more detail.
*
* @type string $submit_label Custom submit button label.
* @type boolean $editing Pass true if currently in editing mode.
* @type integer $editing_id If editing then pass editing post or comment id.
* @type array $fields Fields. For more detail on field option check documentations.
* }
* @since 4.1.0
* @todo Add detailed docs for `$fields`.
*/
$args = apply_filters( 'ap_form_' . $name, null );
if ( ! is_null( $args ) && ! empty( $args ) ) {
$this->forms[ $name ] = new AnsPress\Form( 'form_' . $name, $args );
return true;
}
return false;
}
Expand full source code Collapse full source code View on GitHub: anspress-question-answer.php:513
Add your comment