-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtfp-network-settings.php
More file actions
54 lines (46 loc) · 2.01 KB
/
tfp-network-settings.php
File metadata and controls
54 lines (46 loc) · 2.01 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
<?php
/**
* In order to display Network settings of this plugin extensions-for-pressbooks plugin v1.2.4 must be activated.
* Creates plugin setting section in "EFP setting" on the network level.
*
* @package translations for pressbooks
* @since 1.2.6
* 1.2.8 modifications
*/
defined ("ABSPATH") or die ("Action denied!");
if (( is_multisite()) && is_plugin_active('pressbooks/pressbooks.php') && is_plugin_active('extensions-for-pressbooks/extensions-for-pressbooks.php')){
if (isset($_REQUEST['page']) && "efp-network-settings-page" == $_REQUEST['page']) {
add_action('admin_init','tfp_renderTranslationsSection');
}
}
/**
* Create section and call checkbox
*
* @since 1.2.8
*
* Unistall translation section is created by this plugin in extensions for pressbooks blank
**/
function tfp_renderTranslationsSection(){
add_settings_section( 'translations_section',
'Translations section',
'',
'tfp-network-settings-page');
add_option('tfp_uninstall_save', 0);
add_settings_field( 'tfp_uninstall_save', // Parameter
'Persist data on uninstall', // Title
'tfp_unistall_checkbox', // Function
'tfp-network-settings-page', // Page
'translations_section'); // Add settings field to the translations_section
register_setting( 'tfp-network-settings-page-grp',
'tfp_uninstall_save');
}
/**
* Create the checkbox
* If option 'tfp_uninstall_save' = 1 checkbox is checked
**/
function tfp_unistall_checkbox(){
$option = get_option( 'tfp_uninstall_save' );
echo "<label>";
echo '<input name="tfp_uninstall_save" id="tfp_uninstall_save" type="checkbox" value="1" class= "code"' . checked(1, $option, false ) . '/> Check to keep translations data saved on plugin uninstall. Present value: ' . $option;
echo "</label>";
}