Making WordPress.org

Changeset 8488


Ignore:
Timestamp:
03/21/2019 11:29:36 PM (6 years ago)
Author:
coreymckrill
Message:

WordCamp MES: Simplify saving of post meta to avoid accidental data loss

When an MES post is saved, the save routine logic looks for specific keys in
$_POST and for the ones it finds, it updates related post meta fields. For
ones it doesn't find, it deletes related post meta fields.

When updating an MES from the Edit screen, this is fine because all of the
postmeta values have related metabox fields, so they will always be present
in $_POST during the save_post action. But when using Quick Edit, those
metaboxes don't exist, so everything gets deleted.

Removing the lines that delete post meta fields when they are not present
fixes this issue. This should be ok because the fields will still be updated
with empty values if the related fields are cleared on the Edit screen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/multi-event-sponsors/classes/mes-sponsor.php

    r6626 r8488  
    215215            array_walk( $new_values[ 'mes_regional_sponsorships' ], 'absint' );
    216216            update_post_meta( $post_id, 'mes_regional_sponsorships', $new_values[ 'mes_regional_sponsorships' ] );
    217         } else {
    218             delete_post_meta( $post_id, 'mes_regional_sponsorships' );
    219217        }
    220218
     
    231229            if ( isset( $new_values["mes_$field"] ) ) {
    232230                update_post_meta( $post_id, "mes_$field", sanitize_text_field( $new_values["mes_$field"] ) );
    233             } else {
    234                 delete_post_meta( $post_id, "mes_$field" );
    235231            }
    236232        }
     
    239235        if ( $sponsor_agreement ) {
    240236            update_post_meta( $post_id, 'mes_sponsor_agreement', $sponsor_agreement );
    241         } else {
    242             delete_post_meta( $post_id, 'mes_sponsor_agreement' );
    243237        }
    244238    }
Note: See TracChangeset for help on using the changeset viewer.