@@ -12,22 +12,35 @@ public function __construct() {
1212 'label ' => __ ( 'Webhook URL ' , 'shifter-wp-webhook ' ),
1313 "default " => '' ,
1414 ),
15- array (
16- "key " => "shifter_webhook_content_type " ,
17- "form_type " => "select " ,
18- "sanitize_callback " => 'esc_attr ' ,
19- 'label ' => __ ( 'Content-Type ' , 'shifter-wp-webhook ' ),
20- "default " => 'application/json ' ,
21- 'options ' => array (
22- 'application/x-www-form-urlencoded ' ,
23- 'application/json '
24- )
15+ array (
16+ "key " => "shifter_webhook_content_type " ,
17+ "form_type " => "select " ,
18+ "sanitize_callback " => 'esc_attr ' ,
19+ 'label ' => __ ( 'Content-Type ' , 'shifter-wp-webhook ' ),
20+ "default " => 'application/json ' ,
21+ 'options ' => array (
22+ 'application/x-www-form-urlencoded ' ,
23+ 'application/json '
2524 )
25+ ),
26+ array (
27+ "key " => "shifter_webhook_send_on_boot " ,
28+ "form_type " => "boolean " ,
29+ "sanitize_callback " => array ( $ this , 'esc_boolean ' ),
30+ 'label ' => __ ( 'Send on boot ' , 'shifter-wp-webhook ' ),
31+ "default " => "0 "
32+ )
2633 ]
2734 ];
2835 add_action ( 'admin_menu ' , array ( $ this , 'register_pages ' ) );
2936 add_action ( 'admin_init ' , array ( $ this , 'register_setting_fields ' ) );
3037 }
38+ public function esc_boolean ( $ value ) {
39+ if ( ! isset ( $ value ) || '1 ' !== $ value ) {
40+ $ value = '0 ' ;
41+ }
42+ return $ value ;
43+ }
3144 public function register_setting_fields () {
3245 foreach ( $ this ->options as $ group => $ options ) {
3346 foreach ( $ options as $ option ) {
@@ -104,6 +117,15 @@ public function get_form_input( $item, $current_value ) {
104117 ?>
105118 </select>
106119 <?php
120+ } else if ( 'boolean ' === $ item ['form_type ' ] ) {
121+ ?>
122+ <input
123+ type="checkbox"
124+ name="<?php echo $ name ?> "
125+ value="1"
126+ <?php checked ( "1 " , $ current_value ); ?>
127+ />
128+ <?php
107129 } else {
108130 ?>
109131 <input
0 commit comments