WooCommerce Admin Settings Custom Attributes

To set custom attributes, you could use custom_attributes as array key.

This is an example taken from WooCommerce.

/woocommerce/includes/admin/settings/class-wc-settings-emails.php

You can see now the input field has a new attribute name ‘multiple’ and with the value ‘multiple’

WordPress Poedit 如何排除 text domain

如果你的佈景主題有用到別的程式,其中包含翻譯文字,而你又不希望這個 text domain 出現在你的翻譯檔中,可以在 Poedit 中排除。

使用 Poedit 打開你的 pot 檔,透過上方 [翻譯] -> [屬性] 選單來打開設定介面。點擊 [原始程式碼路徑],在下方有排除的路徑,點擊 + 號來選擇你要排除的檔案或路徑。

如何避免 git pull 產生不必要的 merge commit

之前跟別人協作的時候,使用 git pull 並 commit 後會產生額外的 merge 訊息。

這是因為其實 git pull 這個動作是包含了 git fetch 和 git merge

如果你不希望產生額外的 merge commit,可以透過 rebase 來處理

git pull --rebase origin main

上面的指令,其實結合了 git fetch 和 git rebase,會將我們 local 的 commit 放在遠端 commit 的前面

git fetch
git rebase origin main

參考資料

https://gitbook.tw/chapters/github/pull-from-github

https://coderwall.com/p/jgn6-q/git-pull-is-evil

https://dev.to/mliakos/don-t-git-pull-use-git-pull-rebase-instead-5b8k

VS Code Intelephense 無法辨識 WordPress 函式

PHP Intelephense 是 VS Code 中相當熱門的一個擴充,讓 VS Code 可以更接近 PHPStorm 具有 IDE (Integrated Development Environment) 的功能。

當在開發 WordPress 的時候,可能會遇到 VS Code 無法辨識 WordPress 函式的狀況。

你可以開啟設定,然然找到 Intelephense: Stubs 這個設定,將 WordPress 加入,重新啟動 VS Code 就可以了。

WordPress/WooCommerce 分類排序

WordPress 分類排序

方法1: 在 wp_terms 資料表新增一個欄位來記錄排序

這個外掛會新增一個 term_order 的欄位來記錄排序

這個外掛也是新增一個 term_order 的欄位來記錄排序

WooCommerce 商品分類排序

WooCommerce 商品分類排序
WooCommerce 可以透過拖曳的方式來改變分類排序

//woocommerce/includes/class-wc-ajax.php
term_ordering
wc_reorder_terms

//woocommerce/includes/wc-term-functions.php
wc_reorder_terms
wc_set_term_order
update_term_meta( $term_id, ‘order’, $index );

woocommerce 是用 order 這個 meta key 來記錄 term 的排序,記錄在 wp_termmeta 資料表

Elementor 收購 Strattic

Elementor 在 6/8 宣佈收購了同樣來自以色列的公司 Strattic。 Strattic 主要提供靜態化 (Static) 和 Headless WordPress 的主機服務。

這幾年在 WordPress 生態圈出現了許多收購,特別是由主機商的收購,各家主機商好像在搞軍備競賽似的,收購了許多大大小小的外掛,來加強自己在生態圈的優勢。例如 Godaddy、WPEngine、Liquidweb 皆收購了不少 WordPress 生態圈的外掛。而這次 Elementor 收購了 Strattic 則是相當有趣地由外掛方發起的收購,也因此引起了大家的好奇心和注意。

而事實上 Elementor 也在今年推出了自家的主機託管服務 Cloud Website,除了提供主機託管服務外,也內建了 Elementor Pro 外掛的授權。相信在未來 Elementor 和 Strattic 會有更多的整合,提供給使用 Elementor 架站的使用者更優質的託管服務和架站體驗。

參考資料: