Completed
Push — fix/conflicting-libraries-load... ( 24e82f...4283a6 )
by
unknown
12:26 queued 05:24
created

jetpack.php ➔ jetpack_admin_unsupported_wp_notice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * Plugin Name: Jetpack by WordPress.com
5
 * Plugin URI: https://jetpack.com
6
 * Description: Bring the power of the WordPress.com cloud to your self-hosted WordPress. Jetpack enables you to connect your blog to a WordPress.com account to use the powerful features normally only available to WordPress.com users.
7
 * Author: Automattic
8
 * Version: 7.4-alpha
9
 * Author URI: https://jetpack.com
10
 * License: GPL2+
11
 * Text Domain: jetpack
12
 * Domain Path: /languages/
13
 */
14
error_log( 'loading jetpack ' );
15
define( 'JETPACK__MINIMUM_WP_VERSION', '5.0' );
16
17
define( 'JETPACK__VERSION',            '7.4-alpha' );
18
define( 'JETPACK_MASTER_USER',         true );
19
define( 'JETPACK__API_VERSION',        1 );
20
define( 'JETPACK__PLUGIN_DIR',         plugin_dir_path( __FILE__ ) );
21
define( 'JETPACK__PLUGIN_FILE',        __FILE__ );
22
23
defined( 'JETPACK_CLIENT__AUTH_LOCATION' )   or define( 'JETPACK_CLIENT__AUTH_LOCATION', 'header' );
24
defined( 'JETPACK_CLIENT__HTTPS' )           or define( 'JETPACK_CLIENT__HTTPS', 'AUTO' );
25
defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) or define( 'JETPACK__GLOTPRESS_LOCALES_PATH', JETPACK__PLUGIN_DIR . 'locales.php' );
26
defined( 'JETPACK__API_BASE' )               or define( 'JETPACK__API_BASE', 'https://jetpack.wordpress.com/jetpack.' );
27
defined( 'JETPACK_PROTECT__API_HOST' )       or define( 'JETPACK_PROTECT__API_HOST', 'https://api.bruteprotect.com/' );
28
defined( 'JETPACK__WPCOM_JSON_API_HOST' )    or define( 'JETPACK__WPCOM_JSON_API_HOST', 'public-api.wordpress.com' );
29
30
defined( 'JETPACK__SANDBOX_DOMAIN' ) or define( 'JETPACK__SANDBOX_DOMAIN', '' );
31
32
defined( 'JETPACK__DEBUGGER_PUBLIC_KEY' ) or define(
33
	'JETPACK__DEBUGGER_PUBLIC_KEY',
34
	"\r\n" . '-----BEGIN PUBLIC KEY-----' . "\r\n"
35
	. 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm+uLLVoxGCY71LS6KFc6' . "\r\n"
36
	. '1UnF6QGBAsi5XF8ty9kR3/voqfOkpW+gRerM2Kyjy6DPCOmzhZj7BFGtxSV2ZoMX' . "\r\n"
37
	. '9ZwWxzXhl/Q/6k8jg8BoY1QL6L2K76icXJu80b+RDIqvOfJruaAeBg1Q9NyeYqLY' . "\r\n"
38
	. 'lEVzN2vIwcFYl+MrP/g6Bc2co7Jcbli+tpNIxg4Z+Hnhbs7OJ3STQLmEryLpAxQO' . "\r\n"
39
	. 'q8cbhQkMx+FyQhxzSwtXYI/ClCUmTnzcKk7SgGvEjoKGAmngILiVuEJ4bm7Q1yok' . "\r\n"
40
	. 'xl9+wcfW6JAituNhml9dlHCWnn9D3+j8pxStHihKy2gVMwiFRjLEeD8K/7JVGkb/' . "\r\n"
41
	. 'EwIDAQAB' . "\r\n"
42
	. '-----END PUBLIC KEY-----' . "\r\n"
43
);
44
45
/**
46
 * Returns the location of Jetpack's lib directory. This filter is applied
47
 * in require_lib().
48
 *
49
 * @since 4.0.2
50
 *
51
 * @return string Location of Jetpack library directory.
52
 *
53
 * @filter require_lib_dir
54
 */
55
function jetpack_require_lib_dir() {
56
	return JETPACK__PLUGIN_DIR . '_inc/lib';
57
}
58
59
/**
60
 * THIS CODE WOULD NEED TO BE DUPLICATED IN EACH PLUGIN...
61
 */
62 View Code Duplication
if ( ! function_exists( 'jetpack_enqueue_library' ) ) {
63
	global $jetpack_libraries;
64
	if ( ! is_array( $jetpack_libraries ) ) {
65
		$jetpack_libraries = array();
66
	}
67
	function jetpack_enqueue_library( $class_name, $version, $path ) {
0 ignored issues
show
Best Practice introduced by
The function jetpack_enqueue_library() has been defined more than once; this definition is ignored, only the first definition in docker/mu-plugins/conflicting-plugin.php (L17-24) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
68
		global $jetpack_libraries;
69
		if ( ! isset( $jetpack_libraries[ $class_name ] )
70
		     || version_compare( $jetpack_libraries[ $class_name ] ['version'], $version, '>' )
71
		) {
72
			$jetpack_libraries[ $class_name ] = array( 'version' => $version, 'path' => $path );
73
		}
74
	}
75
76
	// add the autoloader
77
	spl_autoload_register( function ( $class_name ) {
78
		global $jetpack_libraries;
79
		if ( isset( $jetpack_libraries[ $class_name ] ) ) {
80
			if ( ! did_action( 'plugins_loaded' ) ) {
81
				_doing_it_wrong( $class_name, 'Jetpack Class Autoloader, not all plugins have loaded yet!', JETPACK__VERSION );
82
			}
83
			require_once $jetpack_libraries[ $class_name ]['path'];
84
		}
85
	} );
86
}
87
/**
88
 * END OF DUPLICATE CODE
89
 */
