[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog
  • #
  • &
  • A
  • B
  • C
  • D
  • E
  • F
  • G
  • H
  • I
  • J
  • L
  • M
  • N
  • O
  • P
  • Q
  • R
  • S
  • T
  • U
  • V
  • W
  • [

Misplaced comments fix in oik v1.17

For a while now I’ve been rather confused as to the location of comments against some of my posts and pages. People’s comments were being added to the attached images rather than the original post or page. Additionally, pages or posts could display a comment form even when the checkbox to allow comments was not ticked. I tracked the problem down yesterday evening, and have now developed a fix. This will be in oik version 1.17

Problem detail

  • Reader writes a comment against a post/page
  • The comment is misplaced; it’s associated to a different post or page, or sometimes an attached image
  • Replies to the comment appear against the misplaced comment

Explanation

In cases where a shortcode (such as [bw_list] was being used to list attached or related items, the comment form being displayed was associated with the most recently loaded post id, not the original post.

This is mostly due to default processing. In the WordPress comment_form() function, if the $post_id is not specified then the routine uses the global $id variable instead. The global $id variable gets set by the setup_postdata() function but doesn’t always get reset when the global $post is changed. So the values of $post-ID and $id can get out of sync.

A couple of the dynamic shortcodes load multiple posts and invoke the routines that set the global $id variable.

When time the comment_form() function is called in the theme’s template processing, the value that is set in $id no longer matches the post ID of the main content being displayed.

So any comment that is created using the generated form is associated with the wrong post.

Fix

The fix is to save any values that can be corrupted during shortcode expansion and reset them after the expansion. The function that oik v1.17 uses to do this is bw_global_post(). An alternative fix would be to avoid calling setup_postdata(). These changes are currently being tested.

Published: November 21, 2012 | Last updated: December 4, 2020

Filed Under: 1.17, News, oik Tagged With: comments, misplaced

Information

Component:

Recent plugin updates

oik-themes v1.4.0 

Update to oik-themes v1.4.0 to support Full Site Editing (FSE) themes. FSE themes, which are currently experimental, deliver block based templates and template parts.

 ...
oik-clone v2.0.1 oik-clone v2.0.1 contains a fix for a 500 internal server error being produced when cloning content with certain taxonomy terms. ...
SB Chart block v0.1.1 

Update to SB Chart block v0.1.1 for improved enqueing of the chart.js Javascript and better colours in the Gutenberg palette.

 ...
Slog v1.3.1 

Update to Slog v1.3.1 for a new Driver tab and improved display of charts grouping Elapsed times.

 ...
SB-Chart-Block v0.0.8 SB-Chart-Block v0.0.8, a WordPress single block plugin, supports 4 different chart types; Line, Bar, Horizontal bar and Pie. ...

Plugins

  • All Plugins
  • oik base plugin
  • FREE oik plugins
  • WordPress plugins
  • Premium oik plugins

Themes

  • FREE themes
  • Bespoke themes
  • Premium themes

Blocks

  • All Blocks
  • Block examples
  • About Blocks

Shortcodes

  • All Shortcodes
  • Shortcode examples
  • About Shortcodes

Reference

  • About APIs
  • All APIs
  • All Classes
  • All Files
  • All Hooks

Support

  • Contact
  • Cookies policy
  • Get API key
  • Privacy
  • Request support
  • Sitemap
  • Stay informed
  • Terms and Conditions
oik-plugins
Email: [email protected]

Weight shipping plugins

Find out which cart weight shipping plugin you need for your WooCommerce site.
Which cart weight based plugin do I need?

Site:  www.oik-plugins.com
© Copyright oik-plugins 2011-2021. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins