Skip to content

Commit

Permalink
feat: allow external links in dashboard via a filter (#2279)
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek authored Mar 1, 2023
1 parent 267306e commit 3943b1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion assets/wizards/dashboard/views/dashboardCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DashboardCard extends Component {
* Render.
*/
render() {
const { name, description, slug, url } = this.props;
const { name, description, slug, url, is_external } = this.props;
const iconMap = {
'site-design': typography,
'reader-revenue': payment,
Expand All @@ -47,6 +47,7 @@ class DashboardCard extends Component {
return (
<ButtonCard
href={ url }
{ ...( is_external && { target: '_blank' } ) }
title={ name }
desc={ description }
icon={ iconMap[ slug ] || plugins }
Expand Down
15 changes: 14 additions & 1 deletion includes/wizards/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,20 @@ protected function get_dashboard() {
],
];

return $dashboard;
/**
* Filters the dashboard items.
*
* @param array $dashboard {
* Dashboard items.
*
* @type string $slug Slug.
* @type string $name Displayed name.
* @type string $url URL to redirect to.
* @type string $description Item description.
* @type bool $is_externam If true, the URL will be opened in a new window. Optional.
* }
*/
return apply_filters( 'newspack_plugin_dashboard_items', $dashboard );
}

/**
Expand Down

0 comments on commit 3943b1a

Please sign in to comment.