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

Add post date control and preview #202

Merged
merged 85 commits into from
Aug 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
996c2ca
Post Date - Initial text input
Jul 23, 2016
adaf8cd
Post Date - Add basic custom control
Jul 24, 2016
59f5419
Post Date - Simplify, cleanup
Jul 25, 2016
7bedfab
Post Date - Iniital Tests
Jul 25, 2016
a73a67b
Post Date - Code cleanup
Jul 25, 2016
ddeed3b
Post Date - WIP
Jul 25, 2016
128d4bc
Post Date - New Control
Jul 26, 2016
c76f7a4
Merge branch 'develop' into feature/issue-56-post-date-control
Jul 26, 2016
a1f6ca0
Post Date - CSS, Code cleanup
Jul 26, 2016
d274099
Post Date - Change comment type
Jul 26, 2016
f8c68ee
Post Date - JS Date Handlers
Jul 26, 2016
37b3a87
Post Date - Code cleanup
Jul 26, 2016
a67829a
Post Date - Documentation
Jul 26, 2016
a7226a5
Post Date - Feature working
Jul 27, 2016
4798cdf
Post Date - Remove Date formatter
Jul 27, 2016
3c7acd9
Post Date - 'Published on' text
Jul 27, 2016
ca92ac4
Post Date - Code cleanup
Jul 27, 2016
0081baf
Post Date - Modify eslint for consistent-this
Jul 27, 2016
092d3bc
Post Date - correct syntax for eslint
Jul 27, 2016
0ac0e77
Post Date - Input validation
Jul 27, 2016
c59b673
Post Date - Documentation
Jul 27, 2016
e2ad701
Post Date - Code cleanup
Jul 27, 2016
4b56523
Post Date - Code cleanup
Jul 27, 2016
6fd3084
Post Date - Hidden update Post Status
Jul 27, 2016
4a5c6c5
Post Date - Update Post Status
Jul 28, 2016
e6a9048
Post Date - JSDocs
Jul 28, 2016
ef76128
Post Date - JSDoc update
Jul 28, 2016
1ca7394
Post Date - Refactor and new file
Jul 28, 2016
097f211
Post Date - Saving post_date_gmt & post_status
Jul 28, 2016
4e58a2d
Rename customize-post-date to customize-post-date-control
westonruter Jul 28, 2016
467ebb8
Remove 'Post' from Status and Date control labels
westonruter Jul 28, 2016
62adabe
Include timezone and/or GMT offset in date control description
westonruter Jul 29, 2016
517cb2d
Add missing phpdoc and translator comment
westonruter Jul 29, 2016
4845ec2
Refactor how date fields are bound with the post_date setting property.
westonruter Jul 29, 2016
c79172e
Remove obsolete CSS rule
westonruter Jul 29, 2016
e032ebb
Allow post type registration to override date control label
westonruter Jul 29, 2016
dd10ae7
Prevent selective refresh requests from dropping queriedPostId
westonruter Jul 29, 2016
60a6f6a
Eliminate post_date_gmt and post_modified_gmt from setting value
westonruter Jul 29, 2016
4caf74d
Hide date control in edit post screen preview; add todo for sync
westonruter Jul 29, 2016
f382ef9
Fix eslint issues across plugin
westonruter Jul 29, 2016
faf80fa
Prevent low-fidelity live preview of post title from running at refresh
westonruter Jul 29, 2016
1dcaa23
Add getCurrentTime function
westonruter Jul 29, 2016
a0b0382
Use getDate (of month) instead of uncorrect getDay (of week)
westonruter Jul 29, 2016
7b2e6cb
Prevent erroneously showing post navigation link when status is trash
westonruter Jul 29, 2016
75bec41
Add dedicated post_status control, sync publish/future status with po…
westonruter Jul 29, 2016
ce5d417
Ensure JS sets post_author to integer
westonruter Jul 30, 2016
aab10bf
Prevent infinite partial fallbackRefresh when a setting is invalid
westonruter Jul 30, 2016
c70bd59
Turn off fallback_refresh for author partials
westonruter Jul 30, 2016
0df59d2
Let auto-draft posts be inserted with empty dates
westonruter Jul 30, 2016
43baeca
Allow draft posts to have empty dates which translate to current date…
westonruter Jul 30, 2016
0262640
Add button to reset post_date to current time
westonruter Jul 30, 2016
3b0d8ae
Merge branch 'develop' of https://github.com/xwp/wp-customize-posts i…
westonruter Jul 30, 2016
0efcaea
Force archives to refresh when dates change so posts can bre reordered
westonruter Jul 30, 2016
5680d0d
Filter the_posts to re-order after previewed changes have been applied
westonruter Jul 30, 2016
0ec6824
Do full refreshes on archive views when a post field is modified that…
westonruter Jul 30, 2016
28bc885
Add tests for Customize_Posts_Plugin and WP_Customize_Post_Date_Control
westonruter Jul 30, 2016
410f9cb
Add test for render_post_date
westonruter Jul 30, 2016
29077d4
Add tests for WP_Customize_Post_Setting
westonruter Jul 30, 2016
899ce61
Add tests and stubs for stubs
westonruter Jul 31, 2016
7f2e87c
Implement incomplete tests for WP_Customize_Posts
westonruter Jul 31, 2016
86e448c
Implement tests for WP_Customize_Posts_Preview
westonruter Jul 31, 2016
8dec6c8
Move month choices to main component class
westonruter Jul 31, 2016
641b7eb
Ensure that empty dates are not leaked when a setting is invalid
westonruter Jul 31, 2016
9b1fcdd
Attempt to fix Test_WP_Customize_Posts::test_enqueue_scripts double v…
westonruter Jul 31, 2016
7975f86
Force all post field partials to refresh even if an unrelated field w…
westonruter Aug 1, 2016
1b37d71
Leave partial placements in a loading state after they get refreshed …
westonruter Aug 1, 2016
76afa9f
Move deferred partial into its own file; clean up dependencies
westonruter Aug 1, 2016
d86532e
Move settingValidities collection into separate JS file
westonruter Aug 1, 2016
57bad17
Add scheduled countdown when status is future and time is after now
westonruter Aug 1, 2016
fb90a0a
Add grunt build to npm postinstall script
westonruter Aug 1, 2016
191b923
Use small for date control description; fix call to format_gmt_offset
westonruter Aug 1, 2016
70a7fd4
Re-use tz_string var
westonruter Aug 1, 2016
d95eaac
Update wp-plugin-dev-lib 449182d...ce4fce1: Use __FILE__ instead of _…
westonruter Aug 1, 2016
a385a60
Skip grunt build if not PHP>5.2
westonruter Aug 1, 2016
ebf331e
Only run grunt build if PHP>=5.3
westonruter Aug 1, 2016
18364e2
Improvement: Refine UI for post date control reset button 💯
Aug 1, 2016
04efe42
Fix: Wierd redirect by adding buttons type
Aug 1, 2016
ad6751d
Merge pull request #208 from ahmadawais/feature/issue-56-post-date-co…
westonruter Aug 1, 2016
276f8fb
Use link instead of button to re-use styles
westonruter Aug 1, 2016
41b8d0b
Show local timezone abbr as details summary on same line as title
westonruter Aug 2, 2016
2bac360
Update wp-plugin-dev-lib 449182d...4aba13a: Merge pull request #194 f…
westonruter Aug 2, 2016
b293245
Fix display of GMT offset
westonruter Aug 2, 2016
a7315e1
Fix reset post time by passing in post_date_gmt as empty as well
westonruter Aug 2, 2016
ce956fd
Fix race condition when saving publish post at current time
westonruter Aug 2, 2016
b7bcbe1
Improve logic for updating selected status option
westonruter Aug 2, 2016
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
53 changes: 52 additions & 1 deletion css/customize-posts.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
transition: all 0.2s;
visibility: hidden;
}

