',
''
); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
parent_base ) {
if ( ! get_option( 'leadin_portalId' ) && leadin_is_admin() ) {
$message_type = 'DISCONNECTED_MESSAGE';
}
}
if ( 'DISCONNECTED_MESSAGE' === $message_type ) {
leadin_render_disconnected_banner();
}
}
/**
* LeadinAdmin Class
*/
class LeadinAdmin {
/**
* Class constructor
*/
public function __construct() {
// =============================================
// Hooks & Filters
// =============================================
$plugin_version = get_option( 'leadin_pluginVersion' );
// If the plugin version matches the latest version escape the update function.
if ( LEADIN_PLUGIN_VERSION !== $plugin_version ) {
self::leadin_update_check();
}
add_action( 'admin_init', array( &$this, 'leadin_maybe_redirect' ) );
add_action( 'admin_menu', array( &$this, 'leadin_add_menu_items' ) );
add_action( 'admin_enqueue_scripts', array( &$this, 'add_leadin_admin_scripts' ) );
add_filter( 'plugin_action_links_leadin/leadin.php', array( $this, 'leadin_plugin_settings_link' ) );
add_filter( 'plugin_action_links_leadin/leadin.php', array( $this, 'leadin_plugin_advanced_features_link' ) );
add_action( 'admin_notices', array( &$this, 'leadin_add_background_iframe' ) );
add_action( 'admin_notices', 'leadin_action_required_notice' );
add_action( 'admin_footer', array( $this, 'leadin_add_feedback' ) );
$affiliate = $this->get_affiliate_code();
if ( $affiliate ) {
add_option( 'hubspot_affiliate_code', $affiliate );
}
$this->hydrate_acquisition_attribution();
}
/**
* Redirect after activation.
*/
public function leadin_maybe_redirect() {
if ( get_transient( 'leadin_redirect_after_activation' ) ) {
delete_transient( 'leadin_redirect_after_activation' );
wp_safe_redirect( admin_url( 'admin.php?page=leadin' ) );
exit;
} elseif ( ! empty( get_option( 'leadin_portalId' ) ) && isset( $_GET['page'] ) && 'leadin' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
// Redirect to the default landing page if the user is already logged in.
wp_safe_redirect( admin_url( 'admin.php?page=' . LEADIN_LANDING_PAGE ) );
exit;
}
}
/**
* Return affiliate code from either file or option.
*/
private function get_affiliate_code() {
$affiliate = get_option( 'hubspot_affiliate_code' );
if ( ! $affiliate ) {
$affiliate = trim( preg_replace( '/\s\s+/', ' ', leadin_file_get_contents( 'hs_affiliate.txt' ) ) );
}
if ( $affiliate ) {
return $affiliate;
}
return false;
}
/**
* Get hubspot_acquisition_attribution option
*/
private function get_acquisition_attribution_option() {
return get_option( 'hubspot_acquisition_attribution' );
}
/**
* Return attribution string from wither file or option
*/
private function hydrate_acquisition_attribution() {
if ( $this->get_acquisition_attribution_option() ) {
return;
}
if ( file_exists( LEADIN_PLUGIN_DIR . '/hs_attribution.txt' ) ) {
$acquisition_attribution = trim( leadin_file_get_contents( 'hs_attribution.txt' ) );
add_option( 'hubspot_acquisition_attribution', $acquisition_attribution );
}
}
/**
* Store current version in option
*/
private function leadin_update_check() {
update_option( 'leadin_pluginVersion', LEADIN_PLUGIN_VERSION );
}
// =============================================
// Menus
// =============================================
/**
* Adds Leadin menu to /wp-admin sidebar
*/
public function leadin_add_menu_items() {
global $submenu;
global $wp_version;
$notification_icon = '';
if ( ! get_option( 'leadin_portalId' ) ) {
$notification_icon = '