Skip to content

20: Give the two WordPress plugin questions a folder of their own - #34

Open
nikolaystrikhar wants to merge 2 commits into
19-registry-folderfrom
20-plugin-folder
Open

20: Give the two WordPress plugin questions a folder of their own#34
nikolaystrikhar wants to merge 2 commits into
19-registry-folderfrom
20-plugin-folder

Conversation

@nikolaystrikhar

Copy link
Copy Markdown
Contributor

What: moves Plugin_Checker, Plugin_Deactivator, their two interfaces and Loads_Plugin_Functions into src/Plugin/ as Checker, Deactivator, Contracts\Checker_Interface and Contracts\Deactivator_Interface. No behaviour changes.

Usage:

use Nexcess\PluginAbsorber\Plugin\Contracts\Checker_Interface;

$container->singleton( Checker_Interface::class, My_Checker::class );

Why this way:

These are one subject. They are the only files that touch WordPress's own plugin functions, and the trait that pulls in plugin.php has no other consumer — so a folder, rather than two root-level classes with their interfaces in the catch-all Contracts\ and their trait in the cross-cutting Traits\.

All four class and interface names lose the Plugin_ prefix, because the folder now spells it. That renames two host seams, which is free until 1.0.0 tags and would not be after; Plugin\Plugin_Checker_Interface stutters in every name and buys nothing a host can use. The trait keeps its prefix — the folder means "a WordPress plugin", the name means "the functions in plugin.php".

src/Contracts/ is down to Activator_Interface and Provider_Interface, and the root of src/ from eleven files to seven.

Plugin_Checker and Plugin_Deactivator are the only files that touch WordPress's
own plugin functions, both through Traits\Loads_Plugin_Functions, and they sat
in the root of src/ beside the facades with their interfaces in src/Contracts/.
They are now src/Plugin/: Checker, Deactivator, and Contracts/ holding
Checker_Interface and Deactivator_Interface.

Both classes and both interfaces lose the Plugin_ prefix, because the folder is
now spelling it. That renames two host seams, which is free until 1.0.0 tags
and would not be after; the alternative, Plugin\Plugin_Checker_Interface,
stutters in all four names and buys nothing a host can use.

src/Contracts/ is down to Activator_Interface and Provider_Interface, and the
root of src/ to the seven files a host is likely to name.
The trait exists so that Checker and Deactivator can pull in
wp-admin/includes/plugin.php, and nothing else uses it. src/Traits/ is for
what cuts across folders, which Guards_Hook_Prefix does and this does not.

Its name keeps the Plugin_ the two classes just dropped, because it does not
mean the same thing: the folder is the subject "a WordPress plugin", and the
name is about the functions in plugin.php.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant