├── public ├── favicon.ico ├── plugins │ └── index.php ├── themes │ ├── index.php │ └── wordplate │ │ ├── footer.php │ │ ├── screenshot.png │ │ ├── 404.php │ │ ├── style.css │ │ ├── header.php │ │ ├── index.php │ │ └── functions.php ├── index.php ├── .htaccess ├── mu-plugins │ └── mu-plugins.php └── wp-config.php ├── resources ├── static │ └── .gitkeep ├── js │ └── index.js └── css │ └── index.css ├── wp-cli.yml ├── .editorconfig ├── .gitignore ├── package.json ├── .env.example ├── src └── helpers.php ├── vite.config.js ├── composer.json └── README.md /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/js/index.js: -------------------------------------------------------------------------------- 1 | import '../css/index.css'; 2 | -------------------------------------------------------------------------------- /public/plugins/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /wp-cli.yml: -------------------------------------------------------------------------------- 1 | path: public/wordpress 2 | server: 3 | docroot: public 4 | require: 5 | - vendor/autoload.php 6 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |

404

5 |
6 | 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.php] 12 | indent_size = 4 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | # BEGIN WordPress 2 | 3 | RewriteEngine On 4 | RewriteBase / 5 | RewriteRule ^index\.php$ - [L] 6 | RewriteCond %{REQUEST_FILENAME} !-f 7 | RewriteCond %{REQUEST_FILENAME} !-d 8 | RewriteRule . /index.php [L] 9 | 10 | # END WordPress 11 | -------------------------------------------------------------------------------- /public/themes/wordplate/style.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Theme Name: WordPlate 3 | * Theme URI: https://github.com/vinkla/wordplate 4 | * Description: WordPress theme built with WordPlate. 5 | * Version: 1.0.0 6 | * Author: WordPlate 7 | * Author URI: https://github.com/vinkla/wordplate 8 | */ 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | .env 4 | /auth.json 5 | /node_modules 6 | /public/cache 7 | /public/languages 8 | /public/mu-plugins/* 9 | !/public/mu-plugins/mu-plugins.php 10 | /public/plugins/* 11 | !/public/plugins/index.php 12 | /public/themes/*/assets 13 | /public/upgrade 14 | /public/uploads 15 | /public/wordpress 16 | /vendor 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/package.json", 3 | "type": "module", 4 | "scripts": { 5 | "build": "vite build", 6 | "dev": "vite" 7 | }, 8 | "dependencies": { 9 | "@tailwindcss/vite": "^4.1.18", 10 | "dotenv": "^17.2.3", 11 | "tailwindcss": "^4.1.18", 12 | "vite": "^7.3.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /public/themes/wordplate/header.php: -------------------------------------------------------------------------------- 1 | 2 | > 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | > 12 | 13 |
14 | 17 |
-------------------------------------------------------------------------------- /public/mu-plugins/mu-plugins.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 |
7 |

8 |
9 | 10 | 11 |
12 | 13 | 14 |
15 |

Nothing to see.

