Tribe__PUE__Checker::get_key( string $type = 'any', string $return_type = 'key' )
Get current license key, optionally of a specific type.
Contents
Parameters
- $type
-
(string) (Optional) The type of key to get (any, network, local, default).
Default value: 'any'
- $return_type
-
(string) (Optional) The type of data to return (key, origin).
Default value: 'key'
Return
(string)
Source
File: src/Tribe/PUE/Checker.php
public function get_key( $type = 'any', $return_type = 'key' ) {
$license_key = '';
$license_origin = 'm';
/*
* Even if we have a network key if the plugin is not active on the network then it should
* not be used.
*/
if (
( 'network' === $type || 'any' === $type )
&& is_multisite()
&& $this->is_plugin_active_for_network()
) {
$license_key = get_network_option( null, $this->pue_install_key, '' );
}
if ( ( 'local' === $type || 'any' === $type ) && empty( $license_key ) ) {
$license_key = get_option( $this->pue_install_key, '' );
}
if ( empty( $license_key ) && ( 'default' === $type || 'any' === $type ) ) {
$autoloader = Tribe__Autoloader::instance();
$class_name = $autoloader->get_prefix_by_slug( $this->get_slug() );
if ( $class_name ) {
$class_name .= 'PUE__Helper';
if ( constant( $class_name . '::DATA' ) ) {
$license_key = constant( $class_name . '::DATA' );
$license_origin = 'e';
}
}
}
if ( 'origin' === $return_type ) {
if ( 'm' === $license_origin ) {
$default_key = $this->get_key( 'default' );
if ( $license_key !== $default_key ) {
$license_origin = 'o';
}
}
return $license_origin;
}
return $license_key;
}