Changeset 1293687
- Timestamp:
- 11/24/2015 06:49:48 PM (10 years ago)
- Location:
- storyform/trunk
- Files:
-
- 2 edited
-
class-storyform-editor-page.php (modified) (3 diffs)
-
editor/editor.js (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
storyform/trunk/class-storyform-editor-page.php
r1265358 r1293687 348 348 349 349 public function storyform_publish_post(){ 350 351 352 $nonce = isset( $_GET['_wpnonce'] ) ? $_GET[ '_wpnonce' ] : FALSE; 350 if( !isset( $_GET['_wpnonce'] ) || !isset( $_GET['id'] ) || !isset( $_GET['name'] ) ) { 351 die( 'Invalid parameters. Nonce, id and name required' ); 352 } 353 354 $nonce = $_GET[ '_wpnonce' ]; 353 355 $id = intval( $_GET['id'] ); 354 356 $name = sanitize_title( $_GET['name'] ); … … 362 364 363 365 // Update post with revision if already published, keep name 364 $post = get_post( $id )->to_array(); 366 $post_obj = get_post( $id ); 367 if( !$post_obj ){ 368 die( 'Cannot find post with id: ' . $id ); 369 } 370 371 $post = $post_obj->to_array(); 365 372 $revisions = array_values( wp_get_post_revisions( $id ) ); 366 373 367 if( $post['post_status'] === 'publish' && count( $revisions ) > 0 ){ 368 $revision = $revisions[0]->to_array(); 369 $post = array( 370 'ID' => $id, 371 'post_content' => $revision['post_content'], 372 'post_excerpt' => $revision['post_excerpt'], 373 'post_title' => $revision['post_title'] 374 ); 374 if( $post['post_status'] === 'publish' && count( $revisions ) ){ 375 $revision = $revisions[0]; 376 $post = array( 'ID' => $id ); 377 if( $revision->post_content ){ 378 $post['post_content'] = $revision->post_content; 379 } 380 if( $revision->post_excerpt ){ 381 $post['post_excerpt'] = $revision->post_excerpt; 382 } 383 if( $revision->post_title ){ 384 $post['post_title'] = $revision->post_title; 385 } 375 386 376 387 } else { … … 382 393 } 383 394 384 wp_update_post( $post ); 395 $update_result = wp_update_post( $post ); 396 if( !$update_result ){ 397 die( 'Unable to update post with changes' ); 398 } 399 385 400 wp_publish_post( $id ); 386 401 387 wp_redirect( get_permalink( $id ) ); 402 $permalink = get_permalink( $id ); 403 if( !$permalink ){ 404 die( 'Post is published, but cannot find permalink.' ); 405 } 406 407 wp_redirect( $permalink ); 388 408 die(); 389 409 } -
storyform/trunk/editor/editor.js
r1261349 r1293687 682 682 _classCallCheck(this, ThenPromise); 683 683 684 _PromiseStateMachine.call(this); 684 685 if (tagWithStack && (tagWithStack === true || tagWithStack & tag.thenPromise)) { 685 686 this._stack = Promise._getStack(); … … 850 851 _classCallCheck(this, ExceptionPromise); 851 852 853 _ErrorPromise.call(this); 852 854 if (tagWithStack && (tagWithStack === true || tagWithStack & tag.exceptionPromise)) { 853 855 this._stack = Promise._getStack(); … … 1030 1032 /// </param> 1031 1033 /// </signature> 1032 1034 _PromiseStateMachine2.call(this); 1033 1035 if (tagWithStack && (tagWithStack === true || tagWithStack & tag.promise)) { 1034 1036 this._stack = Promise._getStack(); … … 1514 1516 _classCallCheck(this, SignalPromise); 1515 1517 1518 _PromiseStateMachine3.call(this); 1516 1519 this._oncancel = cancel; 1517 1520 this._setState(state_created); … … 1630 1633 /// <returns type="Error" locid=".ErrorFromName_returnValue">Error instance with .name and .message properties populated</returns> 1631 1634 /// </signature> 1635 _Error.call(this); 1632 1636 this.name = name; 1633 1637 this.message = message || name; … … 2281 2285 2282 2286 },{}],6:[function(require,module,exports){ 2287 (function (global){ 2283 2288 /* 2284 2289 * classList.js: Cross-browser full element.classList implementation. … … 2296 2301 "use strict"; 2297 2302 2298 if ("document" in self) {2303 if ("document" in global) { 2299 2304 2300 2305 // Full polyfill for browsers with no classList support … … 2443 2448 elemCtrProto.__defineGetter__(classListProp, classListGetter); 2444 2449 } 2445 })( self);2450 })(global); 2446 2451 } else { 2447 2452 // There is full or partial native classList support, so just check if we need … … 2496 2501 } 2497 2502 2503 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2498 2504 },{}],7:[function(require,module,exports){ 2499 2505 "use strict"; … … 2557 2563 var F = _interopRequireWildcard(require("./array-find")); 2558 2564 2559 },{"./array-find":4,"./canvas-to-blob":5,"./element-classlist":6,"./nodelist-foreach":7,"./object-assign":8,"./set-immediate":10}],10:[function(require,module,exports){ 2565 var G = _interopRequireWildcard(require("./typedarray")); 2566 2567 },{"./array-find":4,"./canvas-to-blob":5,"./element-classlist":6,"./nodelist-foreach":7,"./object-assign":8,"./set-immediate":10,"./typedarray":11}],10:[function(require,module,exports){ 2560 2568 "use strict"; 2561 2569 … … 2573 2581 2574 2582 },{}],11:[function(require,module,exports){ 2583 "use strict"; 2584 2585 if (Uint8Array && !Uint8Array.prototype.sort) { 2586 Object.defineProperty(Uint8Array.prototype, "sort", { 2587 enumerable: false, 2588 value: function value() { 2589 return Array.prototype.sort.call(this, function (a, b) { 2590 return a - b; 2591 }); 2592 } 2593 }); 2594 } 2595 if (Uint16Array && !Uint16Array.prototype.sort) { 2596 Object.defineProperty(Uint16Array.prototype, "sort", { 2597 enumerable: false, 2598 value: function value() { 2599 return Array.prototype.sort.call(this, function (a, b) { 2600 return a - b; 2601 }); 2602 } 2603 }); 2604 } 2605 if (Uint32Array && !Uint32Array.prototype.sort) { 2606 Object.defineProperty(Uint32Array.prototype, "sort", { 2607 enumerable: false, 2608 value: function value() { 2609 return Array.prototype.sort.call(this, function (a, b) { 2610 return a - b; 2611 }); 2612 } 2613 }); 2614 } 2615 if (Uint8ClampedArray && !Uint8ClampedArray.prototype.sort) { 2616 Object.defineProperty(Uint8ClampedArray.prototype, "sort", { 2617 enumerable: false, 2618 value: function value() { 2619 return Array.prototype.sort.call(this, function (a, b) { 2620 return a - b; 2621 }); 2622 } 2623 }); 2624 } 2625 2626 },{}],12:[function(require,module,exports){ 2575 2627 (function (global){ 2576 2628 "use strict"; … … 2716 2768 2717 2769 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2718 },{"Promise":1,"event-utils":2,"object":3}],1 2:[function(require,module,exports){2770 },{"Promise":1,"event-utils":2,"object":3}],13:[function(require,module,exports){ 2719 2771 (function (global){ 2720 2772 "use strict"; … … 2996 3048 2997 3049 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2998 },{"window-messages":1 1}]},{},[9,12]);3050 },{"window-messages":12}]},{},[9,13]);
Note: See TracChangeset
for help on using the changeset viewer.