Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VIP config file #98

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions configure.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,22 +653,20 @@ function install_plugin( array $plugin_data, bool $prompt, &$installed_plugins )
run( 'ln -s mu-plugins/drop-ins/object-cache.php object-cache.php' );
}

write( 'Scaffolding out vip-config...' );

run( 'mkdir -p vip-config && touch vip-config/.gitkeep' );

write( 'Scaffolding out VIP directories...' );

run( 'mkdir -p images && touch images/.gitkeep' );
run( 'mkdir -p languages && touch languages/.gitkeep' );
run( 'mkdir -p private && touch private/.gitkeep' );
run( 'mkdir -p vip-config && touch vip-config/.gitkeep' );

echo "Done!\n\n";
} elseif ( 'pantheon' === $hosting_provider ) {
write( 'Deleting VIP-specific GitHub Action workflows...' );

delete_files(
[
'vip-config',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when/where is this being created that it is necessary to delete this at this point?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakewrfoster I guess as part of the repo we have vip-config/vip-config.php that needs to be removed?

'.github/workflows/deploy-to-vip.yml',
'.circleci',
]
Expand Down
103 changes: 103 additions & 0 deletions vip-config/vip-config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
/**
* Hi there, VIP dev!
*
* vip-config.php is where you put things you'd usually put in wp-config.php. Don't worry about database settings
* and such, we've taken care of that for you. This is a good place to define a constant or something of that
* nature. However, consider using environment variables for anything sensitive or environment-specific:
*
* @see https://docs.wpvip.com/how-tos/manage-environment-variables/
*
* WARNING: This file is loaded very early (immediately after `wp-config.php`), which means that most WordPress APIs,
* classes, and functions are not available. The code below should be limited to pure PHP.
*
* @see https://docs.wpvip.com/technical-references/vip-codebase/vip-config-directory/
*
* Happy coding!
*
* - The WordPress VIP Team
**/

/**
* Redirect non www to www.
*
* @see https://docs.wpvip.com/redirects/domain-redirects-in-vip-config-php/
*/
if ( isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ) {
$http_host = $_SERVER['HTTP_HOST']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$request_uri = $_SERVER['REQUEST_URI']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
}

/**
* Set a high default limit to avoid too many revisions from polluting the database.
*
* @see https://docs.wpvip.com/technical-references/vip-platform/post-revisions/
*
* Posts with high revisions can result in fatal errors or have performance issues.
*
* Feel free to adjust this depending on your use cases.
*/
if ( ! defined( 'WP_POST_REVISIONS' ) ) {
define( 'WP_POST_REVISIONS', 100 );
}
Comment on lines +31 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be moved to Alleyvate. maybe @kevinfodness can weigh in on this? I assume we would want this same approach to employed on Pantheon sites as well as VIP sites.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes from https://github.com/Automattic/vip-go-skeleton/blob/production/vip-config/vip-config.php

We might want to add it to Alleyvate for non-VIP sites, yes, but for our purposes here we're cloning what VIP is providing us with in their skeleton.

Another possibility for how to tackle this would be to actually fetch the latest and greatest from the VIP skeleton repo rather than maintaining a copy here. If installing VIP, then clone skeleton, copy relevant files, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should make a separate issue for the automating the download of the VIP Config file.


/**
* The VIP_JETPACK_IS_PRIVATE constant is enabled by default in non-production environments.
*
* It disables programmatic access to content via the WordPress.com REST API and Jetpack Search;
* subscriptions via the WordPress.com Reader; and syndication via the WordPress.com Firehose.
*
* You can disable "private" mode (e.g. for testing) in non-production environment by setting the constant to `false` below (or just by removing the lines).
*
* @see https://docs.wpvip.com/technical-references/restricting-site-access/controlling-content-distribution-via-jetpack/
*/
if (
! defined( 'VIP_JETPACK_IS_PRIVATE' )
&& defined( 'VIP_GO_APP_ENVIRONMENT' )
&& 'production' !== VIP_GO_APP_ENVIRONMENT
) {
define( 'VIP_JETPACK_IS_PRIVATE', true );
}

/**
* Disable New Relic Browser instrumentation.
*
* By default, the New Relic extension automatically enables Browser instrumentation.
*
* This injects some New Relic specific javascript onto all pages on the VIP Platform.
*
* This isn't always desireable (e.g. impacts performance) so let's turn it off.
*
* If you would like to enable Browser instrumentation, please remove the lines below.
*
* @see https://docs.newrelic.com/docs/agents/php-agent/features/browser-monitoring-php-agent/#disable
* @see https://docs.wpvip.com/technical-references/tools-for-site-management/new-relic/
*/
if ( function_exists( 'newrelic_disable_autorum' ) ) {
newrelic_disable_autorum();
}

/**
* Set WP_DEBUG to true for all local or non-production VIP environments to ensure
* _doing_it_wrong() notices display in Query Monitor. This also changes the error_reporting level to E_ALL.
*
* @see https://wordpress.org/support/article/debugging-in-wordpress/#wp_debug
*/
if (
! defined( 'WP_DEBUG' )
&& ( ! defined( 'VIP_GO_APP_ENVIRONMENT' ) || 'production' !== VIP_GO_APP_ENVIRONMENT )
) {
define( 'WP_DEBUG', true );
}

// Enable VIP Search.
define( 'VIP_ENABLE_VIP_SEARCH', true );
define( 'VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION', true );

// Set up VIP Search locally.
if ( ! defined( 'VIP_GO_APP_ENVIRONMENT' ) || 'local' === VIP_GO_APP_ENVIRONMENT ) {
define( 'VIP_ELASTICSEARCH_ENDPOINTS', [ 'http://localhost:9200' ] );
define( 'VIP_ELASTICSEARCH_USERNAME', 'username' );
define( 'VIP_ELASTICSEARCH_PASSWORD', 'password' );
define( 'FILES_CLIENT_SITE_ID', 'localdev' );
}