Skip to content

Commit b8fc5e5

Browse files
author
cristian-ungureanu
authored
Merge pull request #876 from Codeinwp/feature/313
Oversimplify the free version
2 parents 26b9851 + 21cca59 commit b8fc5e5

File tree

16 files changed

+118
-88
lines changed

16 files changed

+118
-88
lines changed

classes/Visualizer/Gutenberg/Block.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public function enqueue_gutenberg_scripts() {
111111
'adminPage' => menu_page_url( 'visualizer', false ),
112112
'sqlTable' => $table_col_mapping,
113113
'chartsPerPage' => defined( 'TI_CYPRESS_TESTING' ) ? 20 : 6,
114+
'proFeaturesLocked' => Visualizer_Module_Admin::proFeaturesLocked(),
114115
);
115116
wp_localize_script( 'visualizer-gutenberg-block', 'visualizerLocalize', $translation_array );
116117

classes/Visualizer/Gutenberg/build/block.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/Visualizer/Gutenberg/src/Components/Sidebar/FrontendActions.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
} = wp.element;
1010

1111
const {
12+
Button,
1213
CheckboxControl,
1314
PanelBody
1415
} = wp.components;
@@ -34,6 +35,7 @@ class FrontendActions extends Component {
3435
const type = this.props.chart['visualizer-chart-type'];
3536

3637
return (
38+
( '' !== visualizerLocalize.proFeaturesLocked ) ?
3739
<PanelBody
3840
title={ __( 'Frontend Actions' ) }
3941
initialOpen={ false }
@@ -135,7 +137,25 @@ class FrontendActions extends Component {
135137

136138
) }
137139

138-
</PanelBody>
140+
</PanelBody> :
141+
<PanelBody
142+
title={ __( 'Frontend Actions' ) }
143+
initialOpen={ false }
144+
icon="lock"
145+
className="visualizer-advanced-panel"
146+
>
147+
148+
<p>{ __( 'Enable this feature in PRO version!' ) }</p>
149+
150+
<Button
151+
isPrimary
152+
href={ visualizerLocalize.proTeaser }
153+
target="_blank"
154+
>
155+
{ __( 'Buy Now' ) }
156+
</Button>
157+
158+
</PanelBody>
139159
);
140160
}
141161
}

classes/Visualizer/Module/Admin.php

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -389,64 +389,66 @@ public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darra
389389
);
390390
}
391391

392+
$enabled = self::proFeaturesLocked();
393+
392394
$types = array_merge(
393395
$additional,
394396
array(
395397
'tabular' => array(
396398
'name' => esc_html__( 'Table', 'visualizer' ),
397399
'enabled' => true,
398-
'supports' => array( 'Google Charts', 'DataTable' ),
400+
'supports' => $enabled ? array( 'Google Charts', 'DataTable' ) : array( 'DataTable' ),
399401
),
400402
'pie' => array(
401403
'name' => esc_html__( 'Pie/Donut', 'visualizer' ),
402404
'enabled' => true,
403-
'supports' => array( 'Google Charts', 'ChartJS' ),
405+
'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ),
404406
),
405407
'line' => array(
406408
'name' => esc_html__( 'Line', 'visualizer' ),
407409
'enabled' => true,
408-
'supports' => array( 'Google Charts', 'ChartJS' ),
410+
'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ),
411+
),
412+
'bar' => array(
413+
'name' => esc_html__( 'Bar', 'visualizer' ),
414+
'enabled' => true,
415+
'supports' => $enabled ? array( 'Google Charts', 'ChartJS' ) : array( 'Google Charts' ),
409416
),
410417
'area' => array(
411418
'name' => esc_html__( 'Area', 'visualizer' ),
412-
'enabled' => true,
419+
'enabled' => $enabled,
413420
// in ChartJS, the fill option is used to make Line chart an area: https://www.chartjs.org/docs/latest/charts/area.html
414421
'supports' => array( 'Google Charts' ),
415422
),
416423
'geo' => array(
417424
'name' => esc_html__( 'Geo', 'visualizer' ),
418-
'enabled' => true,
425+
'enabled' => $enabled,
419426
'supports' => array( 'Google Charts' ),
420427
),
421-
'bar' => array(
422-
'name' => esc_html__( 'Bar', 'visualizer' ),
423-
'enabled' => true,
424-
'supports' => array( 'Google Charts', 'ChartJS' ),
425-
),
426428
'column' => array(
427429
'name' => esc_html__( 'Column', 'visualizer' ),
428-
'enabled' => true,
430+
'enabled' => $enabled,
429431
'supports' => array( 'Google Charts', 'ChartJS' ),
430432
),
431433
'bubble' => array(
432434
'name' => esc_html__( 'Bubble', 'visualizer' ),
433-
'enabled' => true,
435+
'enabled' => $enabled,
434436
// chartjs' bubble is ugly looking (and it won't work off the default bubble.csv) so it is being excluded for the time being.
435437
'supports' => array( 'Google Charts' ),
436438
),
437439
'scatter' => array(
438440
'name' => esc_html__( 'Scatter', 'visualizer' ),
439-
'enabled' => true,
441+
'enabled' => $enabled,
440442
'supports' => array( 'Google Charts' ),
441443
),
442444
'gauge' => array(
443445
'name' => esc_html__( 'Gauge', 'visualizer' ),
444-
'enabled' => true,
446+
'enabled' => $enabled,
445447
'supports' => array( 'Google Charts' ),
446448
),
447449
'candlestick' => array(
448450
'name' => esc_html__( 'Candlestick', 'visualizer' ),
449-
'enabled' => true,
451+
'enabled' => $enabled,
450452
'supports' => array( 'Google Charts' ),
451453
),
452454
// pro types
@@ -1046,4 +1048,15 @@ public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
10461048
return $plugin_meta;
10471049
}
10481050

1051+
/**
1052+
* If check is existing user.
1053+
*
1054+
* @return bool Default false
1055+
*/
1056+
public static function proFeaturesLocked() {
1057+
if ( Visualizer_Module::is_pro() ) {
1058+
return true;
1059+
}
1060+
return 'yes' === get_option( 'visualizer-new-user', 'yes' ) ? false : true;
1061+
}
10491062
}

classes/Visualizer/Module/Setup.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public function __construct( Visualizer_Plugin $plugin ) {
5353
$this->_addFilter( 'visualizer_logger_data', 'getLoggerData' );
5454
$this->_addFilter( 'visualizer_get_chart_counts', 'getUsage', 10, 2 );
5555

56+
$this->_addAction( 'init', 'checkIsExistingUser' );
57+
5658
// only for testing
5759
// $this->_addAction( 'admin_init', 'getUsage' );
5860
}
@@ -405,4 +407,20 @@ public function refreshDbChart() {
405407
update_option( Visualizer_Plugin::CF_DB_SCHEDULE, $new_schedules );
406408
}
407409

410+
/**
411+
* Save flag for existing users.
412+
*/
413+
public function checkIsExistingUser() {
414+
$chart_exists = get_option( 'visualizer-new-user', '' );
415+
if ( '' === $chart_exists ) {
416+
$charts = get_posts(
417+
array(
418+
'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
419+
'fields' => 'ids',
420+
)
421+
);
422+
update_option( 'visualizer-new-user', ! empty( $charts ) ? 'no' : 'yes' );
423+
}
424+
}
425+
408426
}

classes/Visualizer/Render/Layout.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ class="dashicons dashicons-lock"></span></h2>
960960
</li>
961961

962962
<!-- manual -->
963-
<li class="viz-group visualizer_source_manual">
963+
<li class="viz-group visualizer_source_manual <?php echo ! Visualizer_Module_Admin::proFeaturesLocked() ? apply_filters( 'visualizer_pro_upsell_class', 'only-pro-feature', 'db-query' ) : ''; ?>">
964964
<h2 class="viz-group-title viz-sub-group visualizer-editor-tab" data-current="chart"><?php _e( 'Manual Data', 'visualizer' ); ?>
965965
<span class="dashicons dashicons-lock"></span>
966966
</h2>
@@ -1002,6 +1002,11 @@ class="dashicons dashicons-lock"></span></h2>
10021002
>
10031003
<p class="viz-group-description viz-info-msg"><?php echo sprintf( __( 'Please make sure you click \'Show Chart\' before you save the chart.', 'visualizer' ) ); ?></p>
10041004
<?php } ?>
1005+
<?php
1006+
if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
1007+
echo apply_filters( 'visualizer_pro_upsell', '', 'db-query' );
1008+
}
1009+
?>
10051010
</form>
10061011
</div>
10071012
</li>

