|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class Jetpack_Site_Importer_Module { |
|
4
|
|
|
static function admin_init() { |
|
5
|
|
|
if ( ! ( class_exists( 'Jetpack_Calypsoify' ) && Jetpack_Calypsoify::is_active() ) ) { |
|
6
|
|
|
// Don't do anything if we're not "calypsoified" |
|
7
|
|
|
return; |
|
8
|
|
|
} |
|
9
|
|
|
add_action( 'current_screen', array( 'Jetpack_Site_Importer_Module', 'current_screen' ) ); |
|
10
|
|
|
add_filter( 'admin_url', array( 'Jetpack_Site_Importer_Module', 'admin_url_change_have_fun_link' ) ); |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
static function is_import_screen() { |
|
14
|
|
|
global $pagenow; |
|
15
|
|
|
|
|
16
|
|
|
// $pagenow is probably enough for us |
|
17
|
|
|
// We may want additional "screen" info at some point, so putting here for ref |
|
18
|
|
|
// $screen = get_current_screen(); |
|
19
|
|
|
// error_log( print_r( $screen, 1 ) ); |
|
20
|
|
|
|
|
21
|
|
|
switch ( $pagenow ) { |
|
22
|
|
|
case 'import.php': |
|
23
|
|
|
return true; |
|
24
|
|
|
case 'admin.php': |
|
25
|
|
|
return isset( $_REQUEST['import'] ) && $_REQUEST['import']; |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
static function get_current_importer() { |
|
30
|
|
|
if ( ! ( self::is_import_screen() && isset( $_REQUEST['import'] ) ) ) { |
|
|
|
|
|
|
31
|
|
|
return ''; |
|
32
|
|
|
} |
|
33
|
|
|
return strtolower( $_REQUEST['import'] ); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
static function is_wordpress_importer() { |
|
37
|
|
|
return 'wordpress' === self::get_current_importer(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
static function current_screen() { |
|
41
|
|
|
if ( ! self::is_wordpress_importer() ) { |
|
42
|
|
|
return; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
error_log( "SUP WordPress Importer!!!!" ); |
|
46
|
|
|
// @TODO <img src="all-the-things.png" /> |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
static function admin_url_change_have_fun_link( $admin_url ) { |
|
50
|
|
|
if ( ! self::is_wordpress_importer() ) { |
|
51
|
|
|
return $admin_url; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
if ( isset( $_GET['step'] ) && 2 === (int) $_GET['step'] ) { |
|
55
|
|
|
return 'https://wordpress.com/settings/'; // @TODO dynamic parts |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
return $admin_url; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
add_action( 'admin_init', array( 'Jetpack_Site_Importer_Module', 'admin_init' ) ); |
|
63
|
|
|
|
If an expression can have both
false, andnullas possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.