el'] = $this->get_label( $account_summary ); /** * Filters the account data after it was created. * * @since 1.9.3 * * @param array $account Account data. */ return (array) apply_filters( 'wpforms_integrations_constant_contact_v3_auth_create_account_data', $account ); } /** * Get APP data needed for auth in the sing-up popup. * * @since 1.9.3 * * @return string */ public static function get_auth_url(): string { return add_query_arg( [ 'client_id' => ConstantContact::get_api_key(), 'scope' => 'offline_access account_read contact_data', 'redirect_uri' => add_query_arg( 'api-version', 'v3', ConstantContact::get_middleware_url() ), 'state' => 'WPForms-' . wp_rand( 1000, 9999 ), 'response_type' => 'code', 'prompt' => 'login', ], ConstantContact::SIGN_UP ); } /** * Get label. * * @since 1.9.3 * * @param array $account_summary Account summary. * * @return string */ private function get_label( array $account_summary ): string { $email_part = $account_summary['contact_email'] ?? ''; $org_part = $account_summary['organization_name'] ?? ''; if ( empty( $email_part ) && empty( $org_part ) ) { return ''; } if ( empty( $email_part ) ) { return $org_part; } if ( empty( $org_part ) ) { return $email_part; } return "$email_part / $org_part"; } /** * Get the URL to the providers' page with the focus on the CC v3 integration. * * @since 1.9.3 * * @return string */ private function get_page_url(): string { return add_query_arg( [ 'page' => 'wpforms-settings', 'view' => 'integrations', 'wpforms-integration' => Core::SLUG, ], admin_url( 'admin.php' ) ); } }