Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 41 additions & 5 deletions classes/Visualizer/Module/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function render_review_notice( $footer_text ) {
__( 'Enjoying %1$s? %2$s %3$s rating. Thank you for being so supportive!', 'visualizer' ),
'<b>Visualizer</b>',
esc_html__( 'You can help us by leaving a', 'visualizer' ),
'<a href="https://wordpress.org/support/plugin/visualizer/reviews/" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
'<a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
);
break;
}
Expand Down Expand Up @@ -1163,6 +1163,20 @@ public function getPluginActionLinks( $links, $file ) {
* @return array Updated array of plugin meta links.
*/
public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
if ( Visualizer_Module::is_pro() ) {
return $plugin_meta;
}

// Also suppress the upsell when Pro is installed but not currently active.
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
foreach ( array_keys( get_plugins() ) as $installed_plugin ) {
if ( false !== strpos( $installed_plugin, 'visualizer-pro' ) ) {
return $plugin_meta;
}
}

if ( $plugin_file === plugin_basename( VISUALIZER_BASEFILE ) ) {
// knowledge base link
$plugin_meta[] = sprintf(
Expand All @@ -1180,15 +1194,37 @@ public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
}

/**
* If check is existing user.
* Returns true when premium chart types should be enabled for the current user.
*
* @return bool Default false
* Pro 1.9.0+ hooks the 'visualizer_is_pro' filter and returns true only when
* the license is valid. Pre-1.9.0 Pro defined a Visualizer_Pro class instead;
* we detect that as a fallback so those legacy installs still work.
*
* Passing false as the filter default ensures the constant VISUALIZER_PRO
* (which is set to true whenever the Pro class exists, regardless of license
* state) cannot bypass the license check.
*
* @return bool
*/
public static function proFeaturesLocked() {
if ( Visualizer_Module::is_pro() ) {
$is_pro_filter = apply_filters( 'visualizer_is_pro', false );

// Pro 1.9.0+: filter is hooked and returns true only with a valid license.
if ( $is_pro_filter ) {
return true;
}
Comment on lines +1210 to 1215
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not entirely sure about the semantics of this method. Its name is proFeaturesLocked, but it seems to return true when the pro filter returns true.

As per the comment: // Pro 1.9.0+: filter is hooked and returns true only with a valid license.

So I'm not sure if it says that pro features are locked, or unlocked. The fallthrough below seems to be coherent in this regard though.

return 'yes' === get_option( 'visualizer-new-user', 'yes' ) ? false : true;

// Pro is installed (active) but the license check above did not pass.
// Do NOT fall through to the legacy "old user" path — that path exists
// only for sites that never had Pro installed. If Pro is present but
// the license is inactive we should lock, regardless of chart history.
if ( class_exists( 'Visualizer_Pro', false ) ) {
return false;
}

// No Pro installed at all: grant legacy access to existing users so
// their charts are not suddenly broken when they upgrade the free plugin.
return 'yes' === get_option( 'visualizer-new-user' ) ? false : true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Render/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function _toHTML() {
esc_html_e( 'Visualizer Library', 'visualizer' );
echo ' <a href="javascript:;" class="add-new-h2 add-new-chart">', esc_html__( 'Add New', 'visualizer' ), '</a>';
if ( Visualizer_Module::is_pro() ) {
echo ' <a href="' . admin_url( 'options-general.php' ) . '" class="page-title-action">', esc_html__( 'License Settings', 'visualizer' ), '</a>';
echo ' <a href="' . admin_url( 'options-general.php#visualizer_pro_license' ) . '" class="page-title-action">', esc_html__( 'License Settings', 'visualizer' ), '</a>';
}
echo '</h2>';
$this->_renderMessages();
Expand Down
4 changes: 1 addition & 3 deletions classes/Visualizer/Render/Page/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ protected function _renderSidebarContent() {
</div>

<li class="viz-group bottom-fixed" id="vz-chart-copyright">
Hate it? Love it? <a href="https://wordpress.org/support/plugin/visualizer/reviews/#new-post" target="_blank">Rate it!</a>
<br/>
Visualizer &copy;
<?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>
<?php
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date, WordPress.DateTime.CurrentTimeTimestamp.Requested
echo date( 'Y', current_time( 'timestamp' ) );
Expand Down
14 changes: 9 additions & 5 deletions css/frame.css
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@
width: 100%;
height: 100%;
margin: 0;
padding-bottom: 60px;
}

.viz-group.bottom-fixed {
.viz-group.bottom-fixed {
display: block;
position: absolute;
bottom: 0;
width: 100%;
position: fixed;
width: 350px;
padding: 12px;
margin: 0 auto;
}

.viz-group ul li h2,
Expand Down Expand Up @@ -1012,8 +1014,10 @@ button#editor-chart-button {
}

#vz-chart-copyright {
bottom: 10px;
bottom: 60px;
text-align: center;
z-index: 999;
background: #f3f3f3;
}

#sidebar {
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function visualizer_launch() {
// the link to pre-build queries.
define( 'VISUALIZER_DB_QUERY_DOC_URL', 'https://docs.themeisle.com/article/970-visualizer-sample-queries-to-generate-charts' );
define( 'VISUALIZER_MAIN_DOC', 'https://docs.themeisle.com/category/657-visualizer' );
define( 'VISUALIZER_DOC_COLLECTION', 'https://docs.themeisle.com/search?collectionId=561ec249c69791452ed4bceb&query=#+visualizer' );
define( 'VISUALIZER_DOC_COLLECTION', 'https://docs.themeisle.com/visualizer-charts-and-graphs/?query=#' );
define( 'VISUALIZER_DEMO_URL', 'https://demo.themeisle.com/visualizer/#' );
define( 'VISUALIZER_CODE_SNIPPETS_URL', 'https://docs.themeisle.com/category/726-visualizer' );
define( 'VISUALIZER_SUBSCRIBE_API', 'https://api.themeisle.com/tracking/subscribe' );
Expand Down
Loading