@codigodoleo/wp-kit 2.0.1 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.php +17 -0
- package/lib/core/generator.js +11 -10
- package/lib/prompts/loadModulePrompts.js +2 -1
- package/lib/utils/paths.js +29 -0
- package/package.json +4 -1
- package/server/php/php.ini +48 -0
- package/server/www/rocket.conf +283 -0
- package/wp-config.php +190 -0
package/index.php
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Front to the WordPress application. This file doesn't do anything, but loads
|
|
4
|
+
* wp-blog-header.php which does and tells WordPress to load the theme.
|
|
5
|
+
*
|
|
6
|
+
* @package WordPress
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Tells WordPress to load the WordPress theme and output it.
|
|
11
|
+
*
|
|
12
|
+
* @var bool
|
|
13
|
+
*/
|
|
14
|
+
define( 'WP_USE_THEMES', true );
|
|
15
|
+
|
|
16
|
+
/** Loads the WordPress Environment and Template */
|
|
17
|
+
require __DIR__ . '/wp/wp-blog-header.php';
|
package/lib/core/generator.js
CHANGED
|
@@ -7,6 +7,7 @@ import mergeWith from 'lodash.mergewith';
|
|
|
7
7
|
import yaml from 'js-yaml';
|
|
8
8
|
import { log, color } from '../utils/logger.js';
|
|
9
9
|
import { HookManager } from './hook-manager.js';
|
|
10
|
+
import { PACKAGE_ROOT, MODULES_PATH, TEMPLATES_PATH, getModulePath, getModuleTemplatePath, getBaseTemplatePath } from '../utils/paths.js';
|
|
10
11
|
|
|
11
12
|
export class Generator {
|
|
12
13
|
constructor(baseDir = process.cwd()) {
|
|
@@ -16,8 +17,8 @@ export class Generator {
|
|
|
16
17
|
|
|
17
18
|
async copyFile(sourcePathRelative, moduleName = null, outputName = "") {
|
|
18
19
|
const baseDir = moduleName
|
|
19
|
-
?
|
|
20
|
-
:
|
|
20
|
+
? getModulePath(moduleName)
|
|
21
|
+
: PACKAGE_ROOT;
|
|
21
22
|
|
|
22
23
|
outputName = outputName ? outputName : sourcePathRelative;
|
|
23
24
|
|
|
@@ -37,8 +38,8 @@ export class Generator {
|
|
|
37
38
|
*/
|
|
38
39
|
async copyDirectory(sourcePathRelative, moduleName = null, outputName = "", overwrite = true) {
|
|
39
40
|
const baseDir = moduleName
|
|
40
|
-
?
|
|
41
|
-
:
|
|
41
|
+
? getModulePath(moduleName)
|
|
42
|
+
: PACKAGE_ROOT;
|
|
42
43
|
|
|
43
44
|
outputName = outputName ? outputName : sourcePathRelative;
|
|
44
45
|
|
|
@@ -102,8 +103,8 @@ export class Generator {
|
|
|
102
103
|
|
|
103
104
|
async generateFile(templatePathRelative, context, moduleName = null, outputName = "") {
|
|
104
105
|
const baseDir = moduleName
|
|
105
|
-
?
|
|
106
|
-
:
|
|
106
|
+
? getModuleTemplatePath(moduleName, '')
|
|
107
|
+
: TEMPLATES_PATH;
|
|
107
108
|
|
|
108
109
|
outputName = outputName ? outputName : templatePathRelative;
|
|
109
110
|
|
|
@@ -129,7 +130,7 @@ export class Generator {
|
|
|
129
130
|
* @param {'concat'|'replace'} [options.mergeStrategy='concat'] - Estratégia de merge de arrays
|
|
130
131
|
*/
|
|
131
132
|
async generateModularFile({ baseTemplate, outputFile = "", modules = [], context = {}, format = 'yaml', mergeStrategy = 'replace', debug = false }) {
|
|
132
|
-
const baseTemplatePath =
|
|
133
|
+
const baseTemplatePath = getBaseTemplatePath(baseTemplate + '.hbs');
|
|
133
134
|
const baseRaw = await fs.readFile(baseTemplatePath, 'utf8');
|
|
134
135
|
const compiledBase = handlebars.compile(baseRaw);
|
|
135
136
|
outputFile = outputFile ? outputFile : baseTemplate;
|
|
@@ -156,7 +157,7 @@ export class Generator {
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
for (const mod of modules) {
|
|
159
|
-
const modPath =
|
|
160
|
+
const modPath = getModuleTemplatePath(mod, path.basename(baseTemplate) + '.hbs');
|
|
160
161
|
|
|
161
162
|
if (await fs.pathExists(modPath)) {
|
|
162
163
|
const modRaw = await fs.readFile(modPath, 'utf8');
|
|
@@ -211,8 +212,8 @@ export class Generator {
|
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
const moduleBase = moduleName
|
|
214
|
-
?
|
|
215
|
-
:
|
|
215
|
+
? getModuleTemplatePath(moduleName, '')
|
|
216
|
+
: TEMPLATES_PATH;
|
|
216
217
|
const templatePath = path.resolve(moduleBase, moduleTemplatePath + '.hbs');
|
|
217
218
|
|
|
218
219
|
const modRaw = await fs.readFile(templatePath, 'utf8');
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { MODULES_PATH } from '../utils/paths.js';
|
|
3
4
|
|
|
4
|
-
export async function loadModulePrompts(modulesDir =
|
|
5
|
+
export async function loadModulePrompts(modulesDir = MODULES_PATH) {
|
|
5
6
|
const modules = await fs.readdir(modulesDir);
|
|
6
7
|
const promptsMap = {};
|
|
7
8
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// lib/utils/paths.js
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
|
|
8
|
+
// Caminho base do pacote (raiz do projeto)
|
|
9
|
+
export const PACKAGE_ROOT = path.resolve(__dirname, '../..');
|
|
10
|
+
|
|
11
|
+
// Caminhos principais
|
|
12
|
+
export const MODULES_PATH = path.join(PACKAGE_ROOT, 'modules');
|
|
13
|
+
export const TEMPLATES_PATH = path.join(PACKAGE_ROOT, 'templates');
|
|
14
|
+
export const SERVER_PATH = path.join(PACKAGE_ROOT, 'server');
|
|
15
|
+
|
|
16
|
+
// Função auxiliar para resolver caminhos de módulos
|
|
17
|
+
export function getModulePath(moduleName) {
|
|
18
|
+
return path.join(MODULES_PATH, moduleName);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Função auxiliar para resolver templates de módulos
|
|
22
|
+
export function getModuleTemplatePath(moduleName, templateName) {
|
|
23
|
+
return path.join(MODULES_PATH, moduleName, 'templates', templateName);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Função auxiliar para resolver templates base
|
|
27
|
+
export function getBaseTemplatePath(templateName) {
|
|
28
|
+
return path.join(TEMPLATES_PATH, templateName);
|
|
29
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codigodoleo/wp-kit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Kit opinativo para padronizar projetos WordPress com CI/CD dinâmico.",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"lib/",
|
|
16
16
|
"modules/",
|
|
17
17
|
"templates/",
|
|
18
|
+
"server/",
|
|
19
|
+
"wp-config.php",
|
|
20
|
+
"index.php",
|
|
18
21
|
".cspell.json",
|
|
19
22
|
".gitkeep"
|
|
20
23
|
],
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[PHP]
|
|
2
|
+
|
|
3
|
+
;;;;;;;;;;;;;;;
|
|
4
|
+
; PHP Globals ;
|
|
5
|
+
;;;;;;;;;;;;;;;
|
|
6
|
+
|
|
7
|
+
short_open_tag = Off
|
|
8
|
+
output_buffering = 4096
|
|
9
|
+
allow_call_time_pass_reference = Off
|
|
10
|
+
request_order = "GP"
|
|
11
|
+
register_long_arrays = Off
|
|
12
|
+
register_argc_argv = Off
|
|
13
|
+
magic_quotes_gpc = Off
|
|
14
|
+
enable_dl = Off
|
|
15
|
+
allow_url_fopen = On
|
|
16
|
+
realpath_cache_size = "800K"
|
|
17
|
+
realpath_cache_ttl = "86400"
|
|
18
|
+
disable_functions =
|
|
19
|
+
sendmail_path=/bin/true
|
|
20
|
+
|
|
21
|
+
[Date]
|
|
22
|
+
date.timezone = "UTC"
|
|
23
|
+
|
|
24
|
+
;;;;;;;;;;;;;;;;;;;;;;
|
|
25
|
+
;; PACKAGE SETTINGS ;;
|
|
26
|
+
;;;;;;;;;;;;;;;;;;;;;;
|
|
27
|
+
|
|
28
|
+
[xdebug]
|
|
29
|
+
xdebug.mode=debug
|
|
30
|
+
xdebug.start_with_request=yes
|
|
31
|
+
xdebug.client_host=host.docker.internal
|
|
32
|
+
xdebug.client_port=9003
|
|
33
|
+
xdebug.log_level=0
|
|
34
|
+
xdebug.idekey=VSCODE
|
|
35
|
+
|
|
36
|
+
; Globals
|
|
37
|
+
expose_php = on
|
|
38
|
+
max_execution_time = 90
|
|
39
|
+
max_input_time = 900
|
|
40
|
+
max_input_vars = 10000
|
|
41
|
+
memory_limit = 512M
|
|
42
|
+
upload_max_filesize = 100M
|
|
43
|
+
post_max_size = 100M
|
|
44
|
+
error_reporting = E_ALL & ~E_DEPRECATED
|
|
45
|
+
ignore_repeated_errors = on
|
|
46
|
+
html_errors = off
|
|
47
|
+
display_errors = on
|
|
48
|
+
log_errors = on
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
###################################################################################################
|
|
2
|
+
# Rocket-Nginx
|
|
3
|
+
#
|
|
4
|
+
# Rocket-Nginx is a NGINX configuration to speedup your WordPress
|
|
5
|
+
# website with the cache plugin WP-Rocket (http://wp-rocket.me)
|
|
6
|
+
#
|
|
7
|
+
# Author: Maxime Jobin
|
|
8
|
+
# Maintainer: SatelliteWP.com
|
|
9
|
+
# URL: https://github.com/satellitewp/rocket-nginx
|
|
10
|
+
#
|
|
11
|
+
# Tested with WP-Rocket version: 3.16.2.1
|
|
12
|
+
# Tested with NGINX: 1.26.1 (mainline)
|
|
13
|
+
#
|
|
14
|
+
# Version 3.1.0
|
|
15
|
+
#
|
|
16
|
+
###################################################################################################
|
|
17
|
+
|
|
18
|
+
# Add debug information into header
|
|
19
|
+
set $rocket_debug 1;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
###################################################################################################
|
|
23
|
+
# Do not alter theses values
|
|
24
|
+
#
|
|
25
|
+
set $rocket_bypass 1; # Should NGINX bypass WordPress and call cache file directly ?
|
|
26
|
+
set $rocket_encryption ""; # Is GZIP accepted by client ?
|
|
27
|
+
set $rocket_file ""; # Filename to look for
|
|
28
|
+
set $rocket_is_bypassed "MISS"; # Header text added to check if the bypass worked or not. Header: X-Rocket-Nginx-Serving-Static
|
|
29
|
+
set $rocket_reason ""; # Reason why cache file was not used. If cache file is used, what file was used
|
|
30
|
+
set $rocket_https_prefix ""; # HTTPS prefix to use when cached files are using HTTPS
|
|
31
|
+
set $rocket_mobile_prefix ""; # Mobile prefix to use when mobile device is detected and mobile cache is activated
|
|
32
|
+
set $rocket_is_https 0; # Checks if the request is HTTPS
|
|
33
|
+
set $rocket_dynamic ""; # Dynamic value to add to cached filename
|
|
34
|
+
set $rocket_device "desktop"; # Device type (desktop or mobile)
|
|
35
|
+
|
|
36
|
+
###################################################################################################
|
|
37
|
+
# PAGE CACHE
|
|
38
|
+
#
|
|
39
|
+
|
|
40
|
+
# Define Rocket-Nginx $is_args
|
|
41
|
+
set $rocket_is_args $is_args;
|
|
42
|
+
|
|
43
|
+
# Get query string without the parameters (before the '?')
|
|
44
|
+
set $rocket_uri_path $request_uri;
|
|
45
|
+
if ($request_uri ~* "^([^?]*)(\?.+)$") {
|
|
46
|
+
set $rocket_uri_path $1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# Is GZIP accepted by client ?
|
|
50
|
+
if ($http_accept_encoding ~ gzip) {
|
|
51
|
+
set $rocket_encryption "_gzip";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Is Brotli accepted by client ?
|
|
55
|
+
if ($http_accept_encoding ~ br) {
|
|
56
|
+
set $rocket_encryption "";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Is HTTPS request ?
|
|
60
|
+
if ($https = "on") { set $rocket_is_https 1; }
|
|
61
|
+
if ($http_x_forwarded_proto = "https") { set $rocket_is_https 1; }
|
|
62
|
+
if ($http_front_end_https = "on") { set $rocket_is_https 1; }
|
|
63
|
+
if ($http_x_forwarded_protocol = "https") { set $rocket_is_https 1; }
|
|
64
|
+
if ($http_x_forwarded_ssl = "on") { set $rocket_is_https 1; }
|
|
65
|
+
if ($http_x_url_scheme = "https") { set $rocket_is_https 1; }
|
|
66
|
+
if ($http_forwarded ~ /proto=https/) { set $rocket_is_https 1; }
|
|
67
|
+
|
|
68
|
+
if ($rocket_is_https = "1") {
|
|
69
|
+
set $rocket_https_prefix "-https";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# Set mobile detection file path
|
|
73
|
+
# This variable contains a file to look for. If it exists, WP Rocket is set to
|
|
74
|
+
# generate both Desktop and Mobile cache.
|
|
75
|
+
set $rocket_mobile_detection "$document_root/wp-content/cache/wp-rocket/$http_host/$request_uri/.mobile-active";
|
|
76
|
+
|
|
77
|
+
# Query strings to ignore
|
|
78
|
+
set $rocket_args $args;
|
|
79
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_source=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
80
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_campaign=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
81
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_medium=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
82
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_expid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
83
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_term=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
84
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_content=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
85
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_id=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
86
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_source_platform=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
87
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_creative_format=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
88
|
+
if ($rocket_args ~ (.*)(?:&|^)utm_marketing_tactic=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
89
|
+
if ($rocket_args ~ (.*)(?:&|^)_ga=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
90
|
+
if ($rocket_args ~ (.*)(?:&|^)gclid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
91
|
+
if ($rocket_args ~ (.*)(?:&|^)campaignid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
92
|
+
if ($rocket_args ~ (.*)(?:&|^)adgroupid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
93
|
+
if ($rocket_args ~ (.*)(?:&|^)adid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
94
|
+
if ($rocket_args ~ (.*)(?:&|^)gbraid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
95
|
+
if ($rocket_args ~ (.*)(?:&|^)wbraid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
96
|
+
if ($rocket_args ~ (.*)(?:&|^)gclsrc=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
97
|
+
if ($rocket_args ~ (.*)(?:&|^)ef_id=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
98
|
+
if ($rocket_args ~ (.*)(?:&|^)fb_action_ids=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
99
|
+
if ($rocket_args ~ (.*)(?:&|^)fb_action_types=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
100
|
+
if ($rocket_args ~ (.*)(?:&|^)fb_source=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
101
|
+
if ($rocket_args ~ (.*)(?:&|^)fbclid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
102
|
+
if ($rocket_args ~ (.*)(?:&|^)mc_cid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
103
|
+
if ($rocket_args ~ (.*)(?:&|^)mc_eid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
104
|
+
if ($rocket_args ~ (.*)(?:&|^)mtm_source=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
105
|
+
if ($rocket_args ~ (.*)(?:&|^)mtm_medium=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
106
|
+
if ($rocket_args ~ (.*)(?:&|^)mtm_campaign=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
107
|
+
if ($rocket_args ~ (.*)(?:&|^)mtm_keyword=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
108
|
+
if ($rocket_args ~ (.*)(?:&|^)mtm_cid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
109
|
+
if ($rocket_args ~ (.*)(?:&|^)mtm_content=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
110
|
+
if ($rocket_args ~ (.*)(?:&|^)_ke=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
111
|
+
if ($rocket_args ~ (.*)(?:&|^)age-verified=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
112
|
+
if ($rocket_args ~ (.*)(?:&|^)ao_noptimize=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
113
|
+
if ($rocket_args ~ (.*)(?:&|^)usqp=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
114
|
+
if ($rocket_args ~ (.*)(?:&|^)cn-reloaded=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
115
|
+
if ($rocket_args ~ (.*)(?:&|^)sscid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
116
|
+
if ($rocket_args ~ (.*)(?:&|^)msclkid=[^&]*(.*)) { set $rocket_args $1$2; }
|
|
117
|
+
|
|
118
|
+
# Remove & at the beginning (if needed)
|
|
119
|
+
if ($rocket_args ~ ^&(.*)) { set $rocket_args $1; }
|
|
120
|
+
|
|
121
|
+
# Do not count arguments if part of caching arguments
|
|
122
|
+
if ($rocket_args ~ ^\?$) {
|
|
123
|
+
set $rocket_is_args "";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
# Adjust $rocket_is_args after processing query strings to ignore
|
|
127
|
+
if ($rocket_args = "") {
|
|
128
|
+
set $rocket_is_args "";
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# Query string to cache
|
|
132
|
+
# None
|
|
133
|
+
|
|
134
|
+
# Check if device is Mobile
|
|
135
|
+
if ($http_user_agent ~* "(?:phone|windows\s+phone|ipod|blackberry|(?:android|bb\d+|meego|silk|googlebot) .+? mobile|palm|windows\s+ce|opera mini|avantgo|mobilesafari|docomo|kaios)") {
|
|
136
|
+
set $rocket_device "mobile";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
# Set mobile prefix if mobile mode is activated
|
|
140
|
+
if (-f "$rocket_mobile_detection") {
|
|
141
|
+
set $rocket_mobile_prefix "-mobile";
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if ($rocket_device != "mobile") {
|
|
145
|
+
set $rocket_mobile_prefix "";
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# File/URL to return IF we must bypass WordPress
|
|
149
|
+
# Desktop: index.html
|
|
150
|
+
# Gzip: index.html_gzip
|
|
151
|
+
# HTTPS: index-https.html
|
|
152
|
+
# Mobile: index-mobile-https.html
|
|
153
|
+
set $rocket_file_start "index$rocket_mobile_prefix$rocket_https_prefix";
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
set $rocket_pre_url "/wp-content/cache/wp-rocket/$http_host/$rocket_uri_path/$rocket_args/";
|
|
157
|
+
set $rocket_pre_file "$document_root/wp-content/cache/wp-rocket/$http_host/$rocket_uri_path/$rocket_args/";
|
|
158
|
+
|
|
159
|
+
# Standard cache file format
|
|
160
|
+
set $rocket_url "$rocket_pre_url$rocket_file_start$rocket_dynamic.html";
|
|
161
|
+
set $rocket_file "$rocket_pre_file$rocket_file_start$rocket_dynamic.html";
|
|
162
|
+
|
|
163
|
+
# Check if gzip version cached file is available
|
|
164
|
+
if (-f "$rocket_file$rocket_encryption") {
|
|
165
|
+
set $rocket_file "$rocket_file$rocket_encryption";
|
|
166
|
+
set $rocket_url "$rocket_url$rocket_encryption";
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
# Do not bypass if the cached file does not exist
|
|
170
|
+
if (!-f "$rocket_file") {
|
|
171
|
+
set $rocket_bypass 0;
|
|
172
|
+
set $rocket_is_bypassed "MISS";
|
|
173
|
+
set $rocket_reason "File not cached";
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
# Do not bypass if it's a POST request
|
|
177
|
+
if ($request_method = POST) {
|
|
178
|
+
set $rocket_bypass 0;
|
|
179
|
+
set $rocket_is_bypassed "BYPASS";
|
|
180
|
+
set $rocket_reason "POST request";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
# Do not bypass if arguments are found (e.g. ?page=2)
|
|
184
|
+
if ($rocket_is_args) {
|
|
185
|
+
set $rocket_bypass 0;
|
|
186
|
+
set $rocket_is_bypassed "BYPASS";
|
|
187
|
+
set $rocket_reason "Arguments found";
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
# Do not bypass if the site is in maintenance mode
|
|
191
|
+
if (-f "$document_root/.maintenance") {
|
|
192
|
+
set $rocket_bypass 0;
|
|
193
|
+
set $rocket_is_bypassed "BYPASS";
|
|
194
|
+
set $rocket_reason "Maintenance mode";
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
# Do not bypass if one of those cookie if found
|
|
198
|
+
# wordpress_logged_in_[hash] : When a user is logged in, this cookie is created (we'd rather let WP-Rocket handle that)
|
|
199
|
+
# wp-postpass_[hash] : When a protected post requires a password, this cookie is created.
|
|
200
|
+
if ($http_cookie ~* "(wordpress_logged_in_|wp\-postpass_|woocommerce_items_in_cart|woocommerce_cart_hash|wptouch_switch_toogle|comment_author_|comment_author_email_)") {
|
|
201
|
+
set $rocket_bypass 0;
|
|
202
|
+
set $rocket_is_bypassed "BYPASS";
|
|
203
|
+
set $rocket_reason "Cookie";
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
# If the bypass token is still on, let's bypass WordPress with the cached URL
|
|
207
|
+
if ($rocket_bypass = 1) {
|
|
208
|
+
set $rocket_is_bypassed "HIT";
|
|
209
|
+
set $rocket_reason "$rocket_url";
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
# Clear variables if debug is not needed
|
|
213
|
+
if ($rocket_debug = 0) {
|
|
214
|
+
set $rocket_reason "";
|
|
215
|
+
set $rocket_file "";
|
|
216
|
+
set $rocket_device "";
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
# If the bypass token is still on, rewrite according to the file linked to the request
|
|
220
|
+
if ($rocket_bypass = 1) {
|
|
221
|
+
rewrite .* "$rocket_url" last;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
# Add header to HTML cached files
|
|
225
|
+
location ~ /wp-content/cache/wp-rocket/.*html$ {
|
|
226
|
+
etag on;
|
|
227
|
+
add_header Vary "Accept-Encoding, Cookie";
|
|
228
|
+
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
229
|
+
add_header X-Rocket-Nginx-Serving-Static $rocket_is_bypassed;
|
|
230
|
+
add_header X-Rocket-Nginx-Reason $rocket_reason;
|
|
231
|
+
add_header X-Rocket-Nginx-File $rocket_file;
|
|
232
|
+
add_header X-Rocket-Nginx-Device $rocket_device;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
# Do not gzip cached files that are already gzipped
|
|
236
|
+
location ~ /wp-content/cache/wp-rocket/.*_gzip$ {
|
|
237
|
+
etag on;
|
|
238
|
+
gzip off;
|
|
239
|
+
types {}
|
|
240
|
+
default_type text/html;
|
|
241
|
+
add_header Content-Encoding gzip;
|
|
242
|
+
add_header Vary "Accept-Encoding, Cookie";
|
|
243
|
+
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
244
|
+
add_header X-Rocket-Nginx-Serving-Static $rocket_is_bypassed;
|
|
245
|
+
add_header X-Rocket-Nginx-Reason $rocket_reason;
|
|
246
|
+
add_header X-Rocket-Nginx-File $rocket_file;
|
|
247
|
+
add_header X-Rocket-Nginx-Device $rocket_device;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
# Debug header (when file is not cached)
|
|
251
|
+
add_header X-Rocket-Nginx-Serving-Static $rocket_is_bypassed;
|
|
252
|
+
add_header X-Rocket-Nginx-Reason $rocket_reason;
|
|
253
|
+
add_header X-Rocket-Nginx-File $rocket_file;
|
|
254
|
+
add_header X-Rocket-Nginx-Device $rocket_device;
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
###################################################################################################
|
|
258
|
+
# BROWSER CSS CACHE
|
|
259
|
+
#
|
|
260
|
+
location ~* \.css$ {
|
|
261
|
+
etag on;
|
|
262
|
+
gzip_vary on;
|
|
263
|
+
expires 30d;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
###################################################################################################
|
|
268
|
+
# BROWSER JS CACHE
|
|
269
|
+
#
|
|
270
|
+
location ~* \.js$ {
|
|
271
|
+
etag on;
|
|
272
|
+
gzip_vary on;
|
|
273
|
+
expires 30d;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
###################################################################################################
|
|
278
|
+
# BROWSER MEDIA CACHE
|
|
279
|
+
#
|
|
280
|
+
location ~* \.(ico|gif|jpe?g|png|svg|eot|otf|woff|woff2|ttf|ogg|webp)$ {
|
|
281
|
+
etag on;
|
|
282
|
+
expires 30d;
|
|
283
|
+
}
|
package/wp-config.php
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The base configuration for WordPress
|
|
5
|
+
*
|
|
6
|
+
* The wp-config.php creation script uses this file during the installation.
|
|
7
|
+
* You don't have to use the website, you can copy this file to "wp-config.php"
|
|
8
|
+
* and fill in the values.
|
|
9
|
+
*
|
|
10
|
+
* This file contains the following configurations:
|
|
11
|
+
*
|
|
12
|
+
* * Database settings
|
|
13
|
+
* * Secret keys
|
|
14
|
+
* * Database table prefix
|
|
15
|
+
* * ABSPATH
|
|
16
|
+
*
|
|
17
|
+
* This has been slightly modified (to read environment variables) for use in Docker.
|
|
18
|
+
*
|
|
19
|
+
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
|
|
20
|
+
*
|
|
21
|
+
* @package WordPress
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// ** Load Composer autoload ** //
|
|
25
|
+
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
|
|
26
|
+
require_once __DIR__ . '/vendor/autoload.php';
|
|
27
|
+
} else {
|
|
28
|
+
die('Error: Composer autoload not found.');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// ** Carregar o .env para variáveis de ambiente ** //
|
|
33
|
+
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
|
34
|
+
$dotenv->safeLoad();
|
|
35
|
+
$requiredEnvs = ['WORDPRESS_DB_NAME', 'WORDPRESS_DB_USER', 'WORDPRESS_DB_PASSWORD', 'WORDPRESS_DB_HOST', 'WORDPRESS_SITE_URL'];
|
|
36
|
+
$dotenv->required($requiredEnvs);
|
|
37
|
+
|
|
38
|
+
// a helper function to lookup "env_FILE", "env", then fallback
|
|
39
|
+
if (!function_exists('getenv_docker')) {
|
|
40
|
+
// https://github.com/docker-library/wordpress/issues/588 (WP-CLI will load this file 2x)
|
|
41
|
+
function getenv_docker($env, $default)
|
|
42
|
+
{
|
|
43
|
+
if (getenv('LANDO_INFO')) {
|
|
44
|
+
// Lando-specific environment variable
|
|
45
|
+
return $_ENV[$env] ?? $default;
|
|
46
|
+
} else if ($fileEnv = getenv($env . '_FILE')) {
|
|
47
|
+
return rtrim(file_get_contents($fileEnv), "\r\n");
|
|
48
|
+
} else if (($val = getenv($env)) !== false) {
|
|
49
|
+
return $val;
|
|
50
|
+
} else {
|
|
51
|
+
return $default;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ** Database settings - You can get this info from your web host ** //
|
|
57
|
+
/** The name of the database for WordPress */
|
|
58
|
+
define('DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpress'));
|
|
59
|
+
|
|
60
|
+
/** Database username */
|
|
61
|
+
define('DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username'));
|
|
62
|
+
|
|
63
|
+
/** Database password */
|
|
64
|
+
define('DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password'));
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Docker image fallback values above are sourced from the official WordPress installation wizard:
|
|
68
|
+
* https://github.com/WordPress/WordPress/blob/1356f6537220ffdc32b9dad2a6cdbe2d010b7a88/wp-admin/setup-config.php#L224-L238
|
|
69
|
+
* (However, using "example username" and "example password" in your database is strongly discouraged. Please use strong, random credentials!)
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
/** Database hostname */
|
|
73
|
+
define('DB_HOST', getenv_docker('WORDPRESS_DB_HOST', 'mysql'));
|
|
74
|
+
|
|
75
|
+
/** Database charset to use in creating database tables. */
|
|
76
|
+
define('DB_CHARSET', getenv_docker('WORDPRESS_DB_CHARSET', 'utf8'));
|
|
77
|
+
|
|
78
|
+
/** The database collate type. Don't change this if in doubt. */
|
|
79
|
+
define('DB_COLLATE', getenv_docker('WORDPRESS_DB_COLLATE', ''));
|
|
80
|
+
|
|
81
|
+
/**#@+
|
|
82
|
+
* Authentication unique keys and salts.
|
|
83
|
+
*
|
|
84
|
+
* Change these to different unique phrases! You can generate these using
|
|
85
|
+
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
|
|
86
|
+
*
|
|
87
|
+
* You can change these at any point in time to invalidate all existing cookies.
|
|
88
|
+
* This will force all users to have to log in again.
|
|
89
|
+
*
|
|
90
|
+
* @since 2.6.0
|
|
91
|
+
*/
|
|
92
|
+
define('AUTH_KEY', getenv_docker('WORDPRESS_AUTH_KEY', 'put your unique phrase here'));
|
|
93
|
+
define('SECURE_AUTH_KEY', getenv_docker('WORDPRESS_SECURE_AUTH_KEY', 'put your unique phrase here'));
|
|
94
|
+
define('LOGGED_IN_KEY', getenv_docker('WORDPRESS_LOGGED_IN_KEY', 'put your unique phrase here'));
|
|
95
|
+
define('NONCE_KEY', getenv_docker('WORDPRESS_NONCE_KEY', 'put your unique phrase here'));
|
|
96
|
+
define('AUTH_SALT', getenv_docker('WORDPRESS_AUTH_SALT', 'put your unique phrase here'));
|
|
97
|
+
define('SECURE_AUTH_SALT', getenv_docker('WORDPRESS_SECURE_AUTH_SALT', 'put your unique phrase here'));
|
|
98
|
+
define('LOGGED_IN_SALT', getenv_docker('WORDPRESS_LOGGED_IN_SALT', 'put your unique phrase here'));
|
|
99
|
+
define('NONCE_SALT', getenv_docker('WORDPRESS_NONCE_SALT', 'put your unique phrase here'));
|
|
100
|
+
// (See also https://wordpress.stackexchange.com/a/152905/199287)
|
|
101
|
+
|
|
102
|
+
/**#@-*/
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* WordPress database table prefix.
|
|
106
|
+
*
|
|
107
|
+
* You can have multiple installations in one database if you give each
|
|
108
|
+
* a unique prefix. Only numbers, letters, and underscores please!
|
|
109
|
+
*
|
|
110
|
+
* At the installation time, database tables are created with the specified prefix.
|
|
111
|
+
* Changing this value after WordPress is installed will make your site think
|
|
112
|
+
* it has not been installed.
|
|
113
|
+
*
|
|
114
|
+
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
|
|
115
|
+
*/
|
|
116
|
+
$table_prefix = getenv_docker('WORDPRESS_TABLE_PREFIX', 'wp_');
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* For developers: WordPress debugging mode.
|
|
120
|
+
*
|
|
121
|
+
* Change this to true to enable the display of notices during development.
|
|
122
|
+
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
|
123
|
+
* in their development environments.
|
|
124
|
+
*
|
|
125
|
+
* For information on other constants that can be used for debugging,
|
|
126
|
+
* visit the documentation.
|
|
127
|
+
*
|
|
128
|
+
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
|
|
129
|
+
*/
|
|
130
|
+
define('WP_DEBUG', !!getenv_docker('WORDPRESS_DEBUG', ''));
|
|
131
|
+
|
|
132
|
+
/* Add any custom values between this line and the "stop editing" line. */
|
|
133
|
+
|
|
134
|
+
// If we're running in a Docker container, we need to set the HTTP_HOST and SERVER_PORT
|
|
135
|
+
// to empty strings, otherwise WordPress will try to use the container name as the host.
|
|
136
|
+
// This is necessary for WordPress to work correctly in a Docker environment.
|
|
137
|
+
// This is a workaround for the issue where WordPress tries to use the container name as the host,
|
|
138
|
+
// which can cause issues with SSL and other configurations.
|
|
139
|
+
if (defined('WP_CLI') && constant('WP_CLI')) {
|
|
140
|
+
$_SERVER["HTTP_HOST"] = "";
|
|
141
|
+
$_SERVER['SERVER_PORT'] = 80;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
|
|
145
|
+
// see also https://wordpress.org/support/article/administration-over-ssl/#using-a-reverse-proxy
|
|
146
|
+
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
|
|
147
|
+
$_SERVER['HTTPS'] = 'on';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** URL routing (Optional, may not be necessary) */
|
|
151
|
+
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
|
|
152
|
+
$siteUrl = getenv_docker('WORDPRESS_SITE_URL', 'localhost');
|
|
153
|
+
$siteUrl = (strpos($siteUrl, 'http') === 0) ? $siteUrl : $protocol . $siteUrl;
|
|
154
|
+
define('WP_HOME', $siteUrl);
|
|
155
|
+
define('WP_SITEURL', $siteUrl . '/wp');
|
|
156
|
+
|
|
157
|
+
// Define the content directory and URL
|
|
158
|
+
// This is where your themes, plugins, and uploads will be stored.
|
|
159
|
+
// The default is to use the "content" directory in the same directory as this file.
|
|
160
|
+
// If you want to use a different directory, you can change the path below.
|
|
161
|
+
// Note: This is not the same as the "wp-content" directory, which is the default location for WordPress content.
|
|
162
|
+
define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/content' );
|
|
163
|
+
define( 'WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/content' );
|
|
164
|
+
|
|
165
|
+
// Load all WordPress environment variables from the .env file
|
|
166
|
+
$wordpressEnvs = array_filter($_ENV, function ($key) {
|
|
167
|
+
return strpos($key, 'WORDPRESS_') === 0;
|
|
168
|
+
}, ARRAY_FILTER_USE_KEY);
|
|
169
|
+
|
|
170
|
+
// Define all remaining WordPress environment variables
|
|
171
|
+
foreach ($wordpressEnvs as $key => $value) {
|
|
172
|
+
$key = str_replace('WORDPRESS_', '', $key);
|
|
173
|
+
if (!defined($key))
|
|
174
|
+
define($key, $value);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// If there's a WORDPRESS_CONFIG_EXTRA environment variable, evaluate it
|
|
178
|
+
if ($configExtra = getenv_docker('WORDPRESS_CONFIG_EXTRA', '')) {
|
|
179
|
+
eval($configExtra);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* That's all, stop editing! Happy publishing. */
|
|
183
|
+
|
|
184
|
+
/** Absolute path to the WordPress directory. */
|
|
185
|
+
if (! defined('ABSPATH')) {
|
|
186
|
+
define('ABSPATH', __DIR__ . '/');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Sets up WordPress vars and included files. */
|
|
190
|
+
require_once ABSPATH . 'wp-settings.php';
|