Created
January 31, 2022 13:34
-
-
Save reikjarloekl/5f1a8410c43163a7ca2d5d42300e4403 to your computer and use it in GitHub Desktop.
Automatically set Postman options to staging settings (mailhog running on same server) after cloning a wordpress site to staging. Adapt to your needs!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'wp_loaded', 'set_postman_staging_settings'); | |
function set_postman_staging_settings() { | |
$staging_options = [ | |
"enc_type" => "none", | |
"hostname" => "localhost", | |
"port" => 1025, | |
"sender_email" => "[email protected]", | |
"envelope_sender" => "[email protected]", | |
"transport_type" => "smtp", | |
"smtp_mailers" => "postsmtp", | |
"auth_type" => "none", | |
"sender_name" => "YourSite", | |
"oauth_client_id" => "", | |
"oauth_client_secret" => "", | |
"basic_auth_username" => "", | |
"basic_auth_password" => "", | |
"mandrill_api_key" => "", | |
"sendgrid_api_key" => "", | |
"mailgun_api_key" => "", | |
"mailgun_domain_name" => "", | |
"reply_to" => "", | |
"forced_to" => "", | |
"forced_cc" => "", | |
"forced_bcc" => "", | |
"headers" => "", | |
"read_timeout" => 60, | |
"connection_timeout" => 10, | |
"log_level" => 40000, | |
"mail_log_enabled" => "true", | |
"mail_log_max_entries" => 250, | |
"run_mode" => "production", | |
"transcript_size" => 128, | |
"tmp_dir" => "/tmp", | |
"fallback_smtp_enabled" => "no", | |
"fallback_smtp_hostname" => "", | |
"fallback_smtp_port" => 0, | |
"fallback_smtp_security" => "none", | |
"fallback_from_email" => "", | |
"fallback_smtp_username" => "", | |
"fallback_smtp_password" => "", | |
"notification_service" => "default", | |
"pushover_user" => "", | |
"pushover_token" => "", | |
"slack_token" => "", | |
"notification_chrome_uid" => "", | |
]; | |
$current_options = get_option('postman_options'); | |
if (strpos(site_url(), 'staging') !== false ) { | |
if ($current_options['hostname'] !== 'localhost') { | |
error_log ("Setting postman options to staging values."); | |
update_option('postman_options', $staging_options); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment