Last active
December 7, 2015 20:17
-
-
Save wvega/c54518cb5a9e56a4121f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function _find_caller_plugin_file() { | |
$bt = debug_backtrace(); | |
$abs_path_lenght = strlen( ABSPATH ); | |
$backtrace_entries_count = count( $bt ); | |
$plugin_file = null; | |
for ( $i = 1; $i < $backtrace_entries_count; $i++ ) { | |
if ( false !== strpos( substr( fs_normalize_path( $bt[ $i ]['file'] ), $abs_path_lenght ), '/freemius/' ) ) { | |
continue; | |
} | |
if ( ! in_array( $bt[ $i ]['function'], array( 'freemius', 'fs_init', 'fs_dynamic_init' ) ) ) { | |
continue; | |
} | |
if ( basename( dirname( $bt[ $i ]['file'] ) ) !== $this->_slug ) { | |
continue; | |
} | |
$plugin_file = $bt[ $i ]['file']; | |
break; | |
} | |
return $plugin_file; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment