Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
995af42
Eliminate active validate overrides for WP 4.7-alpha-38464
westonruter Aug 31, 2016
b42ebfd
Update dev-lib
valendesigns Aug 23, 2017
d509d64
Regenerate readme
valendesigns Aug 23, 2017
c342846
Update devDependencies
valendesigns Aug 23, 2017
763edf3
Merge pull request #360 from xwp/fix/deps
valendesigns Aug 23, 2017
6f87070
Revert "Prevent loading postmeta controllers if posts component is di…
westonruter Aug 29, 2017
9550566
Merge pull request #361 from xwp/revert/258
westonruter Aug 29, 2017
114b269
Make use of section notifications API in WP 4.9 when available; other…
westonruter Sep 19, 2017
5e68883
Merge pull request #366 from xwp/use-section-notifications-api
westonruter Sep 20, 2017
f6585d0
Update wrapper around notifications.add for new params accepted in 4.9
westonruter Oct 9, 2017
94467b9
Merge pull request #369 from xwp/use-section-notifications-api
westonruter Oct 9, 2017
f434773
Bump tested up to, to 4.9.0
westonruter Oct 22, 2017
0f4587c
Update wp-plugin-dev-lib d8540c1...52874e4: Merge pull request xwp/wp…
westonruter Oct 22, 2017
ac6e880
Update WP_Customize_Posts::sanitize_nav_menus_created_posts() for 4.9
westonruter Oct 22, 2017
27a3b13
Bump minimum version to 4.7 from 4.5
westonruter Oct 22, 2017
69b9bc1
Exclude PHPCS Generic.Formatting.MultipleStatementAlignment.NotSameWa…
westonruter Oct 22, 2017
89dea29
Skip PHPCS on PHP 5.2
westonruter Oct 22, 2017
84e25c7
Change Travis build PHP version to 5.2
westonruter Oct 23, 2017
89ebab7
Fix PHP 5.2 syntax errors
westonruter Oct 23, 2017
07535d4
Fix phpcs issues
westonruter Oct 25, 2017
2d00417
Merge branch 'enhancement/trac-37270-remove-validate-overrides' of ht…
westonruter Oct 25, 2017
9e56b17
Remove additional validate overrides missed in #235
westonruter Oct 25, 2017
63deab2
Hide publish settings gear button in customizer post preview
westonruter Oct 26, 2017
6768816
Bump version, add readme
westonruter Oct 31, 2017
135bc5b
Merge pull request #371 from xwp/add/4.9-support
westonruter Nov 11, 2017
d917c74
Update readme
westonruter Nov 11, 2017
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
4 changes: 4 additions & 0 deletions .dev-lib
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
WPCS_GIT_TREE=develop
ASSETS_DIR=wp-assets

if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]] || [[ ${TRAVIS_PHP_VERSION:0:3} == "5.3" ]]; then
DEV_LIB_SKIP="$DEV_LIB_SKIP,phpcs"
fi
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ language:
- node_js

php:
- 5.3
- 5.2
- 7.0

env:
- WP_VERSION=trunk WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=4.6.1 WP_MULTISITE=0
- WP_VERSION=4.7.6 WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=1

install:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xwp/wp-customize-posts",
"description": "Manage posts and postmeta via the Customizer.",
"version": "0.8.7",
"version": "0.9.0",
"type": "wordpress-plugin",
"keywords": [ "customizer", "customize", "posts", "postmeta", "preview", "featured-image", "page-template" ],
"homepage": "https://github.com/xwp/wp-customize-posts/",
Expand Down
3 changes: 2 additions & 1 deletion css/edit-post-preview-customize.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#customize-header-actions #snapshot-save,
#snapshot-status-button-wrapper,
#snapshot-preview-link,
#snapshot-expand-button
#snapshot-expand-button,
#publish-settings
{
display: none !important;
}
Expand Down
2 changes: 1 addition & 1 deletion customize-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Customize Posts
* Description: Manage posts and postmeta via the Customizer.
* Plugin URI: https://github.com/xwp/wp-customize-posts/
* Version: 0.8.7
* Version: 0.9.0
* Author: XWP
* Author URI: https://make.xwp.co/
* License: GPLv2+
Expand Down
2 changes: 1 addition & 1 deletion dev-lib
5 changes: 0 additions & 5 deletions js/customize-featured-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ var CustomizeFeaturedImage = (function( api ) {
} );
};