body.customize-posts-content-editor-pane-resize #customize-preview,
body.customize-posts-content-editor-pane-resize #customize-posts-content-editor-pane {
-webkit-transition: none;
Expand Down Expand Up @@ -220,3 +220,54 @@ body.customize-posts-content-editor-pane-resize #customize-preview:before {
width: auto;
vertical-align: middle;
}

.customize-control-post_date .customize-control-description {
font-style: normal;
display: block;
margin-bottom: 0;
margin-top: -28px;
}
.customize-control-post_date .customize-control-description summary {
font-size: 14px;
line-height: 24px;
margin-bottom: 4px;
display: block;
float: right;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.customize-control-post_date .customize-control-description[open] {
margin-bottom: 5px;
}
.customize-control-post_date .customize-control-description .time-details {
clear: both;
}
.customize-control-post_date .date-inputs {
clear: both;
}

.customize-control-post_date select,
.customize-control-post_date input.date-input {
min-width: 10%;
width: auto;
}
.customize-control-post_date input.date-input {
-moz-appearance: textfield;
}
.customize-control-post_date input.date-input::-webkit-outer-spin-button,
.customize-control-post_date input.date-input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
.wrap-reset-time {
font-weight: normal;
font-size: 75%;
}
.customize-control-post_date .reset-time {
cursor: pointer;
margin-left: 0.25ex;
margin-right: 0.25ex;
}
2 changes: 1 addition & 1 deletion dev-lib
2 changes: 2 additions & 0 deletions js/customize-controls-patched-36521.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @see FeaturedImage.updateSelection()
*
* @link https://core.trac.wordpress.org/ticket/36521
* @returns {void}
*/
api.MediaControl.prototype.ready = function() {
var control = this;
Expand Down Expand Up @@ -47,6 +48,7 @@
* attachmentData before calling the renderContent method.
*
* @param {number|string} value Attachment
* @returns {void}
*/
function setAttachmentDataAndRenderContent( value ) {
var hasAttachmentData = $.Deferred(), attachmentId = value;
Expand Down
97 changes: 97 additions & 0 deletions js/customize-deferred-partial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/* global wp */
/* eslint consistent-this: [ "error", "partial" ] */
/* eslint-disable no-magic-numbers */

(function( api ) {
'use strict';

/**
* A deferred partial for settings that created at runtime.
*
* @class
* @augments wp.customize.selectiveRefresh.Partial
* @augments wp.customize.Class
*/
api.selectiveRefresh.partialConstructor.deferred = api.selectiveRefresh.Partial.extend({

/**
* Handle fail to render partial.
*
* {@inheritdoc}
*
* @this {wp.customize.selectiveRefresh.Partial}
* @returns {void}
*/
fallback: function deferredPartialFallback() {
var partial = this, hasInvalidSettings = false;

// Prevent infinite selective refresh reloading for partials that have fallbackRefresh.
_.each( partial.settings(), function checkSettingValidity( settingId ) {
var validityState = api.settingValidities( settingId );
if ( validityState && true !== validityState.get() ) {
hasInvalidSettings = true;
}
} );
if ( hasInvalidSettings ) {
return;
}
api.selectiveRefresh.Partial.prototype.fallback.call( partial );
},

/**
* Return whether the setting is related to the partial.
*
* This is needed because selective refresh has the behavior of calling
* `handleSettingChange` when a setting is added, but since we are deferring
* to create settings until they are needed, we need to prevent created
* settings from triggering a partial refresh.
*
* @param {wp.customize.Value|string} setting ID or object for setting.
* @param {*} newValue New value.
* @param {*} oldValue Old value.
* @return {boolean} Whether the setting is related to the partial.
*/
isRelatedSetting: function( setting, newValue, oldValue ) {
var isSettingCreated = null === oldValue;
if ( isSettingCreated ) {
return false;
} else {
return api.selectiveRefresh.Partial.prototype.isRelatedSetting.call( this, setting, newValue, oldValue );
}
},

/**
* Request the new partial and render it into the placements.
*
* @return {jQuery.Promise} Refresh promise.
*/
refresh: function() {
var partial = this, refreshPromise;

refreshPromise = api.selectiveRefresh.Partial.prototype.refresh.call( partial );

refreshPromise.done( function() {
var hasInvalidSettings = false;
_.each( partial.settings(), function( settingId ) {
var validityState = api.settingValidities( settingId );
if ( validityState && true !== validityState.get() ) {
hasInvalidSettings = true;
}
} );

/*
* Leave partial placements in a loading state after they get
* refreshed but have invalid settings (and thus revert to original values).
*/
if ( hasInvalidSettings ) {
_.each( partial.placements(), function( placement ) {
partial.preparePlacement( placement );
} );
}
} );

return refreshPromise;
}
});

})( wp.customize );
9 changes: 8 additions & 1 deletion js/customize-dynamic-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* should be changed in Core to be applied once the control is embedded.
*
* @private
* @returns {void}
*/
_setUpSettingRootLinks: function() {
var control, nodes, radios;
Expand Down Expand Up @@ -73,6 +74,7 @@
* Add bidirectional data binding links between inputs and the setting properties.
*
* @private
* @returns {void}
*/
_setUpSettingPropertyLinks: function() {
var control = this, nodes, radios;
Expand Down Expand Up @@ -141,6 +143,8 @@
* Override the embed() method to do nothing,
* so that the control isn't embedded on load,
* unless the containing section is already expanded.
*
* @returns {void}
*/
embed: function() {
var control = this,
Expand All @@ -166,6 +170,8 @@
*
* This function is called in Section.onChangeExpanded() so the control
* will only get embedded when the Section is first expanded.
*
* @returns {void}
*/
actuallyEmbed: function() {
var control = this;
Expand All @@ -179,7 +185,8 @@
/**
* This is not working with autofocus.
*
* @param args
* @param {object} [args] Args.
* @returns {void}
*/
focus: function( args ) {
var control = this;
Expand Down
2 changes: 1 addition & 1 deletion js/customize-page-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var CustomizePageTemplate = (function( api ) {
/**
* Make sure that control only appears if there are page templates (other than 'default').
*
* @returns {boolean}
* @returns {boolean} Is active.
*/
isActiveCallback = function() {
var defaultSize = 1;
Expand Down
Loading