Bug in autofocus-post-meta

  • Problem
  • Updated 4 years ago
There is a problem with the checkbox. It, somehow, takes the value of a text field.

If you enter copyright value and save you will get show_gallery value = copyright value.

As a result it triggers cycle script on single post page. Photos might not rotate, but if you look into source you will see it.

Also, since there is no gallery to rotate it generates infinite error. Every time you scroll the page up or down.

I am trying to rewrite post-meta file, but not yet successful.
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes

Posted 4 years ago

  • 1
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
The problem is in save_af_meta_data function.
Correcting this function will be sufficient enough.

But I still can't get it right.
Photo of Allan Cole

Allan Cole, Owner

  • 2047 Posts
  • 112 Reply Likes
Interesting. Adding this to the bug fix list.
Thanks.
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
Allan, I believe this time i did it right. First test went well.

All trouble came from just a few symbols.

So here is the part of save_af_meta_data function, with changes:
$data = '';
if ( isset( $_POST[$meta_box['name']] ) ) {
$data = $_POST[$meta_box['name']];
}

if ( get_post_meta($post_id, $meta_box['name']) == '' )
add_post_meta($post_id, $meta_box['name'], $data, true);

elseif ( isset( $data ) && ($data != get_post_meta($post_id, $meta_box['name'], true)) )
update_post_meta($post_id, $meta_box['name'], $data);

elseif ( isset( $data ) && $data == '')
delete_post_meta($post_id, $meta_box['name']);


First line - $data = ''; Prevents from checkbox taking wrong value
Last line - delete_post_meta($post_id, $meta_box['name']); Shortened to make clean delete
Photo of AxelYa

AxelYa

  • 548 Posts
  • 105 Reply Likes
I also made some changes to make this file translatable, but it is difficult to explain using fingers.
Photo of Allan Cole

Allan Cole, Owner

  • 2047 Posts
  • 112 Reply Likes
NICE! I’ll try an apply this to the next update...