Skip to content

Commit 40ae0a6

Browse files
pagination and filter not working in modal from "add media" button
1 parent 2b27d62 commit 40ae0a6

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public function enqueueMediaScripts() {
121121
* @return array The extended array of media view strings.
122122
*/
123123
public function setupMediaViewStrings( $strings ) {
124+
$chart_types = self::_getChartTypesLocalized( true, true, true );
124125
$strings['visualizer'] = array(
125126
'actions' => array(
126127
'get_charts' => Visualizer_Plugin::ACTION_GET_CHARTS,
@@ -134,8 +135,8 @@ public function setupMediaViewStrings( $strings ) {
134135
'create' => esc_html__( 'Create New', 'visualizer' ),
135136
),
136137
'library' => array(
137-
'filters' => self::_getChartTypesLocalized( true, true ),
138-
'types' => array_keys( self::_getChartTypesLocalized( true, true ) ),
138+
'filters' => $chart_types,
139+
'types' => array_keys( $chart_types ),
139140
),
140141
'nonce' => wp_create_nonce(),
141142
'buildurl' => add_query_arg( 'action', Visualizer_Plugin::ACTION_CREATE_CHART, admin_url( 'admin-ajax.php' ) ),
@@ -153,8 +154,16 @@ public function setupMediaViewStrings( $strings ) {
153154
* @access private
154155
* @return array The associated array of chart types with localized names.
155156
*/
156-
public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false ) {
157-
$types = array(
157+
public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darray = false, $add_select = false ) {
158+
$additional = array();
159+
if ( $add_select ) {
160+
$additional['select'] = array(
161+
'name' => esc_html__( 'All', 'visualizer' ),
162+
'enabled' => true,
163+
);
164+
}
165+
166+
$types = array_merge( $additional, array(
158167
'pie' => array(
159168
'name' => esc_html__( 'Pie', 'visualizer' ),
160169
'enabled' => true,
@@ -204,7 +213,7 @@ public static function _getChartTypesLocalized( $enabledOnly = false, $get2Darra
204213
'name' => esc_html__( 'Combo', 'visualizer' ),
205214
'enabled' => false,
206215
),
207-
);
216+
) );
208217
$types = apply_filters( 'visualizer_pro_chart_types', $types );
209218
if ( $enabledOnly ) {
210219
$filtered = array();

classes/Visualizer/Module/Chart.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public function getCharts() {
8383
),
8484
);
8585
$filter = filter_input( INPUT_GET, 's', FILTER_SANITIZE_STRING );
86+
if ( empty( $filter ) ) {
87+
// 'filter' is from the modal from the add media button.
88+
$filter = filter_input( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
89+
}
90+
8691
if ( $filter && in_array( $filter, Visualizer_Plugin::getChartTypes() ) ) {
8792
$query_args['meta_query'] = array(
8893
array(

js/media/view.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,18 @@
5959
settings.height = self.options.height;
6060

6161
table = new gv.DataTable({cols: series});
62-
chart = type === 'gauge' ? 'Gauge' : type.charAt(0).toUpperCase() + type.slice(1) + 'Chart';
62+
63+
switch (type) {
64+
case "gauge":
65+
case "table":
66+
case "timeline":
67+
chart = type.charAt(0).toUpperCase() + type.slice(1);
68+
break;
69+
default:
70+
chart = type.charAt(0).toUpperCase() + type.slice(1) + 'Chart';
71+
break;
72+
}
73+
6374
chart = new gv[chart](self.el);
6475

6576
switch (type) {

0 commit comments

Comments
 (0)