PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.8
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.8
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
← All changes | classes/Visualizer/Render/Library.php +187 -49 3.1.13.4.8 View file →
@@ -39,9 +39,12 @@
39 39 echo '<div class="wrap">';
40 40 echo '<div id="visualizer-icon" class="icon32"><br></div>';
41 41 echo '<h2>';
42 42 esc_html_e( 'Visualizer Library', 'visualizer' );
43 - echo ' <a href="javascript:;" class="add-new-h2">', esc_html__( 'Add New', 'visualizer' ), '</a>';
43 + echo ' <a href="javascript:;" class="add-new-h2 add-new-chart">', esc_html__( 'Add New', 'visualizer' ), '</a>';
44 + if ( Visualizer_Module::is_pro() ) {
45 + echo ' <a href="' . admin_url( 'options-general.php' ) . '" class="page-title-action">', esc_html__( 'License Settings', 'visualizer' ), '</a>';
46 + }
44 47 echo '</h2>';
45 48 $this->_renderMessages();
46 49 $this->_renderLibrary();
47 50 echo '</div>';
@@ -64,8 +67,148 @@
64 67 }
65 68 }
66 69
67 70 /**
71 + * Displays the search form.
72 + */
73 + private function getDisplayForm() {
74 + echo '<div class="visualizer-library-form">
75 + <form action="' . admin_url( 'admin.php' ) . '">
76 + <input type="hidden" name="page" value="' . Visualizer_Plugin::NAME . '"/>
77 + <select class="viz-filter" name="type">
78 + ';
79 +
80 + echo '<option value="" selected>' . __( 'All types', 'visualizer' ) . '</option>';
81 +
82 + $type = isset( $_GET['type'] ) ? $_GET['type'] : '';
83 + $enabled = array();
84 + $disabled = array();
85 + foreach ( $this->types as $id => $array ) {
86 + if ( ! is_array( $array ) ) {
87 + // support for old pro
88 + $array = array( 'enabled' => true, 'name' => $array );
89 + }
90 + if ( ! $array['enabled'] ) {
91 + $disabled[ $id ] = $array['name'];
92 + continue;
93 + }
94 + $enabled[ $id ] = $array['name'];
95 + }
96 +
97 + asort( $enabled );
98 + asort( $disabled );
99 +
100 + foreach ( $enabled as $id => $name ) {
101 + echo '<option value="' . esc_attr( $id ) . '" ' . selected( $type, $id ) . '>' . $name . '</option>';
102 + }
103 +
104 + if ( $disabled ) {
105 + echo '<optgroup label="' . __( 'Not available', 'visualizer' ) . '">';
106 + foreach ( $disabled as $id => $name ) {
107 + echo '<option value="' . esc_attr( $id ) . '" ' . selected( $type, $id ) . ' disabled>' . $name . '</option>';
108 + }
109 + echo '</optgroup>';
110 + }
111 +
112 + echo '
113 + </select>
114 + <select class="viz-filter" name="library">
115 + ';
116 +
117 + $libraries = array( '', 'ChartJS', 'DataTable', 'GoogleCharts' );
118 + $library = isset( $_GET['library'] ) ? $_GET['library'] : '';
119 + foreach ( $libraries as $lib ) {
120 + echo '<option value="' . esc_attr( $lib ) . '" ' . selected( $library, $lib ) . '>' . ( $lib === '' ? __( 'All libraries', 'visualizer' ) : $lib ) . '</option>';
121 + }
122 +
123 + echo '
124 + </select>
125 + <select class="viz-filter" name="date">
126 + ';
127 +
128 + $dates = Visualizer_Plugin::getSupportedDateFilter();
129 + $date = isset( $_GET['date'] ) ? $_GET['date'] : '';
130 + foreach ( Visualizer_Plugin::getSupportedDateFilter() as $dt => $label ) {
131 + echo '<option value="' . esc_attr( $dt ) . '" ' . selected( $date, $dt ) . '>' . $label . '</option>';
132 + }
133 +
134 + echo '
135 + </select>
136 + <select class="viz-filter" name="source">
137 + ';
138 +
139 + $disabled = array();
140 + $sources = array( 'json' => __( 'JSON', 'visualizer' ), 'csv' => __( 'Local CSV', 'visualizer' ), 'csv_remote' => __( 'Remote CSV', 'visualizer' ), 'query' => __( 'Database', 'visualizer' ), 'query_wp' => __( 'WordPress', 'visualizer' ) );
141 + if ( ! Visualizer_Module::is_pro() ) {
142 + $disabled['query'] = $sources['query'];
143 + unset( $sources['query'] );
144 + }
145 + if ( ! apply_filters( 'visualizer_is_business', false ) ) {
146 + $disabled['query_wp'] = $sources['query_wp'];
147 + unset( $sources['query_wp'] );
148 + }
149 + $sources = array_filter( $sources );
150 + uasort(
151 + $sources, function( $a, $b ) {
152 + if ( $a === $b ) {
153 + return 0;
154 + }
155 + return ( $a < $b ) ? -1 : 1;
156 + }
157 + );
158 +
159 + $source = isset( $_GET['source'] ) ? $_GET['source'] : '';
160 + echo '<option value="">' . __( 'All sources', 'visualizer' ) . '</option>';
161 + foreach ( $sources as $field => $label ) {
162 + echo '<option value="' . esc_attr( $field ) . '" ' . selected( $source, $field ) . '>' . $label . '</option>';
163 + }
164 +
165 + if ( $disabled ) {
166 + echo '<optgroup label="' . __( 'Not available', 'visualizer' ) . '">';
167 + foreach ( $disabled as $id => $name ) {
168 + echo '<option value="' . esc_attr( $id ) . '" ' . selected( $type, $id ) . ' disabled>' . $name . '</option>';
169 + }
170 + echo '</optgroup>';
171 + }
172 +
173 + $name = isset( $_GET['s'] ) ? $_GET['s'] : '';
174 + echo '
175 + </select>
176 + <input class="viz-filter" type="text" name="s" placeholder="' . __( 'Enter title', 'visualizer' ) . '" value="' . esc_attr( $name ) . '">
177 + ';
178 +
179 + echo '
180 + <span class="viz-filter">|</span>
181 + <select class="viz-filter" name="orderby">
182 + ';
183 +
184 + $order_by_fields = apply_filters( 'visualizer_filter_order_by', array( 'date' => __( 'Date', 'visualizer' ), 's' => __( 'Title', 'visualizer' ) ) );
185 + $order_by = isset( $_GET['orderby'] ) ? $_GET['orderby'] : '';
186 + echo '<option value="">' . __( 'Order By', 'visualizer' ) . '</option>';
187 + foreach ( $order_by_fields as $field => $label ) {
188 + echo '<option value="' . esc_attr( $field ) . '" ' . selected( $order_by, $field ) . '>' . $label . '</option>';
189 + }
190 +
191 + echo '
192 + </select>
193 + <select class="viz-filter" name="order">
194 + ';
195 +
196 + $order_type = array( 'desc' => __( 'Descending', 'visualizer' ), 'asc' => __( 'Ascending', 'visualizer' ) );
197 + $order = isset( $_GET['order'] ) ? $_GET['order'] : 'desc';
198 + foreach ( $order_type as $field => $label ) {
199 + echo '<option value="' . esc_attr( $field ) . '" ' . selected( $order, $field ) . '>' . $label . '</option>';
200 + }
201 +
202 + echo '
203 + </select>
204 + <input type="submit" class="viz-filter button button-secondary" value="' . __( 'Apply Filters', 'visualizer' ) . '">
205 + <input type="button" id="viz-lib-reset" class="viz-filter button button-secondary" value="' . __( 'Clear Filters', 'visualizer' ) . '">
206 + </form>
207 + </div>';
208 + }
209 +
210 + /**
68 211 * Renders library content.
69 212 *
70 213 * @since 1.0.0
71 214 *
@@ -79,57 +222,31 @@
79 222 }
80 223 // Added by Ash/Upwork
81 224 echo $this->custom_css;
82 225 echo '<div id="visualizer-types" class="visualizer-clearfix">';
83 - echo '<ul class="subsubsub">';
84 - foreach ( $this->types as $type => $array ) {
85 - if ( ! is_array( $array ) ) {
86 - // support for old pro
87 - $array = array( 'enabled' => true, 'name' => $array );
88 - }
89 - $label = $array['name'];
90 - $link = '<a class=" " href="' . esc_url(
91 - add_query_arg(
92 - array(
93 - 'type' => $type,
94 - 'vpage' => false,
95 - )
96 - )
97 - ) . '">';
98 - if ( ! $array['enabled'] ) {
99 - $link = "<a class=' visualizer-pro-only' href='" . Visualizer_Plugin::PRO_TEASER_URL . "' target='_blank'>";
100 - }
101 - echo '<li class="visualizer-list-item all">';
102 - if ( $type == $this->type ) {
103 - echo '<a class=" current" href="', esc_url( add_query_arg( 'vpage', false ) ), '">';
104 - echo $label;
105 - echo '</a>';
106 - } else {
107 - echo $link;
108 - echo $label;
109 - echo '</a>';
110 - }
111 - echo ' | </li>';
112 - }
113 - echo '</ul>';
114 - echo '<form action="" method="get"><p id="visualizer-search" class="search-box">
115 - <input type="search" name="s" value="' . $filterBy . '">
116 - <input type="hidden" name="page" value="visualizer">
117 - <input type="submit" id="search-submit" class="button button-secondary" value="' . esc_attr__( 'Search', 'visualizer' ) . '">
118 - </p> </form>';
226 + $this->getDisplayForm();
119 227 echo '</div>';
120 228 echo '<div id="visualizer-content-wrapper">';
121 229 if ( ! empty( $this->charts ) ) {
122 230 echo '<div id="visualizer-library" class="visualizer-clearfix">';
231 + $count = 0;
123 232 foreach ( $this->charts as $placeholder_id => $chart ) {
124 233 $this->_renderChartBox( $placeholder_id, $chart['id'] );
234 + // show the sidebar after the first 3 charts.
235 + if ( $count++ === 2 ) {
236 + $this->_renderSidebar();
237 + }
125 238 }
239 + // show the sidebar if there are less than 3 charts.
240 + if ( $count < 3 ) {
241 + $this->_renderSidebar();
242 + }
126 243 echo '</div>';
127 244 } else {
128 245 echo '<div id="visualizer-library" class="visualizer-clearfix">';
129 246 echo '<div class="visualizer-chart">';
130 247 echo '<div class="visualizer-chart-canvas visualizer-nochart-canvas">';
131 - echo '<div class="visualizer-notfound">', esc_html__( 'No charts found', 'visualizer' ), '</div>';
248 + 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>';
132 249 echo '</div>';
133 250 echo '<div class="visualizer-chart-footer visualizer-clearfix">';
134 251 echo '<span class="visualizer-chart-action visualizer-nochart-delete"></span>';
135 252 echo '<span class="visualizer-chart-action visualizer-nochart-clone"></span>';
@@ -134,16 +251,14 @@
134 251 echo '<span class="visualizer-chart-action visualizer-nochart-delete"></span>';
135 252 echo '<span class="visualizer-chart-action visualizer-nochart-clone"></span>';
136 253 echo '<span class="visualizer-chart-action visualizer-nochart-edit"></span>';
137 254 echo '<span class="visualizer-chart-action visualizer-nochart-export"></span>';
138 - echo '<span class="visualizer-chart-shortcode">';
139 - echo '&nbsp;[visualizer]&nbsp;';
140 - echo '</span>';
255 + echo '<span class="visualizer-chart-action visualizer-nochart-shortcode"></span>';
141 256 echo '</div>';
142 257 echo '</div>';
258 + $this->_renderSidebar();
143 259 echo '</div>';
144 260 }
145 - $this->_renderSidebar();
146 261 echo '</div>';
147 262 if ( is_array( $this->pagination ) ) {
148 263 echo '<ul class=" subsubsub">';
149 264 foreach ( $this->pagination as $page ) {
@@ -168,8 +283,16 @@
168 283 $title = '#' . $chart_id;
169 284 if ( ! empty( $settings[0]['title'] ) ) {
170 285 $title = $settings[0]['title'];
171 286 }
287 + // for ChartJS, title is an array.
288 + if ( is_array( $title ) && isset( $title['text'] ) ) {
289 + $title = $title['text'];
290 + }
291 + if ( empty( $title ) ) {
292 + $title = '#' . $chart_id;
293 + }
294 +
172 295 $ajax_url = admin_url( 'admin-ajax.php' );
173 296 $delete_url = add_query_arg(
174 297 array(
175 298 'action' => Visualizer_Plugin::ACTION_DELETE_CHART,
@@ -194,8 +317,16 @@
194 317 'security' => wp_create_nonce( Visualizer_Plugin::ACTION_EXPORT_DATA . Visualizer_Plugin::VERSION ),
195 318 ),
196 319 admin_url( 'admin-ajax.php' )
197 320 );
321 +
322 + $chart_status = array( 'date' => get_the_modified_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $chart_id ), 'error' => get_post_meta( $chart_id, Visualizer_Plugin::CF_ERROR, true ), 'icon' => 'dashicons-yes-alt', 'title' => 'A-OK!' );
323 + if ( ! empty( $chart_status['error'] ) ) {
324 + $chart_status['icon'] = 'error dashicons-dismiss';
325 + $chart_status['title'] = __( 'Click to view the error', 'visualizer' );
326 + }
327 +
328 + $shortcode = sprintf( '[visualizer id="%s" lazy="no" class=""]', $chart_id );
198 329 echo '<div class="visualizer-chart"><div class="visualizer-chart-title">', esc_html( $title ), '</div>';
199 330 echo '<div id="', $placeholder_id, '" class="visualizer-chart-canvas">';
200 331 echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
201 332 echo '</div>';
@@ -203,11 +334,14 @@
203 334 echo '<a class="visualizer-chart-action visualizer-chart-delete" href="', $delete_url, '" title="', esc_attr__( 'Delete', 'visualizer' ), '" onclick="return showNotice.warn();"></a>';
204 335 echo '<a class="visualizer-chart-action visualizer-chart-clone" href="', $clone_url, '" title="', esc_attr__( 'Clone', 'visualizer' ), '"></a>';
205 336 echo '<a class="visualizer-chart-action visualizer-chart-edit" href="javascript:;" title="', esc_attr__( 'Edit', 'visualizer' ), '" data-chart="', $chart_id, '"></a>';
206 337 echo '<a class="visualizer-chart-action visualizer-chart-export" href="javascript:;" title="', esc_attr__( 'Export', 'visualizer' ), '" data-chart="', $export_link, '"></a>';
207 - echo '<span class="visualizer-chart-shortcode" title="', esc_attr__( 'Click to select', 'visualizer' ), '">';
208 - echo '&nbsp;[visualizer id=&quot;', $chart_id, '&quot;]&nbsp;';
209 - echo '</span>';
338 + if ( $this->can_chart_have_action( 'image', $chart_id ) ) {
339 + echo '<a class="visualizer-chart-action visualizer-chart-image" href="javascript:;" title="', esc_attr__( 'Download as image', 'visualizer' ), '" data-chart="visualizer-', $chart_id, '" data-chart-title="', $title, '"></a>';
340 + }
341 + echo '<a class="visualizer-chart-action visualizer-chart-shortcode" href="javascript:;" title="', esc_attr__( 'Click to copy shortcode', 'visualizer' ), '" data-clipboard-text="', esc_attr( $shortcode ), '"></a>';
342 + echo '<span>&nbsp;</span>';
343 + 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>';
210 344 echo '</div>';
211 345 echo '</div>';
212 346 }
213 347
@@ -214,19 +348,23 @@
214 348 /**
215 349 * Render sidebar.
216 350 */
217 351 private function _renderSidebar() {
218 - if ( ! VISUALIZER_PRO ) {
352 + if ( ! Visualizer_Module::is_pro() ) {
219 353 echo '<div id="visualizer-sidebar">';
220 354 echo '<div class="visualizer-sidebar-box">';
221 - echo '<h3>' . __( 'Gain more editing power', 'visualizer' ) . '</h3><ul>';
355 + echo '<h3>' . __( 'Discover the power of PRO!', 'visualizer' ) . '</h3><ul>';
222 356 echo '<li>' . __( 'Spreadsheet like editor', 'visualizer' ) . '</li>';
223 357 echo '<li>' . __( 'Import from other charts', 'visualizer' ) . '</li>';
358 + echo '<li>' . __( 'Use database query to create charts', 'visualizer' ) . '</li>';
359 + echo '<li>' . __( 'Create charts from WordPress tables', 'visualizer' ) . '</li>';
224 360 echo '<li>' . __( 'Frontend editor', 'visualizer' ) . '</li>';
225 361 echo '<li>' . __( 'Private charts', 'visualizer' ) . '</li>';
226 362 echo '<li>' . __( 'Auto-sync with online files', 'visualizer' ) . '</li>';
227 - echo '<li>' . __( '3 more chart types', 'visualizer' ) . '</li></ul>';
228 - echo '<a href="' . Visualizer_Plugin::PRO_TEASER_URL . '" target="_blank" class="button button-primary">' . __( 'View more features', 'visualizer' ) . '</a>';
363 + echo '<li>' . __( '6 more chart types', 'visualizer' ) . '</li></ul>';
364 + echo '<p><a href="' . Visualizer_Plugin::PRO_TEASER_URL . '" target="_blank" class="button button-primary">' . __( 'View more features', 'visualizer' ) . '</a></p>';
365 + echo '<p style="background-color: #0073aac7; color: #ffffff; padding: 2px; font-weight: bold;">' . __( 'We offer a 30-day no-questions-asked money back guarantee!', 'visualizer' ) . '</p>';
366 + echo '<p><a href="' . VISUALIZER_SURVEY . '" target="_blank" class="">' . __( 'Don\'t see the features you need? Help us improve!', 'visualizer' ) . '</a></p>';
229 367 echo '</div>';
230 368 echo '</div>';
231 369 }
232 370 }