The gform_stripe_url_port Gravity Forms PHP filter sets the Stripe URL port if it’s not 80.
Usage
$server_port = apply_filters('gform_stripe_url_port', $_SERVER['SERVER_PORT']);
Parameters
- $server_port (string): Default server port.
More information
See Gravity Forms Docs: gform_stripe_url_port
Examples
Change Stripe URL port to 8080
This example changes the Stripe URL port to 8080.
add_filter('gform_stripe_url_port', 'set_custom_stripe_port');
function set_custom_stripe_port($server_port) {
return '8080';
}
Set Stripe URL port based on environment
This example sets the Stripe URL port based on the environment (development or production).
add_filter('gform_stripe_url_port', 'set_environment_stripe_port');
function set_environment_stripe_port($server_port) {
if (WP_ENV == 'development') {
return '8080';
} else {
return '80';
}
}
Set Stripe URL port from a configuration file
This example sets the Stripe URL port from a configuration file.
add_filter('gform_stripe_url_port', 'set_config_stripe_port');
function set_config_stripe_port($server_port) {
$config = include 'config.php';
return $config['stripe_port'];
}
Set Stripe URL port based on server name
This example sets the Stripe URL port based on the server name.
add_filter('gform_stripe_url_port', 'set_server_name_stripe_port');
function set_server_name_stripe_port($server_port) {
if ($_SERVER['SERVER_NAME'] == 'example.dev') {
return '8080';
} else {
return '80';
}
}
Change Stripe URL port if it’s not the default (80)
This example changes the Stripe URL port if it’s not the default (80).
add_filter('gform_stripe_url_port', 'change_non_default_stripe_port');
function change_non_default_stripe_port($server_port) {
if ($server_port != '80') {
return '8080';
}
return $server_port;
}