Skip to content

Commit

Permalink
Merge pull request #916 from Codeinwp/enhancement/915
Browse files Browse the repository at this point in the history
Chart unique title
  • Loading branch information
vytisbulkevicius authored Aug 29, 2022
2 parents e6945aa + ac521a4 commit 1aa78e3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 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;
}
}
5 changes: 3 additions & 2 deletions classes/Visualizer/Module/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -1245,15 +1245,16 @@ public function cloneChart() {
'vaction' => false,
),
admin_url( 'admin.php' )
)
),
null,
'db'
);
}
}

if ( defined( 'WP_TESTS_DOMAIN' ) ) {
wp_die();
}

wp_redirect( $redirect );
exit;
}
Expand Down
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 1aa78e3

Please sign in to comment.