@@ -13,724 +13,724 @@ discard block |
||
| 13 | 13 | class GetPaid_Post_Types_Admin { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * Hook in methods. |
|
| 17 | - */ |
|
| 18 | - public static function init() { |
|
| 19 | - |
|
| 20 | - // Init metaboxes. |
|
| 21 | - GetPaid_Metaboxes::init(); |
|
| 22 | - |
|
| 23 | - // Filter the post updated messages. |
|
| 24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
| 25 | - |
|
| 26 | - // Filter post actions. |
|
| 27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
| 28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
| 29 | - |
|
| 30 | - // Invoice table columns. |
|
| 31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
| 32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
| 33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
| 34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
| 35 | - |
|
| 36 | - // Items table columns. |
|
| 37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
| 38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
| 39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
| 40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
| 41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
| 42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
| 43 | - |
|
| 44 | - // Payment forms columns. |
|
| 45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
| 46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
| 47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
| 48 | - |
|
| 49 | - // Discount table columns. |
|
| 50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
| 51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
| 52 | - |
|
| 53 | - // Deleting posts. |
|
| 54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
| 55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
| 56 | - |
|
| 57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Post updated messages. |
|
| 62 | - */ |
|
| 63 | - public static function post_updated_messages( $messages ) { |
|
| 64 | - global $post; |
|
| 65 | - |
|
| 66 | - $messages['wpi_discount'] = array( |
|
| 67 | - 0 => '', |
|
| 68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 78 | - ); |
|
| 79 | - |
|
| 80 | - $messages['wpi_payment_form'] = array( |
|
| 81 | - 0 => '', |
|
| 82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
| 89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
| 90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
| 92 | - ); |
|
| 93 | - |
|
| 94 | - return $messages; |
|
| 95 | - |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Post row actions. |
|
| 100 | - */ |
|
| 101 | - public static function post_row_actions( $actions, $post ) { |
|
| 102 | - |
|
| 103 | - $post = get_post( $post ); |
|
| 104 | - |
|
| 105 | - // We do not want to edit the default payment form. |
|
| 106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
| 107 | - |
|
| 108 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
| 109 | - unset( $actions['trash'] ); |
|
| 110 | - unset( $actions['inline hide-if-no-js'] ); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $actions['duplicate'] = sprintf( |
|
| 114 | - '<a href="%1$s">%2$s</a>', |
|
| 115 | - esc_url( |
|
| 116 | - wp_nonce_url( |
|
| 117 | - add_query_arg( |
|
| 118 | - array( |
|
| 119 | - 'getpaid-admin-action' => 'duplicate_form', |
|
| 120 | - 'form_id' => $post->ID, |
|
| 121 | - ) |
|
| 122 | - ), |
|
| 123 | - 'getpaid-nonce', |
|
| 124 | - 'getpaid-nonce' |
|
| 125 | - ) |
|
| 126 | - ), |
|
| 127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 128 | - ); |
|
| 129 | - |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // Link to item payment form. |
|
| 133 | - if ( 'wpi_item' == $post->post_type ) { |
|
| 134 | - |
|
| 135 | - if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
| 136 | - |
|
| 137 | - $actions['buy'] = sprintf( |
|
| 138 | - '<a href="%1$s">%2$s</a>', |
|
| 139 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
| 140 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
| 141 | - ); |
|
| 142 | - |
|
| 143 | - } |
|
| 16 | + * Hook in methods. |
|
| 17 | + */ |
|
| 18 | + public static function init() { |
|
| 19 | + |
|
| 20 | + // Init metaboxes. |
|
| 21 | + GetPaid_Metaboxes::init(); |
|
| 22 | + |
|
| 23 | + // Filter the post updated messages. |
|
| 24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
| 25 | + |
|
| 26 | + // Filter post actions. |
|
| 27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
| 28 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
| 29 | + |
|
| 30 | + // Invoice table columns. |
|
| 31 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
| 32 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
| 33 | + add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
| 34 | + add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
| 35 | + |
|
| 36 | + // Items table columns. |
|
| 37 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
| 38 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
| 39 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
| 40 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
| 41 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
| 42 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
| 43 | + |
|
| 44 | + // Payment forms columns. |
|
| 45 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
| 46 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
| 47 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
| 48 | + |
|
| 49 | + // Discount table columns. |
|
| 50 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
| 51 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
| 52 | + |
|
| 53 | + // Deleting posts. |
|
| 54 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
| 55 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
| 56 | + |
|
| 57 | + add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Post updated messages. |
|
| 62 | + */ |
|
| 63 | + public static function post_updated_messages( $messages ) { |
|
| 64 | + global $post; |
|
| 65 | + |
|
| 66 | + $messages['wpi_discount'] = array( |
|
| 67 | + 0 => '', |
|
| 68 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 69 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 70 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 71 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 72 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 73 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 74 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 75 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 76 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 77 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 78 | + ); |
|
| 79 | + |
|
| 80 | + $messages['wpi_payment_form'] = array( |
|
| 81 | + 0 => '', |
|
| 82 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 83 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 84 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 85 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 86 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 87 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 88 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
| 89 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
| 90 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 91 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
| 92 | + ); |
|
| 93 | + |
|
| 94 | + return $messages; |
|
| 95 | + |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Post row actions. |
|
| 100 | + */ |
|
| 101 | + public static function post_row_actions( $actions, $post ) { |
|
| 102 | + |
|
| 103 | + $post = get_post( $post ); |
|
| 104 | + |
|
| 105 | + // We do not want to edit the default payment form. |
|
| 106 | + if ( 'wpi_payment_form' == $post->post_type ) { |
|
| 107 | + |
|
| 108 | + if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
| 109 | + unset( $actions['trash'] ); |
|
| 110 | + unset( $actions['inline hide-if-no-js'] ); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $actions['duplicate'] = sprintf( |
|
| 114 | + '<a href="%1$s">%2$s</a>', |
|
| 115 | + esc_url( |
|
| 116 | + wp_nonce_url( |
|
| 117 | + add_query_arg( |
|
| 118 | + array( |
|
| 119 | + 'getpaid-admin-action' => 'duplicate_form', |
|
| 120 | + 'form_id' => $post->ID, |
|
| 121 | + ) |
|
| 122 | + ), |
|
| 123 | + 'getpaid-nonce', |
|
| 124 | + 'getpaid-nonce' |
|
| 125 | + ) |
|
| 126 | + ), |
|
| 127 | + esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 128 | + ); |
|
| 129 | + |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // Link to item payment form. |
|
| 133 | + if ( 'wpi_item' == $post->post_type ) { |
|
| 134 | + |
|
| 135 | + if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
| 136 | + |
|
| 137 | + $actions['buy'] = sprintf( |
|
| 138 | + '<a href="%1$s">%2$s</a>', |
|
| 139 | + esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
| 140 | + esc_html( __( 'Buy', 'invoicing' ) ) |
|
| 141 | + ); |
|
| 142 | + |
|
| 143 | + } |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - return $actions; |
|
| 147 | - } |
|
| 146 | + return $actions; |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - /** |
|
| 149 | + /** |
|
| 150 | 150 | * Remove bulk edit option from admin side quote listing |
| 151 | 151 | * |
| 152 | 152 | * @since 1.0.0 |
| 153 | 153 | * @param array $actions post actions |
| 154 | - * @param WP_Post $post |
|
| 154 | + * @param WP_Post $post |
|
| 155 | 155 | * @return array $actions actions without edit option |
| 156 | 156 | */ |
| 157 | 157 | public static function filter_invoice_row_actions( $actions, $post ) { |
| 158 | 158 | |
| 159 | 159 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
| 160 | 160 | |
| 161 | - $actions = array(); |
|
| 162 | - $invoice = new WPInv_Invoice( $post ); |
|
| 163 | - |
|
| 164 | - $actions['edit'] = sprintf( |
|
| 165 | - '<a href="%1$s">%2$s</a>', |
|
| 166 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 167 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
| 168 | - ); |
|
| 169 | - |
|
| 170 | - if ( ! $invoice->is_draft() ) { |
|
| 171 | - |
|
| 172 | - $actions['view'] = sprintf( |
|
| 173 | - '<a href="%1$s">%2$s</a>', |
|
| 174 | - esc_url( $invoice->get_view_url() ), |
|
| 175 | - sprintf( |
|
| 176 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
| 177 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
| 178 | - ) |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - $actions['send'] = sprintf( |
|
| 182 | - '<a href="%1$s">%2$s</a>', |
|
| 183 | - esc_url( |
|
| 184 | - wp_nonce_url( |
|
| 185 | - add_query_arg( |
|
| 186 | - array( |
|
| 187 | - 'getpaid-admin-action' => 'send_invoice', |
|
| 188 | - 'invoice_id' => $invoice->get_id(), |
|
| 189 | - ) |
|
| 190 | - ), |
|
| 191 | - 'getpaid-nonce', |
|
| 192 | - 'getpaid-nonce' |
|
| 193 | - ) |
|
| 194 | - ), |
|
| 195 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
| 196 | - ); |
|
| 197 | - |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $actions['duplicate'] = sprintf( |
|
| 201 | - '<a href="%1$s">%2$s</a>', |
|
| 202 | - esc_url( |
|
| 203 | - wp_nonce_url( |
|
| 204 | - add_query_arg( |
|
| 205 | - array( |
|
| 206 | - 'getpaid-admin-action' => 'duplicate_invoice', |
|
| 207 | - 'invoice_id' => $post->ID, |
|
| 208 | - ) |
|
| 209 | - ), |
|
| 210 | - 'getpaid-nonce', |
|
| 211 | - 'getpaid-nonce' |
|
| 212 | - ) |
|
| 213 | - ), |
|
| 214 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 215 | - ); |
|
| 161 | + $actions = array(); |
|
| 162 | + $invoice = new WPInv_Invoice( $post ); |
|
| 163 | + |
|
| 164 | + $actions['edit'] = sprintf( |
|
| 165 | + '<a href="%1$s">%2$s</a>', |
|
| 166 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 167 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
| 168 | + ); |
|
| 169 | + |
|
| 170 | + if ( ! $invoice->is_draft() ) { |
|
| 171 | + |
|
| 172 | + $actions['view'] = sprintf( |
|
| 173 | + '<a href="%1$s">%2$s</a>', |
|
| 174 | + esc_url( $invoice->get_view_url() ), |
|
| 175 | + sprintf( |
|
| 176 | + esc_html( __( 'View %s', 'invoicing' ) ), |
|
| 177 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
| 178 | + ) |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + $actions['send'] = sprintf( |
|
| 182 | + '<a href="%1$s">%2$s</a>', |
|
| 183 | + esc_url( |
|
| 184 | + wp_nonce_url( |
|
| 185 | + add_query_arg( |
|
| 186 | + array( |
|
| 187 | + 'getpaid-admin-action' => 'send_invoice', |
|
| 188 | + 'invoice_id' => $invoice->get_id(), |
|
| 189 | + ) |
|
| 190 | + ), |
|
| 191 | + 'getpaid-nonce', |
|
| 192 | + 'getpaid-nonce' |
|
| 193 | + ) |
|
| 194 | + ), |
|
| 195 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
| 196 | + ); |
|
| 197 | + |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $actions['duplicate'] = sprintf( |
|
| 201 | + '<a href="%1$s">%2$s</a>', |
|
| 202 | + esc_url( |
|
| 203 | + wp_nonce_url( |
|
| 204 | + add_query_arg( |
|
| 205 | + array( |
|
| 206 | + 'getpaid-admin-action' => 'duplicate_invoice', |
|
| 207 | + 'invoice_id' => $post->ID, |
|
| 208 | + ) |
|
| 209 | + ), |
|
| 210 | + 'getpaid-nonce', |
|
| 211 | + 'getpaid-nonce' |
|
| 212 | + ) |
|
| 213 | + ), |
|
| 214 | + esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 215 | + ); |
|
| 216 | 216 | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | return $actions; |
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * Returns an array of invoice table columns. |
|
| 224 | - */ |
|
| 225 | - public static function invoice_columns( $columns ) { |
|
| 226 | - |
|
| 227 | - $columns = array( |
|
| 228 | - 'cb' => $columns['cb'], |
|
| 229 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
| 230 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 231 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
| 232 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
| 233 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 234 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
| 235 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 236 | - ); |
|
| 237 | - |
|
| 238 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Displays invoice table columns. |
|
| 243 | - */ |
|
| 244 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
| 245 | - |
|
| 246 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 247 | - |
|
| 248 | - switch ( $column_name ) { |
|
| 249 | - |
|
| 250 | - case 'invoice_date': |
|
| 251 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
| 252 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
| 253 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
| 254 | - break; |
|
| 255 | - |
|
| 256 | - case 'payment_date': |
|
| 257 | - if ( $invoice->is_paid() ) { |
|
| 258 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
| 259 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
| 260 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
| 261 | - } else { |
|
| 262 | - echo '—'; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - break; |
|
| 266 | - |
|
| 267 | - case 'amount': |
|
| 268 | - $amount = $invoice->get_total(); |
|
| 269 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
| 270 | - |
|
| 271 | - if ( $invoice->is_refunded() ) { |
|
| 272 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
| 273 | - echo wp_kses_post( "<del>$formated_amount</del> <ins>$refunded_amount</ins>" ); |
|
| 274 | - } else { |
|
| 275 | - |
|
| 276 | - $discount = $invoice->get_total_discount(); |
|
| 277 | - |
|
| 278 | - if ( ! empty( $discount ) ) { |
|
| 279 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
| 280 | - echo wp_kses_post( "<del>$new_amount</del> <ins>$formated_amount</ins>" ); |
|
| 281 | - } else { |
|
| 282 | - echo wp_kses_post( $formated_amount ); |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - break; |
|
| 287 | - |
|
| 288 | - case 'status': |
|
| 289 | - $status = esc_html( $invoice->get_status() ); |
|
| 290 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
| 291 | - |
|
| 292 | - // If it is paid, show the gateway title. |
|
| 293 | - if ( $invoice->is_paid() ) { |
|
| 294 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
| 295 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
| 296 | - |
|
| 297 | - echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" ); |
|
| 298 | - } else { |
|
| 299 | - echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" ); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - // If it is not paid, display the overdue and view status. |
|
| 303 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 304 | - |
|
| 305 | - // Invoice view status. |
|
| 306 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
| 307 | - echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
| 308 | - } else { |
|
| 309 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - // Display the overview status. |
|
| 313 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
| 314 | - $due_date = $invoice->get_due_date(); |
|
| 315 | - $fomatted = getpaid_format_date( $due_date ); |
|
| 316 | - |
|
| 317 | - if ( ! empty( $fomatted ) ) { |
|
| 318 | - $date = wp_sprintf( |
|
| 319 | - // translators: %s is the due date. |
|
| 320 | - __( 'Due %s', 'invoicing' ), |
|
| 321 | - $fomatted |
|
| 322 | - ); |
|
| 323 | - echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" ); |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - break; |
|
| 329 | - |
|
| 330 | - case 'recurring': |
|
| 331 | - if ( $invoice->is_recurring() ) { |
|
| 332 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
| 333 | - } else { |
|
| 334 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
| 335 | - } |
|
| 336 | - break; |
|
| 337 | - |
|
| 338 | - case 'number': |
|
| 339 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
| 340 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
| 341 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
| 342 | - |
|
| 343 | - echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" ); |
|
| 344 | - |
|
| 345 | - do_action( 'getpaid_admin_table_invoice_number_column', $invoice ); |
|
| 346 | - break; |
|
| 347 | - |
|
| 348 | - case 'customer': |
|
| 349 | - $customer_name = $invoice->get_user_full_name(); |
|
| 350 | - |
|
| 351 | - if ( empty( $customer_name ) ) { |
|
| 352 | - $customer_name = $invoice->get_email(); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - if ( ! empty( $customer_name ) ) { |
|
| 356 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
| 357 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
| 358 | - echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" ); |
|
| 359 | - } else { |
|
| 360 | - echo '<div>—</div>'; |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - break; |
|
| 364 | - |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * Displays invoice bulk actions. |
|
| 371 | - */ |
|
| 372 | - public static function invoice_bulk_actions( $actions ) { |
|
| 373 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
| 374 | - return $actions; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * Processes invoice bulk actions. |
|
| 379 | - */ |
|
| 380 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
| 381 | - |
|
| 382 | - if ( 'resend-invoice' === $action ) { |
|
| 383 | - foreach ( $post_ids as $post_id ) { |
|
| 384 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - return $redirect_url; |
|
| 389 | - |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - /** |
|
| 393 | - * Returns an array of payment forms table columns. |
|
| 394 | - */ |
|
| 395 | - public static function payment_form_columns( $columns ) { |
|
| 396 | - |
|
| 397 | - $columns = array( |
|
| 398 | - 'cb' => $columns['cb'], |
|
| 399 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 400 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 401 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
| 402 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
| 403 | - 'items' => __( 'Items', 'invoicing' ), |
|
| 404 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 405 | - ); |
|
| 406 | - |
|
| 407 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
| 408 | - |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * Displays payment form table columns. |
|
| 413 | - */ |
|
| 414 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
| 415 | - |
|
| 416 | - // Retrieve the payment form. |
|
| 417 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
| 418 | - |
|
| 419 | - switch ( $column_name ) { |
|
| 420 | - |
|
| 421 | - case 'earnings': |
|
| 422 | - echo wp_kses_post( wpinv_price( $form->get_earned() ) ); |
|
| 423 | - break; |
|
| 424 | - |
|
| 425 | - case 'refunds': |
|
| 426 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
| 427 | - break; |
|
| 428 | - |
|
| 429 | - case 'refunds': |
|
| 430 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
| 431 | - break; |
|
| 432 | - |
|
| 433 | - case 'shortcode': |
|
| 434 | - if ( $form->is_default() ) { |
|
| 435 | - echo '—'; |
|
| 436 | - } else { |
|
| 437 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - break; |
|
| 220 | + } |
|
| 441 | 221 | |
| 442 | - case 'items': |
|
| 443 | - $items = $form->get_items(); |
|
| 444 | - |
|
| 445 | - if ( $form->is_default() || empty( $items ) ) { |
|
| 446 | - echo '—'; |
|
| 447 | - return; |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - $_items = array(); |
|
| 451 | - |
|
| 452 | - foreach ( $items as $item ) { |
|
| 453 | - $url = $item->get_edit_url(); |
|
| 454 | - |
|
| 455 | - if ( empty( $url ) ) { |
|
| 456 | - $_items[] = esc_html( $item->get_name() ); |
|
| 457 | - } else { |
|
| 458 | - $_items[] = sprintf( |
|
| 459 | - '<a href="%s">%s</a>', |
|
| 460 | - esc_url( $url ), |
|
| 461 | - esc_html( $item->get_name() ) |
|
| 462 | - ); |
|
| 463 | - } |
|
| 222 | + /** |
|
| 223 | + * Returns an array of invoice table columns. |
|
| 224 | + */ |
|
| 225 | + public static function invoice_columns( $columns ) { |
|
| 226 | + |
|
| 227 | + $columns = array( |
|
| 228 | + 'cb' => $columns['cb'], |
|
| 229 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
| 230 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
| 231 | + 'invoice_date' => __( 'Created', 'invoicing' ), |
|
| 232 | + 'payment_date' => __( 'Completed', 'invoicing' ), |
|
| 233 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 234 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
| 235 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 236 | + ); |
|
| 237 | + |
|
| 238 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Displays invoice table columns. |
|
| 243 | + */ |
|
| 244 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
| 245 | + |
|
| 246 | + $invoice = new WPInv_Invoice( $post_id ); |
|
| 247 | + |
|
| 248 | + switch ( $column_name ) { |
|
| 249 | + |
|
| 250 | + case 'invoice_date': |
|
| 251 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
| 252 | + $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
| 253 | + echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
| 254 | + break; |
|
| 255 | + |
|
| 256 | + case 'payment_date': |
|
| 257 | + if ( $invoice->is_paid() ) { |
|
| 258 | + $date_time = esc_attr( $invoice->get_completed_date() ); |
|
| 259 | + $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
| 260 | + echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
| 261 | + } else { |
|
| 262 | + echo '—'; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + break; |
|
| 266 | + |
|
| 267 | + case 'amount': |
|
| 268 | + $amount = $invoice->get_total(); |
|
| 269 | + $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
| 270 | + |
|
| 271 | + if ( $invoice->is_refunded() ) { |
|
| 272 | + $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
| 273 | + echo wp_kses_post( "<del>$formated_amount</del> <ins>$refunded_amount</ins>" ); |
|
| 274 | + } else { |
|
| 275 | + |
|
| 276 | + $discount = $invoice->get_total_discount(); |
|
| 277 | + |
|
| 278 | + if ( ! empty( $discount ) ) { |
|
| 279 | + $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
| 280 | + echo wp_kses_post( "<del>$new_amount</del> <ins>$formated_amount</ins>" ); |
|
| 281 | + } else { |
|
| 282 | + echo wp_kses_post( $formated_amount ); |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + break; |
|
| 287 | + |
|
| 288 | + case 'status': |
|
| 289 | + $status = esc_html( $invoice->get_status() ); |
|
| 290 | + $status_label = esc_html( $invoice->get_status_nicename() ); |
|
| 291 | + |
|
| 292 | + // If it is paid, show the gateway title. |
|
| 293 | + if ( $invoice->is_paid() ) { |
|
| 294 | + $gateway = esc_html( $invoice->get_gateway_title() ); |
|
| 295 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
| 296 | + |
|
| 297 | + echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" ); |
|
| 298 | + } else { |
|
| 299 | + echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" ); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + // If it is not paid, display the overdue and view status. |
|
| 303 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 304 | + |
|
| 305 | + // Invoice view status. |
|
| 306 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
| 307 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
| 308 | + } else { |
|
| 309 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + // Display the overview status. |
|
| 313 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
| 314 | + $due_date = $invoice->get_due_date(); |
|
| 315 | + $fomatted = getpaid_format_date( $due_date ); |
|
| 316 | + |
|
| 317 | + if ( ! empty( $fomatted ) ) { |
|
| 318 | + $date = wp_sprintf( |
|
| 319 | + // translators: %s is the due date. |
|
| 320 | + __( 'Due %s', 'invoicing' ), |
|
| 321 | + $fomatted |
|
| 322 | + ); |
|
| 323 | + echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" ); |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + break; |
|
| 329 | + |
|
| 330 | + case 'recurring': |
|
| 331 | + if ( $invoice->is_recurring() ) { |
|
| 332 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
| 333 | + } else { |
|
| 334 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
| 335 | + } |
|
| 336 | + break; |
|
| 337 | + |
|
| 338 | + case 'number': |
|
| 339 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
| 340 | + $invoice_number = esc_html( $invoice->get_number() ); |
|
| 341 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
| 342 | + |
|
| 343 | + echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" ); |
|
| 344 | + |
|
| 345 | + do_action( 'getpaid_admin_table_invoice_number_column', $invoice ); |
|
| 346 | + break; |
|
| 347 | + |
|
| 348 | + case 'customer': |
|
| 349 | + $customer_name = $invoice->get_user_full_name(); |
|
| 350 | + |
|
| 351 | + if ( empty( $customer_name ) ) { |
|
| 352 | + $customer_name = $invoice->get_email(); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + if ( ! empty( $customer_name ) ) { |
|
| 356 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
| 357 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
| 358 | + echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" ); |
|
| 359 | + } else { |
|
| 360 | + echo '<div>—</div>'; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + break; |
|
| 364 | + |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * Displays invoice bulk actions. |
|
| 371 | + */ |
|
| 372 | + public static function invoice_bulk_actions( $actions ) { |
|
| 373 | + $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
| 374 | + return $actions; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * Processes invoice bulk actions. |
|
| 379 | + */ |
|
| 380 | + public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
| 381 | + |
|
| 382 | + if ( 'resend-invoice' === $action ) { |
|
| 383 | + foreach ( $post_ids as $post_id ) { |
|
| 384 | + getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + return $redirect_url; |
|
| 389 | + |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + /** |
|
| 393 | + * Returns an array of payment forms table columns. |
|
| 394 | + */ |
|
| 395 | + public static function payment_form_columns( $columns ) { |
|
| 396 | + |
|
| 397 | + $columns = array( |
|
| 398 | + 'cb' => $columns['cb'], |
|
| 399 | + 'title' => __( 'Name', 'invoicing' ), |
|
| 400 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 401 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
| 402 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
| 403 | + 'items' => __( 'Items', 'invoicing' ), |
|
| 404 | + 'date' => __( 'Date', 'invoicing' ), |
|
| 405 | + ); |
|
| 406 | + |
|
| 407 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
| 408 | + |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * Displays payment form table columns. |
|
| 413 | + */ |
|
| 414 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
| 415 | + |
|
| 416 | + // Retrieve the payment form. |
|
| 417 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
| 418 | + |
|
| 419 | + switch ( $column_name ) { |
|
| 420 | + |
|
| 421 | + case 'earnings': |
|
| 422 | + echo wp_kses_post( wpinv_price( $form->get_earned() ) ); |
|
| 423 | + break; |
|
| 424 | + |
|
| 425 | + case 'refunds': |
|
| 426 | + echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
| 427 | + break; |
|
| 428 | + |
|
| 429 | + case 'refunds': |
|
| 430 | + echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
| 431 | + break; |
|
| 432 | + |
|
| 433 | + case 'shortcode': |
|
| 434 | + if ( $form->is_default() ) { |
|
| 435 | + echo '—'; |
|
| 436 | + } else { |
|
| 437 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + break; |
|
| 441 | + |
|
| 442 | + case 'items': |
|
| 443 | + $items = $form->get_items(); |
|
| 444 | + |
|
| 445 | + if ( $form->is_default() || empty( $items ) ) { |
|
| 446 | + echo '—'; |
|
| 447 | + return; |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + $_items = array(); |
|
| 451 | + |
|
| 452 | + foreach ( $items as $item ) { |
|
| 453 | + $url = $item->get_edit_url(); |
|
| 454 | + |
|
| 455 | + if ( empty( $url ) ) { |
|
| 456 | + $_items[] = esc_html( $item->get_name() ); |
|
| 457 | + } else { |
|
| 458 | + $_items[] = sprintf( |
|
| 459 | + '<a href="%s">%s</a>', |
|
| 460 | + esc_url( $url ), |
|
| 461 | + esc_html( $item->get_name() ) |
|
| 462 | + ); |
|
| 463 | + } |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - echo wp_kses_post( implode( '<br>', $_items ) ); |
|
| 466 | + echo wp_kses_post( implode( '<br>', $_items ) ); |
|
| 467 | 467 | |
| 468 | - break; |
|
| 468 | + break; |
|
| 469 | 469 | |
| 470 | - } |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - } |
|
| 472 | + } |
|
| 473 | 473 | |
| 474 | - /** |
|
| 475 | - * Filters post states. |
|
| 476 | - */ |
|
| 477 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
| 474 | + /** |
|
| 475 | + * Filters post states. |
|
| 476 | + */ |
|
| 477 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
| 478 | 478 | |
| 479 | - if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) { |
|
| 480 | - $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
| 481 | - } |
|
| 479 | + if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) { |
|
| 480 | + $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | - return $post_states; |
|
| 483 | + return $post_states; |
|
| 484 | 484 | |
| 485 | - } |
|
| 485 | + } |
|
| 486 | 486 | |
| 487 | - /** |
|
| 488 | - * Returns an array of coupon table columns. |
|
| 489 | - */ |
|
| 490 | - public static function discount_columns( $columns ) { |
|
| 487 | + /** |
|
| 488 | + * Returns an array of coupon table columns. |
|
| 489 | + */ |
|
| 490 | + public static function discount_columns( $columns ) { |
|
| 491 | + |
|
| 492 | + $columns = array( |
|
| 493 | + 'cb' => $columns['cb'], |
|
| 494 | + 'title' => __( 'Name', 'invoicing' ), |
|
| 495 | + 'code' => __( 'Code', 'invoicing' ), |
|
| 496 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 497 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
| 498 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 499 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
| 500 | + ); |
|
| 501 | + |
|
| 502 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
| 503 | + } |
|
| 491 | 504 | |
| 492 | - $columns = array( |
|
| 493 | - 'cb' => $columns['cb'], |
|
| 494 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 495 | - 'code' => __( 'Code', 'invoicing' ), |
|
| 496 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 497 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
| 498 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 499 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
| 500 | - ); |
|
| 505 | + /** |
|
| 506 | + * Filters post states. |
|
| 507 | + */ |
|
| 508 | + public static function filter_discount_state( $post_states, $post ) { |
|
| 501 | 509 | |
| 502 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
| 503 | - } |
|
| 510 | + if ( 'wpi_discount' === $post->post_type ) { |
|
| 504 | 511 | |
| 505 | - /** |
|
| 506 | - * Filters post states. |
|
| 507 | - */ |
|
| 508 | - public static function filter_discount_state( $post_states, $post ) { |
|
| 512 | + $discount = new WPInv_Discount( $post ); |
|
| 509 | 513 | |
| 510 | - if ( 'wpi_discount' === $post->post_type ) { |
|
| 514 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
| 511 | 515 | |
| 512 | - $discount = new WPInv_Discount( $post ); |
|
| 516 | + if ( 'publish' !== $status ) { |
|
| 517 | + return array( |
|
| 518 | + 'discount_status' => wpinv_discount_status( $status ), |
|
| 519 | + ); |
|
| 520 | + } |
|
| 513 | 521 | |
| 514 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
| 522 | + return array(); |
|
| 515 | 523 | |
| 516 | - if ( 'publish' !== $status ) { |
|
| 517 | - return array( |
|
| 518 | - 'discount_status' => wpinv_discount_status( $status ), |
|
| 519 | - ); |
|
| 520 | - } |
|
| 524 | + } |
|
| 521 | 525 | |
| 522 | - return array(); |
|
| 526 | + return $post_states; |
|
| 523 | 527 | |
| 524 | - } |
|
| 528 | + } |
|
| 525 | 529 | |
| 526 | - return $post_states; |
|
| 530 | + /** |
|
| 531 | + * Returns an array of items table columns. |
|
| 532 | + */ |
|
| 533 | + public static function item_columns( $columns ) { |
|
| 534 | + |
|
| 535 | + $columns = array( |
|
| 536 | + 'cb' => $columns['cb'], |
|
| 537 | + 'title' => __( 'Name', 'invoicing' ), |
|
| 538 | + 'price' => __( 'Price', 'invoicing' ), |
|
| 539 | + 'vat_rule' => __( 'Tax Rule', 'invoicing' ), |
|
| 540 | + 'vat_class' => __( 'Tax Class', 'invoicing' ), |
|
| 541 | + 'type' => __( 'Type', 'invoicing' ), |
|
| 542 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 543 | + ); |
|
| 544 | + |
|
| 545 | + if ( ! wpinv_use_taxes() ) { |
|
| 546 | + unset( $columns['vat_rule'] ); |
|
| 547 | + unset( $columns['vat_class'] ); |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + /** |
|
| 554 | + * Returns an array of sortable items table columns. |
|
| 555 | + */ |
|
| 556 | + public static function sortable_item_columns( $columns ) { |
|
| 557 | + |
|
| 558 | + return array_merge( |
|
| 559 | + $columns, |
|
| 560 | + array( |
|
| 561 | + 'price' => 'price', |
|
| 562 | + 'vat_rule' => 'vat_rule', |
|
| 563 | + 'vat_class' => 'vat_class', |
|
| 564 | + 'type' => 'type', |
|
| 565 | + ) |
|
| 566 | + ); |
|
| 567 | + |
|
| 568 | + } |
|
| 569 | + |
|
| 570 | + /** |
|
| 571 | + * Displays items table columns. |
|
| 572 | + */ |
|
| 573 | + public static function display_item_columns( $column_name, $post_id ) { |
|
| 574 | + |
|
| 575 | + $item = new WPInv_Item( $post_id ); |
|
| 576 | + |
|
| 577 | + switch ( $column_name ) { |
|
| 578 | + |
|
| 579 | + case 'price': |
|
| 580 | + if ( ! $item->is_recurring() ) { |
|
| 581 | + echo wp_kses_post( $item->get_the_price() ); |
|
| 582 | + break; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + $price = wp_sprintf( |
|
| 586 | + __( '%1$s / %2$s', 'invoicing' ), |
|
| 587 | + $item->get_the_price(), |
|
| 588 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
| 589 | + ); |
|
| 590 | + |
|
| 591 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
| 592 | + echo wp_kses_post( $price ); |
|
| 593 | + break; |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + echo wp_kses_post( $item->get_the_initial_price() ); |
|
| 597 | + |
|
| 598 | + echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
| 599 | + break; |
|
| 600 | + |
|
| 601 | + case 'vat_rule': |
|
| 602 | + echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) ); |
|
| 603 | + break; |
|
| 604 | + |
|
| 605 | + case 'vat_class': |
|
| 606 | + echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) ); |
|
| 607 | + break; |
|
| 608 | + |
|
| 609 | + case 'shortcode': |
|
| 610 | + if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
| 611 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 612 | + } else { |
|
| 613 | + echo '—'; |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + break; |
|
| 617 | + |
|
| 618 | + case 'type': |
|
| 619 | + echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' ); |
|
| 620 | + break; |
|
| 621 | + |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + } |
|
| 625 | + |
|
| 626 | + /** |
|
| 627 | + * Lets users filter items using taxes. |
|
| 628 | + */ |
|
| 629 | + public static function add_item_filters( $post_type ) { |
|
| 630 | + |
|
| 631 | + // Abort if we're not dealing with items. |
|
| 632 | + if ( 'wpi_item' !== $post_type ) { |
|
| 633 | + return; |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + // Filter by vat rules. |
|
| 637 | + if ( wpinv_use_taxes() ) { |
|
| 638 | + |
|
| 639 | + // Sanitize selected vat rule. |
|
| 640 | + $vat_rule = ''; |
|
| 641 | + $vat_rules = getpaid_get_tax_rules(); |
|
| 642 | + if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 643 | + $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + // Filter by VAT rule. |
|
| 647 | + wpinv_html_select( |
|
| 648 | + array( |
|
| 649 | + 'options' => array_merge( |
|
| 650 | + array( |
|
| 651 | + '' => __( 'All Tax Rules', 'invoicing' ), |
|
| 652 | + ), |
|
| 653 | + $vat_rules |
|
| 654 | + ), |
|
| 655 | + 'name' => 'vat_rule', |
|
| 656 | + 'id' => 'vat_rule', |
|
| 657 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '', |
|
| 658 | + 'show_option_all' => false, |
|
| 659 | + 'show_option_none' => false, |
|
| 660 | + ) |
|
| 661 | + ); |
|
| 662 | + |
|
| 663 | + // Filter by VAT class. |
|
| 664 | + |
|
| 665 | + // Sanitize selected vat rule. |
|
| 666 | + $vat_class = ''; |
|
| 667 | + $vat_classes = getpaid_get_tax_classes(); |
|
| 668 | + if ( isset( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 669 | + $vat_class = sanitize_text_field( $_GET['vat_class'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + wpinv_html_select( |
|
| 673 | + array( |
|
| 674 | + 'options' => array_merge( |
|
| 675 | + array( |
|
| 676 | + '' => __( 'All Tax Classes', 'invoicing' ), |
|
| 677 | + ), |
|
| 678 | + $vat_classes |
|
| 679 | + ), |
|
| 680 | + 'name' => 'vat_class', |
|
| 681 | + 'id' => 'vat_class', |
|
| 682 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '', |
|
| 683 | + 'show_option_all' => false, |
|
| 684 | + 'show_option_none' => false, |
|
| 685 | + ) |
|
| 686 | + ); |
|
| 687 | + |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + // Filter by item type. |
|
| 691 | + $type = ''; |
|
| 692 | + if ( isset( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 693 | + $type = sanitize_text_field( $_GET['type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 694 | + } |
|
| 527 | 695 | |
| 528 | - } |
|
| 696 | + wpinv_html_select( |
|
| 697 | + array( |
|
| 698 | + 'options' => array_merge( |
|
| 699 | + array( |
|
| 700 | + '' => __( 'All item types', 'invoicing' ), |
|
| 701 | + ), |
|
| 702 | + wpinv_get_item_types() |
|
| 703 | + ), |
|
| 704 | + 'name' => 'type', |
|
| 705 | + 'id' => 'type', |
|
| 706 | + 'selected' => in_array( $type, wpinv_item_types(), true ) ? $type : '', |
|
| 707 | + 'show_option_all' => false, |
|
| 708 | + 'show_option_none' => false, |
|
| 709 | + ) |
|
| 710 | + ); |
|
| 529 | 711 | |
| 530 | - /** |
|
| 531 | - * Returns an array of items table columns. |
|
| 532 | - */ |
|
| 533 | - public static function item_columns( $columns ) { |
|
| 712 | + } |
|
| 534 | 713 | |
| 535 | - $columns = array( |
|
| 536 | - 'cb' => $columns['cb'], |
|
| 537 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 538 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 539 | - 'vat_rule' => __( 'Tax Rule', 'invoicing' ), |
|
| 540 | - 'vat_class' => __( 'Tax Class', 'invoicing' ), |
|
| 541 | - 'type' => __( 'Type', 'invoicing' ), |
|
| 542 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 543 | - ); |
|
| 714 | + /** |
|
| 715 | + * Filters the item query. |
|
| 716 | + */ |
|
| 717 | + public static function filter_item_query( $query ) { |
|
| 544 | 718 | |
| 545 | - if ( ! wpinv_use_taxes() ) { |
|
| 546 | - unset( $columns['vat_rule'] ); |
|
| 547 | - unset( $columns['vat_class'] ); |
|
| 548 | - } |
|
| 719 | + // modify the query only if it admin and main query. |
|
| 720 | + if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
| 721 | + return $query; |
|
| 722 | + } |
|
| 549 | 723 | |
| 550 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
| 551 | - } |
|
| 724 | + // we want to modify the query for our items. |
|
| 725 | + if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) { |
|
| 726 | + return $query; |
|
| 727 | + } |
|
| 552 | 728 | |
| 553 | - /** |
|
| 554 | - * Returns an array of sortable items table columns. |
|
| 555 | - */ |
|
| 556 | - public static function sortable_item_columns( $columns ) { |
|
| 557 | - |
|
| 558 | - return array_merge( |
|
| 559 | - $columns, |
|
| 560 | - array( |
|
| 561 | - 'price' => 'price', |
|
| 562 | - 'vat_rule' => 'vat_rule', |
|
| 563 | - 'vat_class' => 'vat_class', |
|
| 564 | - 'type' => 'type', |
|
| 565 | - ) |
|
| 566 | - ); |
|
| 567 | - |
|
| 568 | - } |
|
| 569 | - |
|
| 570 | - /** |
|
| 571 | - * Displays items table columns. |
|
| 572 | - */ |
|
| 573 | - public static function display_item_columns( $column_name, $post_id ) { |
|
| 574 | - |
|
| 575 | - $item = new WPInv_Item( $post_id ); |
|
| 576 | - |
|
| 577 | - switch ( $column_name ) { |
|
| 578 | - |
|
| 579 | - case 'price': |
|
| 580 | - if ( ! $item->is_recurring() ) { |
|
| 581 | - echo wp_kses_post( $item->get_the_price() ); |
|
| 582 | - break; |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - $price = wp_sprintf( |
|
| 586 | - __( '%1$s / %2$s', 'invoicing' ), |
|
| 587 | - $item->get_the_price(), |
|
| 588 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
| 589 | - ); |
|
| 590 | - |
|
| 591 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
| 592 | - echo wp_kses_post( $price ); |
|
| 593 | - break; |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
| 597 | - |
|
| 598 | - echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
| 599 | - break; |
|
| 600 | - |
|
| 601 | - case 'vat_rule': |
|
| 602 | - echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) ); |
|
| 603 | - break; |
|
| 604 | - |
|
| 605 | - case 'vat_class': |
|
| 606 | - echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) ); |
|
| 607 | - break; |
|
| 608 | - |
|
| 609 | - case 'shortcode': |
|
| 610 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
| 611 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 612 | - } else { |
|
| 613 | - echo '—'; |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - break; |
|
| 617 | - |
|
| 618 | - case 'type': |
|
| 619 | - echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' ); |
|
| 620 | - break; |
|
| 621 | - |
|
| 622 | - } |
|
| 623 | - |
|
| 624 | - } |
|
| 625 | - |
|
| 626 | - /** |
|
| 627 | - * Lets users filter items using taxes. |
|
| 628 | - */ |
|
| 629 | - public static function add_item_filters( $post_type ) { |
|
| 630 | - |
|
| 631 | - // Abort if we're not dealing with items. |
|
| 632 | - if ( 'wpi_item' !== $post_type ) { |
|
| 633 | - return; |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - // Filter by vat rules. |
|
| 637 | - if ( wpinv_use_taxes() ) { |
|
| 638 | - |
|
| 639 | - // Sanitize selected vat rule. |
|
| 640 | - $vat_rule = ''; |
|
| 641 | - $vat_rules = getpaid_get_tax_rules(); |
|
| 642 | - if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 643 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - // Filter by VAT rule. |
|
| 647 | - wpinv_html_select( |
|
| 648 | - array( |
|
| 649 | - 'options' => array_merge( |
|
| 650 | - array( |
|
| 651 | - '' => __( 'All Tax Rules', 'invoicing' ), |
|
| 652 | - ), |
|
| 653 | - $vat_rules |
|
| 654 | - ), |
|
| 655 | - 'name' => 'vat_rule', |
|
| 656 | - 'id' => 'vat_rule', |
|
| 657 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '', |
|
| 658 | - 'show_option_all' => false, |
|
| 659 | - 'show_option_none' => false, |
|
| 660 | - ) |
|
| 661 | - ); |
|
| 662 | - |
|
| 663 | - // Filter by VAT class. |
|
| 664 | - |
|
| 665 | - // Sanitize selected vat rule. |
|
| 666 | - $vat_class = ''; |
|
| 667 | - $vat_classes = getpaid_get_tax_classes(); |
|
| 668 | - if ( isset( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 669 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - wpinv_html_select( |
|
| 673 | - array( |
|
| 674 | - 'options' => array_merge( |
|
| 675 | - array( |
|
| 676 | - '' => __( 'All Tax Classes', 'invoicing' ), |
|
| 677 | - ), |
|
| 678 | - $vat_classes |
|
| 679 | - ), |
|
| 680 | - 'name' => 'vat_class', |
|
| 681 | - 'id' => 'vat_class', |
|
| 682 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '', |
|
| 683 | - 'show_option_all' => false, |
|
| 684 | - 'show_option_none' => false, |
|
| 685 | - ) |
|
| 686 | - ); |
|
| 687 | - |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - // Filter by item type. |
|
| 691 | - $type = ''; |
|
| 692 | - if ( isset( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 693 | - $type = sanitize_text_field( $_GET['type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - wpinv_html_select( |
|
| 697 | - array( |
|
| 698 | - 'options' => array_merge( |
|
| 699 | - array( |
|
| 700 | - '' => __( 'All item types', 'invoicing' ), |
|
| 701 | - ), |
|
| 702 | - wpinv_get_item_types() |
|
| 703 | - ), |
|
| 704 | - 'name' => 'type', |
|
| 705 | - 'id' => 'type', |
|
| 706 | - 'selected' => in_array( $type, wpinv_item_types(), true ) ? $type : '', |
|
| 707 | - 'show_option_all' => false, |
|
| 708 | - 'show_option_none' => false, |
|
| 709 | - ) |
|
| 710 | - ); |
|
| 711 | - |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - /** |
|
| 715 | - * Filters the item query. |
|
| 716 | - */ |
|
| 717 | - public static function filter_item_query( $query ) { |
|
| 718 | - |
|
| 719 | - // modify the query only if it admin and main query. |
|
| 720 | - if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
| 721 | - return $query; |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - // we want to modify the query for our items. |
|
| 725 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) { |
|
| 726 | - return $query; |
|
| 727 | - } |
|
| 728 | - |
|
| 729 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
| 730 | - $query->query_vars['meta_query'] = array(); |
|
| 731 | - } |
|
| 732 | - |
|
| 733 | - // Filter vat rule type |
|
| 729 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
| 730 | + $query->query_vars['meta_query'] = array(); |
|
| 731 | + } |
|
| 732 | + |
|
| 733 | + // Filter vat rule type |
|
| 734 | 734 | if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 735 | 735 | $query->query_vars['meta_query'][] = array( |
| 736 | 736 | 'key' => '_wpinv_vat_rule', |
@@ -755,97 +755,97 @@ discard block |
||
| 755 | 755 | 'value' => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 756 | 756 | 'compare' => '=', |
| 757 | 757 | ); |
| 758 | - } |
|
| 759 | - |
|
| 760 | - } |
|
| 761 | - |
|
| 762 | - /** |
|
| 763 | - * Reorders items. |
|
| 764 | - */ |
|
| 765 | - public static function reorder_items( $vars ) { |
|
| 766 | - global $typenow; |
|
| 767 | - |
|
| 768 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
| 769 | - return $vars; |
|
| 770 | - } |
|
| 771 | - |
|
| 772 | - // By item type. |
|
| 773 | - if ( 'type' === $vars['orderby'] ) { |
|
| 774 | - return array_merge( |
|
| 775 | - $vars, |
|
| 776 | - array( |
|
| 777 | - 'meta_key' => '_wpinv_type', |
|
| 778 | - 'orderby' => 'meta_value', |
|
| 779 | - ) |
|
| 780 | - ); |
|
| 781 | - } |
|
| 782 | - |
|
| 783 | - // By vat class. |
|
| 784 | - if ( 'vat_class' === $vars['orderby'] ) { |
|
| 785 | - return array_merge( |
|
| 786 | - $vars, |
|
| 787 | - array( |
|
| 788 | - 'meta_key' => '_wpinv_vat_class', |
|
| 789 | - 'orderby' => 'meta_value', |
|
| 790 | - ) |
|
| 791 | - ); |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - // By vat rule. |
|
| 795 | - if ( 'vat_rule' === $vars['orderby'] ) { |
|
| 796 | - return array_merge( |
|
| 797 | - $vars, |
|
| 798 | - array( |
|
| 799 | - 'meta_key' => '_wpinv_vat_rule', |
|
| 800 | - 'orderby' => 'meta_value', |
|
| 801 | - ) |
|
| 802 | - ); |
|
| 803 | - } |
|
| 804 | - |
|
| 805 | - // By price. |
|
| 806 | - if ( 'price' === $vars['orderby'] ) { |
|
| 807 | - return array_merge( |
|
| 808 | - $vars, |
|
| 809 | - array( |
|
| 810 | - 'meta_key' => '_wpinv_price', |
|
| 811 | - 'orderby' => 'meta_value_num', |
|
| 812 | - ) |
|
| 813 | - ); |
|
| 814 | - } |
|
| 815 | - |
|
| 816 | - return $vars; |
|
| 817 | - |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - /** |
|
| 821 | - * Fired when deleting a post. |
|
| 822 | - */ |
|
| 823 | - public static function delete_post( $post_id ) { |
|
| 824 | - |
|
| 825 | - switch ( get_post_type( $post_id ) ) { |
|
| 826 | - |
|
| 827 | - case 'wpi_item': |
|
| 828 | - do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
| 829 | - break; |
|
| 830 | - |
|
| 831 | - case 'wpi_payment_form': |
|
| 832 | - do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
| 833 | - break; |
|
| 834 | - |
|
| 835 | - case 'wpi_discount': |
|
| 836 | - do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
| 837 | - break; |
|
| 838 | - |
|
| 839 | - case 'wpi_invoice': |
|
| 840 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 841 | - do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
| 842 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
| 843 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
| 844 | - break; |
|
| 845 | - } |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - /** |
|
| 758 | + } |
|
| 759 | + |
|
| 760 | + } |
|
| 761 | + |
|
| 762 | + /** |
|
| 763 | + * Reorders items. |
|
| 764 | + */ |
|
| 765 | + public static function reorder_items( $vars ) { |
|
| 766 | + global $typenow; |
|
| 767 | + |
|
| 768 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
| 769 | + return $vars; |
|
| 770 | + } |
|
| 771 | + |
|
| 772 | + // By item type. |
|
| 773 | + if ( 'type' === $vars['orderby'] ) { |
|
| 774 | + return array_merge( |
|
| 775 | + $vars, |
|
| 776 | + array( |
|
| 777 | + 'meta_key' => '_wpinv_type', |
|
| 778 | + 'orderby' => 'meta_value', |
|
| 779 | + ) |
|
| 780 | + ); |
|
| 781 | + } |
|
| 782 | + |
|
| 783 | + // By vat class. |
|
| 784 | + if ( 'vat_class' === $vars['orderby'] ) { |
|
| 785 | + return array_merge( |
|
| 786 | + $vars, |
|
| 787 | + array( |
|
| 788 | + 'meta_key' => '_wpinv_vat_class', |
|
| 789 | + 'orderby' => 'meta_value', |
|
| 790 | + ) |
|
| 791 | + ); |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + // By vat rule. |
|
| 795 | + if ( 'vat_rule' === $vars['orderby'] ) { |
|
| 796 | + return array_merge( |
|
| 797 | + $vars, |
|
| 798 | + array( |
|
| 799 | + 'meta_key' => '_wpinv_vat_rule', |
|
| 800 | + 'orderby' => 'meta_value', |
|
| 801 | + ) |
|
| 802 | + ); |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + // By price. |
|
| 806 | + if ( 'price' === $vars['orderby'] ) { |
|
| 807 | + return array_merge( |
|
| 808 | + $vars, |
|
| 809 | + array( |
|
| 810 | + 'meta_key' => '_wpinv_price', |
|
| 811 | + 'orderby' => 'meta_value_num', |
|
| 812 | + ) |
|
| 813 | + ); |
|
| 814 | + } |
|
| 815 | + |
|
| 816 | + return $vars; |
|
| 817 | + |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + /** |
|
| 821 | + * Fired when deleting a post. |
|
| 822 | + */ |
|
| 823 | + public static function delete_post( $post_id ) { |
|
| 824 | + |
|
| 825 | + switch ( get_post_type( $post_id ) ) { |
|
| 826 | + |
|
| 827 | + case 'wpi_item': |
|
| 828 | + do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
| 829 | + break; |
|
| 830 | + |
|
| 831 | + case 'wpi_payment_form': |
|
| 832 | + do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
| 833 | + break; |
|
| 834 | + |
|
| 835 | + case 'wpi_discount': |
|
| 836 | + do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
| 837 | + break; |
|
| 838 | + |
|
| 839 | + case 'wpi_invoice': |
|
| 840 | + $invoice = new WPInv_Invoice( $post_id ); |
|
| 841 | + do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
| 842 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
| 843 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
| 844 | + break; |
|
| 845 | + } |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + /** |
|
| 849 | 849 | * Add a post display state for special GetPaid pages in the page list table. |
| 850 | 850 | * |
| 851 | 851 | * @param array $post_states An array of post display states. |
@@ -859,21 +859,21 @@ discard block |
||
| 859 | 859 | $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
| 862 | + foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
| 863 | 863 | |
| 864 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
| 865 | - $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
| 866 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
| 867 | - $label |
|
| 868 | - ); |
|
| 869 | - } |
|
| 864 | + if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
| 865 | + $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
| 866 | + __( 'GetPaid %s History Page', 'invoicing' ), |
|
| 867 | + $label |
|
| 868 | + ); |
|
| 869 | + } |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
| 872 | + if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
| 873 | 873 | $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
| 876 | + if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
| 877 | 877 | $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
| 878 | 878 | } |
| 879 | 879 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Post types Admin Class |
@@ -21,74 +21,74 @@ discard block |
||
| 21 | 21 | GetPaid_Metaboxes::init(); |
| 22 | 22 | |
| 23 | 23 | // Filter the post updated messages. |
| 24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
| 24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
| 25 | 25 | |
| 26 | 26 | // Filter post actions. |
| 27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
| 28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
| 27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
| 28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
| 29 | 29 | |
| 30 | 30 | // Invoice table columns. |
| 31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
| 32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
| 33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
| 34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
| 31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
| 32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
| 33 | + add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions')); |
|
| 34 | + add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3); |
|
| 35 | 35 | |
| 36 | 36 | // Items table columns. |
| 37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
| 38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
| 39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
| 40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
| 41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
| 42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
| 37 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
| 38 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
| 39 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
| 40 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
| 41 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
| 42 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
| 43 | 43 | |
| 44 | 44 | // Payment forms columns. |
| 45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
| 46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
| 47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
| 45 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
| 46 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
| 47 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
| 48 | 48 | |
| 49 | 49 | // Discount table columns. |
| 50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
| 51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
| 50 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
| 51 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
| 52 | 52 | |
| 53 | 53 | // Deleting posts. |
| 54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
| 55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
| 54 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
| 55 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
| 56 | 56 | |
| 57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
| 57 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Post updated messages. |
| 62 | 62 | */ |
| 63 | - public static function post_updated_messages( $messages ) { |
|
| 63 | + public static function post_updated_messages($messages) { |
|
| 64 | 64 | global $post; |
| 65 | 65 | |
| 66 | 66 | $messages['wpi_discount'] = array( |
| 67 | 67 | 0 => '', |
| 68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
| 69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
| 72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
| 74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
| 75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
| 76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
| 68 | + 1 => __('Discount updated.', 'invoicing'), |
|
| 69 | + 2 => __('Custom field updated.', 'invoicing'), |
|
| 70 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
| 71 | + 4 => __('Discount updated.', 'invoicing'), |
|
| 72 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
| 73 | + 6 => __('Discount updated.', 'invoicing'), |
|
| 74 | + 7 => __('Discount saved.', 'invoicing'), |
|
| 75 | + 8 => __('Discount submitted.', 'invoicing'), |
|
| 76 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
| 77 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | 80 | $messages['wpi_payment_form'] = array( |
| 81 | 81 | 0 => '', |
| 82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
| 84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
| 85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
| 88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
| 89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
| 90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
| 91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
| 82 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
| 83 | + 2 => __('Custom field updated.', 'invoicing'), |
|
| 84 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
| 85 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
| 86 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
| 87 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
| 88 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
| 89 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
| 90 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
| 91 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | return $messages; |
@@ -98,16 +98,16 @@ discard block |
||
| 98 | 98 | /** |
| 99 | 99 | * Post row actions. |
| 100 | 100 | */ |
| 101 | - public static function post_row_actions( $actions, $post ) { |
|
| 101 | + public static function post_row_actions($actions, $post) { |
|
| 102 | 102 | |
| 103 | - $post = get_post( $post ); |
|
| 103 | + $post = get_post($post); |
|
| 104 | 104 | |
| 105 | 105 | // We do not want to edit the default payment form. |
| 106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
| 106 | + if ('wpi_payment_form' == $post->post_type) { |
|
| 107 | 107 | |
| 108 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
| 109 | - unset( $actions['trash'] ); |
|
| 110 | - unset( $actions['inline hide-if-no-js'] ); |
|
| 108 | + if ($post->ID == wpinv_get_default_payment_form()) { |
|
| 109 | + unset($actions['trash']); |
|
| 110 | + unset($actions['inline hide-if-no-js']); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $actions['duplicate'] = sprintf( |
@@ -124,20 +124,20 @@ discard block |
||
| 124 | 124 | 'getpaid-nonce' |
| 125 | 125 | ) |
| 126 | 126 | ), |
| 127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 127 | + esc_html(__('Duplicate', 'invoicing')) |
|
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // Link to item payment form. |
| 133 | - if ( 'wpi_item' == $post->post_type ) { |
|
| 133 | + if ('wpi_item' == $post->post_type) { |
|
| 134 | 134 | |
| 135 | - if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) { |
|
| 135 | + if (in_array(get_post_meta($post->ID, '_wpinv_type', true), array('', 'fee', 'custom'))) { |
|
| 136 | 136 | |
| 137 | 137 | $actions['buy'] = sprintf( |
| 138 | 138 | '<a href="%1$s">%2$s</a>', |
| 139 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
| 140 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
| 139 | + esc_url(getpaid_embed_url(false, $post->ID . '|0')), |
|
| 140 | + esc_html(__('Buy', 'invoicing')) |
|
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | 143 | } |
@@ -154,27 +154,27 @@ discard block |
||
| 154 | 154 | * @param WP_Post $post |
| 155 | 155 | * @return array $actions actions without edit option |
| 156 | 156 | */ |
| 157 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
| 157 | + public static function filter_invoice_row_actions($actions, $post) { |
|
| 158 | 158 | |
| 159 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 159 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
| 160 | 160 | |
| 161 | 161 | $actions = array(); |
| 162 | - $invoice = new WPInv_Invoice( $post ); |
|
| 162 | + $invoice = new WPInv_Invoice($post); |
|
| 163 | 163 | |
| 164 | 164 | $actions['edit'] = sprintf( |
| 165 | 165 | '<a href="%1$s">%2$s</a>', |
| 166 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
| 167 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
| 166 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
| 167 | + esc_html(__('Edit', 'invoicing')) |
|
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | - if ( ! $invoice->is_draft() ) { |
|
| 170 | + if (!$invoice->is_draft()) { |
|
| 171 | 171 | |
| 172 | 172 | $actions['view'] = sprintf( |
| 173 | 173 | '<a href="%1$s">%2$s</a>', |
| 174 | - esc_url( $invoice->get_view_url() ), |
|
| 174 | + esc_url($invoice->get_view_url()), |
|
| 175 | 175 | sprintf( |
| 176 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
| 177 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
| 176 | + esc_html(__('View %s', 'invoicing')), |
|
| 177 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
| 178 | 178 | ) |
| 179 | 179 | ); |
| 180 | 180 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | 'getpaid-nonce' |
| 193 | 193 | ) |
| 194 | 194 | ), |
| 195 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
| 195 | + esc_html(__('Send to Customer', 'invoicing')) |
|
| 196 | 196 | ); |
| 197 | 197 | |
| 198 | 198 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | 'getpaid-nonce' |
| 212 | 212 | ) |
| 213 | 213 | ), |
| 214 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
| 214 | + esc_html(__('Duplicate', 'invoicing')) |
|
| 215 | 215 | ); |
| 216 | 216 | |
| 217 | 217 | } |
@@ -222,42 +222,42 @@ discard block |
||
| 222 | 222 | /** |
| 223 | 223 | * Returns an array of invoice table columns. |
| 224 | 224 | */ |
| 225 | - public static function invoice_columns( $columns ) { |
|
| 225 | + public static function invoice_columns($columns) { |
|
| 226 | 226 | |
| 227 | 227 | $columns = array( |
| 228 | 228 | 'cb' => $columns['cb'], |
| 229 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
| 230 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 231 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
| 232 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
| 233 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 234 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
| 235 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 229 | + 'number' => __('Invoice', 'invoicing'), |
|
| 230 | + 'customer' => __('Customer', 'invoicing'), |
|
| 231 | + 'invoice_date' => __('Created', 'invoicing'), |
|
| 232 | + 'payment_date' => __('Completed', 'invoicing'), |
|
| 233 | + 'amount' => __('Amount', 'invoicing'), |
|
| 234 | + 'recurring' => __('Recurring', 'invoicing'), |
|
| 235 | + 'status' => __('Status', 'invoicing'), |
|
| 236 | 236 | ); |
| 237 | 237 | |
| 238 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 238 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
| 242 | 242 | * Displays invoice table columns. |
| 243 | 243 | */ |
| 244 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
| 244 | + public static function display_invoice_columns($column_name, $post_id) { |
|
| 245 | 245 | |
| 246 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 246 | + $invoice = new WPInv_Invoice($post_id); |
|
| 247 | 247 | |
| 248 | - switch ( $column_name ) { |
|
| 248 | + switch ($column_name) { |
|
| 249 | 249 | |
| 250 | 250 | case 'invoice_date': |
| 251 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
| 252 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
| 253 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
| 251 | + $date_time = esc_attr($invoice->get_created_date()); |
|
| 252 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
| 253 | + echo wp_kses_post("<span title='$date_time'>$date</span>"); |
|
| 254 | 254 | break; |
| 255 | 255 | |
| 256 | 256 | case 'payment_date': |
| 257 | - if ( $invoice->is_paid() ) { |
|
| 258 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
| 259 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
| 260 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
| 257 | + if ($invoice->is_paid()) { |
|
| 258 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
| 259 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
| 260 | + echo wp_kses_post("<span title='$date_time'>$date</span>"); |
|
| 261 | 261 | } else { |
| 262 | 262 | echo '—'; |
| 263 | 263 | } |
@@ -266,61 +266,61 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | case 'amount': |
| 268 | 268 | $amount = $invoice->get_total(); |
| 269 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
| 269 | + $formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency())); |
|
| 270 | 270 | |
| 271 | - if ( $invoice->is_refunded() ) { |
|
| 272 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
| 273 | - echo wp_kses_post( "<del>$formated_amount</del> <ins>$refunded_amount</ins>" ); |
|
| 271 | + if ($invoice->is_refunded()) { |
|
| 272 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
| 273 | + echo wp_kses_post("<del>$formated_amount</del> <ins>$refunded_amount</ins>"); |
|
| 274 | 274 | } else { |
| 275 | 275 | |
| 276 | 276 | $discount = $invoice->get_total_discount(); |
| 277 | 277 | |
| 278 | - if ( ! empty( $discount ) ) { |
|
| 279 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
| 280 | - echo wp_kses_post( "<del>$new_amount</del> <ins>$formated_amount</ins>" ); |
|
| 278 | + if (!empty($discount)) { |
|
| 279 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
| 280 | + echo wp_kses_post("<del>$new_amount</del> <ins>$formated_amount</ins>"); |
|
| 281 | 281 | } else { |
| 282 | - echo wp_kses_post( $formated_amount ); |
|
| 282 | + echo wp_kses_post($formated_amount); |
|
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | break; |
| 287 | 287 | |
| 288 | 288 | case 'status': |
| 289 | - $status = esc_html( $invoice->get_status() ); |
|
| 290 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
| 289 | + $status = esc_html($invoice->get_status()); |
|
| 290 | + $status_label = esc_html($invoice->get_status_nicename()); |
|
| 291 | 291 | |
| 292 | 292 | // If it is paid, show the gateway title. |
| 293 | - if ( $invoice->is_paid() ) { |
|
| 294 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
| 295 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
| 293 | + if ($invoice->is_paid()) { |
|
| 294 | + $gateway = esc_html($invoice->get_gateway_title()); |
|
| 295 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway)); |
|
| 296 | 296 | |
| 297 | - echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" ); |
|
| 297 | + echo wp_kses_post("<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"); |
|
| 298 | 298 | } else { |
| 299 | - echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" ); |
|
| 299 | + echo wp_kses_post("<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // If it is not paid, display the overdue and view status. |
| 303 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
| 303 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
| 304 | 304 | |
| 305 | 305 | // Invoice view status. |
| 306 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
| 307 | - echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
| 306 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
| 307 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
| 308 | 308 | } else { |
| 309 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
| 309 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Display the overview status. |
| 313 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
| 313 | + if (wpinv_get_option('overdue_active')) { |
|
| 314 | 314 | $due_date = $invoice->get_due_date(); |
| 315 | - $fomatted = getpaid_format_date( $due_date ); |
|
| 315 | + $fomatted = getpaid_format_date($due_date); |
|
| 316 | 316 | |
| 317 | - if ( ! empty( $fomatted ) ) { |
|
| 317 | + if (!empty($fomatted)) { |
|
| 318 | 318 | $date = wp_sprintf( |
| 319 | 319 | // translators: %s is the due date. |
| 320 | - __( 'Due %s', 'invoicing' ), |
|
| 320 | + __('Due %s', 'invoicing'), |
|
| 321 | 321 | $fomatted |
| 322 | 322 | ); |
| 323 | - echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" ); |
|
| 323 | + echo wp_kses_post("<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"); |
|
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | break; |
| 329 | 329 | |
| 330 | 330 | case 'recurring': |
| 331 | - if ( $invoice->is_recurring() ) { |
|
| 331 | + if ($invoice->is_recurring()) { |
|
| 332 | 332 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
| 333 | 333 | } else { |
| 334 | 334 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -336,26 +336,26 @@ discard block |
||
| 336 | 336 | break; |
| 337 | 337 | |
| 338 | 338 | case 'number': |
| 339 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
| 340 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
| 341 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
| 339 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
| 340 | + $invoice_number = esc_html($invoice->get_number()); |
|
| 341 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
| 342 | 342 | |
| 343 | - echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" ); |
|
| 343 | + echo wp_kses_post("<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"); |
|
| 344 | 344 | |
| 345 | - do_action( 'getpaid_admin_table_invoice_number_column', $invoice ); |
|
| 345 | + do_action('getpaid_admin_table_invoice_number_column', $invoice); |
|
| 346 | 346 | break; |
| 347 | 347 | |
| 348 | 348 | case 'customer': |
| 349 | 349 | $customer_name = $invoice->get_user_full_name(); |
| 350 | 350 | |
| 351 | - if ( empty( $customer_name ) ) { |
|
| 351 | + if (empty($customer_name)) { |
|
| 352 | 352 | $customer_name = $invoice->get_email(); |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - if ( ! empty( $customer_name ) ) { |
|
| 356 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
| 357 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
| 358 | - echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" ); |
|
| 355 | + if (!empty($customer_name)) { |
|
| 356 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
| 357 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
| 358 | + echo wp_kses_post("<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"); |
|
| 359 | 359 | } else { |
| 360 | 360 | echo '<div>—</div>'; |
| 361 | 361 | } |
@@ -369,19 +369,19 @@ discard block |
||
| 369 | 369 | /** |
| 370 | 370 | * Displays invoice bulk actions. |
| 371 | 371 | */ |
| 372 | - public static function invoice_bulk_actions( $actions ) { |
|
| 373 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
| 372 | + public static function invoice_bulk_actions($actions) { |
|
| 373 | + $actions['resend-invoice'] = __('Send to Customer', 'invoicing'); |
|
| 374 | 374 | return $actions; |
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
| 378 | 378 | * Processes invoice bulk actions. |
| 379 | 379 | */ |
| 380 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
| 380 | + public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) { |
|
| 381 | 381 | |
| 382 | - if ( 'resend-invoice' === $action ) { |
|
| 383 | - foreach ( $post_ids as $post_id ) { |
|
| 384 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
| 382 | + if ('resend-invoice' === $action) { |
|
| 383 | + foreach ($post_ids as $post_id) { |
|
| 384 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true); |
|
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
@@ -392,49 +392,49 @@ discard block |
||
| 392 | 392 | /** |
| 393 | 393 | * Returns an array of payment forms table columns. |
| 394 | 394 | */ |
| 395 | - public static function payment_form_columns( $columns ) { |
|
| 395 | + public static function payment_form_columns($columns) { |
|
| 396 | 396 | |
| 397 | 397 | $columns = array( |
| 398 | 398 | 'cb' => $columns['cb'], |
| 399 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 400 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 401 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
| 402 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
| 403 | - 'items' => __( 'Items', 'invoicing' ), |
|
| 404 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 399 | + 'title' => __('Name', 'invoicing'), |
|
| 400 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
| 401 | + 'earnings' => __('Revenue', 'invoicing'), |
|
| 402 | + 'refunds' => __('Refunded', 'invoicing'), |
|
| 403 | + 'items' => __('Items', 'invoicing'), |
|
| 404 | + 'date' => __('Date', 'invoicing'), |
|
| 405 | 405 | ); |
| 406 | 406 | |
| 407 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
| 407 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
| 408 | 408 | |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | 412 | * Displays payment form table columns. |
| 413 | 413 | */ |
| 414 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
| 414 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
| 415 | 415 | |
| 416 | 416 | // Retrieve the payment form. |
| 417 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
| 417 | + $form = new GetPaid_Payment_Form($post_id); |
|
| 418 | 418 | |
| 419 | - switch ( $column_name ) { |
|
| 419 | + switch ($column_name) { |
|
| 420 | 420 | |
| 421 | 421 | case 'earnings': |
| 422 | - echo wp_kses_post( wpinv_price( $form->get_earned() ) ); |
|
| 422 | + echo wp_kses_post(wpinv_price($form->get_earned())); |
|
| 423 | 423 | break; |
| 424 | 424 | |
| 425 | 425 | case 'refunds': |
| 426 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
| 426 | + echo wp_kses_post(wpinv_price($form->get_refunded())); |
|
| 427 | 427 | break; |
| 428 | 428 | |
| 429 | 429 | case 'refunds': |
| 430 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
| 430 | + echo wp_kses_post(wpinv_price($form->get_refunded())); |
|
| 431 | 431 | break; |
| 432 | 432 | |
| 433 | 433 | case 'shortcode': |
| 434 | - if ( $form->is_default() ) { |
|
| 434 | + if ($form->is_default()) { |
|
| 435 | 435 | echo '—'; |
| 436 | 436 | } else { |
| 437 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
| 437 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | break; |
@@ -442,28 +442,28 @@ discard block |
||
| 442 | 442 | case 'items': |
| 443 | 443 | $items = $form->get_items(); |
| 444 | 444 | |
| 445 | - if ( $form->is_default() || empty( $items ) ) { |
|
| 445 | + if ($form->is_default() || empty($items)) { |
|
| 446 | 446 | echo '—'; |
| 447 | 447 | return; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | $_items = array(); |
| 451 | 451 | |
| 452 | - foreach ( $items as $item ) { |
|
| 452 | + foreach ($items as $item) { |
|
| 453 | 453 | $url = $item->get_edit_url(); |
| 454 | 454 | |
| 455 | - if ( empty( $url ) ) { |
|
| 456 | - $_items[] = esc_html( $item->get_name() ); |
|
| 455 | + if (empty($url)) { |
|
| 456 | + $_items[] = esc_html($item->get_name()); |
|
| 457 | 457 | } else { |
| 458 | 458 | $_items[] = sprintf( |
| 459 | 459 | '<a href="%s">%s</a>', |
| 460 | - esc_url( $url ), |
|
| 461 | - esc_html( $item->get_name() ) |
|
| 460 | + esc_url($url), |
|
| 461 | + esc_html($item->get_name()) |
|
| 462 | 462 | ); |
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - echo wp_kses_post( implode( '<br>', $_items ) ); |
|
| 466 | + echo wp_kses_post(implode('<br>', $_items)); |
|
| 467 | 467 | |
| 468 | 468 | break; |
| 469 | 469 | |
@@ -474,10 +474,10 @@ discard block |
||
| 474 | 474 | /** |
| 475 | 475 | * Filters post states. |
| 476 | 476 | */ |
| 477 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
| 477 | + public static function filter_payment_form_state($post_states, $post) { |
|
| 478 | 478 | |
| 479 | - if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) { |
|
| 480 | - $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
| 479 | + if ('wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID) { |
|
| 480 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | return $post_states; |
@@ -487,35 +487,35 @@ discard block |
||
| 487 | 487 | /** |
| 488 | 488 | * Returns an array of coupon table columns. |
| 489 | 489 | */ |
| 490 | - public static function discount_columns( $columns ) { |
|
| 490 | + public static function discount_columns($columns) { |
|
| 491 | 491 | |
| 492 | 492 | $columns = array( |
| 493 | 493 | 'cb' => $columns['cb'], |
| 494 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 495 | - 'code' => __( 'Code', 'invoicing' ), |
|
| 496 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 497 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
| 498 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 499 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
| 494 | + 'title' => __('Name', 'invoicing'), |
|
| 495 | + 'code' => __('Code', 'invoicing'), |
|
| 496 | + 'amount' => __('Amount', 'invoicing'), |
|
| 497 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
| 498 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 499 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
| 500 | 500 | ); |
| 501 | 501 | |
| 502 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
| 502 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | /** |
| 506 | 506 | * Filters post states. |
| 507 | 507 | */ |
| 508 | - public static function filter_discount_state( $post_states, $post ) { |
|
| 508 | + public static function filter_discount_state($post_states, $post) { |
|
| 509 | 509 | |
| 510 | - if ( 'wpi_discount' === $post->post_type ) { |
|
| 510 | + if ('wpi_discount' === $post->post_type) { |
|
| 511 | 511 | |
| 512 | - $discount = new WPInv_Discount( $post ); |
|
| 512 | + $discount = new WPInv_Discount($post); |
|
| 513 | 513 | |
| 514 | 514 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
| 515 | 515 | |
| 516 | - if ( 'publish' !== $status ) { |
|
| 516 | + if ('publish' !== $status) { |
|
| 517 | 517 | return array( |
| 518 | - 'discount_status' => wpinv_discount_status( $status ), |
|
| 518 | + 'discount_status' => wpinv_discount_status($status), |
|
| 519 | 519 | ); |
| 520 | 520 | } |
| 521 | 521 | |
@@ -530,30 +530,30 @@ discard block |
||
| 530 | 530 | /** |
| 531 | 531 | * Returns an array of items table columns. |
| 532 | 532 | */ |
| 533 | - public static function item_columns( $columns ) { |
|
| 533 | + public static function item_columns($columns) { |
|
| 534 | 534 | |
| 535 | 535 | $columns = array( |
| 536 | 536 | 'cb' => $columns['cb'], |
| 537 | - 'title' => __( 'Name', 'invoicing' ), |
|
| 538 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 539 | - 'vat_rule' => __( 'Tax Rule', 'invoicing' ), |
|
| 540 | - 'vat_class' => __( 'Tax Class', 'invoicing' ), |
|
| 541 | - 'type' => __( 'Type', 'invoicing' ), |
|
| 542 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
| 537 | + 'title' => __('Name', 'invoicing'), |
|
| 538 | + 'price' => __('Price', 'invoicing'), |
|
| 539 | + 'vat_rule' => __('Tax Rule', 'invoicing'), |
|
| 540 | + 'vat_class' => __('Tax Class', 'invoicing'), |
|
| 541 | + 'type' => __('Type', 'invoicing'), |
|
| 542 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
| 543 | 543 | ); |
| 544 | 544 | |
| 545 | - if ( ! wpinv_use_taxes() ) { |
|
| 546 | - unset( $columns['vat_rule'] ); |
|
| 547 | - unset( $columns['vat_class'] ); |
|
| 545 | + if (!wpinv_use_taxes()) { |
|
| 546 | + unset($columns['vat_rule']); |
|
| 547 | + unset($columns['vat_class']); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
| 550 | + return apply_filters('wpi_item_table_columns', $columns); |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
| 554 | 554 | * Returns an array of sortable items table columns. |
| 555 | 555 | */ |
| 556 | - public static function sortable_item_columns( $columns ) { |
|
| 556 | + public static function sortable_item_columns($columns) { |
|
| 557 | 557 | |
| 558 | 558 | return array_merge( |
| 559 | 559 | $columns, |
@@ -570,45 +570,45 @@ discard block |
||
| 570 | 570 | /** |
| 571 | 571 | * Displays items table columns. |
| 572 | 572 | */ |
| 573 | - public static function display_item_columns( $column_name, $post_id ) { |
|
| 573 | + public static function display_item_columns($column_name, $post_id) { |
|
| 574 | 574 | |
| 575 | - $item = new WPInv_Item( $post_id ); |
|
| 575 | + $item = new WPInv_Item($post_id); |
|
| 576 | 576 | |
| 577 | - switch ( $column_name ) { |
|
| 577 | + switch ($column_name) { |
|
| 578 | 578 | |
| 579 | 579 | case 'price': |
| 580 | - if ( ! $item->is_recurring() ) { |
|
| 581 | - echo wp_kses_post( $item->get_the_price() ); |
|
| 580 | + if (!$item->is_recurring()) { |
|
| 581 | + echo wp_kses_post($item->get_the_price()); |
|
| 582 | 582 | break; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | $price = wp_sprintf( |
| 586 | - __( '%1$s / %2$s', 'invoicing' ), |
|
| 586 | + __('%1$s / %2$s', 'invoicing'), |
|
| 587 | 587 | $item->get_the_price(), |
| 588 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
| 588 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
| 589 | 589 | ); |
| 590 | 590 | |
| 591 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
| 592 | - echo wp_kses_post( $price ); |
|
| 591 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
| 592 | + echo wp_kses_post($price); |
|
| 593 | 593 | break; |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
| 596 | + echo wp_kses_post($item->get_the_initial_price()); |
|
| 597 | 597 | |
| 598 | - echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
| 598 | + echo '<span class="meta">' . wp_sprintf(esc_html__('then %s', 'invoicing'), wp_kses_post($price)) . '</span>'; |
|
| 599 | 599 | break; |
| 600 | 600 | |
| 601 | 601 | case 'vat_rule': |
| 602 | - echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) ); |
|
| 602 | + echo wp_kses_post(getpaid_get_tax_rule_label($item->get_vat_rule())); |
|
| 603 | 603 | break; |
| 604 | 604 | |
| 605 | 605 | case 'vat_class': |
| 606 | - echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) ); |
|
| 606 | + echo wp_kses_post(getpaid_get_tax_class_label($item->get_vat_class())); |
|
| 607 | 607 | break; |
| 608 | 608 | |
| 609 | 609 | case 'shortcode': |
| 610 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
| 611 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 610 | + if ($item->is_type(array('', 'fee', 'custom'))) { |
|
| 611 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
| 612 | 612 | } else { |
| 613 | 613 | echo '—'; |
| 614 | 614 | } |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | break; |
| 617 | 617 | |
| 618 | 618 | case 'type': |
| 619 | - echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' ); |
|
| 619 | + echo wp_kses_post(wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'); |
|
| 620 | 620 | break; |
| 621 | 621 | |
| 622 | 622 | } |
@@ -626,21 +626,21 @@ discard block |
||
| 626 | 626 | /** |
| 627 | 627 | * Lets users filter items using taxes. |
| 628 | 628 | */ |
| 629 | - public static function add_item_filters( $post_type ) { |
|
| 629 | + public static function add_item_filters($post_type) { |
|
| 630 | 630 | |
| 631 | 631 | // Abort if we're not dealing with items. |
| 632 | - if ( 'wpi_item' !== $post_type ) { |
|
| 632 | + if ('wpi_item' !== $post_type) { |
|
| 633 | 633 | return; |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | // Filter by vat rules. |
| 637 | - if ( wpinv_use_taxes() ) { |
|
| 637 | + if (wpinv_use_taxes()) { |
|
| 638 | 638 | |
| 639 | 639 | // Sanitize selected vat rule. |
| 640 | 640 | $vat_rule = ''; |
| 641 | 641 | $vat_rules = getpaid_get_tax_rules(); |
| 642 | - if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 643 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 642 | + if (isset($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 643 | + $vat_rule = sanitize_text_field($_GET['vat_rule']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | // Filter by VAT rule. |
@@ -648,13 +648,13 @@ discard block |
||
| 648 | 648 | array( |
| 649 | 649 | 'options' => array_merge( |
| 650 | 650 | array( |
| 651 | - '' => __( 'All Tax Rules', 'invoicing' ), |
|
| 651 | + '' => __('All Tax Rules', 'invoicing'), |
|
| 652 | 652 | ), |
| 653 | 653 | $vat_rules |
| 654 | 654 | ), |
| 655 | 655 | 'name' => 'vat_rule', |
| 656 | 656 | 'id' => 'vat_rule', |
| 657 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '', |
|
| 657 | + 'selected' => in_array($vat_rule, array_keys($vat_rules), true) ? $vat_rule : '', |
|
| 658 | 658 | 'show_option_all' => false, |
| 659 | 659 | 'show_option_none' => false, |
| 660 | 660 | ) |
@@ -665,21 +665,21 @@ discard block |
||
| 665 | 665 | // Sanitize selected vat rule. |
| 666 | 666 | $vat_class = ''; |
| 667 | 667 | $vat_classes = getpaid_get_tax_classes(); |
| 668 | - if ( isset( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 669 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 668 | + if (isset($_GET['vat_class'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 669 | + $vat_class = sanitize_text_field($_GET['vat_class']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | wpinv_html_select( |
| 673 | 673 | array( |
| 674 | 674 | 'options' => array_merge( |
| 675 | 675 | array( |
| 676 | - '' => __( 'All Tax Classes', 'invoicing' ), |
|
| 676 | + '' => __('All Tax Classes', 'invoicing'), |
|
| 677 | 677 | ), |
| 678 | 678 | $vat_classes |
| 679 | 679 | ), |
| 680 | 680 | 'name' => 'vat_class', |
| 681 | 681 | 'id' => 'vat_class', |
| 682 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '', |
|
| 682 | + 'selected' => in_array($vat_class, array_keys($vat_classes), true) ? $vat_class : '', |
|
| 683 | 683 | 'show_option_all' => false, |
| 684 | 684 | 'show_option_none' => false, |
| 685 | 685 | ) |
@@ -688,22 +688,22 @@ discard block |
||
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | // Filter by item type. |
| 691 | - $type = ''; |
|
| 692 | - if ( isset( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 693 | - $type = sanitize_text_field( $_GET['type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 691 | + $type = ''; |
|
| 692 | + if (isset($_GET['type'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 693 | + $type = sanitize_text_field($_GET['type']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | wpinv_html_select( |
| 697 | 697 | array( |
| 698 | 698 | 'options' => array_merge( |
| 699 | 699 | array( |
| 700 | - '' => __( 'All item types', 'invoicing' ), |
|
| 700 | + '' => __('All item types', 'invoicing'), |
|
| 701 | 701 | ), |
| 702 | 702 | wpinv_get_item_types() |
| 703 | 703 | ), |
| 704 | 704 | 'name' => 'type', |
| 705 | 705 | 'id' => 'type', |
| 706 | - 'selected' => in_array( $type, wpinv_item_types(), true ) ? $type : '', |
|
| 706 | + 'selected' => in_array($type, wpinv_item_types(), true) ? $type : '', |
|
| 707 | 707 | 'show_option_all' => false, |
| 708 | 708 | 'show_option_none' => false, |
| 709 | 709 | ) |
@@ -714,45 +714,45 @@ discard block |
||
| 714 | 714 | /** |
| 715 | 715 | * Filters the item query. |
| 716 | 716 | */ |
| 717 | - public static function filter_item_query( $query ) { |
|
| 717 | + public static function filter_item_query($query) { |
|
| 718 | 718 | |
| 719 | 719 | // modify the query only if it admin and main query. |
| 720 | - if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
| 720 | + if (!(is_admin() && $query->is_main_query())) { |
|
| 721 | 721 | return $query; |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | // we want to modify the query for our items. |
| 725 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) { |
|
| 725 | + if (empty($query->query['post_type']) || 'wpi_item' !== $query->query['post_type']) { |
|
| 726 | 726 | return $query; |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
| 729 | + if (empty($query->query_vars['meta_query'])) { |
|
| 730 | 730 | $query->query_vars['meta_query'] = array(); |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | // Filter vat rule type |
| 734 | - if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 734 | + if (!empty($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 735 | 735 | $query->query_vars['meta_query'][] = array( |
| 736 | 736 | 'key' => '_wpinv_vat_rule', |
| 737 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 737 | + 'value' => sanitize_text_field($_GET['vat_rule']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 738 | 738 | 'compare' => '=', |
| 739 | 739 | ); |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | // Filter vat class |
| 743 | - if ( ! empty( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 743 | + if (!empty($_GET['vat_class'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 744 | 744 | $query->query_vars['meta_query'][] = array( |
| 745 | 745 | 'key' => '_wpinv_vat_class', |
| 746 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 746 | + 'value' => sanitize_text_field($_GET['vat_class']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 747 | 747 | 'compare' => '=', |
| 748 | 748 | ); |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | // Filter item type |
| 752 | - if ( ! empty( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 752 | + if (!empty($_GET['type'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 753 | 753 | $query->query_vars['meta_query'][] = array( |
| 754 | 754 | 'key' => '_wpinv_type', |
| 755 | - 'value' => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 755 | + 'value' => sanitize_text_field($_GET['type']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 756 | 756 | 'compare' => '=', |
| 757 | 757 | ); |
| 758 | 758 | } |
@@ -762,15 +762,15 @@ discard block |
||
| 762 | 762 | /** |
| 763 | 763 | * Reorders items. |
| 764 | 764 | */ |
| 765 | - public static function reorder_items( $vars ) { |
|
| 765 | + public static function reorder_items($vars) { |
|
| 766 | 766 | global $typenow; |
| 767 | 767 | |
| 768 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
| 768 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
| 769 | 769 | return $vars; |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | // By item type. |
| 773 | - if ( 'type' === $vars['orderby'] ) { |
|
| 773 | + if ('type' === $vars['orderby']) { |
|
| 774 | 774 | return array_merge( |
| 775 | 775 | $vars, |
| 776 | 776 | array( |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | // By vat class. |
| 784 | - if ( 'vat_class' === $vars['orderby'] ) { |
|
| 784 | + if ('vat_class' === $vars['orderby']) { |
|
| 785 | 785 | return array_merge( |
| 786 | 786 | $vars, |
| 787 | 787 | array( |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | // By vat rule. |
| 795 | - if ( 'vat_rule' === $vars['orderby'] ) { |
|
| 795 | + if ('vat_rule' === $vars['orderby']) { |
|
| 796 | 796 | return array_merge( |
| 797 | 797 | $vars, |
| 798 | 798 | array( |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | // By price. |
| 806 | - if ( 'price' === $vars['orderby'] ) { |
|
| 806 | + if ('price' === $vars['orderby']) { |
|
| 807 | 807 | return array_merge( |
| 808 | 808 | $vars, |
| 809 | 809 | array( |
@@ -820,27 +820,27 @@ discard block |
||
| 820 | 820 | /** |
| 821 | 821 | * Fired when deleting a post. |
| 822 | 822 | */ |
| 823 | - public static function delete_post( $post_id ) { |
|
| 823 | + public static function delete_post($post_id) { |
|
| 824 | 824 | |
| 825 | - switch ( get_post_type( $post_id ) ) { |
|
| 825 | + switch (get_post_type($post_id)) { |
|
| 826 | 826 | |
| 827 | 827 | case 'wpi_item': |
| 828 | - do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
| 828 | + do_action('getpaid_before_delete_item', new WPInv_Item($post_id)); |
|
| 829 | 829 | break; |
| 830 | 830 | |
| 831 | 831 | case 'wpi_payment_form': |
| 832 | - do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
| 832 | + do_action('getpaid_before_delete_payment_form', new GetPaid_Payment_Form($post_id)); |
|
| 833 | 833 | break; |
| 834 | 834 | |
| 835 | 835 | case 'wpi_discount': |
| 836 | - do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
| 836 | + do_action('getpaid_before_delete_discount', new WPInv_Discount($post_id)); |
|
| 837 | 837 | break; |
| 838 | 838 | |
| 839 | 839 | case 'wpi_invoice': |
| 840 | - $invoice = new WPInv_Invoice( $post_id ); |
|
| 841 | - do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
| 842 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
| 843 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
| 840 | + $invoice = new WPInv_Invoice($post_id); |
|
| 841 | + do_action('getpaid_before_delete_invoice', $invoice); |
|
| 842 | + $invoice->get_data_store()->delete_items($invoice); |
|
| 843 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
| 844 | 844 | break; |
| 845 | 845 | } |
| 846 | 846 | } |
@@ -853,28 +853,28 @@ discard block |
||
| 853 | 853 | * |
| 854 | 854 | * @return mixed |
| 855 | 855 | */ |
| 856 | - public static function add_display_post_states( $post_states, $post ) { |
|
| 856 | + public static function add_display_post_states($post_states, $post) { |
|
| 857 | 857 | |
| 858 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
| 859 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
| 858 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
| 859 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
| 860 | 860 | } |
| 861 | 861 | |
| 862 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
| 862 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
| 863 | 863 | |
| 864 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
| 865 | - $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf( |
|
| 866 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
| 864 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
| 865 | + $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
|
| 866 | + __('GetPaid %s History Page', 'invoicing'), |
|
| 867 | 867 | $label |
| 868 | 868 | ); |
| 869 | 869 | } |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
| 873 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
| 872 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
| 873 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
| 877 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
| 876 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
| 877 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | return $post_states; |