Skip to content

Commit 3f35dac

Browse files
Create unique chart title #915
1 parent 5425d59 commit 3f35dac

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

classes/Visualizer/Module.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +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 );
7071
register_shutdown_function( array($this, 'onShutdown') );
7172

7273
}
@@ -791,4 +792,21 @@ public function _getImage( $chart = null ) {
791792
'csv' => $image,
792793
);
793794
}
795+
796+
/**
797+
* Filter chart title.
798+
*
799+
* @access public
800+
* @param string $post_title Post title.
801+
* @param int $post_id Post ID.
802+
* @return string
803+
*/
804+
public function filterChartTitle( $post_title, $post_id ) {
805+
$post_type = get_post_type( $post_id );
806+
$post_title = trim( $post_title );
807+
if ( 'visualizer' === $post_type && 'Visualization' === $post_title ) {
808+
return sprintf( '%s #%d', $post_title, $post_id );
809+
}
810+
return $post_title;
811+
}
794812
}

classes/Visualizer/Plugin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class Visualizer_Plugin {
9090
const FILTER_HANDLE_REVISIONS = 'visualizer-handle-revisions';
9191
const FILTER_GET_CHART_DATA_AS = 'visualizer-get-chart-data-as';
9292
const FILTER_HANDLE_CACHE_EXPIRATION_TIME = 'visualizer-handle-expiration-time';
93+
const FILTER_CHART_TITLE = 'the_title';
9394

9495
const CF_DB_SCHEDULE = 'visualizer-db-schedule';
9596
const CF_DB_QUERY = 'visualizer-db-query';

0 commit comments

Comments
 (0)