PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.1.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.1.0
4.0.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 All 149 releases
← All changes | classes/Visualizer/Module/Frontend.php +25 -4 1.0.11.1.0 View file →
@@ -78,14 +78,22 @@
78 78 * Returns placeholder for chart according to visualizer shortcode attributes.
79 79 *
80 80 * @since 1.0.0
81 81 * @uses shortcode_atts() To parse income shortocdes.
82 + * @uses apply_filters() To filter chart's data and series arrays.
83 + * @uses get_post_meta() To fetch chart's meta information.
84 + * @uses wp_enqueue_script() To enqueue charts render script.
85 + * @uses wp_localize_script() To add chart data to the page inline script.
82 86 *
83 87 * @access public
84 88 * @param array $atts The array of shortcode attributes.
85 89 */
86 90 public function renderChart( $atts ) {
87 - $atts = shortcode_atts( array( 'id' => false ), $atts );
91 + $atts = shortcode_atts( array(
92 + 'id' => false, // chart id
93 + 'series' => false, // series filter hook
94 + 'data' => false, // data filter hook
95 + ), $atts );
88 96
89 97 // if empty id or chart does not exists, then return empty string
90 98 if ( !$atts['id'] || !( $chart = get_post( $atts['id'] ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) {
91 99 return '';
@@ -91,8 +99,9 @@
91 99 return '';
92 100 }
93 101
94 102 $id = 'visualizer-' . $atts['id'];
103 + $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true );
95 104
96 105 // faetch and update settings
97 106 $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true );
98 107 if ( empty( $settings['height'] ) ) {
@@ -98,14 +107,26 @@
98 107 if ( empty( $settings['height'] ) ) {
99 108 $settings['height'] = '400';
100 109 }
101 110
111 + // handle series filter hooks
112 + $series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type );
113 + if ( !empty( $atts['series'] ) ) {
114 + $series = apply_filters( $atts['series'], $series, $chart->ID, $type );
115 + }
116 +
117 + // handle data filter hooks
118 + $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( $chart->post_content ), $chart->ID, $type );
119 + if ( !empty( $atts['data'] ) ) {
120 + $data = apply_filters( $atts['data'], $data, $chart->ID, $type );
121 + }
122 +
102 123 // add chart to the array
103 124 $this->_charts[$id] = array(
104 - 'type' => get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true ),
105 - 'series' => get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ),
125 + 'type' => $type,
126 + 'series' => $series,
106 127 'settings' => $settings,
107 - 'data' => unserialize( $chart->post_content ),
128 + 'data' => $data,
108 129 );
109 130
110 131 // enqueue visualizer render and update render localizations
111 132 wp_enqueue_script( 'visualizer-render' );