Changeset 2342 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php
- Timestamp:
- 01/20/2016 09:49:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php
r2331 r2342 387 387 */ 388 388 protected function render_files_input( $post, $label, $name, $description = '' ) { 389 $files = get_posts( array( 390 'post_parent' => $post->ID, 391 'post_type' => 'attachment', 392 'posts_per_page' => -1, 393 'orderby' => 'title', 394 'order' => 'ASC', 395 ) ); 396 397 foreach ( $files as &$file ) { 398 $file->filename = wp_basename( $file->guid ); 399 $file->url = wp_get_attachment_url( $file->ID ); 400 } 389 $files = WordCamp_Budgets::get_attached_files( $post ); 390 391 wp_localize_script( 'wcb-attached-files', 'wcbAttachedFiles', $files ); // todo merge into wordcampBudgets var 401 392 402 393 require( dirname( __DIR__ ) . '/views/payment-request/input-files.php' ); … … 765 756 766 757 // Attach existing files 767 $this->attach_existing_files( $post_id, $_POST ); 768 } 769 758 remove_action( 'save_post', array( $this, 'save_payment' ), 10 ); // avoid infinite recursion 759 WordCamp_Budgets::attach_existing_files( $post_id, $_POST ); 760 add_action( 'save_post', array( $this, 'save_payment' ), 10, 2 ); 761 } 762 763 /** 764 * Add log entries when the post status changes 765 * 766 * @param string $new 767 * @param string $old 768 * @param WP_Post $post 769 */ 770 770 public function transition_post_status( $new, $old, $post ) { 771 771 if ( $post->post_type != self::POST_TYPE ) … … 803 803 804 804 /** 805 * Attach unattached files to the payment request post806 *807 * Sometimes users will upload the files manually to the Media Library, instead of using the Add Files button,808 * and we need to attach them to the request so that they show up in the metabox.809 *810 * @param int $post_id811 * @param array $request812 */813 protected function attach_existing_files( $post_id, $request ) {814 if ( empty( $request['wcp_existing_files_to_attach'] ) ) {815 return;816 }817 818 if ( ! $files = json_decode( $request['wcp_existing_files_to_attach'] ) ) {819 return;820 }821 822 remove_action( 'save_post', array( $this, 'save_payment' ), 10 ); // avoid infinite recursion823 824 foreach( $files as $file_id ) {825 wp_update_post( array(826 'ID' => $file_id,827 'post_parent' => $post_id,828 ) );829 }830 831 add_action( 'save_post', array( $this, 'save_payment' ), 10, 2 );832 }833 834 /**835 805 * Define columns for the Payment Requests screen. 836 806 *
Note: See TracChangeset
for help on using the changeset viewer.