ClassicPress / ClassicPress-v2

NOT READY FOR PRODUCTION.
GNU General Public License v2.0
13 stars 4 forks source link

💡 WordPress block-related functions list #175

Open viktorix opened 1 year ago

viktorix commented 1 year ago

Context

To ensure our block compatibility feature works as expected, we need to polyfill all functions that can be polyfilled.

The list of block-related functions in WordPress (6.2.2):

ClassicPress 2.0.0

For reference, these are the block-related functions in ClassicPress 2.0.0 (08-09 nightly):

The following block-related functions are in the core, not polyfills:

The following block-related functions are in the core but set to return: false. I assume that is a polyfill.

The following block-related functions are not in WordPress but we do have a polyfill:

Might not be related to blocks?

viktorix commented 1 year ago

Can we create a list of functions to polyfill and loop through that list without writing polyfill code for each function?

For example:

$functions_to_polyfill = array(
    'unregister_block_type',
    'another_function_to_polyfill',
);

foreach ($functions_to_polyfill as $function_name) {
    if (!function_exists($function_name)) {
        function_exists($function_name) || function ($...args) {
            WP_Compat::using_block_function();
            return false;
        };
    }
}

Any thoughts? Performance issues?

viktorix commented 1 year ago

Functions starting with an underscore, which are meant for internal core use, have been removed from the list.

xxsimoxx commented 1 year ago

This is my list. I've excluded function from classes. Had a quick look to every other function. From my point of view only six (those marked with non checked checkboxes) can be considered. Two can be polyfilled and one deleted.

viktorix commented 1 year ago

@xxsimoxx what about the rest of them? They won't cause fatal errors?

xxsimoxx commented 1 year ago

I've excluded:

Maybe I've missed some. So an extra eye on this can help. Anyway we can add more if a specific plugin is causing errors calling a specific missing function.