Skip to content

Commit c87a796

Browse files
free search over charts
free search over charts
1 parent 7e0ec01 commit c87a796

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

classes/Visualizer/Module/Admin.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ public function renderLibraryPage() {
316316
$filter = 'all';
317317
}
318318

319+
// Added by Ash/Upwork
320+
$filterByMeta = filter_input( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
321+
// Added by Ash/Upwork
322+
319323
// fetch charts
320324
$charts = array();
321325
$query = new WP_Query( $query_args );
@@ -326,6 +330,10 @@ public function renderLibraryPage() {
326330
$settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
327331
unset( $settings['height'], $settings['width'] );
328332

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

classes/Visualizer/Render/Library.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ private function _renderChartBox( $placeholder_id, $chart_id ) {
7979
* @access private
8080
*/
8181
private function _renderLibrary() {
82+
// Added by Ash/Upwork
83+
$filterBy = null;
84+
if(isset($_GET["filter"]) && strlen($_GET["filter"]) > 0){
85+
$filterBy = filter_input( INPUT_GET, $_GET["filter"], FILTER_SANITIZE_STRING );
86+
}
87+
$action = $_SERVER["REQUEST_URI"];
88+
echo '<div id="visualizer-search"><form action="" method="get">
89+
<input type="text" name="filter" value="' . $filterBy . '">
90+
<input type="hidden" name="page" value="visualizer">
91+
<input type="submit" class="button button-secondary" value="' . esc_attr__('Search', Visualizer_Plugin::NAME) . '">
92+
</form></div>';
93+
// Added by Ash/Upwork
94+
8295
echo '<div id="visualizer-types" class="visualizer-clearfix">';
8396
echo '<ul>';
8497
foreach ( $this->types as $type => $label ) {

0 commit comments

Comments
 (0)