[WordPress] 外掛分享: Moody Shortcodes

首頁外掛目錄 › Moody Shortcodes
全新外掛
安裝啟用
尚無評分
4489 天前
最後更新
問題解決
WordPress 2.5+ v0.1 上架:2013-12-01

內容簡介

注意事項:

此外掛專為開發人員而設,而非一般使用者。
此外掛沒有 GUI(管理設定頁面)。

基本範例

根據您的需求,您可以以多種方式使用此外掛程式,以下的範例僅供學習參考:

// 註冊 "test-1" 簡碼,僅適用於管理員的文章或迴圈外。Moody_Shortcodes_Manager::register( 'test-1', function() { if ( in_the_loop() ) { $post_author = get_post_field( 'post_author', get_post() ); if ( ! user_can( $post_author, 'administrator' ) ) { return false; } // end if } // dnd if return true; }, 'my_test_shortcode' ); // 註冊 "test-2" 簡碼,僅適用於頁面或迴圈外。Moody_Shortcodes_Manager::register( 'test-2', function() { return ( ! in_the_loop() XOR get_post_type() === 'page' ); }, 'my_test_shortcode' ); // 註冊 "test-3" 簡碼,在啟用了 bbPress 外掛時才有效。Moody_Shortcodes_Manager::register( 'test-3', function() { return function_exists( 'is_bbpress' ); }, 'my_test_shortcode' );
貢獻

如果您喜歡這個外掛程式,請在GitHub 儲存庫上為它加星號或進行分支貢獻。

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Moody Shortcodes」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Important Notes:

This plugin is for developers, not general users.
This plugin doesn’t have a GUI ( Admin Settings Page ).

Basic Examples
You can use this plugin in many ways depending on your needs, this examples only for learning purposes:
// Register the "test-1" shortcode, Works only in the administrators posts or outside the loop. Moody_Shortcodes_Manager::register( 'test-1', function() { if ( in_the_loop() ) { $post_author = get_post_field( 'post_author', get_post() ); if ( ! user_can( $post_author, 'administrator' ) ) { return false; } // end if } // dnd if return true; }, 'my_test_shortcode' ); // Register the "test-2" shortcode, Works only in pages or outside the loop. Moody_Shortcodes_Manager::register( 'test-2', function() { return ( ! in_the_loop() XOR get_post_type() === 'page' ); }, 'my_test_shortcode' ); // Register the "test-3" shortcode, Works only when bbPress plugin is activated. Moody_Shortcodes_Manager::register( 'test-3', function() { return function_exists( 'is_bbpress' ); }, 'my_test_shortcode' );
Contributing
If you love this plugin star/fork it on the GitHub Repository.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon