Making WordPress.org

Changeset 2627


Ignore:
Timestamp:
02/26/2016 12:34:20 AM (10 years ago)
Author:
kovshenin
Message:

WordCamp.org: Allow network admins/deputies to approve payment requests from the network dashboard.

Location:
sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes
Files:
2 edited

Legend:

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

    r2623 r2627  
    2020                add_action( 'network_admin_menu', array( __CLASS__, 'network_admin_menu' ) );
    2121                add_action( 'init', array( __CLASS__, 'upgrade' ) );
     22                add_action( 'init', array( __CLASS__, 'process_approval' ) );
    2223                add_action( 'init', array( __CLASS__, 'process_export_request' ) );
    2324                add_action( 'init', array( __CLASS__, 'process_import_request' ) );
     
    256257                        <h1>Vendor Payments</h1>
    257258
     259                        <?php do_action( 'admin_notices' ); ?>
    258260                        <?php settings_errors(); ?>
    259261
     
    296298
    297299                <?php
     300        }
     301
     302        /**
     303         * Process Approve button in network admin
     304         */
     305        public static function process_approval() {
     306                if ( ! current_user_can( 'network_admin' ) )
     307                        return;
     308
     309                if ( empty( $_GET['wcb-approve'] ) || empty( $_GET['_wpnonce'] ) )
     310                        return;
     311
     312                list( $blog_id, $post_id ) = explode( '-', $_GET['wcb-approve'] );
     313
     314                if ( ! wp_verify_nonce( $_GET['_wpnonce'], sprintf( 'wcb-approve-%d-%d', $blog_id, $post_id ) ) ) {
     315                        add_action( 'admin_notices', function() {
     316                                ?><div class="notice notice-error is-dismissible">
     317                                        <p><?php _e( 'Error! Could not verify nonce.', 'wordcamporg' ); ?></p>
     318                                </div><?php
     319                        });
     320                        return;
     321                }
     322
     323                switch_to_blog( $blog_id );
     324                $post = get_post( $post_id );
     325                if ( $post->post_type == 'wcp_payment_request' ) {
     326                        $post->post_status = 'wcb-approved';
     327                        wp_insert_post( $post );
     328
     329                        WordCamp_Budgets::log( $post->ID, get_current_user_id(), 'Request approved via Network Admin', array(
     330                                'action' => 'approved',
     331                        ) );
     332
     333                        add_action( 'admin_notices', function() {
     334                                ?><div class="notice notice-success is-dismissible">
     335                                        <p><?php _e( 'Success! Request has been marked as approved.', 'wordcamporg' ); ?></p>
     336                                </div><?php
     337                        });
     338                }
     339                restore_current_blog();
    298340        }
    299341
  • sites/branches/wcb-payment-request-statuses/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments-network/includes/payment-requests-list-table.php

    r2623 r2627  
    142142         */
    143143        public function column_payment( $request ) {
    144                 $title          = empty( $request->post_title ) ? '(no title)' : $request->post_title;
     144                $blog_id = get_current_blog_id();
     145                $title = empty( $request->post_title ) ? '(no title)' : $request->post_title;
    145146                $edit_post_link = add_query_arg( array( 'post' => $request->ID, 'action' => 'edit' ), admin_url( 'post.php' ) );
    146147                $actions = array(
    147148                        'view-all' => sprintf( '<a href="%s" target="_blank">View All</a>', esc_url( admin_url( 'edit.php?post_type=wcp_payment_request' ) ) ),
    148149                );
     150
     151                if ( $request->post_status == 'wcb-pending-approval' ) {
     152                        $approve_url = wp_nonce_url( add_query_arg( array(
     153                                'wcb-approve' => sprintf( '%d-%d', $blog_id, $request->ID ),
     154                        ) ), sprintf( 'wcb-approve-%d-%d', $blog_id, $request->ID ) );
     155
     156                        $actions['wcb-approve'] = sprintf( '<a style="color: green;" onclick="return confirm(\'Approve this payment request?\');" href="%s">Approve</a>', esc_url( $approve_url ) );
     157                }
    149158
    150159                return sprintf( '<a href="%s" class="row-title" target="_blank">%s</a>%s',
Note: See TracChangeset for help on using the changeset viewer.