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
63 changes: 63 additions & 0 deletions .github/workflows/WP_6_6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: WP 6.6 [PHP8.0-8.4] Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master, develop ]

jobs:
build:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']
runs-on: ${{ matrix.operating-system }}
services:
mysql-service:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: 'crab'
MYSQL_DATABASE: pc_core_tests
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect || mysqladmin ping -uroot -pcrab"
--health-interval=10s
--health-timeout=10s
--health-retries=10

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, pcov
ini-values: post_max_size=256M, log_errors=1
tools: pecl

- name: Check PHP Version
run: php -v

- name: Clear existing composer
run: >
sudo rm -rf vendor
&& rm -rf composer.lock
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: >
rm -rf composer.lock
&& composer clearcache
&& composer require php-stubs/wordpress-stubs:6.6.* --dev --no-update
&& composer require roots/wordpress:6.6.* --dev --no-update
&& composer require wp-phpunit/wp-phpunit:6.6.* --dev --no-update
&& composer update --no-cache

- name: Run Tests on WP6.6
env:
environment_github: true
run: composer all
63 changes: 63 additions & 0 deletions .github/workflows/WP_6_7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: WP 6.7 [PHP8.0-8.4] Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master, develop ]

jobs:
build:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']
runs-on: ${{ matrix.operating-system }}
services:
mysql-service:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: 'crab'
MYSQL_DATABASE: pc_core_tests
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect || mysqladmin ping -uroot -pcrab"
--health-interval=10s
--health-timeout=10s
--health-retries=10

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, pcov
ini-values: post_max_size=256M, log_errors=1
tools: pecl

- name: Check PHP Version
run: php -v

- name: Clear existing composer
run: >
sudo rm -rf vendor
&& rm -rf composer.lock
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: >
rm -rf composer.lock
&& composer clearcache
&& composer require php-stubs/wordpress-stubs:6.7.* --dev --no-update
&& composer require roots/wordpress:6.7.* --dev --no-update
&& composer require wp-phpunit/wp-phpunit:6.7.* --dev --no-update
&& composer update --no-cache

- name: Run Tests on WP6.7
env:
environment_github: true
run: composer all
63 changes: 63 additions & 0 deletions .github/workflows/WP_6_8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: WP 6.8 [PHP8.0-8.4] Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master, develop ]

jobs:
build:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']
runs-on: ${{ matrix.operating-system }}
services:
mysql-service:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: 'crab'
MYSQL_DATABASE: pc_core_tests
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect || mysqladmin ping -uroot -pcrab"
--health-interval=10s
--health-timeout=10s
--health-retries=10

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, pcov
ini-values: post_max_size=256M, log_errors=1
tools: pecl

- name: Check PHP Version
run: php -v

- name: Clear existing composer
run: >
sudo rm -rf vendor
&& rm -rf composer.lock
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: >
rm -rf composer.lock
&& composer clearcache
&& composer require php-stubs/wordpress-stubs:6.8.* --dev --no-update
&& composer require roots/wordpress:6.8.* --dev --no-update
&& composer require wp-phpunit/wp-phpunit:6.8.* --dev --no-update
&& composer update --no-cache

- name: Run Tests on WP6.8
env:
environment_github: true
run: composer all
70 changes: 70 additions & 0 deletions .github/workflows/WP_6_9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: WP 6.9 [PHP8.0-8.4] Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master, develop ]

jobs:
build:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']
runs-on: ${{ matrix.operating-system }}
services:
mysql-service:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: 'crab'
MYSQL_DATABASE: pc_core_tests
ports:
- 3306:3306
options: >-
--health-cmd="healthcheck.sh --connect || mysqladmin ping -uroot -pcrab"
--health-interval=10s
--health-timeout=10s
--health-retries=10

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, pcov
ini-values: post_max_size=256M, log_errors=1
tools: pecl

- name: Check PHP Version
run: php -v

- name: Clear existing composer
run: >
sudo rm -rf vendor
&& rm -rf composer.lock
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: >
rm -rf composer.lock
&& composer clearcache
&& composer require php-stubs/wordpress-stubs:6.9.* --dev --no-update
&& composer require roots/wordpress:6.9.* --dev --no-update
&& composer require wp-phpunit/wp-phpunit:6.9.* --dev --no-update
&& composer update --no-cache

- name: Run Tests on WP6.9
env:
environment_github: true
run: composer all

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.MOUNT_CODECOV }}
files: ./clover.xml
fail_ci_if_error: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ clover.xml
workspace.code-workspace
.phpunit.result.cache
.vscode
tests/.env
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 PinkCrab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 2 additions & 7 deletions src/Standard_Flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,15 @@ public function ajax_action(): string {
*/
protected function current_user(): ?array {
$user = \wp_get_current_user();
if ( ! $user || 0 === $user->ID ) {
if ( 0 === $user->ID ) {
return null;
}

$capabilities = array();
if ( is_array( $user->allcaps ) ) {
$capabilities = array_values( array_keys( array_filter( $user->allcaps ) ) );
}

return array(
'id' => (int) $user->ID,
'displayName' => (string) $user->display_name,
'roles' => array_values( (array) $user->roles ),
'capabilities' => $capabilities,
'capabilities' => array_keys( array_filter( $user->allcaps ) ),
);
}
}
8 changes: 8 additions & 0 deletions tests/.env_sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# WP Config Details

# Please ensure the database exists before running the tests

WP_DB_NAME=pc_core_tests
WP_DB_USER=root
WP_DB_PASS=
WP_DB_HOST=127.0.0.1
Loading