Last active
June 20, 2018 21:55
-
-
Save corypina/9925c7991fc9bb4f51f0dd96e14ec1fe to your computer and use it in GitHub Desktop.
Register fields of custom BB modules into the WPML String Translation interface in WordPress. Add to functions.php, or custom module plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Translating custom Beaver Builder Modules with WPML | |
// Runs a filter included in the WPML String Translation plugin | |
add_filter( 'wpml_beaver_builder_modules_to_translate', 'wpml_modules_to_translate_filter' ); | |
// Add each custom module to the $modules array, e.g. `custom-module-1` | |
function wpml_modules_to_translate_filter( $modules ) { | |
// Adding the first module. | |
// `custom-module-1` would be the same as the directory name of your custom module | |
// assuming you've followed BB's directions for creating modules | |
$modules[ 'custom-module-1' ] = [ | |
'conditions' => [ 'type' => 'custom-module-1' ], | |
'fields' => [ | |
[ | |
// `field` is the same thing you would call in BB | |
// when retrieving the data in $settings in your `frontend.php` | |
'field' => 'name-of-field', | |
// `type` is just the label you want to be shown next | |
// to the field in the String Translation Interface | |
'type' => __( 'The Field Label', 'fl-builder' ), | |
// What type of field should String Translation provide? | |
// As of writing, options are LINE, AREA, and VISUAL | |
'editor_type' => 'LINE' | |
], | |
], | |
]; | |
return $modules; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment