$url, 'key' => $key, ); } /** * Get ActiveCampaign webhook URL. * * @since 1.0.0 * * @return string */ function automatorwp_activecampaign_get_webhook_url() { $prefix = 'automatorwp_activecampaign_'; $settings = get_option( 'automatorwp_settings', array() ); $webhook_url = ( isset( $settings[$prefix . 'webhook'] ) ) ? $settings[$prefix . 'webhook'] : ''; // Check if webhook URL exists if ( empty( $webhook_url ) ){ $slug = strtolower( wp_generate_password( 8, false ) ); $webhook_url = get_rest_url() . 'activecampaign/webhooks/' . $slug; $settings[$prefix . 'webhook'] = $webhook_url; $settings[$prefix . 'slug'] = $slug; // Update settings update_option( 'automatorwp_settings', $settings ); } return $webhook_url; } /** * Get ActiveCampaign webhook slug. * * @since 1.0.0 * * @return string */ function automatorwp_activecampaign_get_webhook_slug() { $prefix = 'automatorwp_activecampaign_'; $settings = get_option( 'automatorwp_settings' ); $slug = $settings[$prefix . 'slug']; // Check if webhook slug exists if ( empty( $slug ) ){ $slug = strtolower( wp_generate_password( 8, false ) ); $webhook_url = get_rest_url() . 'activecampaign/webhooks/' . $slug; $settings[$prefix . 'webhook'] = $webhook_url; $settings[$prefix . 'slug'] = $slug; // Update settings update_option( 'automatorwp_settings', $settings ); } return $slug; } /** * Get ActiveCampaign webhook URL. * * @since 1.0.0 * * @return string */ function automatorwp_activecampaign_trigger_notice() { $webhook_url = automatorwp_activecampaign_get_webhook_url(); // Warn user about copy the webhook url at ActiveCampaign ?>