Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
WIP Addition of trash link
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Jun 10, 2016
1 parent 6da404f commit 2c4ff64
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion js/customize-post-section.js
Expand Up @@ -300,7 +300,7 @@
* @returns {wp.customize.Control} Added control.
*/
addPostStatusControl: function() {
var section = this, control, setting = api( section.id ), sectionContainer, sectionTitle;
var section = this, control, setting = api( section.id ), sectionContainer, sectionTitle, trashLink;

sectionContainer = section.container.closest( '.accordion-section' );
sectionTitle = sectionContainer.find( '.accordion-section-title:first' );
Expand All @@ -320,6 +320,20 @@
}
} );

control.deferred.embedded.done( function() {
trashLink = $( '<a href="" class="trash"></a>' );
trashLink.text( api.Posts.data.l10n.movePostToTrashLabel );
control.container.find( 'select' ).after( trashLink );
trashLink.click( function( e ) {
e.preventDefault();
control.setting.set( _.extend(
{},
control.setting.get(),
{ post_status: 'trash' }
) );
} );
} );

/**
* Update the UI when a post is transitioned from/to trash.
*
Expand Down
2 changes: 2 additions & 0 deletions php/class-wp-customize-posts.php
Expand Up @@ -588,6 +588,8 @@ public function enqueue_scripts() {
'fieldTitleLabel' => __( 'Title', 'customize-posts' ),
'fieldSlugLabel' => __( 'Slug', 'customize-posts' ),
'fieldPostStatusLabel' => __( 'Post Status', 'customize-posts' ),
'movePostToTrashLabel' => __( 'Move to Trash', 'customize-posts' ),
'deletePostLabel' => __( 'Delete', 'customize-posts' ),
'fieldContentLabel' => __( 'Content', 'customize-posts' ),
'fieldExcerptLabel' => __( 'Excerpt', 'customize-posts' ),
'fieldDiscussionLabel' => __( 'Discussion', 'customize-posts' ),
Expand Down

0 comments on commit 2c4ff64

Please sign in to comment.