Advertisement
AlejandroS13

Qode - Elementor + WPML Widget Registration

Mar 3rd, 2020
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.34 KB | None | 0 0
  1. /**
  2. * Translate Button V2, Simple Quote and blockquote
  3. * @param array $widgets
  4. * @return array
  5. */
  6.  
  7.  
  8. add_action('init', function (){
  9.     add_filter( 'wpml_elementor_widgets_to_translate', 'qode_to_WPML' );
  10. });
  11.  
  12. function qode_to_WPML($widgets) {
  13.     $widgets['bridge_button_v2'] = [
  14.         'conditions' => ['widgetType' => 'bridge_button_v2'],
  15.         'fields' => [
  16.             [
  17.                 'field' => 'text',
  18.                 'type' => __('Text', 'bridge-core'),
  19.                 'editor_type' => 'LINE'
  20.             ], //END OF FIRST WIDGET ELEMENT REGISTRATION
  21.            
  22.             [
  23.                 'field' => 'link',
  24.                 'type' => __('Link', 'bridge-core'),
  25.                 'editor_type' => 'LINK'
  26.             ], //END OF SECOND WIDGET ELEMENT REGISTRATION
  27.            
  28.         ],
  29.     ];
  30.  
  31.     $widgets['bridge_simple_quote'] = [
  32.         'conditions' => ['widgetType' => 'bridge_simple_quote'],
  33.         'fields' => [
  34.             [
  35.                 'field' => 'simple_quote_text',
  36.                 'type' => __('Simple Quote Text', 'bridge-core'),
  37.                 'editor_type' => 'LINE'
  38.             ], //END OF FIRST WIDGET ELEMENT REGISTRATION
  39.            
  40.             [
  41.                 'field' => 'simple_quote_author',
  42.                 'type' => __('Simple Quote Author', 'bridge-core'),
  43.                 'editor_type' => 'LINE'
  44.             ], //END OF SECOND WIDGET ELEMENT REGISTRATION
  45.            
  46.         ],
  47.     ];
  48.  
  49.     $widgets['bridge_blockquote'] = [
  50.         'conditions' => ['widgetType' => 'bridge_blockquote'],
  51.         'fields' => [
  52.             [
  53.                 'field' => 'text',
  54.                 'type' => __( "Text", 'bridge-core' ),
  55.                 'editor_type' => 'AREA'
  56.             ], //END OF FIRST WIDGET ELEMENT REGISTRATION
  57.            
  58.         ],
  59.     ];
  60.  
  61. return $widgets;
  62. }
  63.  
  64.  
  65. /**
  66. * Translate Numbered Process and Process Widgets
  67. * @param array $widgets
  68. * @return array
  69. */
  70.  
  71. add_action('init', function (){
  72.         add_filter( 'wpml_elementor_widgets_to_translate', 'qode_elementor_WPML_registration' );
  73. });
  74.  
  75.  
  76. function qode_elementor_WPML_registration($widgets)
  77. {
  78.         $widgets['bridge_numbered_process'] = array(
  79.                 'conditions' => array('widgetType' => 'bridge_numbered_process'),
  80.                 'fields' => array(),
  81.                 'integration-class' => array(
  82.                         'numbered_items',
  83.                          
  84.                 )
  85.         );
  86.         $widgets['bridge_circles'] = array(
  87.                 'conditions' => array('widgetType' => 'bridge_circles'),
  88.                 'fields' => array(),
  89.                 'integration-class' => array(
  90.                         'process_items',
  91.                          
  92.                 )
  93.         );
  94.  
  95.         return $widgets;
  96. }
  97.  
  98. class numbered_items extends WPML_Elementor_Module_With_Items
  99. {
  100.  
  101.         public function get_items_field()
  102.         {
  103.                 return 'numbered_process_items';
  104.         }
  105.  
  106.         public function get_fields()
  107.         {
  108.                 return array(
  109.                         'number',
  110.                         'title',
  111.                 );
  112.         }
  113.  
  114.         protected function get_title($field)
  115.         {
  116.                 switch ($field) {
  117.                         case 'number':
  118.                                 return __('Number', 'bridge-core');
  119.                        
  120.                         case 'title':
  121.                                 return __('Title', 'bridge-core');
  122.                        
  123.                         default:
  124.                                 return '';
  125.                 }
  126.         }
  127.  
  128.         protected function get_editor_type($field)
  129.         {
  130.                 switch ($field) {
  131.                         case 'number':
  132.                                 return 'LINE';
  133.  
  134.                         case 'title':
  135.                                 return 'LINE';
  136.                        
  137.                         default:
  138.                                 return '';
  139.                 }
  140.         }
  141. }
  142.  
  143.  
  144. class process_items extends WPML_Elementor_Module_With_Items
  145. {
  146.  
  147.         public function get_items_field()
  148.         {
  149.                 return 'circles';
  150.         }
  151.  
  152.         public function get_fields()
  153.         {
  154.                 return array(
  155.                         'text_in_circle',
  156.                         'link',
  157.                         'title',
  158.                         'text',
  159.                 );
  160.         }
  161.  
  162.         protected function get_title($field)
  163.         {
  164.                 switch ($field) {
  165.                         case 'text_in_circle':
  166.                                 return __( 'Text in Process', 'bridge-core');
  167.                        
  168.                         case 'title':
  169.                                 return __( 'Title', 'bridge-core');
  170.  
  171.                         case 'link':
  172.                                 return __( 'Link', 'bridge-core');
  173.                        
  174.                         case 'text':
  175.                                 return __( 'Text', 'bridge-core');
  176.                        
  177.                         default:
  178.                                 return '';
  179.                 }
  180.         }
  181.  
  182.         protected function get_editor_type($field)
  183.         {
  184.                 switch ($field) {
  185.                         case 'text_in_circle':
  186.                                 return 'LINE';
  187.  
  188.                         case 'title':
  189.                                 return 'LINE';
  190.  
  191.                         case 'link':
  192.                                 return 'LINK';
  193.                        
  194.                         case 'text':
  195.                                 return 'AREA';
  196.  
  197.                         default:
  198.                                 return '';
  199.                 }
  200.         }
  201. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement