| @@ -357,9 +357,9 @@ | ||
| 357 | 357 | $chart = $this->_chart; |
| 358 | 358 | } |
| 359 | 359 | $type = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_TYPE, true ); |
| 360 | 360 | $series = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SERIES, get_post_meta( $chart->ID, Visualizer_Plugin::CF_SERIES, true ), $chart->ID, $type ); |
| 361 | - $data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( $chart->post_content ), $chart->ID, $type ); | |
| 361 | + $data = self::get_chart_data( $chart, $type ); | |
| 362 | 362 | $library = $this->load_chart_type( $chart->ID ); |
| 363 | 363 | |
| 364 | 364 | $settings = get_post_meta( $chart->ID, Visualizer_Plugin::CF_SETTINGS, true ); |
| 365 | 365 | $settings = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_SETTINGS, $settings, $chart->ID, $type ); |
| @@ -533,9 +533,9 @@ | ||
| 533 | 533 | wp_register_script( 'visualizer-chosen', VISUALIZER_ABSURL . 'js/lib/chosen.jquery.min.js', array( 'jquery' ), Visualizer_Plugin::VERSION ); |
| 534 | 534 | wp_register_style( 'visualizer-chosen', VISUALIZER_ABSURL . 'css/lib/chosen.min.css', array(), Visualizer_Plugin::VERSION ); |
| 535 | 535 | |
| 536 | 536 | wp_register_style( 'visualizer-frame', VISUALIZER_ABSURL . 'css/frame.css', array( 'visualizer-chosen' ), Visualizer_Plugin::VERSION ); |
| 537 | - wp_register_script( 'visualizer-frame', VISUALIZER_ABSURL . 'js/frame.js', array( 'visualizer-chosen', 'jquery-ui-accordion' ), Visualizer_Plugin::VERSION, true ); | |
| 537 | + wp_register_script( 'visualizer-frame', VISUALIZER_ABSURL . 'js/frame.js', array( 'visualizer-chosen', 'jquery-ui-accordion', 'jquery-ui-tabs' ), Visualizer_Plugin::VERSION, true ); | |
| 538 | 538 | wp_register_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true ); |
| 539 | 539 | wp_register_script( |
| 540 | 540 | 'visualizer-render', |
| 541 | 541 | VISUALIZER_ABSURL . 'js/render-facade.js', |
| @@ -574,8 +574,9 @@ | ||
| 574 | 574 | if ( isset( $_POST['cancel'] ) && 1 === intval( $_POST['cancel'] ) ) { |
| 575 | 575 | // if the cancel button is clicked. |
| 576 | 576 | $this->undoRevisions( $chart_id, true ); |
| 577 | 577 | } elseif ( isset( $_POST['save'] ) && 1 === intval( $_POST['save'] ) ) { |
| 578 | + $this->handlePermissions(); | |
| 578 | 579 | // if the save button is clicked. |
| 579 | 580 | $this->undoRevisions( $chart_id, false ); |
| 580 | 581 | } else { |
| 581 | 582 | // if the edit button is clicked. |
| @@ -590,9 +591,9 @@ | ||
| 590 | 591 | case 'visualizer': // fall through. |
| 591 | 592 | $this->_handleTypesPage(); |
| 592 | 593 | break; |
| 593 | 594 | default: |
| 594 | - do_action( 'visualizer_pro_handle_tab', $tab, $this->_chart ); | |
| 595 | + // this should never happen. | |
| 595 | 596 | break; |
| 596 | 597 | } |
| 597 | 598 | defined( 'WP_TESTS_DOMAIN' ) ? wp_die() : exit(); |
| 598 | 599 | } |
| @@ -652,8 +653,25 @@ | ||
| 652 | 653 | return $table_col_mapping; |
| 653 | 654 | } |
| 654 | 655 | |
| 655 | 656 | /** |
| 657 | + * Handle permissions from the new conslidated settings sidebar. | |
| 658 | + */ | |
| 659 | + private function handlePermissions() { | |
| 660 | + if ( ! Visualizer_Module::is_pro() ) { | |
| 661 | + return; | |
| 662 | + } | |
| 663 | + | |
| 664 | + // we will not support old free and new pro. | |
| 665 | + // handling new free and old pro. | |
| 666 | + if ( has_action( 'visualizer_pro_handle_tab' ) ) { | |
| 667 | + do_action( 'visualizer_pro_handle_tab', 'permissions', $this->_chart ); | |
| 668 | + } else { | |
| 669 | + do_action( 'visualizer_handle_permissions', $this->_chart ); | |
| 670 | + } | |
| 671 | + } | |
| 672 | + | |
| 673 | + /** | |
| 656 | 674 | * Handle data and settings page |
| 657 | 675 | */ |
| 658 | 676 | private function _handleDataAndSettingsPage() { |
| 659 | 677 | if ( isset( $_POST['map_api_key'] ) ) { |
| @@ -658,8 +676,9 @@ | ||
| 658 | 676 | private function _handleDataAndSettingsPage() { |
| 659 | 677 | if ( isset( $_POST['map_api_key'] ) ) { |
| 660 | 678 | update_option( 'visualizer-map-api-key', $_POST['map_api_key'] ); |
| 661 | 679 | } |
| 680 | + | |
| 662 | 681 | if ( $_SERVER['REQUEST_METHOD'] === 'POST' && isset( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'] ) ) { |
| 663 | 682 | if ( $this->_chart->post_status === 'auto-draft' ) { |
| 664 | 683 | $this->_chart->post_status = 'publish'; |
| 665 | 684 | |
| @@ -690,9 +709,8 @@ | ||
| 690 | 709 | } |
| 691 | 710 | $render = new Visualizer_Render_Page_Send(); |
| 692 | 711 | $render->text = sprintf( '[visualizer id="%d"]', $this->_chart->ID ); |
| 693 | 712 | wp_iframe( array( $render, 'render' ) ); |
| 694 | - | |
| 695 | 713 | return; |
| 696 | 714 | } |
| 697 | 715 | $data = $this->_getChartArray(); |
| 698 | 716 | $sidebar = ''; |
| @@ -742,8 +760,9 @@ | ||
| 742 | 760 | 'invalid_source' => esc_html__( 'You have entered an invalid URL. Please provide a valid URL.', 'visualizer' ), |
| 743 | 761 | 'loading' => esc_html__( 'Loading...', 'visualizer' ), |
| 744 | 762 | 'json_error' => esc_html__( 'An error occured in fetching data.', 'visualizer' ), |
| 745 | 763 | 'select_columns' => esc_html__( 'Please select a few columns to include in the chart.', 'visualizer' ), |
| 764 | + 'save_settings' => __( 'You have modified the chart\'s settings. To modify the source/data again, you must save this chart and reopen it for editing. If you continue without saving the chart, you may lose your changes.', 'visualizer' ), | |
| 746 | 765 | ), |
| 747 | 766 | 'charts' => array( |
| 748 | 767 | 'canvas' => $data, |
| 749 | 768 | 'id' => $this->_chart->ID, |
| @@ -886,12 +905,13 @@ | ||
| 886 | 905 | continue; |
| 887 | 906 | } |
| 888 | 907 | // don't use fpucsv here because we need to just dump the data |
| 889 | 908 | // minus the empty rows |
| 890 | - // and if any row contains ' or ", fputcsv will mess it up | |
| 891 | 909 | // because fputcsv needs to tokenize |
| 892 | - // and let's standardize the CSV enclosure | |
| 893 | - $row = str_replace( "'", VISUALIZER_CSV_ENCLOSURE, $row ); | |
| 910 | + // we can standardize the CSV enclosure here and replace all ' with " | |
| 911 | + // we can assume that if there are an even number of ' they should be changed to " | |
| 912 | + // but that will screw up words like fo'c'sle | |
| 913 | + // so here let's just assume ' will NOT be used for enclosures | |
| 894 | 914 | fwrite( $handle, $row ); |
| 895 | 915 | fwrite( $handle, PHP_EOL ); |
| 896 | 916 | } |
| 897 | 917 | } |