Skip to content

Commit

Permalink
fix: Remove setup params
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdiyazdani committed Mar 23, 2024
1 parent a956012 commit 72a09ac
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/Enhancements/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@ class Meta {
*
* @since 1.0.0
*
* @param string $plugin_basename The plugin basename.
*
* @return void
*/
public function setup( $plugin_basename ) {

// Set the plugin basename.
$this->plugin_basename = $plugin_basename;
public function setup() {

add_filter( 'plugin_row_meta', array( $this, 'meta_links' ), 10, 2 );
add_filter( "plugin_action_links_{$this->plugin_basename}", array( $this, 'action_links' ) );
add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 );
}

/**
Expand All @@ -56,7 +51,7 @@ public function setup( $plugin_basename ) {
public function meta_links( $links, $file ) {

// Return early if not on the plugin page.
if ( $this->plugin_basename !== $file ) {
if ( ! $this->is_this_plugin( $file ) ) {
return $links;
}

Expand Down Expand Up @@ -94,6 +89,11 @@ public function meta_links( $links, $file ) {
*/
public function action_links( $links ) {

// Leave early if the filter is not for this plugin.
if ( ! $this->is_this_plugin( $file ) ) {
return $links;
}

$plugin_links = array();
$plugin_links[] = sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */
esc_html_x( '%1$sGet PRO%2$s', 'plugin link', 'woo-store-vacation' ),
Expand All @@ -114,4 +114,18 @@ public function action_links( $links ) {

return array_merge( $plugin_links, $links );
}

/**
* Check if the current plugin is the one we are looking for.
*
* @since 1.0.0
*
* @param string $file Path to the plugin file relative to the plugins' directory.
*
* @return bool
*/
private function is_this_plugin( $file ) {

return woo_store_vacation()->service( 'file' )->plugin_basename() === $file;
}
}

0 comments on commit 72a09ac

Please sign in to comment.