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