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

Commit 112d942

Browse files
authored
Merge pull request #374 from xwp/develop
Upgrade 0.9.0
2 parents 936b25e + d917c74 commit 112d942

30 files changed

+291
-195
lines changed

.dev-lib

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
WPCS_GIT_TREE=develop
22
ASSETS_DIR=wp-assets
3+
4+
if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]] || [[ ${TRAVIS_PHP_VERSION:0:3} == "5.3" ]]; then
5+
DEV_LIB_SKIP="$DEV_LIB_SKIP,phpcs"
6+
fi

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ language:
1717
- node_js
1818

1919
php:
20-
- 5.3
20+
- 5.2
2121
- 7.0
2222

2323
env:
2424
- WP_VERSION=trunk WP_MULTISITE=0
2525
- WP_VERSION=latest WP_MULTISITE=0
26-
- WP_VERSION=4.6.1 WP_MULTISITE=0
26+
- WP_VERSION=4.7.6 WP_MULTISITE=0
2727
- WP_VERSION=latest WP_MULTISITE=1
2828

2929
install:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "xwp/wp-customize-posts",
33
"description": "Manage posts and postmeta via the Customizer.",
4-
"version": "0.8.7",
4+
"version": "0.9.0",
55
"type": "wordpress-plugin",
66
"keywords": [ "customizer", "customize", "posts", "postmeta", "preview", "featured-image", "page-template" ],
77
"homepage": "https://github.com/xwp/wp-customize-posts/",

css/edit-post-preview-customize.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#customize-header-actions #snapshot-save,
77
#snapshot-status-button-wrapper,
88
#snapshot-preview-link,
9-
#snapshot-expand-button
9+
#snapshot-expand-button,
10+
#publish-settings
1011
{
1112
display: none !important;
1213
}

customize-posts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Customize Posts
44
* Description: Manage posts and postmeta via the Customizer.
55
* Plugin URI: https://github.com/xwp/wp-customize-posts/
6-
* Version: 0.8.7
6+
* Version: 0.9.0
77
* Author: XWP
88
* Author URI: https://make.xwp.co/
99
* License: GPLv2+

dev-lib

js/customize-featured-image.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,6 @@ var CustomizeFeaturedImage = (function( api ) {
123123
} );
124124
};
125125

126-
control.active.set( true );
127-
control.active.validate = function validateForcingTrue() {
128-
return true;
129-
};
130-
131126
// Register.
132127
api.control.add( control.id, control );
133128

js/customize-page-template.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var CustomizePageTemplate = (function( api ) {
5050
* @returns {wp.customize.Control|null} The control.
5151
*/
5252
component.addControl = function( section ) {
53-
var supports, control, controlId, settingId, isActiveCallback;
53+
var supports, control, controlId, settingId;
5454
supports = api.Posts.data.postTypes[ section.params.post_type ].supports;
5555

5656
if ( ! supports['page-attributes'] || 'page' !== section.params.post_type ) {
@@ -103,13 +103,13 @@ var CustomizePageTemplate = (function( api ) {
103103
*
104104
* @returns {boolean} Is active.
105105
*/
106-
isActiveCallback = function() {
106+
function isActiveCallback() {
107107
var defaultSize = 1;
108108
if ( api.has( 'page_for_posts' ) && parseInt( api( 'page_for_posts' ).get(), 10 ) === section.params.post_id ) {
109109
return false;
110110
}
111111
return _.size( control.params.choices ) > defaultSize;
112-
};
112+
}
113113
control.active.set( isActiveCallback() );
114114
control.active.validate = isActiveCallback;
115115
api( 'page_for_posts', function( pageOnFrontSetting ) {

js/customize-post-section.js

Lines changed: 45 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,17 @@
307307
* unless the notification is specifically for this control's setting property.
308308
*
309309
* @this {wp.customize.Control}
310-
* @param {string} code Notification code.
311-
* @param {wp.customize.Notification} notification Notification object.
310+
* @param {string|wp.customize.Notification} notification - Notification object to add. Alternatively code may be supplied, and in that case the second notificationObject argument must be supplied.
311+
* @param {wp.customize.Notification} [notificationObject] - Notification to add when first argument is the code string.
312312
* @returns {wp.customize.Notification|null} Notification if not bypassed.
313313
*/
314-
addPostFieldControlNotification: function addPostFieldControlNotification( code, notification ) {
315-
var isSettingNotification, isSettingPropertyNotification;
314+
addPostFieldControlNotification: function addPostFieldControlNotification( notification, notificationObject ) {
315+
var isSettingNotification, isSettingPropertyNotification, code;
316+
code = 'string' === typeof notification ? notification : notification.code;
316317
isSettingNotification = -1 !== code.indexOf( ':' ) || notification.setting; // Note that sniffing for ':' is deprecated as of #36944 & #37890.
317318
isSettingPropertyNotification = notification.data && notification.data.setting_property === this.setting_property;
318319
if ( isSettingPropertyNotification || ! isSettingNotification ) {
319-
return api.Values.prototype.add.call( this, code, notification );
320+
return ( api.Notifications || api.Values ).prototype.add.call( this, notification, notificationObject );
320321
} else {
321322
return null;
322323
}
@@ -393,11 +394,6 @@
393394
}
394395
} );
395396

396-
// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
397-
control.active.validate = function() {
398-
return true;
399-
};
400-
401397
// Register.
402398
section.postFieldControls.post_title = control;
403399
api.control.add( control.id, control );
@@ -451,11 +447,6 @@
451447
setting.bind( setPlaceholder );
452448
} );
453449

454-
// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
455-
control.active.validate = function() {
456-
return true;
457-
};
458-
459450
// Register.
460451
section.postFieldControls.post_name = control;
461452
api.control.add( control.id, control );
@@ -487,11 +478,6 @@
487478
}
488479
} );
489480

490-
// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
491-
control.active.validate = function() {
492-
return true;
493-
};
494-
495481
// Register.
496482
section.postFieldControls.post_status = control;
497483
api.control.add( control.id, control );
@@ -524,11 +510,6 @@
524510
}
525511
} );
526512

