Contributors: jmarceli
Tags: cmb2, qtranslate, integration, translation
Tested with: CMB2 (2.1.0), qTranslate X (3.4.5), Wordpress (4.3.0)
Current version 0.1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
CMB2-qTranslate is Wordpress plugin for CMB2 and qTranslate X integration. Adds language switch buttons above selected CMB2 fields to make content translatable.
- 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).
$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'
)
) );
$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).
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).
- CMB2 (https://pl.wordpress.org/plugins/cmb2/)
- qTranslateX (https://pl.wordpress.org/plugins/qtranslate-x/)
All contributions are welcome.
- Fork it ( https://github.com/jmarceli/Gekosale2/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
If installing the plugin from wordpress.org:
- Upload the entire
cmb2_qtranslate/
directory to the/wp-content/plugins/
directory. - Activate CMB2-qTranslate through the 'Plugins' menu in WordPress.
If including the library in your plugin or theme:
- Place the
cmb2_qtranslate/
directory inside of your theme or plugin. - Enqueue JavaScript file
dist/scripts/main.js
withwp_enqueue_script
function
- add support for
data-cmb2-qtranslate
- first release
- support for more field types from CMB2