Add public WordPress release conventions
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$LabRoot = Split-Path -Parent (Split-Path -Parent $PSCommandPath)
|
||||
$WorkspaceRoot = Split-Path -Parent (Split-Path -Parent $LabRoot)
|
||||
$ConfigPath = Join-Path $LabRoot 'config\environments.json'
|
||||
$GeneratedRoot = Join-Path $LabRoot 'generated'
|
||||
$ResultsRoot = Join-Path $LabRoot 'results'
|
||||
$PluginSource = Join-Path $WorkspaceRoot 'plugins\bible-reference-tooltips'
|
||||
$PluginSlug = 'bible-reference-tooltips'
|
||||
$ExpectedPluginVersion = '1.1.5'
|
||||
|
||||
function Get-TestLabEnvironments {
|
||||
Get-Content -LiteralPath $ConfigPath -Raw | ConvertFrom-Json
|
||||
}
|
||||
|
||||
function Get-TestLabEnvironment {
|
||||
param([Parameter(Mandatory)][string]$Name)
|
||||
$envs = Get-TestLabEnvironments
|
||||
$selected = $envs | Where-Object { $_.name -eq $Name } | Select-Object -First 1
|
||||
if (-not $selected) {
|
||||
throw "Unknown environment '$Name'. Available: $($envs.name -join ', ')"
|
||||
}
|
||||
return $selected
|
||||
}
|
||||
|
||||
function Convert-ToComposePath {
|
||||
param([Parameter(Mandatory)][string]$Path)
|
||||
return ($Path -replace '\\', '/')
|
||||
}
|
||||
|
||||
function Ensure-TestLabDirectories {
|
||||
New-Item -ItemType Directory -Force -Path $GeneratedRoot, $ResultsRoot | Out-Null
|
||||
}
|
||||
|
||||
function Get-EnvDir {
|
||||
param([Parameter(Mandatory)][string]$Name)
|
||||
return Join-Path $GeneratedRoot $Name
|
||||
}
|
||||
|
||||
function Get-ResultFile {
|
||||
param([Parameter(Mandatory)][string]$Name)
|
||||
return Join-Path $ResultsRoot "$Name.json"
|
||||
}
|
||||
|
||||
function Write-ComposeFile {
|
||||
param([Parameter(Mandatory)]$Environment)
|
||||
|
||||
Ensure-TestLabDirectories
|
||||
$envDir = Get-EnvDir $Environment.name
|
||||
New-Item -ItemType Directory -Force -Path $envDir | Out-Null
|
||||
|
||||
$pluginPath = Convert-ToComposePath $PluginSource
|
||||
$compose = @"
|
||||
services:
|
||||
db:
|
||||
image: $($Environment.dbImage)
|
||||
environment:
|
||||
MYSQL_DATABASE: wordpress
|
||||
MYSQL_USER: wordpress
|
||||
MYSQL_PASSWORD: wordpress
|
||||
MYSQL_ROOT_PASSWORD: rootpass
|
||||
healthcheck:
|
||||
test: ["CMD", "mariadb-admin", "ping", "-h", "localhost", "-uroot", "-prootpass"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 30
|
||||
volumes:
|
||||
- db_data:/var/lib/mysql
|
||||
|
||||
wordpress:
|
||||
image: $($Environment.wordpressImage)
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "$($Environment.hostPort):80"
|
||||
environment:
|
||||
WORDPRESS_DB_HOST: db:3306
|
||||
WORDPRESS_DB_USER: wordpress
|
||||
WORDPRESS_DB_PASSWORD: wordpress
|
||||
WORDPRESS_DB_NAME: wordpress
|
||||
WORDPRESS_DEBUG: "1"
|
||||
volumes:
|
||||
- wp_data:/var/www/html
|
||||
- ${pluginPath}:/var/www/html/wp-content/plugins/$PluginSlug
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
wp_data:
|
||||
"@
|
||||
Set-Content -LiteralPath (Join-Path $envDir 'compose.yml') -Value $compose -Encoding UTF8
|
||||
}
|
||||
|
||||
function Invoke-Compose {
|
||||
param(
|
||||
[Parameter(Mandatory)]$Environment,
|
||||
[Parameter(Mandatory)][string[]]$Arguments
|
||||
)
|
||||
$envDir = Get-EnvDir $Environment.name
|
||||
docker compose -p "wptest-$($Environment.name)" -f (Join-Path $envDir 'compose.yml') @Arguments
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "docker compose failed with exit code ${LASTEXITCODE}: $($Arguments -join ' ')"
|
||||
}
|
||||
}
|
||||
|
||||
function Invoke-WpCli {
|
||||
param(
|
||||
[Parameter(Mandatory)]$Environment,
|
||||
[Parameter(Mandatory)][string]$Command
|
||||
)
|
||||
Invoke-Compose $Environment @('exec', '-T', '-u', '33', 'wordpress', 'bash', '-lc', $Command)
|
||||
}
|
||||
|
||||
function Invoke-WpCliRoot {
|
||||
param(
|
||||
[Parameter(Mandatory)]$Environment,
|
||||
[Parameter(Mandatory)][string]$Command
|
||||
)
|
||||
Invoke-Compose $Environment @('exec', '-T', 'wordpress', 'bash', '-lc', $Command)
|
||||
}
|
||||
|
||||
function Write-ContainerPhpFile {
|
||||
param(
|
||||
[Parameter(Mandatory)]$Environment,
|
||||
[Parameter(Mandatory)][string]$ContainerPath,
|
||||
[Parameter(Mandatory)][string]$Content
|
||||
)
|
||||
$encoded = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Content))
|
||||
Invoke-WpCliRoot $Environment "rm -f '$ContainerPath' && printf '%s' '$encoded' | base64 -d > '$ContainerPath' && chown www-data:www-data '$ContainerPath'" | Out-Null
|
||||
}
|
||||
|
||||
function Write-ContainerTextFile {
|
||||
param(
|
||||
[Parameter(Mandatory)]$Environment,
|
||||
[Parameter(Mandatory)][string]$ContainerPath,
|
||||
[Parameter(Mandatory)][string]$Content,
|
||||
[string]$Mode = '0644'
|
||||
)
|
||||
$encoded = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($Content))
|
||||
Invoke-WpCliRoot $Environment "rm -f '$ContainerPath' && printf '%s' '$encoded' | base64 -d > '$ContainerPath' && chmod '$Mode' '$ContainerPath' && chown www-data:www-data '$ContainerPath'" | Out-Null
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
. "$PSScriptRoot\common.ps1"
|
||||
|
||||
foreach ($environment in Get-TestLabEnvironments) {
|
||||
Write-Host "=== Removing $($environment.name) ==="
|
||||
& "$PSScriptRoot\down-env.ps1" -Env $environment.name
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$Env
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\common.ps1"
|
||||
|
||||
$environment = Get-TestLabEnvironment -Name $Env
|
||||
Write-ComposeFile -Environment $environment
|
||||
Invoke-Compose $environment @('down', '-v', '--remove-orphans') | Out-Host
|
||||
@@ -0,0 +1,9 @@
|
||||
. "$PSScriptRoot\common.ps1"
|
||||
|
||||
$environments = Get-TestLabEnvironments
|
||||
foreach ($environment in $environments) {
|
||||
$name = [string]$environment.name
|
||||
Write-Host ""
|
||||
Write-Host "=== Running $name ==="
|
||||
& "$PSScriptRoot\run-env.ps1" -Env $name
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$Env
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\common.ps1"
|
||||
|
||||
$environment = Get-TestLabEnvironment -Name $Env
|
||||
Write-ComposeFile -Environment $environment
|
||||
|
||||
$result = [ordered]@{
|
||||
environment = $environment.name
|
||||
wordpressImage = $environment.wordpressImage
|
||||
dbImage = $environment.dbImage
|
||||
hostPort = $environment.hostPort
|
||||
startedAt = (Get-Date).ToString('o')
|
||||
checks = @()
|
||||
}
|
||||
|
||||
function Add-Check {
|
||||
param([string]$Name, [bool]$Passed, [string]$Detail = '')
|
||||
$script:result.checks += [ordered]@{ name = $Name; passed = $Passed; detail = $Detail }
|
||||
if ($Passed) {
|
||||
Write-Host "[PASS] $Name $Detail"
|
||||
} else {
|
||||
Write-Host "[FAIL] $Name $Detail"
|
||||
throw "Check failed: $Name $Detail"
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Invoke-Compose $environment @('up', '-d') | Out-Host
|
||||
|
||||
$wpCli = 'if ! command -v wp >/dev/null 2>&1; then curl -fsSL https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o /usr/local/bin/wp && chmod +x /usr/local/bin/wp; fi'
|
||||
Invoke-WpCliRoot $environment $wpCli | Out-Host
|
||||
Add-Check 'wp-cli available' $true
|
||||
|
||||
if ($environment.PSObject.Properties.Name -contains 'wordpressVersion' -and $environment.wordpressVersion) {
|
||||
Invoke-WpCli $environment "wp core download --version=$($environment.wordpressVersion) --force --path=/var/www/html" | Out-Host
|
||||
Add-Check 'wordpress core version prepared' $true "target=$($environment.wordpressVersion)"
|
||||
}
|
||||
|
||||
$installScript = @'
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
for i in $(seq 1 40); do
|
||||
if wp core is-installed --path=/var/www/html >/dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
if wp core install --path=/var/www/html --url=http://localhost:__HOST_PORT__ --title=PluginTest --admin_user=admin --admin_password=adminpass --admin_email=admin@example.test --skip-email; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 3
|
||||
done
|
||||
exit 1
|
||||
'@ -replace '__HOST_PORT__', [string]$environment.hostPort
|
||||
Write-ContainerTextFile $environment '/tmp/brt-install.sh' $installScript '0755'
|
||||
Invoke-WpCli $environment 'bash /tmp/brt-install.sh' | Out-Host
|
||||
$installed = (Invoke-WpCli $environment 'wp core is-installed --path=/var/www/html && echo installed' | Out-String).Trim()
|
||||
Add-Check 'wordpress installed' ($installed -eq 'installed') $installed
|
||||
|
||||
$phpVersion = (Invoke-WpCliRoot $environment "php -r 'echo PHP_VERSION;'" | Out-String).Trim()
|
||||
$wpVersion = (Invoke-WpCli $environment 'wp core version --path=/var/www/html' | Out-String).Trim()
|
||||
Add-Check 'runtime versions' $true "WP=$wpVersion PHP=$phpVersion"
|
||||
$result.phpVersion = $phpVersion
|
||||
$result.wordpressVersion = $wpVersion
|
||||
|
||||
Invoke-WpCli $environment "wp plugin activate $PluginSlug --path=/var/www/html" | Out-Host
|
||||
Add-Check 'plugin activated' $true
|
||||
|
||||
$pluginVersion = (Invoke-WpCli $environment "wp plugin get $PluginSlug --field=version --path=/var/www/html" | Out-String).Trim()
|
||||
Add-Check 'plugin version detected' ($pluginVersion -eq $ExpectedPluginVersion) "version=$pluginVersion"
|
||||
$result.pluginVersion = $pluginVersion
|
||||
|
||||
$tablePhp = @'
|
||||
<?php
|
||||
global $wpdb;
|
||||
echo $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->prefix . 'brt_verses'));
|
||||
'@
|
||||
Write-ContainerPhpFile $environment '/tmp/brt-table.php' $tablePhp
|
||||
$tableExists = (Invoke-WpCli $environment 'wp eval-file /tmp/brt-table.php --path=/var/www/html' | Out-String).Trim()
|
||||
Add-Check 'verse table created' ($tableExists -eq 'wp_brt_verses') $tableExists
|
||||
|
||||
$translationsToImport = @('WEB', 'KJV', 'ASV', 'YLT')
|
||||
foreach ($translationCode in $translationsToImport) {
|
||||
$importPhp = @"
|
||||
<?php
|
||||
`$plugin = new Bible_Reference_Tooltips();
|
||||
`$ref = new ReflectionClass(`$plugin);
|
||||
`$m = `$ref->getMethod('import_vpl_translation');
|
||||
`$m->setAccessible(true);
|
||||
`$count = `$m->invoke(`$plugin, '$translationCode', false);
|
||||
echo `$count;
|
||||
"@
|
||||
Write-ContainerPhpFile $environment '/tmp/brt-import.php' $importPhp
|
||||
$imported = (Invoke-WpCli $environment 'wp eval-file /tmp/brt-import.php --path=/var/www/html' | Out-String).Trim()
|
||||
$importNumberText = [regex]::Match($imported, '[\d,]+').Value -replace ',', ''
|
||||
$importNumber = if ($importNumberText) { [int]$importNumberText } else { 0 }
|
||||
Add-Check "$translationCode import completed" ($importNumber -gt 30000) $imported
|
||||
}
|
||||
Invoke-WpCli $environment "wp option patch update brt_settings translation WEB --path=/var/www/html" | Out-Host
|
||||
|
||||
$countPhp = @'
|
||||
<?php
|
||||
global $wpdb;
|
||||
$rows = $wpdb->get_results('SELECT translation, COUNT(*) row_count FROM ' . $wpdb->prefix . 'brt_verses GROUP BY translation ORDER BY translation', ARRAY_A);
|
||||
echo json_encode($rows);
|
||||
'@
|
||||
Write-ContainerPhpFile $environment '/tmp/brt-count.php' $countPhp
|
||||
$rowCount = (Invoke-WpCli $environment 'wp eval-file /tmp/brt-count.php --path=/var/www/html' | Out-String).Trim()
|
||||
Add-Check 'translation rows stored' ($rowCount -match 'WEB' -and $rowCount -match 'KJV' -and $rowCount -match 'ASV' -and $rowCount -match 'YLT') $rowCount
|
||||
|
||||
$bookCoveragePhp = @'
|
||||
<?php
|
||||
global $wpdb;
|
||||
$expected = ['GEN','EXO','LEV','NUM','DEU','JOS','JDG','RUT','1SA','2SA','1KI','2KI','1CH','2CH','EZR','NEH','EST','JOB','PSA','PRO','ECC','SNG','ISA','JER','LAM','EZK','DAN','HOS','JOL','AMO','OBA','JON','MIC','NAM','HAB','ZEP','HAG','ZEC','MAL','MAT','MRK','LUK','JHN','ACT','ROM','1CO','2CO','GAL','EPH','PHP','COL','1TH','2TH','1TI','2TI','TIT','PHM','HEB','JAS','1PE','2PE','1JN','2JN','3JN','JUD','REV'];
|
||||
$translations = ['WEB','KJV','ASV','YLT'];
|
||||
$missing = [];
|
||||
foreach ($translations as $translation) {
|
||||
$found = $wpdb->get_col($wpdb->prepare('SELECT DISTINCT book FROM ' . $wpdb->prefix . 'brt_verses WHERE translation = %s', $translation));
|
||||
$diff = array_values(array_diff($expected, $found));
|
||||
if ($diff) $missing[$translation] = $diff;
|
||||
}
|
||||
echo $missing ? json_encode($missing) : 'ok';
|
||||
'@
|
||||
Write-ContainerPhpFile $environment '/tmp/brt-book-coverage.php' $bookCoveragePhp
|
||||
$bookCoverage = (Invoke-WpCli $environment 'wp eval-file /tmp/brt-book-coverage.php --path=/var/www/html' | Out-String).Trim()
|
||||
Add-Check 'canonical book coverage' ($bookCoverage -eq 'ok') $bookCoverage
|
||||
|
||||
$refs = @('John 3:16', 'John 3.16', 'Jn3:16', 'Romans 8:28', 'James 1:5', 'Mark 10:45', 'Mark10:45', 'Mk 10:45', 'Ezekiel 36:26', 'Eze 36:26', '2 John 1:6', '2Jn1:6', '2 Jo 1:6')
|
||||
foreach ($ref in $refs) {
|
||||
$lookupPhp = @"
|
||||
<?php
|
||||
`$request = new WP_REST_Request('GET', '/bible-reference-tooltips/v1/lookup');
|
||||
`$request->set_param('ref', '$ref');
|
||||
`$request->set_param('translation', 'WEB');
|
||||
`$response = rest_do_request(`$request);
|
||||
`$data = `$response->get_data();
|
||||
echo (!empty(`$data['ok']) && !empty(`$data['verses'])) ? 'ok' : json_encode(`$data);
|
||||
"@
|
||||
Write-ContainerPhpFile $environment '/tmp/brt-lookup.php' $lookupPhp
|
||||
$lookupResult = (Invoke-WpCli $environment 'wp eval-file /tmp/brt-lookup.php --path=/var/www/html' | Out-String).Trim()
|
||||
Add-Check "REST lookup $ref" ($lookupResult -eq 'ok') $lookupResult
|
||||
}
|
||||
|
||||
Invoke-WpCli $environment "wp post create --post_type=post --post_status=publish --post_title='Bible Reference Tooltip Smoke Test' --post_content='John 3:16 Romans 8:28 James 1:5' --path=/var/www/html" | Out-Host
|
||||
Add-Check 'test post created' $true
|
||||
|
||||
$result.completedAt = (Get-Date).ToString('o')
|
||||
$result.passed = $true
|
||||
} catch {
|
||||
$result.completedAt = (Get-Date).ToString('o')
|
||||
$result.passed = $false
|
||||
$result.error = $_.Exception.Message
|
||||
throw
|
||||
} finally {
|
||||
Ensure-TestLabDirectories
|
||||
$result | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Get-ResultFile -Name $environment.name) -Encoding UTF8
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
. "$PSScriptRoot\common.ps1"
|
||||
|
||||
$envs = Get-Content -LiteralPath $ConfigPath -Raw | ConvertFrom-Json
|
||||
foreach ($environment in $envs) {
|
||||
$name = [string]$environment.name
|
||||
Write-Host ""
|
||||
Write-Host "=== Seeding $name ==="
|
||||
& "$PSScriptRoot\seed-bible-reference-page.ps1" -Env $name
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
param(
|
||||
[Parameter(Mandatory)][string]$Env
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\common.ps1"
|
||||
|
||||
$environment = Get-TestLabEnvironment -Name $Env
|
||||
|
||||
$seedPhp = @'
|
||||
<?php
|
||||
$books = [
|
||||
['Genesis', 'Gen', 'Genesis 1:1', 'Gen 1:1'],
|
||||
['Exodus', 'Exod', 'Exodus 3:14', 'Exod 3:14'],
|
||||
['Leviticus', 'Lev', 'Leviticus 19:18', 'Lev 19:18'],
|
||||
['Numbers', 'Num', 'Numbers 6:24', 'Num 6:24'],
|
||||
['Deuteronomy', 'Deut', 'Deuteronomy 6:5', 'Deut 6:5'],
|
||||
['Joshua', 'Josh', 'Joshua 1:9', 'Josh 1:9'],
|
||||
['Judges', 'Judg', 'Judges 6:12', 'Judg 6:12'],
|
||||
['Ruth', 'Ruth', 'Ruth 1:16', 'Ruth 1:16'],
|
||||
['1 Samuel', '1 Sam', '1 Samuel 16:7', '1 Sam 16:7'],
|
||||
['2 Samuel', '2 Sam', '2 Samuel 7:22', '2 Sam 7:22'],
|
||||
['1 Kings', '1 Kgs', '1 Kings 8:27', '1 Kgs 8:27'],
|
||||
['2 Kings', '2 Kgs', '2 Kings 6:17', '2 Kgs 6:17'],
|
||||
['1 Chronicles', '1 Chr', '1 Chronicles 16:34', '1 Chr 16:34'],
|
||||
['2 Chronicles', '2 Chr', '2 Chronicles 7:14', '2 Chr 7:14'],
|
||||
['Ezra', 'Ezra', 'Ezra 7:10', 'Ezra 7:10'],
|
||||
['Nehemiah', 'Neh', 'Nehemiah 8:10', 'Neh 8:10'],
|
||||
['Esther', 'Esth', 'Esther 4:14', 'Esth 4:14'],
|
||||
['Job', 'Job', 'Job 19:25', 'Job 19:25'],
|
||||
['Psalms', 'Ps', 'Psalms 23:1', 'Ps 23:1'],
|
||||
['Proverbs', 'Prov', 'Proverbs 3:5', 'Prov 3:5'],
|
||||
['Ecclesiastes', 'Eccl', 'Ecclesiastes 3:1', 'Eccl 3:1'],
|
||||
['Song of Solomon', 'Song', 'Song of Solomon 2:4', 'Song 2:4'],
|
||||
['Isaiah', 'Isa', 'Isaiah 40:31', 'Isa 40:31'],
|
||||
['Jeremiah', 'Jer', 'Jeremiah 29:11', 'Jer 29:11'],
|
||||
['Lamentations', 'Lam', 'Lamentations 3:22', 'Lam 3:22'],
|
||||
['Ezekiel', 'Ezek', 'Ezekiel 36:26', 'Ezek 36:26'],
|
||||
['Daniel', 'Dan', 'Daniel 3:17', 'Dan 3:17'],
|
||||
['Hosea', 'Hos', 'Hosea 6:3', 'Hos 6:3'],
|
||||
['Joel', 'Joel', 'Joel 2:28', 'Joel 2:28'],
|
||||
['Amos', 'Amos', 'Amos 5:24', 'Amos 5:24'],
|
||||
['Obadiah', 'Obad', 'Obadiah 1:15', 'Obad 1:15'],
|
||||
['Jonah', 'Jonah', 'Jonah 2:2', 'Jonah 2:2'],
|
||||
['Micah', 'Mic', 'Micah 6:8', 'Mic 6:8'],
|
||||
['Nahum', 'Nah', 'Nahum 1:7', 'Nah 1:7'],
|
||||
['Habakkuk', 'Hab', 'Habakkuk 2:4', 'Hab 2:4'],
|
||||
['Zephaniah', 'Zeph', 'Zephaniah 3:17', 'Zeph 3:17'],
|
||||
['Haggai', 'Hag', 'Haggai 2:9', 'Hag 2:9'],
|
||||
['Zechariah', 'Zech', 'Zechariah 4:6', 'Zech 4:6'],
|
||||
['Malachi', 'Mal', 'Malachi 3:10', 'Mal 3:10'],
|
||||
['Matthew', 'Matt', 'Matthew 5:16', 'Matt 5:16'],
|
||||
['Mark', 'Mk', 'Mark 10:45', 'Mk 10:45'],
|
||||
['Luke', 'Lk', 'Luke 2:10', 'Lk 2:10'],
|
||||
['John', 'Jn', 'John 3:16', 'Jn 3:16'],
|
||||
['Acts', 'Acts', 'Acts 1:8', 'Acts 1:8'],
|
||||
['Romans', 'Rom', 'Romans 8:28', 'Rom 8:28'],
|
||||
['1 Corinthians', '1 Cor', '1 Corinthians 13:4', '1 Cor 13:4'],
|
||||
['2 Corinthians', '2 Cor', '2 Corinthians 5:17', '2 Cor 5:17'],
|
||||
['Galatians', 'Gal', 'Galatians 5:22', 'Gal 5:22'],
|
||||
['Ephesians', 'Eph', 'Ephesians 2:8', 'Eph 2:8'],
|
||||
['Philippians', 'Phil', 'Philippians 4:13', 'Phil 4:13'],
|
||||
['Colossians', 'Col', 'Colossians 3:23', 'Col 3:23'],
|
||||
['1 Thessalonians', '1 Thess', '1 Thessalonians 5:16', '1 Thess 5:16'],
|
||||
['2 Thessalonians', '2 Thess', '2 Thessalonians 3:3', '2 Thess 3:3'],
|
||||
['1 Timothy', '1 Tim', '1 Timothy 4:12', '1 Tim 4:12'],
|
||||
['2 Timothy', '2 Tim', '2 Timothy 1:7', '2 Tim 1:7'],
|
||||
['Titus', 'Titus', 'Titus 2:11', 'Titus 2:11'],
|
||||
['Philemon', 'Phlm', 'Philemon 1:6', 'Phlm 1:6'],
|
||||
['Hebrews', 'Heb', 'Hebrews 11:1', 'Heb 11:1'],
|
||||
['James', 'Jas', 'James 1:5', 'Jas 1:5'],
|
||||
['1 Peter', '1 Pet', '1 Peter 5:7', '1 Pet 5:7'],
|
||||
['2 Peter', '2 Pet', '2 Peter 3:9', '2 Pet 3:9'],
|
||||
['1 John', '1 Jn', '1 John 1:9', '1 Jn 1:9'],
|
||||
['2 John', '2 Jn', '2 John 1:6', '2 Jn 1:6'],
|
||||
['3 John', '3 Jn', '3 John 1:4', '3 Jn 1:4'],
|
||||
['Jude', 'Jude', 'Jude 1:24', 'Jude 1:24'],
|
||||
['Revelation', 'Rev', 'Revelation 21:4', 'Rev 21:4'],
|
||||
];
|
||||
|
||||
$translations = [
|
||||
['WEB', 'World English Bible'],
|
||||
['KJV', 'King James Version'],
|
||||
['ASV', 'American Standard Version'],
|
||||
['YLT', 'Young\'s Literal Translation'],
|
||||
];
|
||||
|
||||
$content = '<div class="brt-test-page">';
|
||||
$content .= '<style>.brt-test-page{box-sizing:border-box;width:min(1520px,calc(100vw - 120px));max-width:none;margin-left:50%;transform:translateX(-50%);font-family:system-ui,-apple-system,Segoe UI,sans-serif}.brt-test-page *{box-sizing:border-box}.brt-test-page p{max-width:760px;margin:0 0 18px;color:#4b5563}.brt-test-grid{display:grid;grid-template-columns:minmax(120px,.65fr) repeat(4,minmax(130px,1fr));border:1px solid #d7dee8;border-bottom:0;border-right:0;background:#fff}.brt-test-row{display:contents}.brt-test-head,.brt-test-book,.brt-test-cell{border-right:1px solid #d7dee8;border-bottom:1px solid #d7dee8;padding:10px 12px}.brt-test-head{position:sticky;top:0;z-index:1;background:#f3f6fa;font-weight:800}.brt-test-book{font-weight:800;background:#fff}.brt-test-cell{min-width:0}.brt-test-cell .ref-pair{display:flex;flex-direction:column;align-items:flex-start;gap:6px}.brt-test-cell a{display:inline-block;max-width:100%;font-weight:700;line-height:1.25;white-space:normal;overflow-wrap:anywhere}@media(max-width:980px){.brt-test-page{width:min(100%,calc(100vw - 36px))}.brt-test-grid{display:block;border:0}.brt-test-head{display:none}.brt-test-row{display:grid;grid-template-columns:1fr;border:1px solid #d7dee8;margin:0 0 12px}.brt-test-book{background:#f3f6fa}.brt-test-cell{display:grid;grid-template-columns:54px 1fr;gap:10px}.brt-test-cell:before{content:attr(data-version);font-weight:800;color:#4b5563}}}</style>';
|
||||
$content .= '<p>This page intentionally includes one full-name and one abbreviated Bible reference for every book of the Bible across all installed local translations.</p>';
|
||||
$content .= '<div class="brt-test-grid">';
|
||||
$content .= '<div class="brt-test-head">Book</div>';
|
||||
foreach ($translations as $translation) {
|
||||
$content .= '<div class="brt-test-head">' . esc_html($translation[0]) . '</div>';
|
||||
}
|
||||
foreach ($books as $book) {
|
||||
[$name, $abbr, $fullRef, $abbrRef] = $book;
|
||||
$content .= '<div class="brt-test-row">';
|
||||
$content .= '<div class="brt-test-book">' . esc_html($name) . '</div>';
|
||||
foreach ($translations as $translation) {
|
||||
[$code, $label] = $translation;
|
||||
$content .= '<div class="brt-test-cell" data-version="' . esc_attr($code) . '"><div class="ref-pair">';
|
||||
$content .= '<span>' . esc_html($fullRef) . '</span>';
|
||||
$content .= '<span>' . esc_html($abbrRef) . '</span>';
|
||||
$content .= '</div></div>';
|
||||
}
|
||||
$content .= '</div>';
|
||||
}
|
||||
$content .= '</div></div>';
|
||||
|
||||
$existing = get_page_by_path('bible-reference-tooltip-test');
|
||||
$post_data = [
|
||||
'post_title' => 'Bible Reference Tooltip Test',
|
||||
'post_name' => 'bible-reference-tooltip-test',
|
||||
'post_type' => 'page',
|
||||
'post_status' => 'publish',
|
||||
'post_content' => $content,
|
||||
];
|
||||
|
||||
if ($existing) {
|
||||
$post_data['ID'] = $existing->ID;
|
||||
$page_id = wp_update_post($post_data, true);
|
||||
} else {
|
||||
$page_id = wp_insert_post($post_data, true);
|
||||
}
|
||||
|
||||
if (is_wp_error($page_id)) {
|
||||
fwrite(STDERR, $page_id->get_error_message());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
update_option('show_on_front', 'page');
|
||||
update_option('page_on_front', (int) $page_id);
|
||||
$settings = get_option('brt_settings', []);
|
||||
if (is_array($settings)) {
|
||||
$settings['translation'] = $settings['translation'] ?? 'WEB';
|
||||
update_option('brt_settings', $settings, false);
|
||||
}
|
||||
echo 'seeded front page ' . $page_id . ' with ' . count($books) . ' books, ' . count($translations) . ' translations, and ' . (count($books) * count($translations) * 2) . ' reference links';
|
||||
'@
|
||||
|
||||
Write-ContainerPhpFile $environment '/tmp/brt-seed-front.php' $seedPhp
|
||||
Invoke-WpCli $environment 'wp eval-file /tmp/brt-seed-front.php --path=/var/www/html' | Out-Host
|
||||
Reference in New Issue
Block a user