Changeset 1816
- Timestamp:
- 08/06/2015 11:05:20 PM (10 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/classes/payment-request.php
r1732 r1816 88 88 ) 89 89 ); 90 } 91 90 91 register_post_status( 92 'incomplete', 93 array( 94 'label' => _x( 'Incomplete', 'post', 'wordcamporg' ), 95 'label_count' => _nx_noop( 'Incomplete<span class="count">(%s)</span>', 'Incomplete <span class="count">(%s)</span>', 'wordcamporg' ), 96 'public' => true, 97 'publicly_queryable' => false, 98 ) 99 ); 100 } 101 102 /** 103 * Register meta boxes 104 */ 92 105 public function init_meta_boxes() { 106 /** @var $post WP_Post */ 107 global $post; 108 93 109 // We're build our own Publish box, thankyouverymuch 94 110 remove_meta_box( 'submitdiv', self::POST_TYPE, 'side' ); … … 103 119 ); 104 120 121 if ( 'incomplete' != $post->post_status && current_user_can( 'manage_network' ) ) { 122 add_meta_box( 123 'wcp_mark_incomplete', 124 __( 'Mark as Incomplete', 'wordcamporg' ), 125 array( $this, 'render_mark_incomplete_metabox' ), 126 self::POST_TYPE, 127 'side', 128 'high' 129 ); 130 } 131 105 132 add_meta_box( 106 133 'wcp_general_info', … … 153 180 154 181 require_once( dirname( __DIR__ ) . '/views/payment-request/metabox-status.php' ); 182 } 183 184 /** 185 * Render the Mark as Incomplete metabox 186 * 187 * @param WP_Post $post 188 */ 189 public function render_mark_incomplete_metabox( $post ) { 190 wp_nonce_field( 'mark_incomplete', 'mark_incomplete_nonce' ); 191 192 require_once( dirname( __DIR__ ) . '/views/payment-request/metabox-mark-incomplete.php' ); 155 193 } 156 194 … … 539 577 } 540 578 579 if ( 'incomplete' == $post->post_status && 'incomplete' != get_query_var( 'post_status' ) ) { 580 $states['incomplete'] = __( 'Incomplete', 'wordcamporg' ); 581 } 582 541 583 return $states; 542 584 } … … 595 637 public function update_request_status( $post_data, $post_data_raw ) { 596 638 if ( $this->post_edit_is_actionable( $post_data ) ) { 597 $previous_status = $post_data['post_status']; 598 $post_data['post_status'] = strtotime( sanitize_text_field( $_POST['date_vendor_paid'] ) ) ? 'paid' : 'unpaid'; 599 600 if ( 'paid' != $previous_status && 'paid' == $post_data['post_status'] ) { 601 $this->notify_requester_payment_made( $post_data_raw['ID'], $post_data ); 639 640 if ( 'on' == $_POST['wcp_mark_incomplete_checkbox'] && ! empty( $_POST['wcp_mark_incomplete_notes'] ) ) { 641 $post_data['post_status'] = 'incomplete'; 642 $this->notify_requester_request_incomplete( $post_data_raw['ID'], $post_data, $post_data_raw ); 643 } else { 644 $previous_status = $post_data['post_status']; 645 $post_data['post_status'] = strtotime( sanitize_text_field( $_POST['date_vendor_paid'] ) ) ? 'paid' : 'unpaid'; 646 647 if ( 'paid' != $previous_status && 'paid' == $post_data['post_status'] ) { 648 $this->notify_requester_payment_made( $post_data_raw['ID'], $post_data ); 649 } 602 650 } 603 651 } … … 637 685 638 686 /** 687 * Notify the payment requester that it has been marked as paid. 688 * 689 * @param int $request_id 690 * @param array $post_data 691 * @param array $post_data_raw 692 */ 693 protected function notify_requester_request_incomplete( $request_id, $post_data, $post_data_raw ) { 694 if ( ! $to = $this->get_requester_formatted_email( $post_data['post_author'] ) ) { 695 return; 696 } 697 698 $subject = sprintf( '`%s` is incomplete', $post_data['post_title'] ); 699 $headers = array( 'Reply-To: support@wordcamp.org' ); 700 701 $message = sprintf( 702 "The request for `%s` has been marked as incomplete by WordCamp Central. 703 704 The reason for this is: %s 705 706 You can complete the request at: 707 708 %s 709 710 If you have any questions, please reply to let us know.", 711 $post_data['post_title'], 712 sanitize_text_field( $post_data_raw['wcp_mark_incomplete_notes'] ), 713 admin_url( sprintf( 'post.php?post=%s&action=edit', $request_id ) ) 714 ); 715 $message = str_replace( "\t", '', $message ); 716 717 wp_mail( $to, $subject, $message, $headers ); 718 } 719 720 /** 639 721 * Save the post's data 640 722 * … … 648 730 649 731 // Verify nonces 650 $nonces = array( 'status_nonce', ' general_info_nonce', 'payment_details_nonce', 'vendor_details_nonce' ); // todo add prefix to all of these732 $nonces = array( 'status_nonce', 'mark_incomplete_nonce', 'general_info_nonce', 'payment_details_nonce', 'vendor_details_nonce' ); // todo add prefix to all of these 651 733 652 734 foreach ( $nonces as $nonce ) { -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/javascript/wordcamp-payments.js
r995 r1816 18 18 $( '#payment_category' ).change( $.wordcampPayments.toggleOtherCategoryDescription ); 19 19 $( '#wcp_files' ).find( 'a.wcp-insert-media' ).click( $.wordcampPayments.showUploadModal ); 20 $( '#wcp_mark_incomplete_checkbox' ).click( $.wordcampPayments.requireNotes ); 20 21 }, 21 22 … … 109 110 } ); 110 111 } 112 }, 113 114 /** 115 * Require notes when the request is being marked as incomplete 116 */ 117 requireNotes : function() { 118 var notes = $( '#wcp_mark_incomplete_notes' ); 119 120 if ( 'checked' === $( '#wcp_mark_incomplete_checkbox' ).attr( 'checked' ) ) { 121 notes.attr( 'required', true ); 122 } else { 123 notes.attr( 'required', false ); 124 } 111 125 } 112 126 }; -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/views/payment-request/metabox-status.php
r995 r1816 6 6 7 7 <span id="post-status-display"> 8 <?php if ( 'paid' == $post->post_status ) : ?> 8 <?php if ( 'incomplete' == $post->post_status ) : ?> 9 <?php _e( 'Incomplete', 'wordcamporg' ); ?> 10 <?php elseif ( 'paid' == $post->post_status ) : ?> 9 11 <?php _e( 'Paid' ); ?> 10 12 <?php else : ?>
Note: See TracChangeset
for help on using the changeset viewer.