Completed
Push — try/composer ( 5fde13 )
by
unknown
06:30
created

Bootstrap::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php //phpcs:ignore
2
3
/**
4
 * TODO
5
 *
6
 * - connection
7
 * - API
8
 * - UI
9
 * - etc
10
 */
11
12
namespace \Jetpack\Core;
13
14
// declare as internal var because declaring const here would throw error if another
15
// instance of this library is already loaded
16
$version = '7.2-alpha';
17
$primary_class = 'Jetpack\\Core\\Bootstrap';
18
19
if ( class_exists( $primary_class ) ) {
20
	if ( Jetpack\Core\Bootstrap\VERSION !== $version ) {
21
		error_log("Multiple versions of $primary_class detected: $version <> " . Jetpack\Core\Bootstrap\VERSION );
22
	}
23
	return;
24
}
25
26
const VERSION = '7.2-alpha'; // can't assign from $variables :sigh:
27
28
class Bootstrap {
29
	public function load() {
30
		// This will be used as a check if we have already loaded the plugin.
31
		if ( defined( 'Jetpack_Core_Loaded' ) ) { return; }
32
		define( 'Jetpack_Core_Loaded', true );
33
34
		// Change site title.
35
		add_filter( 'bloginfo', array( $this, 'change_title' ), 10, 2 );
36
	}
37
38
	// just a test right now
39
	public function change_title( $title, $show ) {
40
		if ( 'name' === $show ) {
41
			return 'Changed through Library';
42
		}
43
		return $title;
44
	}
45
}
46
47
// Initialize the plugin if not already loaded.
48
add_action( 'init', function(){
49
	if ( ! defined( 'Jetpack_Core_Loaded' ) ) {
50
		$plugin = new Bootstrap();
51
		$plugin->load();
52
	}
53
});