Skip to content

Commit 0a0a87b

Browse files
redirect to the correct page depending on charts created
1 parent 7788d1c commit 0a0a87b

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

classes/Visualizer/Module.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,21 @@ protected static function hasChartType( $type ) {
600600
return $q->found_posts > 0;
601601
}
602602

603+
/**
604+
* Determines how many charts have been created.
605+
*/
606+
protected static function numberOfCharts() {
607+
$args = array(
608+
'post_type' => Visualizer_Plugin::CPT_VISUALIZER,
609+
'fields' => 'ids',
610+
'post_status' => 'publish',
611+
'posts_per_page' => 300,
612+
);
613+
614+
$q = new WP_Query( $args );
615+
return $q->found_posts;
616+
}
617+
603618
/**
604619
* Checks if the PRO version is active.
605620
*

classes/Visualizer/Module/Setup.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ public function onActivation( $plugin ) {
155155
}
156156

157157
if ( $plugin === VISUALIZER_BASENAME ) {
158-
wp_redirect( admin_url( 'admin.php?page=viz-support' ) );
158+
if ( Visualizer_Module::numberOfCharts() > 0 ) {
159+
wp_redirect( admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME ) );
160+
} else {
161+
wp_redirect( admin_url( 'admin.php?page=viz-support' ) );
162+
}
159163
exit();
160164
}
161165
}

templates/docs.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
<?php if ( ! $is_pro ) { ?>
2323
<p>We have many more features and charts, and offer email & chat support if you purchase our <a href="<?php echo Visualizer_Plugin::PRO_TEASER_URL; ?>">Pro Version</a>.</p>
2424
<?php } ?>
25+
26+
<p>Ready to begin? Let's <a href="<?php echo admin_url( 'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew' ); ?>">create a chart!
2527
</div>
2628
</div>
2729
</div>

0 commit comments

Comments
 (0)