classes/Visualizer/Render/Library.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,15 @@ private function _renderSidebar() {
359359
echo '<li>' . __( 'Frontend editor', 'visualizer' ) . '</li>';
360360
echo '<li>' . __( 'Private charts', 'visualizer' ) . '</li>';
361361
echo '<li>' . __( 'Auto-sync with online files', 'visualizer' ) . '</li>';
362-
echo '<li>' . __( '6 more chart types', 'visualizer' ) . '</li></ul>';
362+
if ( Visualizer_Module_Admin::proFeaturesLocked() ) {
363+
echo '<li>' . __( '6 more chart types', 'visualizer' ) . '</ul>';
364+
} else {
365+
echo '<li>' . __( '11 more chart types', 'visualizer' ) . '</li>';
366+
echo '<li>' . __( 'Manual Data Editor', 'visualizer' ) . '</li>';
367+
echo '<li>' . __( 'ChartJS Charts', 'visualizer' ) . '</li>';
368+
echo '<li>' . __( 'Table Google chart', 'visualizer' ) . '</li>';
369+
echo '<li>' . __( 'Frontend Actions(Print Chart, Export to CSV, Export to Excel, Copy, Download Chart Image)', 'visualizer' ) . '</li></ul>';
370+
}
363371
echo '<p><a href="' . Visualizer_Plugin::PRO_TEASER_URL . '" target="_blank" class="button button-primary">' . __( 'View more features', 'visualizer' ) . '</a></p>';
364372
echo '<p style="background-color: #0073aac7; color: #ffffff; padding: 2px; font-weight: bold;">' . __( 'We offer a 30-day no-questions-asked money back guarantee!', 'visualizer' ) . '</p>';
365373
echo '<p><a href="' . VISUALIZER_SURVEY . '" target="_blank" class="">' . __( 'Don\'t see the features you need? Help us improve!', 'visualizer' ) . '</a></p>';

classes/Visualizer/Render/Page/Types.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected function _renderToolbar() {
120120

121121
if ( ! empty( $libraries ) ) {
122122
?>
123-
<select name="chart-library" class="viz-select-library" data-type-vs-library="<?php echo esc_attr( json_encode( $type_vs_library ) ); ?>">
123+
<select name="chart-library" class="viz-select-library<?php echo ! Visualizer_Module_Admin::proFeaturesLocked() && ! defined( 'TI_CYPRESS_TESTING' ) ? ' viz-hide-libary' : ''; ?>" data-type-vs-library="<?php echo esc_attr( json_encode( $type_vs_library ) ); ?>">
124124
<option value=""><?php esc_html_e( 'Use Library', 'visualizer' ); ?></option>
125125
<?php
126126
foreach ( $libraries as $library ) {

classes/Visualizer/Render/Sidebar.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,21 @@ protected function _renderManualConfigExample() {
151151
* @access protected
152152
*/
153153
protected function _renderAdvancedSettings() {
154-
self::_renderGroupStart( esc_html__( 'Frontend Actions', 'visualizer' ) );
154+
if ( Visualizer_Module_Admin::proFeaturesLocked() ) {
155+
self::_renderGroupStart( esc_html__( 'Frontend Actions', 'visualizer' ) );
156+
} else {
157+
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' );
158+
echo '<div style="position: relative">';
159+
}
155160
self::_renderSectionStart();
156161
self::_renderSectionDescription( esc_html__( 'Configure frontend actions that need to be shown.', 'visualizer' ) );
157162
self::_renderSectionEnd();
158163

159164
$this->_renderActionSettings();
165+
if ( ! Visualizer_Module_Admin::proFeaturesLocked() ) {
166+
echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions' );
167+
echo '</div>';
168+
}
160169
self::_renderGroupEnd();
161170

162171
self::_renderGroupStart( esc_html__( 'Manual Configuration', 'visualizer' ) );

css/frame.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,9 @@ button#editor-chart-button {
806806
.viz-select-library {
807807
color: #0085ba;
808808
}
809+
.viz-select-library.viz-hide-libary {
810+
display: none;
811+
}
809812

810813
.viz-select-library option:first-child {
811814
font-weight: bold;
@@ -1521,3 +1524,10 @@ button#viz-text-editor-button {
15211524
canvas.chartjs-render-monitor {
15221525
height: 500px !important;
15231526
}
1527+
1528+
/******************************************************************************/
1529+
/******************************** Frontend Actions ***********************************/
1530+
/******************************************************************************/
1531+
#vz-frontend-actions .only-pro-inner {
1532+
text-align: center;
1533+
}

0 commit comments

Comments
 (0)