Completed
Push — update/core-version-upgrade-ro... ( 3d6e97...e1c6f7 )
by
unknown
76:14 queued 66:29
created

Jetpack_Upgrade::run()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 15
rs 9.4285
1
<?php
2
3
class Jetpack_Upgrade {
4
5
	static public $previous_version;
6
7
	static function run() {
8
		if ( Jetpack::is_active() ) {
9
			$version_option = Jetpack_Options::get_option( 'version' );
10
			list( self::$previous_version ) = explode( ':', $version_option );
11
			if ( JETPACK__VERSION != self::$previous_version ) {
12
				Jetpack_Options::update_options(
13
					array(
14
						'version'     => JETPACK__VERSION . ':' . time(),
15
						'old_version' => self::$previous_version,
16
					)
17
				);
18
				add_action( 'init', array( 'Jetpack_Upgrade', 'init' ) );
19
			}
20
		}
21
	}
22
23
	static function init() {
24
		do_action( 'updating_jetpack_version', self::$previous_version );
25
		self::modules_cleanup();
26
	}
27
28
	static function modules_cleanup() {
29
		if ( ! self::$previous_version ) { // For new sites
30
			self::activate_module( 'manage', false, false );
0 ignored issues
show
Bug introduced by
The method activate_module() does not seem to exist on object<Jetpack_Upgrade>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
		}
32
		// Check which active modules actually exist and remove others from active_modules list
33
		Jetpack_Options::update_option( 'active_modules', array_intersect( Jetpack::get_active_modules(), Jetpack::get_available_modules() ) );
34
		Jetpack::activate_new_modules();
35
	}
36
}
37