Skip to content

Commit ffc7b64

Browse files
release: fixes
- Fixed chart rendering on page load with multiple charts - Updated dependencies
2 parents 213d032 + ae0cac7 commit ffc7b64

File tree

24 files changed

+392
-88
lines changed

24 files changed

+392
-88
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 98 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ class Visualizer_Module_Admin extends Visualizer_Module {
4040
*/
4141
private $_libraryPage;
4242

43+
/**
44+
* Support page suffix.
45+
*
46+
* @access private
47+
* @var string
48+
*/
49+
private $_supportPage;
50+
4351
/**
4452
* Constructor.
4553
*
@@ -56,12 +64,14 @@ public function __construct( Visualizer_Plugin $plugin ) {
5664
$this->_addAction( 'enqueue_block_editor_assets', 'enqueueMediaScripts' );
5765
$this->_addAction( 'admin_footer', 'renderTemplates' );
5866
$this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 0 );
67+
$this->_addAction( 'admin_enqueue_scripts', 'enqueue_support_page' );
5968
$this->_addAction( 'admin_menu', 'registerAdminMenu' );
6069
$this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
6170
$this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
6271
$this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 );
6372
$this->_addFilter( 'visualizer_logger_data', 'getLoggerData' );
6473
$this->_addFilter( 'visualizer_feedback_review_trigger', 'feedbackReviewTrigger' );
74+
$this->_addFilter( 'themeisle_sdk_blackfriday_data', 'add_black_friday_data' );
6575

6676
// screen pagination
6777
$this->_addFilter( 'set-screen-option', 'setScreenOptions', 10, 3 );
@@ -100,6 +110,7 @@ public function render_review_notice( $footer_text ) {
100110
foreach ( $visualizer_page_ids as $page_to_check ) {
101111
if ( strpos( $current_screen->id, $page_to_check ) !== false ) {
102112
$footer_text = sprintf(
113+
// translators: %1$s - the name of the plugin (Visualizer), %2$s - message (You can help us by leaving a), %3$s - HTML entity code.
103114
__( 'Enjoying %1$s? %2$s %3$s rating. Thank you for being so supportive!', 'visualizer' ),
104115
'<b>Visualizer</b>',
105116
esc_html__( 'You can help us by leaving a', 'visualizer' ),
@@ -639,40 +650,56 @@ public function renderTemplates() {
639650
* @param string $suffix The current page suffix.
640651
*/
641652
public function enqueueLibraryScripts( $suffix ) {
642-
if ( $suffix === $this->_libraryPage ) {
643-
wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
644-
$this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
645-
wp_enqueue_media();
653+
if ( $suffix !== $this->_libraryPage ) {
654+
return;
655+
}
656+
657+
wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
658+
$this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
659+
wp_enqueue_media();
660+
wp_enqueue_script(
661+
'visualizer-library',
662+
VISUALIZER_ABSURL . 'js/library.js',
663+
array(
664+
'jquery',
665+
'media-views',
666+
'clipboard',
667+
),
668+
Visualizer_Plugin::VERSION,
669+
true
670+
);
671+
672+
wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
673+
674+
$query = $this->getQuery();
675+
while ( $query->have_posts() ) {
676+
$chart = $query->next_post();
677+
$library = $this->load_chart_type( $chart->ID );
678+
if ( is_null( $library ) ) {
679+
continue;
680+
}
646681
wp_enqueue_script(
647-
'visualizer-library',
648-
VISUALIZER_ABSURL . 'js/library.js',
649-
array(
650-
'jquery',
651-
'media-views',
652-
'clipboard',
653-
),
682+
"visualizer-render-$library",
683+
VISUALIZER_ABSURL . 'js/render-facade.js',
684+
apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
654685
Visualizer_Plugin::VERSION,
655686
true
656687
);
688+
}
657689

658-
wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
690+
do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );
691+
}
659692

660-
$query = $this->getQuery();
661-
while ( $query->have_posts() ) {
662-
$chart = $query->next_post();
663-
$library = $this->load_chart_type( $chart->ID );
664-
if ( is_null( $library ) ) {
665-
continue;
666-
}
667-
wp_enqueue_script(
668-
"visualizer-render-$library",
669-
VISUALIZER_ABSURL . 'js/render-facade.js',
670-
apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
671-
Visualizer_Plugin::VERSION,
672-
true
673-
);
674-
}
693+
/**
694+
* Enqueue script for support page.
695+
*
696+
* @param string $hook_suffix Current hook.
697+
*/
698+
public function enqueue_support_page( $hook_suffix ) {
699+
if ( $this->_supportPage !== $hook_suffix ) {
700+
return;
675701
}
702+
do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' );
676703
}
677704

678705
/**
@@ -718,7 +745,8 @@ public function registerAdminMenu() {
718745
'edit_posts',
719746
'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew'
720747
);
721-
add_submenu_page(
748+
749+
$this->_supportPage = add_submenu_page(
722750
Visualizer_Plugin::NAME,
723751
__( 'Support', 'visualizer' ),
724752
__( 'Support', 'visualizer' ) . '<span class="dashicons dashicons-editor-help more-features-icon" style="width: 17px; height: 17px; margin-left: 4px; color: #ffca54; font-size: 17px; vertical-align: -3px;"></span>',
@@ -938,7 +966,6 @@ private function getQuery() {
938966
*/
939967
public function renderSupportPage() {
940968
wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION );
941-
do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' );
942969
include_once VISUALIZER_ABSPATH . '/templates/support.php';
943970
}
944971

