From e0422f9bbfd35ac94f804438e977beb9ddec4dd1 Mon Sep 17 00:00:00 2001 From: Horacio Gonzalez Date: Mon, 16 Mar 2026 15:20:12 +0100 Subject: [PATCH 1/2] Update to Bedrock 1.30.0 and rewrite README Upgrade from Bedrock 1.12.8 (WordPress 5.3) to 1.30.0 (WordPress 6.9). Clever Cloud patches reapplied: MYSQL_ADDON_* and CELLAR_ADDON_* env var mapping, s3-uploads plugin, .htaccess tracking, and php.json webroot. Add setup-cellar.sh script to create the S3 bucket via s3cmd. README rewritten to match the standard Clever Cloud example format with both Web Console and CLI deployment instructions. --- .gitignore | 36 ++- README.md | 265 ++++++++++++++---- composer.json | 65 +++-- config/application.php | 103 +++++-- config/environments/development.php | 5 + config/environments/staging.php | 3 + phpcs.xml | 23 -- setup-cellar.sh | 15 + web/.htaccess | 9 +- web/app/mu-plugins/bedrock-autoloader.php | 201 +------------ web/app/mu-plugins/disallow-indexing.php | 14 - .../mu-plugins/register-theme-directory.php | 14 - web/app/plugins/.gitkeep | 0 web/app/plugins/composer.json | 5 - web/app/plugins/wp-dummy-content-generator | 1 - web/app/themes/.gitkeep | 0 web/app/uploads/.gitkeep | 0 web/index.php | 4 +- web/wp-config.php | 1 + wp-cli.yml | 3 + 20 files changed, 407 insertions(+), 360 deletions(-) delete mode 100644 phpcs.xml create mode 100755 setup-cellar.sh delete mode 100644 web/app/mu-plugins/disallow-indexing.php delete mode 100644 web/app/mu-plugins/register-theme-directory.php create mode 100644 web/app/plugins/.gitkeep delete mode 100644 web/app/plugins/composer.json delete mode 100644 web/app/plugins/wp-dummy-content-generator create mode 100644 web/app/themes/.gitkeep create mode 100644 web/app/uploads/.gitkeep create mode 100644 wp-cli.yml diff --git a/.gitignore b/.gitignore index 455b64a45..55eee763a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,35 @@ +# Application +web/app/plugins/* +!web/app/plugins/.gitkeep +# Ignore Composer-installed mu-plugin directories; single-file mu-plugins are tracked intentionally +web/app/mu-plugins/*/ +web/app/themes/twentytwentyfive/ +web/app/upgrade +web/app/uploads/* +!web/app/uploads/.gitkeep +web/app/cache/* + +# WordPress +web/wp + +# Logs +*.log + +# Dotenv +.env +.env.* +!.env.example + +# Composer +/vendor +auth.json + +# PHPUnit/Pest +phpunit.xml +.phpunit.result.cache +.phpunit.cache + +# WP-CLI +wp-cli.local.yml + .clever.json -vendor/ -composer.lock \ No newline at end of file diff --git a/README.md b/README.md index 85deda0df..83e374049 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,236 @@ -# Deploy WordPress on CleverCloud, the immutable way +# WordPress (Bedrock) Example Application on Clever Cloud -## What is this? +[![Clever Cloud - PaaS](https://img.shields.io/badge/Clever%20Cloud-PaaS-orange)](https://clever-cloud.com) -[Bedrock](https://roots.io/bedrock/) ([GitHub Project](https://github.com/roots/bedrock)) is a modern WordPress stack that allows to maintain your installation clean from any code change during runtime. [CleverCloud](https://www.clever-cloud.com/) is a rock solid IT automation platform. +This is a WordPress application using [Bedrock](https://roots.io/bedrock/) ([GitHub](https://github.com/roots/bedrock)), a modern WordPress stack that keeps your installation clean from runtime code changes. It is pre-configured to deploy on [Clever Cloud](https://www.clever-cloud.com/) with MySQL and Cellar S3 storage. -Now you can take advantages of both to have your [WordPress](https://wordpress.org) installed on it. While you can follow basic steps to install BedRock yourself on CleverCloud, here is a nice shortcut that you can just fork and deploy. +## About the Application -## How it works? +This project is based on Bedrock 1.30.0 with the following Clever Cloud-specific modifications: -Composer is a PHP dependency manager that allows you to manage your Wordpress install and plugins with improved dependency management and more reliable development than vanilla Wordpress. It's similar to putting Worpdress in its own subdirectory, but with easier configuration. Isolated web root enhances security by limiting access to non-web files, while vanilla WordPress structure the whole configuration on the same root. +- `config/application.php` — maps Clever Cloud's `MYSQL_ADDON_*` and `CELLAR_ADDON_*` environment variables +- `composer.json` — includes `humanmade/s3-uploads` for S3 media storage and `wpackagist-plugin/mailgun` for email delivery +- `web/app/mu-plugins/s3-uploads-filter.php` — configures a Cellar endpoint instead of AWS +- `web/.htaccess` — included and tracked (Bedrock gitignores it by default) +- `clevercloud/php.json` — sets the webroot to `/web` +- `setup-cellar.sh` — creates the S3 bucket on Cellar (used as a post-build hook) -### Bedrock's structure +## Technology Stack +- [WordPress](https://wordpress.org/) 6.9 — Content management system +- [Bedrock](https://roots.io/bedrock/) 1.30 — Modern WordPress boilerplate +- [Composer](https://getcomposer.org/) — Dependency manager for PHP +- [Cellar](https://www.clever-cloud.com/product/cellar-s3/) — S3-compatible object storage for media files + +## Prerequisites + +- PHP 8.3+ +- Composer +- A Clever Cloud account + +## Running the Application Locally + +```bash +# Install dependencies +composer install + +# Copy and edit the environment file +cp .env.example .env + +# Start the local server +wp server ``` -site/ -├── config/ -│ ├── environments/ -│ │ ├── development.php -│ │ ├── staging.php -│ │ └── production.php -│ └── application.php # Primary wp-config.php -├── vendor/ # Composer dependencies -└── web/ # Virtual host document root - ├── app/ # WordPress content directory - │ ├── mu-plugins/ - │ ├── plugins/ - │ ├── themes/ - │ └── uploads/ - └── wp/ # WordPress core + +The application will be accessible at http://localhost:8080. + +## Deploying on Clever Cloud + +You have two options to deploy your WordPress application on Clever Cloud: using the Web Console or using the Clever Tools CLI. + +### Option 1: Deploy using the Web Console + +#### 1. Create an account on Clever Cloud + +If you don't already have an account, go to the [Clever Cloud console](https://console.clever-cloud.com/) and follow the registration instructions. + +#### 2. Set up your application on Clever Cloud + +1. Log in to the [Clever Cloud console](https://console.clever-cloud.com/) +2. Click on "Create" and select "An application" +3. Select this project (or a fork of it) as the source +4. Choose "PHP" as the runtime environment +5. Configure your application settings (name, region, etc.) + +#### 3. Add a MySQL Database Add-on + +1. In your application settings, go to "Service dependencies" +2. Add a **MySQL** add-on and link it to your application + +The `MYSQL_ADDON_*` environment variables will be automatically injected. + +#### 4. Configure Environment Variables + +Add the following environment variables in the Clever Cloud console (expert mode): + +| Variable | Value | Description | +|----------|-------|-------------| +| `WP_ENV` | `production` | WordPress environment | +| `WP_HOME` | `https://your-domain.tld` | Your site URL | +| `WP_SITEURL` | `https://your-domain.tld/wp` | WordPress core URL | +| `AUTH_KEY` | *(generated)* | Authentication salts — generate all 8 keys at https://cdn.roots.io/salts.html | +| `SECURE_AUTH_KEY` | *(generated)* | | +| `LOGGED_IN_KEY` | *(generated)* | | +| `NONCE_KEY` | *(generated)* | | +| `AUTH_SALT` | *(generated)* | | +| `SECURE_AUTH_SALT` | *(generated)* | | +| `LOGGED_IN_SALT` | *(generated)* | | +| `NONCE_SALT` | *(generated)* | | + +#### 5. Set up Cellar S3 Storage (for media files) + +1. Create a **Cellar S3 storage** add-on and link it to your application +2. In the Cellar add-on dashboard, click on **"Create a bucket"** and give it a name +3. Add the environment variable `CELLAR_ADDON_BUCKET` with the name of your bucket +4. Restart your application to apply changes + +#### 6. Deploy Your Application + +You can deploy your application using Git: + +```bash +# Add Clever Cloud as a remote repository +git remote add clever git+ssh://git@push-par-clevercloud-customers.services.clever-cloud.com/app_.git + +# Push your code to deploy +git push clever master ``` -## Status +#### 7. Finish WordPress Installation + +1. Set up your domain name as configured for `WP_HOME` (or use `*.cleverapps.io` for testing) +2. Access the WordPress installation page at your domain +3. After installation, go to the plugins page and activate **S3 Uploads** -This repository has been tested and successfully deployed with Clever Cloud. We will keep adding features and updating the project to fit our customers' needs. +### Option 2: Deploy using Clever Tools CLI -## Instructions +#### 1. Install Clever Tools -Let's build your modern Wordpress. +Install the Clever Tools CLI following the [official documentation](https://www.clever-cloud.com/doc/clever-tools/getting_started/): -### Requirements +```bash +# Using npm +npm install -g clever-tools -None. Except a CleverCloud account ;-) +# Or using Homebrew (macOS) +brew install clever-tools +``` -### Initial deployment +#### 2. Log in to your Clever Cloud account -It will assume your GitHub account is linked to your CleverCloud account. If not, you'll just have to do the same steps but cloning and pushing the project yourself to CleverCloud. +```bash +clever login +``` + +#### 3. Create and configure the application + +```bash +# Create a PHP application +clever create --type php + +# Add a MySQL add-on +clever addon create mysql-addon --link + +# Add a Cellar S3 add-on +clever addon create cellar-addon --link + +# Add your domain (optional) +clever domain add + +# Set required environment variables +clever env set WP_ENV production +clever env set WP_HOME "https://$(clever domain | tr -d ' ')" +clever env set WP_SITEURL "https://$(clever domain | tr -d ' ')wp" + + + +# Please remember S3 bucket names are unique +# To avoid conflicts, simply use your app id as bucket name +clever env set CELLAR_ADDON_BUCKET $(clever applications -j | jq -r '.[0].app_id' | tr '_' '-') + +# Load env variables +eval "$(clever env -F shell)" + +# Create the Cellar bucket on first deploy +./setup-cellar.sh + +# Set authentication salts (generate at https://cdn.roots.io/salts.html) +clever env set AUTH_KEY "your-generated-key" +clever env set SECURE_AUTH_KEY "your-generated-key" +clever env set LOGGED_IN_KEY "your-generated-key" +clever env set NONCE_KEY "your-generated-key" +clever env set AUTH_SALT "your-generated-salt" +clever env set SECURE_AUTH_SALT "your-generated-salt" +clever env set LOGGED_IN_SALT "your-generated-salt" +clever env set NONCE_SALT "your-generated-salt" + +``` + +#### 4. Deploy your application + +```bash +clever deploy +``` + +#### 5. Open your application in a browser + +Once deployed, access your site at `https:///` and complete the WordPress installation. + +## Sending Emails + +By default, this WordPress installation cannot send emails. You can either: + +- Follow [Clever Cloud's SMTP documentation](https://www.clever-cloud.com/doc/php/php-apps/#sending-emails) to configure your SMTP server +- Activate and configure the **Mailgun** plugin (installed by default) + +## Installing Themes and Plugins + +Themes and plugins are managed via Composer and [WordPress Packagist](https://wpackagist.org). To install a new plugin or theme, add it to `composer.json` and commit: + +```bash +composer require wpackagist-plugin/plugin-name +git add composer.json composer.lock +git commit -m "Add plugin-name" +git push clever master +``` -1. Fork this magnificent repository -2. Log in to your CleverCloud console -3. Create a new application, by selecting this project fork, and obviously as a *PHP* one -4. Add one *MySQL database* add-on -5. On next page, edit the environment variables in expert mode and paste one env salts generated [here](https://cdn.roots.io/salts.html). Don't forget to save the changes. -6. Add 4 more variables : `WP_ENV` with value `production` ; `WP_HOME` with value `https://your-domain.tld` ; `WP_SITEURL` with value `https://your-domain.tld/wp` ; `CC_PHP_VERSION` with value `8`. -7. While your app start, create a *Cellar S3 storage* add-on, and link it to your application -8. On the add-on configuration page, create one bucket -9. Go back in your application configuration and add the environment variable `CELLAR_ADDON_BUCKET` with the name of your bucket -10. Apply changes by restarting your application -11. Don't forget to set up your domain name as configured for `WP_HOME` (or one `*.cleverapps.io` for testing purpose) -12. You'll then have access to the installation page of WordPress -13. After installed, go to your plugins home page and active `S3 Uploads` +> **Note:** Pay attention to how you define your [dependencies with Composer](https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies). The stricter way is to locally run `composer update` and commit your `composer.lock` file. -**Important note :** At this time, your WordPress installation is not capable of sending any emails. Follow [CleverCloud's documentation](https://www.clever-cloud.com/doc/php/php-apps/#sending-emails) to configure your SMTP server, of activate and configure the `Mailgun` plugin installed by default. +## Keeping WordPress Updated -### Installing themes and plugins +WordPress updates are handled through Composer. Update the version in `composer.json`, run `composer update`, commit, and deploy. If a database migration is needed, WordPress will prompt you when logged in as administrator. -Your WordPress installation is now fully managed by *composer* and [WordPress Packagist](https://wpackagist.org). So to install themes or plugins, you'll have to add them to the `composer.json` file, and commit. The dependencies will be fetched by *composer* during CleverCloud rebuild of your project. +## Monitoring Your Application -**Important note :** Pay attention to how you define your [dependencies with composer](https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies), being strict, or having them automatically update if needed when it rebuilds. The stricter way would even be to locally `composer update` your project and commit your own `composer.lock` file. +Once deployed, you can monitor your application through: -### Keeping WP updated +- **Web Console**: The Clever Cloud console provides logs, metrics, and other tools to help you manage your application. +- **CLI**: Use `clever logs` to view application logs and `clever status` to check the status of your application. -As for themes and plugins, keeping WordPress updated must be done by the dependencies way. That means you'll have to change the WordPress version in your `composer.json` file and commit. Once restarted, if you are connected as administrator, a page will propose you to do the database update, if any. +## Differences with Bedrock -### Differences with Bedrock +This project is based on [Bedrock 1.30.0](https://github.com/roots/bedrock/releases/tag/1.30.0) with the following changes: -For those who want or need to go deeper regarding Bedrock, here are the small differences between this fork (based on version **1.12.8**) and a standard Bedrock install. +- `config/application.php` uses Clever Cloud's `MYSQL_ADDON_*` variables for database configuration and `CELLAR_ADDON_*` variables for S3 storage +- `composer.json` includes `humanmade/s3-uploads` and `wpackagist-plugin/mailgun` as additional dependencies, and the wpackagist.org repository +- `web/app/mu-plugins/s3-uploads-filter.php` configures the S3 client to use a Cellar endpoint +- `web/.htaccess` is tracked in the repository (Bedrock gitignores it by default) +- `clevercloud/php.json` configures the webroot for Clever Cloud's build system +- `setup-cellar.sh` creates the S3 bucket on Cellar via `s3cmd` (can be used as `CC_POST_BUILD_HOOK`) -- You don't need any `.env` file for your environment variables, it can be useful if you want to run your WordPress locally -- `config/application.php` has been modified to directly use MySQL and Cellar environment variables shared by CleverCloud -- Plugin `humanmade/s3-uploads` added by default to use S3 storage for media files -- `web/app/mu-plugins/s3-uploads-filter.php` have been added to use a Cellar endpoint in place of an AWS one -- `.htaccess` have been included by default +## Additional Resources -Enjoy ! +- [Bedrock Documentation](https://roots.io/bedrock/docs/) +- [WordPress Documentation](https://developer.wordpress.org/) +- [Composer Documentation](https://getcomposer.org/doc/) +- [Clever Cloud PHP Documentation](https://www.clever-cloud.com/developers/doc/applications/php/) +- [Clever Cloud Cellar Documentation](https://www.clever-cloud.com/developers/doc/addons/cellar/) diff --git a/composer.json b/composer.json index 3bbe1bffc..b4b557f2f 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "roots/bedrock", "type": "project", "license": "MIT", - "description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure", + "description": "WordPress boilerplate with Composer, easier configuration, and an improved folder structure", "homepage": "https://roots.io/bedrock/", "authors": [ { @@ -17,60 +17,73 @@ } ], "keywords": [ - "bedrock", "composer", "roots", "wordpress", "wp", "wp-config" + "bedrock", "composer", "roots", "wordpress-composer", "wordpress", "wp-composer", "wp-config", "wp" ], "support": { "issues": "https://github.com/roots/bedrock/issues", "forum": "https://discourse.roots.io/category/bedrock" }, "repositories": [ + { + "name": "wp-composer", + "type": "composer", + "url": "https://repo.wp-composer.com", + "only": [ + "wp-plugin/*", + "wp-theme/*" + ] + }, { "type": "composer", "url": "https://wpackagist.org" } ], "require": { - "php": ">=7.1", + "php": ">=8.3", "composer/installers": "^2.2", - "vlucas/phpdotenv": "^5.6.0", - "oscarotero/env": "^2.1.0", - "roots/wordpress": "6.8", + "humanmade/s3-uploads": "^3.0", + "oscarotero/env": "^2.1", + "roots/bedrock-autoloader": "^1.0", + "roots/bedrock-disallow-indexing": "^2.0", + "roots/wordpress": "6.9.4", "roots/wp-config": "1.0.0", - "roots/wp-password-bcrypt": "1.2.0", - "wp-cli/wp-cli-bundle": "2.11.*", - "humanmade/s3-uploads": "~3.0", - "wpackagist-plugin/mailgun": "2.1.7", - "wpackagist-theme/twentytwentytwo":"^1.2" + "vlucas/phpdotenv": "^5.5", + "wpackagist-plugin/mailgun": "^1.9", + "wp-theme/twentytwentyfive": "^1.0" }, "require-dev": { - "squizlabs/php_codesniffer": "^3.4.2", - "roave/security-advisories": "dev-master" + "laravel/pint": "^1.27", + "pestphp/pest": "^4.0" }, "config": { "optimize-autoloader": true, "preferred-install": "dist", - "sort-packages": true, "allow-plugins": { - "composer/installers":true, - "roots/wordpress-core-installer":true - } + "composer/installers": true, + "roots/wordpress-core-installer": true, + "pestphp/pest-plugin": true + }, + "sort-packages": true }, "minimum-stability": "dev", "prefer-stable": true, "extra": { "installer-paths": { - "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"], - "web/app/plugins/{$name}/": ["type:wordpress-plugin"], - "web/app/themes/{$name}/": ["type:wordpress-theme"] + "web/app/mu-plugins/{$name}/": [ + "type:wordpress-muplugin" + ], + "web/app/plugins/{$name}/": [ + "type:wordpress-plugin" + ], + "web/app/themes/{$name}/": [ + "type:wordpress-theme" + ] }, "wordpress-install-dir": "web/wp" }, "scripts": { - "post-root-package-install": [ - "php -r \"copy('.env.example', '.env');\"" - ], - "test": [ - "phpcs" - ] + "lint": "pint --test", + "lint:fix": "pint", + "test": "pest" } } diff --git a/config/application.php b/config/application.php index 6e99b0fab..0ccbd9a0d 100644 --- a/config/application.php +++ b/config/application.php @@ -1,4 +1,5 @@ addAdapter(Dotenv\Repository\Adapter\EnvConstAdapter::class) + ->addAdapter(Dotenv\Repository\Adapter\PutenvAdapter::class) + ->immutable() + ->make(); + + $dotenv = Dotenv\Dotenv::create($repository, $root_dir, $env_files, false); $dotenv->load(); + $dotenv->required(['WP_HOME', 'WP_SITEURL']); if (!env('DATABASE_URL')) { $dotenv->required(['DB_NAME', 'DB_USER', 'DB_PASSWORD']); @@ -40,6 +65,30 @@ */ define('WP_ENV', env('WP_ENV') ?: 'production'); +/** + * Set WP_ENVIRONMENT_TYPE if not already defined + */ +if (!defined('WP_ENVIRONMENT_TYPE')) { + $wp_environment_type = env('WP_ENVIRONMENT_TYPE'); + + if ($wp_environment_type) { + Config::define('WP_ENVIRONMENT_TYPE', $wp_environment_type); + } elseif (in_array(WP_ENV, ['production', 'staging', 'development', 'local'], true)) { + Config::define('WP_ENVIRONMENT_TYPE', WP_ENV); + } +} + +/** + * Set WP_DEVELOPMENT_MODE if explicitly configured + */ +if (!defined('WP_DEVELOPMENT_MODE')) { + $wp_development_mode = env('WP_DEVELOPMENT_MODE'); + + if ($wp_development_mode) { + Config::define('WP_DEVELOPMENT_MODE', $wp_development_mode); + } +} + /** * URLs */ @@ -55,11 +104,18 @@ /** * DB settings + * + * On Clever Cloud, database credentials are provided via MYSQL_ADDON_* environment variables. + * These are mapped here instead of the default DB_* variables. */ -Config::define('DB_NAME', env('MYSQL_ADDON_DB')); -Config::define('DB_USER', env('MYSQL_ADDON_USER')); -Config::define('DB_PASSWORD', env('MYSQL_ADDON_PASSWORD')); -Config::define('DB_HOST', env('MYSQL_ADDON_HOST') . ":" . env('MYSQL_ADDON_PORT')); +if (env('DB_SSL')) { + Config::define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL); +} + +Config::define('DB_NAME', env('MYSQL_ADDON_DB') ?: env('DB_NAME')); +Config::define('DB_USER', env('MYSQL_ADDON_USER') ?: env('DB_USER')); +Config::define('DB_PASSWORD', env('MYSQL_ADDON_PASSWORD') ?: env('DB_PASSWORD')); +Config::define('DB_HOST', env('MYSQL_ADDON_HOST') ? env('MYSQL_ADDON_HOST') . ':' . env('MYSQL_ADDON_PORT') : (env('DB_HOST') ?: 'localhost')); Config::define('DB_CHARSET', 'utf8mb4'); Config::define('DB_COLLATE', ''); $table_prefix = env('DB_PREFIX') ?: 'wp_'; @@ -90,25 +146,36 @@ */ Config::define('AUTOMATIC_UPDATER_DISABLED', true); Config::define('DISABLE_WP_CRON', env('DISABLE_WP_CRON') ?: false); + // Disable the plugin and theme file editor in the admin Config::define('DISALLOW_FILE_EDIT', true); + // Disable plugin and theme updates and installation from the admin Config::define('DISALLOW_FILE_MODS', true); +// Limit the number of post revisions +Config::define('WP_POST_REVISIONS', env('WP_POST_REVISIONS') ?? true); + +// Disable script concatenation +Config::define('CONCATENATE_SCRIPTS', false); + /** - * S3 Uploads Settings + * S3 Uploads Settings (Cellar S3 storage on Clever Cloud) */ -define('S3_UPLOADS_BUCKET', env('CELLAR_ADDON_BUCKET')); -define('S3_UPLOADS_KEY', env('CELLAR_ADDON_KEY_ID')); -define('S3_UPLOADS_SECRET', env('CELLAR_ADDON_KEY_SECRET')); -define('S3_UPLOADS_REGION', 'Cellar'); -define('S3_UPLOADS_BUCKET_URL', 'https://' . env('CELLAR_ADDON_BUCKET') . '.' . env('CELLAR_ADDON_HOST')); -define('S3_UPLOADS_ENDPOINT', 'https://' . env('CELLAR_ADDON_HOST')); +if (env('CELLAR_ADDON_BUCKET')) { + define('S3_UPLOADS_BUCKET', env('CELLAR_ADDON_BUCKET')); + define('S3_UPLOADS_KEY', env('CELLAR_ADDON_KEY_ID')); + define('S3_UPLOADS_SECRET', env('CELLAR_ADDON_KEY_SECRET')); + define('S3_UPLOADS_REGION', 'Cellar'); + define('S3_UPLOADS_BUCKET_URL', 'https://' . env('CELLAR_ADDON_BUCKET') . '.' . env('CELLAR_ADDON_HOST')); + define('S3_UPLOADS_ENDPOINT', 'https://' . env('CELLAR_ADDON_HOST')); +} /** * Debugging Settings */ Config::define('WP_DEBUG_DISPLAY', false); +Config::define('WP_DEBUG_LOG', false); Config::define('SCRIPT_DEBUG', false); ini_set('display_errors', '0'); diff --git a/config/environments/development.php b/config/environments/development.php index 90077657a..94026ac6f 100644 --- a/config/environments/development.php +++ b/config/environments/development.php @@ -1,15 +1,20 @@ - - Roots Coding Standards - - - . - - - - - - web/wp - vendor/ - - - - - - - - - - diff --git a/setup-cellar.sh b/setup-cellar.sh new file mode 100755 index 000000000..7900dba11 --- /dev/null +++ b/setup-cellar.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Create the S3 bucket on Cellar + +pip install s3cmd + +cat > .s3cfg << EOF +[default] +access_key = $CELLAR_ADDON_KEY_ID +secret_key = $CELLAR_ADDON_KEY_SECRET +host_base = $CELLAR_ADDON_HOST +host_bucket = $CELLAR_ADDON_HOST +use_https = True +EOF + +s3cmd mb s3://$CELLAR_ADDON_BUCKET -c .s3cfg diff --git a/web/.htaccess b/web/.htaccess index fd77845f4..554aec318 100644 --- a/web/.htaccess +++ b/web/.htaccess @@ -1,15 +1,10 @@ # BEGIN WordPress -# The directives (lines) between "BEGIN WordPress" and "END WordPress" are -# dynamically generated, and should only be modified via WordPress filters. -# Any changes to the directives between these markers will be overwritten. RewriteEngine On -RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / -RewriteRule ^index\.php$ - [L] +RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] - -# END WordPress \ No newline at end of file +# END WordPress diff --git a/web/app/mu-plugins/bedrock-autoloader.php b/web/app/mu-plugins/bedrock-autoloader.php index 8e76483ba..023c5c908 100644 --- a/web/app/mu-plugins/bedrock-autoloader.php +++ b/web/app/mu-plugins/bedrock-autoloader.php @@ -1,199 +1,16 @@ relativePath = '/../' . basename(__DIR__); - - if (is_admin()) { - add_filter('show_advanced_plugins', [$this, 'showInAdmin'], 0, 2); - } - - $this->loadPlugins(); - } - - /** - * Run some checks then autoload our plugins. - */ - public function loadPlugins() - { - $this->checkCache(); - $this->validatePlugins(); - $this->countPlugins(); - - array_map(static function () { - include_once WPMU_PLUGIN_DIR . '/' . func_get_args()[0]; - }, array_keys($this->cache['plugins'])); - - $this->pluginHooks(); - } - /** - * Filter show_advanced_plugins to display the autoloaded plugins. - * @param $show bool Whether to show the advanced plugins for the specified plugin type. - * @param $type string The plugin type, i.e., `mustuse` or `dropins` - * @return bool We return `false` to prevent WordPress from overriding our work - * {@internal We add the plugin details ourselves, so we return false to disable the filter.} - */ - public function showInAdmin($show, $type) - { - $screen = get_current_screen(); - $current = is_multisite() ? 'plugins-network' : 'plugins'; - - if ($screen->base !== $current || $type !== 'mustuse' || !current_user_can('activate_plugins')) { - return $show; - } - - $this->updateCache(); - - $this->autoPlugins = array_map(function ($auto_plugin) { - $auto_plugin['Name'] .= ' *'; - return $auto_plugin; - }, $this->autoPlugins); - - $GLOBALS['plugins']['mustuse'] = array_unique(array_merge($this->autoPlugins, $this->muPlugins), SORT_REGULAR); - - return false; - } - - /** - * This sets the cache or calls for an update - */ - private function checkCache() - { - $cache = get_site_option('bedrock_autoloader'); - - if ($cache === false || (isset($cache['plugins'], $cache['count']) && count($cache['plugins']) !== $cache['count'])) { - $this->updateCache(); - return; - } - - $this->cache = $cache; - } - - /** - * Get the plugins and mu-plugins from the mu-plugin path and remove duplicates. - * Check cache against current plugins for newly activated plugins. - * After that, we can update the cache. - */ - private function updateCache() - { - require_once ABSPATH . 'wp-admin/includes/plugin.php'; - - $this->autoPlugins = get_plugins($this->relativePath); - $this->muPlugins = get_mu_plugins(); - $plugins = array_diff_key($this->autoPlugins, $this->muPlugins); - $rebuild = !is_array($this->cache['plugins']); - $this->activated = $rebuild ? $plugins : array_diff_key($plugins, $this->cache['plugins']); - $this->cache = ['plugins' => $plugins, 'count' => $this->countPlugins()]; - - update_site_option('bedrock_autoloader', $this->cache); - } - - /** - * This accounts for the plugin hooks that would run if the plugins were - * loaded as usual. Plugins are removed by deletion, so there's no way - * to deactivate or uninstall. - */ - private function pluginHooks() - { - if (!is_array($this->activated)) { - return; - } - - foreach ($this->activated as $plugin_file => $plugin_info) { - do_action('activate_' . $plugin_file); - } - } - - /** - * Check that the plugin file exists, if it doesn't update the cache. - */ - private function validatePlugins() - { - foreach ($this->cache['plugins'] as $plugin_file => $plugin_info) { - if (!file_exists(WPMU_PLUGIN_DIR . '/' . $plugin_file)) { - $this->updateCache(); - break; - } - } - } - - /** - * Count the number of autoloaded plugins. - * - * Count our plugins (but only once) by counting the top level folders in the - * mu-plugins dir. If it's more or less than last time, update the cache. - * - * @return int Number of autoloaded plugins. - */ - private function countPlugins() - { - if (isset($this->count)) { - return $this->count; - } - - $count = count(glob(WPMU_PLUGIN_DIR . '/*/', GLOB_ONLYDIR | GLOB_NOSORT)); - - if (!isset($this->cache['count']) || $count !== $this->cache['count']) { - $this->count = $count; - $this->updateCache(); - } +namespace Roots\Bedrock; - return $this->count; - } +if (is_blog_installed() && class_exists(Autoloader::class)) { + new Autoloader(); } - -new Autoloader(); diff --git a/web/app/mu-plugins/disallow-indexing.php b/web/app/mu-plugins/disallow-indexing.php deleted file mode 100644 index dcfe319ca..000000000 --- a/web/app/mu-plugins/disallow-indexing.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Mon, 10 Aug 2026 10:02:54 +0200 Subject: [PATCH 2/2] Fix formatting in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 062139b16..91c0ed155 100644 --- a/composer.json +++ b/composer.json @@ -66,7 +66,7 @@ }, "require-dev": { "laravel/pint": "^1.27", - "pestphp/pest": "^4.0" + "pestphp/pest": "^4.0", "vlucas/phpdotenv": "^5.6.0", "oscarotero/env": "^2.1.0", "roots/wordpress": "7.0.2",