Merge remote-tracking branch 'remotes/origin/origin/improvement/field-notice'

This commit is contained in:
nikitasinelnikov
2020-02-06 15:05:34 +02:00
3 changed files with 210 additions and 9 deletions
+46
View File
@@ -232,6 +232,40 @@ if ( ! class_exists( 'um\core\Form' ) ) {
}
}
/**
* Appends field notices
* @param string $key
* @param string $notice
*/
function add_notice( $key, $notice ) {
if ( ! isset( $this->notices[ $key ] ) ){
/**
* UM hook
*
* @type filter
* @title um_submit_form_notice
* @description Change notice text on submit form
* @input_vars
* [{"var":"$notice","type":"string","desc":"notice String"},
* {"var":"$key","type":"string","desc":"notice Key"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_submit_form_notice', 'function_name', 10, 2 ); ?>
* @example
* <?php
* add_filter( 'um_submit_form_notice', 'my_submit_form_notice', 10, 2 );
* function my_submit_form_notice( $notice, $key ) {
* // your code here
* return $notice;
* }
* ?>
*/
$notice = apply_filters( 'um_submit_form_notice', $notice, $key );
$this->notices[ $key ] = $notice;
}
}
/**
* If a form has errors
@@ -245,6 +279,18 @@ if ( ! class_exists( 'um\core\Form' ) ) {
return false;
}
/**
* If a form has notices/info
* @param string $key
* @return boolean
*/
function has_notice( $key ) {
if ( isset( $this->notices[ $key ] ) ) {
return true;
}
return false;
}
/**
* Declare all fields