Post Expirator - Version 2.5.1

Version Description

Download this release

Release Info

Developer publishpress
Plugin Icon 128x128 Post Expirator
Version 2.5.1
Comparing to
See all releases

Code changes from version 2.5.0 to 2.5.1

assets/css/style.css CHANGED
@@ -32,3 +32,22 @@
32
  font-style: italic;
33
  font-size: x-small;
34
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  font-style: italic;
33
  font-size: x-small;
34
  }
35
+
36
+ div.pe-classic-fields {
37
+ display: flex;
38
+ flex-direction: row;
39
+ flex-wrap: wrap;
40
+ align-content: center;
41
+ justify-content: space-between;
42
+ align-items: center;
43
+ }
44
+
45
+ div.pe-classic-fields > div {
46
+ display: flex;
47
+ flex-direction: column;
48
+ padding: 5px;
49
+ }
50
+
51
+ div.pe-classic-fields > div > label {
52
+ font-weight: bold;
53
+ }
assets/js/block.js CHANGED
@@ -1,2 +1,440 @@
1
- !function(e){var t={};function a(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=e,a.c=t,a.d=function(e,t,o){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(a.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)a.d(o,r,function(t){return e[t]}.bind(null,r));return o},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,a){e.exports=a(1)},function(e,t,a){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r=function(){function e(e,t){for(var a=0;a<t.length;a++){var o=t[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,a,o){return a&&e(t.prototype,a),o&&e(t,o),t}}();function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}!function(e,t){var a=e.plugins.registerPlugin,c=e.i18n.__,s=e.editPost.PluginDocumentSettingPanel,u=e.components,l=u.PanelRow,p=u.DateTimePicker,d=u.CheckboxControl,f=u.SelectControl,g=u.FormTokenField,y=u.Spinner,m=e.element,b=m.Fragment,x=m.Component,v=e.htmlEntities.decodeEntities,h=lodash,E=h.isEmpty,P=h.keys,S=h.compact;a("postexpirator-sidebar",{render:function(a){function u(){n(this,u);var e=i(this,(u.__proto__||Object.getPrototypeOf(u)).apply(this,arguments));return e.state={categoriesList:[],catIdVsName:[]},e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(u,a),r(u,[{key:"componentWillMount",value:function(){var a,o=this,r=(this.state.attributes,e.data.select("core/editor").getEditedPostAttribute("meta")),n=e.data.select("core/editor").getCurrentPostType(),i=1==t.defaults.autoEnable,s=new Date,u=this.getExpireType(r),l=[];if(u.includes("category")&&(l=this.getCategories(r)),r["_expiration-date-status"]&&"saved"===r["_expiration-date-status"]&&(i=!0),r["_expiration-date"])s.setTime(1e3*(r["_expiration-date"]+60*s.getTimezoneOffset()));else if(l=t.default_categories,t.default_date){s.setTime(1e3*(parseInt(t.default_date)+60*s.getTimezoneOffset()));a={"_expiration-date":this.getDate(s)},e.data.dispatch("core/editor").editPost({meta:a})}var p=t.defaults.taxonomy||"category";this.setState({enabled:i,date:s,expireAction:u,categories:l,taxonomy:p});var d=[],f=[];!p&&"post"===n||"category"===p?e.apiFetch({path:e.url.addQueryArgs("wp/v2/categories",{per_page:-1,hide_empty:!1})}).then((function(e){e.forEach((function(e){d[e.name]=e,f[e.id]=e.name})),o.setState({categoriesList:d,catIdVsName:f,taxonomy:c("Category")})})):"page"!==n&&e.apiFetch({path:e.url.addQueryArgs("wp/v2/taxonomies/"+p,{context:"edit"})}).then((function(t){e.apiFetch({path:e.url.addQueryArgs("wp/v2/"+t.rest_base,{context:"edit"})}).then((function(e){e.forEach((function(e){d[v(e.name)]=e,f[e.id]=v(e.name)})),o.setState({categoriesList:d,catIdVsName:f,taxonomy:v(t.name)})}))}))}},{key:"componentDidUpdate",value:function(){var t=this.state,a=t.enabled,o=t.date,r=t.expireAction,n=t.categories,i=function(t){return e.data.dispatch("core/editor").editPost({meta:t})};switch(t.attribute){case"enabled":i({"_expiration-date-status":a?"saved":""});break;case"date":"string"==typeof o&&i({"_expiration-date":this.getDate(o)});break;case"action":i({"_expiration-date-type":r}),r.includes("category")||i({"_expiration-date-categories":[]});break;case"category":i({"_expiration-date-categories":n})}}},{key:"render",value:function(){var t=this,a=this.state,o=a.categoriesList,r=a.catIdVsName,n=this.state,i=n.enabled,u=n.date,m=n.expireAction,x=n.categories,v=n.taxonomy,h=e.data.select("core/editor").getCurrentPostType(),k=[{label:c("Draft","post-expirator"),value:"draft"},{label:c("Delete","post-expirator"),value:"delete"},{label:c("Trash","post-expirator"),value:"trash"},{label:c("Private","post-expirator"),value:"private"},{label:c("Stick","post-expirator"),value:"stick"},{label:c("Unstick","post-expirator"),value:"unstick"}];"page"!==h&&(k=_.union(k,[{label:c("Category: Replace","post-expirator"),value:"category"},{label:c("Category: Add","post-expirator"),value:"category-add"},{label:c("Category: Remove","post-expirator"),value:"category-remove"}]));var w=x&&S(x.map((function(e){return r[e]||!1})));return"string"==typeof w&&(w=[]),React.createElement(s,{title:c("Post Expirator","post-expirator"),icon:"calendar",initialOpen:i},React.createElement(l,null,React.createElement(d,{label:c("Enable Post Expiration","post-expirator"),checked:i,onChange:function(e){t.setState({enabled:!i,attribute:"enabled"})}})),i&&React.createElement(b,null,React.createElement(l,null,React.createElement(p,{currentDate:u,onChange:function(e){return t.setState({date:e,attribute:"date"})},is12Hour:!0})),React.createElement(f,{label:c("How to expire","post-expirator"),value:m,options:k,onChange:function(e){t.setState({expireAction:e,attribute:"action"})}}),m.includes("category")&&(E(P(o))&&React.createElement(b,null,c("Loading","post-expirator")+" ("+v+")",React.createElement(y,null))||React.createElement(g,{label:c("Expiration Categories","post-expirator")+" ("+v+")",value:w,suggestions:Object.keys(o),onChange:function(e){t.setState({categories:t.selectCategories(e),attribute:"category"})},maxSuggestions:10}))))}},{key:"getExpireType",value:function(e){var t=e["_expiration-date-type"],a=e["_expiration-date-options"]&&e["_expiration-date-options"].expireType;return t||(a||"draft")}},{key:"getCategories",value:function(e){var t=e["_expiration-date-categories"]&&e["_expiration-date-categories"],a=e["_expiration-date-options"]&&e["_expiration-date-options"].category;return"object"===(void 0===t?"undefined":o(t))&&t.length>0?t:(a&&void 0!==a&&"object"!==(void 0===a?"undefined":o(a))&&(categories=[a]),a)}},{key:"selectCategories",value:function(e){var t=this.state,a=t.categoriesList;t.catIdVsName;if(!e.some((function(e){return"string"==typeof e&&!a[e]})))return e.map((function(e){return"string"==typeof e?a[e]:e})).map((function(e){return e.id}))}},{key:"getDate",value:function(e){var t=new Date;return t.setTime(Date.parse(e)),t.setTime(t.getTime()-60*(new Date).getTimezoneOffset()*1e3),t.getTime()/1e3}}]),u}(x)})}(window.wp,config)}]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  //# sourceMappingURL=block.js.map
1
+ /******/ (function(modules) { // webpackBootstrap
2
+ /******/ // The module cache
3
+ /******/ var installedModules = {};
4
+ /******/
5
+ /******/ // The require function
6
+ /******/ function __webpack_require__(moduleId) {
7
+ /******/
8
+ /******/ // Check if module is in cache
9
+ /******/ if(installedModules[moduleId]) {
10
+ /******/ return installedModules[moduleId].exports;
11
+ /******/ }
12
+ /******/ // Create a new module (and put it into the cache)
13
+ /******/ var module = installedModules[moduleId] = {
14
+ /******/ i: moduleId,
15
+ /******/ l: false,
16
+ /******/ exports: {}
17
+ /******/ };
18
+ /******/
19
+ /******/ // Execute the module function
20
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
+ /******/
22
+ /******/ // Flag the module as loaded
23
+ /******/ module.l = true;
24
+ /******/
25
+ /******/ // Return the exports of the module
26
+ /******/ return module.exports;
27
+ /******/ }
28
+ /******/
29
+ /******/
30
+ /******/ // expose the modules object (__webpack_modules__)
31
+ /******/ __webpack_require__.m = modules;
32
+ /******/
33
+ /******/ // expose the module cache
34
+ /******/ __webpack_require__.c = installedModules;
35
+ /******/
36
+ /******/ // define getter function for harmony exports
37
+ /******/ __webpack_require__.d = function(exports, name, getter) {
38
+ /******/ if(!__webpack_require__.o(exports, name)) {
39
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40
+ /******/ }
41
+ /******/ };
42
+ /******/
43
+ /******/ // define __esModule on exports
44
+ /******/ __webpack_require__.r = function(exports) {
45
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47
+ /******/ }
48
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
49
+ /******/ };
50
+ /******/
51
+ /******/ // create a fake namespace object
52
+ /******/ // mode & 1: value is a module id, require it
53
+ /******/ // mode & 2: merge all properties of value into the ns
54
+ /******/ // mode & 4: return value when already ns object
55
+ /******/ // mode & 8|1: behave like require
56
+ /******/ __webpack_require__.t = function(value, mode) {
57
+ /******/ if(mode & 1) value = __webpack_require__(value);
58
+ /******/ if(mode & 8) return value;
59
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60
+ /******/ var ns = Object.create(null);
61
+ /******/ __webpack_require__.r(ns);
62
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64
+ /******/ return ns;
65
+ /******/ };
66
+ /******/
67
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
68
+ /******/ __webpack_require__.n = function(module) {
69
+ /******/ var getter = module && module.__esModule ?
70
+ /******/ function getDefault() { return module['default']; } :
71
+ /******/ function getModuleExports() { return module; };
72
+ /******/ __webpack_require__.d(getter, 'a', getter);
73
+ /******/ return getter;
74
+ /******/ };
75
+ /******/
76
+ /******/ // Object.prototype.hasOwnProperty.call
77
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78
+ /******/
79
+ /******/ // __webpack_public_path__
80
+ /******/ __webpack_require__.p = "";
81
+ /******/
82
+ /******/
83
+ /******/ // Load entry module and return exports
84
+ /******/ return __webpack_require__(__webpack_require__.s = 0);
85
+ /******/ })
86
+ /************************************************************************/
87
+ /******/ ({
88
+
89
+ /***/ "./assets/jsx/block.jsx":
90
+ /*!******************************!*\
91
+ !*** ./assets/jsx/block.jsx ***!
92
+ \******************************/
93
+ /*! no static exports found */
94
+ /***/ (function(module, exports, __webpack_require__) {
95
+
96
+ "use strict";
97
+
98
+
99
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
100
+
101
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
102
+
103
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
104
+
105
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
106
+
107
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
108
+
109
+ (function (wp, config) {
110
+ var registerPlugin = wp.plugins.registerPlugin;
111
+ var __ = wp.i18n.__;
112
+ var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;
113
+ var _wp$components = wp.components,
114
+ PanelRow = _wp$components.PanelRow,
115
+ DateTimePicker = _wp$components.DateTimePicker,
116
+ CheckboxControl = _wp$components.CheckboxControl,
117
+ SelectControl = _wp$components.SelectControl,
118
+ FormTokenField = _wp$components.FormTokenField,
119
+ Spinner = _wp$components.Spinner;
120
+ var _wp$element = wp.element,
121
+ Fragment = _wp$element.Fragment,
122
+ Component = _wp$element.Component;
123
+ var decodeEntities = wp.htmlEntities.decodeEntities;
124
+ var _lodash = lodash,
125
+ isEmpty = _lodash.isEmpty,
126
+ keys = _lodash.keys,
127
+ compact = _lodash.compact;
128
+
129
+ var PostExpiratorSidebar = function (_Component) {
130
+ _inherits(PostExpiratorSidebar, _Component);
131
+
132
+ function PostExpiratorSidebar() {
133
+ _classCallCheck(this, PostExpiratorSidebar);
134
+
135
+ var _this = _possibleConstructorReturn(this, (PostExpiratorSidebar.__proto__ || Object.getPrototypeOf(PostExpiratorSidebar)).apply(this, arguments));
136
+
137
+ _this.state = {
138
+ categoriesList: [],
139
+ catIdVsName: []
140
+ };
141
+ return _this;
142
+ }
143
+
144
+ _createClass(PostExpiratorSidebar, [{
145
+ key: 'componentWillMount',
146
+ value: function componentWillMount() {
147
+ var _this2 = this;
148
+
149
+ var attributes = this.state.attributes;
150
+
151
+
152
+ var postMeta = wp.data.select('core/editor').getEditedPostAttribute('meta');
153
+ var postType = wp.data.select('core/editor').getCurrentPostType();
154
+
155
+ var enabled = config.defaults.autoEnable == 1;
156
+ var date = new Date();
157
+
158
+ var expireAction = this.getExpireType(postMeta);
159
+
160
+ var categories = [];
161
+ if (expireAction.includes('category')) {
162
+ categories = this.getCategories(postMeta);
163
+ }
164
+
165
+ if (postMeta['_expiration-date-status'] && postMeta['_expiration-date-status'] === 'saved') {
166
+ enabled = true;
167
+ }
168
+
169
+ if (postMeta['_expiration-date']) {
170
+ date.setTime((postMeta['_expiration-date'] + date.getTimezoneOffset() * 60) * 1000);
171
+ } else {
172
+ categories = config.default_categories;
173
+ if (config.default_date) {
174
+ date.setTime((parseInt(config.default_date) + date.getTimezoneOffset() * 60) * 1000);
175
+ }
176
+ }
177
+
178
+ var taxonomy = config.defaults.taxonomy || 'category';
179
+
180
+ this.setState({
181
+ enabled: enabled,
182
+ date: date,
183
+ expireAction: expireAction,
184
+ categories: categories,
185
+ taxonomy: taxonomy
186
+ });
187
+
188
+ var categoriesList = [];
189
+ var catIdVsName = [];
190
+
191
+ if (!taxonomy && postType === 'post' || taxonomy === 'category') {
192
+ wp.apiFetch({
193
+ path: wp.url.addQueryArgs('wp/v2/categories', { per_page: -1, hide_empty: false })
194
+ }).then(function (list) {
195
+ list.forEach(function (cat) {
196
+ categoriesList[cat.name] = cat;
197
+ catIdVsName[cat.id] = cat.name;
198
+ });
199
+ _this2.setState({ categoriesList: categoriesList, catIdVsName: catIdVsName, taxonomy: __('Category') });
200
+ });
201
+ } else if (postType !== 'page') {
202
+ wp.apiFetch({
203
+ path: wp.url.addQueryArgs('wp/v2/taxonomies/' + taxonomy, { context: 'edit' })
204
+ }).then(function (taxAttributes) {
205
+ // fetch all terms
206
+ wp.apiFetch({
207
+ path: wp.url.addQueryArgs('wp/v2/' + taxAttributes.rest_base, { context: 'edit' })
208
+ }).then(function (terms) {
209
+ terms.forEach(function (term) {
210
+ categoriesList[decodeEntities(term.name)] = term;
211
+ catIdVsName[term.id] = decodeEntities(term.name);
212
+ });
213
+ _this2.setState({ categoriesList: categoriesList, catIdVsName: catIdVsName, taxonomy: decodeEntities(taxAttributes.name) });
214
+ });
215
+ });
216
+ }
217
+ }
218
+ }, {
219
+ key: 'componentDidUpdate',
220
+ value: function componentDidUpdate() {
221
+ var _state = this.state,
222
+ enabled = _state.enabled,
223
+ date = _state.date,
224
+ expireAction = _state.expireAction,
225
+ categories = _state.categories,
226
+ attribute = _state.attribute;
227
+
228
+ var setPostMeta = function setPostMeta(newMeta) {
229
+ return wp.data.dispatch('core/editor').editPost({ meta: newMeta });
230
+ };
231
+ var postMeta = wp.data.select('core/editor').getEditedPostAttribute('meta');
232
+
233
+ switch (attribute) {
234
+ case 'enabled':
235
+ setPostMeta({ '_expiration-date-status': enabled ? 'saved' : '' });
236
+ // if date is not set when the checkbox is enabled, set it to the default date
237
+ // this is to prevent the user from having to click the date to set it
238
+ if (!postMeta['_expiration-date']) {
239
+ setPostMeta({ '_expiration-date': this.getDate(date) });
240
+ }
241
+ break;
242
+ case 'date':
243
+ if (typeof date === 'string') {
244
+ setPostMeta({ '_expiration-date': this.getDate(date) });
245
+ }
246
+ break;
247
+ case 'action':
248
+ setPostMeta({ '_expiration-date-type': expireAction });
249
+ if (!expireAction.includes('category')) {
250
+ setPostMeta({ '_expiration-date-categories': [] });
251
+ }
252
+ break;
253
+ case 'category':
254
+ setPostMeta({ '_expiration-date-categories': categories });
255
+ break;
256
+ }
257
+ }
258
+ }, {
259
+ key: 'render',
260
+ value: function render() {
261
+ var _this3 = this;
262
+
263
+ var _state2 = this.state,
264
+ categoriesList = _state2.categoriesList,
265
+ catIdVsName = _state2.catIdVsName;
266
+ var _state3 = this.state,
267
+ enabled = _state3.enabled,
268
+ date = _state3.date,
269
+ expireAction = _state3.expireAction,
270
+ categories = _state3.categories,
271
+ taxonomy = _state3.taxonomy;
272
+
273
+
274
+ var postType = wp.data.select('core/editor').getCurrentPostType();
275
+
276
+ var actionsList = [{ label: __('Draft', 'post-expirator'), value: 'draft' }, { label: __('Delete', 'post-expirator'), value: 'delete' }, { label: __('Trash', 'post-expirator'), value: 'trash' }, { label: __('Private', 'post-expirator'), value: 'private' }, { label: __('Stick', 'post-expirator'), value: 'stick' }, { label: __('Unstick', 'post-expirator'), value: 'unstick' }];
277
+
278
+ if (postType !== 'page') {
279
+ actionsList = _.union(actionsList, [{ label: __('Category: Replace', 'post-expirator'), value: 'category' }, { label: __('Category: Add', 'post-expirator'), value: 'category-add' }, { label: __('Category: Remove', 'post-expirator'), value: 'category-remove' }]);
280
+ }
281
+
282
+ var selectedCats = categories && compact(categories.map(function (id) {
283
+ return catIdVsName[id] || false;
284
+ }));
285
+ if (typeof selectedCats === 'string') {
286
+ selectedCats = [];
287
+ }
288
+
289
+ return React.createElement(
290
+ PluginDocumentSettingPanel,
291
+ { title: __('Post Expirator', 'post-expirator'), icon: 'calendar', initialOpen: enabled },
292
+ React.createElement(
293
+ PanelRow,
294
+ null,
295
+ React.createElement(CheckboxControl, {
296
+ label: __('Enable Post Expiration', 'post-expirator'),
297
+ checked: enabled,
298
+ onChange: function onChange(value) {
299
+ _this3.setState({ enabled: !enabled, attribute: 'enabled' });
300
+ }
301
+ })
302
+ ),
303
+ enabled && React.createElement(
304
+ Fragment,
305
+ null,
306
+ React.createElement(
307
+ PanelRow,
308
+ null,
309
+ React.createElement(DateTimePicker, {
310
+ currentDate: date,
311
+ onChange: function onChange(value) {
312
+ return _this3.setState({ date: value, attribute: 'date' });
313
+ },
314
+ is12Hour: true
315
+ })
316
+ ),
317
+ React.createElement(SelectControl, {
318
+ label: __('How to expire', 'post-expirator'),
319
+ value: expireAction,
320
+ options: actionsList,
321
+ onChange: function onChange(value) {
322
+ _this3.setState({ expireAction: value, attribute: 'action' });
323
+ }
324
+ }),
325
+ expireAction.includes('category') && (isEmpty(keys(categoriesList)) && React.createElement(
326
+ Fragment,
327
+ null,
328
+ __('Loading', 'post-expirator') + (' (' + taxonomy + ')'),
329
+ React.createElement(Spinner, null)
330
+ ) || React.createElement(FormTokenField, {
331
+ label: __('Expiration Categories', 'post-expirator') + (' (' + taxonomy + ')'),
332
+ value: selectedCats,
333
+ suggestions: Object.keys(categoriesList),
334
+ onChange: function onChange(value) {
335
+ _this3.setState({ categories: _this3.selectCategories(value), attribute: 'category' });
336
+ },
337
+ maxSuggestions: 10
338
+ }))
339
+ )
340
+ );
341
+ }
342
+
343
+ // what action to take on expiration
344
+
345
+ }, {
346
+ key: 'getExpireType',
347
+ value: function getExpireType(postMeta) {
348
+ var typeNew = postMeta['_expiration-date-type'];
349
+ var typeOld = postMeta['_expiration-date-options'] && postMeta['_expiration-date-options']['expireType'];
350
+
351
+ if (typeNew) {
352
+ return typeNew;
353
+ }
354
+
355
+ if (typeOld) {
356
+ return typeOld;
357
+ }
358
+
359
+ return 'draft';
360
+ }
361
+
362
+ // what categories to add/remove/replace
363
+
364
+ }, {
365
+ key: 'getCategories',
366
+ value: function getCategories(postMeta) {
367
+ var categoriesNew = postMeta['_expiration-date-categories'] && postMeta['_expiration-date-categories'];
368
+ var categoriesOld = postMeta['_expiration-date-options'] && postMeta['_expiration-date-options']['category'];
369
+
370
+ if ((typeof categoriesNew === 'undefined' ? 'undefined' : _typeof(categoriesNew)) === 'object' && categoriesNew.length > 0) {
371
+ return categoriesNew;
372
+ }
373
+
374
+ if (categoriesOld && typeof categoriesOld !== 'undefined' && (typeof categoriesOld === 'undefined' ? 'undefined' : _typeof(categoriesOld)) !== 'object') {
375
+ categories = [categoriesOld];
376
+ }
377
+
378
+ return categoriesOld;
379
+ }
380
+
381
+ // fired for the autocomplete
382
+
383
+ }, {
384
+ key: 'selectCategories',
385
+ value: function selectCategories(tokens) {
386
+ var _state4 = this.state,
387
+ categoriesList = _state4.categoriesList,
388
+ catIdVsName = _state4.catIdVsName;
389
+
390
+
391
+ var hasNoSuggestion = tokens.some(function (token) {
392
+ return typeof token === 'string' && !categoriesList[token];
393
+ });
394
+
395
+ if (hasNoSuggestion) {
396
+ return;
397
+ }
398
+
399
+ var categories = tokens.map(function (token) {
400
+ return typeof token === 'string' ? categoriesList[token] : token;
401
+ });
402
+
403
+ return categories.map(function (cat) {
404
+ return cat.id;
405
+ });
406
+ }
407
+ }, {
408
+ key: 'getDate',
409
+ value: function getDate(date) {
410
+ var newDate = new Date();
411
+ newDate.setTime(Date.parse(date));
412
+ newDate.setTime(newDate.getTime() - new Date().getTimezoneOffset() * 60 * 1000);
413
+ return newDate.getTime() / 1000;
414
+ }
415
+ }]);
416
+
417
+ return PostExpiratorSidebar;
418
+ }(Component);
419
+
420
+ registerPlugin('postexpirator-sidebar', {
421
+ render: PostExpiratorSidebar
422
+ });
423
+ })(window.wp, config);
424
+
425
+ /***/ }),
426
+
427
+ /***/ 0:
428
+ /*!************************************!*\
429
+ !*** multi ./assets/jsx/block.jsx ***!
430
+ \************************************/
431
+ /*! no static exports found */
432
+ /***/ (function(module, exports, __webpack_require__) {
433
+
434
+ module.exports = __webpack_require__(/*! ./assets/jsx/block.jsx */"./assets/jsx/block.jsx");
435
+
436
+
437
+ /***/ })
438
+
439
+ /******/ });
440
  //# sourceMappingURL=block.js.map
assets/js/block.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./assets/jsx/block.jsx"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","wp","config","registerPlugin","plugins","__","i18n","PluginDocumentSettingPanel","editPost","components","PanelRow","DateTimePicker","CheckboxControl","SelectControl","FormTokenField","Spinner","element","Fragment","Component","decodeEntities","htmlEntities","lodash","isEmpty","keys","compact","render","arguments","state","categoriesList","catIdVsName","newMeta","postMeta","this","attributes","data","select","getEditedPostAttribute","postType","getCurrentPostType","enabled","defaults","autoEnable","date","Date","expireAction","getExpireType","categories","includes","getCategories","setTime","getTimezoneOffset","default_categories","default_date","parseInt","getDate","dispatch","meta","taxonomy","setState","apiFetch","path","url","addQueryArgs","per_page","hide_empty","then","list","forEach","cat","id","context","taxAttributes","rest_base","terms","term","setPostMeta","attribute","actionsList","label","_","union","selectedCats","map","title","icon","initialOpen","checked","onChange","currentDate","is12Hour","options","suggestions","selectCategories","maxSuggestions","typeNew","typeOld","categoriesNew","categoriesOld","length","tokens","some","token","newDate","parse","getTime","window"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EA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G,GAAa,EAAKwE,SAAU,CAAEZ,WAAY,EAAK8C,iBAAiB1G,GAAQ0F,UAAW,cAChGiB,eAAiB,UA3L5B,oCAsMH9D,GACV,IAAI+D,EAAU/D,EAAS,yBACnBgE,EAAUhE,EAAS,6BAA+BA,EAAS,4BAAT,WAEtD,OAAG+D,IAIAC,GAII,WAlNM,oCAsNHhE,GACV,IAAIiE,EAAgBjE,EAAS,gCAAkCA,EAAS,+BACpEkE,EAAgBlE,EAAS,6BAA+BA,EAAS,4BAAT,SAE5D,MAA4B,iBAAzB,IAAOiE,EAAP,cAAOA,KAA8BA,EAAcE,OAAS,EACpDF,GAGRC,QAA0C,IAAlBA,GAA0D,iBAAzB,IAAOA,EAAP,cAAOA,MAC/DnD,WAAa,CAAEmD,IAGZA,KAlOM,uCAuOAE,GAAQ,MACmBnE,KAAKL,MAArCC,EADa,EACbA,eADa,EACGC,YAMxB,IAJsBsE,EAAOC,MAAK,SAAUC,GACxC,MAAwB,iBAAVA,IAAuBzE,EAAeyE,MAWxD,OAJiBF,EAAOjB,KAAI,SAAUmB,GAClC,MAAwB,iBAAVA,EAAqBzE,EAAeyE,GAASA,KAG7CnB,KAAK,SAACd,GAAD,OAASA,EAAIC,QAtPvB,8BAyPT3B,GACJ,IAAI4D,EAAU,IAAI3D,KAGlB,OAFA2D,EAAQrD,QAAQN,KAAK4D,MAAM7D,IAC3B4D,EAAQrD,QAAQqD,EAAQE,UAA6C,IAAjC,IAAI7D,MAAOO,oBAA2B,KACjEoD,EAAQE,UAAa,QA7PjB,GAUctF,KAVvC,CAuQIuF,OAAOxG,GAAIC","file":"block.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","(function ( wp, config ) {\r\n\r\n const { registerPlugin } = wp.plugins;\r\n const { __ } = wp.i18n;\r\n const { PluginDocumentSettingPanel } = wp.editPost;\r\n const { PanelRow, DateTimePicker, CheckboxControl, SelectControl, FormTokenField, Spinner } = wp.components;\r\n const { Fragment, Component } = wp.element;\r\n const { decodeEntities } = wp.htmlEntities;\r\n const { isEmpty, keys, compact } = lodash;\r\n\r\n class PostExpiratorSidebar extends Component {\r\n constructor() {\r\n super( ...arguments );\r\n\r\n this.state = {\r\n categoriesList: [],\r\n catIdVsName: [],\r\n }\r\n }\r\n\r\n componentWillMount() {\r\n const { attributes } = this.state;\r\n\r\n const postMeta = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'meta' );\r\n const postType = wp.data.select('core/editor').getCurrentPostType();\r\n\r\n let enabled = config.defaults.autoEnable == 1;\r\n let date = new Date();\r\n\r\n let expireAction = this.getExpireType(postMeta);\r\n\r\n let categories = [];\r\n if(expireAction.includes('category')){\r\n categories = this.getCategories(postMeta);\r\n }\r\n\r\n if(postMeta['_expiration-date-status'] && postMeta['_expiration-date-status'] === 'saved'){\r\n enabled = true;\r\n }\r\n\r\n if(postMeta['_expiration-date']){\r\n date.setTime((postMeta['_expiration-date'] + date.getTimezoneOffset() * 60) * 1000);\r\n }else{\r\n categories = config.default_categories;\r\n if(config.default_date){\r\n date.setTime((parseInt(config.default_date) + date.getTimezoneOffset() * 60) * 1000);\r\n // update the post meta for date so that the user does not have to click the date to set it\r\n const setPostMeta = (newMeta) => wp.data.dispatch( 'core/editor' ).editPost( { meta: newMeta } );\r\n setPostMeta( {'_expiration-date': this.getDate(date) } );\r\n }\r\n }\r\n\r\n let taxonomy = config.defaults.taxonomy || 'category';\r\n\r\n this.setState( {\r\n enabled: enabled,\r\n date: date,\r\n expireAction: expireAction,\r\n categories: categories,\r\n taxonomy: taxonomy,\r\n } );\r\n\r\n let categoriesList = [];\r\n let catIdVsName = [];\r\n\r\n if( (!taxonomy && postType === 'post') || taxonomy === 'category' ){\r\n wp.apiFetch( {\r\n path: wp.url.addQueryArgs( 'wp/v2/categories', { per_page: -1, hide_empty: false } ),\r\n } ).then( ( list ) => {\r\n list.forEach(cat => {\r\n categoriesList[ cat.name ] = cat;\r\n catIdVsName[ cat.id ] = cat.name;\r\n });\r\n this.setState( { categoriesList: categoriesList, catIdVsName: catIdVsName, taxonomy: __( 'Category' ) } );\r\n } );\r\n }else if(postType !== 'page') {\r\n wp.apiFetch( {\r\n path: wp.url.addQueryArgs( `wp/v2/taxonomies/${taxonomy}`, { context: 'edit' } ),\r\n } ).then( ( taxAttributes ) => {\r\n // fetch all terms\r\n wp.apiFetch( {\r\n path: wp.url.addQueryArgs( `wp/v2/${taxAttributes.rest_base}`, { context: 'edit' } ),\r\n } ).then( ( terms ) => {\r\n terms.forEach(term => {\r\n categoriesList[ decodeEntities(term.name) ] = term;\r\n catIdVsName[ term.id ] = decodeEntities(term.name);\r\n });\r\n this.setState( { categoriesList: categoriesList, catIdVsName: catIdVsName, taxonomy: decodeEntities(taxAttributes.name) } );\r\n });\r\n });\r\n }\r\n\r\n }\r\n\r\n componentDidUpdate() {\r\n const { enabled, date, expireAction, categories, attribute } = this.state;\r\n const setPostMeta = (newMeta) => wp.data.dispatch( 'core/editor' ).editPost( { meta: newMeta } );\r\n\r\n switch(attribute){\r\n case 'enabled':\r\n setPostMeta( { '_expiration-date-status' : (enabled ? 'saved' : '' ) } );\r\n break;\r\n case 'date':\r\n if(typeof date === 'string'){\r\n setPostMeta( {'_expiration-date': this.getDate(date) } );\r\n }\r\n break;\r\n case 'action':\r\n setPostMeta( { '_expiration-date-type': expireAction } );\r\n if(!expireAction.includes('category')){\r\n setPostMeta( { '_expiration-date-categories': [] } );\r\n }\r\n break;\r\n case 'category':\r\n setPostMeta( { '_expiration-date-categories': categories } );\r\n break;\r\n }\r\n\r\n }\r\n\r\n render() {\r\n const { categoriesList, catIdVsName } = this.state;\r\n const { enabled, date, expireAction, categories, taxonomy } = this.state;\r\n\r\n const postType = wp.data.select('core/editor').getCurrentPostType();\r\n\r\n let actionsList = [\r\n { label: __( 'Draft', 'post-expirator' ), value: 'draft' },\r\n { label: __( 'Delete', 'post-expirator' ), value: 'delete' },\r\n { label: __( 'Trash', 'post-expirator' ), value: 'trash' },\r\n { label: __( 'Private', 'post-expirator' ), value: 'private' },\r\n { label: __( 'Stick', 'post-expirator' ), value: 'stick' },\r\n { label: __( 'Unstick', 'post-expirator' ), value: 'unstick' },\r\n ];\r\n\r\n if(postType !== 'page'){\r\n actionsList = _.union(actionsList, [\r\n { label: __('Category: Replace', 'post-expirator'), value: 'category' },\r\n { label: __('Category: Add', 'post-expirator'), value: 'category-add' },\r\n { label: __('Category: Remove', 'post-expirator'), value: 'category-remove' },\r\n ]);\r\n }\r\n\r\n let selectedCats = categories && compact(categories.map((id) => catIdVsName[id] || false ));\r\n if(typeof selectedCats === 'string'){\r\n selectedCats = [];\r\n }\r\n \r\n return (\r\n <PluginDocumentSettingPanel title={ __( 'Post Expirator', 'post-expirator' ) } icon=\"calendar\" initialOpen={ enabled }>\r\n <PanelRow>\r\n <CheckboxControl\r\n label={ __( 'Enable Post Expiration', 'post-expirator' ) }\r\n checked={ enabled }\r\n onChange={ (value) => { this.setState( { enabled: !enabled, attribute: 'enabled' } ) } }\r\n />\r\n </PanelRow>\r\n { enabled && (\r\n <Fragment>\r\n <PanelRow>\r\n <DateTimePicker\r\n currentDate={ date }\r\n onChange={ ( value ) => this.setState( { date: value, attribute: 'date' } ) }\r\n is12Hour={ true }\r\n />\r\n </PanelRow>\r\n <SelectControl\r\n label={ __( 'How to expire', 'post-expirator' ) }\r\n value={ expireAction }\r\n options={ actionsList }\r\n onChange={ (value) => { this.setState( { expireAction: value, attribute: 'action' } ) } }\r\n />\r\n { expireAction.includes('category') && \r\n (\r\n ( isEmpty(keys(categoriesList)) && (\r\n <Fragment>\r\n { __( 'Loading', 'post-expirator' ) + ` (${taxonomy})` }\r\n <Spinner/>\r\n </Fragment>\r\n ) )\r\n ||\r\n (\r\n <FormTokenField\r\n label={ __('Expiration Categories', 'post-expirator') + ` (${taxonomy})` }\r\n value={ selectedCats }\r\n suggestions={ Object.keys(categoriesList) }\r\n onChange={ ( value ) => { this.setState( { categories: this.selectCategories(value), attribute: 'category' } ) } }\r\n maxSuggestions={ 10 }\r\n />\r\n )\r\n ) }\r\n </Fragment>\r\n ) }\r\n </PluginDocumentSettingPanel>\r\n );\r\n }\r\n\r\n // what action to take on expiration\r\n getExpireType(postMeta) {\r\n let typeNew = postMeta['_expiration-date-type'];\r\n let typeOld = postMeta['_expiration-date-options'] && postMeta['_expiration-date-options']['expireType'];\r\n\r\n if(typeNew){\r\n return typeNew;\r\n }\r\n\r\n if(typeOld){\r\n return typeOld;\r\n }\r\n\r\n return 'draft';\r\n }\r\n\r\n // what categories to add/remove/replace\r\n getCategories(postMeta) {\r\n let categoriesNew = postMeta['_expiration-date-categories'] && postMeta['_expiration-date-categories'];\r\n let categoriesOld = postMeta['_expiration-date-options'] && postMeta['_expiration-date-options']['category'];\r\n\r\n if(typeof categoriesNew === 'object' && categoriesNew.length > 0){\r\n return categoriesNew;\r\n }\r\n\r\n if(categoriesOld && typeof categoriesOld !== 'undefined' && typeof categoriesOld !== 'object'){\r\n categories = [ categoriesOld ];\r\n }\r\n\r\n return categoriesOld;\r\n\r\n }\r\n\r\n // fired for the autocomplete\r\n selectCategories(tokens) {\r\n const { categoriesList, catIdVsName } = this.state;\r\n\r\n var hasNoSuggestion = tokens.some(function (token) {\r\n return typeof token === 'string' && !categoriesList[token];\r\n });\r\n\r\n if (hasNoSuggestion) {\r\n return;\r\n }\r\n\r\n var categories = tokens.map(function (token) {\r\n return typeof token === 'string' ? categoriesList[token] : token;\r\n })\r\n\r\n return categories.map( (cat) => cat.id );\r\n }\r\n\r\n getDate(date){\r\n let newDate = new Date();\r\n newDate.setTime(Date.parse(date));\r\n newDate.setTime(newDate.getTime() - new Date().getTimezoneOffset() * 60 * 1000);\r\n return ((newDate.getTime()) / 1000);\r\n }\r\n\r\n }\r\n\r\n registerPlugin( 'postexpirator-sidebar', {\r\n render: PostExpiratorSidebar\r\n } );\r\n\r\n\r\n})( window.wp, config );"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./assets/jsx/block.jsx"],"names":["wp","config","registerPlugin","plugins","__","i18n","PluginDocumentSettingPanel","editPost","components","PanelRow","DateTimePicker","CheckboxControl","SelectControl","FormTokenField","Spinner","element","Fragment","Component","decodeEntities","htmlEntities","lodash","isEmpty","keys","compact","PostExpiratorSidebar","arguments","state","categoriesList","catIdVsName","attributes","postMeta","data","select","getEditedPostAttribute","postType","getCurrentPostType","enabled","defaults","autoEnable","date","Date","expireAction","getExpireType","categories","includes","getCategories","setTime","getTimezoneOffset","default_categories","default_date","parseInt","taxonomy","setState","apiFetch","path","url","addQueryArgs","per_page","hide_empty","then","list","forEach","cat","name","id","context","taxAttributes","rest_base","terms","term","attribute","setPostMeta","newMeta","dispatch","meta","getDate","actionsList","label","value","_","union","selectedCats","map","Object","selectCategories","typeNew","typeOld","categoriesNew","categoriesOld","length","tokens","hasNoSuggestion","some","token","newDate","parse","getTime","render","window"],"mappings":";QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,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E,KADxB;AAAA,oBACbC,cADa,WACbA,cADa;AAAA,oBACGC,WADH,WACGA,WADH;;;AAGrB,oBAAI+D,kBAAkBD,OAAOE,IAAP,CAAY,UAAUC,KAAV,EAAiB;AAC/C,2BAAO,OAAOA,KAAP,KAAiB,QAAjB,IAA6B,CAAClE,eAAekE,KAAf,CAArC;AACH,iBAFqB,CAAtB;;AAIA,oBAAIF,eAAJ,EAAqB;AACjB;AACH;;AAED,oBAAIhD,aAAa+C,OAAOR,GAAP,CAAW,UAAUW,KAAV,EAAiB;AACzC,2BAAO,OAAOA,KAAP,KAAiB,QAAjB,GAA4BlE,eAAekE,KAAf,CAA5B,GAAoDA,KAA3D;AACH,iBAFgB,CAAjB;;AAIA,uBAAOlD,WAAWuC,GAAX,CAAgB,UAACpB,GAAD;AAAA,2BAASA,IAAIE,EAAb;AAAA,iBAAhB,CAAP;AACH;AA1PgB;AAAA;AAAA,oCA4PTzB,IA5PS,EA4PJ;AACT,oBAAIuD,UAAU,IAAItD,IAAJ,EAAd;AACAsD,wBAAQhD,OAAR,CAAgBN,KAAKuD,KAAL,CAAWxD,IAAX,CAAhB;AACAuD,wBAAQhD,OAAR,CAAgBgD,QAAQE,OAAR,KAAoB,IAAIxD,IAAJ,GAAWO,iBAAX,KAAiC,EAAjC,GAAsC,IAA1E;AACA,uBAAS+C,QAAQE,OAAR,EAAD,GAAsB,IAA9B;AACH;AAjQgB;;AAAA;AAAA,MAUc/E,SAVd;;AAqQrBf,mBAAgB,uBAAhB,EAAyC;AACrC+F,gBAAQzE;AAD6B,KAAzC;AAKH,CA1QD,EA0QI0E,OAAOlG,EA1QX,EA0QeC,MA1Qf,E","file":"block.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","(function ( wp, config ) {\r\n\r\n const { registerPlugin } = wp.plugins;\r\n const { __ } = wp.i18n;\r\n const { PluginDocumentSettingPanel } = wp.editPost;\r\n const { PanelRow, DateTimePicker, CheckboxControl, SelectControl, FormTokenField, Spinner } = wp.components;\r\n const { Fragment, Component } = wp.element;\r\n const { decodeEntities } = wp.htmlEntities;\r\n const { isEmpty, keys, compact } = lodash;\r\n\r\n class PostExpiratorSidebar extends Component {\r\n constructor() {\r\n super( ...arguments );\r\n\r\n this.state = {\r\n categoriesList: [],\r\n catIdVsName: [],\r\n }\r\n }\r\n\r\n componentWillMount() {\r\n const { attributes } = this.state;\r\n\r\n const postMeta = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'meta' );\r\n const postType = wp.data.select('core/editor').getCurrentPostType();\r\n\r\n let enabled = config.defaults.autoEnable == 1;\r\n let date = new Date();\r\n\r\n let expireAction = this.getExpireType(postMeta);\r\n\r\n let categories = [];\r\n if(expireAction.includes('category')){\r\n categories = this.getCategories(postMeta);\r\n }\r\n\r\n if(postMeta['_expiration-date-status'] && postMeta['_expiration-date-status'] === 'saved'){\r\n enabled = true;\r\n }\r\n\r\n if(postMeta['_expiration-date']){\r\n date.setTime((postMeta['_expiration-date'] + date.getTimezoneOffset() * 60) * 1000);\r\n }else{\r\n categories = config.default_categories;\r\n if(config.default_date){\r\n date.setTime((parseInt(config.default_date) + date.getTimezoneOffset() * 60) * 1000);\r\n }\r\n }\r\n\r\n let taxonomy = config.defaults.taxonomy || 'category';\r\n\r\n this.setState( {\r\n enabled: enabled,\r\n date: date,\r\n expireAction: expireAction,\r\n categories: categories,\r\n taxonomy: taxonomy,\r\n } );\r\n\r\n let categoriesList = [];\r\n let catIdVsName = [];\r\n\r\n if( (!taxonomy && postType === 'post') || taxonomy === 'category' ){\r\n wp.apiFetch( {\r\n path: wp.url.addQueryArgs( 'wp/v2/categories', { per_page: -1, hide_empty: false } ),\r\n } ).then( ( list ) => {\r\n list.forEach(cat => {\r\n categoriesList[ cat.name ] = cat;\r\n catIdVsName[ cat.id ] = cat.name;\r\n });\r\n this.setState( { categoriesList: categoriesList, catIdVsName: catIdVsName, taxonomy: __( 'Category' ) } );\r\n } );\r\n }else if(postType !== 'page') {\r\n wp.apiFetch( {\r\n path: wp.url.addQueryArgs( `wp/v2/taxonomies/${taxonomy}`, { context: 'edit' } ),\r\n } ).then( ( taxAttributes ) => {\r\n // fetch all terms\r\n wp.apiFetch( {\r\n path: wp.url.addQueryArgs( `wp/v2/${taxAttributes.rest_base}`, { context: 'edit' } ),\r\n } ).then( ( terms ) => {\r\n terms.forEach(term => {\r\n categoriesList[ decodeEntities(term.name) ] = term;\r\n catIdVsName[ term.id ] = decodeEntities(term.name);\r\n });\r\n this.setState( { categoriesList: categoriesList, catIdVsName: catIdVsName, taxonomy: decodeEntities(taxAttributes.name) } );\r\n });\r\n });\r\n }\r\n\r\n }\r\n\r\n componentDidUpdate() {\r\n const { enabled, date, expireAction, categories, attribute } = this.state;\r\n const setPostMeta = (newMeta) => wp.data.dispatch( 'core/editor' ).editPost( { meta: newMeta } );\r\n const postMeta = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'meta' );\r\n\r\n switch(attribute){\r\n case 'enabled':\r\n setPostMeta( { '_expiration-date-status' : (enabled ? 'saved' : '' ) } );\r\n // if date is not set when the checkbox is enabled, set it to the default date\r\n // this is to prevent the user from having to click the date to set it\r\n if(!postMeta['_expiration-date']){\r\n setPostMeta( {'_expiration-date': this.getDate(date) } );\r\n }\r\n break;\r\n case 'date':\r\n if(typeof date === 'string'){\r\n setPostMeta( {'_expiration-date': this.getDate(date) } );\r\n }\r\n break;\r\n case 'action':\r\n setPostMeta( { '_expiration-date-type': expireAction } );\r\n if(!expireAction.includes('category')){\r\n setPostMeta( { '_expiration-date-categories': [] } );\r\n }\r\n break;\r\n case 'category':\r\n setPostMeta( { '_expiration-date-categories': categories } );\r\n break;\r\n }\r\n\r\n }\r\n\r\n render() {\r\n const { categoriesList, catIdVsName } = this.state;\r\n const { enabled, date, expireAction, categories, taxonomy } = this.state;\r\n\r\n const postType = wp.data.select('core/editor').getCurrentPostType();\r\n\r\n let actionsList = [\r\n { label: __( 'Draft', 'post-expirator' ), value: 'draft' },\r\n { label: __( 'Delete', 'post-expirator' ), value: 'delete' },\r\n { label: __( 'Trash', 'post-expirator' ), value: 'trash' },\r\n { label: __( 'Private', 'post-expirator' ), value: 'private' },\r\n { label: __( 'Stick', 'post-expirator' ), value: 'stick' },\r\n { label: __( 'Unstick', 'post-expirator' ), value: 'unstick' },\r\n ];\r\n\r\n if(postType !== 'page'){\r\n actionsList = _.union(actionsList, [\r\n { label: __('Category: Replace', 'post-expirator'), value: 'category' },\r\n { label: __('Category: Add', 'post-expirator'), value: 'category-add' },\r\n { label: __('Category: Remove', 'post-expirator'), value: 'category-remove' },\r\n ]);\r\n }\r\n\r\n let selectedCats = categories && compact(categories.map((id) => catIdVsName[id] || false ));\r\n if(typeof selectedCats === 'string'){\r\n selectedCats = [];\r\n }\r\n \r\n return (\r\n <PluginDocumentSettingPanel title={ __( 'Post Expirator', 'post-expirator' ) } icon=\"calendar\" initialOpen={ enabled }>\r\n <PanelRow>\r\n <CheckboxControl\r\n label={ __( 'Enable Post Expiration', 'post-expirator' ) }\r\n checked={ enabled }\r\n onChange={ (value) => { this.setState( { enabled: !enabled, attribute: 'enabled' } ) } }\r\n />\r\n </PanelRow>\r\n { enabled && (\r\n <Fragment>\r\n <PanelRow>\r\n <DateTimePicker\r\n currentDate={ date }\r\n onChange={ ( value ) => this.setState( { date: value, attribute: 'date' } ) }\r\n is12Hour={ true }\r\n />\r\n </PanelRow>\r\n <SelectControl\r\n label={ __( 'How to expire', 'post-expirator' ) }\r\n value={ expireAction }\r\n options={ actionsList }\r\n onChange={ (value) => { this.setState( { expireAction: value, attribute: 'action' } ) } }\r\n />\r\n { expireAction.includes('category') && \r\n (\r\n ( isEmpty(keys(categoriesList)) && (\r\n <Fragment>\r\n { __( 'Loading', 'post-expirator' ) + ` (${taxonomy})` }\r\n <Spinner/>\r\n </Fragment>\r\n ) )\r\n ||\r\n (\r\n <FormTokenField\r\n label={ __('Expiration Categories', 'post-expirator') + ` (${taxonomy})` }\r\n value={ selectedCats }\r\n suggestions={ Object.keys(categoriesList) }\r\n onChange={ ( value ) => { this.setState( { categories: this.selectCategories(value), attribute: 'category' } ) } }\r\n maxSuggestions={ 10 }\r\n />\r\n )\r\n ) }\r\n </Fragment>\r\n ) }\r\n </PluginDocumentSettingPanel>\r\n );\r\n }\r\n\r\n // what action to take on expiration\r\n getExpireType(postMeta) {\r\n let typeNew = postMeta['_expiration-date-type'];\r\n let typeOld = postMeta['_expiration-date-options'] && postMeta['_expiration-date-options']['expireType'];\r\n\r\n if(typeNew){\r\n return typeNew;\r\n }\r\n\r\n if(typeOld){\r\n return typeOld;\r\n }\r\n\r\n return 'draft';\r\n }\r\n\r\n // what categories to add/remove/replace\r\n getCategories(postMeta) {\r\n let categoriesNew = postMeta['_expiration-date-categories'] && postMeta['_expiration-date-categories'];\r\n let categoriesOld = postMeta['_expiration-date-options'] && postMeta['_expiration-date-options']['category'];\r\n\r\n if(typeof categoriesNew === 'object' && categoriesNew.length > 0){\r\n return categoriesNew;\r\n }\r\n\r\n if(categoriesOld && typeof categoriesOld !== 'undefined' && typeof categoriesOld !== 'object'){\r\n categories = [ categoriesOld ];\r\n }\r\n\r\n return categoriesOld;\r\n\r\n }\r\n\r\n // fired for the autocomplete\r\n selectCategories(tokens) {\r\n const { categoriesList, catIdVsName } = this.state;\r\n\r\n var hasNoSuggestion = tokens.some(function (token) {\r\n return typeof token === 'string' && !categoriesList[token];\r\n });\r\n\r\n if (hasNoSuggestion) {\r\n return;\r\n }\r\n\r\n var categories = tokens.map(function (token) {\r\n return typeof token === 'string' ? categoriesList[token] : token;\r\n })\r\n\r\n return categories.map( (cat) => cat.id );\r\n }\r\n\r\n getDate(date){\r\n let newDate = new Date();\r\n newDate.setTime(Date.parse(date));\r\n newDate.setTime(newDate.getTime() - new Date().getTimezoneOffset() * 60 * 1000);\r\n return ((newDate.getTime()) / 1000);\r\n }\r\n\r\n }\r\n\r\n registerPlugin( 'postexpirator-sidebar', {\r\n render: PostExpiratorSidebar\r\n } );\r\n\r\n\r\n})( window.wp, config );"],"sourceRoot":""}
assets/jsx/block.jsx CHANGED
@@ -44,9 +44,6 @@
44
  categories = config.default_categories;
45
  if(config.default_date){
46
  date.setTime((parseInt(config.default_date) + date.getTimezoneOffset() * 60) * 1000);
47
- // update the post meta for date so that the user does not have to click the date to set it
48
- const setPostMeta = (newMeta) => wp.data.dispatch( 'core/editor' ).editPost( { meta: newMeta } );
49
- setPostMeta( {'_expiration-date': this.getDate(date) } );
50
  }
51
  }
52
 
@@ -95,10 +92,16 @@
95
  componentDidUpdate() {
96
  const { enabled, date, expireAction, categories, attribute } = this.state;
97
  const setPostMeta = (newMeta) => wp.data.dispatch( 'core/editor' ).editPost( { meta: newMeta } );
 
98
 
99
  switch(attribute){
100
  case 'enabled':
101
  setPostMeta( { '_expiration-date-status' : (enabled ? 'saved' : '' ) } );
 
 
 
 
 
102
  break;
103
  case 'date':
104
  if(typeof date === 'string'){
44
  categories = config.default_categories;
45
  if(config.default_date){
46
  date.setTime((parseInt(config.default_date) + date.getTimezoneOffset() * 60) * 1000);
 
 
 
47
  }
48
  }
49
 
92
  componentDidUpdate() {
93
  const { enabled, date, expireAction, categories, attribute } = this.state;
94
  const setPostMeta = (newMeta) => wp.data.dispatch( 'core/editor' ).editPost( { meta: newMeta } );
95
+ const postMeta = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'meta' );
96
 
97
  switch(attribute){
98
  case 'enabled':
99
  setPostMeta( { '_expiration-date-status' : (enabled ? 'saved' : '' ) } );
100
+ // if date is not set when the checkbox is enabled, set it to the default date
101
+ // this is to prevent the user from having to click the date to set it
102
+ if(!postMeta['_expiration-date']){
103
+ setPostMeta( {'_expiration-date': this.getDate(date) } );
104
+ }
105
  break;
106
  case 'date':
107
  if(typeof date === 'string'){
classes/Display.class.php CHANGED
@@ -223,9 +223,7 @@ class PostExpirator_Display {
223
  update_option( 'expirationdateFooterContents', $_POST['expired-footer-contents'] );
224
  update_option( 'expirationdateFooterStyle', $_POST['expired-footer-style'] );
225
  update_option( 'expirationdateGutenbergSupport', $_POST['gutenberg-support'] );
226
- if ( isset( $_POST['expirationdate_category'] ) ) {
227
- update_option( 'expirationdateCategoryDefaults', $_POST['expirationdate_category'] );
228
- }
229
  update_option( 'expirationdateDefaultDate', $_POST['expired-default-expiration-date'] );
230
  if ( $_POST['expired-custom-expiration-date'] ) {
231
  update_option( 'expirationdateDefaultDateCustom', $_POST['expired-custom-expiration-date'] );
223
  update_option( 'expirationdateFooterContents', $_POST['expired-footer-contents'] );
224
  update_option( 'expirationdateFooterStyle', $_POST['expired-footer-style'] );
225
  update_option( 'expirationdateGutenbergSupport', $_POST['gutenberg-support'] );
226
+ update_option( 'expirationdateCategoryDefaults', isset( $_POST['expirationdate_category'] ) ? $_POST['expirationdate_category'] : array() );
 
 
227
  update_option( 'expirationdateDefaultDate', $_POST['expired-default-expiration-date'] );
228
  if ( $_POST['expired-custom-expiration-date'] ) {
229
  update_option( 'expirationdateDefaultDateCustom', $_POST['expired-custom-expiration-date'] );
composer.json CHANGED
@@ -26,7 +26,7 @@
26
  }
27
  ],
28
  "dist": {
29
- "url": "https://github.com/publishpress/PublishPress-Future/releases/download/v2.5.0/publishpress-authors-2.5.0.zip",
30
  "type": "zip"
31
  },
32
  "require-dev": {
26
  }
27
  ],
28
  "dist": {
29
+ "url": "https://github.com/publishpress/PublishPress-Future/releases/download/v2.5.1/post-expirator-2.5.1.zip",
30
  "type": "zip"
31
  },
32
  "require-dev": {
composer.lock CHANGED
@@ -9,16 +9,16 @@
9
  "packages-dev": [
10
  {
11
  "name": "consolidation/annotated-command",
12
- "version": "4.3.1",
13
  "source": {
14
  "type": "git",
15
  "url": "https://github.com/consolidation/annotated-command.git",
16
- "reference": "386d2c9253675bbb4b7f04c6bc52f8e74c0d4cc6"
17
  },
18
  "dist": {
19
  "type": "zip",
20
- "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/386d2c9253675bbb4b7f04c6bc52f8e74c0d4cc6",
21
- "reference": "386d2c9253675bbb4b7f04c6bc52f8e74c0d4cc6",
22
  "shasum": ""
23
  },
24
  "require": {
@@ -58,9 +58,9 @@
58
  "description": "Initialize Symfony Console commands from annotated command class methods.",
59
  "support": {
60
  "issues": "https://github.com/consolidation/annotated-command/issues",
61
- "source": "https://github.com/consolidation/annotated-command/tree/4.3.1"
62
  },
63
- "time": "2021-08-30T03:50:47+00:00"
64
  },
65
  {
66
  "name": "consolidation/config",
9
  "packages-dev": [
10
  {
11
  "name": "consolidation/annotated-command",
12
+ "version": "4.3.2",
13
  "source": {
14
  "type": "git",
15
  "url": "https://github.com/consolidation/annotated-command.git",
16
+ "reference": "101c7dd0388259cfbba41b705b9255d2b1976bbf"
17
  },
18
  "dist": {
19
  "type": "zip",
20
+ "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/101c7dd0388259cfbba41b705b9255d2b1976bbf",
21
+ "reference": "101c7dd0388259cfbba41b705b9255d2b1976bbf",
22
  "shasum": ""
23
  },
24
  "require": {
58
  "description": "Initialize Symfony Console commands from annotated command class methods.",
59
  "support": {
60
  "issues": "https://github.com/consolidation/annotated-command/issues",
61
+ "source": "https://github.com/consolidation/annotated-command/tree/4.3.2"
62
  },
63
+ "time": "2021-09-19T14:35:36+00:00"
64
  },
65
  {
66
  "name": "consolidation/config",
languages/post-expirator.pot CHANGED
@@ -5,7 +5,7 @@ msgstr ""
5
  "Project-Id-Version: Post Expirator 2.4.4\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/PublishPress-Future\n"
8
- "POT-Creation-Date: 2021-08-30 07:18:09+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -70,111 +70,58 @@ msgstr ""
70
  msgid "Expires"
71
  msgstr ""
72
 
73
- #: post-expirator.php:334 views/bulk-edit.php:20 views/quick-edit.php:7
74
- msgid "Enable Post Expiration"
75
- msgstr ""
76
-
77
- #: post-expirator.php:337
78
- msgid "The published date/time will be used as the expiration value"
79
- msgstr ""
80
-
81
- #: post-expirator.php:340 views/bulk-edit.php:51 views/quick-edit.php:32
82
- msgid "Year"
83
- msgstr ""
84
-
85
- #: post-expirator.php:341 views/bulk-edit.php:31 views/quick-edit.php:14
86
- msgid "Month"
87
- msgstr ""
88
-
89
- #: post-expirator.php:342 views/bulk-edit.php:47 views/quick-edit.php:28
90
- msgid "Day"
91
- msgstr ""
92
-
93
- #: post-expirator.php:379 views/bulk-edit.php:55 views/quick-edit.php:36
94
- msgid "Hour"
95
- msgstr ""
96
-
97
- #: post-expirator.php:380 views/bulk-edit.php:59 views/quick-edit.php:40
98
- msgid "Minute"
99
- msgstr ""
100
-
101
- #: post-expirator.php:401 views/bulk-edit.php:67 views/menu-defaults.php:60
102
- #: views/quick-edit.php:47
103
- msgid "How to expire"
104
- msgstr ""
105
-
106
- #: post-expirator.php:412 views/bulk-edit.php:79 views/quick-edit.php:57
107
- msgid "Expiration Categories"
108
- msgstr ""
109
-
110
- #: post-expirator.php:423
111
- msgid ""
112
- "You must assign a heirarchical taxonomy to this post type to use this "
113
- "feature."
114
- msgstr ""
115
-
116
- #: post-expirator.php:425
117
- msgid ""
118
- "More than 1 heirachical taxonomy detected. You must assign a default "
119
- "taxonomy on the settings screen."
120
- msgstr ""
121
-
122
- #: post-expirator.php:435
123
- msgid "Taxonomy Name"
124
- msgstr ""
125
-
126
- #: post-expirator.php:744 post-expirator.php:755 post-expirator.php:766
127
- #: post-expirator.php:777
128
  msgid ""
129
  "%1$s (%2$s) has expired at %3$s. Post status has been successfully changed "
130
  "to \"%4$s\"."
131
  msgstr ""
132
 
133
- #: post-expirator.php:788
134
  msgid ""
135
  "%1$s (%2$s) has expired at %3$s. Post \"%4$s\" status has been successfully "
136
  "set."
137
  msgstr ""
138
 
139
- #: post-expirator.php:799
140
  msgid ""
141
  "%1$s (%2$s) has expired at %3$s. Post \"%4$s\" status has been successfully "
142
  "removed."
143
  msgstr ""
144
 
145
- #: post-expirator.php:812 post-expirator.php:826
146
  msgid ""
147
  "%1$s (%2$s) has expired at %3$s. Post \"%4$s\" have now been set to "
148
  "\"%5$s\"."
149
  msgstr ""
150
 
151
- #: post-expirator.php:849 post-expirator.php:863
152
  msgid ""
153
  "%1$s (%2$s) has expired at %3$s. The following post \"%4$s\" have now been "
154
  "added: \"%5$s\". The full list of categories on the post are: \"%6$s\"."
155
  msgstr ""
156
 
157
- #: post-expirator.php:892 post-expirator.php:913
158
  msgid ""
159
  "%1$s (%2$s) has expired at %3$s. The following post \"%4$s\" have now been "
160
  "removed: \"%5$s\". The full list of categories on the post are: \"%6$s\"."
161
  msgstr ""
162
 
163
- #: post-expirator.php:932
164
  msgid "Post Expiration Complete \"%s\""
165
  msgstr ""
166
 
167
- #: post-expirator.php:968
168
  msgid "[%1$s] %2$s"
169
  msgstr ""
170
 
171
- #: post-expirator.php:1540
172
  msgid ""
173
  "Select the hierarchical taxonomy to be used for \"category\" based "
174
  "expiration."
175
  msgstr ""
176
 
177
- #: post-expirator.php:1542
178
  msgid "No taxonomies found"
179
  msgstr ""
180
 
@@ -182,6 +129,10 @@ msgstr ""
182
  msgid "Date"
183
  msgstr ""
184
 
 
 
 
 
185
  #: views/bulk-edit.php:22
186
  msgid "No Change"
187
  msgstr ""
@@ -210,47 +161,96 @@ msgstr ""
210
  msgid "Remove from posts"
211
  msgstr ""
212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  #: views/bulk-edit.php:66 views/quick-edit.php:46
214
  msgid "Type"
215
  msgstr ""
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  #: views/expire-column.php:3
218
  msgid "Never"
219
  msgstr ""
220
 
221
- #: views/how-to-expire.php:30
222
  msgid "Draft"
223
  msgstr ""
224
 
225
- #: views/how-to-expire.php:31
226
  msgid "Delete"
227
  msgstr ""
228
 
229
- #: views/how-to-expire.php:32
230
  msgid "Trash"
231
  msgstr ""
232
 
233
- #: views/how-to-expire.php:33
234
  msgid "Private"
235
  msgstr ""
236
 
237
- #: views/how-to-expire.php:34
238
  msgid "Stick"
239
  msgstr ""
240
 
241
- #: views/how-to-expire.php:35
242
  msgid "Unstick"
243
  msgstr ""
244
 
245
- #: views/how-to-expire.php:37
246
  msgid "Category: Replace"
247
  msgstr ""
248
 
249
- #: views/how-to-expire.php:38
250
  msgid "Category: Add"
251
  msgstr ""
252
 
253
- #: views/how-to-expire.php:39
254
  msgid "Category: Remove"
255
  msgstr ""
256
 
5
  "Project-Id-Version: Post Expirator 2.4.4\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/PublishPress-Future\n"
8
+ "POT-Creation-Date: 2021-09-07 07:34:21+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
70
  msgid "Expires"
71
  msgstr ""
72
 
73
+ #: post-expirator.php:618 post-expirator.php:629 post-expirator.php:640
74
+ #: post-expirator.php:651
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  msgid ""
76
  "%1$s (%2$s) has expired at %3$s. Post status has been successfully changed "
77
  "to \"%4$s\"."
78
  msgstr ""
79
 
80
+ #: post-expirator.php:662
81
  msgid ""
82
  "%1$s (%2$s) has expired at %3$s. Post \"%4$s\" status has been successfully "
83
  "set."
84
  msgstr ""
85
 
86
+ #: post-expirator.php:673
87
  msgid ""
88
  "%1$s (%2$s) has expired at %3$s. Post \"%4$s\" status has been successfully "
89
  "removed."
90
  msgstr ""
91
 
92
+ #: post-expirator.php:686 post-expirator.php:700
93
  msgid ""
94
  "%1$s (%2$s) has expired at %3$s. Post \"%4$s\" have now been set to "
95
  "\"%5$s\"."
96
  msgstr ""
97
 
98
+ #: post-expirator.php:723 post-expirator.php:737
99
  msgid ""
100
  "%1$s (%2$s) has expired at %3$s. The following post \"%4$s\" have now been "
101
  "added: \"%5$s\". The full list of categories on the post are: \"%6$s\"."
102
  msgstr ""
103
 
104
+ #: post-expirator.php:766 post-expirator.php:787
105
  msgid ""
106
  "%1$s (%2$s) has expired at %3$s. The following post \"%4$s\" have now been "
107
  "removed: \"%5$s\". The full list of categories on the post are: \"%6$s\"."
108
  msgstr ""
109
 
110
+ #: post-expirator.php:806
111
  msgid "Post Expiration Complete \"%s\""
112
  msgstr ""
113
 
114
+ #: post-expirator.php:842
115
  msgid "[%1$s] %2$s"
116
  msgstr ""
117
 
118
+ #: post-expirator.php:1415
119
  msgid ""
120
  "Select the hierarchical taxonomy to be used for \"category\" based "
121
  "expiration."
122
  msgstr ""
123
 
124
+ #: post-expirator.php:1417
125
  msgid "No taxonomies found"
126
  msgstr ""
127
 
129
  msgid "Date"
130
  msgstr ""
131
 
132
+ #: views/bulk-edit.php:20 views/classic-metabox.php:3 views/quick-edit.php:7
133
+ msgid "Enable Post Expiration"
134
+ msgstr ""
135
+
136
  #: views/bulk-edit.php:22
137
  msgid "No Change"
138
  msgstr ""
161
  msgid "Remove from posts"
162
  msgstr ""
163
 
164
+ #: views/bulk-edit.php:31 views/classic-metabox.php:40 views/quick-edit.php:14
165
+ msgid "Month"
166
+ msgstr ""
167
+
168
+ #: views/bulk-edit.php:47 views/classic-metabox.php:57 views/quick-edit.php:28
169
+ msgid "Day"
170
+ msgstr ""
171
+
172
+ #: views/bulk-edit.php:51 views/classic-metabox.php:16 views/quick-edit.php:32
173
+ msgid "Year"
174
+ msgstr ""
175
+
176
+ #: views/bulk-edit.php:55 views/classic-metabox.php:61 views/quick-edit.php:36
177
+ msgid "Hour"
178
+ msgstr ""
179
+
180
+ #: views/bulk-edit.php:59 views/classic-metabox.php:79 views/quick-edit.php:40
181
+ msgid "Minute"
182
+ msgstr ""
183
+
184
  #: views/bulk-edit.php:66 views/quick-edit.php:46
185
  msgid "Type"
186
  msgstr ""
187
 
188
+ #: views/bulk-edit.php:67 views/classic-metabox.php:83
189
+ #: views/menu-defaults.php:60 views/quick-edit.php:47
190
+ msgid "How to expire"
191
+ msgstr ""
192
+
193
+ #: views/bulk-edit.php:79 views/classic-metabox.php:96 views/quick-edit.php:57
194
+ msgid "Expiration Categories"
195
+ msgstr ""
196
+
197
+ #: views/classic-metabox.php:9
198
+ msgid "The published date/time will be used as the expiration value"
199
+ msgstr ""
200
+
201
+ #: views/classic-metabox.php:104
202
+ msgid ""
203
+ "You must assign a heirarchical taxonomy to this post type to use this "
204
+ "feature."
205
+ msgstr ""
206
+
207
+ #: views/classic-metabox.php:106
208
+ msgid ""
209
+ "More than 1 heirachical taxonomy detected. You must assign a default "
210
+ "taxonomy on the settings screen."
211
+ msgstr ""
212
+
213
+ #: views/classic-metabox.php:116
214
+ msgid "Taxonomy Name"
215
+ msgstr ""
216
+
217
  #: views/expire-column.php:3
218
  msgid "Never"
219
  msgstr ""
220
 
221
+ #: views/how-to-expire.php:24
222
  msgid "Draft"
223
  msgstr ""
224
 
225
+ #: views/how-to-expire.php:25
226
  msgid "Delete"
227
  msgstr ""
228
 
229
+ #: views/how-to-expire.php:26
230
  msgid "Trash"
231
  msgstr ""
232
 
233
+ #: views/how-to-expire.php:27
234
  msgid "Private"
235
  msgstr ""
236
 
237
+ #: views/how-to-expire.php:28
238
  msgid "Stick"
239
  msgstr ""
240
 
241
+ #: views/how-to-expire.php:29
242
  msgid "Unstick"
243
  msgstr ""
244
 
245
+ #: views/how-to-expire.php:31
246
  msgid "Category: Replace"
247
  msgstr ""
248
 
249
+ #: views/how-to-expire.php:32
250
  msgid "Category: Add"
251
  msgstr ""
252
 
253
+ #: views/how-to-expire.php:33
254
  msgid "Category: Remove"
255
  msgstr ""
256
 
post-expirator.php CHANGED
@@ -3,15 +3,15 @@
3
  Plugin Name: Post Expirator
4
  Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
5
  Description: Allows you to add an expiration date (minute) to posts which you can configure to either delete the post, change it to a draft, or update the post categories at expiration time.
6
- Author: Aaron Axelsen
7
- Version: 2.5.0
8
- Author URI: http://postexpirator.tuxdocs.net/
9
  Text Domain: post-expirator
10
  Domain Path: /languages
11
  */
12
 
13
  // Default Values
14
- define( 'POSTEXPIRATOR_VERSION', '2.5.0' );
15
  define( 'POSTEXPIRATOR_DATEFORMAT', __( 'l F jS, Y', 'post-expirator' ) );
16
  define( 'POSTEXPIRATOR_TIMEFORMAT', __( 'g:ia', 'post-expirator' ) );
17
  define( 'POSTEXPIRATOR_FOOTERCONTENTS', __( 'Post expires at EXPIRATIONTIME on EXPIRATIONDATE', 'post-expirator' ) );
@@ -68,7 +68,7 @@ add_action( 'plugins_loaded', 'postexpirator_init' );
68
  function postexpirator_add_column( $columns, $type ) {
69
  $defaults = get_option( 'expirationdateDefaults' . ucfirst( $type ) );
70
  // if settings are not configured, show the metabox by default only for posts and pages
71
- if ( ( ! isset( $defaults['activeMetaBox'] ) && in_array( $type, array( 'post', 'page' ), true ) ) || $defaults['activeMetaBox'] === 'active' ) {
72
  $columns['expirationdate'] = __( 'Expires', 'post-expirator' );
73
  }
74
  return $columns;
@@ -243,8 +243,8 @@ add_action( 'bulk_edit_custom_box', 'postexpirator_bulkedit', 10, 2 );
243
  * @access private
244
  */
245
  function postexpirator_get_post_types() {
246
- $post_types = get_post_types( array('public' => true) );
247
- $post_types = array_merge( $post_types, get_post_types( array('public' => false, '_builtin' => false ) ) );
248
 
249
  // in case some post types should not be supported.
250
  $unset_post_types = apply_filters( 'postexpirator_unset_post_types', array( 'attachment' ) );
@@ -265,11 +265,11 @@ function postexpirator_get_post_types() {
265
  */
266
  function postexpirator_meta_custom() {
267
  $post_types = postexpirator_get_post_types();
268
- foreach ( $post_types as $t ) {
269
- $defaults = get_option( 'expirationdateDefaults' . ucfirst( $t ) );
270
  // if settings are not configured, show the metabox by default only for posts and pages
271
- if ( ( ! isset( $defaults['activeMetaBox'] ) && in_array( $t, array( 'post', 'page' ), true ) ) || $defaults['activeMetaBox'] === 'active' ) {
272
- add_meta_box( 'expirationdatediv', __( 'Post Expirator', 'post-expirator' ), 'postexpirator_meta_box', $t, 'side', 'core', array( '__back_compat_meta_box' => PostExpirator_Facade::show_gutenberg_metabox() ) );
273
  }
274
  }
275
  }
@@ -287,23 +287,18 @@ function postexpirator_meta_box( $post ) {
287
  $expirationdatets = get_post_meta( $post->ID, '_expiration-date', true );
288
  $firstsave = get_post_meta( $post->ID, '_expiration-date-status', true );
289
 
290
- // nonce
291
- wp_nonce_field( '__postexpirator', '_postexpiratornonce' );
292
-
293
- $default = '';
294
- $expireType = '';
295
  $defaults = get_option( 'expirationdateDefaults' . ucfirst( $post->post_type ) );
296
  if ( empty( $expirationdatets ) ) {
297
  $default_expiry = PostExpirator_Facade::get_default_expiry( $post->post_type );
298
 
299
  $defaultmonth = $default_expiry['month'];
300
- $defaultday = $default_expiry['day'];
301
- $defaulthour = $default_expiry['hour'];
302
- $defaultyear = $default_expiry['year'];
303
- $defaultminute = $default_expiry['minute'];
304
 
305
  $enabled = '';
306
- $disabled = ' disabled="disabled"';
307
  $categories = get_option( 'expirationdateCategoryDefaults' );
308
 
309
  if ( isset( $defaults['expireType'] ) ) {
@@ -313,7 +308,6 @@ function postexpirator_meta_box( $post ) {
313
  // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
314
  if ( isset( $defaults['autoEnable'] ) && ( $firstsave !== 'saved' ) && ( $defaults['autoEnable'] === true || $defaults['autoEnable'] == 1 ) ) {
315
  $enabled = ' checked="checked"';
316
- $disabled = '';
317
  }
318
  } else {
319
  $defaultmonth = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $expirationdatets ), 'm' );
@@ -322,121 +316,26 @@ function postexpirator_meta_box( $post ) {
322
  $defaulthour = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $expirationdatets ), 'H' );
323
  $defaultminute = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $expirationdatets ), 'i' );
324
  $enabled = ' checked="checked"';
325
- $disabled = '';
326
 
327
  $attributes = PostExpirator_Facade::get_expire_principles( $post->ID );
328
  $expireType = $attributes['expireType'];
329
  $categories = $attributes['category'];
330
  }
331
 
332
- $rv = array();
333
- $rv[] = '<p><input type="checkbox" name="enable-expirationdate" id="enable-expirationdate" value="checked"' . $enabled . ' onclick="expirationdate_ajax_add_meta(\'enable-expirationdate\')" />';
334
- $rv[] = '<label for="enable-expirationdate">' . __( 'Enable Post Expiration', 'post-expirator' ) . '</label></p>';
335
-
336
- if ( $default === 'publish' ) {
337
- $rv[] = '<em>' . __( 'The published date/time will be used as the expiration value', 'post-expirator' ) . '</em><br/>';
338
- } else {
339
- $rv[] = '<table><tr>';
340
- $rv[] = '<th style="text-align: left;">' . __( 'Year', 'post-expirator' ) . '</th>';
341
- $rv[] = '<th style="text-align: left;">' . __( 'Month', 'post-expirator' ) . '</th>';
342
- $rv[] = '<th style="text-align: left;">' . __( 'Day', 'post-expirator' ) . '</th>';
343
- $rv[] = '</tr><tr>';
344
- $rv[] = '<td>';
345
- $rv[] = '<select name="expirationdate_year" id="expirationdate_year"' . $disabled . '>';
346
- $currentyear = date( 'Y' );
347
-
348
- if ( $defaultyear < $currentyear ) {
349
- $currentyear = $defaultyear;
350
- }
351
-
352
- for ( $i = $currentyear; $i <= $currentyear + 10; $i++ ) {
353
- // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
354
- if ( $i == $defaultyear ) {
355
- $selected = ' selected="selected"';
356
- } else {
357
- $selected = '';
358
- }
359
- $rv[] = '<option' . $selected . '>' . ( $i ) . '</option>';
360
- }
361
- $rv[] = '</select>';
362
- $rv[] = '</td><td>';
363
- $rv[] = '<select name="expirationdate_month" id="expirationdate_month"' . $disabled . '>';
364
-
365
- for ( $i = 1; $i <= 12; $i++ ) {
366
- if ( $defaultmonth === date_i18n( 'm', mktime( 0, 0, 0, $i, 1, date_i18n( 'Y' ) ) ) ) {
367
- $selected = ' selected="selected"';
368
- } else {
369
- $selected = '';
370
- }
371
- $rv[] = '<option value="' . date_i18n( 'm', mktime( 0, 0, 0, $i, 1, date_i18n( 'Y' ) ) ) . '"' . $selected . '>' . date_i18n( 'F', mktime( 0, 0, 0, $i, 1, date_i18n( 'Y' ) ) ) . '</option>';
372
- }
373
-
374
- $rv[] = '</select>';
375
- $rv[] = '</td><td>';
376
- $rv[] = '<input type="text" id="expirationdate_day" name="expirationdate_day" value="' . $defaultday . '" size="2"' . $disabled . ' />,';
377
- $rv[] = '</td></tr><tr>';
378
- $rv[] = '<th style="text-align: left;"></th>';
379
- $rv[] = '<th style="text-align: left;">' . __( 'Hour', 'post-expirator' ) . '(' . date_i18n( 'T', mktime( 0, 0, 0, $i, 1, date_i18n( 'Y' ) ) ) . ')</th>';
380
- $rv[] = '<th style="text-align: left;">' . __( 'Minute', 'post-expirator' ) . '</th>';
381
- $rv[] = '</tr><tr>';
382
- $rv[] = '<td>@</td><td>';
383
- $rv[] = '<select name="expirationdate_hour" id="expirationdate_hour"' . $disabled . '>';
384
-
385
- for ( $i = 1; $i <= 24; $i++ ) {
386
- if ( $defaulthour === date_i18n( 'H', mktime( $i, 0, 0, date_i18n( 'n' ), date_i18n( 'j' ), date_i18n( 'Y' ) ) ) ) {
387
- $selected = ' selected="selected"';
388
- } else {
389
- $selected = '';
390
- }
391
- $rv[] = '<option value="' . date_i18n( 'H', mktime( $i, 0, 0, date_i18n( 'n' ), date_i18n( 'j' ), date_i18n( 'Y' ) ) ) . '"' . $selected . '>' . date_i18n( 'H', mktime( $i, 0, 0, date_i18n( 'n' ), date_i18n( 'j' ), date_i18n( 'Y' ) ) ) . '</option>';
392
- }
393
-
394
- $rv[] = '</select></td><td>';
395
- $rv[] = '<input type="text" id="expirationdate_minute" name="expirationdate_minute" value="' . $defaultminute . '" size="2"' . $disabled . ' />';
396
- $rv[] = '</td></tr></table>';
397
- }
398
- $rv[] = '<input type="hidden" name="expirationdate_formcheck" value="true" />';
399
- echo implode( "\n", $rv );
400
-
401
- echo '<br/>' . __( 'How to expire', 'post-expirator' ) . ': ';
402
- _postexpirator_expire_type( array('type' => $post->post_type, 'name' => 'expirationdate_expiretype', 'selected' => $expireType, 'disabled' => $disabled, 'onchange' => 'expirationdate_toggle_category(this)') );
403
- echo '<br/>';
404
-
405
- if ( $post->post_type !== 'page' ) {
406
- if ( isset( $expireType ) && ( $expireType === 'category' || $expireType === 'category-add' || $expireType === 'category-remove' ) ) {
407
- $catdisplay = 'block';
408
- } else {
409
- $catdisplay = 'none';
410
- }
411
- echo '<div id="expired-category-selection" style="display: ' . $catdisplay . '">';
412
- echo '<br/>' . __( 'Expiration Categories', 'post-expirator' ) . ':<br/>';
413
-
414
- echo '<div class="wp-tab-panel" id="post-expirator-cat-list">';
415
- echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">';
416
- $walker = new Walker_PostExpirator_Category_Checklist();
417
- if ( ! empty( $disabled ) ) {
418
- $walker->setDisabled();
419
- }
420
- $taxonomies = get_object_taxonomies( $post->post_type, 'object' );
421
- $taxonomies = wp_filter_object_list( $taxonomies, array('hierarchical' => true) );
422
- if ( sizeof( $taxonomies ) === 0 ) {
423
- echo '<p>' . __( 'You must assign a heirarchical taxonomy to this post type to use this feature.', 'post-expirator' ) . '</p>';
424
- } elseif ( sizeof( $taxonomies ) > 1 && ! isset( $defaults['taxonomy'] ) ) {
425
- echo '<p>' . __( 'More than 1 heirachical taxonomy detected. You must assign a default taxonomy on the settings screen.', 'post-expirator' ) . '</p>';
426
- } else {
427
- $keys = array_keys( $taxonomies );
428
- $taxonomy = isset( $defaults['taxonomy'] ) ? $defaults['taxonomy'] : $keys[0];
429
- wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy, 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false ) );
430
- echo '<input type="hidden" name="taxonomy-heirarchical" value="' . $taxonomy . '" />';
431
- }
432
- echo '</ul>';
433
- echo '</div>';
434
- if ( isset( $taxonomy ) ) {
435
- echo '<p class="post-expirator-taxonomy-name">' . __( 'Taxonomy Name', 'post-expirator' ) . ': ' . $taxonomy . '</p>';
436
- }
437
- echo '</div>';
438
- }
439
- echo '<div id="expirationdate_ajax_result"></div>';
440
  }
441
 
442
  /**
@@ -447,57 +346,32 @@ function postexpirator_meta_box( $post ) {
447
  * @access private
448
  */
449
  function postexpirator_js_admin_header() {
450
- // Define custom JavaScript function
451
  ?>
452
  <script type="text/javascript">
453
  //<![CDATA[
454
- function expirationdate_ajax_add_meta(expireenable) {
455
- var expire = document.getElementById(expireenable);
456
-
457
- if (expire.checked == true) {
458
- var enable = 'true';
459
- if (document.getElementById('expirationdate_month')) {
460
- document.getElementById('expirationdate_month').disabled = false;
461
- document.getElementById('expirationdate_day').disabled = false;
462
- document.getElementById('expirationdate_year').disabled = false;
463
- document.getElementById('expirationdate_hour').disabled = false;
464
- document.getElementById('expirationdate_minute').disabled = false;
465
- }
466
- document.getElementById('expirationdate_expiretype').disabled = false;
467
- var cats = document.getElementsByName('expirationdate_category[]');
468
- var max = cats.length;
469
- for (var i=0; i<max; i++) {
470
- cats[i].disabled = '';
471
- }
472
- } else {
473
- if (document.getElementById('expirationdate_month')) {
474
- document.getElementById('expirationdate_month').disabled = true;
475
- document.getElementById('expirationdate_day').disabled = true;
476
- document.getElementById('expirationdate_year').disabled = true;
477
- document.getElementById('expirationdate_hour').disabled = true;
478
- document.getElementById('expirationdate_minute').disabled = true;
479
- }
480
- document.getElementById('expirationdate_expiretype').disabled = true;
481
- var cats = document.getElementsByName('expirationdate_category[]');
482
- var max = cats.length;
483
- for (var i=0; i<max; i++) {
484
- cats[i].disabled = 'disable';
485
- }
486
- var enable = 'false';
487
- }
488
- return true;
489
- }
490
- function expirationdate_toggle_category(id) {
491
- if (id.options[id.selectedIndex].value == 'category') {
492
- jQuery('#expired-category-selection').show();
493
- } else if (id.options[id.selectedIndex].value == 'category-add') {
494
- jQuery('#expired-category-selection').show(); //TEMP
495
- } else if (id.options[id.selectedIndex].value == 'category-remove') {
496
- jQuery('#expired-category-selection').show(); //TEMP
497
- } else {
498
- jQuery('#expired-category-selection').hide();
499
  }
500
- }
501
  //]]>
502
  </script>
503
  <?php
3
  Plugin Name: Post Expirator
4
  Plugin URI: http://wordpress.org/extend/plugins/post-expirator/
5
  Description: Allows you to add an expiration date (minute) to posts which you can configure to either delete the post, change it to a draft, or update the post categories at expiration time.
6
+ Author: PublishPress
7
+ Version: 2.5.1
8
+ Author URI: http://publishpress.com
9
  Text Domain: post-expirator
10
  Domain Path: /languages
11
  */
12
 
13
  // Default Values
14
+ define( 'POSTEXPIRATOR_VERSION', '2.5.1' );
15
  define( 'POSTEXPIRATOR_DATEFORMAT', __( 'l F jS, Y', 'post-expirator' ) );
16
  define( 'POSTEXPIRATOR_TIMEFORMAT', __( 'g:ia', 'post-expirator' ) );
17
  define( 'POSTEXPIRATOR_FOOTERCONTENTS', __( 'Post expires at EXPIRATIONTIME on EXPIRATIONDATE', 'post-expirator' ) );
68
  function postexpirator_add_column( $columns, $type ) {
69
  $defaults = get_option( 'expirationdateDefaults' . ucfirst( $type ) );
70
  // if settings are not configured, show the metabox by default only for posts and pages
71
+ if ( ( ! isset( $defaults['activeMetaBox'] ) && in_array( $type, array( 'post', 'page' ), true ) ) || ( is_array( $defaults ) && $defaults['activeMetaBox'] === 'active' ) ) {
72
  $columns['expirationdate'] = __( 'Expires', 'post-expirator' );
73
  }
74
  return $columns;
243
  * @access private
244
  */
245
  function postexpirator_get_post_types() {
246
+ $post_types = get_post_types( array( 'public' => true ) );
247
+ $post_types = array_merge( $post_types, get_post_types( array( 'public' => false, 'show_ui' => true, '_builtin' => false ) ) );
248
 
249
  // in case some post types should not be supported.
250
  $unset_post_types = apply_filters( 'postexpirator_unset_post_types', array( 'attachment' ) );
265
  */
266
  function postexpirator_meta_custom() {
267
  $post_types = postexpirator_get_post_types();
268
+ foreach ( $post_types as $type ) {
269
+ $defaults = get_option( 'expirationdateDefaults' . ucfirst( $type ) );
270
  // if settings are not configured, show the metabox by default only for posts and pages
271
+ if ( ( ! isset( $defaults['activeMetaBox'] ) && in_array( $type, array( 'post', 'page' ), true ) ) || ( is_array( $defaults ) && $defaults['activeMetaBox'] === 'active' ) ) {
272
+ add_meta_box( 'expirationdatediv', __( 'Post Expirator', 'post-expirator' ), 'postexpirator_meta_box', $type, 'side', 'core', array( '__back_compat_meta_box' => PostExpirator_Facade::show_gutenberg_metabox() ) );
273
  }
274
  }
275
  }
287
  $expirationdatets = get_post_meta( $post->ID, '_expiration-date', true );
288
  $firstsave = get_post_meta( $post->ID, '_expiration-date-status', true );
289
 
290
+ $default = $expireType = $enabled = $defaultmonth = $defaultday = $defaulthour = $defaultyear = $defaultminute = $categories = '';
 
 
 
 
291
  $defaults = get_option( 'expirationdateDefaults' . ucfirst( $post->post_type ) );
292
  if ( empty( $expirationdatets ) ) {
293
  $default_expiry = PostExpirator_Facade::get_default_expiry( $post->post_type );
294
 
295
  $defaultmonth = $default_expiry['month'];
296
+ $defaultday = $default_expiry['day'];
297
+ $defaulthour = $default_expiry['hour'];
298
+ $defaultyear = $default_expiry['year'];
299
+ $defaultminute = $default_expiry['minute'];
300
 
301
  $enabled = '';
 
302
  $categories = get_option( 'expirationdateCategoryDefaults' );
303
 
304
  if ( isset( $defaults['expireType'] ) ) {
308
  // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
309
  if ( isset( $defaults['autoEnable'] ) && ( $firstsave !== 'saved' ) && ( $defaults['autoEnable'] === true || $defaults['autoEnable'] == 1 ) ) {
310
  $enabled = ' checked="checked"';
 
311
  }
312
  } else {
313
  $defaultmonth = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $expirationdatets ), 'm' );
316
  $defaulthour = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $expirationdatets ), 'H' );
317
  $defaultminute = get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $expirationdatets ), 'i' );
318
  $enabled = ' checked="checked"';
 
319
 
320
  $attributes = PostExpirator_Facade::get_expire_principles( $post->ID );
321
  $expireType = $attributes['expireType'];
322
  $categories = $attributes['category'];
323
  }
324
 
325
+ PostExpirator_Display::getInstance()->render_template(
326
+ 'classic-metabox', array(
327
+ 'post' => $post,
328
+ 'enabled' => $enabled,
329
+ 'default' => $default,
330
+ 'defaultmonth' => $defaultmonth,
331
+ 'defaultday' => $defaultday,
332
+ 'defaulthour' => $defaulthour,
333
+ 'defaultyear' => $defaultyear,
334
+ 'defaultminute' => $defaultminute,
335
+ 'categories' => $categories,
336
+ 'expireType' => $expireType,
337
+ )
338
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  }
340
 
341
  /**
346
  * @access private
347
  */
348
  function postexpirator_js_admin_header() {
 
349
  ?>
350
  <script type="text/javascript">
351
  //<![CDATA[
352
+ (function($){
353
+ $(document).ready(function(){
354
+ init();
355
+ });
356
+
357
+ function init(){
358
+ $('#enable-expirationdate').on('click', function(e){
359
+ if($(this).is(':checked')){
360
+ $('.pe-classic-fields').show();
361
+ }else{
362
+ $('.pe-classic-fields').hide();
363
+ }
364
+ });
365
+
366
+ $('.pe-howtoexpire').on('change', function(e){
367
+ if($(this).val().indexOf('category') !== -1){
368
+ $('#expired-category-selection').show();
369
+ }else{
370
+ $('#expired-category-selection').hide();
371
+ }
372
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  }
374
+ })(jQuery);
375
  //]]>
376
  </script>
377
  <?php
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === Post Expirator: Automatically Unpublish WordPress Posts ===
2
- Contributors: publishpress, kevinB, stevejburge, andergmartins
3
  Author: publishpress
4
  Author URI: https://publishpress.com
5
  Tags: expire, posts, pages, schedule
6
- Requires at least: 4.0
7
  Tested up to: 5.8
8
- Stable tag: 2.5.0
9
 
10
  Add an expiration date to posts. When your post is automatically unpublished, you can delete the post, change the status, or update the post categories.
11
 
@@ -81,6 +81,14 @@ This section describes how to install the plugin and get it working.
81
 
82
  == Changelog ==
83
 
 
 
 
 
 
 
 
 
84
  = [2.5.0] - 08 Aug 2021 =
85
 
86
  * Fixed: Appearance Widgets screen shows PHP Notice, #92;
1
  === Post Expirator: Automatically Unpublish WordPress Posts ===
2
+ Contributors: publishpress, kevinB, stevejburge, andergmartins, rozroz
3
  Author: publishpress
4
  Author URI: https://publishpress.com
5
  Tags: expire, posts, pages, schedule
6
+ Requires at least: 5.0
7
  Tested up to: 5.8
8
+ Stable tag: 2.5.1
9
 
10
  Add an expiration date to posts. When your post is automatically unpublished, you can delete the post, change the status, or update the post categories.
11
 
81
 
82
  == Changelog ==
83
 
84
+ = [2.5.1] - 27 Sep 2021 =
85
+
86
+ * Fixed: Default Expiration Categories cannot be unset, #94;
87
+ * Fixed: Tidy up design for Classic Editor version, #83;
88
+ * Fixed: All posts now carry the default expiration, #115;
89
+ * Fixed: Error with 2.5.0 and WordPress 5.8.1, #110;
90
+ * Fixed: Do not show private post types that don't have an admin UI, #116;
91
+
92
  = [2.5.0] - 08 Aug 2021 =
93
 
94
  * Fixed: Appearance Widgets screen shows PHP Notice, #92;
vendor/composer/InstalledVersions.php CHANGED
@@ -29,7 +29,7 @@ private static $installed = array (
29
  'aliases' =>
30
  array (
31
  ),
32
- 'reference' => 'a03b725c71daf735915144ede3563c2449c7b921',
33
  'name' => 'publishpress/post-expirator',
34
  ),
35
  'versions' =>
@@ -41,7 +41,7 @@ private static $installed = array (
41
  'aliases' =>
42
  array (
43
  ),
44
- 'reference' => 'a03b725c71daf735915144ede3563c2449c7b921',
45
  ),
46
  ),
47
  );
29
  'aliases' =>
30
  array (
31
  ),
32
+ 'reference' => '4996c39a952ccb9b01d2783c88728a1c578b6fa2',
33
  'name' => 'publishpress/post-expirator',
34
  ),
35
  'versions' =>
41
  'aliases' =>
42
  array (
43
  ),
44
+ 'reference' => '4996c39a952ccb9b01d2783c88728a1c578b6fa2',
45
  ),
46
  ),
47
  );
vendor/composer/installed.php CHANGED
@@ -6,7 +6,7 @@
6
  'aliases' =>
7
  array (
8
  ),
9
- 'reference' => 'a03b725c71daf735915144ede3563c2449c7b921',
10
  'name' => 'publishpress/post-expirator',
11
  ),
12
  'versions' =>
@@ -18,7 +18,7 @@
18
  'aliases' =>
19
  array (
20
  ),
21
- 'reference' => 'a03b725c71daf735915144ede3563c2449c7b921',
22
  ),
23
  ),
24
  );
6
  'aliases' =>
7
  array (
8
  ),
9
+ 'reference' => '4996c39a952ccb9b01d2783c88728a1c578b6fa2',
10
  'name' => 'publishpress/post-expirator',
11
  ),
12
  'versions' =>
18
  'aliases' =>
19
  array (
20
  ),
21
+ 'reference' => '4996c39a952ccb9b01d2783c88728a1c578b6fa2',
22
  ),
23
  ),
24
  );
views/bulk-edit.php CHANGED
@@ -69,7 +69,7 @@
69
  <label>
70
  <?php
71
  $defaults = get_option( 'expirationdateDefaults' . ucfirst( $post_type ) );
72
- _postexpirator_expire_type( array('name' => 'expirationdate_expiretype', 'selected' => $defaults['expireType'], 'post_type' => $post_type ) );
73
  ?>
74
  </label>
75
  </div>
69
  <label>
70
  <?php
71
  $defaults = get_option( 'expirationdateDefaults' . ucfirst( $post_type ) );
72
+ _postexpirator_expire_type( array('name' => 'expirationdate_expiretype', 'selected' => empty( $defaults ) ? 'draft' : $defaults['expireType'], 'post_type' => $post_type ) );
73
  ?>
74
  </label>
75
  </div>
views/classic-metabox.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p>
2
+ <input type="checkbox" name="enable-expirationdate" id="enable-expirationdate" value="checked"' . <?php echo $enabled; ?>/>
3
+ <label for="enable-expirationdate"><?php _e( 'Enable Post Expiration', 'post-expirator' ); ?></label>
4
+ </p>
5
+
6
+ <?php
7
+ if ( $default === 'publish' ) {
8
+ ?>
9
+ <em><?php _e( 'The published date/time will be used as the expiration value', 'post-expirator' ); ?></em>
10
+ <?php
11
+ return;
12
+ }
13
+ ?>
14
+ <div class="pe-classic-fields" style="display: <?php echo empty( $enabled ) ? 'none' : 'flex'; ?>">
15
+ <div>
16
+ <label><?php _e( 'Year', 'post-expirator' ); ?></label>
17
+ <select name="expirationdate_year" id="expirationdate_year" >
18
+ <?php
19
+ $currentyear = date( 'Y' );
20
+
21
+ if ( $defaultyear < $currentyear ) {
22
+ $currentyear = $defaultyear;
23
+ }
24
+
25
+ for ( $i = $currentyear; $i <= $currentyear + 10; $i++ ) {
26
+ // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
27
+ if ( $i == $defaultyear ) {
28
+ $selected = ' selected="selected"';
29
+ } else {
30
+ $selected = '';
31
+ }
32
+ ?>
33
+ <option <?php echo $selected; ?> value="<?php echo $i; ?>"><?php echo $i; ?></option>
34
+ <?php
35
+ }
36
+ ?>
37
+ </select>
38
+ </div>
39
+ <div>
40
+ <label><?php _e( 'Month', 'post-expirator' ); ?></label>
41
+ <select name="expirationdate_month" id="expirationdate_month" >
42
+ <?php
43
+ for ( $i = 1; $i <= 12; $i++ ) {
44
+ if ( $defaultmonth === date_i18n( 'm', mktime( 0, 0, 0, $i, 1, date_i18n( 'Y' ) ) ) ) {
45
+ $selected = ' selected="selected"';
46
+ } else {
47
+ $selected = '';
48
+ }
49
+ ?>
50
+ <option value="<?php echo date_i18n( 'm', mktime( 0, 0, 0, $i, 1, date_i18n( 'Y' ) ) ); ?>" <?php echo $selected; ?>><?php echo date_i18n( 'F', mktime( 0, 0, 0, $i, 1, date_i18n( 'Y' ) ) ); ?></option>
51
+ <?php
52
+ }
53
+ ?>
54
+ </select>
55
+ </div>
56
+ <div>
57
+ <label><?php _e( 'Day', 'post-expirator' ); ?></label>
58
+ <input type="text" id="expirationdate_day" name="expirationdate_day" value="<?php echo $defaultday; ?>" size="2" />
59
+ </div>
60
+ <div>
61
+ <label><?php _e( 'Hour', 'post-expirator' ); ?> (<?php echo date_i18n( 'T', mktime( 0, 0, 0, $i, 1, date_i18n( 'Y' ) ) ); ?>)</label>
62
+ <select name="expirationdate_hour" id="expirationdate_hour" >
63
+ <?php
64
+ for ( $i = 1; $i <= 24; $i++ ) {
65
+ $hour = date_i18n( 'H', mktime( $i, 0, 0, date_i18n( 'n' ), date_i18n( 'j' ), date_i18n( 'Y' ) ) );
66
+ if ( $defaulthour === $hour ) {
67
+ $selected = ' selected="selected"';
68
+ } else {
69
+ $selected = '';
70
+ }
71
+ ?>
72
+ <option value="<?php echo $hour; ?>" <?php echo $selected; ?>><?php echo $hour; ?></option>
73
+ <?php
74
+ }
75
+ ?>
76
+ </select>
77
+ </div>
78
+ <div>
79
+ <label><?php _e( 'Minute', 'post-expirator' ); ?></label>
80
+ <input type="text" id="expirationdate_minute" name="expirationdate_minute" value="<?php echo $defaultminute; ?>" size="2" />
81
+ </div>
82
+ <div>
83
+ <label><?php _e( 'How to expire', 'post-expirator' ); ?></label>
84
+ <?php _postexpirator_expire_type( array('type' => $post->post_type, 'name' => 'expirationdate_expiretype', 'selected' => $expireType ) ); ?>
85
+ </div>
86
+
87
+ <?php
88
+ if ( $post->post_type !== 'page' ) {
89
+ if ( isset( $expireType ) && ( $expireType === 'category' || $expireType === 'category-add' || $expireType === 'category-remove' ) ) {
90
+ $catdisplay = 'block';
91
+ } else {
92
+ $catdisplay = 'none';
93
+ }
94
+
95
+ echo '<div id="expired-category-selection" style="display: ' . $catdisplay . '">';
96
+ echo '<br/>' . __( 'Expiration Categories', 'post-expirator' ) . ':<br/>';
97
+
98
+ echo '<div class="wp-tab-panel" id="post-expirator-cat-list">';
99
+ echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">';
100
+ $walker = new Walker_PostExpirator_Category_Checklist();
101
+ $taxonomies = get_object_taxonomies( $post->post_type, 'object' );
102
+ $taxonomies = wp_filter_object_list( $taxonomies, array('hierarchical' => true) );
103
+ if ( sizeof( $taxonomies ) === 0 ) {
104
+ echo '<p>' . __( 'You must assign a heirarchical taxonomy to this post type to use this feature.', 'post-expirator' ) . '</p>';
105
+ } elseif ( sizeof( $taxonomies ) > 1 && ! isset( $defaults['taxonomy'] ) ) {
106
+ echo '<p>' . __( 'More than 1 heirachical taxonomy detected. You must assign a default taxonomy on the settings screen.', 'post-expirator' ) . '</p>';
107
+ } else {
108
+ $keys = array_keys( $taxonomies );
109
+ $taxonomy = isset( $defaults['taxonomy'] ) ? $defaults['taxonomy'] : $keys[0];
110
+ wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy, 'walker' => $walker, 'selected_cats' => $categories, 'checked_ontop' => false ) );
111
+ echo '<input type="hidden" name="taxonomy-heirarchical" value="' . $taxonomy . '" />';
112
+ }
113
+ echo '</ul>';
114
+ echo '</div>';
115
+ if ( isset( $taxonomy ) ) {
116
+ echo '<p class="post-expirator-taxonomy-name">' . __( 'Taxonomy Name', 'post-expirator' ) . ': ' . $taxonomy . '</p>';
117
+ }
118
+ echo '</div>';
119
+ }
120
+ ?>
121
+ </div>
122
+
123
+ <input type="hidden" name="expirationdate_formcheck" value="true" />
124
+ <?php wp_nonce_field( '__postexpirator', '_postexpiratornonce' ); ?>
views/how-to-expire.php CHANGED
@@ -9,12 +9,6 @@ if ( ! isset( $name ) ) {
9
  if ( ! isset( $id ) ) {
10
  $id = $name;
11
  }
12
- if ( ! isset( $disabled ) ) {
13
- $disabled = false;
14
- }
15
- if ( ! isset( $onchange ) ) {
16
- $onchange = '';
17
- }
18
  if ( ! isset( $type ) ) {
19
  $type = '';
20
  }
@@ -24,19 +18,18 @@ if ( empty( $type ) && isset( $opts['post_type'] ) ) {
24
  $type = $opts['post_type'];
25
  }
26
 
27
- $rv = array();
28
  // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
29
- $rv[] = '<select name="' . $name . '" id="' . $id . '"' . ( $disabled == true ? ' disabled="disabled"' : '' ) . ' onchange="' . $onchange . '">';
30
- $rv[] = '<option value="draft" ' . ( $selected === 'draft' ? 'selected="selected"' : '' ) . '>' . __( 'Draft', 'post-expirator' ) . '</option>';
31
- $rv[] = '<option value="delete" ' . ( $selected === 'delete' ? 'selected="selected"' : '' ) . '>' . __( 'Delete', 'post-expirator' ) . '</option>';
32
- $rv[] = '<option value="trash" ' . ( $selected === 'trash' ? 'selected="selected"' : '' ) . '>' . __( 'Trash', 'post-expirator' ) . '</option>';
33
- $rv[] = '<option value="private" ' . ( $selected === 'private' ? 'selected="selected"' : '' ) . '>' . __( 'Private', 'post-expirator' ) . '</option>';
34
- $rv[] = '<option value="stick" ' . ( $selected === 'stick' ? 'selected="selected"' : '' ) . '>' . __( 'Stick', 'post-expirator' ) . '</option>';
35
- $rv[] = '<option value="unstick" ' . ( $selected === 'unstick' ? 'selected="selected"' : '' ) . '>' . __( 'Unstick', 'post-expirator' ) . '</option>';
36
- if ( $type !== 'page' ) {
37
- $rv[] = '<option value="category" ' . ( $selected === 'category' ? 'selected="selected"' : '' ) . '>' . __( 'Category: Replace', 'post-expirator' ) . '</option>';
38
- $rv[] = '<option value="category-add" ' . ( $selected === 'category-add' ? 'selected="selected"' : '' ) . '>' . __( 'Category: Add', 'post-expirator' ) . '</option>';
39
- $rv[] = '<option value="category-remove" ' . ( $selected === 'category-remove' ? 'selected="selected"' : '' ) . '>' . __( 'Category: Remove', 'post-expirator' ) . '</option>';
40
- }
41
- $rv[] = '</select>';
42
- echo implode( "<br/>\n", $rv );
9
  if ( ! isset( $id ) ) {
10
  $id = $name;
11
  }
 
 
 
 
 
 
12
  if ( ! isset( $type ) ) {
13
  $type = '';
14
  }
18
  $type = $opts['post_type'];
19
  }
20
 
 
21
  // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
22
+ ?>
23
+ <select name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="pe-howtoexpire">
24
+ <option value="draft" <?php echo $selected === 'draft' ? 'selected="selected"' : ''; ?>><?php _e( 'Draft', 'post-expirator' ); ?></option>
25
+ <option value="delete" <?php echo $selected === 'delete' ? 'selected="selected"' : ''; ?>><?php _e( 'Delete', 'post-expirator' ); ?></option>
26
+ <option value="trash" <?php echo $selected === 'trash' ? 'selected="selected"' : ''; ?>><?php _e( 'Trash', 'post-expirator' ); ?></option>
27
+ <option value="private" <?php echo $selected === 'private' ? 'selected="selected"' : ''; ?>><?php _e( 'Private', 'post-expirator' ); ?></option>
28
+ <option value="stick" <?php echo $selected === 'stick' ? 'selected="selected"' : ''; ?>><?php _e( 'Stick', 'post-expirator' ); ?></option>
29
+ <option value="unstick" <?php echo $selected === 'unstick' ? 'selected="selected"' : ''; ?>><?php _e( 'Unstick', 'post-expirator' ); ?></option>
30
+ <?php if ( $type !== 'page' ) { ?>
31
+ <option value="category" <?php echo $selected === 'category' ? 'selected="selected"' : ''; ?>><?php _e( 'Category: Replace', 'post-expirator' ); ?></option>
32
+ <option value="category-add" <?php echo $selected === 'category-add' ? 'selected="selected"' : ''; ?>><?php _e( 'Category: Add', 'post-expirator' ); ?></option>
33
+ <option value="category-remove" <?php echo $selected === 'category-remove' ? 'selected="selected"' : ''; ?>><?php _e( 'Category: Remove', 'post-expirator' ); ?></option>
34
+ <?php } ?>
35
+ </select>
views/quick-edit.php CHANGED
@@ -48,7 +48,7 @@
48
  </legend>
49
  <?php
50
  $defaults = get_option( 'expirationdateDefaults' . ucfirst( $post_type ) );
51
- _postexpirator_expire_type( array( 'name' => 'expirationdate_expiretype', 'selected' => $defaults['expireType'], 'post_type' => $post_type ) );
52
  ?>
53
  </div>
54
  <div class="pe-category-list">
48
  </legend>
49
  <?php
50
  $defaults = get_option( 'expirationdateDefaults' . ucfirst( $post_type ) );
51
+ _postexpirator_expire_type( array( 'name' => 'expirationdate_expiretype', 'selected' => empty( $defaults ) ? 'draft' : $defaults['expireType'], 'post_type' => $post_type ) );
52
  ?>
53
  </div>
54
  <div class="pe-category-list">