| @@ -66,9 +66,9 @@ | ||
| 66 | 66 | |
| 67 | 67 | $this->_addFilter( Visualizer_Plugin::FILTER_UNDO_REVISIONS, 'undoRevisions', 10, 2 ); |
| 68 | 68 | $this->_addFilter( Visualizer_Plugin::FILTER_HANDLE_REVISIONS, 'handleExistingRevisions', 10, 2 ); |
| 69 | 69 | $this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_DATA_AS, 'getDataAs', 10, 3 ); |
| 70 | - $this->_addFilter( Visualizer_Plugin::FILTER_CHART_TITLE, 'filterChartTitle', 10, 2 ); | |
| 70 | + $this->_addAction( 'pre_get_posts', 'PreGetPosts' ); | |
| 71 | 71 | register_shutdown_function( array($this, 'onShutdown') ); |
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | |
| @@ -790,8 +790,23 @@ | ||
| 790 | 790 | } |
| 791 | 791 | return array( |
| 792 | 792 | 'csv' => $image, |
| 793 | 793 | ); |
| 794 | + } | |
| 795 | + | |
| 796 | + /** | |
| 797 | + * Filter chart title if visualizer post type. | |
| 798 | + * | |
| 799 | + * @param object $query WP Query object. | |
| 800 | + * @return void | |
| 801 | + */ | |
| 802 | + public function PreGetPosts( $query ) { | |
| 803 | + if ( ! $query->is_main_query() ) { | |
| 804 | + $post_type = $query->get( 'post_type' ); | |
| 805 | + if ( 'visualizer' === $post_type ) { | |
| 806 | + $this->_addFilter( Visualizer_Plugin::FILTER_CHART_TITLE, 'filterChartTitle', 10, 2 ); | |
| 807 | + } | |
| 808 | + } | |
| 794 | 809 | } |
| 795 | 810 | |
| 796 | 811 | /** |
| 797 | 812 | * Filter chart title. |