| @@ -76,9 +76,9 @@ | ||
| 76 | 76 | register_rest_route( |
| 77 | 77 | 'visualizer/v' . VISUALIZER_REST_VERSION, |
| 78 | 78 | '/action/(?P<chart>\d+)/(?P<type>.+)/', |
| 79 | 79 | array( |
| 80 | - 'methods' => 'GET', | |
| 80 | + 'methods' => array( 'GET', 'POST' ), | |
| 81 | 81 | 'callback' => array( $this, 'perform_action' ), |
| 82 | 82 | ) |
| 83 | 83 | ); |
| 84 | 84 | } |
| @@ -129,9 +129,9 @@ | ||
| 129 | 129 | case 'xls': |
| 130 | 130 | $data = $this->_getDataAs( $chart_id, 'xls' ); |
| 131 | 131 | break; |
| 132 | 132 | default: |
| 133 | - $data = apply_filters( 'visualizer_action_data', $data, $chart_id, $type ); | |
| 133 | + $data = apply_filters( 'visualizer_action_data', $data, $chart_id, $type, $params, $this ); | |
| 134 | 134 | break; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | return new WP_REST_Response( array( 'data' => $data ) ); |
| @@ -150,8 +150,10 @@ | ||
| 150 | 150 | wp_register_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true ); |
| 151 | 151 | wp_register_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'visualizer-google-jsapi-old', 'jquery' ), Visualizer_Plugin::VERSION, true ); |
| 152 | 152 | wp_register_script( 'visualizer-clipboardjs', VISUALIZER_ABSURL . 'js/lib/clipboardjs/clipboard.min.js', array( 'jquery' ), Visualizer_Plugin::VERSION, true ); |
| 153 | 153 | wp_enqueue_script( 'visualizer-clipboardjs' ); |
| 154 | + wp_register_style( 'visualizer-front', VISUALIZER_ABSURL . 'css/front.css', array(), Visualizer_Plugin::VERSION ); | |
| 155 | + do_action( 'visualizer_pro_frontend_load_resources' ); | |
| 154 | 156 | } |
| 155 | 157 | |
| 156 | 158 | /** |
| 157 | 159 | * Returns placeholder for chart according to visualizer shortcode attributes. |
| @@ -181,8 +183,12 @@ | ||
| 181 | 183 | if ( ! $atts['id'] || ! ( $chart = get_post( $atts['id'] ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) { |
| 182 | 184 | return ''; |
| 183 | 185 | } |
| 184 | 186 | |
| 187 | + if ( ! apply_filters( 'visualizer_pro_show_chart', true, $atts['id'] ) ) { | |
| 188 | + return ''; | |
| 189 | + } | |
| 190 | + | |
| 185 | 191 | $id = 'visualizer-' . $atts['id']; |
| 186 | 192 | $defaultClass = 'visualizer-front'; |
| 187 | 193 | $class = apply_filters( Visualizer_Plugin::FILTER_CHART_WRAPPER_CLASS, $atts['class'], $atts['id'] ); |
| 188 | 194 | $class = $defaultClass . ' ' . $class . ' ' . 'visualizer-front-' . $atts['id']; |
| @@ -212,9 +218,13 @@ | ||
| 212 | 218 | if ( ! empty( $atts['data'] ) ) { |
| 213 | 219 | $data = apply_filters( $atts['data'], $data, $chart->ID, $type ); |
| 214 | 220 | } |
| 215 | 221 | |
| 216 | - $id = $id . '-' . rand(); | |
| 222 | + $id = $id . '-' . rand(); | |
| 223 | + $arguments = array( '', $id, $settings ); | |
| 224 | + apply_filters_ref_array( 'visualizer_pro_inline_css', array( &$arguments ) ); | |
| 225 | + $css = $arguments[0]; | |
| 226 | + $settings = $arguments[2]; | |
| 217 | 227 | |
| 218 | 228 | // add chart to the array |
| 219 | 229 | $this->_charts[ $id ] = array( |
| 220 | 230 | 'type' => $type, |
| @@ -234,14 +244,16 @@ | ||
| 234 | 244 | 'copied' => __( 'Copied!', 'visualizer' ), |
| 235 | 245 | ), |
| 236 | 246 | ) |
| 237 | 247 | ); |
| 248 | + wp_enqueue_style( 'visualizer-front' ); | |
| 238 | 249 | |
| 239 | 250 | $actions_div = ''; |
| 240 | - if ( ! empty( $settings['actions'] ) ) { | |
| 251 | + $actions_visible = apply_filters( 'visualizer_pro_add_actions', isset( $settings['actions'] ) ? $settings['actions'] : array(), $atts['id'] ); | |
| 252 | + if ( ! empty( $actions_visible ) ) { | |
| 241 | 253 | $actions = $this->get_actions(); |
| 242 | 254 | $actions_div = '<div class="visualizer-actions">'; |
| 243 | - foreach ( $settings['actions'] as $action_type ) { | |
| 255 | + foreach ( $actions_visible as $action_type ) { | |
| 244 | 256 | $key = $action_type; |
| 245 | 257 | $mime = ''; |
| 246 | 258 | if ( strpos( $action_type, ';' ) !== false ) { |
| 247 | 259 | $array = explode( ';', $action_type ); |
| @@ -261,9 +273,11 @@ | ||
| 261 | 273 | } |
| 262 | 274 | |
| 263 | 275 | $actions_div .= '</div>'; |
| 264 | 276 | } |
| 277 | + | |
| 278 | + $actions_div .= $css; | |
| 279 | + | |
| 265 | 280 | // return placeholder div |
| 266 | 281 | return $actions_div . '<div id="' . $id . '"' . $class . '></div>'; |
| 267 | 282 | } |
| 268 | - | |
| 269 | 283 | } |