@@ -1095,12 +1122,6 @@ public function renderLibraryPage() {
10951122
)
10961123
);
10971124

1098-
do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );
1099-
1100-
if ( ! apply_filters( 'visualizer_is_business', false ) ) {
1101-
do_action( 'themeisle_sdk_load_banner', 'visualizer' );
1102-
}
1103-
11041125
$render->render();
11051126
}
11061127

@@ -1304,4 +1325,46 @@ public function count_charts( $limit = -1 ) {
13041325
$query = new WP_Query( $args);
13051326
return $query->post_count;
13061327
}
1328+
1329+
/**
1330+
* Set the black friday data.
1331+
*
1332+
* @param array $configs The configuration array for the loaded products.
1333+
* @return array
1334+
*/
1335+
public function add_black_friday_data( $configs ) {
1336+
$config = $configs['default'];
1337+
1338+
// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
1339+
$message_template = __( 'Our biggest sale of the year: %1$sup to %2$s OFF%3$s on %4$s. Don\'t miss this limited-time offer.', 'visualizer' );
1340+
$product_label = 'Visualizer';
1341+
$discount = '70%';
1342+
1343+
$plan = apply_filters( 'product_visualizer_license_plan', 0 );
1344+
$license = apply_filters( 'product_visualizer_license_key', false );
1345+
$is_pro = 0 < $plan;
1346+
1347+
if ( $is_pro ) {
1348+
// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
1349+
$message_template = __( 'Get %1$sup to %2$s off%3$s when you upgrade your %4$s plan or renew early.', 'visualizer' );
1350+
$product_label = 'Visualizer Pro';
1351+
$discount = '30%';
1352+
}
1353+
1354+
$product_label = sprintf( '<strong>%s</strong>', $product_label );
1355+
$url_params = array(
1356+
'utm_term' => $is_pro ? 'plan-' . $plan : 'free',
1357+
'lkey' => ! empty( $license ) ? $license : false,
1358+
);
1359+
1360+
$config['message'] = sprintf( $message_template, '<strong>', $discount, '</strong>', $product_label );
1361+
$config['sale_url'] = add_query_arg(
1362+
$url_params,
1363+
tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/vizualizer-bf', 'bfcm', 'visualizer' ) )
1364+
);
1365+
1366+
$configs[ VISUALIZER_DIRNAME ] = $config;
1367+
1368+
return $configs;
1369+
}
13071370
}

