Skip to content

Commit 1aa78e3

Browse files
Merge pull request #916 from Codeinwp/enhancement/915
Chart unique title
2 parents e6945aa + ac521a4 commit 1aa78e3

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
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/Module/Chart.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,15 +1245,16 @@ public function cloneChart() {
12451245
'vaction' => false,
12461246
),
12471247
admin_url( 'admin.php' )
1248-
)
1248+
),
1249+
null,
1250+
'db'
12491251
);
12501252
}
12511253
}
12521254

12531255
if ( defined( 'WP_TESTS_DOMAIN' ) ) {
12541256
wp_die();
12551257
}
1256-
12571258
wp_redirect( $redirect );
12581259
exit;
12591260
}

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)