wordpress-develop/src/wp-admin/index.php
Anton Timmermans d2d7243e80 Build tools: Allow building WordPress to src.
After the JavaScript reorganization in [43309], it was no longer possible to test WordPress from the `src` folder. That meant a build step was required to test PHP modifications. That is suboptimal as even a simple copy is slower than a web server just serving the new file.

We achieve building to `src` by setting a `WORKING_DIR` constant in the Gruntfile that is `build` by default, but changes to `src` when the `--dev` flag is present on any Grunt command. We provide sensible defaults so some commands, such as copying `version.php`, always build to `build`.

Because testing from `build` is no longer required, we change the messages present in `index.php` and `wp-admin/index.php` to be more broadly about building WordPress.

We also change the webpack config to have more straightforward behavior based on the `buildTarget` argument. It only determines the build target now and has no implicit behavior anymore. `grunt build` still works as it worked before, to make sure that the build server produces the same `wordpress.zip` we are used to.

We do all this instead of a symlink setup because symlinks don't work on every platform.

Props omarreiss, netweb, flixos90, SergeyBiryukov.
Fixes #44492.


git-svn-id: https://develop.svn.wordpress.org/trunk@44359 602fd350-edb4-49c9-b593-d223f7449a82
2018-12-24 13:28:22 +00:00

71 lines
2.3 KiB
PHP

<?php
/**
* Note: this file exists only to remind developers to build the assets.
* For the real wp-admin/index.php that gets built and boots WordPress,
* please refer to wp-admin/_index.php.
*/
if ( file_exists( dirname( __FILE__ ) . '/../wp-includes/js/dist/edit-post.js' ) ) {
require_once dirname( __FILE__ ) . '/_index.php';
return;
}
/** Define ABSPATH as this file's directory */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', dirname( __FILE__ ) . '/../' );
}
define( 'WPINC', 'wp-includes' );
require_once( ABSPATH . WPINC . '/load.php' );
// Standardize $_SERVER variables across setups.
wp_fix_server_vars();
require_once( ABSPATH . WPINC . '/functions.php' );
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
require_once( ABSPATH . WPINC . '/version.php' );
wp_check_php_mysql_versions();
wp_load_translations_early();
// Die with an error message
$die = sprintf(
/* translators: %1$s: WordPress */
__( 'You are running %1$s without JavaScript and CSS files. These need to be built.' ),
'WordPress'
) . '</p>';
$die .= '<p>' . __( 'Before running any grunt tasks you need to make sure the dependencies are installed. You can install these by running ');
$die .= '<code style="color: green;">npm install</code>.</p>';
$die .= '<ul>';
$die .= '<li>' . sprintf(
/* translators: %s: WordPress */
__( 'To build %s while developing run:' ),
'WordPress'
) . '<br /><br />';
$die .= '<code style="color: green;">grunt build --dev</code></li>';
$die .= '<li>' . sprintf(
__( 'To build files automatically when changing the source files run:' ),
'WordPress'
) . '<br /><br />';
$die .= '<code style="color: green;">grunt watch</code></li>';
$die .= '<li>' . sprintf(
__( 'To create a production build of %s run:' ),
'WordPress'
) . '<br /><br />';
$die .= '<code style="color: green;">grunt build</code></li>';
$die .= '</ul>';
$die .= '<p>' . sprintf(
/* translators: %1$s: NPM URL, %2$s: Grunt URL */
__( 'This requires <a href="%1$s">NPM</a> and <a href="%2$s">Grunt</a>. <a href="%3$s">Read more about setting up your local development environment</a>.' ),
'https://www.npmjs.com/',
'https://gruntjs.com/',
__( 'https://make.wordpress.org/core/handbook/tutorials/installing-wordpress-locally/' )
) . '</p>';
wp_die( $die, __( 'WordPress &rsaquo; Error' ) );