| @@ -53,8 +53,9 @@ | ||
| 53 | 53 | public function __construct( Visualizer_Plugin $plugin ) { |
| 54 | 54 | parent::__construct( $plugin ); |
| 55 | 55 | |
| 56 | 56 | $this->_addAction( 'wp_enqueue_scripts', 'enqueueScripts' ); |
| 57 | + $this->_addAction( 'visualizer_enqueue_scripts', 'enqueueScripts' ); | |
| 57 | 58 | $this->_addFilter( 'visualizer_get_language', 'getLanguage' ); |
| 58 | 59 | $this->_addShortcode( 'visualizer', 'renderChart' ); |
| 59 | 60 | |
| 60 | 61 | // add do_shortocde hook for widget_text filter |
| @@ -98,9 +99,10 @@ | ||
| 98 | 99 | * @access private |
| 99 | 100 | */ |
| 100 | 101 | private function get_actions() { |
| 101 | 102 | return apply_filters( |
| 102 | - 'visualizer_action_buttons', array( | |
| 103 | + 'visualizer_action_buttons', | |
| 104 | + array( | |
| 103 | 105 | 'print' => __( 'Print', 'visualizer' ), |
| 104 | 106 | 'csv' => __( 'CSV', 'visualizer' ), |
| 105 | 107 | 'xls' => __( 'Excel', 'visualizer' ), |
| 106 | 108 | 'copy' => __( 'Copy', 'visualizer' ), |
| @@ -154,11 +156,9 @@ | ||
| 154 | 156 | * |
| 155 | 157 | * @access public |
| 156 | 158 | */ |
| 157 | 159 | public function enqueueScripts() { |
| 158 | - wp_register_script( 'visualizer-google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true ); | |
| 159 | - wp_register_script( 'visualizer-google-jsapi-old', '//www.google.com/jsapi', array( 'visualizer-google-jsapi-new' ), null, true ); | |
| 160 | - wp_register_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'visualizer-google-jsapi-old', 'jquery' ), Visualizer_Plugin::VERSION, true ); | |
| 160 | + wp_register_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true ); | |
| 161 | 161 | wp_register_script( 'visualizer-clipboardjs', VISUALIZER_ABSURL . 'js/lib/clipboardjs/clipboard.min.js', array( 'jquery' ), Visualizer_Plugin::VERSION, true ); |
| 162 | 162 | wp_register_style( 'visualizer-front', VISUALIZER_ABSURL . 'css/front.css', array(), Visualizer_Plugin::VERSION ); |
| 163 | 163 | do_action( 'visualizer_pro_frontend_load_resources' ); |
| 164 | 164 | } |
| @@ -184,9 +184,10 @@ | ||
| 184 | 184 | 'class' => false, // chart class |
| 185 | 185 | 'series' => false, // series filter hook |
| 186 | 186 | 'data' => false, // data filter hook |
| 187 | 187 | 'settings' => false, // data filter hook |
| 188 | - ), $atts | |
| 188 | + ), | |
| 189 | + $atts | |
| 189 | 190 | ); |
| 190 | 191 | |
| 191 | 192 | // if empty id or chart does not exists, then return empty string |
| 192 | 193 | if ( ! $atts['id'] || ! ( $chart = get_post( $atts['id'] ) ) || $chart->post_type != Visualizer_Plugin::CPT_VISUALIZER ) { |
| @@ -209,9 +210,11 @@ | ||
| 209 | 210 | $class = ! empty( $class ) ? ' class="' . trim( $class ) . '"' : ''; |
| 210 | 211 | |
| 211 | 212 | $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true ); |
| 212 | 213 | |
| 213 | - // faetch and update settings | |
| 214 | + $chart = apply_filters( 'visualizer_schedule_refresh_chart', $chart, $chart->ID, false ); | |
| 215 | + | |
| 216 | + // fetch and update settings | |
| 214 | 217 | $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true ); |
| 215 | 218 | if ( empty( $settings['height'] ) ) { |
| 216 | 219 | $settings['height'] = '400'; |
| 217 | 220 | } |
| @@ -227,22 +230,22 @@ | ||
| 227 | 230 | $settings = apply_filters( $atts['settings'], $settings, $chart->ID, $type ); |
| 228 | 231 | } |
| 229 | 232 | |
| 230 | 233 | // handle data filter hooks |
| 231 | - $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( $chart->post_content ), $chart->ID, $type ); | |
| 234 | + $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( html_entity_decode( $chart->post_content ) ), $chart->ID, $type ); | |
| 232 | 235 | if ( ! empty( $atts['data'] ) ) { |
| 233 | 236 | $data = apply_filters( $atts['data'], $data, $chart->ID, $type ); |
| 234 | 237 | } |
| 235 | 238 | |
| 236 | - $id = $id . '-' . rand(); | |
| 237 | - $arguments = array( '', $id, $settings ); | |
| 238 | 239 | $css = ''; |
| 239 | - apply_filters_ref_array( 'visualizer_pro_inline_css', array( &$arguments ) ); | |
| 240 | + $arguments = $this->get_inline_custom_css( $id, $settings ); | |
| 240 | 241 | if ( ! empty( $arguments ) ) { |
| 241 | 242 | $css = $arguments[0]; |
| 242 | - $settings = $arguments[2]; | |
| 243 | + $settings = $arguments[1]; | |
| 243 | 244 | } |
| 244 | 245 | |
| 246 | + $library = $this->load_chart_type( $chart->ID ); | |
| 247 | + | |
| 245 | 248 | // add chart to the array |
| 246 | 249 | $this->_charts[ $id ] = array( |
| 247 | 250 | 'type' => $type, |
| 248 | 251 | 'series' => $series, |
| @@ -247,21 +250,32 @@ | ||
| 247 | 250 | 'type' => $type, |
| 248 | 251 | 'series' => $series, |
| 249 | 252 | 'settings' => $settings, |
| 250 | 253 | 'data' => $data, |
| 254 | + 'library' => $library, | |
| 251 | 255 | ); |
| 252 | 256 | |
| 253 | - // enqueue visualizer render and update render localizations | |
| 254 | - wp_enqueue_script( 'visualizer-render' ); | |
| 257 | + wp_register_script( | |
| 258 | + "visualizer-render-$library", | |
| 259 | + VISUALIZER_ABSURL . 'js/render-facade.js', | |
| 260 | + apply_filters( 'visualizer_assets_render', array( 'jquery', 'visualizer-customization' ), true ), | |
| 261 | + Visualizer_Plugin::VERSION, | |
| 262 | + true | |
| 263 | + ); | |
| 264 | + | |
| 265 | + wp_enqueue_script( "visualizer-render-$library" ); | |
| 255 | 266 | wp_localize_script( |
| 256 | - 'visualizer-render', 'visualizer', array( | |
| 267 | + "visualizer-render-$library", | |
| 268 | + 'visualizer', | |
| 269 | + array( | |
| 257 | 270 | 'charts' => $this->_charts, |
| 258 | - 'language' => $this->get_language(), | |
| 271 | + 'language' => $this->get_language(), | |
| 259 | 272 | 'map_api_key' => get_option( 'visualizer-map-api-key' ), |
| 260 | 273 | 'rest_url' => version_compare( $wp_version, '4.7.0', '>=' ) ? rest_url( 'visualizer/v' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/' ) : '', |
| 261 | 274 | 'i10n' => array( |
| 262 | 275 | 'copied' => __( 'Copied!', 'visualizer' ), |
| 263 | 276 | ), |
| 277 | + 'page_type' => 'frontend', | |
| 264 | 278 | ) |
| 265 | 279 | ); |
| 266 | 280 | wp_enqueue_style( 'visualizer-front' ); |
| 267 | 281 | |