Skip to content

Commit

Permalink
Create unique chart title #915
Browse files Browse the repository at this point in the history
  • Loading branch information
girishpanchal30 committed Aug 1, 2022
1 parent 5425d59 commit 3f35dac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions classes/Visualizer/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function __construct( Visualizer_Plugin $plugin ) {
$this->_addFilter( Visualizer_Plugin::FILTER_UNDO_REVISIONS, 'undoRevisions', 10, 2 );
$this->_addFilter( Visualizer_Plugin::FILTER_HANDLE_REVISIONS, 'handleExistingRevisions', 10, 2 );
$this->_addFilter( Visualizer_Plugin::FILTER_GET_CHART_DATA_AS, 'getDataAs', 10, 3 );
$this->_addFilter( Visualizer_Plugin::FILTER_CHART_TITLE, 'filterChartTitle', 10, 2 );
register_shutdown_function( array($this, 'onShutdown') );

}
Expand Down Expand Up @@ -791,4 +792,21 @@ public function _getImage( $chart = null ) {
'csv' => $image,
);
}

/**
* Filter chart title.
*
* @access public
* @param string $post_title Post title.
* @param int $post_id Post ID.
* @return string
*/
public function filterChartTitle( $post_title, $post_id ) {
$post_type = get_post_type( $post_id );
$post_title = trim( $post_title );
if ( 'visualizer' === $post_type && 'Visualization' === $post_title ) {
return sprintf( '%s #%d', $post_title, $post_id );
}
return $post_title;
}
}
1 change: 1 addition & 0 deletions classes/Visualizer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Visualizer_Plugin {
const FILTER_HANDLE_REVISIONS = 'visualizer-handle-revisions';
const FILTER_GET_CHART_DATA_AS = 'visualizer-get-chart-data-as';
const FILTER_HANDLE_CACHE_EXPIRATION_TIME = 'visualizer-handle-expiration-time';
const FILTER_CHART_TITLE = 'the_title';

const CF_DB_SCHEDULE = 'visualizer-db-schedule';
const CF_DB_QUERY = 'visualizer-db-query';
Expand Down

0 comments on commit 3f35dac

Please sign in to comment.