[WIP] Add control to manipulate the post parent #189
Conversation
@@ -224,6 +224,9 @@ | |||
if ( 'undefined' === typeof EditPostPreviewCustomize ) { | |||
section.addPostStatusControl(); | |||
} | |||
if ( postTypeObj.supports['page-attributes'] ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As seen above with postTypeObj.supports.slug
, I suggest we introduce a discrete feature for parent, so this could be:
if ( postTypeObj.supports['page-attributes'] || postTypeObj.supports.parent ) {
@sunnyratilal this is looking good. I left some feedback. Something you may want to consider, perhaps in a separate PR, also is adding support for the Object Selector Control, wherein if it is present, the dropdown could be replaced with a select2 field for loading pages on demand. |
The Customize Object Selector has some new changes that allow it to be used for manipulating the |
@westonruter will make the amendments soon. Sorry been stuck with university exams in the past few weeks hence I didn't get the chance |
@sunnyratilal no worries! I can pick it up from you if you like. |
@sunnyratilal here's some code for var section = this, control, setting = api( section.id ), controlId, params;
controlId = section.id + '[post_parent]';
params = {
section: section.id,
priority: 20,
label: api.Posts.data.l10n.postParentLabel,
active: true,
settings: {
'default': setting.id
},
field_type: 'select',
setting_property: 'post_parent',
choices: api.Posts.data.postParentChoices
};
if ( api.controlConstructor.object_selector ) {
control = new api.controlConstructor.object_selector( controlId, {
params: _.extend( params, {
post_query_vars: {
post_type: section.params.post_type,
post_status: 'publish',
post__not_in: [ section.params.post_id ]
},
select2_options: {
multiple: false
}
} )
} );
} else {
control = new api.controlConstructor.dynamic( controlId, {
params: _.extend( params, {
field_type: 'select',
choices: api.Posts.data.postParentChoices
} )
} );
} |
(Updated JS snippet to include |
@westonruter I'm going to be really tied up for the next few weeks with other projects so if you'd like to take over, feel free. Sorry for the delay in getting this out. |
No worries. Thanks for the help! |
Picking this up in #233. |
Pull request for #65