| @@ -73,8 +73,10 @@ | ||
| 73 | 73 | $this->_addAction( 'visualizer_chart_schedules_spl', 'addSplChartSchedules', null, 10, 3 ); |
| 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 | } |
| 80 | 82 | |
| @@ -766,8 +768,24 @@ | ||
| 766 | 768 | */ |
| 767 | 769 | private function getDisplayFilters( &$query_args ) { |
| 768 | 770 | $query = array(); |
| 769 | 771 | |
| 772 | + if ( Visualizer_Module::is_pro() && function_exists( 'icl_get_languages' ) ) { | |
| 773 | + $current_lang = icl_get_current_language(); | |
| 774 | + if ( in_array( $current_lang, array( 'all', icl_get_default_language() ), true ) ) { | |
| 775 | + $query[] = array( | |
| 776 | + 'key' => 'chart_lang', | |
| 777 | + 'compare' => 'NOT EXISTS', | |
| 778 | + ); | |
| 779 | + } else { | |
| 780 | + $query[] = array( | |
| 781 | + 'key' => 'chart_lang', | |
| 782 | + 'value' => $current_lang, | |
| 783 | + 'compare' => '=', | |
| 784 | + ); | |
| 785 | + } | |
| 786 | + } | |
| 787 | + | |
| 770 | 788 | // add chart type filter to the query arguments |
| 771 | 789 | $type = filter_input( INPUT_GET, 'type' ); |
| 772 | 790 | if ( $type && in_array( $type, Visualizer_Plugin::getChartTypes(), true ) ) { |
| 773 | 791 | $query[] = array( |
| @@ -1110,6 +1128,51 @@ | ||
| 1110 | 1128 | if ( Visualizer_Module::is_pro() ) { |
| 1111 | 1129 | return true; |
| 1112 | 1130 | } |
| 1113 | 1131 | return 'yes' === get_option( 'visualizer-new-user', 'yes' ) ? false : true; |
| 1132 | + } | |
| 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 | + } | |
| 1114 | 1177 | } |
| 1115 | 1178 | } |