90
91
/**
92
 * Checks if the code debug mode turned on, and returns false if it is. When Jetpack is in
93
 * code debug mode, it shouldn't use minified assets. Note that this filter is not being used
94
 * in every place where assets are enqueued. The filter is added at priority 9 to be overridden
95
 * by any default priority filter that runs after it.
96
 *
97
 * @since 6.2.0
98
 *
99
 * @return boolean
100
 *
101
 * @filter jetpack_should_use_minified_assets
102
 */
103
function jetpack_should_use_minified_assets() {
104
	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
105
		return false;
106
	}
107
	return true;
108
}
109
110
/**
111
 * Outputs for an admin notice about running Jetpack on outdated WordPress.
112
 *
113
 * @since 7.2.0
114
 */
115
function jetpack_admin_unsupported_wp_notice() { ?>
116
	<div class="notice notice-error is-dismissible">
117
		<p><?php esc_html_e( 'Jetpack requires a more recent version of WordPress and has been paused. Please update WordPress to continue enjoying Jetpack.', 'jetpack' ); ?></p>
118
	</div>
119
	<?php
120
}
121
122
if ( version_compare( $GLOBALS['wp_version'], JETPACK__MINIMUM_WP_VERSION, '<' ) ) {
123
	add_action( 'admin_notices', 'jetpack_admin_unsupported_wp_notice' );
124
	return;
125
}
126
127
add_filter( 'jetpack_require_lib_dir', 'jetpack_require_lib_dir' );
128
add_filter( 'jetpack_should_use_minified_assets', 'jetpack_should_use_minified_assets', 9 );
129
130
// @todo: Abstract out the admin functions, and only include them if is_admin()
131
jetpack_enqueue_library( 'Jetpack', '7.3', JETPACK__PLUGIN_DIR . 'class.jetpack.php' );
132
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-network.php'       );
133
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-client.php'        );
134
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-data.php'          );
135
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-client-server.php' );
136
require_once( JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-actions.php' );
137
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-options.php'       );
138
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-user-agent.php'    );
139
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-post-images.php'   );
140
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-error.php'         );
141
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-heartbeat.php'     );
142
require_once( JETPACK__PLUGIN_DIR . 'class.photon.php'                );
143
require_once( JETPACK__PLUGIN_DIR . 'functions.photon.php'            );
144
require_once( JETPACK__PLUGIN_DIR . 'functions.global.php'            );
145
require_once( JETPACK__PLUGIN_DIR . 'functions.compat.php'            );
146
require_once( JETPACK__PLUGIN_DIR . 'functions.gallery.php'           );
147
require_once( JETPACK__PLUGIN_DIR . 'require-lib.php'                 );
148
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-autoupdate.php'    );
149
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-tracks.php'        );
150
require_once( JETPACK__PLUGIN_DIR . 'class.frame-nonce-preview.php'   );
151
require_once( JETPACK__PLUGIN_DIR . 'modules/module-headings.php');
152
jetpack_enqueue_library( 'Jetpack_Constants', '7.3', JETPACK__PLUGIN_DIR . 'class.jetpack-constants.php' );
153
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-idc.php'  );
154
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-connection-banner.php'  );
155
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-plan.php'          );
156
157
if ( is_admin() ) {
158
	require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php'     );
159
	require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-jitm.php'      );
160
	require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-affiliate.php' );
161
	jetpack_require_lib( 'debugger' );
162
}
163
164
// Play nice with http://wp-cli.org/
165
if ( defined( 'WP_CLI' ) && WP_CLI ) {
166
	require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-cli.php'       );
167
}
168
169
require_once( JETPACK__PLUGIN_DIR . '_inc/lib/class.core-rest-api-endpoints.php' );
170
171
register_activation_hook( __FILE__, array( 'Jetpack', 'plugin_activation' ) );
172
register_deactivation_hook( __FILE__, array( 'Jetpack', 'plugin_deactivation' ) );
173
add_action( 'updating_jetpack_version', array( 'Jetpack', 'do_version_bump' ), 10, 2 );
174
add_action( 'init', array( 'Jetpack', 'init' ) );
175
add_action( 'plugins_loaded', array( 'Jetpack', 'plugin_textdomain' ), 99 );
176
add_action( 'plugins_loaded', array( 'Jetpack', 'load_modules' ), 100 );
177
add_filter( 'jetpack_static_url', array( 'Jetpack', 'staticize_subdomain' ) );
178
add_filter( 'is_jetpack_site', '__return_true' );
179
180
/**
181
 * Add an easy way to photon-ize a URL that is safe to call even if Jetpack isn't active.
182
 *
183
 * See: http://jetpack.com/2013/07/11/photon-and-themes/
184
 */
185
if ( Jetpack::is_module_active( 'photon' ) ) {
186
	add_filter( 'jetpack_photon_url', 'jetpack_photon_url', 10, 3 );
187
}
188
189
if ( JETPACK__SANDBOX_DOMAIN ) {
190
	require_once( JETPACK__PLUGIN_DIR . '_inc/jetpack-server-sandbox.php' );
191
}
192
193
require_once( JETPACK__PLUGIN_DIR . '3rd-party/3rd-party.php' );
194
195
Jetpack::init();
196