Skip to content
Merged
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
2 changes: 1 addition & 1 deletion classes/Visualizer/Module/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
$is_black_friday = apply_filters( 'themeisle_sdk_is_black_friday_sale', false );
// knowledge base link
$plugin_meta[] = sprintf(
'<a href="' . VISUALIZER_MAIN_DOC . '" target="_blank">%s</a>',
'<a href="' . esc_url( tsdk_utmify( VISUALIZER_MAIN_DOC, 'documentation', 'pluginrow' ) ) . '" target="_blank">%s</a>',
esc_html__( 'Docs', 'visualizer' )
);
if ( ! $is_black_friday ) {
Expand Down
29 changes: 19 additions & 10 deletions classes/Visualizer/Render/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static function _renderDbQuery( $args ) {
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 href="' . esc_url( tsdk_utmify( VISUALIZER_DB_QUERY_DOC_URL, 'sample-queries', 'chart-editor' ) ) . '" target="_blank">',
'</a>'
);
?>
Expand Down Expand Up @@ -208,7 +208,7 @@ public static function _renderJsonScreen( $args ) {
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 href="' . esc_url( tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/visualizer-how-to-extend-rest-endpoints-with-json-response', 'rest-endpoints', 'chart-editor' ) ) . '" target="_blank">',
'</a>'
);
?>
Expand Down Expand Up @@ -621,7 +621,7 @@ private static function _renderPermissions( $args ) {
array( 'visualizer-permission', 'visualizer-permission-specific', 'visualizer-permission-edit-specific' )
);
Visualizer_Render_Sidebar::_renderSectionEnd();
echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions', 'https://docs.themeisle.com/article/1280-how-to-customize-permissions' );
echo apply_filters( 'visualizer_pro_upsell', '', 'chart-permissions', tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/how-to-customize-permissions', 'chart-permissions', 'chart-editor' ) );
echo '</div>';
Visualizer_Render_Sidebar::_renderGroupEnd();
}
Expand Down Expand Up @@ -689,15 +689,15 @@ public static function _renderTabHelp( $args ) {
Visualizer_Render_Sidebar::_renderGroupStart( esc_html__( 'Documentation', 'visualizer' ), '', 'open' );
Visualizer_Render_Sidebar::_renderSectionStart( esc_html__( 'General', 'visualizer' ), true );
?>
<h4><span class="dashicons dashicons-editor-help"></span><a href="<?php echo VISUALIZER_MAIN_DOC; ?>" target="_blank"><?php _e( 'Main documentation page', 'visualizer' ); ?></a></h4>
<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>
<h4><span class="dashicons dashicons-editor-help"></span><a href="<?php echo esc_url( tsdk_utmify( VISUALIZER_MAIN_DOC, 'documentation', 'chart-editor' ) ); ?>" target="_blank"><?php _e( 'Main documentation page', 'visualizer' ); ?></a></h4>
<h4><span class="dashicons dashicons-media-code"></span><a href="<?php echo esc_url( tsdk_utmify( VISUALIZER_CODE_SNIPPETS_URL, 'code-snippets', 'chart-editor' ) ); ?>" 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">
<h4><span class="dashicons dashicons-search"></span><a href="<?php echo esc_url( tsdk_utmify( str_replace( '#', $type, VISUALIZER_DOC_COLLECTION ), 'chart-type-articles', 'chart-editor' ) ); ?>" target="_blank">
<?php
echo sprintf(
// translators: %s - the chart type.
Expand Down Expand Up @@ -854,7 +854,7 @@ public static function _renderTabBasic( $args ) {
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 or Excel (XLSX) 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 href="' . esc_url( tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/how-can-i-populate-data-from-google-spreadsheet', 'google-sheets', 'chart-editor' ) ) . '" target="_blank" >',
'</a>'
);
?>
Expand Down Expand Up @@ -917,7 +917,16 @@ public static function _renderTabBasic( $args ) {
<span class="viz-section-title visualizer_source_json" role="button" tabindex="0"><?php _e( 'Import from JSON', 'visualizer' ); ?></span>
<div class="only-pro-anchor">
<div class="viz-section-items section-items">
<p class="viz-group-description"><?php _e( 'You can choose here to import/synchronize your chart data with a remote JSON source. For more info check <a href="https://docs.themeisle.com/article/1052-how-to-generate-charts-from-json-data-rest-endpoints" target="_blank" >this</a> tutorial', 'visualizer' ); ?></p>
<p class="viz-group-description">
<?php
echo sprintf(
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
__( 'You can choose here to import/synchronize your chart data with a remote JSON source. For more info check %1$sthis%2$s tutorial', 'visualizer' ),
'<a href="' . esc_url( tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/how-to-generate-charts-from-json-data-rest-endpoints', 'json-data', 'chart-editor' ) ) . '" target="_blank" >',
'</a>'
);
?>
</p>
<form id="vz-import-json" action="<?php echo $upload_link; ?>" method="post" target="thehole" enctype="multipart/form-data">
<div class="remote-file-section">
<?php
Expand Down Expand Up @@ -1089,7 +1098,7 @@ class="dashicons dashicons-lock"></span></h2>
</div>
</div>
</form>
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp', 'https://docs.themeisle.com/article/1278-how-to-import-data-from-wordpress' ); ?>
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'import-wp', tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/how-to-create-charts-from-your-wordpress-posts', 'wordpress-posts', 'chart-editor' ) ); ?>
</div>
</div>
</li>
Expand Down Expand Up @@ -1248,7 +1257,7 @@ class="dashicons dashicons-lock"></span></h2>
<input type="button" id="db-chart-save-button" class="button button-primary" value="<?php _e( 'Save Schedule', 'visualizer' ); ?>">
</div>
</div>
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query', 'https://docs.themeisle.com/article/1279-how-to-import-data-from-a-database' ); ?>
<?php echo apply_filters( 'visualizer_pro_upsell', '', 'db-query', tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/how-to-generate-charts-from-the-database', 'database-query', 'chart-editor' ) ); ?>
</form>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Render/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected function _renderManualConfigDescription() {
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag, %3$s - HTML link tag, %4$s - HTML closing link tag.
__( 'Configure the graph by providing configuration variables right from the %1$sGoogle Visualization API%2$s. You can refer to %3$sCommon Snippets%4$s for examples.', 'visualizer' ), '<a href="https://developers.google.com/chart/interactive/docs/gallery/?#configuration-options" target="_blank">',
'</a>',
'<a href="https://docs.themeisle.com/article/728-manual-configuration" target="_blank">',
'<a href="' . esc_url( tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/manual-configuration', 'manual-configuration', 'chart-editor' ) ) . '" target="_blank">',
'</a>'
) . '</span>'
);
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Render/Sidebar/ChartJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ protected function _renderManualConfigDescription() {
__( 'Configure the graph by providing configuration variables right from the %1$sChartJS API%2$s. You can refer to %3$sCommon Snippets%4$s for examples.', 'visualizer' ),
'<a href="https://www.chartjs.org/docs/latest/configuration/" target="_blank">',
'</a>',
'<a href="https://docs.themeisle.com/article/728-manual-configuration" target="_blank">',
'<a href="' . esc_url( tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/manual-configuration', 'manual-configuration', 'chart-editor' ) ) . '" target="_blank">',
'</a>'
) . '</span>'
);
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Render/Sidebar/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected function _renderRoleField( $index ) {
esc_html__( 'Determines whether the series has to be used for a special role as mentioned in %1$shere%2$s. You can view a few examples %3$shere%4$s.', 'visualizer' ),
'<a href="https://developers.google.com/chart/interactive/docs/roles#what-roles-are-available" target="_blank">',
'</a>',
'<a href="https://docs.themeisle.com/article/1160-roles-for-series-visualizer" target="_blank">',
'<a href="' . esc_url( tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/roles-for-series-visualizer', 'series-roles', 'chart-editor' ) ) . '" target="_blank">',
'</a>'
)
);
Expand Down
6 changes: 3 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ function visualizer_launch() {
define( 'VISUALIZER_ENABLE_BETA_FEATURES', '' );

// 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_DB_QUERY_DOC_URL', 'https://docs.themeisle.com/visualizer-charts-and-graphs/visualizer-sample-queries-to-generate-charts' );
define( 'VISUALIZER_MAIN_DOC', 'https://docs.themeisle.com/visualizer-charts-and-graphs/' );
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_CODE_SNIPPETS_URL', 'https://docs.themeisle.com/visualizer-charts-and-graphs/' );
define( 'VISUALIZER_SUBSCRIBE_API', 'https://api.themeisle.com/tracking/subscribe' );
define( 'VISUALIZER_AGENTS_URL', 'https://ai.themeisle.com' );

Expand Down
8 changes: 5 additions & 3 deletions js/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@
break;
}

if($('span.viz-gvlink').length > 0) {
$('span.viz-gvlink').html($('span.viz-gvlink').html().replace('?', chart_type_in_api_link));
}
// Only the Google API link has the "gallery/?" placeholder. Other links in the
// description (e.g. Common Snippets) carry UTM query strings and must stay as they are.
$('span.viz-gvlink a[href*="/chart/interactive/docs/gallery/?"]').attr('href', function (i, href) {
return href.replace('gallery/?', 'gallery/' + chart_type_in_api_link);
});

$('.type-radio').change(function () {
$('.type-label-selected').removeClass('type-label-selected');
Expand Down
4 changes: 2 additions & 2 deletions templates/docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
<div class="pro-feature-inner">
<div class="pro-feature-features">
<h2>Documentation</h2>
<p>To get started with Visualizer, we recommend you first bookmark our main documentation page <a href="<?php echo VISUALIZER_MAIN_DOC; ?>" target="_blank">here</a>.</p>
<p>To get started with Visualizer, we recommend you first bookmark our main documentation page <a href="<?php echo esc_url( tsdk_utmify( VISUALIZER_MAIN_DOC, 'documentation', 'support-page' ) ); ?>" target="_blank">here</a>.</p>

<p>
Notably, you could take a look at this first introductory tutorial: <a href="https://docs.themeisle.com/article/597-create-chart" target="_blank">How to create my first chart</a>.
Notably, you could take a look at this first introductory tutorial: <a href="<?php echo esc_url( tsdk_utmify( 'https://docs.themeisle.com/visualizer-charts-and-graphs/create-chart', 'create-chart', 'support-page' ) ); ?>" target="_blank">How to create my first chart</a>.
</p>

<p>If you prefer learning through video, this could prove useful. It is a little dated however.</p>
Expand Down
35 changes: 35 additions & 0 deletions tests/e2e/specs/admin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,41 @@ test.describe( 'Chart Library', () => {
await expect( page.getByText(backendName) ).toBeVisible();
await expect( page.locator('g').filter({ hasText: 'Test Chart Name' }).locator('rect') ).toBeVisible();
} );

// frame.js rewrites the Google API link for the chart type. It must leave the
// "Common Snippets" docs link and its UTMs alone, on both libraries.
for ( const library of [ 'GoogleCharts', 'ChartJS' ] ) {
test( `manual configuration links (${ library })`, async ( { admin, page } ) => {
await admin.visitAdminPage( 'admin.php?page=visualizer&vaction=addnew' );
await page.waitForURL( '**/admin.php?page=visualizer&vaction=addnew' );
await expect( page.getByRole('button', { name: 'Classic Builder Step-by-step' }) ).toBeVisible({ timeout: 5000 });
await page.getByRole('button', { name: 'Classic Builder Step-by-step' }).click();
await page.waitForSelector('h1:text("Visualizer")');

const frame = page.frameLocator('iframe');
await frame.getByRole('combobox').selectOption({ value: library });
await selectChartAdmin( frame, CHART_JS_LABELS.pie );
await expect( frame.getByRole('button', { name: 'Create Chart' }) ).toBeVisible({ timeout: 5000 });

const snippets = frame.locator('span.viz-gvlink a').filter({ hasText: 'Common Snippets' });
await expect( snippets ).toHaveAttribute(
'href',
'https://docs.themeisle.com/visualizer-charts-and-graphs/manual-configuration?utm_source=wpadmin&utm_medium=chart-editor&utm_campaign=manual-configuration&utm_content=docsvisualizer-charts-and-graphsmanual-configuration'
);

if ( library === 'GoogleCharts' ) {
await expect( frame.locator('span.viz-gvlink a').filter({ hasText: 'Google Visualization API' }) ).toHaveAttribute(
'href',
'https://developers.google.com/chart/interactive/docs/gallery/piechart#configuration-options'
);
// The data filter box keeps its own text and link.
await expect( frame.locator('span.viz-gvlink a').filter({ hasText: 'Chart Controls API' }) ).toHaveAttribute(
'href',
'https://developers.google.com/chart/interactive/docs/gallery/controls#controls-gallery'
);
}
} );
}
} );

test.describe( 'Support', () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/php/static-analysis-stubs/symbols.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
define( 'VISUALIZER_ENABLE_BETA_FEATURES', '' );

// 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_DB_QUERY_DOC_URL', 'https://docs.themeisle.com/visualizer-charts-and-graphs/visualizer-sample-queries-to-generate-charts' );
define( 'VISUALIZER_MAIN_DOC', 'https://docs.themeisle.com/visualizer-charts-and-graphs/' );
define( 'VISUALIZER_DOC_COLLECTION', 'https://docs.themeisle.com/search?collectionId=561ec249c69791452ed4bceb&query=#+visualizer' );
define( 'VISUALIZER_DEMO_URL', 'https://demo.themeisle.com/visualizer/#' );
define( 'VISUALIZER_CODE_SNIPPETS_URL', 'https://docs.themeisle.com/category/726-visualizer' );
define( 'VISUALIZER_CODE_SNIPPETS_URL', 'https://docs.themeisle.com/visualizer-charts-and-graphs/' );
define( 'VISUALIZER_SUBSCRIBE_API', 'https://api.themeisle.com/tracking/subscribe' );

// to redirect all themeisle_log_event to error log.
Expand Down
Loading