forked from retostauffer/wp-wetterturnier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deactivate_pages.php
38 lines (30 loc) · 1.02 KB
/
deactivate_pages.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
<?php
global $wpdb;
/**
* Deactivate pages when the wp-wetterturnier plugin is getting
* deactivated.
*
* @todo Needs a check, not yet fully tested!
*/
function wp_wetterturnier_remove_the_page($lang) {
$the_page_title = get_option( "wetterturnier_page_title_".$lang );
$the_page_name = get_option( "wetterturnier_page_name_".$lang );
// the id of our page...
$the_page_id = get_option( $the_page_name ); #'wtpage_overview_'.$lang );
if( $the_page_id ) {
wp_delete_post( $the_page_id ); // this will trash, not delete
}
delete_option("wetterturnier_page_title_".$lang);
delete_option("wetterturnier_page_name_".$lang);
delete_option("wetterturnier_page_id_".$lang);
}
// If the polylang plugin is active we have to add the pages
// for EACH of the languages!
if ( add_action('is_plugin_active','polylang') ) {
foreach ( pll_languages_list() as $lang ) {
wp_wetterturnier_remove_the_page($lang);
}
} else {
wp_wetterturnier_remove_the_page('');
}
?>