mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-18 14:13:46 +09:00
Adds new select/multi-select options to retrieve options from a callback
This commit is contained in:
@@ -48,4 +48,31 @@
|
||||
|
||||
if(is_array($output)){ print_r($output); }else{ echo $output; } die;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves dropdown/multi-select options from a callback function
|
||||
*/
|
||||
add_action('wp_ajax_nopriv_ultimatemember_populate_dropdown_options', 'ultimatemember_populate_dropdown_options');
|
||||
add_action('wp_ajax_ultimatemember_populate_dropdown_options', 'ultimatemember_populate_dropdown_options');
|
||||
function ultimatemember_populate_dropdown_options(){
|
||||
|
||||
$arr_options = array();
|
||||
|
||||
$um_callback_func = $_POST['um_option_callback'];
|
||||
if( empty( $um_callback_func ) ){
|
||||
$arr_options['status'] = 'empty';
|
||||
$arr_options['function_name'] = $um_callback_func;
|
||||
$arr_options['function_exists'] = function_exists( $um_callback_func );
|
||||
}
|
||||
|
||||
$arr_options['data'] = array();
|
||||
|
||||
if( function_exists( $um_callback_func ) ){
|
||||
$arr_options['data'] = call_user_func( $um_callback_func );
|
||||
}
|
||||
|
||||
wp_send_json( $arr_options );
|
||||
}
|
||||
|
||||
|
||||
@@ -1505,6 +1505,17 @@ class UM_Admin_Metabox {
|
||||
|
||||
<?php
|
||||
break;
|
||||
|
||||
case '_custom_dropdown_options_source':
|
||||
?>
|
||||
|
||||
<p><label for="_placeholder">Options Callback<?php $this->tooltip('Add a callback source to retrieve options.'); ?></label>
|
||||
<input type="text" name="_custom_dropdown_options_source" id="_custom_dropdown_options_source" value="<?php echo htmlspecialchars($this->edit_mode_value, ENT_QUOTES); ?>" />
|
||||
</p>
|
||||
|
||||
<?php
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user