-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.php
More file actions
88 lines (80 loc) · 3.03 KB
/
Copy pathconfig.php
File metadata and controls
88 lines (80 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
if (is_admin()) {
$options['intro'] = get_option( 'ifrs_documentos_intro' );
add_action( 'admin_menu', function() {
add_submenu_page(
'edit.php?post_type=documento',
'Configurações de Documentos', // page_title
'Configurações', // menu_title
'manage_options', // capability
'documento_settings', // menu_slug
function() {
?>
<div class="wrap">
<h2><?php _e('Configurações de Documentos', 'ifrs-portal-plugin-documentos'); ?></h2>
<p></p>
<?php settings_errors(); ?>
<form method="POST" action="options.php">
<?php
settings_fields( 'ifrs_documentos-default' );
do_settings_sections( 'ifrs_documentos-admin' );
submit_button();
?>
</form>
</div>
<?php
}
);
} );
add_action( 'admin_init', function() use ($options) {
register_setting(
'ifrs_documentos-default', // option_group
'ifrs_documentos_intro', // option_name
array ( // args
'type' => 'string',
'description' => '',
'sanitize_callback' => function($input) {
$allowed_html = wp_kses_allowed_html( 'post' );
// Remove '<textarea>' and '<iframe>' tags
unset( $allowed_html['textarea'] );
unset( $allowed_html['iframe'] );
/**
* wp_kses_allowed_html return the wrong values for wp_kses,
* need to change "true" -> "array()"
*/
array_walk_recursive(
$allowed_html,
function ( &$value ) {
if ( is_bool( $value ) ) {
$value = array();
}
}
);
// Run sanitization.
return wp_kses( $input, $allowed_html );
},
'show_in_rest' => true,
'default' => ''
)
);
add_settings_section(
'ifrs_documentos-default', // id
'Geral', // title
function() {}, // callback
'ifrs_documentos-admin' // page
);
add_settings_field(
'ifrs_documentos_intro', // id
'Texto de Introdução', // title
function() use ($options) { // callback
wp_editor(
$options['intro'] ? $options['intro'] : '',
'ifrs_documentos_intro',
array('media_buttons' => false, 'textarea_rows' => '15')
);
},
'ifrs_documentos-admin', // page
'ifrs_documentos-default' // section
);
} );
}