control.active.set( true );
control.active.validate = function validateForcingTrue() {
return true;
};

// Register.
api.control.add( control.id, control );

Expand Down
6 changes: 3 additions & 3 deletions js/customize-page-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var CustomizePageTemplate = (function( api ) {
* @returns {wp.customize.Control|null} The control.
*/
component.addControl = function( section ) {
var supports, control, controlId, settingId, isActiveCallback;
var supports, control, controlId, settingId;
supports = api.Posts.data.postTypes[ section.params.post_type ].supports;

if ( ! supports['page-attributes'] || 'page' !== section.params.post_type ) {
Expand Down Expand Up @@ -103,13 +103,13 @@ var CustomizePageTemplate = (function( api ) {
*
* @returns {boolean} Is active.
*/
isActiveCallback = function() {
function isActiveCallback() {
var defaultSize = 1;
if ( api.has( 'page_for_posts' ) && parseInt( api( 'page_for_posts' ).get(), 10 ) === section.params.post_id ) {
return false;
}
return _.size( control.params.choices ) > defaultSize;
};
}
control.active.set( isActiveCallback() );
control.active.validate = isActiveCallback;
api( 'page_for_posts', function( pageOnFrontSetting ) {
Expand Down
112 changes: 45 additions & 67 deletions js/customize-post-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,17 @@
* unless the notification is specifically for this control's setting property.
*
* @this {wp.customize.Control}
* @param {string} code Notification code.
* @param {wp.customize.Notification} notification Notification object.
* @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.
* @param {wp.customize.Notification} [notificationObject] - Notification to add when first argument is the code string.
* @returns {wp.customize.Notification|null} Notification if not bypassed.
*/
addPostFieldControlNotification: function addPostFieldControlNotification( code, notification ) {
var isSettingNotification, isSettingPropertyNotification;
addPostFieldControlNotification: function addPostFieldControlNotification( notification, notificationObject ) {
var isSettingNotification, isSettingPropertyNotification, code;
code = 'string' === typeof notification ? notification : notification.code;
isSettingNotification = -1 !== code.indexOf( ':' ) || notification.setting; // Note that sniffing for ':' is deprecated as of #36944 & #37890.
isSettingPropertyNotification = notification.data && notification.data.setting_property === this.setting_property;
if ( isSettingPropertyNotification || ! isSettingNotification ) {
return api.Values.prototype.add.call( this, code, notification );
return ( api.Notifications || api.Values ).prototype.add.call( this, notification, notificationObject );
} else {
return null;
}
Expand Down Expand Up @@ -393,11 +394,6 @@
}
} );

// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
control.active.validate = function() {
return true;
};

// Register.
section.postFieldControls.post_title = control;
api.control.add( control.id, control );
Expand Down Expand Up @@ -451,11 +447,6 @@
setting.bind( setPlaceholder );
} );

// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
control.active.validate = function() {
return true;
};

// Register.
section.postFieldControls.post_name = control;
api.control.add( control.id, control );
Expand Down Expand Up @@ -487,11 +478,6 @@
}
} );

// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
control.active.validate = function() {
return true;
};

// Register.
section.postFieldControls.post_status = control;
api.control.add( control.id, control );
Expand Down Expand Up @@ -524,11 +510,6 @@
}
} );

// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
control.active.validate = function() {
return true;
};

// Register.
section.postFieldControls.post_date = control;
api.control.add( control.id, control );
Expand Down Expand Up @@ -617,11 +598,6 @@
}
} );

// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
control.active.validate = function() {
return true;
};

// Register.
section.postFieldControls.post_excerpt = control;
api.control.add( control.id, control );
Expand Down Expand Up @@ -686,11 +662,6 @@
} );
}

// Override preview trying to de-activate control not present in preview context.
control.active.validate = function() {
return true;
};

// Register.
section.postFieldControls.page_parent = control;
api.control.add( control.id, control );
Expand Down Expand Up @@ -724,11 +695,6 @@
}
} );

// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
control.active.validate = function() {
return true;
};

// Register.
section.postFieldControls.menu_order = control;
api.control.add( control.id, control );
Expand Down Expand Up @@ -761,11 +727,6 @@
}
} );

// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
control.active.validate = function() {
return true;
};

// Register.
section.postFieldControls.post_discussion_fields = control;
api.control.add( control.id, control );
Expand Down Expand Up @@ -809,11 +770,6 @@
return data;
};

// Override preview trying to de-activate control not present in preview context. See WP Trac #37270.
control.active.validate = function() {
return true;
};

// Register.
section.postFieldControls.post_author = control;
api.control.add( control.id, control );
Expand All @@ -826,37 +782,27 @@
},

/**
* Set up section notifications.
* Polyfill notifications API onto sections if not yet on WordPress 4.9 where it is defined in core.
*
* @link <https://core.trac.wordpress.org/ticket/38794>
* @returns {void}
*/
setupSectionNotifications: function() {
var section = this, setting = api( section.id ), debouncedRenderNotifications, setPageForPostsNotice;
if ( ! setting.notifications ) {
polyfillNotifications: function() {
var section = this, debouncedRenderNotifications;
if ( section.notifications ) {
return;
}

// Add the notifications API.
section.notifications = new api.Values({ defaultConstructor: api.Notification });
section.notificationsContainer = $( '<div class="customize-control-notifications-container"></div>' );
section.notifications.container = section.notificationsContainer;
section.notificationsTemplate = wp.template( 'customize-post-section-notifications' );
section.container.find( '.customize-section-title' ).after( section.notificationsContainer );
section.getNotificationsContainerElement = function() {
return section.notificationsContainer;
};
section.renderNotifications = api.Control.prototype.renderNotifications;

// Sync setting notifications into the section notifications
setting.notifications.bind( 'add', function( settingNotification ) {
var notification = new api.Notification( setting.id + ':' + settingNotification.code, settingNotification );
if ( ! settingNotification.data || ! settingNotification.data.setting_property || ! api.control.has( section.id + '[' + settingNotification.data.setting_property + ']' ) ) {
section.notifications.add( notification.code, notification );
}
} );
setting.notifications.bind( 'remove', function( settingNotification ) {
section.notifications.remove( setting.id + ':' + settingNotification.code );
} );

/*
* Render notifications when the collection is updated.
* Note that this debounced/deferred rendering is needed for two reasons:
Expand All @@ -872,9 +818,40 @@
} );
section.notifications.bind( 'remove', debouncedRenderNotifications );
section.renderNotifications();
},

/**
* Set up section notifications.
*
* @returns {void}
*/
setupSectionNotifications: function() {
var section = this, setting = api( section.id ), setPageForPostsNotice, notificationTemplate;
if ( ! setting.notifications ) {
return;
}

// Add the notifications API if not present.
section.polyfillNotifications();

// Sync setting notifications into the section notifications
setting.notifications.bind( 'add', function( settingNotification ) {
var notification = new api.Notification( setting.id + ':' + settingNotification.code, _.extend( {},
settingNotification,
{
template: notificationTemplate
}
) );
if ( ! settingNotification.data || ! settingNotification.data.setting_property || ! api.control.has( section.id + '[' + settingNotification.data.setting_property + ']' ) ) {
section.notifications.add( notification.code, notification );
}
} );
setting.notifications.bind( 'remove', function( settingNotification ) {
section.notifications.remove( setting.id + ':' + settingNotification.code );
} );

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

// Detect conflict errors.
notificationTemplate = wp.template( 'customize-post-field-notification' );
api.bind( 'error', function( response ) {
var theirValue, ourValue,
conflictedControls = [];
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
"type": "git",
"url": "https://github.com/xwp/wp-customize-posts.git"
},
"version": "0.8.7",
"version": "0.9.0",
"license": "GPL-2.0+",
"private": true,
"devDependencies": {
"eslint": "^3.19.0",
"eslint": "^4.5.0",
"grunt": "~1.0.1",
"grunt-contrib-clean": "~1.0.0",
"grunt-contrib-clean": "~1.1.0",
"grunt-contrib-copy": "~1.0.0",
"grunt-contrib-cssmin": "~1.0.2",
"grunt-contrib-jshint": "~1.0.0",
"grunt-contrib-uglify": "~2.0.0",
"grunt-shell": "~1.3.1",
"grunt-wp-deploy": "^1.2.1"
"grunt-contrib-cssmin": "~2.2.1",
"grunt-contrib-jshint": "~1.1.0",
"grunt-contrib-uglify": "~3.0.1",
"grunt-shell": "~2.1.0",
"grunt-wp-deploy": "~1.2.1"
},
"author": "XWP",
"scripts": {
Expand Down
12 changes: 6 additions & 6 deletions php/class-customize-posts-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public function __construct() {
add_filter( 'customize_loaded_components', array( $this, 'filter_customize_loaded_components' ), 100, 2 );
add_action( 'customize_register', array( $this, 'load_support_classes' ) );
add_action( 'delete_post', array( $this, 'cleanup_autodraft_on_changeset_delete' ) );

require_once dirname( __FILE__ ) . '/class-wp-customize-postmeta-controller.php';
require_once dirname( __FILE__ ) . '/class-wp-customize-page-template-controller.php';
require_once dirname( __FILE__ ) . '/class-wp-customize-featured-image-controller.php';
$this->page_template_controller = new WP_Customize_Page_Template_Controller();
$this->featured_image_controller = new WP_Customize_Featured_Image_Controller();
}

/**
Expand Down Expand Up @@ -170,12 +176,6 @@ function filter_customize_loaded_components( $components, $wp_customize ) {
require_once dirname( __FILE__ ) . '/class-wp-customize-posts.php';
if ( in_array( 'posts', $components, true ) ) {
$wp_customize->posts = new WP_Customize_Posts( $wp_customize );

require_once dirname( __FILE__ ) . '/class-wp-customize-postmeta-controller.php';
require_once dirname( __FILE__ ) . '/class-wp-customize-page-template-controller.php';
require_once dirname( __FILE__ ) . '/class-wp-customize-featured-image-controller.php';
$this->page_template_controller = new WP_Customize_Page_Template_Controller();
$this->featured_image_controller = new WP_Customize_Featured_Image_Controller();
}

return $components;
Expand Down
2 changes: 1 addition & 1 deletion php/class-wp-customize-dynamic-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function content_template() {
$data = $this->json();
?>
<#
_.defaults( data, <?php echo wp_json_encode( $data ) ?> );
_.defaults( data, <?php echo wp_json_encode( $data ); ?> );
data.input_id = 'input-' + String( Math.random() );
#>
<# if ( 'checkbox' === data.field_type ) { #>
Expand Down
2 changes: 1 addition & 1 deletion php/class-wp-customize-featured-image-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public function sanitize_setting( $attachment_id, WP_Customize_Postmeta_Setting
* and the meta is registered wit WP_Customize_Featured_Image_Controller::sanitize_value() as the sanitize_callback().
* So $attachment_id is either a valid attachment ID, -1, or false.
*/
if ( ! $is_valid ) {
if ( ! $is_valid ) {
return $has_setting_validation ? new WP_Error( 'invalid_attachment_id', __( 'The attachment is invalid.', 'customize-posts' ) ) : null;
}

Expand Down
Loading