sumitpore / mvc-plugin-boilerplate-for-wordpress

An MVC WordPress Plugin Boilerplate with clear separation of concerns. Will make your experience of creating a WordPress Plugin enjoyable!
176 stars 22 forks source link

Add register_hook_callback method of Admin Setttings Controller in Route #16

Closed sumitpore closed 5 years ago

sumitpore commented 5 years ago

Add register_hook_callback method of Admin Setttings Controller in Route.

sumitpore commented 3 weeks ago

plugin-name/app/controllers/admin/class-admin-settings.php

After reviewing the provided code snippet, I found the following issues:

  1. Code quality problem: The __construct method should be declared as public instead of protected. This is because WordPress's WP_Hook class, which is used to register hooks, expects the constructor to be public.

Line number(s): 2-5

code-smell

Corrected code:

public function __construct(Model $model, View $view) {
    // ...
}
  1. Integration issue: The register_hook_callbacks method should be declared as public instead of protected. This is because WordPress's WP_Hook class, which is used to register hooks, expects the callback methods to be public.

Line number(s): 74-76

integration-issue

Corrected code:

public function register_hook_callbacks() {
    // ...
}
  1. Performance implication: The plugin_menu method should not have an unnecessary comment line (// @codingStandardsIgnoreEnd.) as it may slow down the performance of the plugin.

Line number(s): 150-151

performance-implication

Corrected code:

public function plugin_menu() {
    // ...
}
  1. Code quality problem: The markup_fields method should not have an unnecessary variable declaration ($id = 'plugin_name_field';) as it may lead to confusion and errors.

Line number(s): 213-214

code-smell

Corrected code:

public function markup_fields($field_args) {
    // ...
}

Files considered for this review:

plugin-name/routes.php

Based on the provided code change, I have identified the following issues:

  1. Code quality problem: The use of register_hook_callbacks without proper explanation or context can lead to confusion and potential bugs in the future. This method is likely used to register callbacks for hooks, but without clear documentation, it may not be easily understood.

Line number: +133

code-smell, #low-priority