plugin updates

This commit is contained in:
Tony Volpe
2024-09-25 09:45:47 -04:00
parent cc870f301f
commit f6021c7c22
245 changed files with 4835 additions and 4671 deletions

View File

@@ -12,6 +12,7 @@ use Leadin\data\Portal_Options;
use Leadin\admin\Connection;
use Leadin\admin\Impact;
use Leadin\data\User_Metadata;
use Leadin\auth\OAuthCryptoError;
/**
* Class containing all the constants used for admin script localization.
@@ -93,7 +94,7 @@ class AdminConstants {
'theme' => get_option( 'stylesheet' ),
'adminUrl' => admin_url(),
'websiteName' => get_bloginfo( 'name' ),
'domain' => parse_url( get_site_url(), PHP_URL_HOST ),
'domain' => wp_parse_url( get_site_url(), PHP_URL_HOST ),
'wp_user' => $wp_user->first_name ? $wp_user->first_name : $wp_user->user_nicename,
'nonce' => self::get_connection_nonce(),
'accountName' => Portal_Options::get_account_name(),
@@ -143,7 +144,10 @@ class AdminConstants {
* Returns a minimal version of leadinConfig, containing the data needed by the background iframe.
*/
public static function get_background_leadin_config() {
$wp_user_id = get_current_user_id();
$wp_user_id = get_current_user_id();
$portal_id = Portal_Options::get_portal_id();
$refresh_token = OAuth::get_refresh_token();
$is_connected = ! empty( $portal_id ) && ! empty( $refresh_token );
$background_config = array(
'adminUrl' => admin_url(),
@@ -153,7 +157,7 @@ class AdminConstants {
'formsScriptPayload' => Filters::apply_forms_payload_filters(),
'meetingsScript' => Filters::apply_meetings_script_url_filters(),
'hublet' => Filters::apply_hublet_filters(),
'hubspotBaseUrl' => Filters::apply_base_url_filters( Connection::is_connected() ),
'hubspotBaseUrl' => Filters::apply_base_url_filters( $is_connected ),
'leadinPluginVersion' => constant( 'LEADIN_PLUGIN_VERSION' ),
'locale' => get_locale(),
'restUrl' => get_rest_url(),
@@ -162,7 +166,7 @@ class AdminConstants {
'phpVersion' => Versions::get_php_version(),
'pluginPath' => constant( 'LEADIN_PATH' ),
'plugins' => get_plugins(),
'portalId' => Portal_Options::get_portal_id(),
'portalId' => $portal_id,
'accountName' => Portal_Options::get_account_name(),
'portalDomain' => Portal_Options::get_portal_domain(),
'portalEmail' => get_user_meta( $wp_user_id, 'leadin_email', true ),
@@ -170,17 +174,18 @@ class AdminConstants {
'theme' => get_option( 'stylesheet' ),
'wpVersion' => Versions::get_wp_version(),
'leadinQueryParams' => self::get_hubspot_query_params_array(),
'connectionStatus' => Connection::is_connected() ? 'Connected' : 'NotConnected',
'connectionStatus' => $is_connected ? 'Connected' : 'NotConnected',
'contentEmbed' => self::get_content_embed_config(),
'requiresContentEmbedScope' => is_plugin_active( 'hubspot-content-embed/content-embed.php' ) ? '1' : '0',
'lastAuthorizeTime' => Portal_Options::get_last_authorize_time(),
'lastDeauthorizeTime' => Portal_Options::get_last_deauthorize_time(),
'lastDisconnectTime' => Portal_Options::get_last_disconnect_time(),
'refreshTokenError' => Portal_Options::get_refresh_token_error(),
);
if ( Connection::is_connected() ) {
$background_config['refreshToken'] = OAuth::get_refresh_token();
if ( false === $refresh_token ) {
$background_config['decryptError'] = OAuthCryptoError::DECRYPT_FAILED;
} else {
$background_config['refreshToken'] = $refresh_token;
}
return $background_config;
@@ -192,7 +197,7 @@ class AdminConstants {
public static function get_leadin_config() {
$leadin_config = self::get_background_leadin_config();
if ( ! Connection::is_connected() ) {
if ( 'NotConnected' === $leadin_config['connectionStatus'] ) {
if ( ! Impact::has_params() ) {
$impact_link = Impact::get_affiliate_link();
if ( ! empty( $impact_link ) ) {