Making WordPress.org


Ignore:
Timestamp:
03/14/2016 06:17:18 PM (10 years ago)
Author:
kovshenin
Message:

WordCamp Budgets: Add handlers for network dashboard actions.

Move "approve" and "set as pending payment" action link handlers
to the main network dashboard file, allow for reimbursement
requests too.

File:
1 edited

Legend:

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

    r2647 r2747  
    8080     */
    8181    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        );
    8391
    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        }
    88106
    89107        ob_start();
    90108        ?>
    91109
    92         <a href="<?php echo esc_url( $edit_url ); ?>">
     110        <a href="<?php echo esc_url( $edit_post_link ); ?>" class="row-title" target="_blank">
    93111            <?php echo esc_html( $title ); ?>
     112            <?php echo $this->row_actions( $actions ); ?>
    94113        </a>
    95114
    96115        <?php
    97116
    98         return ob_get_clean();
     117        $output = ob_get_clean();
     118        restore_current_blog();
     119        return $output;
    99120    }
    100121
Note: See TracChangeset for help on using the changeset viewer.