Skip to content

An example WordPress plugin for testing for PHP8 compatibility, specifically with code incompatible with PHP 8

Notifications You must be signed in to change notification settings

salcode/wp-example-test-php8-plugin

Repository files navigation

Example Test PHP8 Plugin

This WordPress plugin specifically has code that works in PHP 7.4 but throws fatal errors in PHP 8.

This plugin adds an endpoint at /wp-json/wp-example-test-php8-plugin/v1/site-title, which returns the currently set Site Title.

The PHP 8 specific code is only loaded when you visit this endpoint, so when testing with PHP 8 the site will function properly unless you visit this endpoint.

Warnings in PHP 7.4

When you visit the endpoint using PHP 7.4, you may see a number of warnings displayed on the screen.

Typically on a production site, warnings like these are not displayed to the user but on a development site they can be very helpful to identify issues early.

If you scroll to the bottom of the page, you should see the Site Title.

php-7-4-warnings

Fatal Error in PHP 8

When you visit the endpoint using PHP 8, you should see a fatal error.

Your goal is to fix these PHP 8 errors.

php-8-0-fatal-error

About

An example WordPress plugin for testing for PHP8 compatibility, specifically with code incompatible with PHP 8

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages