2018-04-17 21:03:14 +00:00
< ? php
/**
2018-07-10 12:48:06 +00:00
* Plugin Name : WooCommerce Admin
2019-03-13 17:14:02 +00:00
* Plugin URI : https :// github . com / woocommerce / woocommerce - admin
2019-03-08 16:20:42 +00:00
* Description : A new JavaScript - driven interface for managing your store . The plugin includes new and improved reports , and a dashboard to monitor all the important key metrics of your site .
* Author : WooCommerce
2018-04-17 23:51:48 +00:00
* Author URI : https :// woocommerce . com /
2019-03-13 17:14:02 +00:00
* Text Domain : woocommerce - admin
2018-04-17 23:51:48 +00:00
* Domain Path : / languages
2020-08-11 01:05:03 +00:00
* Version : 1.6 . 0 - dev
2019-12-13 15:05:41 +00:00
* Requires at least : 5.3 . 0
2019-07-23 03:26:46 +00:00
* Requires PHP : 5.6 . 20
2018-04-17 21:03:14 +00:00
*
2019-04-26 18:39:37 +00:00
* WC requires at least : 3.6 . 0
2020-07-14 14:24:52 +00:00
* WC tested up to : 4.3 . 0
2019-04-01 16:16:13 +00:00
*
2020-08-11 19:18:47 +00:00
* @ package WooCommerce\Admin
2018-04-17 21:03:14 +00:00
*/
2019-05-14 14:34:16 +00:00
defined ( 'ABSPATH' ) || exit ;
2019-03-25 06:43:26 +00:00
2019-08-12 21:52:09 +00:00
use \Automattic\WooCommerce\Admin\FeaturePlugin ;
2020-08-04 01:13:48 +00:00
use \Automattic\WooCommerce\Admin\Loader ;
2019-07-31 19:47:32 +00:00
2019-07-29 18:04:17 +00:00
/**
* Autoload packages .
*
* We want to fail gracefully if `composer install` has not been executed yet , so we are checking for the autoloader .
* If the autoloader is not present , let ' s log the failure and display a nice admin notice .
*/
2020-08-04 01:13:48 +00:00
$autoloader = __DIR__ . '/vendor/autoload_packages.php' ;
2019-07-29 18:04:17 +00:00
if ( is_readable ( $autoloader ) ) {
require $autoloader ;
} else {
if ( defined ( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log ( // phpcs:ignore
sprintf (
/* translators: 1: composer command. 2: plugin directory */
esc_html__ ( 'Your installation of the WooCommerce Admin feature plugin is incomplete. Please run %1$s within the %2$s directory.' , 'woocommerce-admin' ),
'`composer install`' ,
'`' . esc_html ( str_replace ( ABSPATH , '' , __DIR__ ) ) . '`'
)
);
}
/**
* Outputs an admin notice if composer install has not been ran .
*/
add_action (
'admin_notices' ,
function () {
?>
< div class = " notice notice-error " >
< p >
< ? php
printf (
/* translators: 1: composer command. 2: plugin directory */
esc_html__ ( 'Your installation of the WooCommerce Admin feature plugin is incomplete. Please run %1$s within the %2$s directory.' , 'woocommerce-admin' ),
'<code>composer install</code>' ,
'<code>' . esc_html ( str_replace ( ABSPATH , '' , __DIR__ ) ) . '</code>'
);
?>
</ p >
</ div >
< ? php
}
);
return ;
}
2020-08-04 01:13:48 +00:00
/**
* Returns whether the current version is a development version
* Note this relies on composer . json version , not plugin version .
* Development installs of the plugin don ' t have a version defined in
* composer json .
*
* @ return bool True means the current version is a development version .
*/
function woocommerce_admin_is_development_version () {
$composer_file = __DIR__ . '/composer.json' ;
if ( ! is_readable ( $composer_file ) ) {
return false ;
}
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- including local file
$composer_config = json_decode ( file_get_contents ( $composer_file ), true );
return ! isset ( $composer_config [ 'version' ] );
}
/**
* Returns true if build file exists .
*
* @ return bool
*/
function woocommerce_admin_check_build_files () {
$script_debug = defined ( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ;
$suffix = Loader :: should_use_minified_js_file ( $script_debug ) ? '.min' : '' ;
return file_exists ( __DIR__ . " /dist/app/index { $suffix } .js " );
}
/**
* If development version is detected and the Jetpack constant is not defined , show a notice .
*/
if ( woocommerce_admin_is_development_version () && ! defined ( 'JETPACK_AUTOLOAD_DEV' ) ) {
add_action (
'admin_notices' ,
function () {
echo '<div class="error"><p>' ;
printf (
/* Translators: %1$s is referring to a php constant name, %2$s is referring to the wp-config.php file. */
esc_html__ ( 'WooCommerce Admin development mode requires the %1$s constant to be defined and true in your %2$s file. Otherwise you are loading the admin package from WooCommerce core.' , 'woocommerce-admin' ),
'<code>JETPACK_AUTOLOAD_DEV</code>' ,
'<code>wp-config.php</code>'
);
echo '</p></div>' ;
}
);
}
/**
* If we ' re missing expected files , notify users that the plugin needs to be built .
*/
if ( ! woocommerce_admin_check_build_files () ) {
add_action (
'admin_notices' ,
function () {
echo '<div class="error"><p>' ;
printf (
/* Translators: %1$s, %2$s, and %3$s are all build commands to be run in order. */
esc_html__ ( 'You have installed a development version of WooCommerce Admin which requires files to be built. From the plugin directory, run %1$s and %2$s to install dependencies, then %3$s to build the files.' , 'woocommerce-admin' ),
'<code>composer install</code>' ,
'<code>npm install</code>' ,
'<code>npm run build</code>'
);
printf (
/* translators: 1: URL of GitHub Repository build page */
esc_html__ ( 'Or you can download a pre-built version of the plugin by visiting <a href="%1$s">the releases page in the repository</a>.' , 'woocommerce-admin' ),
'https://github.com/woocommerce/woocommerce-admin/releases'
);
echo '</p></div>' ;
}
);
}
2019-08-12 21:52:09 +00:00
FeaturePlugin :: instance () -> init ();