Just a heads-up.
on line 106 of simple-preview.php, you grab $_POST['post_ID']
– but on a new post it’s not defined. Even though that function triggers on save, the initial autodraft appears to trigger it and it’s still throwing the notice, so I’d advise adding a check for it first and bailing out if it’s not present. Something like if ( empty($_POST['post_ID']) )
Is it possible to generate these preview links via a function call? Thanks!
]]>Noticed an unanswered ticket here about this.
I saw this on my local site and corrected it by changing the fake_publish
function to use empty instead of isset:
function fake_publish($posts) {
if(!empty($posts)){
$posts[0]->post_status = 'publish';
return $posts;
}
}
It’s just a warning, but it’s one less ??
HTH
Has the issue with PHP7.x been resolved? The site I’m working on does using PHP7.
When I send tick the preview box and savem then send a preview link to my client, when she clicks she just gets a 404 page.
]]>Hi there,
When doing a regular preview of a draft post, using certain modules from the visual builder in BeTheme (Muffin Builder), I get this error:
Warning: Creating default object from empty value in /home/couragem/public_html/wp-content/plugins/simple-preview/simple-preview.php on line 140
Fatal error: Uncaught Error: Call to a member function get_gallery_attachment_ids() on null in /home/couragem/public_html/wp-content/themes/betheme/functions/theme-shortcodes.php:1530 Stack trace: #0 /home/couragem/public_html/wp-content/themes/betheme/functions/builder/front.php(1051): sc_shop_slider(Array) #1 /home/couragem/public_html/wp-content/themes/betheme/functions/builder/front.php(408): mfn_print_shop_slider(Array) #2 /home/couragem/public_html/wp-content/themes/betheme/includes/content-single.php(225): mfn_builder_print(7804) #3 /home/couragem/public_html/wp-includes/template.php(690): require('/home/couragem/...') #4 /home/couragem/public_html/wp-includes/template.php(647): load_template('/home/couragem/...', false) #5 /home/couragem/public_html/wp-includes/general-template.php(155): locate_template(Array, true, false) #6 /home/couragem/public_html/wp-content/themes/betheme/single.php(60): get_template_part('includes/conten...', 'single') #7 /home/couragem/public_html/wp-includes/template-loader.php(74): inclu in /home/couragem/public_html/wp-content/themes/betheme/functions/theme-shortcodes.php on line 1530
Any suggestions?
]]>Okay, I’ve added the support for custom post types:
// hack to add custom post types to the query
$oPost = get_post( $this->id );
$this->post_type = $oPost->post_type;
add_action( 'pre_get_posts', array( $this, 'add_post_type_to_query' ) );
add_filter('posts_results', array(&$this, 'fake_publish'));
function add_post_type_to_query( &$query ) {
$query->set( 'post_type', $this->post_type );
}
And add $post_type
to the class vars.
Cheers!
]]>We are running PHP 7.1 and are getting the following warning when running the Simple Preview plugin:
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Simple_Preview has a deprecated constructor in /app01/html/aaa_ncnu/wp-content/plugins/simple-preview/simple-preview.php on line 45
Can you please update the class constructor in the plugin so it uses the PHP 7-valid __construct() method instead of the old-style constructor method that uses the class name as the constructor?
Instead of constructing the class like this:
// Plugin startup
function Simple_Preview() {
if ( ! is_admin() ) {
add_action('init', array(&$this, 'show_preview'));
} else {
register_activation_hook(__FILE__, array(&$this, 'init'));
add_action('admin_menu', array(&$this, 'meta_box'));
add_action('save_post', array(&$this, 'save_post'));
}
}
We’d construct it like this:
// Plugin startup
function __construct() {
if ( ! is_admin() ) {
add_action('init', array(&$this, 'show_preview'));
} else {
register_activation_hook(__FILE__, array(&$this, 'init'));
add_action('admin_menu', array(&$this, 'meta_box'));
add_action('save_post', array(&$this, 'save_post'));
}
}
]]>
This warning appears at the top of the previewed page:
Warning: Creating default object from empty value in /home/[MY USER]/public_html/wp-content/plugins/simple-preview/simple-preview.php on line 129
]]>Hello,
if the user is authenticated and the plugin is activated the preview is not working even if the user has the rights to view the post preview. I have fixed this with the following change:
In simple-preview.php, line 114 replace the code:
if ( !isset($preview_posts[$this->id])
with the following code:
if ( !isset($preview_posts[$this->id]) AND !current_user_can('edit_post', $this->id))
Regards
]]>I’m using wordpress 3.2.1 and the plugin seems to be broken. The preview doesn’t display where you’re not loged in.
It’s the first time I use this plugin. I don’t know if he was workeing before
Thaks for your help
Hi,
I believe an option to always allow anonymous preview by default would be very useful nowadays. That is because of post-scheduling in social networks, where a preview would be very useful.
Thanks!
]]>