Skip to content

Commit

Permalink
Merge pull request #959 from Codeinwp/enhancement/pro/360
Browse files Browse the repository at this point in the history
Show new features on chart library page
  • Loading branch information
vytisbulkevicius authored Nov 10, 2022
2 parents f616cf3 + 87582e5 commit 1c811c6
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
47 changes: 47 additions & 0 deletions classes/Visualizer/Module/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public function __construct( Visualizer_Plugin $plugin ) {

$this->_addAction( 'admin_init', 'init' );

$this->_addAction( 'visualizer_chart_languages', 'addMultilingualSupport' );

if ( defined( 'TI_CYPRESS_TESTING' ) ) {
$this->load_cypress_hooks();
}
Expand Down Expand Up @@ -1128,4 +1130,49 @@ public static function proFeaturesLocked() {
}
return 'yes' === get_option( 'visualizer-new-user', 'yes' ) ? false : true;
}

/**
* Multilingual Support.
*
* @param int $chart_id Chart ID.
* @return bool Default false
*/
public function addMultilingualSupport( $chart_id ) {
if ( Visualizer_Module::is_pro() ) {
return;
}
if ( function_exists( 'icl_get_languages' ) ) {
$language = icl_get_languages();
$current_lang = icl_get_current_language();
$default_lang = icl_get_default_language();
$post_info = wpml_get_language_information( null, $chart_id );

global $sitepress;
$translations = array();
if ( ! empty( $post_info ) && ( $default_lang === $post_info['language_code'] ) ) {
$trid = $sitepress->get_element_trid( $chart_id, 'post_' . Visualizer_Plugin::CPT_VISUALIZER );
$translations = $sitepress->get_element_translations( $trid );
}
if ( empty( $translations ) ) {
return;
}
?>
<hr><div class="visualizer-languages-list only-pro">
<?php
foreach ( $language as $lang ) {
$lang_code = $lang['code'];
if ( $current_lang !== $lang_code ) {
?>
<a href="javascript:;">
<img src="<?php echo esc_url( $lang['country_flag_url'] ); ?>" alt="<?php echo esc_attr( $lang['translated_name'] ); ?>">
</a>
<?php
}
}
?>
<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>
</div>
<?php
}
}
}
2 changes: 2 additions & 0 deletions classes/Visualizer/Render/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ private function _renderSidebar() {
echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Create charts from WordPress tables', 'visualizer' ) . '</li>';
echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Frontend editor', 'visualizer' ) . '</li>';
echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Private charts', 'visualizer' ) . '</li>';
echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'WPML support for translating charts', 'visualizer' ) . '</li>';
echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Integration with Woocommerce Data endpoints', 'visualizer' ) . '</li>';
echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Auto-sync with online files', 'visualizer' ) . '</li></ul>';
echo '<p><a href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'sidebarupsell' ) . '" target="_blank" class="button button-primary">' . __( 'View more features', 'visualizer' ) . '</a></p>';
echo '</div>';
Expand Down
15 changes: 12 additions & 3 deletions css/library.css
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,22 @@ div#visualizer-types ul, div#visualizer-types form p {
outline: none;
box-shadow: none;
}
.visualizer-languages-list i {
.visualizer-languages-list:not(.only-pro) i {
display: none;
}
.visualizer-languages-list a:hover img {
.visualizer-languages-list:not(.only-pro) a:hover img {
display: none;
}
.visualizer-languages-list a:hover img + i {
.visualizer-languages-list:not(.only-pro) a:hover img + i {
display: block;
}
.visualizer-languages-list.only-pro a:last-child {
display: none;
}
.visualizer-languages-list.only-pro:hover a:not(:last-child) {
display: none;
}
.visualizer-languages-list.only-pro:hover a:last-child {
display: block;
}
@media (-webkit-min-device-pixel-ratio: 2) and (min-width: 1000px) and (max-width: 1600px) {
Expand Down

0 comments on commit 1c811c6

Please sign in to comment.