fauzanjeg

JKIT || Add JKIT Widgets to WPML Translate

May 18th, 2022 (edited)
1,273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.51 KB | None | 0 0
  1. /** Add JKIT Widgets to WPML Translate (Icon Box and Accordion widgets) */
  2. function add_jkit_widgets_to_translate( $widgets ) {
  3.     $widgets['jkit_icon_box'] = array(
  4.         'conditions' => array( 'widgetType' => 'jkit_icon_box' ),
  5.         'fields'     => array(
  6.             array(
  7.                 'field'       => 'sg_icon_text',
  8.                 'type'        => __( 'JKIT Icon Box: Icon Box: Title', 'jeg-elementor-kit' ),
  9.                 'editor_type' => 'LINE',
  10.             ),
  11.             array(
  12.                 'field'       => 'sg_icon_description',
  13.                 'type'        => __( 'JKIT Icon Box: Icon Box: Description', 'jeg-elementor-kit' ),
  14.                 'editor_type' => 'AREA',
  15.             ),
  16.             array(
  17.                 'field'       => 'sg_readmore_button_label',
  18.                 'type'        => __( 'JKIT Icon Box: Read More: Button Label', 'jeg-elementor-kit' ),
  19.                 'editor_type' => 'LINE',
  20.             ),
  21.             array(
  22.                 'field'       => 'sg_badge_text',
  23.                 'type'        => __( 'JKIT Icon Box: Badge: Text', 'jeg-elementor-kit' ),
  24.                 'editor_type' => 'LINE',
  25.             ),
  26.         ),
  27.     );
  28.  
  29.     $widgets['jkit_accordion'] = array(
  30.         'conditions'        => array( 'widgetType' => 'jkit_accordion' ),
  31.         'fields'            => array(),
  32.         'integration-class' => 'WPML_JKIT_Accordion_Custom',
  33.     );
  34.  
  35.     return $widgets;
  36. }
  37. add_filter( 'wpml_elementor_widgets_to_translate', 'add_jkit_widgets_to_translate' );
  38.  
  39. /** Add custom class for JKIT Accordion widget translation*/
  40. add_action(
  41.     'init',
  42.     function() {
  43.         /** Class JKIT Accordion Translation */
  44.         class WPML_JKIT_Accordion_Custom extends WPML_Elementor_Module_With_Items {
  45.             /**
  46.              * @return string
  47.              */
  48.             public function get_items_field() {
  49.                 return 'sg_accordion_list';
  50.             }
  51.  
  52.             /**
  53.              * @return array
  54.              */
  55.             public function get_fields() {
  56.                 return array( 'sg_accordion_list_title', 'sg_accordion_list_content' );
  57.             }
  58.  
  59.             /**
  60.              * @param string $field
  61.              *
  62.              * @return string
  63.              */
  64.             protected function get_title( $field ) {
  65.                 switch ( $field ) {
  66.                     case 'sg_accordion_list_title':
  67.                         return esc_html__( 'JKIT Accordion: Accordion: Title', 'jeg-elementor-kit' );
  68.                     case 'sg_accordion_list_content':
  69.                         return esc_html__( 'JKIT Accordion: Accordion: Content Description', 'jeg-elementor-kit' );
  70.                     default:
  71.                         return '';
  72.                 }
  73.             }
  74.  
  75.             /**
  76.              * @param string $field
  77.              *
  78.              * @return string
  79.              */
  80.             protected function get_editor_type( $field ) {
  81.                 switch ( $field ) {
  82.                     case 'sg_accordion_list_title':
  83.                         return 'LINE';
  84.                     case 'sg_accordion_list_content':
  85.                         return 'VISUAL';
  86.                     default:
  87.                         return '';
  88.                 }
  89.             }
  90.         }
  91.     }
  92. );
Add Comment
Please, Sign In to add comment