Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
63b4a2a
Add PHPUnit tests
aristath Oct 31, 2025
18208d4
more phpunit tests
aristath Oct 31, 2025
7ae059c
Add tests for UI classes
aristath Oct 31, 2025
34ceb00
Rename tests files
aristath Oct 31, 2025
e39e554
Add new tests for Suggested_Tasks classes
aristath Oct 31, 2025
d5e8a46
CS fix
aristath Oct 31, 2025
1796dc4
more tests
aristath Oct 31, 2025
1c6cc77
Merge branch 'develop' into ari/add-phpunit-tests-20251031
aristath Oct 31, 2025
742d9bc
More tests
aristath Oct 31, 2025
236b0c6
Many more phpunit tests
aristath Nov 3, 2025
7a70aa1
Add a code-coverage workflow
aristath Nov 3, 2025
56c0de7
Fix some failing tests
aristath Nov 3, 2025
4b0c2e9
Fix CI test failure: Make install-wp-tests.sh non-interactive
aristath Nov 3, 2025
90c6d8d
Fix NaN% coverage reporting
aristath Nov 3, 2025
ef47fa4
Fix coverage extraction and update comment behavior
aristath Nov 3, 2025
5f3a673
Fix coverage.xml path to use absolute path
aristath Nov 3, 2025
f42573d
Add debug logging for coverage extraction
aristath Nov 3, 2025
66afab7
Fix coverage.xml generation by calling PHPUnit directly
aristath Nov 3, 2025
0d138ba
Fix PHPUnit coverage configuration to use 'classes' directory
aristath Nov 3, 2025
690e451
Enable Xdebug coverage mode explicitly
aristath Nov 3, 2025
041d21b
Add recursive search for coverage.xml file
aristath Nov 3, 2025
8f022c8
Switch from Xdebug to PCOV for code coverage
aristath Nov 3, 2025
aeaed41
Add extensive debugging for coverage.xml generation
aristath Nov 3, 2025
e4535ce
Add PCOV debugging and explicit PHP configuration
aristath Nov 3, 2025
a4a96a0
Check for php-code-coverage library and improve debugging
aristath Nov 3, 2025
ac67ebd
Fix coverage generation by adding php-code-coverage library
aristath Nov 3, 2025
903c4eb
Bust composer cache and fix git checkout conflicts
aristath Nov 3, 2025
f27f975
Fix CodeCoverage class check and revert composer.json
aristath Nov 3, 2025
7c58c55
Configure PHPUnit to process uncovered files and disable strict cover…
aristath Nov 3, 2025
9d612d4
Update composer.lock file
aristath Nov 3, 2025
4899d23
Fix PHPStan issues
aristath Nov 3, 2025
b43c404
CS fixes
aristath Nov 3, 2025
07acec2
Remove invalid beStrictAboutCoverageMetadata attribute from phpunit.x…
aristath Nov 3, 2025
725a084
Use absolute path for pcov.directory in workflow
aristath Nov 3, 2025
93faefe
Remove --dont-report-useless-tests flag from PHPUnit coverage command
aristath Nov 3, 2025
e5a194e
Add extensive debugging for PHPUnit coverage generation
aristath Nov 3, 2025
891f95f
Trigger workflow
aristath Nov 3, 2025
55f53ab
Fix PHPUnit code coverage generation in GitHub Actions
aristath Nov 3, 2025
c668151
Fix coverage.xml generation by disabling processUncoveredFiles
aristath Nov 3, 2025
f166c78
Remove tail pipe that was hiding PHPUnit output and coverage generati…
aristath Nov 3, 2025
2cf155f
Add memory limit increase and comprehensive debugging for coverage ge…
aristath Nov 3, 2025
8744a96
Fix coverage generation by allowing PHPUnit to complete despite test …
aristath Nov 3, 2025
c6ad47a
Remove tee to get accurate PHPUnit exit code and full output
aristath Nov 3, 2025
0f0d3f6
Switch from PCOV to Xdebug for coverage generation
aristath Nov 3, 2025
f90818b
Add phpunit-output.log as artifact for debugging
aristath Nov 3, 2025
56eefb6
Implement grouped test coverage strategy to avoid segfaults
aristath Nov 3, 2025
6ace9d3
Fix test filtering to use class name regex instead of file paths
aristath Nov 3, 2025
5b9b949
Add proper @group annotations to all test files for long-term coverag…
aristath Nov 3, 2025
a0b393f
Split suggested-tasks groups into smaller subgroups to complete coverage
aristath Nov 3, 2025
0c14059
Fix coverage report merging using PHP script to parse Clover XML
aristath Nov 3, 2025
c63dc4d
Simplify PR comment and remove base branch comparison
aristath Nov 3, 2025
0ac84d9
Fix PHPUnit @group annotations placement
aristath Nov 3, 2025
8af3cab
Allow coverage workflow to continue even if some groups fail
aristath Nov 3, 2025
9b29abe
Fix coverage calculation to deduplicate files across test groups
aristath Nov 3, 2025
b8a744c
Add 'Code Coverage Check' job for coverage gate compatibility
aristath Nov 3, 2025
ea20e8e
Fix Coverage Gate to wait for workflow to start before checking
aristath Nov 3, 2025
501940c
Simplify Coverage Gate to use GitHub CLI polling
aristath Nov 3, 2025
08086c2
Move onboard test from utils to misc group to fix coverage
aristath Nov 3, 2025
5995a69
Exclude onboard test from grouped coverage runs
aristath Nov 3, 2025
cb21460
Fix coverage calculation to use union of covered lines
aristath Nov 3, 2025
242187c
Add missing test groups to coverage matrix
aristath Nov 3, 2025
0d3a320
Temporarily exclude security group from coverage
aristath Nov 3, 2025
327916c
revert tests changes
aristath Nov 4, 2025
0ef9e41
Replace grouped coverage with simple single-run coverage
aristath Nov 4, 2025
b29bcf3
Improve coverage PR comment format
aristath Nov 4, 2025
41b4331
Fix CI failure: auto-approve database recreation in CI
aristath Nov 4, 2025
b4761ab
Fix code coverage workflow to properly capture test output
aristath Nov 4, 2025
2b5c4c0
Fix security tests to properly handle WPDieException
aristath Nov 4, 2025
914b9ab
Isolate security tests with @runInSeparateProcess
aristath Nov 4, 2025
424e3f5
Add @coversNothing to tests using @runInSeparateProcess
aristath Nov 4, 2025
44995f5
Add class-level @coversNothing to Security_Test
aristath Nov 4, 2025
4e99f98
Exclude test-class-security.php from coverage to fix output leak
aristath Nov 4, 2025
5f2c817
Fix exclusion of security test file via phpunit.xml.dist
aristath Nov 4, 2025
131f356
Enhance coverage report with detailed file-level changes
aristath Nov 4, 2025
2eabc57
Fix coverage extraction to use summary line only
aristath Nov 4, 2025
0a7c79f
Wrap file-level coverage changes in collapsible details
aristath Nov 4, 2025
3032edf
Fix coverage parsing to properly capture class names
aristath Nov 4, 2025
9973f48
Fix regex pattern to match AWK output format
aristath Nov 4, 2025
1e6e976
Fix regex to capture Methods percentage correctly
aristath Nov 4, 2025
1c4e3fa
Fix regex group numbers after adding Methods capture
aristath Nov 4, 2025
9aa6985
Fix JSON interpolation in github-script action
aristath Nov 4, 2025
b9febf8
Remove file limits from coverage details display
aristath Nov 4, 2025
5540de8
cleanup
aristath Nov 4, 2025
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
456 changes: 456 additions & 0 deletions .github/workflows/code-coverage.yml

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions .github/workflows/coverage-status-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Coverage Status Check - DISABLED

on:
workflow_dispatch:

jobs:
coverage-gate:
name: Coverage Gate
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Wait for coverage check
timeout-minutes: 10
run: |
echo "Waiting for Code Coverage Check to complete..."

# Wait up to 10 minutes for the check to appear and complete
for i in {1..60}; do
# Get the status of the Code Coverage Check
STATUS=$(gh api repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/check-runs \
--jq '.check_runs[] | select(.name == "Code Coverage Check") | .status' || echo "")

CONCLUSION=$(gh api repos/${{ github.repository }}/commits/${{ github.event.pull_request.head.sha }}/check-runs \
--jq '.check_runs[] | select(.name == "Code Coverage Check") | .conclusion' || echo "")

if [ -n "$STATUS" ]; then
echo "Check found with status: $STATUS, conclusion: $CONCLUSION"

if [ "$STATUS" == "completed" ]; then
if [ "$CONCLUSION" == "success" ]; then
echo "✅ Code coverage check passed!"
exit 0
else
echo "❌ Code coverage check failed with conclusion: $CONCLUSION"
exit 1
fi
fi
else
echo "Check not found yet (attempt $i/60)"
fi

sleep 10
done

echo "❌ Timeout waiting for Code Coverage Check"
exit 1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Coverage gate passed
run: echo "✅ Code coverage requirements met!"
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Test](https://github.com/ProgressPlanner/progress-planner/actions/workflows/phpunit.yml/badge.svg)](https://github.com/ProgressPlanner/progress-planner/actions/workflows/phpunit.yml)
[![Code Coverage](https://github.com/ProgressPlanner/progress-planner/actions/workflows/code-coverage.yml/badge.svg)](https://github.com/ProgressPlanner/progress-planner/actions/workflows/code-coverage.yml)
[![CS](https://github.com/ProgressPlanner/progress-planner/actions/workflows/cs.yml/badge.svg)](https://github.com/ProgressPlanner/progress-planner/actions/workflows/cs.yml)
[![PHPStan](https://github.com/ProgressPlanner/progress-planner/actions/workflows/phpstan.yml/badge.svg)](https://github.com/ProgressPlanner/progress-planner/actions/workflows/phpstan.yml)
[![Lint](https://github.com/ProgressPlanner/progress-planner/actions/workflows/lint.yml/badge.svg)](https://github.com/ProgressPlanner/progress-planner/actions/workflows/lint.yml)
Expand All @@ -24,6 +25,39 @@ This post explains what Progress Planner does and how to use it: [What does Prog

You can find [installation instructions here](https://prpl.fyi/install).

## Contributing

### Running Tests

To run the test suite:

```bash
composer test
```

### Code Coverage

To generate code coverage reports locally, you need either [PCOV](https://pecl.php.net/package/PCOV) (recommended) or [Xdebug](https://xdebug.org/) installed:

```bash
composer coverage
```

This will generate:
- An HTML coverage report in the `coverage-html/` directory
- A text-based coverage summary in your terminal

**Coverage Requirements:** Pull requests must maintain code coverage within 0.5% of the base branch. PRs that drop coverage by more than 0.5% will be blocked until additional tests are added.

### Other Quality Commands

```bash
composer check-cs # Check coding standards
composer fix-cs # Auto-fix coding standards
composer phpstan # Run static analysis
composer lint # Check PHP syntax
```

## Branches on this repository

We use a couple of branches in this repository to keep things clean:
Expand Down
169 changes: 169 additions & 0 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#!/usr/bin/env bash

if [ $# -lt 3 ]; then
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
exit 1
fi

DB_NAME=$1
DB_USER=$2
DB_PASS=$3
DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
SKIP_DB_CREATE=${6-false}

TMPDIR=${TMPDIR-/tmp}
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}

download() {
if [ `which curl` ]; then
curl -s "$1" > "$2";
elif [ `which wget` ]; then
wget -nv -O "$2" "$1"
fi
}

if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then
WP_BRANCH=${WP_VERSION%\-*}
WP_TESTS_TAG="branches/$WP_BRANCH"

elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
WP_TESTS_TAG="branches/$WP_VERSION"
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
WP_TESTS_TAG="tags/${WP_VERSION%??}"
else
WP_TESTS_TAG="tags/$WP_VERSION"
fi
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
WP_TESTS_TAG="trunk"
else
# http serves a single offer, whereas https serves multiple. we only want one
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
if [[ -z "$LATEST_VERSION" ]]; then
echo "Latest WordPress version could not be found"
exit 1
fi
WP_TESTS_TAG="tags/$LATEST_VERSION"
fi
set -ex

install_wp() {

if [ -d $WP_CORE_DIR ]; then
return;
fi

mkdir -p $WP_CORE_DIR

if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
mkdir -p $TMPDIR/wordpress-trunk
rm -rf $TMPDIR/wordpress-trunk/*
svn export --quiet https://core.svn.wordpress.org/trunk $TMPDIR/wordpress-trunk/wordpress
mv $TMPDIR/wordpress-trunk/wordpress/* $WP_CORE_DIR
else
if [ $WP_VERSION == 'latest' ]; then
local ARCHIVE_NAME='latest'
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then
# https serves multiple offers, whereas http serves single.
download https://wordpress.org/wordpress-$WP_VERSION.tar.gz $TMPDIR/wordpress.tar.gz
ARCHIVE_NAME="wordpress-$WP_VERSION"
fi

if [ ! -f $TMPDIR/wordpress.tar.gz ]; then
download https://wordpress.org/latest.tar.gz $TMPDIR/wordpress.tar.gz
fi
tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
fi

download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
}

install_test_suite() {
# portable in-place argument for both GNU sed and Mac OSX sed
if [[ $(uname -s) == 'Darwin' ]]; then
local ioption='-i.bak'
else
local ioption='-i'
fi

# set up testing suite if it doesn't yet exist
if [ ! -d $WP_TESTS_DIR ]; then
# set up testing suite
mkdir -p $WP_TESTS_DIR
rm -rf $WP_TESTS_DIR/{includes,data}
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
fi

if [ ! -f wp-tests-config.php ]; then
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
# remove all forward slashes in the end
WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
fi

}

recreate_db() {
shopt -s nocasematch
if [[ $1 =~ ^(y|yes)$ ]]
then
mysqladmin drop $DB_NAME -f --user="$DB_USER" --password="$DB_PASS"$EXTRA
create_db
echo "Recreated the database ($DB_NAME)."
else
echo "Leaving the existing database ($DB_NAME) in place."
fi
shopt -u nocasematch
}

create_db() {
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
}

install_db() {

if [ ${SKIP_DB_CREATE} = "true" ]; then
return 0
fi

# parse DB_HOST for port or socket references
local PARTS=(${DB_HOST//\:/ })
local DB_HOSTNAME=${PARTS[0]};
local DB_SOCK_OR_PORT=${PARTS[1]};
local EXTRA=""

if ! [ -z $DB_HOSTNAME ] ; then
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
EXTRA=" --socket=$DB_SOCK_OR_PORT"
elif ! [ -z $DB_HOSTNAME ] ; then
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
fi
fi

# create database
if [ $(mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA --execute='show databases;' | grep ^$DB_NAME$) ]
then
echo "Reinstalling will delete the existing test database ($DB_NAME)"
read -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB
recreate_db $DELETE_EXISTING_DB
else
create_db
fi
}

install_wp
install_test_suite
install_db
25 changes: 13 additions & 12 deletions classes/admin/class-page-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,28 @@ public function add_admin_page_content() {
public function get_settings() {
$settings = [];
foreach ( \progress_planner()->get_page_types()->get_page_types() as $page_type ) {
if ( ! $this->should_show_setting( $page_type['slug'] ) ) {
$slug = (string) $page_type['slug']; // @phpstan-ignore offsetAccess.invalidOffset
if ( ! $this->should_show_setting( $slug ) ) {
continue;
}

$settings[ $page_type['slug'] ] = [
'id' => $page_type['slug'],
$settings[ $slug ] = [
'id' => $slug,
'value' => '_no_page_needed',
'isset' => 'no',
'title' => $page_type['title'],
'description' => $page_type['description'] ?? '',
'title' => $page_type['title'], // @phpstan-ignore offsetAccess.invalidOffset
'description' => $page_type['description'] ?? '', // @phpstan-ignore offsetAccess.invalidOffset
'type' => 'page-select',
'page' => $page_type['slug'],
'page' => $slug,
];

if ( \progress_planner()->get_page_types()->is_page_needed( $page_type['slug'] ) ) {
$type_pages = \progress_planner()->get_page_types()->get_posts_by_type( 'any', $page_type['slug'] );
if ( \progress_planner()->get_page_types()->is_page_needed( $slug ) ) {
$type_pages = \progress_planner()->get_page_types()->get_posts_by_type( 'any', $slug );
if ( empty( $type_pages ) ) {
$settings[ $page_type['slug'] ]['value'] = \progress_planner()->get_page_types()->get_default_page_id_by_type( $page_type['slug'] );
$settings[ $slug ]['value'] = \progress_planner()->get_page_types()->get_default_page_id_by_type( $slug );
} else {
$settings[ $page_type['slug'] ]['value'] = $type_pages[0]->ID;
$settings[ $page_type['slug'] ]['isset'] = 'yes';
$settings[ $slug ]['value'] = $type_pages[0]->ID;
$settings[ $slug ]['isset'] = 'yes';

// If there is more than one page, we need to check if the page has a parent with the same page-type assigned.
if ( 1 < \count( $type_pages ) ) {
Expand All @@ -89,7 +90,7 @@ public function get_settings() {
foreach ( $type_pages as $type_page ) {
$parent = \get_post_field( 'post_parent', $type_page->ID );
if ( $parent && \in_array( (int) $parent, $type_pages_ids, true ) ) {
$settings[ $page_type['slug'] ]['value'] = $parent;
$settings[ $slug ]['value'] = $parent;
break;
}
}
Expand Down
3 changes: 2 additions & 1 deletion classes/admin/widgets/class-activity-scores.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public function get_checklist_results() {
$items = $this->get_checklist();
$results = [];
foreach ( $items as $item ) {
$results[ $item['label'] ] = $item['callback']();
$label = (string) $item['label']; // @phpstan-ignore offsetAccess.invalidOffset
$results[ $label ] = $item['callback'](); // @phpstan-ignore offsetAccess.invalidOffset
}
return $results;
}
Expand Down
9 changes: 6 additions & 3 deletions classes/class-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ class Base {
*/
public function init() {
if ( ! \function_exists( 'current_user_can' ) ) {
require_once ABSPATH . 'wp-includes/capabilities.php'; // @phpstan-ignore requireOnce.fileNotFound
// @phpstan-ignore-next-line requireOnce.fileNotFound
require_once ABSPATH . 'wp-includes/capabilities.php';
}
if ( ! \function_exists( 'wp_get_current_user' ) ) {
require_once ABSPATH . 'wp-includes/pluggable.php'; // @phpstan-ignore requireOnce.fileNotFound
// @phpstan-ignore-next-line requireOnce.fileNotFound
require_once ABSPATH . 'wp-includes/pluggable.php';
}

if ( \defined( '\IS_PLAYGROUND_PREVIEW' ) && \constant( '\IS_PLAYGROUND_PREVIEW' ) === true ) {
Expand Down Expand Up @@ -421,7 +423,8 @@ public function get_file_version( $file ) {

// Otherwise, use the plugin header.
if ( ! \function_exists( 'get_file_data' ) ) {
require_once ABSPATH . 'wp-includes/functions.php'; // @phpstan-ignore requireOnce.fileNotFound
// @phpstan-ignore-next-line requireOnce.fileNotFound
require_once ABSPATH . 'wp-includes/functions.php';
}

if ( ! self::$plugin_version ) {
Expand Down
4 changes: 3 additions & 1 deletion classes/class-suggested-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ public function rest_api_tax_query( $args, $request ) {

// Handle sorting parameters.
if ( isset( $request['filter']['orderby'] ) ) {
$args['orderby'] = \sanitize_sql_orderby( $request['filter']['orderby'] );
// @phpstan-ignore-next-line argument.templateType
$orderby = \sanitize_sql_orderby( $request['filter']['orderby'] ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$args['orderby'] = $orderby !== false ? $orderby : 'date';
}
if ( isset( $request['filter']['order'] ) ) {
$args['order'] = \in_array( \strtoupper( $request['filter']['order'] ), [ 'ASC', 'DESC' ], true )
Expand Down
6 changes: 4 additions & 2 deletions classes/suggested-tasks/class-task.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,14 @@ public function get_rest_formatted_data( $post_id = null ): array {

// Make sure WP_REST_Posts_Controller is loaded.
if ( ! \class_exists( 'WP_REST_Posts_Controller' ) ) {
require_once ABSPATH . 'wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php'; // @phpstan-ignore requireOnce.fileNotFound
// @phpstan-ignore-next-line requireOnce.fileNotFound
require_once ABSPATH . 'wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php';
}

// Make sure WP_REST_Request is loaded.
if ( ! \class_exists( 'WP_REST_Request' ) ) {
require_once ABSPATH . 'wp-includes/rest-api/class-wp-rest-request.php'; // @phpstan-ignore requireOnce.fileNotFound
// @phpstan-ignore-next-line requireOnce.fileNotFound
require_once ABSPATH . 'wp-includes/rest-api/class-wp-rest-request.php';
}

// Use the appropriate controller for the post type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public function update_inactive_plugins_cache() {
*/
protected function calculate_data() {
if ( ! \function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php'; // @phpstan-ignore requireOnce.fileNotFound
// @phpstan-ignore-next-line requireOnce.fileNotFound
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}

// Clear the plugins cache, so get_plugins() returns the latest plugins.
Expand Down
Loading
Loading