mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Merge remote-tracking branch 'remotes/origin/origin/improvement/field-notice'
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user