@@ -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 }
@@ -1123,9 +1125,55 @@ public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
11231125 * @return bool Default false
11241126 */
11251127 public static function proFeaturesLocked () {
1128+ return false ;
11261129 if ( Visualizer_Module::is_pro () ) {
11271130 return true ;
11281131 }
11291132 return 'yes ' === get_option ( 'visualizer-new-user ' , 'yes ' ) ? false : true ;
11301133 }
1134+
1135+ /**
1136+ * Multilingual Support.
1137+ *
1138+ * @param int $chart_id Chart ID.
1139+ * @return bool Default false
1140+ */
1141+ public function addMultilingualSupport ( $ chart_id ) {
1142+ if ( Visualizer_Module::is_pro () ) {
1143+ return ;
1144+ }
1145+ if ( function_exists ( 'icl_get_languages ' ) ) {
1146+ $ language = icl_get_languages ();
1147+ $ current_lang = icl_get_current_language ();
1148+ $ default_lang = icl_get_default_language ();
1149+ $ post_info = wpml_get_language_information ( null , $ chart_id );
1150+
1151+ global $ sitepress ;
1152+ $ translations = array ();
1153+ if ( ! empty ( $ post_info ) && ( $ default_lang === $ post_info ['language_code ' ] ) ) {
1154+ $ trid = $ sitepress ->get_element_trid ( $ chart_id , 'post_ ' . Visualizer_Plugin::CPT_VISUALIZER );
1155+ $ translations = $ sitepress ->get_element_translations ( $ trid );
1156+ }
1157+ if ( empty ( $ translations ) ) {
1158+ return ;
1159+ }
1160+ ?>
1161+ <hr><div class="visualizer-languages-list only-pro">
1162+ <?php
1163+ foreach ( $ language as $ lang ) {
1164+ $ lang_code = $ lang ['code ' ];
1165+ if ( $ current_lang !== $ lang_code ) {
1166+ ?>
1167+ <a href="javascript:;">
1168+ <img src="<?php echo esc_url ( $ lang ['country_flag_url ' ] ); ?> " alt="<?php echo esc_attr ( $ lang ['translated_name ' ] ); ?> ">
1169+ </a>
1170+ <?php
1171+ }
1172+ }
1173+ ?>
1174+ <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>
1175+ </div>
1176+ <?php
1177+ }
1178+ }
11311179}
0 commit comments