[WordPress] 外掛分享: Integration-CMB2-qTranslate

前言介紹

  • 這款 WordPress 外掛「Integration-CMB2-qTranslate」是 2015-09-28 上架。
  • 目前有 100 個安裝啟用數。
  • 上一次更新是 2016-04-16,距離現在已有 3305 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 4.0 以上版本才可以安裝。
  • 有 3 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

jmarceli |

外掛標籤

cmb2 | qtranslate | integration | qtranslatex |

內容簡介

CMB2-qTranslate 是一款 WordPress 外掛,用於整合 CMB2 和 qTranslate X。它會在所選擇的 CMB2 欄位上方添加語言切換按鈕,以便翻譯內容。
有關更新的文檔,請參閱 Github 專案頁面https://github.com/jmarceli/integration-cmb2-qtranslate。

支援的 CMB2 欄位類型:

文本框
多行文本框
所見即所得編輯器
可重複欄位群組

為了使字段可翻譯,請將 .cmb2-qtranslate 類添加到其上。對於非所見即所得編輯器欄位,您可能更喜歡使用也支援的data-cmb2-qtranslate(自 0.0.3 版本以來)。

使用示例

所見即所得編輯器欄位:

> $field1 = $cmb_demo2->add_field( array(
> 'name' => __( '二次文本', $this->plugin_slug ),
> 'desc' => __( '欄位描述(可選)', $this->plugin_slug ),
> 'id' => $prefix . $this->plugin_slug . '_second_text',
> 'class' => 'cmb2',
> 'type' => 'wysiwyg',
> 'options' => array(
> 'editor_class' => 'cmb2-qtranslate'
> )
> ) );

其他欄位:

> $field2 = $cmb_demo->add_field( array(
> 'name' => __( '小文本', $this->plugin_slug ),
> 'desc' => __( '欄位描述(可選)', $this->plugin_slug ),
> 'id' => $prefix . $this->plugin_slug . '_textsmall',
> 'class' => 'cmb2',
> 'type' => 'text',
> 'attributes' => array(
> 'class' => 'cmb2-qtranslate'
> )
> ) );

> // 您也可以使用數據屬性代替類來觸發 qTranslate 的欄位
> // 但是,所見即所得編輯器欄位不支援它(WordPress 的限制)

> $field2 = $cmb_demo->add_field( array(
> 'name' => __( '小文本', $this->plugin_slug ),
> 'desc' => __( '欄位描述(可選)', $this->plugin_slug ),
> 'id' => $prefix . $this->plugin_slug . '_textsmall',
> 'class' => 'cmb2',
> 'type' => 'text',
> 'attributes' => array(
> 'data-cmb2-qtranslate' => true
> )
> ) );

關於欄位創建的詳細信息可以在 CMB2 項目文檔中找到(https://github.com/WebDevStudios/CMB2/wiki)。

在自訂主題選項頁面上的用法:

參見 https://github.com/qTranslate-Team/qtranslate-x/wiki/Custom-page-(plugin)-integration

您應在 $admin-config 陣列中定義至少一個表單欄位,以觸發 qTranslate LSB 在您的自訂主題選項頁面上運行。否則,您將無法使用 LSB。這是因為默認情況下,qTranslate 只在特定頁面上可用:內容頁面、通用選項頁面和可能的其他一些頁面,但不在您的自訂頁面上(如果您創建了一個自訂頁面)。

需求/依賴

CMB2 (https://pl.wordpress.org/plugins/cmb2/)
qTranslateX (https://pl.wordpress.org/plugins/qtranslate-x/)

連結

Github 專案頁面

原文外掛簡介

CMB2-qTranslate is WordPress plugin for CMB2 and qTranslate X integration. Adds language switch buttons above selected CMB2 fields to make content translatable.
For updated docs please refer to the Github project page https://github.com/jmarceli/integration-cmb2-qtranslate.
Supported CMB2 field types:

input
textarea
wysiwyg
repeatable field groups

In order to make field translatable add .cmb2-qtranslate class to it. For non-WYSIWYG fields you may prefer to use data-cmb2-qtranslate which is also supported (since 0.0.3 version).
Usage example
WYSIWYG field:
> $field1 = $cmb_demo2->add_field( array(
> 'name' => __( 'SECOND Text', $this->plugin_slug ),
> 'desc' => __( 'field description (optional)', $this->plugin_slug ),
> 'id' => $prefix . $this->plugin_slug . '_second_text',
> 'class' => 'cmb2',
> 'type' => 'wysiwyg',
> 'options' => array(
> 'editor_class' => 'cmb2-qtranslate'
> )
> ) );

Other fields:
> $field2 = $cmb_demo->add_field( array(
> 'name' => __( 'Text Small', $this->plugin_slug ),
> 'desc' => __( 'field description (optional)', $this->plugin_slug ),
> 'id' => $prefix . $this->plugin_slug . '_textsmall',
> 'class' => 'cmb2',
> 'type' => 'text',
> 'attributes' => array(
> 'class' => 'cmb2-qtranslate'
> )
> ) );

> // You may also use data-attributes instead of class to trigger qTranslate for the field
> // however it is not supported by WYSIWYG field (WordPress limitation)

> $field2 = $cmb_demo->add_field( array(
> 'name' => __( 'Text Small', $this->plugin_slug ),
> 'desc' => __( 'field description (optional)', $this->plugin_slug ),
> 'id' => $prefix . $this->plugin_slug . '_textsmall',
> 'class' => 'cmb2',
> 'type' => 'text',
> 'attributes' => array(
> 'data-cmb2-qtranslate' => true
> )
> ) );

Detailed info about field creation could be found in CMB2 project documentation (https://github.com/WebDevStudios/CMB2/wiki).
Usage on custom Theme Options Page:
See https://github.com/qTranslate-Team/qtranslate-x/wiki/Custom-page-(plugin)-integration
You should define at least one form field in $admin-config array to trigger qTranslate LSB on your custom Theme Options Page. In other case you will end up with not working LSB. It happens because by default qTranslate is available only on specific pages: content pages, general options and maybe some others, but not your custom page (if you will create one).
Requirements/Dependencies

CMB2 (https://pl.wordpress.org/plugins/cmb2/)
qTranslateX (https://pl.wordpress.org/plugins/qtranslate-x/)

Links

Github project page

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Integration-CMB2-qTranslate」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


0.0.1 | 0.0.2 | 0.0.3 | 0.0.4 | 0.0.6 | 0.1.0 | 0.1.1 | trunk |

延伸相關外掛(你可能也想知道)

  • CMB2 Field Type: Font Awesome 》使用 Font Awesome 圖示選擇器強大的自定義 metabox 產生器 CMB2, 您可以在 CMB2 函數檔案中使用作為欄位類型。新增一個欄位,設置類型為 faiconselect,並將...。
  • CMB2 Markdown 》使用範例, $cmb->add_field( array(, 'name' => '支援 Markdown 的欄位',, 'type' => 'text_markdown',, 'id' => 'test_markdown'...。

文章
Filter
Apply Filters
Mastodon