Skip to content

Release #1218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 27, 2025
Merged

Release #1218

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
133 changes: 98 additions & 35 deletions classes/Visualizer/Module/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ class Visualizer_Module_Admin extends Visualizer_Module {
*/
private $_libraryPage;

/**
* Support page suffix.
*
* @access private
* @var string
*/
private $_supportPage;

/**
* Constructor.
*
Expand All @@ -56,12 +64,14 @@ public function __construct( Visualizer_Plugin $plugin ) {
$this->_addAction( 'enqueue_block_editor_assets', 'enqueueMediaScripts' );
$this->_addAction( 'admin_footer', 'renderTemplates' );
$this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 0 );
$this->_addAction( 'admin_enqueue_scripts', 'enqueue_support_page' );
$this->_addAction( 'admin_menu', 'registerAdminMenu' );
$this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' );
$this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 );
$this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 );
$this->_addFilter( 'visualizer_logger_data', 'getLoggerData' );
$this->_addFilter( 'visualizer_feedback_review_trigger', 'feedbackReviewTrigger' );
$this->_addFilter( 'themeisle_sdk_blackfriday_data', 'add_black_friday_data' );

// screen pagination
$this->_addFilter( 'set-screen-option', 'setScreenOptions', 10, 3 );
Expand Down Expand Up @@ -100,6 +110,7 @@ public function render_review_notice( $footer_text ) {
foreach ( $visualizer_page_ids as $page_to_check ) {
if ( strpos( $current_screen->id, $page_to_check ) !== false ) {
$footer_text = sprintf(
// translators: %1$s - the name of the plugin (Visualizer), %2$s - message (You can help us by leaving a), %3$s - HTML entity code.
__( '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' ),
Expand Down Expand Up @@ -639,40 +650,56 @@ public function renderTemplates() {
* @param string $suffix The current page suffix.
*/
public function enqueueLibraryScripts( $suffix ) {
if ( $suffix === $this->_libraryPage ) {
wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
$this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
wp_enqueue_media();
if ( $suffix !== $this->_libraryPage ) {
return;
}

wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION );
$this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' );
wp_enqueue_media();
wp_enqueue_script(
'visualizer-library',
VISUALIZER_ABSURL . 'js/library.js',
array(
'jquery',
'media-views',
'clipboard',
),
Visualizer_Plugin::VERSION,
true
);

wp_enqueue_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );

$query = $this->getQuery();
while ( $query->have_posts() ) {
$chart = $query->next_post();
$library = $this->load_chart_type( $chart->ID );
if ( is_null( $library ) ) {
continue;
}
wp_enqueue_script(
'visualizer-library',
VISUALIZER_ABSURL . 'js/library.js',
array(
'jquery',
'media-views',
'clipboard',
),
"visualizer-render-$library",
VISUALIZER_ABSURL . 'js/render-facade.js',
apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
Visualizer_Plugin::VERSION,
true
);
}

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

$query = $this->getQuery();
while ( $query->have_posts() ) {
$chart = $query->next_post();
$library = $this->load_chart_type( $chart->ID );
if ( is_null( $library ) ) {
continue;
}
wp_enqueue_script(
"visualizer-render-$library",
VISUALIZER_ABSURL . 'js/render-facade.js',
apply_filters( 'visualizer_assets_render', array( 'visualizer-library', 'visualizer-customization' ), true ),
Visualizer_Plugin::VERSION,
true
);
}
/**
* Enqueue script for support page.
*
* @param string $hook_suffix Current hook.
*/
public function enqueue_support_page( $hook_suffix ) {
if ( $this->_supportPage !== $hook_suffix ) {
return;
}
do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' );
}

/**
Expand Down Expand Up @@ -718,7 +745,8 @@ public function registerAdminMenu() {
'edit_posts',
'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew'
);
add_submenu_page(

$this->_supportPage = add_submenu_page(
Visualizer_Plugin::NAME,
__( 'Support', 'visualizer' ),
__( '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>',
Expand Down Expand Up @@ -938,7 +966,6 @@ private function getQuery() {
*/
public function renderSupportPage() {
wp_enqueue_style( 'visualizer-upsell', VISUALIZER_ABSURL . 'css/upsell.css', array(), Visualizer_Plugin::VERSION );
do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'support' );
include_once VISUALIZER_ABSPATH . '/templates/support.php';
}

