Completed
Push — test/osk-test ( 611177...a15e4f )
by
unknown
29:47 queued 08:30
created

jetpack.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
4
/*
5
 * Plugin Name: Jetpack by WordPress.com
6
 * Plugin URI: https://jetpack.com
7
 * 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.
8
 * Author: Automattic
9
 * Version: 6.4-alpha
10
 * Author URI: https://jetpack.com
11
 * License: GPL2+
12
 * Text Domain: jetpack
13
 * Domain Path: /languages/
14
 */
15
16
define( 'JETPACK__MINIMUM_WP_VERSION', '4.7' );
17
18
define( 'JETPACK__VERSION',            '6.4-alpha' );
19
define( 'JETPACK_MASTER_USER',         true );
20
define( 'JETPACK__API_VERSION',        1 );
21
define( 'JETPACK__PLUGIN_DIR',         plugin_dir_path( __FILE__ ) );
22
define( 'JETPACK__PLUGIN_FILE',        __FILE__ );
23
24
defined( 'JETPACK_CLIENT__AUTH_LOCATION' )   or define( 'JETPACK_CLIENT__AUTH_LOCATION', 'header' );
25
defined( 'JETPACK_CLIENT__HTTPS' )           or define( 'JETPACK_CLIENT__HTTPS', 'AUTO' );
26
defined( 'JETPACK__GLOTPRESS_LOCALES_PATH' ) or define( 'JETPACK__GLOTPRESS_LOCALES_PATH', JETPACK__PLUGIN_DIR . 'locales.php' );
27
defined( 'JETPACK__API_BASE' )               or define( 'JETPACK__API_BASE', 'https://jetpack.wordpress.com/jetpack.' );
28
defined( 'JETPACK_PROTECT__API_HOST' )       or define( 'JETPACK_PROTECT__API_HOST', 'https://api.bruteprotect.com/' );
29
defined( 'JETPACK__WPCOM_JSON_API_HOST' )    or define( 'JETPACK__WPCOM_JSON_API_HOST', 'public-api.wordpress.com' );
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as or instead of || is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
30
31
/**
32
 * Returns the location of Jetpack's lib directory. This filter is applied
33
 * in require_lib().
34
 *
35
 * @since 4.0.2
36
 *
37
 * @return string Location of Jetpack library directory.
38
 *
39
 * @filter require_lib_dir
40
 */
41
function jetpack_require_lib_dir() {
42
	return JETPACK__PLUGIN_DIR . '_inc/lib';
43
}
44
add_filter( 'jetpack_require_lib_dir', 'jetpack_require_lib_dir' );
45
46
/**
47
 * Checks if the code debug mode turned on, and returns false if it is. When Jetpack is in
48
 * code debug mode, it shouldn't use minified assets. Note that this filter is not being used
49
 * in every place where assets are enqueued. The filter is added at priority 9 to be overridden
50
 * by any default priority filter that runs after it.
51
 *
52
 * @since 6.2.0
53
 *
54
 * @return boolean
55
 *
56
 * @filter jetpack_should_use_minified_assets
57
 */
58
function jetpack_should_use_minified_assets() {
59
	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
60
		return false;
61
	}
62
	return true;
63
}
64
add_filter( 'jetpack_should_use_minified_assets', 'jetpack_should_use_minified_assets', 9 );
65
66
// @todo: Abstract out the admin functions, and only include them if is_admin()
67
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack.php'               );
68
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-network.php'       );
69
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-client.php'        );
70
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-data.php'          );
71
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-client-server.php' );
72
require_once( JETPACK__PLUGIN_DIR . 'sync/class.jetpack-sync-actions.php' );
73
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-options.php'       );
74
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-user-agent.php'    );
75
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-post-images.php'   );
76
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-error.php'         );
77
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-heartbeat.php'     );
78
require_once( JETPACK__PLUGIN_DIR . 'class.photon.php'                );
79
require_once( JETPACK__PLUGIN_DIR . 'functions.photon.php'            );
80
require_once( JETPACK__PLUGIN_DIR . 'functions.global.php'            );
81
require_once( JETPACK__PLUGIN_DIR . 'functions.compat.php'            );
82
require_once( JETPACK__PLUGIN_DIR . 'functions.gallery.php'           );
83
require_once( JETPACK__PLUGIN_DIR . 'require-lib.php'                 );
84
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-autoupdate.php'    );
85
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-tracks.php'        );
86
require_once( JETPACK__PLUGIN_DIR . 'class.frame-nonce-preview.php'   );
87
require_once( JETPACK__PLUGIN_DIR . 'modules/module-headings.php');
88
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-constants.php');
89
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-idc.php'  );
90
require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-connection-banner.php'  );
91
92
if ( is_admin() ) {
93
	require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php'     );
94
	require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-jitm.php'      );
95
	require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-debugger.php'  );
96
}
97
98
// Play nice with http://wp-cli.org/
99
if ( defined( 'WP_CLI' ) && WP_CLI ) {
100
	require_once( JETPACK__PLUGIN_DIR . 'class.jetpack-cli.php'       );
101
}
102
103
require_once( JETPACK__PLUGIN_DIR . '_inc/lib/class.core-rest-api-endpoints.php' );
104
105
register_activation_hook( __FILE__, array( 'Jetpack', 'plugin_activation' ) );
106
register_deactivation_hook( __FILE__, array( 'Jetpack', 'plugin_deactivation' ) );
107
add_action( 'updating_jetpack_version', array( 'Jetpack', 'do_version_bump' ), 10, 2 );
108
add_action( 'init', array( 'Jetpack', 'init' ) );
109
add_action( 'plugins_loaded', array( 'Jetpack', 'plugin_textdomain' ), 99 );
110
add_action( 'plugins_loaded', array( 'Jetpack', 'load_modules' ), 100 );
111
add_filter( 'jetpack_static_url', array( 'Jetpack', 'staticize_subdomain' ) );
112
add_filter( 'is_jetpack_site', '__return_true' );
113
114
/**
115
 * Add an easy way to photon-ize a URL that is safe to call even if Jetpack isn't active.
116
 *
117
 * See: http://jetpack.com/2013/07/11/photon-and-themes/
118
 */
119
if ( Jetpack::is_module_active( 'photon' ) ) {
120
	add_filter( 'jetpack_photon_url', 'jetpack_photon_url', 10, 3 );
121
}
122
123
require_once( JETPACK__PLUGIN_DIR . '3rd-party/3rd-party.php' );
124
125
Jetpack::init();
126