fauzanjeg

JKIT || Add JKIT Widgets to WPML Translate

Jun 6th, 2022 (edited)
1,970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.38 KB | None | 0 0
  1. <?php
  2.  
  3. /** Add JKIT Widgets to WPML Translate */
  4. function add_jkit_widgets_to_translate( $widgets ) {
  5.     /** JKIT - Icon Box */
  6.     $widgets['jkit_icon_box'] = array(
  7.         'conditions' => array( 'widgetType' => 'jkit_icon_box' ),
  8.         'fields'     => array(
  9.             array(
  10.                 'field'       => 'sg_icon_text',
  11.                 'type'        => __( 'JKIT Icon Box: Icon Box: Title', 'jeg-elementor-kit' ),
  12.                 'editor_type' => 'LINE',
  13.             ),
  14.             array(
  15.                 'field'       => 'sg_icon_description',
  16.                 'type'        => __( 'JKIT Icon Box: Icon Box: Description', 'jeg-elementor-kit' ),
  17.                 'editor_type' => 'AREA',
  18.             ),
  19.             array(
  20.                 'field'       => 'sg_readmore_button_label',
  21.                 'type'        => __( 'JKIT Icon Box: Read More: Button Label', 'jeg-elementor-kit' ),
  22.                 'editor_type' => 'LINE',
  23.             ),
  24.             array(
  25.                 'field'       => 'sg_badge_text',
  26.                 'type'        => __( 'JKIT Icon Box: Badge: Text', 'jeg-elementor-kit' ),
  27.                 'editor_type' => 'LINE',
  28.             ),
  29.         ),
  30.     );
  31.  
  32.     /** JKIT - Accordion Widget */
  33.     $widgets['jkit_accordion'] = array(
  34.         'conditions'        => array( 'widgetType' => 'jkit_accordion' ),
  35.         'fields'            => array(),
  36.         'integration-class' => 'WPML_JKIT_Accordion_Custom',
  37.     );
  38.  
  39.     /** JKIT - Portfolio Gallery Widget */
  40.     $widgets['jkit_portfolio_gallery'] = array(
  41.         'conditions'        => array( 'widgetType' => 'jkit_portfolio_gallery' ),
  42.         'fields'            => array(),
  43.         'integration-class' => 'WPML_JKIT_Portfolio_Gallery_Custom',
  44.     );
  45.  
  46.     /** JKIT - Testimonials Widget */
  47.     $widgets['jkit_testimonials'] = array(
  48.         'conditions'        => array( 'widgetType' => 'jkit_testimonials' ),
  49.         'fields'            => array(),
  50.         'integration-class' => 'WPML_JKIT_Testimonials_Custom',
  51.     );
  52.  
  53.     /** JKIT - Heading Widget */
  54.     $widgets['jkit_heading'] = array(
  55.         'conditions' => array( 'widgetType' => 'jkit_heading' ),
  56.         'fields'     => array(
  57.             array(
  58.                 'field'       => 'sg_title_before',
  59.                 'type'        => __( 'JKIT Heading: Title: Before Focused Title', 'jeg-elementor-kit' ),
  60.                 'editor_type' => 'LINE',
  61.             ),
  62.             array(
  63.                 'field'       => 'sg_title_focused',
  64.                 'type'        => __( 'JKIT Heading: Title: Focused Title', 'jeg-elementor-kit' ),
  65.                 'editor_type' => 'LINE',
  66.             ),
  67.             array(
  68.                 'field'       => 'sg_title_after',
  69.                 'type'        => __( 'JKIT Heading: Title: After Focused Title', 'jeg-elementor-kit' ),
  70.                 'editor_type' => 'LINE',
  71.             ),
  72.             array(
  73.                 'field'       => 'sg_subtitle_heading',
  74.                 'type'        => __( 'JKIT Heading: Subtitle: Heading Sub Title', 'jeg-elementor-kit' ),
  75.                 'editor_type' => 'LINE',
  76.             ),
  77.             array(
  78.                 'field'       => 'sg_description',
  79.                 'type'        => __( 'JKIT Heading: Description: Heading Description', 'jeg-elementor-kit' ),
  80.                 'editor_type' => 'VISUAL',
  81.             ),
  82.             array(
  83.                 'field'       => 'sg_shadow_content',
  84.                 'type'        => __( 'JKIT Heading: Shadow Text: Content', 'jeg-elementor-kit' ),
  85.                 'editor_type' => 'LINE',
  86.             ),
  87.         ),
  88.     );
  89.  
  90.     /** JKIT - Image Box Widget */
  91.     $widgets['jkit_image_box'] = array(
  92.         'conditions' => array( 'widgetType' => 'jkit_image_box' ),
  93.         'fields'     => array(
  94.             'sg_image_link'  => array(
  95.                 'field'       => 'sg_image_link',
  96.                 'type'        => __( 'JKIT Image Box: Image: Link', 'jeg-elementor-kit' ),
  97.                 'editor_type' => 'LINK',
  98.             ),
  99.             array(
  100.                 'field'       => 'sg_body_title',
  101.                 'type'        => __( 'JKIT Image Box: Body: Title', 'jeg-elementor-kit' ),
  102.                 'editor_type' => 'LINE',
  103.             ),
  104.             array(
  105.                 'field'       => 'sg_body_description',
  106.                 'type'        => __( 'JKIT Image Box: Body: Description', 'jeg-elementor-kit' ),
  107.                 'editor_type' => 'LINE',
  108.             ),
  109.             array(
  110.                 'field'       => 'sg_button_label',
  111.                 'type'        => __( 'JKIT Image Box: Button: Label', 'jeg-elementor-kit' ),
  112.                 'editor_type' => 'LINE',
  113.             ),
  114.             'sg_button_link' => array(
  115.                 'field'       => 'url',
  116.                 'type'        => __( 'JKIT Image Box: Button: Link', 'jeg-elementor-kit' ),
  117.                 'editor_type' => 'LINK',
  118.             ),
  119.         ),
  120.     );
  121.  
  122.     /** JKIT - Button Widget */
  123.     $widgets['jkit_button'] = array(
  124.         'conditions' => array( 'widgetType' => 'jkit_button' ),
  125.         'fields'     => array(
  126.             array(
  127.                 'field'       => 'sg_content_label',
  128.                 'type'        => __( 'JKIT Button: Content: Label', 'jeg-elementor-kit' ),
  129.                 'editor_type' => 'LINE',
  130.             ),
  131.             'sg_content_link' => array(
  132.                 'field'       => 'url',
  133.                 'type'        => __( 'JKIT Button: Content: Link', 'jeg-elementor-kit' ),
  134.                 'editor_type' => 'LINK',
  135.             ),
  136.             array(
  137.                 'field'       => 'sg_content_class',
  138.                 'type'        => __( 'JKIT Button: Content: Class', 'jeg-elementor-kit' ),
  139.                 'editor_type' => 'LINE',
  140.             ),
  141.             array(
  142.                 'field'       => 'sg_button_label',
  143.                 'type'        => __( 'JKIT Image Box: Button: Label', 'jeg-elementor-kit' ),
  144.                 'editor_type' => 'LINE',
  145.             ),
  146.             array(
  147.                 'field'       => 'sg_content_id',
  148.                 'type'        => __( 'JKIT Image Box: Button: ID', 'jeg-elementor-kit' ),
  149.                 'editor_type' => 'LINE',
  150.             ),
  151.         ),
  152.     );
  153.  
  154.     /** JKIT - Animated Text */
  155.     $widgets['jkit_animated_text'] = array(
  156.         'conditions'        => array( 'widgetType' => 'jkit_animated_text' ),
  157.         'fields'            => array(
  158.             array(
  159.                 'field'       => 'sg_text_before',
  160.                 'type'        => __( 'JKIT Animated Text: Text: Before Text', 'jeg-elementor-kit' ),
  161.                 'editor_type' => 'LINE',
  162.             ),
  163.             array(
  164.                 'field'       => 'sg_text_animated',
  165.                 'type'        => __( 'JKIT Animated Text: Text: Animated Text', 'jeg-elementor-kit' ),
  166.                 'editor_type' => 'LINE',
  167.             ),
  168.             array(
  169.                 'field'       => 'sg_text_after',
  170.                 'type'        => __( 'JKIT Animated Text: Text: Rotating Text', 'jeg-elementor-kit' ),
  171.                 'editor_type' => 'LINE',
  172.             ),
  173.         ),
  174.         'integration-class' => 'WPML_JKIT_Animated_Text_Custom',
  175.     );
  176.  
  177.     /** JKIT - Pie Chart */
  178.     $widgets['jkit_pie_chart'] = array(
  179.         'conditions' => array( 'widgetType' => 'jkit_pie_chart' ),
  180.         'fields'     => array(
  181.             array(
  182.                 'field'       => 'sg_content_title',
  183.                 'type'        => __( 'JKIT Pie Chart: Content: Title', 'jeg-elementor-kit' ),
  184.                 'editor_type' => 'LINE',
  185.             ),
  186.             array(
  187.                 'field'       => 'sg_content_description',
  188.                 'type'        => __( 'JKIT Pie Chart: Content: Description', 'jeg-elementor-kit' ),
  189.                 'editor_type' => 'AREA',
  190.             ),
  191.         ),
  192.     );
  193.  
  194.     /** JKIT - Fun Fact */
  195.     $widgets['jkit_fun_fact'] = array(
  196.         'conditions' => array( 'widgetType' => 'jkit_fun_fact' ),
  197.         'fields'     => array(
  198.             array(
  199.                 'field'       => 'sg_content_number_prefix',
  200.                 'type'        => __( 'JKIT Fun Fact: Content: Number Prefix', 'jeg-elementor-kit' ),
  201.                 'editor_type' => 'LINE',
  202.             ),
  203.             array(
  204.                 'field'       => 'sg_content_number',
  205.                 'type'        => __( 'JKIT Fun Fact: Content: Number', 'jeg-elementor-kit' ),
  206.                 'editor_type' => 'LINE',
  207.             ),
  208.             array(
  209.                 'field'       => 'sg_content_number_suffix',
  210.                 'type'        => __( 'JKIT Fun Fact: Content: Number Suffix', 'jeg-elementor-kit' ),
  211.                 'editor_type' => 'LINE',
  212.             ),
  213.             array(
  214.                 'field'       => 'sg_content_title',
  215.                 'type'        => __( 'JKIT Fun Fact: Content: Title', 'jeg-elementor-kit' ),
  216.                 'editor_type' => 'LINE',
  217.             ),
  218.             array(
  219.                 'field'       => 'sg_content_super',
  220.                 'type'        => __( 'JKIT Fun Fact: Content: Super', 'jeg-elementor-kit' ),
  221.                 'editor_type' => 'LINE',
  222.             ),
  223.         ),
  224.     );
  225.  
  226.     /** JKIT - Team */
  227.     $widgets['jkit_team'] = array(
  228.         'conditions' => array( 'widgetType' => 'jkit_team' ),
  229.         'fields'     => array(
  230.             array(
  231.                 'field'       => 'sg_member_name',
  232.                 'type'        => __( 'JKIT Team: Team Member: Member Name', 'jeg-elementor-kit' ),
  233.                 'editor_type' => 'LINE',
  234.             ),
  235.             array(
  236.                 'field'       => 'sg_member_position',
  237.                 'type'        => __( 'JKIT Team: Team Member: Position', 'jeg-elementor-kit' ),
  238.                 'editor_type' => 'LINE',
  239.             ),
  240.             array(
  241.                 'field'       => 'sg_member_description',
  242.                 'type'        => __( 'JKIT Team: Team Member: Description', 'jeg-elementor-kit' ),
  243.                 'editor_type' => 'AREA',
  244.             ),
  245.             array(
  246.                 'field'       => 'sg_popup_phone',
  247.                 'type'        => __( 'JKIT Team: Team Member: Phone', 'jeg-elementor-kit' ),
  248.                 'editor_type' => 'LINE',
  249.             ),
  250.             array(
  251.                 'field'       => 'sg_popup_email',
  252.                 'type'        => __( 'JKIT Team: Team Member: Email', 'jeg-elementor-kit' ),
  253.                 'editor_type' => 'LINE',
  254.             ),
  255.         ),
  256.     );
  257.  
  258.     /** JKIT - Post Block */
  259.     $widgets['jkit_post_block'] = array(
  260.         'conditions' => array( 'widgetType' => 'jkit_post_block' ),
  261.         'fields'     => array(
  262.             array(
  263.                 'field'       => 'sg_content_excerpt_more',
  264.                 'type'        => __( 'JKIT Post Block: Content Setting: Excerpt More', 'jeg-elementor-kit' ),
  265.                 'editor_type' => 'LINE',
  266.             ),
  267.             array(
  268.                 'field'       => 'sg_content_readmore_text',
  269.                 'type'        => __( 'JKIT Post Block: Content Setting: Read More Text', 'jeg-elementor-kit' ),
  270.                 'editor_type' => 'LINE',
  271.             ),
  272.             array(
  273.                 'field'       => 'sg_content_meta_author_by_text',
  274.                 'type'        => __( 'JKIT Post Block: Content Setting: Meta Author "by" Text', 'jeg-elementor-kit' ),
  275.                 'editor_type' => 'LINE',
  276.             ),
  277.             array(
  278.                 'field'       => 'sg_content_meta_date_format_custom',
  279.                 'type'        => __( 'JKIT Post Block: Content Setting: Post Date Custom Format', 'jeg-elementor-kit' ),
  280.                 'editor_type' => 'LINE',
  281.             ),
  282.             /** Pagination Section */
  283.             array(
  284.                 'field'       => 'pagination_prev_text',
  285.                 'type'        => __( 'JKIT Post Block: Pagination: Previous Text', 'jeg-elementor-kit' ),
  286.                 'editor_type' => 'LINE',
  287.             ),
  288.             array(
  289.                 'field'       => 'pagination_next_text',
  290.                 'type'        => __( 'JKIT Post Block: Pagination: Next Text', 'jeg-elementor-kit' ),
  291.                 'editor_type' => 'LINE',
  292.             ),
  293.             array(
  294.                 'field'       => 'pagination_loadmore_text',
  295.                 'type'        => __( 'JKIT Post Block: Pagination: Load More Text', 'jeg-elementor-kit' ),
  296.                 'editor_type' => 'LINE',
  297.             ),
  298.             array(
  299.                 'field'       => 'pagination_loading_text',
  300.                 'type'        => __( 'JKIT Post Block: Pagination: Loading Text', 'jeg-elementor-kit' ),
  301.                 'editor_type' => 'LINE',
  302.             ),
  303.         ),
  304.     );
  305.  
  306.     return $widgets;
  307. }
  308. add_filter( 'wpml_elementor_widgets_to_translate', 'add_jkit_widgets_to_translate' );
  309.  
  310. /** Add a custom class for widget translation who have a Repeater Control */
  311. add_action(
  312.     'init',
  313.     function () {
  314.         if ( ! class_exists( 'WPML_Elementor_Module_With_Items' ) ) {
  315.             return;
  316.         }
  317.  
  318.         /** class JKIT Accordion Translation */
  319.         class WPML_JKIT_Accordion_Custom extends WPML_Elementor_Module_With_Items {
  320.             /**
  321.              * @return string
  322.              */
  323.             public function get_items_field() {
  324.                 return 'sg_accordion_list';
  325.             }
  326.  
  327.             /**
  328.              * @return array
  329.              */
  330.             public function get_fields() {
  331.                 return array( 'sg_accordion_list_title', 'sg_accordion_list_content' );
  332.             }
  333.  
  334.             /**
  335.              * @param string $field
  336.              *
  337.              * @return string
  338.              */
  339.             protected function get_title( $field ) {
  340.                 switch ( $field ) {
  341.                     case 'sg_accordion_list_title':
  342.                         return esc_html__( 'JKIT Accordion: Accordion: Title', 'jeg-elementor-kit' );
  343.                     case 'sg_accordion_list_content':
  344.                         return esc_html__( 'JKIT Accordion: Accordion: Content Description', 'jeg-elementor-kit' );
  345.                     default:
  346.                         return '';
  347.                 }
  348.             }
  349.  
  350.             /**
  351.              * @param string $field
  352.              *
  353.              * @return string
  354.              */
  355.             protected function get_editor_type( $field ) {
  356.                 switch ( $field ) {
  357.                     case 'sg_accordion_list_title':
  358.                         return 'LINE';
  359.                     case 'sg_accordion_list_content':
  360.                         return 'VISUAL';
  361.                     default:
  362.                         return '';
  363.                 }
  364.             }
  365.         }
  366.  
  367.         /** class JKIT Portfolio Gallery Translation */
  368.         class WPML_JKIT_Portfolio_Gallery_Custom extends WPML_Elementor_Module_With_Items {
  369.             /**
  370.              * @return string
  371.              */
  372.             public function get_items_field() {
  373.                 return 'sg_gallery_list';
  374.             }
  375.  
  376.             /**
  377.              * @return array
  378.              */
  379.             public function get_fields() {
  380.                 return array( 'sg_gallery_list_title', 'sg_gallery_list_subtitle', 'sg_gallery_list_more_link' => array( 'url' ), 'sg_gallery_list_more_text' );
  381.             }
  382.  
  383.             /**
  384.              * @param string $field
  385.              *
  386.              * @return string
  387.              */
  388.             protected function get_title( $field ) {
  389.                 switch ( $field ) {
  390.                     case 'sg_gallery_list_title':
  391.                         return esc_html__( 'JKIT Portfolio Gallery: Gallery: Title', 'jeg-elementor-kit' );
  392.                     case 'sg_gallery_list_subtitle':
  393.                         return esc_html__( 'JKIT Portfolio Gallery: Gallery: Sub Title', 'jeg-elementor-kit' );
  394.                     case 'url':
  395.                         return esc_html__( 'JKIT Portfolio Gallery: Gallery: View More Link', 'jeg-elementor-kit' );
  396.                     case 'sg_gallery_list_more_text':
  397.                         return esc_html__( 'JKIT Portfolio Gallery: Gallery: View More Text', 'jeg-elementor-kit' );
  398.                     default:
  399.                         return '';
  400.                 }
  401.             }
  402.  
  403.             /**
  404.              * @param string $field
  405.              *
  406.              * @return string
  407.              */
  408.             protected function get_editor_type( $field ) {
  409.                 switch ( $field ) {
  410.                     case 'sg_gallery_list_title':
  411.                     case 'sg_gallery_list_subtitle':
  412.                     case 'sg_gallery_list_more_text':
  413.                         return 'LINE';
  414.                     case 'url':
  415.                         return 'LINK';
  416.                     default:
  417.                         return '';
  418.                 }
  419.             }
  420.         }
  421.  
  422.         /** class JKIT Testimonials Translation */
  423.         class WPML_JKIT_Testimonials_Custom extends WPML_Elementor_Module_With_Items {
  424.             /**
  425.              * @return string
  426.              */
  427.             public function get_items_field() {
  428.                 return 'sg_testimonials_list';
  429.             }
  430.  
  431.             /**
  432.              * @return array
  433.              */
  434.             public function get_fields() {
  435.                 return array( 'sg_testimonials_list_client_name', 'sg_testimonials_list_designation', 'sg_testimonials_list_review' );
  436.             }
  437.  
  438.             /**
  439.              * @param string $field
  440.              *
  441.              * @return string
  442.              */
  443.             protected function get_title( $field ) {
  444.                 switch ( $field ) {
  445.                     case 'sg_testimonials_list_client_name':
  446.                         return esc_html__( 'JKIT Testimonials: Testimonials: Client Name', 'jeg-elementor-kit' );
  447.                     case 'sg_testimonials_list_designation':
  448.                         return esc_html__( 'JKIT Testimonials: Testimonials: Designation', 'jeg-elementor-kit' );
  449.                     case 'sg_testimonials_list_review':
  450.                         return esc_html__( 'JKIT Testimonials: Testimonials: Review', 'jeg-elementor-kit' );
  451.                     default:
  452.                         return '';
  453.                 }
  454.             }
  455.  
  456.             /**
  457.              * @param string $field
  458.              *
  459.              * @return string
  460.              */
  461.             protected function get_editor_type( $field ) {
  462.                 switch ( $field ) {
  463.                     case 'sg_testimonials_list_client_name':
  464.                         return 'LINE';
  465.                     case 'sg_testimonials_list_designation':
  466.                         return 'LINE';
  467.                     case 'sg_testimonials_list_review':
  468.                         return 'LINE';
  469.                     default:
  470.                         return '';
  471.                 }
  472.             }
  473.         }
  474.  
  475.         /** class JKIT Animated Text Translation */
  476.         class WPML_JKIT_Animated_Text_Custom extends WPML_Elementor_Module_With_Items {
  477.             /**
  478.              * @return string
  479.              */
  480.             public function get_items_field() {
  481.                 return 'sg_text_rotating_list';
  482.             }
  483.  
  484.             /**
  485.              * @return array
  486.              */
  487.             public function get_fields() {
  488.                 return array( 'sg_text_rotating_list_text' );
  489.             }
  490.  
  491.             /**
  492.              * @param string $field
  493.              *
  494.              * @return string
  495.              */
  496.             protected function get_title( $field ) {
  497.                 switch ( $field ) {
  498.                     case 'sg_text_rotating_list_text':
  499.                         return esc_html__( 'JKIT Testimonials: Text: Rotating Text', 'jeg-elementor-kit' );
  500.                     default:
  501.                         return '';
  502.                 }
  503.             }
  504.  
  505.             /**
  506.              * @param string $field
  507.              *
  508.              * @return string
  509.              */
  510.             protected function get_editor_type( $field ) {
  511.                 switch ( $field ) {
  512.                     case 'sg_text_rotating_list_text':
  513.                         return 'LINE';
  514.                     default:
  515.                         return '';
  516.                 }
  517.             }
  518.         }
  519.     }
  520. );
  521.  
Advertisement
Add Comment
Please, Sign In to add comment