|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Utility functions to generate data synced to wpcom |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
class Jetpack_Sync_Functions { |
|
8
|
|
|
|
|
9
|
|
|
public static function get_modules() { |
|
10
|
|
|
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php' ); |
|
11
|
|
|
return Jetpack_Admin::init()->get_modules(); |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
public static function get_taxonomies() { |
|
15
|
|
|
global $wp_taxonomies; |
|
16
|
|
|
|
|
17
|
|
|
return $wp_taxonomies; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public static function get_post_types() { |
|
21
|
|
|
global $wp_post_types; |
|
22
|
|
|
|
|
23
|
|
|
return $wp_post_types; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Finds out if a site is using a version control system. |
|
28
|
|
|
* @return string ( '1' | '0' ) |
|
29
|
|
|
**/ |
|
30
|
|
View Code Duplication |
public static function is_version_controlled() { |
|
31
|
|
|
|
|
32
|
|
|
if ( ! class_exists( 'WP_Automatic_Updater' ) ) { |
|
33
|
|
|
require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); |
|
34
|
|
|
} |
|
35
|
|
|
$updater = new WP_Automatic_Updater(); |
|
36
|
|
|
$is_version_controlled = strval( $updater->is_vcs_checkout( $context = ABSPATH ) ); |
|
37
|
|
|
// transients should not be empty |
|
38
|
|
|
if ( empty( $is_version_controlled ) ) { |
|
39
|
|
|
$is_version_controlled = '0'; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return $is_version_controlled; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Returns true if the site has file write access false otherwise. |
|
47
|
|
|
* @return string ( '1' | '0' ) |
|
48
|
|
|
**/ |
|
49
|
|
View Code Duplication |
public static function file_system_write_access() { |
|
50
|
|
|
if ( ! function_exists( 'get_filesystem_method' ) ) { |
|
51
|
|
|
require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
55
|
|
|
|
|
56
|
|
|
$filesystem_method = get_filesystem_method(); |
|
57
|
|
|
if ( $filesystem_method === 'direct' ) { |
|
58
|
|
|
return 1; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
ob_start(); |
|
62
|
|
|
$filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() ); |
|
63
|
|
|
ob_end_clean(); |
|
64
|
|
|
if ( $filesystem_credentials_are_stored ) { |
|
65
|
|
|
return 1; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return 0; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public static function wp_version() { |
|
72
|
|
|
global $wp_version; |
|
73
|
|
|
return $wp_version; |
|
74
|
|
|
} |
|
75
|
|
|
} |