Changeset 2747
- Timestamp:
- 03/14/2016 06:17:18 PM (10 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes
- Files:
-
- 4 edited
-
payment-requests-dashboard.php (modified) (3 diffs)
-
reimbursement-requests-dashboard.php (modified) (1 diff)
-
reimbursement-requests-list-table.php (modified) (1 diff)
-
wordcamp-budgets-dashboard.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/payment-requests-dashboard.php
r2694 r2747 20 20 add_action( 'init', array( __CLASS__, 'upgrade' ) ); 21 21 add_action( 'init', array( __CLASS__, 'process_import_request' ) ); 22 23 // Dashboard actions.24 add_action( 'init', array( __CLASS__, 'process_action_approve' ) );25 add_action( 'init', array( __CLASS__, 'process_action_set_pending_payment' ) );26 22 27 23 // Diff-based updates to the index. … … 245 241 <h1>Vendor Payments</h1> 246 242 247 <?php do_action( 'admin_notices' ); ?>248 243 <?php settings_errors(); ?> 249 244 … … 284 279 285 280 <?php 286 }287 288 /**289 * Process Approve button in network admin290 */291 public static function process_action_approve() {292 if ( ! current_user_can( 'manage_network' ) )293 return;294 295 if ( empty( $_GET['wcb-approve'] ) || empty( $_GET['_wpnonce'] ) )296 return;297 298 list( $blog_id, $post_id ) = explode( '-', $_GET['wcb-approve'] );299 300 if ( ! wp_verify_nonce( $_GET['_wpnonce'], sprintf( 'wcb-approve-%d-%d', $blog_id, $post_id ) ) ) {301 add_action( 'admin_notices', function() {302 ?><div class="notice notice-error is-dismissible">303 <p><?php _e( 'Error! Could not verify nonce.', 'wordcamporg' ); ?></p>304 </div><?php305 });306 return;307 }308 309 switch_to_blog( $blog_id );310 $post = get_post( $post_id );311 if ( $post->post_type == 'wcp_payment_request' ) {312 $post->post_status = 'wcb-approved';313 wp_insert_post( $post );314 315 WordCamp_Budgets::log( $post->ID, get_current_user_id(), 'Request approved via Network Admin', array(316 'action' => 'approved',317 ) );318 319 add_action( 'admin_notices', function() {320 ?><div class="notice notice-success is-dismissible">321 <p><?php _e( 'Success! Request has been marked as approved.', 'wordcamporg' ); ?></p>322 </div><?php323 });324 }325 restore_current_blog();326 }327 328 /**329 * Process "Set as Pending Payment" dashboard action.330 */331 public static function process_action_set_pending_payment() {332 if ( ! current_user_can( 'manage_network' ) )333 return;334 335 if ( empty( $_GET['wcb-set-pending-payment'] ) || empty( $_GET['_wpnonce'] ) )336 return;337 338 list( $blog_id, $post_id ) = explode( '-', $_GET['wcb-set-pending-payment'] );339 340 if ( ! wp_verify_nonce( $_GET['_wpnonce'], sprintf( 'wcb-set-pending-payment-%d-%d', $blog_id, $post_id ) ) ) {341 add_action( 'admin_notices', function() {342 ?><div class="notice notice-error is-dismissible">343 <p><?php _e( 'Error! Could not verify nonce.', 'wordcamporg' ); ?></p>344 </div><?php345 });346 return;347 }348 349 switch_to_blog( $blog_id );350 $post = get_post( $post_id );351 if ( $post->post_type == 'wcp_payment_request' ) {352 $post->post_status = 'wcb-pending-payment';353 wp_insert_post( $post );354 355 WordCamp_Budgets::log( $post->ID, get_current_user_id(), 'Request set as Pending Payment via Network Admin', array(356 'action' => 'set-pending-payment',357 ) );358 359 add_action( 'admin_notices', function() {360 ?><div class="notice notice-success is-dismissible">361 <p><?php _e( 'Success! Request has been marked as Pending Payment.', 'wordcamporg' ); ?></p>362 </div><?php363 });364 }365 restore_current_blog();366 281 } 367 282 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/reimbursement-requests-dashboard.php
r2706 r2747 10 10 add_action( 'network_admin_menu', __NAMESPACE__ . '\register_submenu_page' ); 11 11 add_action( 'init', __NAMESPACE__ . '\upgrade_database' ); 12 13 } elseif ( is_admin() ) { 14 add_action( 'save_post', __NAMESPACE__ . '\update_index_row', 11, 2 ); // See note in callback about priority 15 add_action( 'trashed_post', __NAMESPACE__ . '\delete_index_row' ); 16 add_action( 'delete_post', __NAMESPACE__ . '\delete_index_row' ); 17 add_action( 'draft_wcb_reimbursement', __NAMESPACE__ . '\delete_index_row' ); 18 } 12 } 13 14 add_action( 'save_post', __NAMESPACE__ . '\update_index_row', 11, 2 ); // See note in callback about priority 15 add_action( 'trashed_post', __NAMESPACE__ . '\delete_index_row' ); 16 add_action( 'delete_post', __NAMESPACE__ . '\delete_index_row' ); 17 add_action( 'draft_wcb_reimbursement', __NAMESPACE__ . '\delete_index_row' ); 19 18 20 19 /** -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/reimbursement-requests-list-table.php
r2647 r2747 80 80 */ 81 81 protected function column_request_title( $index_row ) { 82 $title = empty( $index_row->request_title ) ? '(no title)' : $index_row->request_title; 82 $blog_id = $index_row->blog_id; 83 switch_to_blog( $blog_id ); 84 $post = get_post( $index_row->request_id ); 85 $title = get_the_title( $post ); 86 $title = empty( $title ) ? '(no title)' : $title; 87 $edit_post_link = add_query_arg( array( 'post' => $post->ID, 'action' => 'edit' ), admin_url( 'post.php' ) ); 88 $actions = array( 89 'view-all' => sprintf( '<a href="%s" target="_blank">View All</a>', esc_url( admin_url( 'edit.php?post_type=wcb_reimbursement' ) ) ), 90 ); 83 91 84 $edit_url = get_admin_url( 85 $index_row->blog_id, 86 sprintf( 'post.php?post=%s&action=edit', $index_row->request_id ) 87 ); 92 if ( $post->post_status == 'wcb-pending-approval' ) { 93 $action_url = wp_nonce_url( add_query_arg( array( 94 'wcb-approve' => sprintf( '%d-%d', $blog_id, $post->ID ), 95 ) ), sprintf( 'wcb-approve-%d-%d', $blog_id, $post->ID ) ); 96 97 $actions['wcb-approve'] = sprintf( '<a style="color: green;" onclick="return confirm(\'Approve this reimbursement request?\');" href="%s">Approve</a>', esc_url( $action_url ) ); 98 99 } elseif ( $post->post_status == 'wcb-approved' ) { 100 $action_url = wp_nonce_url( add_query_arg( array( 101 'wcb-set-pending-payment' => sprintf( '%d-%d', $blog_id, $post->ID ), 102 ) ), sprintf( 'wcb-set-pending-payment-%d-%d', $blog_id, $post->ID ) ); 103 104 $actions['wcb-set-pending-payment'] = sprintf( '<a style="color: green;" onclick="return confirm(\'Set this request as pending payment?\');" href="%s">Set as Pending Payment</a>', esc_url( $action_url ) ); 105 } 88 106 89 107 ob_start(); 90 108 ?> 91 109 92 <a href="<?php echo esc_url( $edit_ url ); ?>">110 <a href="<?php echo esc_url( $edit_post_link ); ?>" class="row-title" target="_blank"> 93 111 <?php echo esc_html( $title ); ?> 112 <?php echo $this->row_actions( $actions ); ?> 94 113 </a> 95 114 96 115 <?php 97 116 98 return ob_get_clean(); 117 $output = ob_get_clean(); 118 restore_current_blog(); 119 return $output; 99 120 } 100 121 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/wordcamp-budgets-dashboard.php
r2713 r2747 14 14 15 15 add_action( 'admin_init', __NAMESPACE__ . '\process_export_request' ); 16 add_action( 'admin_init', __NAMESPACE__ . '\process_action_approve', 11 ); 17 add_action( 'admin_init', __NAMESPACE__ . '\process_action_set_pending_payment', 11 ); 16 18 17 19 /** … … 536 538 return $amount * $rate; 537 539 } 540 541 542 /** 543 * Approve a payment or reimbursement request. 544 */ 545 function process_action_approve() { 546 if ( ! current_user_can( 'manage_network' ) ) 547 return; 548 549 if ( empty( $_GET['wcb-approve'] ) || empty( $_GET['_wpnonce'] ) ) 550 return; 551 552 list( $blog_id, $post_id ) = explode( '-', $_GET['wcb-approve'] ); 553 554 if ( ! wp_verify_nonce( $_GET['_wpnonce'], sprintf( 'wcb-approve-%d-%d', $blog_id, $post_id ) ) ) { 555 add_settings_error( 'wcb-dashboard', 'nonce_error', 'Could not verify nonce.', 'error' ); 556 return; 557 } 558 559 switch_to_blog( $blog_id ); 560 $post = get_post( $post_id ); 561 562 if ( ! in_array( $post->post_type, array( 'wcp_payment_request', 'wcb_reimbursement' ) ) ) { 563 add_settings_error( 'wcb-dashboard', 'type_error', 'Invalid post type.', 'error' ); 564 restore_current_blog(); 565 return; 566 } 567 568 $post->post_status = 'wcb-approved'; 569 wp_insert_post( $post ); 570 571 \WordCamp_Budgets::log( $post->ID, get_current_user_id(), 'Request approved via Network Admin', array( 572 'action' => 'approved', 573 ) ); 574 575 restore_current_blog(); 576 add_settings_error( 'wcb-dashboard', 'success', 'Success! Request has been marked as Approved.', 'updated' ); 577 } 578 579 /** 580 * Process "Set as Pending Payment" dashboard action. 581 */ 582 function process_action_set_pending_payment() { 583 if ( ! current_user_can( 'manage_network' ) ) 584 return; 585 586 if ( empty( $_GET['wcb-set-pending-payment'] ) || empty( $_GET['_wpnonce'] ) ) 587 return; 588 589 list( $blog_id, $post_id ) = explode( '-', $_GET['wcb-set-pending-payment'] ); 590 591 if ( ! wp_verify_nonce( $_GET['_wpnonce'], sprintf( 'wcb-set-pending-payment-%d-%d', $blog_id, $post_id ) ) ) { 592 add_settings_error( 'wcb-dashboard', 'nonce_error', 'Could not verify nonce.', 'error' ); 593 return; 594 } 595 596 switch_to_blog( $blog_id ); 597 $post = get_post( $post_id ); 598 599 if ( ! in_array( $post->post_type, array( 'wcp_payment_request', 'wcb_reimbursement' ) ) ) { 600 add_settings_error( 'wcb-dashboard', 'type_error', 'Invalid post type.', 'error' ); 601 restore_current_blog(); 602 return; 603 } 604 605 $post->post_status = 'wcb-pending-payment'; 606 wp_insert_post( $post ); 607 608 \WordCamp_Budgets::log( $post->ID, get_current_user_id(), 'Request set as Pending Payment via Network Admin', array( 609 'action' => 'set-pending-payment', 610 ) ); 611 612 restore_current_blog(); 613 add_settings_error( 'wcb-dashboard', 'success', 'Success! Request has been marked as Pending Payment.', 'updated' ); 614 }
Note: See TracChangeset
for help on using the changeset viewer.