Making WordPress.org


Ignore:
Timestamp:
08/23/2018 09:47:59 PM (6 years ago)
Author:
vedjain
Message:

WordCamp: Added list of original values wcpt_metabox_save_done do_action so that any callback can use original values to see if anything is changed.
Also make use of original values in update_venue_address and fix a bug where it was always returning early because $new_address has already just been saved to the post meta.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php

    r7607 r7629  
    5656            add_action( 'plugins_loaded', array( $this, 'schedule_cron_jobs' ), 11 );
    5757            add_action( 'wcpt_close_wordcamps_after_event', array( $this, 'close_wordcamps_after_event' ) );
    58             add_action( 'wcpt_metabox_save_done', array( $this, 'update_venue_address' ) );
     58            add_action( 'wcpt_metabox_save_done', array( $this, 'update_venue_address' ), 10, 2 );
    5959            add_action( 'wcpt_metabox_save_done', array( $this, 'update_mentor' ) );
    6060        }
     
    152152         * These are used for the maps on Central, stats, etc.
    153153         *
    154          * @param int $post_id Post id
    155          */
    156         public function update_venue_address( $post_id ) {
     154         * @param int   $post_id              Post id
     155         * @param array $original_meta_values Original meta values before save
     156         */
     157        public function update_venue_address( $post_id, $original_meta_values ) {
    157158            if ( $this->get_event_type() !== get_post_type() ) {
    158159                return;
     
    161162            // If the venue address was changed, update its coordinates
    162163            $new_address = $_POST[ wcpt_key_to_str( 'Physical Address', 'wcpt_' ) ];
    163             if ( $new_address === get_post_meta( $post_id, 'Physical Address', true ) ) {
     164            if ( $new_address === $original_meta_values['Physical Address'] ) {
    164165                return;
    165166            }
Note: See TracChangeset for help on using the changeset viewer.