', '' ); // 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 = ' !'; } $portal_id = get_option( 'leadin_portalId' ); if ( ! empty( $portal_id ) ) { add_menu_page( __( 'HubSpot', 'leadin' ), __( 'HubSpot', 'leadin' ) . $notification_icon, 'edit_posts', 'leadin', array( $this, 'leadin_build_app' ), 'dashicons-sprocket', '25.100713' ); add_submenu_page( 'leadin', __( 'Dashboard', 'leadin' ), __( 'Dashboard', 'leadin' ), 'edit_posts', 'leadin_dashboard', array( $this, 'leadin_build_app' ) ); add_submenu_page( 'leadin', __( 'Contacts', 'leadin' ), __( 'Contacts', 'leadin' ), 'edit_posts', 'leadin_contacts', array( $this, 'leadin_build_app' ) ); add_submenu_page( 'leadin', __( 'Lists', 'leadin' ), __( 'Lists', 'leadin' ), 'edit_posts', 'leadin_lists', array( $this, 'leadin_build_app' ) ); add_submenu_page( 'leadin', __( 'Forms', 'leadin' ), __( 'Forms', 'leadin' ), 'edit_posts', 'leadin_forms', array( $this, 'leadin_build_app' ) ); add_submenu_page( 'leadin', __( 'Settings', 'leadin' ), __( 'Settings', 'leadin' ), 'edit_posts', 'leadin_settings', array( $this, 'leadin_build_app' ) ); remove_submenu_page( 'leadin', 'leadin' ); } else { add_menu_page( __( 'HubSpot', 'leadin' ), __( 'HubSpot', 'leadin' ) . $notification_icon, 'manage_options', 'leadin', array( $this, 'leadin_build_app' ), 'dashicons-sprocket', '25.100713' ); } } // ============================================= // Settings Page // ============================================= /** * Adds setting link for Leadin to plugins management page * * @param array $links Return the links for the settings page. * @return array */ public function leadin_plugin_settings_link( $links ) { $portal_id = get_option( 'leadin_portalId' ); if ( ! empty( $portal_id ) ) { $page = 'leadin_settings'; } else { $page = 'leadin'; } $url = get_admin_url( get_current_blog_id(), "admin.php?page=$page" ); $settings_link = '' . __( 'Settings', 'leadin' ) . ''; array_unshift( $links, $settings_link ); return $links; } /** * Adds advanced features link for Leadin to plugins management page * * @param array $links Return the links for the advanced features page. * @return array */ public function leadin_plugin_advanced_features_link( $links ) { $portal_id = get_option( 'leadin_portalId' ); if ( ! empty( $portal_id ) ) { $url = LEADIN_BASE_URL . '/pricing/' . $portal_id . '/marketing?' . leadin_get_query_params(); $advanced_features_link = '' . esc_html( __( 'Advanced Features', 'leadin' ) ) . ''; array_push( $links, $advanced_features_link ); } return $links; } /** * Creates leadin app */ public function leadin_build_app() { global $wp_version; wp_enqueue_style( 'leadin-bridge-css' ); $error_message = ''; if ( version_compare( phpversion(), LEADIN_REQUIRED_PHP_VERSION, '<' ) ) { $error_message = sprintf( __( 'HubSpot All-In-One Marketing %1$s requires PHP %2$s or higher. Please upgrade WordPress first.', 'leadin' ), LEADIN_PLUGIN_VERSION, LEADIN_REQUIRED_PHP_VERSION ); } elseif ( version_compare( $wp_version, LEADIN_REQUIRED_WP_VERSION, '<' ) ) { $error_message = sprintf( __( 'HubSpot All-In-One Marketing %1$s requires PHP %2$s or higher. Please upgrade WordPress first.', 'leadin' ), LEADIN_PLUGIN_VERSION, LEADIN_REQUIRED_WP_VERSION ); } if ( $error_message ) { ?>

id || 'post' === $screen->id || 'page' === $screen->id ) { $background_iframe_url = leadin_get_background_iframe_src(); ?> id === 'plugins' ) { // handlers and logic are added via jQuery in the frontend. ?> id === 'plugins' ) { wp_enqueue_style( 'leadin-feedback-css', LEADIN_PATH . '/style/leadin-feedback.css', array(), LEADIN_PLUGIN_VERSION ); wp_enqueue_script( 'leadin-feedback', LEADIN_JS_BASE_PATH . '/feedback.js', array( 'jquery', 'thickbox' ), LEADIN_PLUGIN_VERSION, true ); } } }