527-
// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
528-
control.active.validate = function() {
529-
return true;
530-
};
531-
532513
// Register.
533514
section.postFieldControls.post_date = control;
534515
api.control.add( control.id, control );
@@ -617,11 +598,6 @@
617598
}
618599
} );
619600

620-
// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
621-
control.active.validate = function() {
622-
return true;
623-
};
624-
625601
// Register.
626602
section.postFieldControls.post_excerpt = control;
627603
api.control.add( control.id, control );
@@ -686,11 +662,6 @@
686662
} );
687663
}
688664

689-
// Override preview trying to de-activate control not present in preview context.
690-
control.active.validate = function() {
691-
return true;
692-
};
693-
694665
// Register.
695666
section.postFieldControls.page_parent = control;
696667
api.control.add( control.id, control );
@@ -724,11 +695,6 @@
724695
}
725696
} );
726697

727-
// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
728-
control.active.validate = function() {
729-
return true;
730-
};
731-
732698
// Register.
733699
section.postFieldControls.menu_order = control;
734700
api.control.add( control.id, control );
@@ -761,11 +727,6 @@
761727
}
762728
} );
763729

764-
// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
765-
control.active.validate = function() {
766-
return true;
767-
};
768-
769730
// Register.
770731
section.postFieldControls.post_discussion_fields = control;
771732
api.control.add( control.id, control );
@@ -809,11 +770,6 @@
809770
return data;
810771
};
811772

812-
// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
813-
control.active.validate = function() {
814-
return true;
815-
};
816-
817773
// Register.
818774
section.postFieldControls.post_author = control;
819775
api.control.add( control.id, control );
@@ -826,37 +782,27 @@
826782
},
827783

