Skip to content

Instantly share code, notes, and snippets.

@wvega
Last active December 7, 2015 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wvega/c54518cb5a9e56a4121f to your computer and use it in GitHub Desktop.
Save wvega/c54518cb5a9e56a4121f to your computer and use it in GitHub Desktop.
<?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