Skip to content

Commit a7be2c7

Browse files
free search over charts
free search over charts
1 parent c87a796 commit a7be2c7

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,16 @@ public function renderLibraryPage() {
318318

319319
// Added by Ash/Upwork
320320
$filterByMeta = filter_input( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
321+
if($filterByMeta){
322+
$query = array(
323+
'key' => Visualizer_Plugin::CF_SETTINGS,
324+
'value' => $filterByMeta,
325+
'compare' => 'LIKE',
326+
);
327+
$meta = isset($query_args['meta_query']) ? $query_args['meta_query'] : array();
328+
$meta[] = $query;
329+
$query_args['meta_query'] = $meta;
330+
}
321331
// Added by Ash/Upwork
322332

323333
// fetch charts
@@ -330,10 +340,6 @@ public function renderLibraryPage() {
330340
$settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
331341
unset( $settings['height'], $settings['width'] );
332342

333-
// Added by Ash/Upwork
334-
if($filterByMeta && strpos(serialize($settings), $filterByMeta) === FALSE) continue;
335-
// Added by Ash/Upwork
336-
337343
$type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
338344
$series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type );
339345
$data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( $chart->post_content ), $chart->ID, $type );

classes/Visualizer/Render/Library.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function _renderLibrary() {
8282
// Added by Ash/Upwork
8383
$filterBy = null;
8484
if(isset($_GET["filter"]) && strlen($_GET["filter"]) > 0){
85-
$filterBy = filter_input( INPUT_GET, $_GET["filter"], FILTER_SANITIZE_STRING );
85+
$filterBy = filter_input( INPUT_GET, "filter", FILTER_SANITIZE_STRING );
8686
}
8787
$action = $_SERVER["REQUEST_URI"];
8888
echo '<div id="visualizer-search"><form action="" method="get">

0 commit comments

Comments
 (0)