Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources/scripts/account*
resources/scripts/auth*
resources/scripts/site*
15 changes: 15 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ],
"globals" : {
"App": "readonly",
"AuthData": "readonly",
"localStorage": "readonly",
"window": "readonly",
"location": "readonly"
},
"settings": {
"react": {
"version": "18.3.1"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Build application
name: Build & Deploy to main

on:
push:
branches: [ "main" ]

jobs:
web-deploy:
name: 🎉 Deploy to Mody Cloud
name: 🎉 Deploy to Mody Cloud - Main branch
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Verify Coding Standards

on:
pull_request:
branches:
- main
- dev

jobs:
web-deploy:
name: 🎉 Verify Coding Standards
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v3

- name: ACF Auth
run: |
cp sample-auth.json auth.json
sed -i 's|"ENTER YOUR LICENSE KEY"|"${{ secrets.ACF_AUTH }}"|g' auth.json
sed -i 's|"ENTER YOUR WEBSITE URL"|"${{ vars.SITE_URL }}"|g' auth.json
cat auth.json

- name: Cache Vendor
id: app-lint-cache-vendor
uses: actions/cache@v3
env:
cache-name: app-lint-cache-vendor
with:
path: vendor
key: app-vendor-${{ runner.os }}-${{ hashFiles('composer.lock') }}
restore-keys: |
app-lint-cache-vendor-${{ runner.os }}-

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Cache Node Modules
id: app-lint-cache-node_modules
uses: actions/cache@v3
env:
cache-name: app-lint-cache-node_modules
with:
path: node_modules
key: app-lint-cache-node_modules-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
app-lint-cache-node_modules-${{ runner.os }}-

- name: Composer Install
run: composer install
if: steps.app-lint-cache-vendor.outputs.cache-hit != 'true'

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: nvm use ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: pnpm install
run: pnpm install
if: steps.app-lint-cache-node_modules.outputs.cache-hit != 'true'

- name: lint
run: pnpm lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ web/content/uploads/*
!web/content/uploads/.gitkeep
web/content/cache/*
web/content/themes/cloud/dist
web/content/themes/cloud/blocks

# WordPress
web/wp
Expand Down
9 changes: 9 additions & 0 deletions .stylelint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('stylelint').Config} */
export default {
extends: "@wordpress/stylelint-config/scss",
rules: {
"unit-allowed-list": {
"line-height": ["px", "em", "rem", "unitless"]
}
}
};
10 changes: 6 additions & 4 deletions app/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@

class App
{
public static function start() : void {
public static function start(): void
{
self::loader(Config::get('APP_PATH') . '/Hooks/*.php', 'App\\Hooks\\');
}

public static function loader(string $path, string $namespace = 'App\\') : void {
foreach(glob($path) as $config_file) {
public static function loader(string $path, string $namespace = 'App\\'): void
{
foreach (glob($path) as $config_file) {
$class_name = $namespace;
$class_name .= basename($config_file, '.php');
if(method_exists($class_name, 'init')) {
if (method_exists($class_name, 'init')) {
$class_name::init();
}
}
Expand Down
5 changes: 5 additions & 0 deletions app/Features/Auth.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

namespace App\Features;

trait Auth {}
13 changes: 7 additions & 6 deletions app/Features/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace App\Features;

use Roots\WPConfig\Config;
use function Env\env;

trait Migrate {
public static function migrate() : void {
trait Migrate
{
public static function migrate(): void
{
$migration_files = glob(Config::get('MC_MIGRATIONS_PATH') . '/*.php');

app_log(print_r($migration_files,1));
app_log(print_r($migration_files, 1));
if (!$migration_files) {
return;
}
Expand All @@ -22,7 +23,7 @@ public static function migrate() : void {

$site_name = get_bloginfo();

if(!Config::get('CHILD_SITE')) {
if (!Config::get('CHILD_SITE')) {
return;
}

Expand Down Expand Up @@ -59,4 +60,4 @@ public static function migrate() : void {
}
}
}
}
}
20 changes: 11 additions & 9 deletions app/Features/Recaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@

use Roots\WPConfig\Config;

trait Recaptcha {
public static function validate_recaptcha() : void {
trait Recaptcha
{
public static function validate_recaptcha(): void
{
$recaptcha_token = $_POST['token'] ?? '';
$recaptcha_secret = Config::get('RECAPTCHA_SECRET');

if($recaptcha_secret && $recaptcha_token) {
$response = wp_remote_get(add_query_arg(array(
if ($recaptcha_secret && $recaptcha_token) {
$response = wp_remote_get(add_query_arg([
'secret' => $recaptcha_secret,
'response' => $recaptcha_token,
), 'https://www.google.com/recaptcha/api/siteverify'));
], 'https://www.google.com/recaptcha/api/siteverify'));
$body = wp_remote_retrieve_body($response);
$result = json_decode($body);

if (!$result->success || $result->score < 0.5) {
wp_send_json_error(
array(
[
'success' => false,
'message' => __('Incorrect email or password.', APP_THEME_LOCALE),
'result' => $result,
),
400
],
400,
);
}
}
}
}
}
51 changes: 46 additions & 5 deletions app/Hooks/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,59 @@
use App\Hooks\Account\Block;
use App\Hooks\Account\Service;
use App\Hooks\Account\Routes;
use App\Hooks\Account\Scripts;
use App\Hooks\User\Service as UserService;

class Account {
public static function init() : void {
class Account
{
public const LAST_UPDATE = 'Hipe|Po|Sonya|Simple';
public const ACCOUNT_PAGE_CONTENT = <<<EOF
<!-- wp:app/account-v2 -->
<p class="wp-block-app-account-v2">Example – hello from the saved content!</p>
<!-- /wp:app/account-v2 -->
EOF;

public static function init(): void
{
add_action('init', self::wp_init(...));
add_action('init', Routes::wp_init(...));
add_action('wp_enqueue_scripts', Scripts::wp_enqueue_scripts(...), 100);
add_action('rest_api_init', Api::register_rest_route(...));
add_action('rest_prepare_user', Service::rest_prepare_user(...), 10, 3);
add_action('delete_user', UserService::delete_user(...), 10, 3);

add_filter('query_vars', Routes::query_vars(...));
add_filter('app_before_render_block_profile', Block::app_before_render_block(...));
}
}

public static function wp_init(): void
{
$account_page_id = get_option('account_page_id');
$account_module_last_update = get_option('account_option_last_update');
if (! $account_page_id || $account_module_last_update !== self::LAST_UPDATE) {
if (!$account_page_id) {
$account_page_id = wp_insert_post([
'post_type' => 'page',
'post_title' => __('Account', APP_THEME_LOCALE),
'post_status' => 'publish',
'post_author' => 1,
'post_name' => 'account',
'post_content' => self::ACCOUNT_PAGE_CONTENT,
]);
}

wp_update_post([
'ID' => $account_page_id,
'post_content' => self::ACCOUNT_PAGE_CONTENT,
]);

$main_cta = [
'route' => '/invoices/new',
'title' => __('New invoice', 'app'),
];

update_post_meta($account_page_id, 'main_cta', $main_cta);

update_option('account_option_last_update', self::LAST_UPDATE);
update_option('account_page_id', $account_page_id);
}
}
}
Loading