
內容簡介
使用 Snippy 快速創建自己的自定義短碼。
Snippy 短碼由各種“比特”組合而成。一個“比特”可以是一個文件,比如樣式表或腳本,也可以是一段代碼,比如 HTML、CSS 或 JavaScript。
“代碼”比特可以包含占位符,自動作為短碼屬性可供訪問。
現在舉一個快速例子。
讓我們創建一個用於嵌入 YouTube 視頻的短碼。我們添加一個 HTML 比特,將其值設置為 YouTube 嵌入式 iframe。
<iframe src="https://youtube/embed/JZYYJY4yoK4"/>
現在,為了使這個比特更加靈活,我們將用一個占位符 {{id}} 替換 YouTube 視頻的 id。
<iframe src="https://youtube/embed/{{id}}"/>
太好了!我們完成了第一個比特!
現在,我們可以創建一個新的 Snippy 短碼,添加 YouTube 的 iFrame HTML 比特。保存短碼後,我們可以在文本編輯器中使用我們全新、閃亮的 YouTube 短碼。
[youtube id=JZYYJY4yoK4]
準備好了嗎?
下面這個 3 分鐘的 YouTube 視頻展示了如何使用 Snippy,將一個 jQuery 插件轉化為 WordPress 外掛。
外掛標籤
開發者團隊
原文外掛簡介
Use Snippy to quickly create your own custom shortcodes.
A Snippy shortcode is built by combining bits. A bit can be a file, like a Stylesheet or a Script, or a piece of code, like HTML, CSS or JavaScript.
The “code” bits can contain placeholders, which are automatically made accessible as shortcode attributes.
Time for a quick example.
Let’s create a shortcode to embed YouTube videos. We’ll add an HTML bit and set the it’s value to the YouTube embed iframe.
Now to make this bit a bit more flexible we will replace the YouTube video id with a placeholder value {{id}}.
Yay! We’ve finished our first bit!
Now we can create a new Snippy shortcode and add the YouTube iFrame HTML bit. After saving the shortcode we can use our new and shiny YouTube shortcode in the text editor.
[youtube id=JZYYJY4yoK4]
Ready for more?
The below 3 minute YouTube video shows how you can use Snippy to turn a jQuery plugin into a WordPress plugin.
