Making WordPress.org

Changeset 2626


Ignore:
Timestamp:
02/26/2016 12:30:19 AM (9 years ago)
Author:
kovshenin
Message:

WordCamp.org: In payment requests, log and timestamp update on save_post, regardless of lack of form submit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php

    r2624 r2626  
    700700     */
    701701    public function save_payment( $post_id, $post ) {
     702
     703        // Update the timestamp and logs either way.
     704        if ( $post->post_type == self::POST_TYPE && $post_id ) {
     705            update_post_meta( $post_id, '_wcb_updated_timestamp', time() );
     706
     707            $user = get_user_by( 'id', get_current_user_id() );
     708
     709            // Look at post status transitions.
     710            foreach ( self::$transition_post_status as $data ) {
     711                list( $new, $old, $transition_post ) = $data;
     712
     713                // Transitioning a different post.
     714                if ( $transition_post->ID != $post->ID )
     715                    continue;
     716
     717                if ( $new == 'incomplete' || $new == 'wcb-incomplete' ) {
     718                    $incomplete_text = get_post_meta( $post->ID, '_wcp_incomplete_notes', true );
     719                    $incomplete_text = preg_replace( '#\.$#', '', $incomplete_text ); // trailing-undot-it.
     720                    WordCamp_Budgets::log( $post->ID, $user->ID, sprintf( 'Marked as incomplete: %s', $incomplete_text ), array(
     721                        'action' => 'marked-incomplete',
     722                        'reason' => 'maybe notes',
     723                    ) );
     724
     725                    $this->notify_requester_request_incomplete( $post->ID );
     726                    WordCamp_Budgets::log( $post->ID, $user->ID, 'Incomplete notification e-mail sent.', array(
     727                        'action' => 'incomplete-notification-sent',
     728                    ) );
     729
     730                } elseif ( $new == 'paid' || $new == 'wcb-paid' ) {
     731                    WordCamp_Budgets::log( $post->ID, $user->ID, 'Marked as paid', array(
     732                        'action' => 'marked-paid',
     733                    ) );
     734
     735                    $this->notify_requester_payment_made( $post->ID );
     736                    WordCamp_Budgets::log( $post->ID, $user->ID, 'Paid notification e-mail sent.', array(
     737                        'action' => 'paid-notification-sent',
     738                    ) );
     739
     740                } elseif ( $old == 'auto-draft' ) {
     741                    WordCamp_Budgets::log( $post->ID, $user->ID, 'Request created', array(
     742                        'action' => 'updated',
     743                    ) );
     744                }
     745            }
     746
     747            WordCamp_Budgets::log( $post->ID, $user->ID, 'Request updated', array(
     748                'action' => 'updated',
     749            ) );
     750        }
     751
     752        // The rest only if triggered by a user submitting a form.
    702753        if ( ! WordCamp_Budgets::post_edit_is_actionable( $post, self::POST_TYPE ) ) {
    703754            return;
     
    717768        WordCamp_Budgets::validate_save_payment_method_fields( $post_id, 'camppayments' );
    718769        $this->sanitize_save_misc_fields( $post_id );
    719 
    720         update_post_meta( $post_id, '_wcb_updated_timestamp', time() );
    721         $user = get_user_by( 'id', get_current_user_id() );
    722 
    723         // Look at post status transitions.
    724         foreach ( self::$transition_post_status as $data ) {
    725             list( $new, $old, $transition_post ) = $data;
    726 
    727             // Transitioning a different post.
    728             if ( $transition_post->ID != $post->ID )
    729                 continue;
    730 
    731             if ( $new == 'incomplete' || $new == 'wcb-incomplete' ) {
    732                 $incomplete_text = get_post_meta( $post->ID, '_wcp_incomplete_notes', true );
    733                 $incomplete_text = preg_replace( '#\.$#', '', $incomplete_text ); // trailing-undot-it.
    734                 WordCamp_Budgets::log( $post->ID, $user->ID, sprintf( 'Marked as incomplete: %s', $incomplete_text ), array(
    735                     'action' => 'marked-incomplete',
    736                     'reason' => 'maybe notes',
    737                 ) );
    738 
    739                 $this->notify_requester_request_incomplete( $post->ID );
    740                 WordCamp_Budgets::log( $post->ID, $user->ID, 'Incomplete notification e-mail sent.', array(
    741                     'action' => 'incomplete-notification-sent',
    742                 ) );
    743 
    744             } elseif ( $new == 'paid' || $new == 'wcb-paid' ) {
    745                 WordCamp_Budgets::log( $post->ID, $user->ID, 'Marked as paid', array(
    746                     'action' => 'marked-paid',
    747                 ) );
    748 
    749                 $this->notify_requester_payment_made( $post->ID );
    750                 WordCamp_Budgets::log( $post->ID, $user->ID, 'Paid notification e-mail sent.', array(
    751                     'action' => 'paid-notification-sent',
    752                 ) );
    753 
    754             } elseif ( $old == 'auto-draft' ) {
    755                 WordCamp_Budgets::log( $post->ID, $user->ID, 'Request created', array(
    756                     'action' => 'updated',
    757                 ) );
    758             }
    759         }
    760 
    761         WordCamp_Budgets::log( $post->ID, $user->ID, 'Request updated', array(
    762             'action' => 'updated',
    763         ) );
    764770    }
    765771
Note: See TracChangeset for help on using the changeset viewer.