Skip to content

Review hook setup in Whip_Hosts.php #67

@jrfnl

Description

@jrfnl

In the Whip_Host.php file, there are a couple of calls to apply_filters() with variable filter names.

I'm not familiar enough with the code to properly review these, but I do believe this setup should be reviewed for the following reasons:

  • Variable filter names with unpredictable values make it hard to hook into these.
  • All hook names should be prefixed to prevent conflicts with other plugins/themes. This is not safeguarded in the current setup.

Relevant warnings thrown by PHPCS when run without exclusions:

FILE: src\Whip_Host.php
------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------
  47 | WARNING | Hook names invoked by a theme/plugin should start with the theme/plugin
     |         | prefix. Found: "strtolower( self::HOST_NAME_KEY )".
  77 | WARNING | Hook names invoked by a theme/plugin should start with the theme/plugin
     |         | prefix. Found: "strtolower( $messageKey )".
 102 | WARNING | Hook names invoked by a theme/plugin should start with the theme/plugin
     |         | prefix. Found: "self::HOSTING_PAGE_FILTER_KEY".
------------------------------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions