Completed
Push — add-autoloader-loader-package ( 92b21b )
by
unknown
06:55
created

AutoloaderLoader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load_autoloader() 0 19 4
A jetpack_admin_missing_autoloader() 0 15 1
1
<?php
2
3
namespace Jetpack\Assets;
4
5
class AutoloaderLoader {
6
7
	public function load_autoloader() {
8
		// Load all the packages.
9
		$jetpack_autoloader = plugin_dir_path( __FILE__ ) . '/vendor/autoload.php';
10
		if ( is_readable( $jetpack_autoloader ) ) {
11
			require $jetpack_autoloader;
12
		} else {
13
			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
14
				error_log(
15
					sprintf(
16
						/* translators: Placeholder is a link to a support document. */
17
						__( 'Your installation of Jetpack 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.', 'jetpack' ),
18
						esc_url( 'https://github.com/Automattic/jetpack/blob/master/docs/development-environment.md' )
19
					)
20
				);
21
			}
22
			add_action( 'admin_notices', array( $this, 'jetpack_admin_missing_autoloader' ) );
23
			return;
24
		}
25
	}
26
27
	/**
28
	 * Outputs an admin notice for folks running Jetpack without having run composer install.
29
	 *
30
	 * @since 7.4.0
31
	 */
32
	public function jetpack_admin_missing_autoloader() { ?>
33
		<div class="notice notice-error is-dismissible">
34
			<p>
35
				<?php
36
				printf(
37
					/* translators: Placeholder is a link to a support document. */
38
					__( 'Your installation of Jetpack 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.', 'jetpack' ),
39
					esc_url( 'https://github.com/Automattic/jetpack/blob/master/docs/development-environment.md' )
40
				);
41
				?>
42
			</p>
43
			</p>
44
		</div>
45
		<?php
46
	}
47
}
48