Expand Down Expand Up @@ -1095,12 +1122,6 @@ public function renderLibraryPage() {
)
);

do_action( 'themeisle_internal_page', VISUALIZER_DIRNAME, 'library' );

if ( ! apply_filters( 'visualizer_is_business', false ) ) {
do_action( 'themeisle_sdk_load_banner', 'visualizer' );
}

$render->render();
}

Expand Down Expand Up @@ -1304,4 +1325,46 @@ public function count_charts( $limit = -1 ) {
$query = new WP_Query( $args);
return $query->post_count;
}

/**
* Set the black friday data.
*
* @param array $configs The configuration array for the loaded products.
* @return array
*/
public function add_black_friday_data( $configs ) {
$config = $configs['default'];

// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
$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' );
$product_label = 'Visualizer';
$discount = '70%';

$plan = apply_filters( 'product_visualizer_license_plan', 0 );
$license = apply_filters( 'product_visualizer_license_key', false );
$is_pro = 0 < $plan;

if ( $is_pro ) {
// translators: %1$s - HTML tag, %2$s - discount, %3$s - HTML tag, %4$s - product name.
$message_template = __( 'Get %1$sup to %2$s off%3$s when you upgrade your %4$s plan or renew early.', 'visualizer' );
$product_label = 'Visualizer Pro';
$discount = '30%';
}

$product_label = sprintf( '<strong>%s</strong>', $product_label );
$url_params = array(
'utm_term' => $is_pro ? 'plan-' . $plan : 'free',
'lkey' => ! empty( $license ) ? $license : false,
);

$config['message'] = sprintf( $message_template, '<strong>', $discount, '</strong>', $product_label );
$config['sale_url'] = add_query_arg(
$url_params,
tsdk_translate_link( tsdk_utmify( 'https://themeisle.link/vizualizer-bf', 'bfcm', 'visualizer' ) )
);

$configs[ VISUALIZER_DIRNAME ] = $config;

return $configs;
}
}
8 changes: 5 additions & 3 deletions classes/Visualizer/Module/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Visualizer_Module_Frontend extends Visualizer_Module {
* @access private
* @var bool
*/
private $lazy_render_script = false;
private $lazy_render_script = true;

/**
* Constructor.
Expand Down Expand Up @@ -383,8 +383,9 @@ public function renderChart( $atts ) {
$lazy_load = isset( $settings['lazy_load_chart'] ) ? $settings['lazy_load_chart'] : false;
$lazy_load = apply_filters( 'visualizer_lazy_load_chart', $lazy_load, $chart->ID );
$container_class = 'visualizer-front-container';
if ( $lazy_load ) {
$this->lazy_render_script = true;
if ( ! $lazy_load ) {
$this->lazy_render_script = false;
} else {
$container_class .= ' visualizer-lazy-render';
}

Expand Down Expand Up @@ -699,6 +700,7 @@ public function printFooterScripts() {
?>
<script type="text/javascript">
var visualizerUserInteractionEvents = [
"scroll",
"mouseover",
"keydown",
"touchmove",
Expand Down
2 changes: 2 additions & 0 deletions classes/Visualizer/Module/Sources.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ public function addProUpsell( $old, $feature = null ) {
( in_array( $feature, $biz_features, true ) && ! apply_filters( 'visualizer_is_business', false ) ) ||
( in_array( $feature, $pro_features, true ) && ! Visualizer_Module::is_pro() )
) {
// translators: $s - the name of the plan (PRO).
$msg = sprintf( __( 'Upgrade to %s to activate this feature!', 'visualizer' ), 'PRO' );
// translators: $s - the name of the plan (Plus).
$plus_msg = sprintf( __( 'Upgrade to %s plan to activate this feature!', 'visualizer' ), 'Plus' );
if ( in_array( $feature, $biz_features, true ) && Visualizer_Module::is_pro() ) {
$msg = $plus_msg;
Expand Down
80 changes: 73 additions & 7 deletions classes/Visualizer/Render/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,26 @@ public static function _renderDbQuery( $args ) {
<div class='db-wizard-hints'>
<ul>
<li><?php echo __( 'Your database prefix is:', 'visualizer' ); ?> <span class="visualizer-emboss"><?php echo $wpdb->prefix; ?></span></li>
<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>
<li><?php echo sprintf( __( 'Use %1$sShift+Space%2$s for autocompleting keywords or table names.', 'visualizer' ), '<span class="visualizer-emboss">', '</span>' ); ?></li>
<li>
<?php
echo sprintf(
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
__( '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>
<li>
<?php
echo sprintf(
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
__( 'Use %1$sShift+Space%2$s for autocompleting keywords or table names.', 'visualizer' ),
'<span class="visualizer-emboss">',
'</span>'
);
?>
</li>
<?php do_action( 'visualizer_db_query_add_hints', $args ); ?>
</ul>
</div>
Expand Down Expand Up @@ -180,7 +198,16 @@ public static function _renderJsonScreen( $args ) {
<form id="json-endpoint-form">
<div class="json-wizard-hints">
<ul class="info">
<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>
<li>
<?php
echo sprintf(
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
__( '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>
</ul>
</div>

Expand Down Expand Up @@ -662,10 +689,20 @@ public static function _renderTabHelp( $args ) {
<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>
<?php
Visualizer_Render_Sidebar::_renderSectionEnd();
// translators: %s - the chart type.
Visualizer_Render_Sidebar::_renderSectionStart( sprintf( __( '%s chart', 'visualizer' ), ucwords( $displayType ) ), true );
?>
<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>
<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>
<h4><span class="dashicons dashicons-search"></span><a href="<?php echo str_replace( '#', $type, VISUALIZER_DOC_COLLECTION ); ?>" target="_blank">
<?php
echo sprintf(
// translators: %s - the chart type.
__( 'Articles containing "%s"', 'visualizer' ),
$displayType
);
?>
</a>
</h4>
<?php
Visualizer_Render_Sidebar::_renderSectionEnd();
Visualizer_Render_Sidebar::_renderGroupEnd();
Expand Down Expand Up @@ -775,7 +812,17 @@ public static function _renderTabBasic( $args ) {
<div class="viz-group-content">
<div>
<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>
<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>
<p class="viz-group-description viz-info-msg">
<b>
<?php
echo sprintf(
// translators: $s - the chart type with the link attached.
__( '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' ),
'<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">' . $type . '.csv</a>'
);
?>
</b>
</p>
<form id="vz-csv-file-form" action="<?php echo $upload_link; ?>" method="post"
target="thehole" enctype="multipart/form-data">
<input type="hidden" id="remote-data" name="remote_data">
Expand All @@ -798,8 +845,27 @@ public static function _renderTabBasic( $args ) {
<span class="viz-section-title"><?php _e( 'Import from CSV', 'visualizer' ); ?></span>
<div class="only-pro-anchor">
<div class="viz-section-items section-items">
<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>
<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>
<p class="viz-group-description">
<?php
echo sprintf(
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
__( '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>
<p class="viz-group-description viz-info-msg">
<b>
<?php
echo sprintf(
// translators: %s - the chart type with the link attached.
__( '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' ),
'<a href="' . VISUALIZER_ABSURL . 'samples/' . $type . '.csv" target="_blank">' . $type . '.csv</a>'
);
?>
</b>
</p>
<form id="vz-one-time-import" action="<?php echo $upload_link; ?>" method="post"
target="thehole" enctype="multipart/form-data">
<div class="remote-file-section">
Expand Down
6 changes: 5 additions & 1 deletion classes/Visualizer/Render/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ private function _renderMessages() {
if ( ! filter_var( ini_get( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN ) ) {
echo '<div class="updated error">';
echo '<p>';
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>' );
printf(
// translators: %s - the name of the option.
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>'
);
echo '</p>';
echo '</div>';
}
Expand Down
Loading
Loading