Skip to content

Commit da64108

Browse files
fix: various issues (#1282)
* fix: pro upsell appearing in plugin meta even when pro is there * fix: some charts showing up as available for free * fix: rate it not always visible * fix: make License link point to the exact option on the page * fix: update docs search link * fix: e2e tests * chore: fix qa
1 parent d253049 commit da64108

7 files changed

Lines changed: 61 additions & 23 deletions

File tree

classes/Visualizer/Module/Admin.php

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function render_review_notice( $footer_text ) {
113113
__( 'Enjoying %1$s? %2$s %3$s rating. Thank you for being so supportive!', 'visualizer' ),
114114
'<b>Visualizer</b>',
115115
esc_html__( 'You can help us by leaving a', 'visualizer' ),
116-
'<a href="https://wordpress.org/support/plugin/visualizer/reviews/" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
116+
'<a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
117117
);
118118
break;
119119
}
@@ -427,7 +427,7 @@ public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darra
427427
);
428428
}
429429

430-
$enabled = self::proFeaturesLocked();
430+
$enabled = self::proFeaturesEnabled();
431431

432432
$types = array_merge(
433433
$additional,
@@ -1163,6 +1163,20 @@ public function getPluginActionLinks( $links, $file ) {
11631163
* @return array Updated array of plugin meta links.
11641164
*/
11651165
public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
1166+
if ( Visualizer_Module::is_pro() ) {
1167+
return $plugin_meta;
1168+
}
1169+
1170+
// Also suppress the upsell when Pro is installed but not currently active.
1171+
if ( ! function_exists( 'get_plugins' ) ) {
1172+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
1173+
}
1174+
foreach ( array_keys( get_plugins() ) as $installed_plugin ) {
1175+
if ( false !== strpos( $installed_plugin, 'visualizer-pro' ) ) {
1176+
return $plugin_meta;
1177+
}
1178+
}
1179+
11661180
if ( $plugin_file === plugin_basename( VISUALIZER_BASEFILE ) ) {
11671181
// knowledge base link
11681182
$plugin_meta[] = sprintf(
@@ -1180,15 +1194,37 @@ public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
11801194
}
11811195

11821196
/**
1183-
* If check is existing user.
1197+
* Returns true when premium chart types should be enabled for the current user.
11841198
*
1185-
* @return bool Default false
1199+
* Pro 1.9.0+ hooks the 'visualizer_is_pro' filter and returns true only when
1200+
* the license is valid. Pre-1.9.0 Pro defined a Visualizer_Pro class instead;
1201+
* we detect that as a fallback so those legacy installs still work.
1202+
*
1203+
* Passing false as the filter default ensures the constant VISUALIZER_PRO
1204+
* (which is set to true whenever the Pro class exists, regardless of license
1205+
* state) cannot bypass the license check.
1206+
*
1207+
* @return bool
11861208
*/
1187-
public static function proFeaturesLocked() {
1188-
if ( Visualizer_Module::is_pro() ) {
1209+
public static function proFeaturesEnabled() {
1210+
$is_pro_filter = apply_filters( 'visualizer_is_pro', false );
1211+
1212+
// Pro 1.9.0+: filter is hooked and returns true only with a valid license.
1213+
if ( $is_pro_filter ) {
11891214
return true;
11901215
}
1191-
return 'yes' === get_option( 'visualizer-new-user', 'yes' ) ? false : true;
1216+
1217+
// Pro is installed (active) but the license check above did not pass.
1218+
// Do NOT fall through to the legacy "old user" path — that path exists
1219+
// only for sites that never had Pro installed. If Pro is present but
1220+
// the license is inactive we should lock, regardless of chart history.
1221+
if ( class_exists( 'Visualizer_Pro', false ) ) {
1222+
return false;
1223+
}
1224+
1225+
// No Pro installed at all: grant legacy access to existing users so
1226+
// their charts are not suddenly broken when they upgrade the free plugin.
1227+
return 'yes' === get_option( 'visualizer-new-user' ) ? false : true;
11921228
}
11931229

11941230
/**

classes/Visualizer/Render/Layout.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ class="dashicons dashicons-lock"></span></h2>
10191019
value="<?php _e( 'Import Chart', 'visualizer' ); ?>"
10201020
data-viz-link="<?php echo $fetch_link; ?>">
10211021
<?php
1022-
if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
1022+
if ( ! Visualizer_Module_Admin::proFeaturesEnabled() ) {
10231023
echo apply_filters( 'visualizer_pro_upsell', '', 'import-chart' );
10241024
}
10251025
?>

classes/Visualizer/Render/Library.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function _toHTML() {
4242
esc_html_e( 'Visualizer Library', 'visualizer' );
4343
echo ' <a href="javascript:;" class="add-new-h2 add-new-chart">', esc_html__( 'Add New', 'visualizer' ), '</a>';
4444
if ( Visualizer_Module::is_pro() ) {
45-
echo ' <a href="' . admin_url( 'options-general.php' ) . '" class="page-title-action">', esc_html__( 'License Settings', 'visualizer' ), '</a>';
45+
echo ' <a href="' . admin_url( 'options-general.php#visualizer_pro_license' ) . '" class="page-title-action">', esc_html__( 'License Settings', 'visualizer' ), '</a>';
4646
}
4747
echo '</h2>';
4848
$this->_renderMessages();
@@ -451,7 +451,7 @@ private function _renderSidebar() {
451451
echo '<div id="visualizer-sidebar" class="one-columns">';
452452
echo '<div class="visualizer-sidebar-box">';
453453
echo '<h3>' . __( 'Discover the power of PRO!', 'visualizer' ) . '</h3><ul>';
454-
if ( Visualizer_Module_Admin::proFeaturesLocked() ) {
454+
if ( Visualizer_Module_Admin::proFeaturesEnabled() ) {
455455
echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( '6 more chart types', 'visualizer' );
456456
} else {
457457
echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( '11 more chart types', 'visualizer' ) . '</li>';

classes/Visualizer/Render/Page/Data.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ protected function _renderSidebarContent() {
108108
</div>
109109

110110
<li class="viz-group bottom-fixed" id="vz-chart-copyright">
111-
Hate it? Love it? <a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank">Rate it!</a>
112-
<br/>
113-
Visualizer &copy;
111+
<?php _e( 'Hate it? Love it?', 'visualizer' ); ?> <a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank"><?php _e( 'Rate it!', 'visualizer' ); ?></a>
114112
<?php
115113
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date, WordPress.DateTime.CurrentTimeTimestamp.Requested
116114
echo date( 'Y', current_time( 'timestamp' ) );

classes/Visualizer/Render/Sidebar.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ protected function _renderAdvancedSettings() {
174174
// Chart control settings.
175175
$this->_renderChartControlsGroup();
176176

177-
if ( Visualizer_Module_Admin::proFeaturesLocked() ) {
177+
if ( Visualizer_Module_Admin::proFeaturesEnabled() ) {
178178
self::_renderGroupStart( esc_html__( 'Frontend Actions', 'visualizer' ) );
179179
} else {
180180
self::_renderGroupStart( esc_html__( 'Frontend Actions', 'visualizer' ) . '<span class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-frontend-actions' ), 'vz-frontend-actions' );
@@ -185,7 +185,7 @@ protected function _renderAdvancedSettings() {
185185
self::_renderSectionEnd();
186186

187187
$this->_renderActionSettings();
188-
if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
188+
if ( ! Visualizer_Module_Admin::proFeaturesEnabled() ) {
189189
echo apply_filters( 'visualizer_pro_upsell', '', 'frontend-actions' );
190190
echo '</div>';
191191
}
@@ -602,7 +602,7 @@ protected function _renderChartControlsGroup() {
602602
if ( 'google' !== $this->getLibrary() ) {
603603
return;
604604
}
605-
if ( Visualizer_Module_Admin::proFeaturesLocked() ) {
605+
if ( Visualizer_Module_Admin::proFeaturesEnabled() ) {
606606
self::_renderGroupStart( esc_html__( 'Chart Data Filter Configuration', 'visualizer' ) );
607607
} else {
608608
self::_renderGroupStart( esc_html__( 'Chart Data Filter Configuration', 'visualizer' ) . '<span class="dashicons dashicons-lock"></span>', '', apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'chart-filter-controls' ), 'vz-data-controls' );
@@ -619,7 +619,7 @@ protected function _renderChartControlsGroup() {
619619
);
620620
self::_renderSectionEnd();
621621
$this->_renderChartControlsSettings();
622-
if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
622+
if ( ! Visualizer_Module_Admin::proFeaturesEnabled() ) {
623623
echo apply_filters( 'visualizer_pro_upsell', '', 'data-filter-configuration' );
624624
echo '</div>';
625625
}

css/frame.css

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,15 @@
174174
width: 100%;
175175
height: 100%;
176176
margin: 0;
177+
padding-bottom: 60px;
177178
}
178179

179-
.viz-group.bottom-fixed {
180+
.viz-group.bottom-fixed {
180181
display: block;
181-
position: absolute;
182-
bottom: 0;
183-
width: 100%;
182+
position: fixed;
183+
width: 350px;
184+
padding: 12px;
185+
margin: 0 auto;
184186
}
185187

186188
.viz-group ul li h2,
@@ -1012,8 +1014,10 @@ button#editor-chart-button {
10121014
}
10131015

10141016
#vz-chart-copyright {
1015-
bottom: 10px;
1017+
bottom: 60px;
10161018
text-align: center;
1019+
z-index: 999;
1020+
background: #f3f3f3;
10171021
}
10181022

10191023
/* Import steps — stepped data-source + schedule flow */

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function visualizer_launch() {
9393
// the link to pre-build queries.
9494
define( 'VISUALIZER_DB_QUERY_DOC_URL', 'https://docs.themeisle.com/article/970-visualizer-sample-queries-to-generate-charts' );
9595
define( 'VISUALIZER_MAIN_DOC', 'https://docs.themeisle.com/category/657-visualizer' );
96-
define( 'VISUALIZER_DOC_COLLECTION', 'https://docs.themeisle.com/search?collectionId=561ec249c69791452ed4bceb&query=#+visualizer' );
96+
define( 'VISUALIZER_DOC_COLLECTION', 'https://docs.themeisle.com/visualizer-charts-and-graphs/?query=#' );
9797
define( 'VISUALIZER_DEMO_URL', 'https://demo.themeisle.com/visualizer/#' );
9898
define( 'VISUALIZER_CODE_SNIPPETS_URL', 'https://docs.themeisle.com/category/726-visualizer' );
9999
define( 'VISUALIZER_SUBSCRIBE_API', 'https://api.themeisle.com/tracking/subscribe' );

0 commit comments

Comments
 (0)