Changeset 1868361
- Timestamp:
- 05/03/2018 09:21:09 PM (8 years ago)
- File:
-
- 1 edited
-
coschedule-by-todaymade/trunk/tm-scheduler.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
coschedule-by-todaymade/trunk/tm-scheduler.php
r1856024 r1868361 3 3 Plugin Name: CoSchedule 4 4 Description: Plan, organize, and execute every content marketing project in one place with CoSchedule, an all-in-one content marketing editorial calendar solution. 5 Version: 3. 0.55 Version: 3.1.0 6 6 Author: CoSchedule 7 7 Author URI: http://coschedule.com/ … … 23 23 private $webhooks_url = "https://webhooks.coschedule.com"; 24 24 private $app = "https://app.coschedule.com"; 25 private $assets = "https:// d2lbmhk9kvi6z5.cloudfront.net";26 private $version = "3. 0.5";25 private $assets = "https://assets.coschedule.com"; 26 private $version = "3.1.0"; 27 27 private $build; 28 28 private $connected = false; … … 48 48 49 49 // Load variables 50 $this->build = intval( "7 7" );50 $this->build = intval( "78" ); 51 51 $this->token = get_option( 'tm_coschedule_token' ); 52 52 $this->calendar_id = get_option( 'tm_coschedule_calendar_id' ); … … 172 172 // Custom Slug Fix, replace data 173 173 add_filter( 'wp_insert_post_data', array( $this, 'fix_custom_slug_after' ), 20 ); 174 175 // Open Graph Previews 176 add_filter( 'posts_results', array( $this, 'set_post_visibility' ), 10, 2 ); 174 177 } 175 178 … … 731 734 } 732 735 736 /** 737 * Retrieves a post with HTML 738 * 739 * @param $data_args 740 */ 741 public function tm_aj_get_full_html_post( $data_args ) { 742 try { 743 if ( isset( $data_args['post_id'] ) ) { 744 $post_id = $data_args['post_id']; 745 } else { 746 throw new Exception( 'Invalid API call. Missing argument(s).' ); 747 } 748 749 $nonce = wp_create_nonce( 'coschedule_preview_' . $this->token .' _post_id-' . $post_id ); 750 wp_safe_redirect( add_query_arg( 'cos_preview', $nonce, get_permalink( $post_id ) ), 301 ); 751 exit; 752 } catch ( Exception $e ) { 753 $data['error'] = $e->getMessage(); 754 $this->respond_json_and_die( $data ); 755 } 756 } 757 758 public function set_post_visibility( $posts ) { 759 remove_filter( 'posts_results', array( $this, 'set_post_visibility' ), 10 ); 760 if ( empty( $posts ) || is_user_logged_in() || ! $this->is_preview_valid($posts) ) { 761 return $posts; 762 } 763 764 // Set in-memory status to 'publish' to enable the preview for this single request. This does not publish the post. 765 $posts[0]->post_status = 'publish'; 766 767 // Disable comments and pings for this post while previewing. 768 add_filter( 'comments_open', '__return_false' ); 769 add_filter( 'pings_open', '__return_false' ); 770 771 return $posts; 772 } 773 774 public function is_preview_valid($posts) { 775 if ( empty( $_GET[ 'cos_preview' ] ) || empty( $posts ) ) { 776 return false; 777 } 778 779 return wp_verify_nonce( $_GET[ 'cos_preview' ], 'coschedule_preview_' . $this->token .' _post_id-' . $posts[0]->ID ); 780 } 733 781 734 782 /** … … 985 1033 'tm_aj_import_post', 986 1034 'tm_aj_get_html_post', 1035 'tm_aj_get_full_html_post', 987 1036 ); 988 1037
Note: See TracChangeset
for help on using the changeset viewer.