-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made each taxonomy appear on its own panel.
Before all taxonomies appeared under "Categories & Tags" panel.
- Loading branch information
1 parent
efc5945
commit 3e86770
Showing
9 changed files
with
177 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
edit-post/components/sidebar/post-taxonomies/taxonomy-panel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* External Dependencies | ||
*/ | ||
import { get } from 'lodash'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { compose } from '@wordpress/element'; | ||
import { PanelBody } from '@wordpress/components'; | ||
import { withSelect, withDispatch } from '@wordpress/data'; | ||
|
||
function TaxonomyPanel( { taxonomy, isOpened, onTogglePanel, children } ) { | ||
const taxonomyMenuName = get( taxonomy, [ 'labels', 'menu_name' ] ); | ||
if ( ! taxonomyMenuName ) { | ||
return null; | ||
} | ||
return ( | ||
<PanelBody | ||
title={ taxonomyMenuName } | ||
opened={ isOpened } | ||
onToggle={ onTogglePanel } | ||
> | ||
{ children } | ||
</PanelBody> | ||
); | ||
} | ||
|
||
export default compose( | ||
withSelect( ( select, ownProps ) => { | ||
const slug = get( ownProps.taxonomy, [ 'slug' ] ); | ||
const panelName = slug ? `taxonomy-panel-${ slug }` : ''; | ||
return { | ||
panelName, | ||
isOpened: slug ? | ||
select( 'core/edit-post' ).isEditorSidebarPanelOpened( panelName ) : | ||
false, | ||
}; | ||
} ), | ||
withDispatch( ( dispatch, ownProps ) => ( { | ||
onTogglePanel: () => { | ||
dispatch( 'core/edit-post' ). | ||
toggleGeneralSidebarEditorPanel( ownProps.panelName ); | ||
}, | ||
} ) ), | ||
)( TaxonomyPanel ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.