File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public function __construct( Visualizer_Plugin $plugin ) {
6767 $ this ->_addFilter ( Visualizer_Plugin::FILTER_UNDO_REVISIONS , 'undoRevisions ' , 10 , 2 );
6868 $ this ->_addFilter ( Visualizer_Plugin::FILTER_HANDLE_REVISIONS , 'handleExistingRevisions ' , 10 , 2 );
6969 $ 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 ' );
7171 register_shutdown_function ( array ($ this , 'onShutdown ' ) );
7272
7373 }
@@ -793,6 +793,21 @@ public function _getImage( $chart = null ) {
793793 );
794794 }
795795
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+ }
809+ }
810+
796811 /**
797812 * Filter chart title.
798813 *
You can’t perform that action at this time.
0 commit comments