| @@ -189,9 +189,9 @@ | ||
| 189 | 189 | if ( $success ) { |
| 190 | 190 | $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS, true ); |
| 191 | 191 | $rows = array(); |
| 192 | 192 | $series = get_post_meta( $chart_id, Visualizer_Plugin::CF_SERIES, true ); |
| 193 | - $data = unserialize( $chart->post_content ); | |
| 193 | + $data = self::get_chart_data( $chart, $type, false ); | |
| 194 | 194 | if ( ! empty( $series ) ) { |
| 195 | 195 | $row = array(); |
| 196 | 196 | foreach ( $series as $array ) { |
| 197 | 197 | $row[] = $array['label']; |
| @@ -697,5 +697,31 @@ | ||
| 697 | 697 | return array( 'schedule-chart', 'chart-permissions' ); |
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | + /** | |
| 702 | + * Gets the chart content after common manipulations. | |
| 703 | + */ | |
| 704 | + public static function get_chart_data( $chart, $type, $run_filter = true ) { | |
| 705 | + // change HTML entities | |
| 706 | + $data = unserialize( html_entity_decode( $chart->post_content ) ); | |
| 707 | + $altered = array(); | |
| 708 | + foreach ( $data as $index => $array ) { | |
| 709 | + if ( ! is_array( $index ) && is_array( $array ) ) { | |
| 710 | + foreach ( $array as &$datum ) { | |
| 711 | + if ( is_string( $datum ) ) { | |
| 712 | + $datum = stripslashes( $datum ); | |
| 713 | + } | |
| 714 | + } | |
| 715 | + $altered[ $index ] = $array; | |
| 716 | + } | |
| 717 | + } | |
| 718 | + // if something goes wrong and the end result is empty, be safe and use the original data | |
| 719 | + if ( empty( $altered ) ) { | |
| 720 | + $altered = $data; | |
| 721 | + } | |
| 722 | + if ( $run_filter ) { | |
| 723 | + return apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, $altered, $chart->ID, $type ); | |
| 724 | + } | |
| 725 | + return $altered; | |
| 726 | + } | |
| 701 | 727 | } |