@@ -74,6 +74,8 @@ public function __construct( Visualizer_Plugin $plugin ) {
7474
7575 $ this ->_addAction ( 'admin_init ' , 'init ' );
7676
77+ $ this ->_addAction ( 'visualizer_chart_languages ' , 'addMultilingualSupport ' );
78+
7779 if ( defined ( 'TI_CYPRESS_TESTING ' ) ) {
7880 $ this ->load_cypress_hooks ();
7981 }
@@ -1128,4 +1130,49 @@ public static function proFeaturesLocked() {
11281130 }
11291131 return 'yes ' === get_option ( 'visualizer-new-user ' , 'yes ' ) ? false : true ;
11301132 }
1133+
1134+ /**
1135+ * Multilingual Support.
1136+ *
1137+ * @param int $chart_id Chart ID.
1138+ * @return bool Default false
1139+ */
1140+ public function addMultilingualSupport ( $ chart_id ) {
1141+ if ( Visualizer_Module::is_pro () ) {
1142+ return ;
1143+ }
1144+ if ( function_exists ( 'icl_get_languages ' ) ) {
1145+ $ language = icl_get_languages ();
1146+ $ current_lang = icl_get_current_language ();
1147+ $ default_lang = icl_get_default_language ();
1148+ $ post_info = wpml_get_language_information ( null , $ chart_id );
1149+
1150+ global $ sitepress ;
1151+ $ translations = array ();
1152+ if ( ! empty ( $ post_info ) && ( $ default_lang === $ post_info ['language_code ' ] ) ) {
1153+ $ trid = $ sitepress ->get_element_trid ( $ chart_id , 'post_ ' . Visualizer_Plugin::CPT_VISUALIZER );
1154+ $ translations = $ sitepress ->get_element_translations ( $ trid );
1155+ }
1156+ if ( empty ( $ translations ) ) {
1157+ return ;
1158+ }
1159+ ?>
1160+ <hr><div class="visualizer-languages-list only-pro">
1161+ <?php
1162+ foreach ( $ language as $ lang ) {
1163+ $ lang_code = $ lang ['code ' ];
1164+ if ( $ current_lang !== $ lang_code ) {
1165+ ?>
1166+ <a href="javascript:;">
1167+ <img src="<?php echo esc_url ( $ lang ['country_flag_url ' ] ); ?> " alt="<?php echo esc_attr ( $ lang ['translated_name ' ] ); ?> ">
1168+ </a>
1169+ <?php
1170+ }
1171+ }
1172+ ?>
1173+ <a href="<?php echo tsdk_utmify ( Visualizer_Plugin::PRO_TEASER_URL , 'wpml-support ' , 'visualizer_render_char ' ); ?> "target="_blank"><?php esc_html_e ( 'Upgrade to PRO to active this translation for charts ' , 'visualizer ' ); ?> </a>
1174+ </div>
1175+ <?php
1176+ }
1177+ }
11311178}
0 commit comments