+ ADD CI/CD
This commit is contained in:
54
.gitea/workflows/cd.yaml
Normal file
54
.gitea/workflows/cd.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
env:
|
||||
NAMESPACE: ${{ github.repository_owner }}
|
||||
DOCKER_REGISTRY: ghcr.io
|
||||
DOCKER_REPOSITORY: ${{ github.repository }}
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
env:
|
||||
IMAGE: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install kpack-cli
|
||||
env:
|
||||
KPACK_CLI_VERSION: 0.13.0
|
||||
KPACK_CLI_SHA256: 52f0c927a1350f4f1bb281575ec246f406fb96aa69dc974ed10a2fe52c538158
|
||||
working-directory: /tmp
|
||||
run: |
|
||||
set -ex
|
||||
curl -sLO "https://github.com/buildpacks-community/kpack-cli/releases/download/v${KPACK_CLI_VERSION}/kp-linux-amd64-${KPACK_CLI_VERSION}"
|
||||
echo "${KPACK_CLI_SHA256} kp-linux-amd64-${KPACK_CLI_VERSION}" | sha256sum --check || exit 1
|
||||
sudo mv kp-linux-amd64-${KPACK_CLI_VERSION} /usr/local/bin/kp
|
||||
sudo chmod +x /usr/local/bin/kp
|
||||
kp version
|
||||
- name: Install kubectl
|
||||
uses: azure/setup-kubectl@v4
|
||||
- name: Configure kubectl
|
||||
uses: azure/k8s-set-context@v1
|
||||
with:
|
||||
kubeconfig: ${{ secrets.KUBE_CONFIG }}
|
||||
- name: Update kpack image
|
||||
env:
|
||||
SHA: ${{ github.sha }}
|
||||
run: |
|
||||
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV
|
||||
IMAGE_NAME="${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}-${GITHUB_REF##*/}"
|
||||
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
|
||||
kp image patch $IMAGE_NAME --replace-additional-tag "${IMAGE}:sha-${SHORT_SHA}" --git-revision "${SHA}" -n $NAMESPACE
|
||||
kp image status $IMAGE_NAME -n $NAMESPACE
|
||||
- name: Wait for build to complete
|
||||
run: |
|
||||
BUILD=$(kubectl -n $NAMESPACE get image $IMAGE_NAME -o jsonpath='{.status.buildCounter}')
|
||||
BUILD_REF=$(kubectl -n $NAMESPACE get image $IMAGE_NAME -o jsonpath='{.status.latestBuildRef}')
|
||||
kp build logs $IMAGE_NAME -n $NAMESPACE --build ${BUILD}
|
||||
kp build status $IMAGE_NAME -n $NAMESPACE -b $BUILD
|
||||
if [ "$(kubectl -n $NAMESPACE get build $BUILD_REF -o jsonpath='{.status.conditions[0].status}')" != "True" ]; then exit 1; fi
|
||||
# - name: Update Kubernetes deployment
|
||||
# run: |
|
||||
# kubectl set image deployment/my-app my-app=<registry>/<repository>:${{ github.sha }}
|
||||
70
.github/workflows/cicd.yaml
vendored
Normal file
70
.github/workflows/cicd.yaml
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
|
||||
env:
|
||||
DESCRIPTION: "Wordpress Heroku App Image https://hvgblog.hu"
|
||||
PHP_VERSION: 8.3
|
||||
|
||||
jobs:
|
||||
|
||||
check:
|
||||
name: Check
|
||||
runs-on: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: editorconfig-checker/action-editorconfig-checker@main
|
||||
- name: EditorConfig Check
|
||||
run: editorconfig-checker
|
||||
- name: ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
- name: PHP security check
|
||||
uses: symfonycorp/security-checker-action@v5
|
||||
|
||||
test:
|
||||
name: Test
|
||||
needs: [check]
|
||||
runs-on: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: php-actions/composer@v6
|
||||
with:
|
||||
dev: yes
|
||||
args: --ignore-platform-reqs
|
||||
php_version: "${{ env.PHP_VERSION }}"
|
||||
- uses: php-actions/composer@v6
|
||||
with:
|
||||
command: outdate
|
||||
args: --strict --direct --ignore-platform-reqs
|
||||
php_version: "${{ env.PHP_VERSION }}"
|
||||
- uses: php-actions/composer@v6
|
||||
with:
|
||||
command: test
|
||||
php_version: "${{ env.PHP_VERSION }}"
|
||||
|
||||
image_build:
|
||||
name: Image Build
|
||||
needs: [check,test]
|
||||
runs-on: [ubuntu-latest]
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: felegy/mirror-action@master
|
||||
with:
|
||||
REMOTE: git@${{ secrets.DEPLOY_REPO }}:${{ github.repository }}.git
|
||||
SSH_CONFIG: |
|
||||
Host ${{ secrets.DEPLOY_REPO }}
|
||||
ProxyCommand cloudflared access ssh --hostname %h
|
||||
GIT_SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
GIT_SSH_NO_VERIFY_HOST: "true"
|
||||
16
.vscode/settings.json
vendored
Normal file
16
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"[php]": {
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "obliviousharmony.vscode-php-codesniffer"
|
||||
},
|
||||
"phpCodeSniffer.exclude": [
|
||||
"**/vendor/**",
|
||||
"web/wp",
|
||||
"web/app/languages/",
|
||||
"web/app/themes/hvg-blog-general/",
|
||||
"web/app/themes/twentytwentyfive/",
|
||||
"web/app/plugins/"
|
||||
],
|
||||
"phpCodeSniffer.autoloadPHPCSIntegration": true,
|
||||
"phpCodeSniffer.autoExecutable": true
|
||||
}
|
||||
@@ -22,7 +22,12 @@
|
||||
}
|
||||
],
|
||||
"keywords": [
|
||||
"bedrock", "composer", "roots", "wordpress", "wp", "wp-config"
|
||||
"bedrock",
|
||||
"composer",
|
||||
"roots",
|
||||
"wordpress",
|
||||
"wp",
|
||||
"wp-config"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/roots/bedrock/issues",
|
||||
@@ -32,11 +37,14 @@
|
||||
{
|
||||
"type": "composer",
|
||||
"url": "https://wpackagist.org",
|
||||
"only": ["wpackagist-plugin/*", "wpackagist-theme/*"]
|
||||
"only": [
|
||||
"wpackagist-plugin/*",
|
||||
"wpackagist-theme/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/hvg-dev/hvg-blog-general"
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/hvg-dev/hvg-blog-general"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
@@ -71,12 +79,11 @@
|
||||
"wpackagist-plugin/menu-image": "^3.13",
|
||||
"wpackagist-plugin/code-snippets": "^3.6",
|
||||
"wpackagist-plugin/saml-sso-wp-single-sign-on": "^1.4"
|
||||
|
||||
},
|
||||
"require-dev": {
|
||||
"heroku/heroku-buildpack-php": "*",
|
||||
"roave/security-advisories": "dev-latest",
|
||||
"laravel/pint": "^1.18"
|
||||
"squizlabs/php_codesniffer": "^3.7.1",
|
||||
"roave/security-advisories": "dev-latest"
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
@@ -90,15 +97,20 @@
|
||||
"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": {
|
||||
"project-init": "php -v",
|
||||
"lint": "pint --test",
|
||||
"lint:fix": "pint"
|
||||
"test": "phpcs",
|
||||
"project-init": "php -v"
|
||||
}
|
||||
}
|
||||
|
||||
184
composer.lock
generated
184
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "4d40ac4d8a55624c5dec818326c4321d",
|
||||
"content-hash": "1a96336bfff331f530d08dd3602518a1",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-crt-php",
|
||||
@@ -62,16 +62,16 @@
|
||||
},
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
"version": "3.356.4",
|
||||
"version": "3.356.7",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/aws/aws-sdk-php.git",
|
||||
"reference": "7bdc3c73897ae576f7d137dad70bddcd03bd4bd6"
|
||||
"reference": "6b44237a218485bf43a0015600aebf43cb726d4e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/7bdc3c73897ae576f7d137dad70bddcd03bd4bd6",
|
||||
"reference": "7bdc3c73897ae576f7d137dad70bddcd03bd4bd6",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/6b44237a218485bf43a0015600aebf43cb726d4e",
|
||||
"reference": "6b44237a218485bf43a0015600aebf43cb726d4e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -153,9 +153,9 @@
|
||||
"support": {
|
||||
"forum": "https://github.com/aws/aws-sdk-php/discussions",
|
||||
"issues": "https://github.com/aws/aws-sdk-php/issues",
|
||||
"source": "https://github.com/aws/aws-sdk-php/tree/3.356.4"
|
||||
"source": "https://github.com/aws/aws-sdk-php/tree/3.356.7"
|
||||
},
|
||||
"time": "2025-08-25T18:21:17+00:00"
|
||||
"time": "2025-08-28T18:14:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/installers",
|
||||
@@ -2245,87 +2245,18 @@
|
||||
},
|
||||
"time": "2025-07-31T20:24:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/pint",
|
||||
"version": "v1.24.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/pint.git",
|
||||
"reference": "0345f3b05f136801af8c339f9d16ef29e6b4df8a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/pint/zipball/0345f3b05f136801af8c339f9d16ef29e6b4df8a",
|
||||
"reference": "0345f3b05f136801af8c339f9d16ef29e6b4df8a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"ext-xml": "*",
|
||||
"php": "^8.2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.82.2",
|
||||
"illuminate/view": "^11.45.1",
|
||||
"larastan/larastan": "^3.5.0",
|
||||
"laravel-zero/framework": "^11.45.0",
|
||||
"mockery/mockery": "^1.6.12",
|
||||
"nunomaduro/termwind": "^2.3.1",
|
||||
"pestphp/pest": "^2.36.0"
|
||||
},
|
||||
"bin": [
|
||||
"builds/pint"
|
||||
],
|
||||
"type": "project",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"overrides/Runner/Parallel/ProcessFactory.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Seeders\\": "database/seeders/",
|
||||
"Database\\Factories\\": "database/factories/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nuno Maduro",
|
||||
"email": "enunomaduro@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "An opinionated code formatter for PHP.",
|
||||
"homepage": "https://laravel.com",
|
||||
"keywords": [
|
||||
"format",
|
||||
"formatter",
|
||||
"lint",
|
||||
"linter",
|
||||
"php"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/pint/issues",
|
||||
"source": "https://github.com/laravel/pint"
|
||||
},
|
||||
"time": "2025-07-10T18:09:32+00:00"
|
||||
},
|
||||
{
|
||||
"name": "roave/security-advisories",
|
||||
"version": "dev-latest",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Roave/SecurityAdvisories.git",
|
||||
"reference": "5e3e764a48c5ae5ac4e19f49434a7ac27e66929c"
|
||||
"reference": "1e6dd833087765a9aa80c5c0a6444f4521a63a79"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/5e3e764a48c5ae5ac4e19f49434a7ac27e66929c",
|
||||
"reference": "5e3e764a48c5ae5ac4e19f49434a7ac27e66929c",
|
||||
"url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/1e6dd833087765a9aa80c5c0a6444f4521a63a79",
|
||||
"reference": "1e6dd833087765a9aa80c5c0a6444f4521a63a79",
|
||||
"shasum": ""
|
||||
},
|
||||
"conflict": {
|
||||
@@ -2343,7 +2274,7 @@
|
||||
"airesvsg/acf-to-rest-api": "<=3.1",
|
||||
"akaunting/akaunting": "<2.1.13",
|
||||
"akeneo/pim-community-dev": "<5.0.119|>=6,<6.0.53",
|
||||
"alextselegidis/easyappointments": "<=1.5.1",
|
||||
"alextselegidis/easyappointments": "<1.5.2.0-beta1",
|
||||
"alterphp/easyadmin-extension-bundle": ">=1.2,<1.2.11|>=1.3,<1.3.1",
|
||||
"amazing/media2click": ">=1,<1.3.3",
|
||||
"ameos/ameos_tarteaucitron": "<1.2.23",
|
||||
@@ -2381,7 +2312,7 @@
|
||||
"backpack/crud": "<3.4.9",
|
||||
"backpack/filemanager": "<2.0.2|>=3,<3.0.9",
|
||||
"bacula-web/bacula-web": "<9.7.1",
|
||||
"badaso/core": "<2.7",
|
||||
"badaso/core": "<=2.9.11",
|
||||
"bagisto/bagisto": "<2.1",
|
||||
"barrelstrength/sprout-base-email": "<1.2.7",
|
||||
"barrelstrength/sprout-forms": "<3.9",
|
||||
@@ -2446,9 +2377,9 @@
|
||||
"concrete5/core": "<8.5.8|>=9,<9.1",
|
||||
"contao-components/mediaelement": ">=2.14.2,<2.21.1",
|
||||
"contao/comments-bundle": ">=2,<4.13.40|>=5.0.0.0-RC1-dev,<5.3.4",
|
||||
"contao/contao": ">=3,<3.5.37|>=4,<4.4.56|>=4.5,<4.9.40|>=4.10,<4.11.7|>=4.13,<4.13.21|>=5.1,<5.1.4",
|
||||
"contao/contao": ">=3,<3.5.37|>=4,<4.4.56|>=4.5,<4.13.56|>=5,<5.3.38|>=5.4.0.0-RC1-dev,<5.6.1",
|
||||
"contao/core": "<3.5.39",
|
||||
"contao/core-bundle": "<4.13.54|>=5,<5.3.30|>=5.4,<5.5.6",
|
||||
"contao/core-bundle": "<4.13.56|>=5,<5.3.38|>=5.4,<5.6.1",
|
||||
"contao/listing-bundle": ">=3,<=3.5.30|>=4,<4.4.8",
|
||||
"contao/managed-edition": "<=1.5",
|
||||
"corveda/phpsandbox": "<1.3.5",
|
||||
@@ -3001,6 +2932,7 @@
|
||||
"snipe/snipe-it": "<8.1",
|
||||
"socalnick/scn-social-auth": "<1.15.2",
|
||||
"socialiteproviders/steam": "<1.1",
|
||||
"solspace/craft-freeform": ">=5,<5.10.16",
|
||||
"soosyze/soosyze": "<=2",
|
||||
"spatie/browsershot": "<5.0.5",
|
||||
"spatie/image-optimizer": "<1.7.3",
|
||||
@@ -3276,7 +3208,91 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2025-08-25T23:05:33+00:00"
|
||||
"time": "2025-08-28T15:05:43+00:00"
|
||||
},
|
||||
{
|
||||
"name": "squizlabs/php_codesniffer",
|
||||
"version": "3.13.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
|
||||
"reference": "5b5e3821314f947dd040c70f7992a64eac89025c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c",
|
||||
"reference": "5b5e3821314f947dd040c70f7992a64eac89025c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-simplexml": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"php": ">=5.4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4"
|
||||
},
|
||||
"bin": [
|
||||
"bin/phpcbf",
|
||||
"bin/phpcs"
|
||||
],
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.x-dev"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Greg Sherwood",
|
||||
"role": "Former lead"
|
||||
},
|
||||
{
|
||||
"name": "Juliette Reinders Folmer",
|
||||
"role": "Current lead"
|
||||
},
|
||||
{
|
||||
"name": "Contributors",
|
||||
"homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors"
|
||||
}
|
||||
],
|
||||
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
|
||||
"homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
|
||||
"keywords": [
|
||||
"phpcs",
|
||||
"standards",
|
||||
"static analysis"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues",
|
||||
"security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy",
|
||||
"source": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
|
||||
"wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/PHPCSStandards",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/jrfnl",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://opencollective.com/php_codesniffer",
|
||||
"type": "open_collective"
|
||||
},
|
||||
{
|
||||
"url": "https://thanks.dev/u/gh/phpcsstandards",
|
||||
"type": "thanks_dev"
|
||||
}
|
||||
],
|
||||
"time": "2025-06-17T22:17:01+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
||||
26
phpcs.xml
Normal file
26
phpcs.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="hvgblog">
|
||||
|
||||
<!-- Scan all files in directory -->
|
||||
<file>.</file>
|
||||
|
||||
<!-- Scan only PHP files -->
|
||||
<arg name="extensions" value="php"/>
|
||||
|
||||
<!-- Ignore WordPress and Composer dependencies -->
|
||||
<exclude-pattern>web/wp</exclude-pattern>
|
||||
<exclude-pattern>web/app/languages/</exclude-pattern>
|
||||
<exclude-pattern>web/app/themes/hvg-blog-general/</exclude-pattern>
|
||||
<exclude-pattern>web/app/themes/twentytwentyfive/</exclude-pattern>
|
||||
<exclude-pattern>web/app/plugins/</exclude-pattern>
|
||||
<exclude-pattern>vendor/</exclude-pattern>
|
||||
|
||||
<!-- Show colors in console -->
|
||||
<arg value="-colors"/>
|
||||
|
||||
<!-- Show sniff codes in all reports -->
|
||||
<arg value="ns"/>
|
||||
|
||||
<!-- Use PSR-2 as a base -->
|
||||
<rule ref="PSR2"/>
|
||||
</ruleset>
|
||||
@@ -15,69 +15,72 @@
|
||||
* Author URI: https://github.com/felegy
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || die('Restricted Area');
|
||||
namespace App;
|
||||
|
||||
defined('ABSPATH') || die('Restricted Area');
|
||||
|
||||
class AppMuPlugin
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// Define constants
|
||||
$this->define_constants();
|
||||
$this->defineConstants();
|
||||
|
||||
if (defined('ERROR_LOG_TO_STDOUT')) {
|
||||
if (ERROR_LOG_TO_STDOUT) {
|
||||
// WP error log to stdout
|
||||
$this->error_log_to_stdout();
|
||||
$this->errorLogToStdout();
|
||||
}
|
||||
}
|
||||
if (defined('S3_UPLOADS_ENDPOINT')) {
|
||||
// Filter S3 Uploads params.
|
||||
$this->s3_uploads_endpoint();
|
||||
$this->s3UploadsEndpoint();
|
||||
}
|
||||
|
||||
if (defined('SMTP_ENABLED') && SMTP_ENABLED) {
|
||||
// If SMTP is enabled, setup PHPMailer
|
||||
if (defined('SMTP_SERVER') && defined('SMTP_PORT')) {
|
||||
$this->setup_phpmailer();
|
||||
$this->setupPhpMailer();
|
||||
}
|
||||
}
|
||||
|
||||
$this->header_security();
|
||||
$this->no_wordpress_errors();
|
||||
$this->sanitize_file_name();
|
||||
$this->remove_wp_version();
|
||||
$this->cc_mime_types();
|
||||
$this->two_factor_default();
|
||||
$this->on_logout_redirect();
|
||||
$this->headerSecurity();
|
||||
$this->noWordpressErrors();
|
||||
$this->sanitizeFileName();
|
||||
$this->removeWpVersion();
|
||||
$this->ccMimeTypes();
|
||||
$this->twoFactorDefault();
|
||||
$this->onLogoutRedirect();
|
||||
}
|
||||
|
||||
|
||||
private function define_constants() {
|
||||
private function defineConstants()
|
||||
{
|
||||
|
||||
if ( ! defined( 'SMTP_SERVER') ) {
|
||||
define( 'SMTP_SERVER', '127.0.0.1' );
|
||||
if (!defined('SMTP_SERVER')) {
|
||||
define('SMTP_SERVER', '127.0.0.1');
|
||||
}
|
||||
|
||||
if ( ! defined( 'SMTP_PORT') ) {
|
||||
define( 'SMTP_PORT', 1025 );
|
||||
if (!defined('SMTP_PORT')) {
|
||||
define('SMTP_PORT', 1025);
|
||||
}
|
||||
|
||||
if ( ! defined( 'BLOG_SLUG') ) {
|
||||
define( 'BLOG_SLUG', 'wp' );
|
||||
if (!defined('BLOG_SLUG')) {
|
||||
define('BLOG_SLUG', 'wp');
|
||||
}
|
||||
}
|
||||
|
||||
private function error_log_to_stdout() {
|
||||
private function errorLogToStdout()
|
||||
{
|
||||
// Add your initialization code here.
|
||||
// WP error log to stdout
|
||||
add_action('init', function () {
|
||||
ini_set ('error_log', '/dev/stdout'); // phpcs:ignore
|
||||
}, 10);
|
||||
|
||||
}
|
||||
|
||||
private function s3_uploads_endpoint() {
|
||||
private function s3UploadsEndpoint()
|
||||
{
|
||||
// Filter S3 Uploads params.
|
||||
add_filter('s3_uploads_s3_client_params', function ($params) {
|
||||
$params['endpoint'] = defined('S3_UPLOADS_ENDPOINT') ? S3_UPLOADS_ENDPOINT : "";
|
||||
@@ -87,33 +90,36 @@ class AppMuPlugin
|
||||
});
|
||||
}
|
||||
|
||||
private function header_security() {
|
||||
private function headerSecurity()
|
||||
{
|
||||
// Add Security headers.
|
||||
add_filter('wp_headers',
|
||||
function ($headers) {
|
||||
$headers['X-Frame-Options'] = 'SAMEORIGIN';
|
||||
$headers['X-Content-Type-Options'] = 'nosniff';
|
||||
$headers['X-XSS-Protection'] = '1; mode=block';
|
||||
$headers['Strict-Transport-Security'] = 'max-age=31536000; includeSubDomains';
|
||||
$headers['Referrer-Policy'] = 'same-origin';
|
||||
$headers['Permissions-Policy'] = 'geolocation=()';
|
||||
$headers['Content-Security-Policy'] = 'upgrade-insecure-requests';
|
||||
add_filter(
|
||||
'wp_headers',
|
||||
function ($headers) {
|
||||
$headers['X-Frame-Options'] = 'SAMEORIGIN';
|
||||
$headers['X-Content-Type-Options'] = 'nosniff';
|
||||
$headers['X-XSS-Protection'] = '1; mode=block';
|
||||
$headers['Strict-Transport-Security'] = 'max-age=31536000; includeSubDomains';
|
||||
$headers['Referrer-Policy'] = 'same-origin';
|
||||
$headers['Permissions-Policy'] = 'geolocation=()';
|
||||
$headers['Content-Security-Policy'] = 'upgrade-insecure-requests';
|
||||
|
||||
return $headers;
|
||||
});
|
||||
return $headers;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private function no_wordpress_errors()
|
||||
private function noWordpressErrors()
|
||||
{
|
||||
add_filter('login_errors', function () {
|
||||
return 'Hiba történt a belépés során!';
|
||||
});
|
||||
}
|
||||
|
||||
private function sanitize_file_name()
|
||||
private function sanitizeFileName()
|
||||
{
|
||||
// Clean file name when uploading files in WordPress.
|
||||
add_filter('sanitize_file_name', function ($filename){
|
||||
add_filter('sanitize_file_name', function ($filename) {
|
||||
$extension = substr($filename, strrpos($filename, '.') + 1);
|
||||
$filename = substr($filename, 0, strrpos($filename, '.'));
|
||||
|
||||
@@ -121,21 +127,23 @@ class AppMuPlugin
|
||||
});
|
||||
}
|
||||
|
||||
private function remove_wp_version() {
|
||||
private function removeWpVersion()
|
||||
{
|
||||
// Remove WordPress version from HTML source.
|
||||
add_filter('the_generator', '__return_empty_string');
|
||||
}
|
||||
|
||||
private function cc_mime_types() {
|
||||
private function ccMimeTypes()
|
||||
{
|
||||
// Add SVG to mime_types.
|
||||
add_filter('upload_mimes', function ($mimes)
|
||||
{
|
||||
add_filter('upload_mimes', function ($mimes) {
|
||||
$mimes['svg'] = 'image/svg+xml';
|
||||
return $mimes;
|
||||
});
|
||||
}
|
||||
|
||||
private function setup_phpmailer() {
|
||||
private function setupPhpMailer()
|
||||
{
|
||||
add_action('phpmailer_init', function ($phpmailer) {
|
||||
$phpmailer->Host = SMTP_SERVER;
|
||||
$phpmailer->Port = SMTP_PORT;
|
||||
@@ -161,10 +169,9 @@ class AppMuPlugin
|
||||
$phpmailer->SMTPSecure = false; // Disable encryption
|
||||
}
|
||||
|
||||
if(defined('SMTP_DOMAIN')) {
|
||||
if (defined('SMTP_DOMAIN')) {
|
||||
$phpmailer->From = BLOG_SLUG . '@' . SMTP_DOMAIN;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$dsn = (object) parse_url(get_bloginfo('url'));
|
||||
$phpmailer->From = BLOG_SLUG . '@' . $dsn->host;
|
||||
}
|
||||
@@ -175,9 +182,9 @@ class AppMuPlugin
|
||||
});
|
||||
}
|
||||
|
||||
private function two_factor_default() {
|
||||
add_filter('two_factor_providers', function ($providers)
|
||||
{
|
||||
private function twoFactorDefault()
|
||||
{
|
||||
add_filter('two_factor_providers', function ($providers) {
|
||||
// Disable FIDO U2F by default
|
||||
// ISSUE https://wordpress.org/support/topic/i-cant-add-my-yubikey/
|
||||
$providers['Two_Factor_FIDO_U2F'] = '';
|
||||
@@ -188,21 +195,19 @@ class AppMuPlugin
|
||||
|
||||
// Enable Two Factor Email by default
|
||||
// force email two factor authentication
|
||||
add_filter('two_factor_enabled_providers_for_user', function ($providers)
|
||||
{
|
||||
if (! in_array('Two_Factor_Email', $providers))
|
||||
{
|
||||
add_filter('two_factor_enabled_providers_for_user', function ($providers) {
|
||||
if (! in_array('Two_Factor_Email', $providers)) {
|
||||
array_push($providers, 'Two_Factor_Email');
|
||||
}
|
||||
return $providers;
|
||||
});
|
||||
}
|
||||
|
||||
private function on_logout_redirect() {
|
||||
add_action('wp_logout', function ()
|
||||
{
|
||||
private function onLogoutRedirect()
|
||||
{
|
||||
add_action('wp_logout', function () {
|
||||
if (defined('LOGOUT_REDIRECT_URL')) {
|
||||
wp_redirect( LOGOUT_REDIRECT_URL );
|
||||
wp_redirect(LOGOUT_REDIRECT_URL);
|
||||
exit;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user