很多時候為了內部程式開發方便或是安裝 wordpress 時候會需要不同的 DNS 名稱,你也可以編修自己電腦中的 host 名單,讓你開發者可以利用 Domain 去安裝 wordpress,或是也可以自己架設一個 DNS SERVER 來處理這件事情,但現在有比較好的選擇,可以兼顧程式開發以及去除廣告的好處,設定又很容易,且還可以安裝在小巧的 Raspberry Pi 上,可以不用透過外面的 DNS 去做繁瑣的設定,非常的加分。
Pi-hole 安裝方法
Pi-hole的安裝很簡單,在 Raspberry Pi 中只要一行,其他的就看圖片精靈回答問題即可
初始安裝畫面告訴你安裝了 Pi-hole 就可以幫你去除煩人的廣告Pi-hole 別忘了,有能力的人要貢獻點小費,施比受有福Pi-hole 選擇你上層的 DNS SERVER 台灣建議用 Google 即可Pi-hole 選擇廣告阻擋清單的供應者,目前也只有一個可以選擇Pi-hole 是否要安裝管理的介面,為了以後方便,預設把它裝起來吧Pi-hole 這一段是問要不要安裝 lighttpd 和 PHP 模組,當然你也可以用自己的 web server ,但為了方便起見,用預設的 web server 即可,他不會佔用太多的硬碟空間。Pi-hole 是否要有記錄檔,當然要囉Pi-hole privacy mode , https://docs.pi-hole.net/ftldns/privacylevels/,用預設不隱藏任何東西,所有統計數據都可用即可看到這個畫面就完成安裝,可以將電腦中的 DNS 指向畫面中的 IP ,需要進入管理介面的輸入 http://pi.hole/admin
add_filter( 'woocommerce_get_price_html', function( $price ) {
if ( is_admin() ) return $price;
$user = wp_get_current_user();
$hide_for_roles = array( 'wholesale', 'wholesale-silver', 'wholesale-gold' );
// If one of the user roles is in the list of roles to hide for.
if ( array_intersect( $user->roles, $hide_for_roles ) ) {
return ''; // Return empty string to hide.
}
return $price; // Return original price
} );
add_filter( 'woocommerce_cart_item_price', '__return_false' );
add_filter( 'woocommerce_cart_item_subtotal', '__return_false' );
Woocommerce 如何對不同的類別中的商品做價格控制
add_filter( 'woocommerce_get_price_html', function( $price, $product ) {
if ( is_admin() ) return $price;
// Hide for these category slugs / IDs
$hide_for_categories = array( 'clothes', 'electronics' );
// Don't show price when its in one of the categories
if ( has_term( $hide_for_categories, 'product_cat', $product->get_id() ) ) {
return '';
}
return $price; // Return original price
}, 10, 2 );
add_filter( 'woocommerce_cart_item_price', '__return_false' );
add_filter( 'woocommerce_cart_item_subtotal', '__return_false' );
近期留言