Title: Safe Staging
Author: ryanshoover
Published: <strong>2019 年 2 月 9 日</strong>
Last modified: 2019 年 3 月 23 日

---

搜尋外掛

![](https://ps.w.org/safe-staging/assets/banner-772x250.png?rev=2027920)

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://ps.w.org/safe-staging/assets/icon-128x128.png?rev=2027920)

# Safe Staging

 由 [ryanshoover](https://profiles.wordpress.org/ryanshoover/) 開發

[下載](https://downloads.wordpress.org/plugin/safe-staging.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/safe-staging/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/safe-staging/#reviews)
 *  [安裝方式](https://tw.wordpress.org/plugins/safe-staging/#installation)
 * [開發資訊](https://tw.wordpress.org/plugins/safe-staging/#developers)

 [技術支援](https://wordpress.org/support/plugin/safe-staging/)

## 外掛說明

Simply define your production url in settings and copy your site to your staging
instance without fear. The staging site won’t send any emails and won’t process 
any payments.

#### Why should I use the plugin

If you host your site on a managed host that provides a staging instance (WP Engine,
Siteground, and others), or if you run a staging instance for a self-hosted website,
you may have found that WordPress and WooCommerce will automatically send emails
and process payments from the staging site. Whenever you clone your production site
to your staging site, you would normally need to complete a number of steps to make
your site “safe for staging.”

Instead, install this plugin in production, set the production URL, and safely copy
your site to and from staging. No other steps needed!

#### Features on Staging

 1. A “noindex” tag is added to all pages. Your staging site won’t show up in Google.
 2. WordPress emails are stopped. The site won’t send any emails except for the password
    reset email. Please note, this feature may not be compatible with plugins that 
    offload email to a 3rd party service.
 3. The WooCommerce checkout page has a warning message notifying the visitor they 
    are viewing the staging site.
 4. WooCommerce payment gateways are suspended. Bank account transfer, Cash on Delivery
    and Check are left enabled. Stripe is automatically put into test mode.
 5. WooCommerce Subscriptions is put into staging mode.

## 安裝方式

 1. Upload the plugin to `/wp-content/plugins/`
 2. Activate the plugin at `/wp-admin/plugins.php`
 3. Set the URL for your production site at `/wp-admin/options-general.php?page=safe-
    staging`

## 常見問題集

  Can I complicate how the plugin determines what the production URL is?

The filter `safe_staging_is_production` will let you change what the plugin sees
as the production site.
 For example, the filter below will let you support an alternative
production URL.

    ```
    /**
     * Change whether Safe Staging thinks the current site
     * is the production site.
     *
     * @param bool $is_prod Is this the production site.
     * @return bool         Whether we should treat this as an alternative production site.
     */
    add_filter(
        'safe_staging_is_production',
        function( $is_prod ) {
            $alternative_prod_url = 'https://myothersite.com';

            if ( site_url() === $alternative_prod_url ) {
                $is_prod = true;
            }

            return $is_prod;
        }
    );
    ```

  Can I let other emails get sent on staging sites?

The filter `safe_staging_is_whitelist_email` will let you intervene just before 
an email is blocked.
 For example, the filter below will let you support an alternative
production URL.

    ```
    /**
     * Determine whether a particular email should be sent.
     *
     * In this case we test if the to recipient is our admin address.
     *
     * @param bool   $whitelisted Should the email actually send.
     * @param object $this        Instance of the Fake PHPMailer class.
     * @return bool               Whitelist value tested against the recipient.
     */
    add_filter(
        'safe_staging_is_whitelist_email'
        function( $whitelisted, $phpmailer ) {
            if ( 'admin@mysite.com' === $phpmailer->getToAddresses() ) {
                $whitelisted = true;
            }

            return $whitelisted;
        },
        10,
        2
    );
    ```

  Can I change the message that shows on the checkout page?

The filter `safe_staging_checkout_notice` will let you override the message shown
on the cart and checkout pages.

    ```
    /**
     * Change the warning message that gets displayed on the checkout page
     * of staging sites.
     *
     * @return string New message to show on the checkout page.
     */
    add_filter(
        'safe_staging_checkout_notice',
        function() {
            return 'You\'ve found our staging site! You might want to go back to the production site.';
        }
    )
    ```

## 使用者評論

![](https://secure.gravatar.com/avatar/03020cc2ed8813d1d52fc461cb56ff3966b96d57a61a6dbbec3c763519dd9aed?
s=60&d=retro&r=g)

### 󠀁[This saved my client](https://wordpress.org/support/topic/this-saved-my-client/)󠁿

 [Cousett](https://profiles.wordpress.org/cousett/) 2019 年 2 月 9 日

My client did something that suddenly started sending emails from the staging server
for their membership site. This plugin allowed me to kill the emails from sending
and backtrack the issues caused before it got out of hand.

 [ 閱讀全部 1 則使用者評論 ](https://wordpress.org/support/plugin/safe-staging/reviews/)

## 參與者及開發者

以下人員參與了開源軟體〈Safe Staging〉的開發相關工作。

參與者

 *   [ ryanshoover ](https://profiles.wordpress.org/ryanshoover/)

[將〈Safe Staging〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/safe-staging)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/safe-staging/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/safe-staging/)，或透過 [RSS](https://plugins.trac.wordpress.org/log/safe-staging/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/safe-staging/)。

## 變更記錄

#### 0.3.2

 * Improves CI / CD
 * Adds wpunit tests

#### 0.3

 * Improve admin notifications
 * Clarifies readme code examples
 * Adds wpunit tests

#### 0.2.3

 * Adds support for CI / CD code management

#### 0.2.1

 * Bumps compatibility to 5.1.
 * Adds uninstall file.

#### 0.2

 * Adds noindex tag to the staging site.

## 中繼資料

 *  版本 **0.3.2**
 *  最後更新 **8 年前**
 *  啟用安裝數 **10+**
 *  WordPress 版本需求 ** 4.7 或更新版本 **
 *  已測試相容的 WordPress 版本 **5.1.26**
 *  PHP 版本需求 ** 7.0 或更新版本 **
 *  語言
 * [English (US)](https://wordpress.org/plugins/safe-staging/)
 * 標籤:
 * [email](https://tw.wordpress.org/plugins/tags/email/)[staging](https://tw.wordpress.org/plugins/tags/staging/)
   [woocommerce](https://tw.wordpress.org/plugins/tags/woocommerce/)
 *  [進階檢視](https://tw.wordpress.org/plugins/safe-staging/advanced/)

## 評分

 5 星，滿分為 5 星

 *  [  1 個 5 星使用者評論     ](https://wordpress.org/support/plugin/safe-staging/reviews/?filter=5)
 *  [  0 個 4 星使用者評論     ](https://wordpress.org/support/plugin/safe-staging/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/safe-staging/reviews/?filter=3)
 *  [  0 個 2 星使用者評論     ](https://wordpress.org/support/plugin/safe-staging/reviews/?filter=2)
 *  [  0 個 1 星使用者評論     ](https://wordpress.org/support/plugin/safe-staging/reviews/?filter=1)

[撰寫評分](https://wordpress.org/support/plugin/safe-staging/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/safe-staging/reviews/)

## 參與者

 *   [ ryanshoover ](https://profiles.wordpress.org/ryanshoover/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/safe-staging/)