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

Restrict page template control to just the page post type #227

Merged
merged 1 commit into from
Aug 23, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions js/customize-page-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ var CustomizePageTemplate = (function( api ) {
component.addControl = function( section ) {
var supports, control, controlId, settingId, isActiveCallback;
supports = api.Posts.data.postTypes[ section.params.post_type ].supports;
if ( ! supports['page-attributes'] ) {

if ( ! supports['page-attributes'] || 'page' !== section.params.post_type ) {
return null;
}

Expand Down Expand Up @@ -94,6 +95,9 @@ var CustomizePageTemplate = (function( api ) {
/**
* Make sure that control only appears if there are page templates (other than 'default').
*
* @todo The control needs to be deactivated when the page is the same as wp.customize( 'page_on_front' ).get().
* @todo Page-specific templates also need to be accounted for here (the 'theme_page_templates' filter in PHP).
*
* @returns {boolean} Is active.
*/
isActiveCallback = function() {
Expand All @@ -106,7 +110,7 @@ var CustomizePageTemplate = (function( api ) {
// Register.
api.control.add( control.id, control );

// @todo Fetch the page templates related to control.params.post_id to override the default choices
// @todo Fetch the page templates related to control.params.post_id to override the default choices (the 'theme_page_templates' filter in PHP).

return control;
};
Expand Down