classes/Visualizer/Module/Frontend.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Visualizer_Module_Frontend extends Visualizer_Module {
4747
* @access private
4848
* @var bool
4949
*/
50-
private $lazy_render_script = false;
50+
private $lazy_render_script = true;
5151

5252
/**
5353
* Constructor.
@@ -383,8 +383,9 @@ public function renderChart( $atts ) {
383383
$lazy_load = isset( $settings['lazy_load_chart'] ) ? $settings['lazy_load_chart'] : false;
384384
$lazy_load = apply_filters( 'visualizer_lazy_load_chart', $lazy_load, $chart->ID );
385385
$container_class = 'visualizer-front-container';
386-
if ( $lazy_load ) {
387-
$this->lazy_render_script = true;
386+
if ( ! $lazy_load ) {
387+
$this->lazy_render_script = false;
388+
} else {
388389
$container_class .= ' visualizer-lazy-render';
389390
}
390391

@@ -699,6 +700,7 @@ public function printFooterScripts() {
699700
?>
700701
<script type="text/javascript">
701702
var visualizerUserInteractionEvents = [
703+
"scroll",
702704
"mouseover",
703705
"keydown",
704706
"touchmove",

classes/Visualizer/Module/Sources.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ public function addProUpsell( $old, $feature = null ) {
138138
( in_array( $feature, $biz_features, true ) && ! apply_filters( 'visualizer_is_business', false ) ) ||
139139
( in_array( $feature, $pro_features, true ) && ! Visualizer_Module::is_pro() )
140140
) {
141+
// translators: $s - the name of the plan (PRO).
141142
$msg = sprintf( __( 'Upgrade to %s to activate this feature!', 'visualizer' ), 'PRO' );
143+
// translators: $s - the name of the plan (Plus).
142144
$plus_msg = sprintf( __( 'Upgrade to %s plan to activate this feature!', 'visualizer' ), 'Plus' );
143145
if ( in_array( $feature, $biz_features, true ) && Visualizer_Module::is_pro() ) {
144146
$msg = $plus_msg;

classes/Visualizer/Render/Layout.php

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,26 @@ public static function _renderDbQuery( $args ) {
9090
<div class='db-wizard-hints'>
9191
<ul>
9292
<li><?php echo __( 'Your database prefix is:', 'visualizer' ); ?> <span class="visualizer-emboss"><?php echo $wpdb->prefix; ?></span></li>
93-
<li><?php echo sprintf( __( 'For examples of queries and links to resources that you can use with this feature, please click %1$shere%2$s', 'visualizer' ), '<a href="' . VISUALIZER_DB_QUERY_DOC_URL . '" target="_blank">', '</a>' ); ?></li>
94-
<li><?php echo sprintf( __( 'Use %1$sShift+Space%2$s for autocompleting keywords or table names.', 'visualizer' ), '<span class="visualizer-emboss">', '</span>' ); ?></li>
93+
<li>
94+
<?php
95+
echo sprintf(
96+
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
97+
__( 'For examples of queries and links to resources that you can use with this feature, please click %1$shere%2$s', 'visualizer' ),
98+
'<a href="' . VISUALIZER_DB_QUERY_DOC_URL . '" target="_blank">',
99+
'</a>'
100+
);
101+
?>
102+
</li>
103+
<li>
104+
<?php
105+
echo sprintf(
106+
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
107+
__( 'Use %1$sShift+Space%2$s for autocompleting keywords or table names.', 'visualizer' ),
108+
'<span class="visualizer-emboss">',
109+
'</span>'
110+
);
111+
?>
112+
</li>
95113
<?php do_action( 'visualizer_db_query_add_hints', $args ); ?>
96114
</ul>
97115
</div>
@@ -180,7 +198,16 @@ public static function _renderJsonScreen( $args ) {
180198
<form id="json-endpoint-form">
181199
<div class="json-wizard-hints">
182200
<ul class="info">
183-
<li><?php echo sprintf( __( 'If you want to add authentication or headers to the endpoint or change the request in any way, please refer to our document %1$shere%2$s.', 'visualizer' ), '<a href="https://docs.themeisle.com/article/1043-visualizer-how-to-extend-rest-endpoints-with-json-response" target="_blank">', '</a>' ); ?></li>
201+
<li>
202+
<?php
203+
echo sprintf(
204+
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
205+
__( 'If you want to add authentication or headers to the endpoint or change the request in any way, please refer to our document %1$shere%2$s.', 'visualizer' ),
206+
'<a href="https://docs.themeisle.com/article/1043-visualizer-how-to-extend-rest-endpoints-with-json-response" target="_blank">',
207+
'</a>'
208+
);
209+
?>
210+
</li>
184211
</ul>
185212
</div>
186213

@@ -662,10 +689,20 @@ public static function _renderTabHelp( $args ) {
662689
<h4><span class="dashicons dashicons-media-code"></span><a href="<?php echo VISUALIZER_CODE_SNIPPETS_URL; ?>" target="_blank"><?php _e( 'Custom code snippets', 'visualizer' ); ?></a></h4>
663690
<?php
664691
Visualizer_Render_Sidebar::_renderSectionEnd();
692+
// translators: %s - the chart type.
665693
Visualizer_Render_Sidebar::_renderSectionStart( sprintf( __( '%s chart', 'visualizer' ), ucwords( $displayType ) ), true );
666694
?>
667695
<h4><span class="dashicons dashicons-video-alt2"></span>&nbsp;<a href="<?php echo str_replace( '#', "$type-chart", VISUALIZER_DEMO_URL ); ?>" target="_blank"><?php _e( 'View demo', 'visualizer' ); ?></a></h4>
668-
<h4><span class="dashicons dashicons-search"></span><a href="<?php echo str_replace( '#', $type, VISUALIZER_DOC_COLLECTION ); ?>" target="_blank"><?php echo sprintf( __( 'Articles containing "%s"', 'visualizer' ), $displayType ); ?></a></h4>
696+
<h4><span class="dashicons dashicons-search"></span><a href="<?php echo str_replace( '#', $type, VISUALIZER_DOC_COLLECTION ); ?>" target="_blank">
697+
<?php
698+
echo sprintf(
699+
// translators: %s - the chart type.
700+
__( 'Articles containing "%s"', 'visualizer' ),
701+
$displayType
702+
);
703+
?>
704+
</a>
705+
</h4>
669706
<?php
670707
Visualizer_Render_Sidebar::_renderSectionEnd();
671708
Visualizer_Render_Sidebar::_renderGroupEnd();
@@ -775,7 +812,17 @@ public static function _renderTabBasic( $args ) {
775812
<div class="viz-group-content">
776813
<div>
777814
<p class="viz-group-description"><?php esc_html_e( 'Select and upload your data CSV file here. The first row of the CSV file should contain the column headings. The second one should contain series type (string, number, boolean, date, datetime, timeofday).', 'visualizer' ); ?></p>
778-
<p class="viz-group-description viz-info-msg"><b><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">', $type, '.csv</a>' ); ?></b></p>
815+
<p class="viz-group-description viz-info-msg">
816+
<b>
817+
<?php
818+
echo sprintf(
819+
// translators: $s - the chart type with the link attached.
820+
__( 'If you are unsure about how to format your data CSV then please take a look at this sample: %s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ),
821+
'<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">' . $type . '.csv</a>'
822+
);
823+
?>
824+
</b>
825+
</p>
779826
<form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
780827
target="thehole" enctype="multipart/form-data">
781828
<input type="hidden" id="remote-data" name="remote_data">
@@ -798,8 +845,27 @@ public static function _renderTabBasic( $args ) {
798845
<span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span>
799846
<div class="only-pro-anchor">
800847
<div class="viz-section-items section-items">
801-
<p class="viz-group-description"><?php echo sprintf( __( 'You can use this to import data from a remote CSV file or %1$sGoogle Spreadsheet%2$s.', 'visualizer' ), '<a href="https://docs.themeisle.com/article/607-how-can-i-populate-data-from-google-spreadsheet" target="_blank" >', '</a>' ); ?> </p>
802-
<p class="viz-group-description viz-info-msg"><b><?php echo sprintf( __( 'If you are unsure about how to format your data CSV then please take a look at this sample: %1$s %2$s%3$s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ), '<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">', $type, '.csv</a>' ); ?></b></p>
848+
<p class="viz-group-description">
849+
<?php
850+
echo sprintf(
851+
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
852+
__( 'You can use this to import data from a remote CSV file or %1$sGoogle Spreadsheet%2$s.', 'visualizer' ),
853+
'<a href="https://docs.themeisle.com/article/607-how-can-i-populate-data-from-google-spreadsheet" target="_blank" >',
854+
'</a>'
855+
);
856+
?>
857+
</p>
858+
<p class="viz-group-description viz-info-msg">
859+
<b>
860+
<?php
861+
echo sprintf(
862+
// translators: %s - the chart type with the link attached.
863+
__( 'If you are unsure about how to format your data CSV then please take a look at this sample: %s. If you are using non-English characters, please make sure you save the file in UTF-8 encoding.', 'visualizer' ),
864+
'<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">' . $type . '.csv</a>'
865+
);
866+
?>
867+
</b>
868+
</p>
803869
<form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
804870
target="thehole" enctype="multipart/form-data">
805871
<div class="remote-file-section">

classes/Visualizer/Render/Library.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ private function _renderMessages() {
6161
if ( ! filter_var( ini_get( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN ) ) {
6262
echo '<div class="updated error">';
6363
echo '<p>';
64-
printf( esc_html__( '%s option is disabled in your php.ini config. Please, enable it by change its value to 1. This option increases the speed of remote CSV uploading.', 'visualizer' ), '<b>allow_url_fopen</b>' );
64+
printf(
65+
// translators: %s - the name of the option.
66+
esc_html__( '%s option is disabled in your php.ini config. Please, enable it by change its value to 1. This option increases the speed of remote CSV uploading.', 'visualizer' ),
67+
'<b>allow_url_fopen</b>'
68+
);
6569
echo '</p>';
6670
echo '</div>';
6771
}

0 commit comments

Comments
 (0)