16 |
17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /src/helpers.php: -------------------------------------------------------------------------------- 1 | safeLoad(); 12 | 13 | // Set the environment type. 14 | define('WP_ENVIRONMENT_TYPE', env('WP_ENVIRONMENT_TYPE', 'production')); 15 | 16 | // Set the default WordPress theme. 17 | define('WP_DEFAULT_THEME', env('WP_DEFAULT_THEME', 'wordplate')); 18 | 19 | // For developers: WordPress debugging mode. 20 | $isDebugModeEnabled = env('WP_DEBUG', false); 21 | define('WP_DEBUG', $isDebugModeEnabled); 22 | define('WP_DEBUG_LOG', env('WP_DEBUG_LOG', false)); 23 | define('WP_DEBUG_DISPLAY', env('WP_DEBUG_DISPLAY', $isDebugModeEnabled)); 24 | define('SCRIPT_DEBUG', env('SCRIPT_DEBUG', $isDebugModeEnabled)); 25 | 26 | // Database configuration with name, username, password, hostname, charset, and collation. 27 | define('DB_NAME', env('DB_NAME')); 28 | define('DB_USER', env('DB_USER')); 29 | define('DB_PASSWORD', env('DB_PASSWORD')); 30 | define('DB_HOST', env('DB_HOST', '127.0.0.1')); 31 | define('DB_CHARSET', env('DB_CHARSET', 'utf8mb4')); 32 | define('DB_COLLATE', env('DB_COLLATE', 'utf8mb4_unicode_ci')); 33 | 34 | // Set the unique authentication keys and salts. 35 | define('AUTH_KEY', env('AUTH_KEY')); 36 | define('SECURE_AUTH_KEY', env('SECURE_AUTH_KEY')); 37 | define('LOGGED_IN_KEY', env('LOGGED_IN_KEY')); 38 | define('NONCE_KEY', env('NONCE_KEY')); 39 | define('AUTH_SALT', env('AUTH_SALT')); 40 | define('SECURE_AUTH_SALT', env('SECURE_AUTH_SALT')); 41 | define('LOGGED_IN_SALT', env('LOGGED_IN_SALT')); 42 | define('NONCE_SALT', env('NONCE_SALT')); 43 | 44 | // Detect HTTPS behind a reverse proxy or a load balancer. 45 | if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { 46 | $_SERVER['HTTPS'] = 'on'; 47 | } 48 | 49 | // Set the home URL to the current domain. 50 | define('WP_HOME', env('WP_HOME', Request::createFromGlobals()->getSchemeAndHttpHost())); 51 | 52 | // Set the WordPress directory path. 53 | define('WP_SITEURL', env('WP_SITEURL', sprintf('%s/%s', WP_HOME, env('WP_DIR', 'wordpress')))); 54 | 55 | // Set the WordPress content directory path and URL. 56 | define('WP_CONTENT_DIR', env('WP_CONTENT_DIR', __DIR__)); 57 | define('WP_CONTENT_URL', env('WP_CONTENT_URL', WP_HOME)); 58 | 59 | // Disable WordPress automatic updates. 60 | define('AUTOMATIC_UPDATER_DISABLED', env('AUTOMATIC_UPDATER_DISABLED', true)); 61 | 62 | // Disable WP-Cron for better performance. 63 | define('DISABLE_WP_CRON', env('DISABLE_WP_CRON', false)); 64 | 65 | // Prevent file editing from the dashboard. 66 | define('DISALLOW_FILE_EDIT', env('DISALLOW_FILE_EDIT', true)); 67 | 68 | // Disable plugin and theme updates and installation from the dashboard. 69 | define('DISALLOW_FILE_MODS', env('DISALLOW_FILE_MODS', true)); 70 | 71 | // Clean up WordPress image edits. 72 | define('IMAGE_EDIT_OVERWRITE', env('IMAGE_EDIT_OVERWRITE', true)); 73 | 74 | // Disable fatal error handler emails. 75 | define('WP_DISABLE_FATAL_ERROR_HANDLER', env('WP_DISABLE_FATAL_ERROR_HANDLER', false)); 76 | 77 | // Limit the number of post revisions. 78 | define('WP_POST_REVISIONS', env('WP_POST_REVISIONS', 2)); 79 | 80 | // Set the absolute path to the WordPress directory. 81 | if (!defined('ABSPATH')) { 82 | define('ABSPATH', sprintf('%s/%s/', __DIR__, env('WP_DIR', 'wordpress'))); 83 | } 84 | 85 | // Set the database table prefix. 86 | $table_prefix = env('DB_TABLE_PREFIX', 'wp_'); 87 | 88 | require_once ABSPATH . 'wp-settings.php'; 89 | -------------------------------------------------------------------------------- /public/themes/wordplate/functions.php: -------------------------------------------------------------------------------- 1 | __('Navigation'), 15 | ]); 16 | }); 17 | 18 | // Register scripts and styles. 19 | add_action('wp_enqueue_scripts', function () { 20 | $manifestPath = get_theme_file_path('assets/.vite/manifest.json'); 21 | 22 | if ( 23 | wp_get_environment_type() === 'local' 24 | && is_array(wp_remote_get('http://localhost:5173/')) // is Vite.js running 25 | ) { 26 | wp_enqueue_script_module('vite', 'http://localhost:5173/@vite/client'); 27 | wp_enqueue_script_module('wordplate', 'http://localhost:5173/resources/js/index.js', ['vite']); 28 | } elseif (file_exists($manifestPath)) { 29 | $manifest = json_decode(file_get_contents($manifestPath), true); 30 | wp_enqueue_script_module('wordplate', get_theme_file_uri('assets/' . $manifest['resources/js/index.js']['file'])); 31 | wp_enqueue_style('wordplate', get_theme_file_uri('assets/' . $manifest['resources/js/index.js']['css'][0])); 32 | } 33 | }); 34 | 35 | // Remove admin menu items. 36 | add_action('admin_init', function () { 37 | remove_menu_page('edit-comments.php'); // Comments 38 | // remove_menu_page('edit.php?post_type=page'); // Pages 39 | remove_menu_page('edit.php'); // Posts 40 | remove_menu_page('index.php'); // Dashboard 41 | // remove_menu_page('upload.php'); // Media 42 | }); 43 | 44 | // Remove admin toolbar menu items. 45 | add_action('admin_bar_menu', function (WP_Admin_Bar $menu) { 46 | $menu->remove_node('archive'); // Archive 47 | $menu->remove_node('comments'); // Comments 48 | $menu->remove_node('customize'); // Customize 49 | $menu->remove_node('dashboard'); // Dashboard 50 | $menu->remove_node('edit'); // Edit 51 | $menu->remove_node('menus'); // Menus 52 | $menu->remove_node('new-content'); // New Content 53 | $menu->remove_node('search'); // Search 54 | // $menu->remove_node('site-name'); // Site Name 55 | $menu->remove_node('themes'); // Themes 56 | $menu->remove_node('updates'); // Updates 57 | $menu->remove_node('view-site'); // Visit Site 58 | $menu->remove_node('view'); // View 59 | $menu->remove_node('widgets'); // Widgets 60 | $menu->remove_node('wp-logo'); // WordPress Logo 61 | }, 999); 62 | 63 | // Remove admin dashboard widgets. 64 | add_action('wp_dashboard_setup', function () { 65 | remove_meta_box('dashboard_activity', 'dashboard', 'normal'); // Activity 66 | // remove_meta_box('dashboard_right_now', 'dashboard', 'normal'); // At a Glance 67 | remove_meta_box('dashboard_site_health', 'dashboard', 'normal'); // Site Health Status 68 | remove_meta_box('dashboard_primary', 'dashboard', 'side'); // WordPress Events and News 69 | remove_meta_box('dashboard_quick_press', 'dashboard', 'side'); // Quick Draft 70 | }); 71 | 72 | // Add custom login form logo. 73 | add_action('login_head', function () { 74 | $url = get_theme_file_uri('favicon.svg'); 75 | 76 | $styles = [ 77 | sprintf('background-image: url(%s)', $url), 78 | 'width: 200px', 79 | 'background-position: center', 80 | 'background-size: contain', 81 | ]; 82 | 83 | printf( 84 | '', 85 | implode(';', $styles), 86 | ); 87 | }); 88 | 89 | // Register custom SMTP credentials. 90 | add_action('phpmailer_init', function (PHPMailer $mailer) { 91 | $mailer->isSMTP(); 92 | $mailer->SMTPAutoTLS = false; 93 | $mailer->SMTPAuth = env('MAIL_USERNAME') && env('MAIL_PASSWORD'); 94 | $mailer->SMTPDebug = env('WP_DEBUG') ? SMTP::DEBUG_SERVER : SMTP::DEBUG_OFF; 95 | $mailer->SMTPSecure = env('MAIL_ENCRYPTION', 'tls'); 96 | $mailer->Debugoutput = 'error_log'; 97 | $mailer->Host = env('MAIL_HOST'); 98 | $mailer->Port = env('MAIL_PORT', 587); 99 | $mailer->Username = env('MAIL_USERNAME'); 100 | $mailer->Password = env('MAIL_PASSWORD'); 101 | return $mailer; 102 | }); 103 | 104 | add_filter('wp_mail_from', fn() => env('MAIL_FROM_ADDRESS', 'hello@example.com')); 105 | add_filter('wp_mail_from_name', fn() => env('MAIL_FROM_NAME', 'Example')); 106 | 107 | // Update permalink structure. 108 | add_action('after_setup_theme', function () { 109 | if (get_option('permalink_structure') !== '/%postname%/') { 110 | update_option('permalink_structure', '/%postname%/'); 111 | flush_rewrite_rules(); 112 | } 113 | }); 114 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![WordPlate](https://github.com/vinkla/wordplate/assets/499192/a6194bed-09c0-418e-8281-2541922aa5f0) 2 | 3 | # WordPlate 4 | 5 | WordPlate is a boilerplate for WordPress, built with Composer and designed with sensible defaults. 6 | 7 | [![Build Status](https://img.shields.io/github/actions/workflow/status/vinkla/wordplate/php-cs-fixer.yml?label=tests&logo)](https://github.com/vinkla/wordplate/actions) 8 | [![Monthly Downloads](https://img.shields.io/packagist/dm/vinkla/wordplate)](https://packagist.org/packages/vinkla/wordplate/stats) 9 | [![Latest Version](https://img.shields.io/packagist/v/vinkla/wordplate)](https://packagist.org/packages/vinkla/wordplate) 10 | 11 | - [Features](#features) 12 | - [Installation](#installation) 13 | - [Configuration](#configuration) 14 | - [Public Directory](#public-directory) 15 | - [Environment Configuration](#environment-configuration) 16 | - [Salt Keys](#salt-keys) 17 | - [Plugins](#plugins) 18 | - [WordPress Packagist](#wordpress-packagist) 19 | - [Must Use Plugins](#must-use-plugins) 20 | - [Included Plugins](#included-plugins) 21 | - [Vite.js](#vitejs) 22 | - [Mail](#mail) 23 | - [FAQ](#faq) 24 | - [Upgrade Guide](#upgrade-guide) 25 | - [Acknowledgements](#acknowledgements) 26 | - [License](#license) 27 | 28 | ## Features 29 | 30 | - **WordPress + Composer = ❤️** 31 | 32 | WordPress can be installed and updated with ease using Composer. To update WordPress, simply run the command `composer update`. 33 | 34 | - **Environment Files** 35 | 36 | Similar to Laravel, WordPlate stores environment variables, such as database credentials, in an `.env` file. 37 | 38 | - **WordPress Packagist** 39 | 40 | WordPress Packagist enables the management of WordPress plugins and themes through Composer. 41 | 42 | - **Must-use plugins** 43 | 44 | Don't worry about clients deactivating plugins; [must-use plugins](https://developer.wordpress.org/advanced-administration/plugins/mu-plugins/) are enabled by default. 45 | 46 | - **Vite.js** 47 | 48 | Using Vite, you can rapidly set up and begin building and minifying your CSS and JavaScript. 49 | 50 | - **Tailwind CSS** 51 | 52 | Tailwind CSS is included by default, allowing you to quickly build custom designs. 53 | 54 | - **Debugging** 55 | 56 | Familiar debugging helper functions are integrated such as `dump()` and `dd()`. 57 | 58 | - **Clean UI** 59 | 60 | Enhance the WordPress dashboard and improves the [user experience](https://user-images.githubusercontent.com/499192/143415951-b01e9498-5f18-44dd-9d4b-51fb2d479a22.png) for clients. 61 | 62 | ## Installation 63 | 64 | Before using WordPlate, make sure you have PHP 8.4 and MySQL 8.0 installed on your computer. You'll also need to have Composer, a package manager for PHP, installed on your computer. 65 | 66 | To install WordPlate, open your terminal and enter the following command: 67 | 68 | ```sh 69 | composer create-project --prefer-dist vinkla/wordplate example-app 70 | ``` 71 | 72 | After installing WordPlate, you'll need to update the database credentials in the `.env` file. This file is located in the root directory of your project. Open the file and update the following lines with your database credentials: 73 | 74 | ```env 75 | DB_NAME=database 76 | DB_USER=username 77 | DB_PASSWORD=password 78 | ``` 79 | 80 | To run your WordPlate application, you may serve it using PHP's built-in web server. Open your terminal and navigate to the `public` directory of your project. Then, enter the following command: 81 | 82 | ```sh 83 | php -S 127.0.0.1:8000 -t public/ 84 | ``` 85 | 86 | Finally, open your web browser and visit the following URLs to view your WordPlate application: 87 | 88 | - [`http://127.0.0.1:8000/`](http://127.0.0.1:8000/) - Your website 89 | - [`http://127.0.0.1:8000/wordpress/wp-admin`](http://127.0.0.1:8000/wordpress/wp-admin) - The dashboard 90 | 91 | ## Configuration 92 | 93 | ### Public Directory 94 | 95 | After installing WordPlate, you'll need to configure your web server's document or web root to be the `public` directory. This is where the main entry point for your application, `index.php`, is located. 96 | 97 | By setting the `public` directory as your web server's document root, you ensure that all HTTP requests are routed through the front controller, which handles the requests and returns the appropriate responses. 98 | 99 | This configuration helps to improve the security and performance of your application by preventing direct access to files outside of the `public` directory. 100 | 101 | ### Environment Configuration 102 | 103 | WordPlate makes it easy to manage different configuration values based on the environment where your application is running. For example, you may need to use a different database locally than you do on your production server. 104 | 105 | To accomplish this, WordPlate uses the [`vlucas/phpdotenv`](https://github.com/vlucas/phpdotenv) PHP package. When you install WordPlate, a `.env.example` file is included in the root directory of your application. If you installed WordPlate via Composer, this file will automatically be renamed to `.env`. Otherwise, you should rename the file manually. 106 | 107 | It's important to note that your `.env` file should not be committed to your application's source control. This is because each developer or server using your application may require a different environment configuration. Additionally, committing your `.env` file to source control would be a security risk in the event that an intruder gains access to your repository, as any sensitive credentials would be exposed. 108 | 109 | To learn more about managing environment variables in WordPlate, you can refer to Laravel's documentation on the topic: 110 | 111 | - [Environment Variable Types](https://laravel.com/docs/12.x/configuration#environment-variable-types) 112 | - [Retrieving Environment Configuration](https://laravel.com/docs/12.x/configuration#retrieving-environment-configuration) 113 | 114 | ### Salt Keys 115 | 116 | It's important to add salt keys to your environment file. These keys are used to encrypt sensitive data, such as user sessions, and help to ensure the security of your application. 117 | 118 | If you don't set the salt keys, your user sessions and other encrypted data may be vulnerable to attacks. To make it easier to generate secure salt keys, we've created a [salt key generator](https://vinkla.github.io/salts/) that you can use. If you haven't already done so, copy the `.env.example` file to a new file named `.env`. Then visit the generator and copy the randomly generated keys to your `.env` file. 119 | 120 | ## Plugins 121 | 122 | ### WordPress Packagist 123 | 124 | WordPlate includes integration with [WordPress Packagist](https://wpackagist.org), a Composer repository that mirrors the WordPress plugin and theme directories. With this integration, you can install and manage plugins using Composer. 125 | 126 | To install a plugin, use `wpackagist-plugin` as the vendor name and the plugin slug as the package name. For example, to install the `clean-image-filenames` plugin, you would use the following command: 127 | 128 | ```bash 129 | composer require wpackagist-plugin/clean-image-filenames 130 | ``` 131 | 132 | The installed packages will be located in the `public/plugins` directory. 133 | 134 | Here's an example of what your `composer.json` file might look like: 135 | 136 | ```json 137 | "require": { 138 | "wpackagist-plugin/clean-image-filenames": "^1.5" 139 | } 140 | ``` 141 | 142 | For more information and examples, please visit the [WordPress Packagist website](https://wpackagist.org). 143 | 144 | ### Must Use Plugins 145 | 146 | [Must-use plugins](https://developer.wordpress.org/advanced-administration/plugins/mu-plugins/) (also known as mu-plugins) are a type of WordPress plugin that is installed in a special directory inside the content folder. These plugins are automatically enabled on all sites in the WordPress installation. 147 | 148 | To install plugins into the `mu-plugins` directory, add the plugin name to the `installer-paths` of your `composer.json` file: 149 | 150 | ```json 151 | "installer-paths": { 152 | "public/mu-plugins/{$name}": [ 153 | "type:wordpress-muplugin", 154 | "wpackagist-plugin/clean-image-filenames", 155 | ] 156 | } 157 | ``` 158 | 159 | To install the plugin, use `wpackagist-plugin` as the vendor name and the plugin slug as the package name: 160 | 161 | ```sh 162 | composer require wpackagist-plugin/clean-image-filenames 163 | ``` 164 | 165 | The plugin will be installed in the `public/mu-plugins` directory. 166 | 167 | For more information on the must-use plugin autoloader, please refer to the [Bedrock documentation](https://roots.io/bedrock/docs/mu-plugin-autoloader/). 168 | 169 | ### Included Plugins 170 | 171 | #### [Headache](https://github.com/vinkla/headache) 172 | 173 | An easy-to-swallow painkiller plugin for WordPress. The plugin removes a lot of default WordPress stuff you just can't wait to get rid of. It removes meta tags such as feeds, version numbers and emojis. 174 | 175 | - Disables XML-RPC and protects against user enumeration 176 | - Removes feeds, emoji scripts, oEmbed, and block styles 177 | - Disables attachment pages and randomizes media slugs 178 | - Prevents indexing on non-production environments 179 | 180 | #### [Clean Image Filenames](https://wordpress.org/plugins/clean-image-filenames/) 181 | 182 | The plugin automatically converts language accent characters in filenames when uploading to the media library. Characters are converted into browser and server friendly, non-accent characters. 183 | 184 | - `Räksmörgås.jpg` → `raksmorgas.jpg` 185 | - `Æblegrød_FTW!.gif` → `aeblegrod-ftw.gif` 186 | - `Château de Ferrières.png` → `chateau-de-ferrieres.png` 187 | 188 | ## Vite.js 189 | 190 | [Vite](https://vitejs.dev/) is a build tool that provides a faster and leaner development experience for modern web projects. It comes with sensible defaults and is highly extensible via its Plugin and JavaScript APIs with full typing support. 191 | 192 | ```sh 193 | # Start the dev server... 194 | npm run dev 195 | 196 | # Build for production... 197 | npm run build 198 | ``` 199 | 200 | [Learn more about Vite's backend integration.](https://vitejs.dev/guide/backend-integration.html) 201 | 202 | ## Mail 203 | 204 | To set up custom SMTP credentials for sending emails in your WordPlate application, you need to configure the required environment variables in your `.env` file. 205 | 206 | ```env 207 | MAIL_HOST=127.0.0.1 208 | MAIL_PORT=2525 209 | MAIL_USERNAME=null 210 | MAIL_PASSWORD=null 211 | MAIL_ENCRYPTION=null 212 | MAIL_FROM_ADDRESS="hello@example.com" 213 | MAIL_FROM_NAME="Example" 214 | ``` 215 | 216 | If you're using a local email service like Mailhog or Mailpit, you need to disable encryption by setting the `MAIL_ENCRYPTION` environment variable to `null`. 217 | 218 | ## FAQ 219 | 220 |
221 | Can I add WordPress constants to the environment file? 222 | 223 | This is possible by updating the `public/wp-config.php` file after the WordPlate application have been created. 224 | 225 | ```diff 226 | define('WP_DISABLE_FATAL_ERROR_HANDLER', env('WP_DISABLE_FATAL_ERROR_HANDLER', false)); 227 | 228 | +define('WP_ALLOW_MULTISITE', env('WP_ALLOW_MULTISITE', true)); 229 | ```` 230 | 231 | Then you may add the constant to the `.env` file. 232 | 233 | ```diff 234 | WP_DEFAULT_THEME=wordplate 235 | +WP_ALLOW_MULTISITE=true 236 | ```` 237 | 238 |
239 |
240 | Can I disable WP-Cron and set up a manual cron job? 241 | 242 | WordPlate allows you to disable the internal WordPress cron system via the `DISABLE_WP_CRON` environment variable: 243 | 244 | ```env 245 | DISABLE_WP_CRON=true 246 | ```` 247 | 248 | It is recommended to manually set a cron job if you enable this setting and disable the WordPress cron. You'll need to add the following in your crontab file: 249 | 250 | ```sh 251 | */5 * * * * curl https://exempel.se/wordpress/wp-cron.php 252 | ```` 253 | 254 |
255 |
256 | Can I install languages with Composer? 257 | 258 | If you want to install language packs using Composer, we recommend looking at the [WP Languages](https://wp-languages.github.io/) project. Below is an example of a `composer.json` file that installs the Swedish language pack for WordPress. 259 | 260 | ```json 261 | { 262 | "require": { 263 | "koodimonni-language/core-sv_se": "*", 264 | }, 265 | "repositories": [ 266 | { 267 | "type": "composer", 268 | "url": "https://wp-languages.github.io", 269 | "only": [ 270 | "koodimonni-language/*" 271 | ] 272 | } 273 | ], 274 | "config": { 275 | "allow-plugins": { 276 | "koodimonni/composer-dropin-installer": true 277 | }, 278 | }, 279 | "extra": { 280 | "dropin-paths": { 281 | "public/languages/": [ 282 | "vendor:koodimonni-language" 283 | ] 284 | } 285 | } 286 | } 287 | ``` 288 | 289 |
290 |
291 | Can I rename the public directory? 292 | 293 | Update your `.gitignore`, `composer.json`, `vite.config.js`, and `wp-cli.yml` files with the new path to the `public` directory. Then, run `composer update` in the root of your project. 294 |
295 |
296 | Can I rename the WordPress directory? 297 | 298 | By default WordPlate will put the WordPress in `public/wordpress`. If you want to change this there are a couple of steps you need to go through. Let's say you want to change the default WordPress location to `public/wp`: 299 | 300 | 1. Update the `wordpress-install-dir` path in your `composer.json` file. 301 | 302 | 1. Update `wordpress` to `wp` in `wordplate/public/.gitignore`. 303 | 304 | 1. Update the last line in the `public/index.php` file to: 305 | 306 | ```php 307 | require __DIR__.'/wp/wp-blog-header.php'; 308 | ``` 309 | 310 | 1. Update the `WP_DIR` environment variable in the `.env` file to `wp`. 311 | 312 | 1. If you're using WP-CLI, update the path in the `wp-cli.yml` file to `public/wp`. 313 | 314 | 1. Remove the `public/wordpress` directory if it exist and then run `composer update`. 315 |
316 |
317 | Can I rename the theme directory? 318 | 319 | For most applications you may leave the theme directory as it is. If you want to rename the `wordplate` theme to something else you'll also need to update the `WP_DEFAULT_THEME` environment variable in the `.env` file. 320 |
321 |
322 | Can I use WordPlate with Laravel Herd? 323 | 324 | If you're using Laravel Herd or Valet together with WordPlate, you may use our [custom driver](https://herd.laravel.com/docs/macos/extending-herd/custom-drivers): 325 | 326 | ```php 327 | isActualFile($staticFilePath)) { 345 | return $staticFilePath; 346 | } 347 | 348 | return false; 349 | } 350 | 351 | public function frontControllerPath(string $sitePath, string $siteName, string $uri): ?string 352 | { 353 | return parent::frontControllerPath( 354 | $sitePath . '/public', 355 | $siteName, 356 | $this->forceTrailingSlash($uri) 357 | ); 358 | } 359 | 360 | private function forceTrailingSlash(string $uri) 361 | { 362 | if (substr($uri, -1 * strlen('/wordpress/wp-admin')) === '/wordpress/wp-admin') { 363 | header('Location: ' . $uri . '/'); 364 | exit; 365 | } 366 | 367 | return $uri; 368 | } 369 | 370 | public function logFilesPaths() 371 | { 372 | return [ 373 | '/public', 374 | ]; 375 | } 376 | } 377 | ``` 378 |
379 |
380 | Can I use WordPlate with Tinkerwell? 381 | 382 | If you're using Tinkerwell together with WordPlate, you may use our [custom driver](https://tinkerwell.app/docs/4/extending-tinkerwell/custom-drivers): 383 | 384 | ```php 385 | 406 | 407 | ## Upgrade Guide 408 | 409 |
410 | Upgrading from 11 to 12 411 | 412 | 1. The `wordplate/framework` package has been archived. Remove the package from the `composer.json` file: 413 | 414 | ```diff 415 | "require": { 416 | - "wordplate/framework": "^11.1", 417 | } 418 | ``` 419 | 420 | 1. Install the following package dependencies: 421 | 422 | ```sh 423 | composer require \ 424 | composer/installers \ 425 | roots/bedrock-autoloader \ 426 | roots/wordpress \ 427 | symfony/http-foundation \ 428 | vinkla/headache \ 429 | vlucas/phpdotenv \ 430 | wpackagist-plugin/clean-image-filenames 431 | ``` 432 | 433 | 1. Install the following development package dependencies: 434 | 435 | ```sh 436 | composer require --dev symfony/var-dumper 437 | ``` 438 | 439 | 1. Replace your `public/wp-config.php` file with [the one in this repository](public/wp-config.php). Remember to save any custom constants defined in your `wp-config.php` file. 440 | 441 | 1. Add the [`src/helpers.php`](src/helpers.php) file from this repository and autoload it in the `composer.json` file: 442 | 443 | ```diff 444 | +"autoload": { 445 | + "files": [ 446 | + "src/helpers.php" 447 | + ] 448 | +} 449 | ``` 450 | 451 | 1. Run `composer update` in the root of your project. 452 | 453 |
454 |
455 | Upgrading from 10 to 11 456 | 457 | 1. WordPlate now requires PHP 8.0 or later. 458 | 459 | 1. Bump the version number in the `composer.json` file to `^11.0`. 460 | 461 | 1. Run `composer update` in the root of your project. 462 |
463 |
464 | Upgrading from 9 to 10 465 | 466 | 1. WordPlate now requires PHP 7.4 or later. 467 | 468 | 1. Bump the version number in the `composer.json` file to `^10.0`. 469 | 470 | 1. Rename `WP_ENV` to `WP_ENVIRONMENT_TYPE` in the environment file. 471 | 472 | 1. Rename `WP_THEME` to `WP_DEFAULT_THEME` in the environment file. 473 | 474 | 1. Rename `WP_URL` to `WP_HOME` in the environment file (if it exists). 475 | 476 | 1. If you're using the `WP_CACHE` environment variable you'll need to define it in the `public/wp-config.php` file: 477 | 478 | ```diff 479 | $application->run(); 480 | 481 | +define('WP_CACHE', env('WP_CACHE', false)); 482 | 483 | $table_prefix = env('DB_TABLE_PREFIX', 'wp_'); 484 | ```` 485 | 486 | 1. Optional: Rename `WP_PREFIX` to `DB_TABLE_PREFIX` in the following files: 487 | 488 | - `.env` 489 | - `.env.example` 490 | - `public/wp-config.php` 491 | 492 | 1. Run `composer update` in the root of your project. 493 |
494 |
495 | Upgrading from 8 to 9 496 | 497 | 1. Bump the version number in the `composer.json` file to `^9.0`. 498 | 499 | 1. Copy the `public/mu-plugins/mu-plugins.php` file into your project. 500 | 501 | 1. Update the `public/.gitignore` file to allow the new `mu-plugins.php` file: 502 | 503 | ```diff 504 | -mu-plugins/ 505 | +mu-plugins/* 506 | +!mu-plugins/mu-plugins.php 507 | ```` 508 | 509 | 1. Run `composer update` in the root of your project. 510 |
511 |
512 | Upgrading from 7 to 8 513 | 514 | 1. WordPlate now requires PHP 7.2 or later. 515 | 516 | 1. Bump the version number in the `composer.json` file to `^8.0`. 517 | 518 | > [!Note] 519 | > WordPlate 8.0 requires WordPress 5.3 or later. 520 | 521 | 1. Laravel's helper functions is now optional in WordPlate. If you want to use the functions, install the [`laravel/helpers`](https://github.com/laravel/helpers#readme) package, with Composer, in the root of your project: 522 | 523 | ```sh 524 | composer require laravel/helpers 525 | ``` 526 | 527 | 1. Laravel's collections are now optional in WordPlate. If you want to use collections, install the [`tightenco/collect`](https://github.com/tightenco/collect#readme) package, with Composer, in the root of your project: 528 | 529 | ```sh 530 | composer require tightenco/collect 531 | ``` 532 | 533 | 1. The `mix` helper function is now optional in WordPlate. If you want to use the function, install the [`ibox/mix-function`](https://github.com/juanem1/mix-function#readme) package, with Composer, in the root of your project: 534 | 535 | ```sh 536 | composer require ibox/mix-function 537 | ``` 538 | 539 | 1. Replace any usage of `asset`, `stylesheet_url` and `template_url` functions with WordPress's [`get_theme_file_uri`](https://developer.wordpress.org/reference/functions/get_theme_file_uri/) function. 540 | 541 | 1. Replace any usage of `stylesheet_path` and `template_path` functions with WordPress's [`get_theme_file_path`](https://developer.wordpress.org/reference/functions/get_theme_file_path/) function . 542 | 543 | 1. The `base_path` and `template_slug` functions have been removed. 544 | 545 | 1. Run `composer update` in the root of your project. 546 |
547 |
548 | Upgrading from 6 to 7 549 | 550 | 1. Bump the version number in the `composer.json` file to `^7.0`. 551 | 552 | > [!Note] 553 | > WordPlate 7.0 requires WordPress 5.0 or later. 554 | 555 | 1. Update the `realpath(__DIR__)` to `realpath(__DIR__.'/../')` in the `wp-config.php` file. 556 | 557 | 1. If your public directory isn't named `public`, add the following line to the `wp-config.php` file: 558 | 559 | ```php 560 | $application->setPublicPath(realpath(__DIR__)); 561 | ``` 562 | 563 | 1. Run `composer update` in the root of your project. 564 |
565 |
566 | Upgrading from 5 to 6 567 | 568 | 1. Bump the version number in the `composer.json` file to `^6.0`. 569 | 570 | 1. Update the `realpath(__DIR__.'/../')` to `realpath(__DIR__)` in the `wp-config.php` file. 571 | 572 | 1. Run `composer update` in the root of your project. 573 |
574 |
575 | Upgrading from 4 to 5 576 | 577 | 1. Bump the version number in the `composer.json` file to `^5.0`. 578 | 579 | 1. Copy and paste the contents of the [`wp-config.php`](https://github.com/vinkla/wordplate/blob/e301f9b093efdbd1bdeeb61e2f99f86e23c36fb2/public/wp-config.php) file into your application. 580 | 581 | > [!Note] 582 | > Make sure you don't overwrite any of your custom constants. 583 | 584 | 1. Run `composer update` in the root of your project. 585 |
586 | 587 | ## Acknowledgements 588 | 589 | WordPlate wouldn't be possible without these amazing open-source projects. 590 | 591 | - [`composer/installers`](https://github.com/composer/installers) 592 | - [`motdotla/dotenv`](https://github.com/motdotla/dotenv) 593 | - [`outlandish/wpackagist`](https://github.com/outlandishideas/wpackagist) 594 | - [`roots/bedrock-autoloader`](https://github.com/roots/bedrock-autoloader) 595 | - [`roots/wordpress`](https://github.com/roots/wordpress) 596 | - [`symfony/http-foundation`](https://github.com/symfony/http-foundation) 597 | - [`symfony/var-dumper`](https://github.com/symfony/var-dumper) 598 | - [`tailwindlabs/tailwindcss`](https://github.com/tailwindlabs/tailwindcss) 599 | - [`upperdog/clean-image-filenames`](https://github.com/upperdog/clean-image-filenames) 600 | - [`vinkla/headache`](https://github.com/vinkla/headache) 601 | - [`vitejs/vite`](https://github.com/vitejs/vite) 602 | - [`vlucas/phpdotenv`](https://github.com/vlucas/phpdotenv) 603 | 604 | ## License 605 | 606 | The WordPlate package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 607 | --------------------------------------------------------------------------------