828784
/**
829-
* Set up section notifications.
785+
* Polyfill notifications API onto sections if not yet on WordPress 4.9 where it is defined in core.
830786
*
787+
* @link <https://core.trac.wordpress.org/ticket/38794>
831788
* @returns {void}
832789
*/
833-
setupSectionNotifications: function() {
834-
var section = this, setting = api( section.id ), debouncedRenderNotifications, setPageForPostsNotice;
835-
if ( ! setting.notifications ) {
790+
polyfillNotifications: function() {
791+
var section = this, debouncedRenderNotifications;
792+
if ( section.notifications ) {
836793
return;
837794
}
838795

839-
// Add the notifications API.
840796
section.notifications = new api.Values({ defaultConstructor: api.Notification });
841797
section.notificationsContainer = $( '<div class="customize-control-notifications-container"></div>' );
798+
section.notifications.container = section.notificationsContainer;
842799
section.notificationsTemplate = wp.template( 'customize-post-section-notifications' );
843800
section.container.find( '.customize-section-title' ).after( section.notificationsContainer );
844801
section.getNotificationsContainerElement = function() {
845802
return section.notificationsContainer;
846803
};
847804
section.renderNotifications = api.Control.prototype.renderNotifications;
848805

849-
// Sync setting notifications into the section notifications
850-
setting.notifications.bind( 'add', function( settingNotification ) {
851-
var notification = new api.Notification( setting.id + ':' + settingNotification.code, settingNotification );
852-
if ( ! settingNotification.data || ! settingNotification.data.setting_property || ! api.control.has( section.id + '[' + settingNotification.data.setting_property + ']' ) ) {
853-
section.notifications.add( notification.code, notification );
854-
}
855-
} );
856-
setting.notifications.bind( 'remove', function( settingNotification ) {
857-
section.notifications.remove( setting.id + ':' + settingNotification.code );
858-
} );
859-
860806
/*
861807
* Render notifications when the collection is updated.
862808
* Note that this debounced/deferred rendering is needed for two reasons:
@@ -872,9 +818,40 @@
872818
} );
873819
section.notifications.bind( 'remove', debouncedRenderNotifications );
874820
section.renderNotifications();
821+
},
822+
823+
/**
824+
* Set up section notifications.
825+
*
826+
* @returns {void}
827+
*/
828+
setupSectionNotifications: function() {
829+
var section = this, setting = api( section.id ), setPageForPostsNotice, notificationTemplate;
830+
if ( ! setting.notifications ) {
831+
return;
832+
}
833+
834+
// Add the notifications API if not present.
835+
section.polyfillNotifications();
836+
837+
// Sync setting notifications into the section notifications
838+
setting.notifications.bind( 'add', function( settingNotification ) {
839+
var notification = new api.Notification( setting.id + ':' + settingNotification.code, _.extend( {},
840+
settingNotification,
841+
{
842+
template: notificationTemplate
843+
}
844+
) );
845+
if ( ! settingNotification.data || ! settingNotification.data.setting_property || ! api.control.has( section.id + '[' + settingNotification.data.setting_property + ']' ) ) {
846+
section.notifications.add( notification.code, notification );
847+
}
848+
} );
849+
setting.notifications.bind( 'remove', function( settingNotification ) {
850+
section.notifications.remove( setting.id + ':' + settingNotification.code );
851+
} );
875852

876853
// Dismiss conflict block when clicking on button.
877-
section.notificationsContainer.on( 'click', '.override-post-conflict', function( e ) {
854+
section.notifications.container.on( 'click', '.override-post-conflict', function( e ) {
878855
var ourValue;
879856
e.preventDefault();
880857
ourValue = _.clone( setting.get() );
@@ -890,6 +867,7 @@
890867
} );
891868

892869
// Detect conflict errors.
870+
notificationTemplate = wp.template( 'customize-post-field-notification' );
893871
api.bind( 'error', function( response ) {
894872
var theirValue, ourValue,
895873
conflictedControls = [];

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
"type": "git",
77
"url": "https://github.com/xwp/wp-customize-posts.git"
88
},
9-
"version": "0.8.7",
9+
"version": "0.9.0",
1010
"license": "GPL-2.0+",
1111
"private": true,
1212
"devDependencies": {
13-
"eslint": "^3.19.0",
13+
"eslint": "^4.5.0",
1414
"grunt": "~1.0.1",
15-
"grunt-contrib-clean": "~1.0.0",
15+
"grunt-contrib-clean": "~1.1.0",
1616
"grunt-contrib-copy": "~1.0.0",
17-
"grunt-contrib-cssmin": "~1.0.2",
18-
"grunt-contrib-jshint": "~1.0.0",
19-
"grunt-contrib-uglify": "~2.0.0",
20-
"grunt-shell": "~1.3.1",
21-
"grunt-wp-deploy": "^1.2.1"
17+
"grunt-contrib-cssmin": "~2.2.1",
18+
"grunt-contrib-jshint": "~1.1.0",
19+
"grunt-contrib-uglify": "~3.0.1",
20+
"grunt-shell": "~2.1.0",
21+
"grunt-wp-deploy": "~1.2.1"
2222
},
2323
"author": "XWP",
2424
"scripts": {

0 commit comments

Comments
 (0)