I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user’s cookies to retrieve preview page source:
$preview_link = set_url_scheme( get_permalink( $post->ID ) );
$preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) );
$cookies = array();
foreach ( $_COOKIE as $name => $value ) {
$cookies[] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) );
}
$request = wp_remote_get( $preview_link, array( 'cookies' => $cookies ) );
$body = wp_remote_retrieve_body( $request );
Related Posts:
- How to add an admin notice upon post save/update
- Post preview mechanism architecture
- Post/Page Preview Template
- How to mark articles as read?
- Listen to Post action
- Manipulate post category after time
- How to disable drafts?
- WooCommerce – Create Products Programatically [closed]
- which action to hook to in order to perform post-publish action
- Cannot access current post’s ID in custom plugin
- Set number of article per number of page
- How to change post status from publish to draft using hook in wordpress?
- prevent showing posts of an specific category in admin posts section
- Enable commenting on front-end preview page for pending posts
- Does WordPress remove draft status automatically?
- Using radio button meta data from a custom meta box
- Don’t post or draft if post already exists
- Post preview and oembed provider issue using polylang plugin with subdomains
- Two posts are loaded instead of one?
- What differences are there between a Privately Published post and a Draft post?
- How to store an extra (surrogate) ID when creating a post with wp_insert_post?
- Global $post not working in OOP function WordPress
- Bulk unpublish posts between specific dates (e.g. from April 2017 and earlier)?
- WordPress version 3.8 – Preview button not working for editor
- Define a wordpress constant through plugin functions?
- Dashboard :10 Last draft page and 10 last pending review page (metabox)
- Custom post preview without saving
- How to get post bulk edit action trigger and get edited post ids?
- Hiding Draft Post In Admin
- updating a post doesn’t trigger a function
- Hide a specific category in admin All Posts page (WordPress)
- Prevent Delete Attachment by URL or When Submit
- What hook do you use to update a post?
- Updating post data on save (save_post vs wp_insert_post_data)
- Lost draft under all posts and drafts
- Change target of view link in admin
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- How to get the old WordPress Draft Editor view back with the Word count?
- Filter Hook for post table (not columns)
- why str_replace targeting pages instead just targeting post?
- l accidentally permanently deleted a Draft. There’s any way I can recover it?
- Get author posts count after excluding a category
- Stop post submission without losing data?
- Cant’ Grab WordPress Built-in Posts Through Loop
- How can my plugin display a populated new post window
- search content of pages and list in wp-admin
- Finding a post’s slug
- Insert specific information to a posts of a predefined category
- Hide content from Post Preview
- Open a wordpress single post in a lightbox without the header and footer
- Preview page/post revisions without overwriting current content
- Site/Post preview is not working on all social media
- Hook when post is set from published to draft?
- My posts are getting to Auto draft when I try to Publish
- WordPress: Develop multiple posts with different data
- How do I change the post title’s link on the posts page?
- How do I prevent draft posts from being accessible publicly?
- Connection dropped due to file size
- Update user meta when post published no working
- Fixing the WP Post Object for Custom Route
- Post preview in iframe without saving the post
- Export Posts with specific custom fields by sql
- Custom plugin to get related posts by category
- how to chang preview of list of articles of one category?
- WordPress is creating a lot of draft posts
- Preview own posts if logged in
- Latest news mini images
- Hide the contents for specific post
- Return All Post from publish to draft [duplicate]
- Display draft posts on single pages [duplicate]
- Error 404 blog/page/2/
- Onclick open posts displayed in slider in a popup [closed]
- How do I save JS classes being applied to the WP dashboard via custom plugin?
- WordPress + Polylang – Error 404 when trying to preview draft post on different language
- display all posts in wordpress admin
- When and Where is `global $post` Set and Available?
- How to Sort Custom columns in admin
- Shortcode Not displayed at the Right Place [duplicate]
- How to show video from specific category on sidebar?
- Display posts with comments closed, with pagination?
- How can I add a meta-box to the posts editor containing all items of a custom taxonomy as checkbox?
- can’t use the page_test method to check pagination
- Post body text occupying featured image space before it loads
- Multi row post list
- Add field to user meta table in database when link is clicked
- How can I show posts for a single category?
- Custom Fields for Author Box
- Custom home page with full post for first one only
- Need to know custom code to display random and most viewed posts in wordpress posts and pages
- Load widget only on blog posts
- Widget to show posts in the sidebar basing on its IDs
- Page of posts made to look like homepage
- How can I to add upload functionality outside of the admin area?
- Related post not showing table of content
- Added a ACF field to custom page and want the results to show as a column in admin
- How to prevent clicking on posts
- Link post to blog from a static page
- What is wrong with this wp_query?
- Post count by Parent Category
- How do i retrive a post from a custom post type