Completed
Push — add/admin-page-package ( 29d478...cbc05d )
by
unknown
141:41 queued 131:38
created

jetpack-beta.php ➔ jetpack_admin_missing_autoloader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 24
loc 24
rs 9.536
c 0
b 0
f 0
1
<?php
2
/**
3
 * Plugin Name: Jetpack Beta Tester
4
 * Plugin URI: https://jetpack.com/beta/
5
 * Description: Use the Beta plugin to get a sneak peek at new features and test them on your site.
6
 * Version: 2.5.0-alpha
7
 * Author: Automattic
8
 * Author URI: https://jetpack.com/
9
 * License: GPLv2 or later
10
 * Text Domain: jetpack-beta
11
 *
12
 * @package automattic/jetpack-beta
13
 */
14
15
/*
16
This program is free software; you can redistribute it and/or
17
modify it under the terms of the GNU General Public License
18
as published by the Free Software Foundation; either version 2
19
of the License, or (at your option) any later version.
20
21
This program is distributed in the hope that it will be useful,
22
but WITHOUT ANY WARRANTY; without even the implied warranty of
23
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
GNU General Public License for more details.
25
26
You should have received a copy of the GNU General Public License
27
along with this program; if not, write to the Free Software
28
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
29
*/
30
31
// Check that the file is not accessed directly.
32
if ( ! defined( 'ABSPATH' ) ) {
33
	exit;
34
}
35
36
/**
37
 * How this plugin works.
38
 * Jetpack beta manages files inside jetpack-dev folder this folder should contain
39
 */
40
define( 'JPBETA__PLUGIN_FOLDER', basename( __DIR__ ) );
41
define( 'JPBETA__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
42
define( 'JPBETA__PLUGIN_FILE', __FILE__ );
43
define( 'JPBETA_VERSION', '2.5.0-alpha' );
44
45
define( 'JPBETA_DEFAULT_BRANCH', 'rc_only' );
46
47
define( 'JETPACK_BETA_MANIFEST_URL', 'https://betadownload.jetpack.me/jetpack-branches.json' );
48
define( 'JETPACK_ORG_API_URL', 'https://api.wordpress.org/plugins/info/1.0/jetpack.json' );
49
define( 'JETPACK_GITHUB_API_URL', 'https://api.github.com/repos/Automattic/Jetpack/' );
50
define( 'JETPACK_GITHUB_URL', 'https://github.com/Automattic/jetpack' );
51
define( 'JETPACK_DEFAULT_URL', 'https://jetpack.com' );
52
53
define( 'JETPACK_DEV_PLUGIN_SLUG', 'jetpack-dev' );
54
55
define( 'JETPACK_PLUGIN_FILE', 'jetpack/jetpack.php' );
56
define( 'JETPACK_DEV_PLUGIN_FILE', 'jetpack-dev/jetpack.php' );
57
58
define( 'JETPACK_BETA_REPORT_URL', 'https://jetpack.com/contact-support/beta-group/' );
59
60
defined( 'JETPACK_GREEN' ) || define( 'JETPACK_GREEN', '#2fb41f' );
61
62
/**
63
 * This is where the loading of Jetpack Beta.
64
 *
65
 * First, we try to load our composer autoloader.
66
 *
67
 * - If it fails, we "pause" Jetpack by ending the loading process
68
 *   and displaying an admin_notice to inform the site owner.
69
 *   (We want to fail gracefully if `composer install` has not been executed yet, so we are checking for the autoloader.)
70
 * - If it succeeds, we require load-jetpack.php, where all legacy files are required,
71
 *   and where we add on to various hooks that we expect to always run.
72
 */
73
$jetpack_beta_autoloader = JPBETA__PLUGIN_DIR . 'vendor/autoload_packages.php';
74 View Code Duplication
if ( is_readable( $jetpack_beta_autoloader ) ) {
75
	require $jetpack_beta_autoloader;
76
} else {
77
	if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
78
		error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
79
			sprintf(
80
			/* translators: Placeholder is a link to a support document. */
81
				__( 'Your installation of Jetpack Beta is incomplete. If you installed Jetpack from GitHub, please refer to this document to set up your development environment: %1$s', 'jetpack' ),
82
				'https://github.com/Automattic/jetpack/blob/master/docs/development-environment.md'
83
			)
84
		);
85
	}
86
87
	/**
88
	 * Outputs an admin notice for folks running Jetpack without having run composer install.
89
	 *
90
	 * @since 7.4.0
91
	 */
92
	function jetpack_admin_missing_autoloader() {
93
		?>
94
		<div class="notice notice-error is-dismissible">
95
			<p>
96
				<?php
97
				printf(
98
					wp_kses(
99
					/* translators: Placeholder is a link to a support document. */
100
						__( 'Your installation of Jetpack Beta is incomplete. If you installed Jetpack from GitHub, please refer to <a href="%1$s" target="_blank" rel="noopener noreferrer">this document</a> to set up your development environment. Ensure you have run jetpack install plugins/beta.', 'jetpack' ),
101
						array(
102
							'a' => array(
103
								'href'   => array(),
104
								'target' => array(),
105
								'rel'    => array(),
106
							),
107
						)
108
					),
109
					'https://github.com/Automattic/jetpack/blob/master/docs/development-environment.md'
110
				);
111
				?>
112
			</p>
113
		</div>
114
		<?php
115
	}
116
117
	add_action( 'admin_notices', 'jetpack_admin_missing_autoloader' );
118
	return;
119
}
120
121
require_once 'class-jetpack-beta-autoupdate-self.php';
122
require_once 'class-jetpackbetaclicommand.php';
123
add_action( 'init', array( 'Jetpack_Beta_Autoupdate_Self', 'instance' ) );
124
125
// The main plugin class file.
126
require_once __DIR__ . '/class-jetpack-beta.php';
127
128
set_error_handler( array( 'Jetpack_Beta', 'custom_error_handler' ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_set_error_handler
129
130
register_activation_hook( __FILE__, array( 'Jetpack_Beta', 'activate' ) );
131
register_deactivation_hook( __FILE__, array( 'Jetpack_Beta', 'deactivate' ) );
132
133
add_action( 'init', array( 'Jetpack_Beta', 'instance' ) );
134
add_action( 'muplugins_loaded', array( 'Jetpack_Beta', 'is_network_enabled' ) );
135