@@ -74,6 +74,8 @@ public function __construct( Visualizer_Plugin $plugin ) {
74
74
75
75
$ this ->_addAction ( 'admin_init ' , 'init ' );
76
76
77
+ $ this ->_addAction ( 'visualizer_chart_languages ' , 'addMultilingualSupport ' );
78
+
77
79
if ( defined ( 'TI_CYPRESS_TESTING ' ) ) {
78
80
$ this ->load_cypress_hooks ();
79
81
}
@@ -1123,9 +1125,55 @@ public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
1123
1125
* @return bool Default false
1124
1126
*/
1125
1127
public static function proFeaturesLocked () {
1128
+ return false ;
1126
1129
if ( Visualizer_Module::is_pro () ) {
1127
1130
return true ;
1128
1131
}
1129
1132
return 'yes ' === get_option ( 'visualizer-new-user ' , 'yes ' ) ? false : true ;
1130
1133
}
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
+ }
1131
1179
}
0 commit comments