Making WordPress.org

Changeset 2516


Ignore:
Timestamp:
02/16/2016 10:01:52 PM (11 years ago)
Author:
iandunn
Message:

WordCamp Payments: Ensure new payment requests always have a post_date_gmt.

Without one, their corresponding index row will be ignored when exporting payments to the bank.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/payment-requests-dashboard.php

    r2500 r2516  
    144144                        'post_id' => $request->ID,
    145145                        'created' => get_post_time( 'U', true, $request->ID ),
    146                                 // todo Sometimes this is empty. Core normally catches this (r8636), but misses in our case because we don't use drafts. #1350-meta might have the side-effect of solving this.
    147146                        'paid'    => absint( get_post_meta( $request->ID, '_camppayments_date_vendor_paid', true ) ),
    148147                        'due' => absint( get_post_meta( $request->ID, '_camppayments_due_by', true ) ),
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php

    r2515 r2516  
    2121                // Saving posts
    2222                add_filter( 'wp_insert_post_data',    array( $this, 'update_request_status' ), 10, 2 );
     23                add_filter( 'wp_insert_post_data',    array( $this, 'ensure_post_date_gmt_set' ), 10, 2 );
    2324                add_action( 'save_post',              array( $this, 'save_payment' ), 10, 2 );
    2425                add_filter( 'map_meta_cap',           array( $this, 'modify_capabilities' ), 10, 4 );
    … …  
    514515                                        $this->notify_requester_payment_made( $post_data_raw['ID'], $post_data );
    515516                                }
     517                        }
     518                }
     519
     520                return $post_data;
     521        }
     522
     523        /**
     524         * Ensure that new posts have the `post_date_gmt` field populated.
     525         *
     526         * Core only handles this for post types that use the `draft` status (see r8636).
     527         *
     528         * @param array $post_data
     529         * @param array $post_data_raw
     530         *
     531         * @return array
     532         */
     533        public function ensure_post_date_gmt_set( $post_data, $post_data_raw ) {
     534                if ( 'auto-draft' !== $post_data['post_status'] ) {
     535                        if ( '0000-00-00 00:00:00' === $post_data['post_date_gmt'] ) {
     536                                $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
    516537                        }
    517538                }
Note: See TracChangeset for help on using the changeset viewer.