Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 37
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 *
4 * Plugin Name: WordPress.com Features
5 * Description: Test plugin for the jetpack-mu-wpcom package
6 * Version: 2.12.0
7 * Author: Automattic
8 * License: GPLv2 or later
9 * Text Domain: jetpack-mu-wpcom-plugin
10 *
11 * @package automattic/jetpack-mu-wpcom-plugin
12 */
13
14/**
15 * Conditionally load the jetpack-mu-wpcom package.
16 *
17 * JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN=true will load the package via the Jetpack Beta Tester plugin, not wpcomsh.
18 */
19if ( defined( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN' ) && JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN ) {
20    /*
21     * Autoloader check: This ensures the plugin doesn't fatal if activated before
22     * `composer install` has been run. This is a common oversight during development
23     * setup. The admin notice helps developers quickly identify the issue.
24     */
25    $jetpack_autoloader = __DIR__ . '/vendor/autoload.php';
26    if ( is_readable( $jetpack_autoloader ) ) {
27        require_once $jetpack_autoloader;
28        if ( class_exists( 'Automattic\Jetpack\Jetpack_Mu_Wpcom' ) ) {
29            Automattic\Jetpack\Jetpack_Mu_Wpcom::init();
30        }
31    } else {
32        if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
33            error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
34                __( 'Error loading autoloader file for WordPress.com Features plugin', 'jetpack-mu-wpcom-plugin' )
35            );
36        }
37
38        add_action(
39            'admin_notices',
40            function () {
41                if ( get_current_screen()->id !== 'plugins' ) {
42                    return;
43                }
44
45                $message = sprintf(
46                    wp_kses(
47                        /* translators: Placeholder is a link to a support document. */
48                        __( 'Your installation of WordPress.com Features is incomplete. If you installed WordPress.com Features from GitHub, please refer to <a href="%1$s" target="_blank" rel="noopener noreferrer">this document</a> to set up your development environment. WordPress.com Features must have Composer dependencies installed and built via the build command.', 'jetpack-mu-wpcom-plugin' ),
49                        array(
50                            'a' => array(
51                                'href'   => array(),
52                                'target' => array(),
53                                'rel'    => array(),
54                            ),
55                        )
56                    ),
57                    'https://github.com/Automattic/jetpack/blob/trunk/docs/development-environment.md#building-your-project'
58                );
59                wp_admin_notice(
60                    $message,
61                    array(
62                        'type'        => 'error',
63                        'dismissible' => true,
64                    )
65                );
66            }
67        );
68    }
69}