Skip to content

Commit

Permalink
introduce Carbon_Breadcrumb_Admin::current_dir() for emulating curren…
Browse files Browse the repository at this point in the history
…t directory
  • Loading branch information
tyxla committed Jan 5, 2016
1 parent d51cfa6 commit a2bbb2f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion admin/Carbon_Breadcrumb_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function is_enabled() {

// enabled if this plugin is installed as a regular WordPress plugin
$plugin_path = untrailingslashit( ABSPATH ) . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'plugins';
$current_dir = dirname( __FILE__ );
$current_dir = $this->current_dir();
if ( false !== strpos( $current_dir, $plugin_path ) ) {
$enabled = true;
}
Expand All @@ -124,4 +124,16 @@ public function is_enabled() {
return apply_filters( 'carbon_breadcrumb_enable_admin', $enabled );
}

/**
* Returns the current directory.
* Useful for covering multiple cases in unit tests.
*
* @access public
*
* @return string The absolute directory of the current file.
*/
public function current_dir() {
return dirname( __FILE__ );
}

}

0 comments on commit a2bbb2f

Please sign in to comment.