-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsettings-page.php
73 lines (65 loc) · 2.28 KB
/
settings-page.php
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
<?php
add_action( 'admin_menu', 'wistia_wordpress_add_admin_menu' );
add_action( 'admin_init', 'wistia_wordpress_settings_init' );
function wistia_wordpress_add_admin_menu() {
add_options_page(
'Wistia WordPress', 'Wistia WordPress', 'manage_options',
'wistia_wordpress', 'wistia_wordpress_options_page'
);
}
function wistia_wordpress_settings_init( ) {
register_setting('pluginPage', 'wistia_wordpress_settings');
add_settings_section(
'wistia_wordpress_pluginPage_section',
__( '', 'wordpress' ),
'wistia_wordpress_settings_section_callback',
'pluginPage'
);
add_settings_field(
'anti_mangler',
__('Include Legacy Anti-Mangler', 'wordpress'),
'wistia_wordpress_anti_mangler_render',
'pluginPage',
'wistia_wordpress_pluginPage_section'
);
}
function wistia_wordpress_anti_mangler_render() {
$wistia_wordpress_anti_mangler = get_wistia_wordpress_option('anti_mangler');
$on = empty($wistia_wordpress_anti_mangler) ||
$wistia_wordpress_anti_mangler == 'on';
?>
<label>
<input type='radio' name='wistia_wordpress_settings[anti_mangler]' <?php echo $on ? "checked='checked'" : ''; ?> value='on'>
On
</label>
<label>
<input type='radio' name='wistia_wordpress_settings[anti_mangler]' <?php echo $on ? '' : 'checked="checked"'; ?> value='off'>
Off
</label>
<?php
}
function wistia_wordpress_settings_section_callback() {
echo __('<p>The Wistia WordPress plugin enables oEmbeds to work in WordPress.</p> <p>There is also some legacy functionality which allows raw HTML, which we recommend turning OFF. It\'s better to use oEmbed!</p>', 'wordpress');
}
function wistia_wordpress_options_page() {
?>
<form action='options.php' method='post'>
<h2>Wistia WordPress</h2>
<?php
settings_fields('pluginPage');
do_settings_sections('pluginPage');
submit_button();
?>
</form>
<?php
}
// Link to Settings page from the Plugins page next to Deactivate | Edit.
$plugin = plugin_basename(wistia_wordpress_plugin_file());
function wistia_wordpress_add_settings_link($links) {
$settings_link = '<a href="options-general.php?page=wistia_wordpress">' .
__('Settings') . '</a>';
array_push($links, $settings_link);
return $links;
}
add_filter("plugin_action_links_$plugin", 'wistia_wordpress_add_settings_link');
?>