-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupgrade.php
76 lines (65 loc) · 1.77 KB
/
upgrade.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
74
75
76
<?php
/**
* WP Sitemaps Manager upgrade.
*
* @package WP Sitemaps Manager
*
* @since 0.2
*/
namespace XMLSitemapsManager;
defined( '\WPINC' ) || die;
const DEFAULTS = array(
'xmlsm_sitemaps_enabled' => true,
'xmlsm_sitemaps_fixes' => true,
'xmlsm_max_urls' => '',
'xmlsm_lastmod' => false,
'xmlsm_sitemap_providers' => array( 'posts', 'taxonomies', 'users' ),
'xmlsm_disabled_subtypes' => '',
);
/**
* Upgrade plugin data.
*
* @since 0.1
*/
if ( '0' !== $db_version ) {
// Upgrading from 0.1 or 0.2.
if ( \version_compare( '0.2', $db_version, '>=' ) ) {
// Max urls option.
$max_urls = \get_option( 'xmlsm_sitemaps_max_urls', '' );
if ( \is_array( $max_urls ) && ! empty( $max_urls['post'] ) ) {
$max_urls = $max_urls['post'];
} else {
$max_urls = '';
}
\add_option( 'xmlsm_max_urls', $max_urls );
\delete_option( 'xmlsm_sitemaps_max_urls' );
// Lastmod option.
$lastmod = \get_option( 'xmlsm_sitemaps_lastmod' );
if ( \is_array( $lastmod ) && ! empty( $lastmod ) ) {
$lastmod = true;
}
\add_option( 'xmlsm_lastmod', $lastmod );
\delete_option( 'xmlsm_sitemaps_lastmod' );
}
}
// Fill in missing options.
foreach ( DEFAULTS as $option => $default ) {
\add_option( $option, $default );
}
// Update DB version.
\update_option( 'xmlsm_version', \XMLSM_VERSION );
/**
* Clear metadata.
*/
// Terms meta.
delete_metadata( 'term', 0, 'term_modified_gmt', '', true );
// User meta.
delete_metadata( 'user', 0, 'user_modified_gmt', '', true );
// Kilroy was here.
if ( \defined( 'WP_DEBUG' ) && WP_DEBUG ) {
if ( '0' === $db_version ) {
\error_log( 'WP Sitemaps Manager version ' . \XMLSM_VERSION . ' installed.' );
} else {
\error_log( 'WP Sitemaps Manager upgraded from ' . $db_version . ' to ' . \XMLSM_VERSION );
}
}