Este plugin non se actualizou en máis de 2 anos. É posible que xa non sexa compatible ou mantido por ninguén, ou podes ter problemas de compatibilidade cando se usa con novas versións de WordPress.

Integration-CMB2-qTranslate

Descrición

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

Instalación

Install as usual from wordpress.org plugins page

or

  1. Download Github repository

  2. Upload the entire integration_cmb2_qtranslate/ directory to the /wp-content/plugins/ directory.

  3. Activate CMB2-qTranslate through the ‘Plugins’ menu in WordPress.

or

  1. Place the integration_cmb2_qtranslate/ directory inside of your theme or plugin.
  2. Enqueue JavaScript file dist/scripts/main.js with wp_enqueue_script function

Preguntas frecuentes

  • none at the moment

Comentarios

22 de Abril, 2025
Great plugin!Still works with latest version of qTranslate-XT. In main.js just comment this out on line: 55, 56, 57: // var langSwitchWrap = cmb2qtranslate.createSetOfLSB();// add switch buttons before each multilanguage input// $field.closest(cmb2_field_wrapper_class).prepend(langSwitchWrap);Then in cmb2-qtranslate.php change the “enqueue_scripts” function to use that file, instead of the minified one in /dist/ folder: public function enqueue_scripts() {wp_enqueue_script( $this->get_plugin_slug() . ‘-plugin-script’, plugins_url( ‘assets/scripts/main.js’, __FILE__ ), array( ‘jquery’ ), self::VERSION );}
26 de Outubro, 2017
Very useful and seems to work perfectly. All my thanks to the developer!
Ler todas as 2 opinións

Colaboradores e desenvolvedores

“Integration-CMB2-qTranslate” é un software de código aberto. As seguintes persoas colaboraron con este plugin.

Colaboradores

Traduce “Integration-CMB2-qTranslate” ao teu idioma.

Interesado no desenvolvemento?

Revisa o código, bota unha ollada aorepositorio SVN, ou subscríbete ao log de desenvolvemento por RSS.

Rexistro de cambios

0.1.0

  • fixed issues (see Github project page)

0.0.4

  • readme update

0.0.3

  • add support for data-cmb2-qtranslate

0.0.2

  • readme update

0.0.1

  • first release