-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbip-pages-update.php
51 lines (38 loc) · 1.07 KB
/
bip-pages-update.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
<?php
namespace BipPages;
function update_plugin() {
switch ( get_option( Settings\OPT_LAST_VERSION, '1.1.1' ) ) {
case '1.1.1':
update_settings_scheme();
update_main_page();
}
update_option( Settings\OPT_LAST_VERSION, CURRENT_VERSION );
}
function update_settings_scheme() {
$option_name = 'bip-pages';
$old_option = get_option( $option_name, array() );
$update_map = array(
'id' => 'bip_pages_main_page_id',
'instruction_id' => 'bip_pages_instruction_id',
'address' => 'bip_pages_address',
'email' => 'bip_pages_email',
'phone' => 'bip_pages_phone',
'rep' => 'bip_pages_editor',
);
foreach ( $old_option as $opt => $val ) {
update_option( $update_map[$opt], $val );
}
delete_option( $option_name );
return true;
}
function update_main_page() {
// check if block editor is enabled
if ( false ) {
return null;
}
$post = get_post( get_bip_main_page() );
$post->post_content = get_main_page_default_content();
$res = wp_update_post( $post );
return $res == get_bip_main_page();
}
update_plugin();