Zodiac1978 / wp-search-ignore-block-names

Modifies the native search to ignore block editor comments
https://wordpress.org/plugins/ignore-block-name-in-search/
GNU General Public License v2.0
4 stars 3 forks source link

Call actions correctly #9

Closed websupporter closed 1 year ago

websupporter commented 1 year ago

Actions need to be callables.

Like a function:

function something() {

}
add_action('hook', 'something');

For a static method in a class:

class Something {
  public static function foo() {

  }
}
add_action('hook', [Something::class, 'foo']);

For a normal method in a class, you need to provide a concrete instance of that class:

class Something {
  public function foo() {

  }
}
$something = new Something();
add_action('hook', [$something, 'foo']);

Additionally: All methods you use for a hook must be public.

This PR attempts to fix some issues in the 6-prevent-activation branch.

websupporter commented 1 year ago

Before:

$ wp plugin activate wp-search-ignore-block-names
Warning: Failed to activate plugin. The plugin generated unexpected output.
Success: Plugin already activated.

After:

$ wp plugin activate wp-search-ignore-block-names
Plugin 'wp-search-ignore-block-names' activated.
Success: Activated 1 of 1 plugins.
Zodiac1978 commented 1 year ago

Thank you so much for explaining!

I've merged the PR #8 from @mustafauysal with the same changes.

websupporter commented 1 year ago

Ah! cool. I didnt see @mustafauysal PR. :ok_hand: