Changeset 1230971
- Timestamp:
- 08/26/2015 05:18:51 AM (11 years ago)
- Location:
- storyform/trunk
- Files:
-
- 4 edited
-
class-storyform-editor-page.php (modified) (4 diffs)
-
editor/editor.js (modified) (3 diffs)
-
src/js/editor.js (modified) (3 diffs)
-
storyform.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
storyform/trunk/class-storyform-editor-page.php
r1229586 r1230971 12 12 public function __construct() 13 13 { 14 add_action( 'init', array( $this, 'storyform_publish_post' ) ); 14 15 add_action( 'admin_menu', array( $this, 'add_plugin_page' ), 500 ); 15 16 add_action( 'wp_ajax_storyform_get_post', array( $this, 'storyform_get_post' ) ); 16 17 add_action( 'wp_ajax_storyform_create_post', array( $this, 'storyform_create_post' ) ); 17 18 add_action( 'wp_ajax_storyform_update_post', array( $this, 'storyform_update_post' ) ); 18 add_action( 'wp_ajax_storyform_ publish_post', array( $this, 'storyform_publish_post' ) );19 add_action( 'wp_ajax_storyform_get_publish_url', array( $this, 'storyform_get_publish_url' ) ); 19 20 add_action( 'wp_ajax_storyform_delete_post', array( $this, 'storyform_delete_post' ) ); 20 21 add_action( 'wp_ajax_storyform_get_post_types', array( $this, 'storyform_get_post_types' ) ); … … 48 49 ); 49 50 51 add_submenu_page( 52 null, 53 'Publish post', 54 'Publish post', 55 'publish_posts', 56 'storyform-publish-post', 57 array( $this, 'storyform_publish_post' ) 58 ); 59 50 60 add_action( 'load-' . $hook_suffix , array( $this, 'hook_create_page' ), 99999 ); 51 61 } … … 240 250 } 241 251 252 public function storyform_get_publish_url(){ 253 check_ajax_referer( 'storyform-post-nonce' ); 254 $nonce = wp_create_nonce( 'storyform-post-nonce' ); 255 $id = intval( $_POST['id'] ); 256 $name = sanitize_title( $_POST['name'] ); 257 258 $url = admin_url( "admin.php?page=storyform-publish-post&_wpnonce={$nonce}&id={$id}&name={$name}" ); 259 260 echo json_encode( array( 'url' => $url ) ); 261 die(); 262 } 263 242 264 public function storyform_publish_post(){ 243 check_ajax_referer( 'storyform-post-nonce' ); 244 $id = sanitize_text_field( $_POST['id'] ); 245 $name = sanitize_title( $_POST['name'] ); 265 if( !is_admin() || !isset( $_GET[ 'page' ] ) || $_GET[ 'page' ] !== 'storyform-publish-post' ){ 266 return; 267 } 268 269 $nonce = isset( $_GET['_wpnonce'] ) ? $_GET[ '_wpnonce' ] : FALSE; 270 $id = intval( $_GET['id'] ); 271 $name = sanitize_title( $_GET['name'] ); 272 273 if ( ! wp_verify_nonce( $nonce, 'storyform-post-nonce' ) ) { 274 die( 'Invalid Nonce' ); 275 } 246 276 247 277 // Update post with revision if already published, keep name … … 270 300 wp_publish_post( $id ); 271 301 272 echo json_encode( array( 'url' => get_permalink( $id ) ) ); 273 die(); 302 wp_redirect( get_permalink( $id ) ); 274 303 } 275 304 -
storyform/trunk/editor/editor.js
r1229730 r1230971 2706 2706 }); 2707 2707 2708 WindowMessageManager.addEventListener(" publish-post", function (ev) {2708 WindowMessageManager.addEventListener("get-publish-url", function (ev) { 2709 2709 var data = ev.detail.data; 2710 2710 2711 2711 jQuery.post(ajaxurl, { 2712 action: "storyform_ publish_post",2712 action: "storyform_get_publish_url", 2713 2713 _ajax_nonce: storyform_nonce, 2714 2714 id: data.id, … … 2716 2716 }, function (data, textStatus, jqXHR) { 2717 2717 data = JSON.parse(data); 2718 data.action = " publish-post";2718 data.action = "get-publish-url"; 2719 2719 data.status = jqXHR.status; 2720 2720 WindowMessageManager.postMessage(ev.detail.source, data); … … 2740 2740 WindowMessageManager.addEventListener("redirect", function (ev) { 2741 2741 var data = ev.detail.data; 2742 if (data.newTab) { 2743 window.open(data.url, "_blank"); 2744 } else { 2745 document.location.href = data.url; 2746 } 2742 document.location.href = data.url; 2747 2743 }); 2748 2744 -
storyform/trunk/src/js/editor.js
r1229730 r1230971 68 68 }); 69 69 70 WindowMessageManager.addEventListener(' publish-post', function(ev){71 var data = ev.detail.data; 72 73 jQuery.post(ajaxurl, { 74 action : 'storyform_ publish_post',70 WindowMessageManager.addEventListener('get-publish-url', function(ev){ 71 var data = ev.detail.data; 72 73 jQuery.post(ajaxurl, { 74 action : 'storyform_get_publish_url', 75 75 _ajax_nonce: storyform_nonce, 76 76 id: data.id, … … 78 78 }, function(data, textStatus, jqXHR){ 79 79 data = JSON.parse(data); 80 data.action = ' publish-post';80 data.action = 'get-publish-url'; 81 81 data.status = jqXHR.status; 82 82 WindowMessageManager.postMessage(ev.detail.source, data); … … 102 102 WindowMessageManager.addEventListener('redirect', function(ev){ 103 103 var data = ev.detail.data; 104 if(data.newTab){ 105 window.open(data.url, '_blank'); 106 } else { 107 document.location.href = data.url; 108 } 109 104 document.location.href = data.url; 110 105 }); 111 106 -
storyform/trunk/storyform.php
r1229586 r1230971 5 5 Plugin Name: Storyform 6 6 Plugin URI: http://storyform.co/docs/wordpress 7 Version: 0.6. 17 Version: 0.6.2 8 8 Description: Plugin to enable Storyform on select posts. Works with both SEO and non-SEO permalinks. 9 9 Author: Storyform … … 13 13 14 14 global $storyform_version; 15 $storyform_version = '0.6. 1'; // The plugin version15 $storyform_version = '0.6.2'; // The plugin version 16 16 17 17 require_once( dirname( __FILE__ ) . '/config.php');
Note: See TracChangeset
for help on using the changeset viewer.