| @@ -28,15 +28,8 @@ | ||
| 28 | 28 | */ |
| 29 | 29 | class Visualizer_Render_Library extends Visualizer_Render { |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * Cached result of _isListView() to avoid repeat DB reads per request. | |
| 33 | - * | |
| 34 | - * @var bool|null | |
| 35 | - */ | |
| 36 | - private $_list_view_cached = null; | |
| 37 | - | |
| 38 | - /** | |
| 39 | 32 | * Renders library page. |
| 40 | 33 | * |
| 41 | 34 | * @since 1.0.0 |
| 42 | 35 | * |
| @@ -46,23 +39,15 @@ | ||
| 46 | 39 | echo '<div class="wrap">'; |
| 47 | 40 | echo '<div id="visualizer-icon" class="icon32"><br></div>'; |
| 48 | 41 | echo '<h2>'; |
| 49 | 42 | esc_html_e( 'Visualizer Library', 'visualizer' ); |
| 50 | - echo ' <div class="viz-add-new-group">'; | |
| 51 | - echo '<a href="javascript:;" class="add-new-h2 add-new-chart">', esc_html__( 'Add New Chart', 'visualizer' ), '</a>'; | |
| 52 | - echo '<button type="button" class="viz-add-new-toggle" aria-haspopup="true" aria-expanded="false"><span class="dashicons dashicons-arrow-down-alt2"></span></button>'; | |
| 53 | - echo '<div class="viz-add-new-menu" role="menu" aria-hidden="true">'; | |
| 54 | - echo '<button type="button" class="viz-add-new-item" data-viz-builder="ai">', esc_html__( 'AI Chart Builder', 'visualizer' ), '</button>'; | |
| 55 | - echo '<button type="button" class="viz-add-new-item" data-viz-builder="classic">', esc_html__( 'Classic Builder', 'visualizer' ), '</button>'; | |
| 56 | - echo '</div>'; | |
| 43 | + echo ' <a href="javascript:;" class="add-new-h2 add-new-chart">', esc_html__( 'Add New', 'visualizer' ), '</a>'; | |
| 57 | 44 | if ( Visualizer_Module::is_pro() ) { |
| 58 | - echo ' <a href="' . admin_url( 'options-general.php#visualizer_pro_license' ) . '" class="page-title-action">', esc_html__( 'License Settings', 'visualizer' ), '</a>'; | |
| 45 | + echo ' <a href="' . admin_url( 'options-general.php' ) . '" class="page-title-action">', esc_html__( 'License Settings', 'visualizer' ), '</a>'; | |
| 59 | 46 | } |
| 60 | - echo '</div>'; | |
| 61 | 47 | echo '</h2>'; |
| 62 | 48 | $this->_renderMessages(); |
| 63 | 49 | $this->_renderLibrary(); |
| 64 | - echo '<div id="viz-chart-builder-root"></div>'; | |
| 65 | 50 | echo '</div>'; |
| 66 | 51 | } |
| 67 | 52 | |
| 68 | 53 | /** |
| @@ -75,13 +60,9 @@ | ||
| 75 | 60 | private function _renderMessages() { |
| 76 | 61 | if ( ! filter_var( ini_get( 'allow_url_fopen' ), FILTER_VALIDATE_BOOLEAN ) ) { |
| 77 | 62 | echo '<div class="updated error">'; |
| 78 | 63 | echo '<p>'; |
| 79 | - printf( | |
| 80 | - // translators: %s - the name of the option. | |
| 81 | - esc_html__( '%s option is disabled in your php.ini config. Please enable it by changing its value to 1. This option increases the speed of remote CSV uploading.', 'visualizer' ), | |
| 82 | - '<b>allow_url_fopen</b>' | |
| 83 | - ); | |
| 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>' ); | |
| 84 | 65 | echo '</p>'; |
| 85 | 66 | echo '</div>'; |
| 86 | 67 | } |
| 87 | 68 | } |
| @@ -92,10 +73,8 @@ | ||
| 92 | 73 | private function getDisplayForm() { |
| 93 | 74 | echo '<div class="visualizer-library-form"> |
| 94 | 75 | <form action="' . admin_url( 'admin.php' ) . '"> |
| 95 | 76 | <input type="hidden" name="page" value="' . Visualizer_Plugin::NAME . '"/> |
| 96 | - <input type="hidden" name="view" value="' . esc_attr( $this->_isListView() ? 'list' : 'grid' ) . '"/> | |
| 97 | - <span class="viz-view-toggle-group">' . $this->_getViewToggleHTML() . '</span> | |
| 98 | 77 | <select class="viz-filter" name="type"> |
| 99 | 78 | '; |
| 100 | 79 | |
| 101 | 80 | echo '<option value="" selected>' . __( 'All types', 'visualizer' ) . '</option>'; |
| @@ -168,9 +147,9 @@ | ||
| 168 | 147 | unset( $sources['query_wp'] ); |
| 169 | 148 | } |
| 170 | 149 | $sources = array_filter( $sources ); |
| 171 | 150 | uasort( |
| 172 | - $sources, function ( $a, $b ) { | |
| 151 | + $sources, function( $a, $b ) { | |
| 173 | 152 | if ( $a === $b ) { |
| 174 | 153 | return 0; |
| 175 | 154 | } |
| 176 | 155 | return ( $a < $b ) ? -1 : 1; |
| @@ -239,10 +218,10 @@ | ||
| 239 | 218 | $license = get_option( 'visualizer_pro_license_data', 'free' ); |
| 240 | 219 | $license_key = ''; |
| 241 | 220 | $download_id = ''; |
| 242 | 221 | if ( ! empty( $license ) && is_object( $license ) ) { |
| 243 | - $license_key = isset( $license->key ) ? $license->key : ''; | |
| 244 | - $download_id = isset( $license->download_id ) ? $license->download_id : ''; | |
| 222 | + $license_key = $license->key; | |
| 223 | + $download_id = $license->download_id; | |
| 245 | 224 | } |
| 246 | 225 | $admin_license_url = admin_url( 'options-general.php#visualizer_pro_license' ); |
| 247 | 226 | $renew_license_url = tsdk_utmify( Visualizer_Plugin::STORE_URL . '?edd_license_key=' . $license_key . '&download_id=' . $download_id, 'visualizer_license_block' ); |
| 248 | 227 | echo ' |
| @@ -273,8 +252,9 @@ | ||
| 273 | 252 | overlay.style.display = "none"; |
| 274 | 253 | popup.style.display = "none"; |
| 275 | 254 | } |
| 276 | 255 | </script>'; |
| 256 | + | |
| 277 | 257 | } |
| 278 | 258 | /** |
| 279 | 259 | * Renders library content. |
| 280 | 260 | * |
| @@ -298,68 +278,40 @@ | ||
| 298 | 278 | echo '</div>'; |
| 299 | 279 | echo '<div id="visualizer-content-wrapper">'; |
| 300 | 280 | echo '<div id="tsdk_banner" class="visualizer-banner"></div>'; |
| 301 | 281 | if ( ! empty( $this->charts ) ) { |
| 302 | - if ( $this->_isListView() ) { | |
| 303 | - echo '<div id="visualizer-library" class="visualizer-clearfix view-list">'; | |
| 304 | - $this->_renderSidebar(); | |
| 305 | - echo '<table class="wp-list-table widefat striped viz-charts-table">'; | |
| 306 | - echo '<thead><tr>'; | |
| 307 | - echo '<th class="col-id">' . esc_html__( 'ID', 'visualizer' ) . '</th>'; | |
| 308 | - echo '<th class="col-title">' . esc_html__( 'Title', 'visualizer' ) . '</th>'; | |
| 309 | - echo '<th class="col-type">' . esc_html__( 'Type', 'visualizer' ) . '</th>'; | |
| 310 | - echo '<th class="col-shortcode">' . esc_html__( 'Shortcode', 'visualizer' ) . '</th>'; | |
| 311 | - echo '<th class="col-actions">' . esc_html__( 'Actions', 'visualizer' ) . '</th>'; | |
| 312 | - echo '</tr></thead><tbody>'; | |
| 313 | - foreach ( $this->charts as $placeholder_id => $chart ) { | |
| 314 | - $enable_controls = false; | |
| 315 | - $settings = isset( $chart['settings'] ) ? $chart['settings'] : array(); | |
| 316 | - if ( ! empty( $settings['controls']['controlType'] ) ) { | |
| 317 | - $column_index = $settings['controls']['filterColumnIndex']; | |
| 318 | - $column_label = $settings['controls']['filterColumnLabel']; | |
| 319 | - if ( 'false' !== $column_index || 'false' !== $column_label ) { | |
| 320 | - $enable_controls = true; | |
| 321 | - } | |
| 282 | + echo '<div id="visualizer-library" class="visualizer-clearfix">'; | |
| 283 | + $count = 0; | |
| 284 | + foreach ( $this->charts as $placeholder_id => $chart ) { | |
| 285 | + // show the sidebar after the first 3 charts. | |
| 286 | + $count++; | |
| 287 | + $enable_controls = false; | |
| 288 | + $settings = isset( $chart['settings'] ) ? $chart['settings'] : array(); | |
| 289 | + if ( ! empty( $settings['controls']['controlType'] ) ) { | |
| 290 | + $column_index = $settings['controls']['filterColumnIndex']; | |
| 291 | + $column_label = $settings['controls']['filterColumnLabel']; | |
| 292 | + if ( 'false' !== $column_index || 'false' !== $column_label ) { | |
| 293 | + $enable_controls = true; | |
| 322 | 294 | } |
| 295 | + } | |
| 296 | + if ( 3 === $count ) { | |
| 297 | + $this->_renderSidebar(); | |
| 323 | 298 | $this->_renderChartBox( $placeholder_id, $chart['id'], $enable_controls ); |
| 299 | + } else { | |
| 300 | + $this->_renderChartBox( $placeholder_id, $chart['id'], $enable_controls ); | |
| 324 | 301 | } |
| 325 | - echo '</tbody></table>'; | |
| 326 | - echo '</div>'; | |
| 327 | - } else { | |
| 328 | - echo '<div id="visualizer-library" class="visualizer-clearfix view-grid">'; | |
| 302 | + } | |
| 303 | + // show the sidebar if there are less than 3 charts. | |
| 304 | + if ( $count < 3 ) { | |
| 329 | 305 | $this->_renderSidebar(); |
| 330 | - foreach ( $this->charts as $placeholder_id => $chart ) { | |
| 331 | - $enable_controls = false; | |
| 332 | - $settings = isset( $chart['settings'] ) ? $chart['settings'] : array(); | |
| 333 | - if ( ! empty( $settings['controls']['controlType'] ) ) { | |
| 334 | - $column_index = $settings['controls']['filterColumnIndex']; | |
| 335 | - $column_label = $settings['controls']['filterColumnLabel']; | |
| 336 | - if ( 'false' !== $column_index || 'false' !== $column_label ) { | |
| 337 | - $enable_controls = true; | |
| 338 | - } | |
| 339 | - } | |
| 340 | - $this->_renderChartBox( $placeholder_id, $chart['id'], $enable_controls ); | |
| 341 | - } | |
| 342 | - echo '</div>'; | |
| 343 | 306 | } |
| 307 | + echo '</div>'; | |
| 344 | 308 | } else { |
| 345 | - echo '<div id="visualizer-library" class="visualizer-clearfix view-grid">'; | |
| 346 | - $this->_renderSidebar(); | |
| 309 | + echo '<div id="visualizer-library" class="visualizer-clearfix">'; | |
| 347 | 310 | echo '<div class="items"><div class="visualizer-chart">'; |
| 348 | 311 | echo '<div class="visualizer-chart-canvas visualizer-nochart-canvas">'; |
| 349 | - echo '<div class="visualizer-notfound">'; | |
| 350 | - echo esc_html__( 'No charts found. Click \'Add New Chart\' to create one.', 'visualizer' ); | |
| 351 | - echo '<p><h2>'; | |
| 352 | - echo '<div class="viz-add-new-group">'; | |
| 353 | - echo '<a href="javascript:;" class="add-new-h2 add-new-chart">', esc_html__( 'Add New Chart', 'visualizer' ), '</a>'; | |
| 354 | - echo '<button type="button" class="viz-add-new-toggle" aria-haspopup="true" aria-expanded="false"><span class="dashicons dashicons-arrow-down-alt2"></span></button>'; | |
| 355 | - echo '<div class="viz-add-new-menu" role="menu" aria-hidden="true">'; | |
| 356 | - echo '<button type="button" class="viz-add-new-item" data-viz-builder="ai">', esc_html__( 'AI Chart Builder', 'visualizer' ), '</button>'; | |
| 357 | - echo '<button type="button" class="viz-add-new-item" data-viz-builder="classic">', esc_html__( 'Classic Builder', 'visualizer' ), '</button>'; | |
| 312 | + echo '<div class="visualizer-notfound">', esc_html__( 'No charts found', 'visualizer' ), '<p><h2><a href="javascript:;" class="add-new-h2 add-new-chart">', esc_html__( 'Add New', 'visualizer' ), '</a></h2></p></div>'; | |
| 358 | 313 | echo '</div>'; |
| 359 | - echo '</div>'; | |
| 360 | - echo '</h2></p></div>'; | |
| 361 | - echo '</div>'; | |
| 362 | 314 | echo '<div class="visualizer-chart-footer visualizer-clearfix">'; |
| 363 | 315 | echo '<div class="visualizer-action-group visualizer-nochart">'; |
| 364 | 316 | echo '<span class="visualizer-chart-action visualizer-nochart-delete"><span class="dashicons dashicons-trash"></span></span>'; |
| 365 | 317 | echo '<span class="visualizer-chart-action visualizer-nochart-shortcode"><span class="dashicons dashicons-shortcode"></span></span>'; |
| @@ -365,12 +317,13 @@ | ||
| 365 | 317 | echo '<span class="visualizer-chart-action visualizer-nochart-shortcode"><span class="dashicons dashicons-shortcode"></span></span>'; |
| 366 | 318 | echo '<span class="visualizer-chart-action visualizer-nochart-image"><span class="dashicons dashicons-format-image"></span></span>'; |
| 367 | 319 | echo '<span class="visualizer-chart-action visualizer-nochart-export"><span class="dashicons dashicons-download"></span></span>'; |
| 368 | 320 | echo '<span class="visualizer-chart-action visualizer-nochart-clone"><span class="dashicons dashicons-admin-page"></span></span>'; |
| 369 | - echo '<span class="visualizer-chart-action visualizer-nochart-edit"><span class="dashicons dashicons-edit"></span></span>'; | |
| 321 | + echo '<span class="visualizer-chart-action visualizer-nochart-edit"><span class="dashicons dashicons-admin-generic"></span></span>'; | |
| 370 | 322 | echo '</div>'; |
| 371 | 323 | echo '</div>'; |
| 372 | 324 | echo '</div></div>'; |
| 325 | + $this->_renderSidebar(); | |
| 373 | 326 | echo '</div>'; |
| 374 | 327 | } |
| 375 | 328 | echo '</div>'; |
| 376 | 329 | if ( is_array( $this->pagination ) ) { |
| @@ -392,11 +345,10 @@ | ||
| 392 | 345 | * @param string $placeholder_id The placeholder's id for the chart. |
| 393 | 346 | * @param int $chart_id The id of the chart. |
| 394 | 347 | */ |
| 395 | 348 | private function _renderChartBox( $placeholder_id, $chart_id, $with_filter = false ) { |
| 396 | - $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS ); | |
| 397 | - $chart_library = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_LIBRARY, true ); | |
| 398 | - $title = '#' . $chart_id; | |
| 349 | + $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS ); | |
| 350 | + $title = '#' . $chart_id; | |
| 399 | 351 | if ( ! empty( $settings[0]['title'] ) ) { |
| 400 | 352 | $title = $settings[0]['title']; |
| 401 | 353 | } |
| 402 | 354 | // for ChartJS, title is an array. |
| @@ -442,14 +394,10 @@ | ||
| 442 | 394 | admin_url( 'admin-ajax.php' ) |
| 443 | 395 | ) |
| 444 | 396 | ); |
| 445 | 397 | $chart_type = get_post_meta( $chart_id, Visualizer_Plugin::CF_CHART_TYPE, true ); |
| 446 | - $chart_type_label = $chart_type; | |
| 447 | - if ( empty( $chart_type_label ) && 'd3' === strtolower( (string) $chart_library ) ) { | |
| 448 | - $chart_type_label = __( 'AI', 'visualizer' ); | |
| 449 | - } | |
| 450 | 398 | |
| 451 | - $types = array( 'area', 'geo', 'column', 'bubble', 'scatter', 'gauge', 'candlestick', 'timeline', 'combo', 'polarArea', 'radar' ); | |
| 399 | + $types = ['area', 'geo', 'column', 'bubble', 'scatter', 'gauge', 'candlestick', 'timeline', 'combo', 'polarArea', 'radar' ]; | |
| 452 | 400 | |
| 453 | 401 | $pro_class = ''; |
| 454 | 402 | |
| 455 | 403 | if ( ! empty( $chart_type ) && in_array( $chart_type, $types, true ) ) { |
| @@ -461,30 +409,9 @@ | ||
| 461 | 409 | $chart_status['icon'] = 'error dashicons-dismiss'; |
| 462 | 410 | $chart_status['title'] = __( 'Click to view the error', 'visualizer' ); |
| 463 | 411 | } |
| 464 | 412 | $shortcode = sprintf( '[visualizer id="%s" class=""]', $chart_id ); |
| 465 | - | |
| 466 | - if ( $this->_isListView() ) { | |
| 467 | - // ── List view: table row ── | |
| 468 | - echo '<tr class="viz-list-row">'; | |
| 469 | - echo '<td class="col-id">#' . esc_html( (string) $chart_id ) . '</td>'; | |
| 470 | - echo '<td class="col-title">' . esc_html( $title ) . '</td>'; | |
| 471 | - echo '<td class="col-type">' . ( ! empty( $chart_type_label ) ? '<span class="viz-chart-type-badge">' . esc_html( $chart_type_label ) . '</span>' : '—' ) . '</td>'; | |
| 472 | - echo '<td class="col-shortcode"><code class="viz-shortcode-display">' . esc_html( $shortcode ) . '</code></td>'; | |
| 473 | - echo '<td class="col-actions"><div class="visualizer-action-group">'; | |
| 474 | - echo '<a class="visualizer-chart-action visualizer-chart-delete" href="' . $delete_url . '" onclick="return showNotice.warn();"><span class="dashicons dashicons-trash"></span><span class="tooltip-text">' . esc_html__( 'Delete', 'visualizer' ) . '</span></a>'; | |
| 475 | - echo '<a class="visualizer-chart-action visualizer-chart-shortcode ' . esc_attr( $pro_class ) . '" href="javascript:;" data-clipboard-text="' . esc_attr( $shortcode ) . '"><span class="dashicons dashicons-shortcode ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_html__( 'Copy Shortcode', 'visualizer' ) . '</span></a>'; | |
| 476 | - echo '<a class="visualizer-chart-action visualizer-chart-export ' . esc_attr( $pro_class ) . '" href="javascript:;" data-chart="' . $export_link . '"><span class="dashicons dashicons-download ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_html__( 'Export CSV', 'visualizer' ) . '</span></a>'; | |
| 477 | - echo '<a class="visualizer-chart-action visualizer-chart-clone ' . esc_attr( $pro_class ) . '" href="' . $clone_url . '"><span class="dashicons dashicons-admin-page ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_html__( 'Duplicate', 'visualizer' ) . '</span></a>'; | |
| 478 | - echo '<a class="visualizer-chart-action visualizer-chart-edit button button-secondary ' . esc_attr( $pro_class ) . '" href="javascript:;" data-chart="' . esc_attr( (string) $chart_id ) . '" data-library="' . esc_attr( $chart_library ) . '"><span class="dashicons dashicons-edit ' . esc_attr( $pro_class ) . '"></span><span class="visualizer-action-label">' . esc_html__( 'Edit', 'visualizer' ) . '</span><span class="tooltip-text">' . esc_html__( 'Edit', 'visualizer' ) . '</span></a>'; | |
| 479 | - echo '</div></td>'; | |
| 480 | - echo '</tr>'; | |
| 481 | - return; | |
| 482 | - } | |
| 483 | - | |
| 484 | - // ── Grid view: card ── | |
| 485 | - $type_badge = ! empty( $chart_type ) ? '<span class="viz-chart-type-badge">' . esc_html( $chart_type ) . '</span>' : ''; | |
| 486 | - echo '<div class="items"><div class="visualizer-chart"><div class="visualizer-chart-title"><span>' . esc_html( $title ) . '</span>' . $type_badge . '</div>'; | |
| 413 | + echo '<div class="items"><div class="visualizer-chart"><div class="visualizer-chart-title">', esc_html( $title ), '</div>'; | |
| 487 | 414 | if ( Visualizer_Module::is_pro() && $with_filter ) { |
| 488 | 415 | echo '<div id="chart_wrapper_' . $placeholder_id . '">'; |
| 489 | 416 | echo '<div id="control_wrapper_' . $placeholder_id . '" class="vz-library-chart-filter"></div>'; |
| 490 | 417 | } |
| @@ -495,16 +422,16 @@ | ||
| 495 | 422 | echo '</div>'; |
| 496 | 423 | } |
| 497 | 424 | echo '<div class="visualizer-chart-footer visualizer-clearfix">'; |
| 498 | 425 | echo '<div class="visualizer-action-group">'; |
| 499 | - echo '<a class="visualizer-chart-action visualizer-chart-edit button button-secondary ' . esc_attr( $pro_class ) . '" href="javascript:;" data-chart="', esc_attr( (string) $chart_id ), '" data-library="' . esc_attr( $chart_library ) . '"><span class="dashicons dashicons-edit ' . esc_attr( $pro_class ) . '"></span><span class="visualizer-action-label">' . esc_html__( 'Edit', 'visualizer' ) . '</span><span class="tooltip-text">' . esc_html__( 'Edit', 'visualizer' ) . '</span></a>'; | |
| 500 | - echo '<a class="visualizer-chart-action visualizer-chart-shortcode ' . esc_attr( $pro_class ) . '" href="javascript:;" data-clipboard-text="', esc_attr( $shortcode ), '"><span class="dashicons dashicons-shortcode ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_html__( 'Copy Shortcode', 'visualizer' ) . '</span></a>'; | |
| 426 | + echo '<a class="visualizer-chart-action visualizer-chart-delete" href="', $delete_url, '" onclick="return showNotice.warn();"><span class="dashicons dashicons-trash"></span><span class="tooltip-text">' . esc_attr__( 'Delete', 'visualizer' ) . '</span></a>'; | |
| 427 | + echo '<a class="visualizer-chart-action visualizer-chart-shortcode ' . esc_attr( $pro_class ) . '" href="javascript:;" data-clipboard-text="', esc_attr( $shortcode ), '"><span class="dashicons dashicons-shortcode ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_attr__( 'Copy Shortcode', 'visualizer' ) . '</span></a>'; | |
| 501 | 428 | if ( $this->can_chart_have_action( 'image', $chart_id ) ) { |
| 502 | - echo '<a class="visualizer-chart-action visualizer-chart-image ' . esc_attr( $pro_class ) . '" href="javascript:;" data-chart="visualizer-', esc_attr( (string) $chart_id ), '" data-chart-title="', esc_attr( $title ), '"><span class="dashicons dashicons-format-image ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_html__( 'Download PNG', 'visualizer' ) . '</span></a>'; | |
| 429 | + echo '<a class="visualizer-chart-action visualizer-chart-image ' . esc_attr( $pro_class ) . '" href="javascript:;" data-chart="visualizer-', $chart_id, '" data-chart-title="', $title, '"><span class="dashicons dashicons-format-image ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_attr__( 'Download PNG', 'visualizer' ) . '</span></a>'; | |
| 503 | 430 | } |
| 504 | - echo '<a class="visualizer-chart-action visualizer-chart-export ' . esc_attr( $pro_class ) . '" href="javascript:;" data-chart="', $export_link, '"><span class="dashicons dashicons-download ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_html__( 'Export CSV', 'visualizer' ) . '</span></a>'; | |
| 505 | - echo '<a class="visualizer-chart-action visualizer-chart-clone ' . esc_attr( $pro_class ) . '" href="', $clone_url, '"><span class="dashicons dashicons-admin-page ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_html__( 'Duplicate', 'visualizer' ) . '</span></a>'; | |
| 506 | - echo '<a class="visualizer-chart-action visualizer-chart-delete" href="', $delete_url, '" onclick="return showNotice.warn();"><span class="dashicons dashicons-trash"></span><span class="tooltip-text">' . esc_html__( 'Delete', 'visualizer' ) . '</span></a>'; | |
| 431 | + echo '<a class="visualizer-chart-action visualizer-chart-export ' . esc_attr( $pro_class ) . '" href="javascript:;" data-chart="', $export_link, '"><span class="dashicons dashicons-download ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_attr__( 'Export CSV', 'visualizer' ) . '</span></a>'; | |
| 432 | + echo '<a class="visualizer-chart-action visualizer-chart-clone ' . esc_attr( $pro_class ) . '" href="', $clone_url, '"><span class="dashicons dashicons-admin-page ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_attr__( 'Duplicate', 'visualizer' ) . '</span></a>'; | |
| 433 | + echo '<a class="visualizer-chart-action visualizer-chart-edit ' . esc_attr( $pro_class ) . '" href="javascript:;" data-chart="', $chart_id, '"><span class="dashicons dashicons-admin-generic ' . esc_attr( $pro_class ) . '"></span><span class="tooltip-text">' . esc_attr__( 'Edit', 'visualizer' ) . '</span></a>'; | |
| 507 | 434 | echo '</div>'; |
| 508 | 435 | do_action( 'visualizer_chart_languages', $chart_id ); |
| 509 | 436 | echo '<hr><div class="visualizer-chart-status"><span title="' . __( 'Chart ID', 'visualizer' ) . '">(' . $chart_id . '):</span> <span class="visualizer-date" title="' . __( 'Last Updated', 'visualizer' ) . '">' . $chart_status['date'] . '</span><span class="visualizer-error"><i class="dashicons ' . $chart_status['icon'] . '" data-viz-error="' . esc_attr( str_replace( '"', "'", $chart_status['error'] ) ) . '" title="' . esc_attr( $chart_status['title'] ) . '"></i></span></div>'; |
| 510 | 437 | echo '</div>'; |
| @@ -511,64 +438,40 @@ | ||
| 511 | 438 | echo '</div></div>'; |
| 512 | 439 | } |
| 513 | 440 | |
| 514 | 441 | /** |
| 515 | - * Returns true when the library should render in list (no-preview) mode. | |
| 516 | - * | |
| 517 | - * Priority: ?view= URL param (saves to user meta) → saved user meta → grid default. | |
| 518 | - * | |
| 519 | - * No nonce needed: this is a bookmarkable UI preference URL. A nonce would expire | |
| 520 | - * and break saved/shared links for zero real security gain — the value is allowlisted | |
| 521 | - * to 'list'|'grid' before any write happens. | |
| 522 | - */ | |
| 523 | - private function _isListView(): bool { | |
| 524 | - if ( null !== $this->_list_view_cached ) { | |
| 525 | - return $this->_list_view_cached; | |
| 526 | - } | |
| 527 | - if ( isset( $_GET['view'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 528 | - $view = sanitize_text_field( wp_unslash( $_GET['view'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 529 | - if ( in_array( $view, array( 'list', 'grid' ), true ) ) { | |
| 530 | - update_user_meta( get_current_user_id(), 'visualizer_library_view', $view ); | |
| 531 | - } | |
| 532 | - $this->_list_view_cached = ( 'list' === $view ); | |
| 533 | - } else { | |
| 534 | - $saved = get_user_meta( get_current_user_id(), 'visualizer_library_view', true ); | |
| 535 | - $this->_list_view_cached = ( 'list' === $saved ); | |
| 536 | - } | |
| 537 | - return $this->_list_view_cached; | |
| 538 | - } | |
| 539 | - | |
| 540 | - /** | |
| 541 | - * Returns the HTML for the grid/list view toggle links. | |
| 542 | - */ | |
| 543 | - private function _getViewToggleHTML(): string { | |
| 544 | - $is_list = $this->_isListView(); | |
| 545 | - $grid_url = esc_url( add_query_arg( 'view', 'grid' ) ); | |
| 546 | - $list_url = esc_url( add_query_arg( 'view', 'list' ) ); | |
| 547 | - return '<a href="' . $grid_url . '" class="viz-view-toggle' . ( ! $is_list ? ' active' : '' ) . '" title="' . esc_attr__( 'Grid View', 'visualizer' ) . '"><span class="dashicons dashicons-screenoptions"></span></a>' | |
| 548 | - . '<a href="' . $list_url . '" class="viz-view-toggle' . ( $is_list ? ' active' : '' ) . '" title="' . esc_attr__( 'List View', 'visualizer' ) . '"><span class="dashicons dashicons-list-view"></span></a>'; | |
| 549 | - } | |
| 550 | - | |
| 551 | - /** | |
| 552 | 442 | * Render 2-col sidebar |
| 553 | 443 | */ |
| 554 | 444 | private function _renderSidebar() { |
| 555 | 445 | if ( ! Visualizer_Module::is_pro() ) { |
| 556 | - $upgrade_url = tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'sidebarMenuUpgrade', 'index' ); | |
| 557 | - $chart_types = Visualizer_Module_Admin::proFeaturesEnabled() ? __( '6 more chart types', 'visualizer' ) : __( '11 more chart types', 'visualizer' ); | |
| 558 | - echo '<div class="items--upsell">'; | |
| 559 | - echo '<div class="viz-upsell-banner">'; | |
| 560 | - echo '<span class="dashicons dashicons-star-filled viz-upsell-banner__icon"></span>'; | |
| 561 | - echo '<div class="viz-upsell-banner__text">'; | |
| 562 | - echo '<strong>' . esc_html__( 'Unlock the full power of Visualizer PRO!', 'visualizer' ) . '</strong>'; | |
| 563 | - /* translators: %s: number of additional chart types (e.g. "11 more chart types") */ | |
| 564 | - echo '<span>' . sprintf( esc_html__( '%s, periodic data sync, database queries, frontend editor, and more.', 'visualizer' ), esc_html( $chart_types ) ) . '</span>'; | |
| 446 | + echo '<div class="items">'; | |
| 447 | + echo '<div class="viz-pro">'; | |
| 448 | + echo '<div id="visualizer-sidebar" class="one-columns">'; | |
| 449 | + echo '<div class="visualizer-sidebar-box">'; | |
| 450 | + echo '<h3>' . __( 'Discover the power of PRO!', 'visualizer' ) . '</h3><ul>'; | |
| 451 | + if ( Visualizer_Module_Admin::proFeaturesLocked() ) { | |
| 452 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( '6 more chart types', 'visualizer' ); | |
| 453 | + } else { | |
| 454 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( '11 more chart types', 'visualizer' ) . '</li>'; | |
| 455 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Synchronize Data Periodically', 'visualizer' ) . '</li>'; | |
| 456 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'ChartJS Charts', 'visualizer' ) . '</li>'; | |
| 457 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Table Google chart', 'visualizer' ) . '</li>'; | |
| 458 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Frontend Actions(Print, Export, Copy, Download)', 'visualizer' ) . '</li>'; | |
| 459 | + } | |
| 460 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Spreadsheet like editor', 'visualizer' ) . '</li>'; | |
| 461 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Import from other charts', 'visualizer' ) . '</li>'; | |
| 462 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Use database query to create charts', 'visualizer' ) . '</li>'; | |
| 463 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Create charts from WordPress tables', 'visualizer' ) . '</li>'; | |
| 464 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Frontend editor', 'visualizer' ) . '</li>'; | |
| 465 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Private charts', 'visualizer' ) . '</li>'; | |
| 466 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'WPML support for translating charts', 'visualizer' ) . '</li>'; | |
| 467 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Integration with Woocommerce Data endpoints', 'visualizer' ) . '</li>'; | |
| 468 | + echo '<li><svg class="icon list-icon"><use xlink:href="#list-icon"></use></svg>' . __( 'Auto-sync with online files', 'visualizer' ) . '</li></ul>'; | |
| 469 | + echo '<p class="vz-sidebar-box-action"><a href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'sidebarMenuUpgrade', 'index' ) . '#pro-features" target="_blank" class="button button-secondary">' . __( 'View more features', 'visualizer' ) . '</a><a href="' . tsdk_utmify( Visualizer_Plugin::PRO_TEASER_URL, 'sidebarMenuUpgrade', 'index' ) . '#pricing" target="_blank" class="button button-primary">' . __( 'Upgrade Now', 'visualizer' ) . '</a></p>'; | |
| 565 | 470 | echo '</div>'; |
| 566 | - echo '<div class="viz-upsell-banner__actions">'; | |
| 567 | - echo '<a href="' . esc_url( $upgrade_url . '#pro-features' ) . '" target="_blank" class="button button-secondary">' . esc_html__( 'View Features', 'visualizer' ) . '</a>'; | |
| 568 | - echo '<a href="' . esc_url( $upgrade_url . '#pricing' ) . '" target="_blank" class="button button-primary">' . esc_html__( 'Upgrade Now', 'visualizer' ) . '</a>'; | |
| 569 | 471 | echo '</div>'; |
| 570 | 472 | echo '</div>'; |
| 571 | 473 | echo '</div>'; |
| 572 | 474 | } |
| 573 | 475 | } |
| 476 | + | |
| 574 | 477 | } |