diff --git a/includes/Checker/Abstract_Check_Runner.php b/includes/Checker/Abstract_Check_Runner.php index 2dd8cae6..a5d33786 100644 --- a/includes/Checker/Abstract_Check_Runner.php +++ b/includes/Checker/Abstract_Check_Runner.php @@ -627,7 +627,7 @@ final protected function get_slug() { private function get_check_context() { $plugin_basename = $this->get_plugin_basename(); $plugin_path = is_dir( $plugin_basename ) ? $plugin_basename : WP_PLUGIN_DIR . '/' . $plugin_basename; - return new Check_Context( $plugin_path, $this->get_slug() ); + return new Check_Context( $plugin_path, $this->get_slug() ? $this->get_slug() : basename( $plugin_path, '.php' ) ); } /** @@ -640,10 +640,6 @@ private function get_check_context() { final public function set_slug( $slug ) { if ( ! empty( $slug ) ) { $this->slug = $slug; - } else { - $basename = $this->get_plugin_basename(); - - $this->slug = ( '.' === pathinfo( $basename, PATHINFO_DIRNAME ) ) ? $basename : dirname( $basename ); } } diff --git a/includes/Plugin_Context.php b/includes/Plugin_Context.php index 9cdde25f..0f2f9b8e 100644 --- a/includes/Plugin_Context.php +++ b/includes/Plugin_Context.php @@ -81,7 +81,7 @@ public function __construct( $main_file, $slug = '' ) { if ( ! empty( $slug ) ) { $this->slug = $slug; } else { - $this->slug = basename( dirname( $this->main_file ) ); + $this->slug = basename( dirname( $this->main_file ), '.php' ); } } @@ -128,9 +128,9 @@ public function slug() { */ public function path( $relative_path = '/' ) { if ( is_dir( $this->main_file ) ) { - return trailingslashit( $this->main_file ) . ltrim( $relative_path, '/' ); + return $this->main_file . '/' . ltrim( $relative_path, '/' ); } else { - return plugin_dir_path( $this->main_file ) . ltrim( $relative_path, '/' ); + return dirname( $this->main_file ) . '/' . ltrim( $relative_path, '/' ); } }