'error',
'dismissible' => true,
)
);
}
add_action( 'admin_notices', 'jetpack_admin_unsupported_wp_notice' );
return;
}
/**
* This is where the loading of Jetpack begins.
*
* First, we try to load our composer autoloader.
*
* - If it fails, we "pause" Jetpack by ending the loading process
* and displaying an admin_notice to inform the site owner.
* (We want to fail gracefully if `composer install` has not been executed yet, so we are checking for the autoloader.)
* - If it succeeds, we require load-jetpack.php, where all legacy files are required,
* and where we add on to various hooks that we expect to always run.
*/
$jetpack_autoloader = JETPACK__PLUGIN_DIR . 'vendor/autoload_packages.php';
$jetpack_module_headings_file = JETPACK__PLUGIN_DIR . 'modules/module-headings.php'; // This file is loaded later in load-jetpack.php, but let's check here to pause before half-loading Jetpack.
if ( is_readable( $jetpack_autoloader ) && is_readable( $jetpack_module_headings_file ) ) {
require_once $jetpack_autoloader;
if ( method_exists( '\Automattic\Jetpack\Assets', 'alias_textdomains_from_file' ) ) {
\Automattic\Jetpack\Assets::alias_textdomains_from_file( JETPACK__PLUGIN_DIR . 'jetpack_vendor/i18n-map.php' );
}
} else {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
sprintf(
/* translators: Placeholder is a link to a support document. */
__( 'Your installation of Jetpack is incomplete. If you installed Jetpack from GitHub, please refer to this document to set up your development environment: %1$s', 'jetpack' ),
'https://github.com/Automattic/jetpack/blob/trunk/docs/development-environment.md'
)
);
}
// Add a red bubble notification to My Jetpack if the installation is bad.
add_filter(
'my_jetpack_red_bubble_notification_slugs',
function ( $slugs ) {
$slugs['jetpack-plugin-bad-installation'] = array(
'data' => array(
'plugin' => 'Jetpack',
),
);
return $slugs;
}
);
/**
* Outputs an admin notice for folks running Jetpack without having run composer install.
*
* @since 7.4.0
*/
function jetpack_admin_missing_files() {
if ( get_current_screen()->id !== 'plugins' ) {
return;
}
$message = sprintf(
wp_kses(
/* translators: Placeholder is a link to a support document. */
__( 'Your installation of Jetpack is incomplete. If you installed Jetpack from GitHub, please refer to this document to set up your development environment. Jetpack must have Composer dependencies installed and built via the build command: jetpack build plugins/jetpack --deps
', 'jetpack' ),
array(
'a' => array(
'href' => array(),
'rel' => array(),
'target' => array(),
),
'code' => array(),
)
),
'https://github.com/Automattic/jetpack/blob/trunk/docs/development-environment.md#building-your-project'
);
wp_admin_notice(
$message,
array(
'type' => 'error',
'dismissible' => true,
)
);
}
add_action( 'admin_notices', 'jetpack_admin_missing_files' );
return;
}
register_activation_hook( __FILE__, array( 'Jetpack', 'plugin_activation' ) );
register_deactivation_hook( __FILE__, array( 'Jetpack', 'plugin_deactivation' ) );
// Load image cdn core. This should load regardless of whether the photon module is active.
Image_CDN_Core::setup();
// Require everything else, that is not loaded via the autoloader.
require_once JETPACK__PLUGIN_DIR . 'load-jetpack.php';