@@ -7,256 +7,256 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | -function wpinv_columns( $columns ) { |
|
| 14 | +function wpinv_columns($columns) { |
|
| 15 | 15 | $columns = array( |
| 16 | 16 | 'cb' => $columns['cb'], |
| 17 | - 'number' => __( 'Number', 'invoicing' ), |
|
| 18 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 19 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 20 | - 'invoice_date' => __( 'Created Date', 'invoicing' ), |
|
| 21 | - 'payment_date' => __( 'Payment Date', 'invoicing' ), |
|
| 22 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 23 | - 'ID' => __( 'ID', 'invoicing' ), |
|
| 24 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
| 17 | + 'number' => __('Number', 'invoicing'), |
|
| 18 | + 'customer' => __('Customer', 'invoicing'), |
|
| 19 | + 'amount' => __('Amount', 'invoicing'), |
|
| 20 | + 'invoice_date' => __('Created Date', 'invoicing'), |
|
| 21 | + 'payment_date' => __('Payment Date', 'invoicing'), |
|
| 22 | + 'status' => __('Status', 'invoicing'), |
|
| 23 | + 'ID' => __('ID', 'invoicing'), |
|
| 24 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
| 27 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
| 28 | 28 | } |
| 29 | -add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' ); |
|
| 29 | +add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns'); |
|
| 30 | 30 | |
| 31 | -function wpinv_bulk_actions( $actions ) { |
|
| 32 | - if ( isset( $actions['edit'] ) ) { |
|
| 33 | - unset( $actions['edit'] ); |
|
| 31 | +function wpinv_bulk_actions($actions) { |
|
| 32 | + if (isset($actions['edit'])) { |
|
| 33 | + unset($actions['edit']); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | return $actions; |
| 37 | 37 | } |
| 38 | -add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' ); |
|
| 39 | -add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' ); |
|
| 38 | +add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions'); |
|
| 39 | +add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions'); |
|
| 40 | 40 | |
| 41 | -function wpinv_sortable_columns( $columns ) { |
|
| 41 | +function wpinv_sortable_columns($columns) { |
|
| 42 | 42 | $columns = array( |
| 43 | - 'ID' => array( 'ID', true ), |
|
| 44 | - 'number' => array( 'number', false ), |
|
| 45 | - 'amount' => array( 'amount', false ), |
|
| 46 | - 'invoice_date' => array( 'date', false ), |
|
| 47 | - 'payment_date' => array( 'payment_date', true ), |
|
| 48 | - 'customer' => array( 'customer', false ), |
|
| 49 | - 'status' => array( 'status', false ), |
|
| 43 | + 'ID' => array('ID', true), |
|
| 44 | + 'number' => array('number', false), |
|
| 45 | + 'amount' => array('amount', false), |
|
| 46 | + 'invoice_date' => array('date', false), |
|
| 47 | + 'payment_date' => array('payment_date', true), |
|
| 48 | + 'customer' => array('customer', false), |
|
| 49 | + 'status' => array('status', false), |
|
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - return apply_filters( 'wpi_invoice_table_sortable_columns', $columns ); |
|
| 52 | + return apply_filters('wpi_invoice_table_sortable_columns', $columns); |
|
| 53 | 53 | } |
| 54 | -add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' ); |
|
| 54 | +add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns'); |
|
| 55 | 55 | |
| 56 | -add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 57 | -function wpinv_posts_custom_column( $column_name, $post_id = 0 ) { |
|
| 56 | +add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column'); |
|
| 57 | +function wpinv_posts_custom_column($column_name, $post_id = 0) { |
|
| 58 | 58 | global $post, $wpi_invoice; |
| 59 | 59 | |
| 60 | - if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) { |
|
| 61 | - $wpi_invoice = new WPInv_Invoice( $post->ID ); |
|
| 60 | + if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) { |
|
| 61 | + $wpi_invoice = new WPInv_Invoice($post->ID); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $value = NULL; |
| 65 | 65 | |
| 66 | - switch ( $column_name ) { |
|
| 66 | + switch ($column_name) { |
|
| 67 | 67 | case 'email' : |
| 68 | - $value = $wpi_invoice->get_email(); |
|
| 68 | + $value = $wpi_invoice->get_email(); |
|
| 69 | 69 | break; |
| 70 | 70 | case 'customer' : |
| 71 | 71 | $customer_name = $wpi_invoice->get_user_full_name(); |
| 72 | - $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' ); |
|
| 73 | - $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>'; |
|
| 74 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 72 | + $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing'); |
|
| 73 | + $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>'; |
|
| 74 | + if ($email = $wpi_invoice->get_email()) { |
|
| 75 | 75 | $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>'; |
| 76 | 76 | } |
| 77 | 77 | break; |
| 78 | 78 | case 'amount' : |
| 79 | - echo $wpi_invoice->get_total( true ); |
|
| 79 | + echo $wpi_invoice->get_total(true); |
|
| 80 | 80 | break; |
| 81 | 81 | case 'invoice_date' : |
| 82 | - $date_format = get_option( 'date_format' ); |
|
| 83 | - $time_format = get_option( 'time_format' ); |
|
| 84 | - $date_time_format = $date_format . ' '. $time_format; |
|
| 82 | + $date_format = get_option('date_format'); |
|
| 83 | + $time_format = get_option('time_format'); |
|
| 84 | + $date_time_format = $date_format . ' ' . $time_format; |
|
| 85 | 85 | |
| 86 | - $t_time = get_the_time( $date_time_format ); |
|
| 86 | + $t_time = get_the_time($date_time_format); |
|
| 87 | 87 | $m_time = $post->post_date; |
| 88 | - $h_time = mysql2date( $date_format, $m_time ); |
|
| 88 | + $h_time = mysql2date($date_format, $m_time); |
|
| 89 | 89 | |
| 90 | - $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
| 90 | + $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
| 91 | 91 | break; |
| 92 | 92 | case 'payment_date' : |
| 93 | - if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) { |
|
| 94 | - $date_format = get_option( 'date_format' ); |
|
| 95 | - $time_format = get_option( 'time_format' ); |
|
| 96 | - $date_time_format = $date_format . ' '. $time_format; |
|
| 93 | + if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) { |
|
| 94 | + $date_format = get_option('date_format'); |
|
| 95 | + $time_format = get_option('time_format'); |
|
| 96 | + $date_time_format = $date_format . ' ' . $time_format; |
|
| 97 | 97 | |
| 98 | - $t_time = get_the_time( $date_time_format ); |
|
| 98 | + $t_time = get_the_time($date_time_format); |
|
| 99 | 99 | $m_time = $date_completed; |
| 100 | - $h_time = mysql2date( $date_format, $m_time ); |
|
| 100 | + $h_time = mysql2date($date_format, $m_time); |
|
| 101 | 101 | |
| 102 | - $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
| 102 | + $value = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>'; |
|
| 103 | 103 | } else { |
| 104 | 104 | $value = '-'; |
| 105 | 105 | } |
| 106 | 106 | break; |
| 107 | 107 | case 'status' : |
| 108 | - $value = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' ); |
|
| 109 | - if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && $gateway_title = $wpi_invoice->get_gateway_title() ) { |
|
| 110 | - $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>'; |
|
| 108 | + $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : ''); |
|
| 109 | + if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && $gateway_title = $wpi_invoice->get_gateway_title()) { |
|
| 110 | + $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>'; |
|
| 111 | 111 | } |
| 112 | 112 | break; |
| 113 | 113 | case 'number' : |
| 114 | - $edit_link = get_edit_post_link( $post->ID ); |
|
| 115 | - $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
| 114 | + $edit_link = get_edit_post_link($post->ID); |
|
| 115 | + $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>'; |
|
| 116 | 116 | break; |
| 117 | 117 | case 'wpi_actions' : |
| 118 | 118 | $value = ''; |
| 119 | - if ( !empty( $post->post_name ) ) { |
|
| 120 | - $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 119 | + if (!empty($post->post_name)) { |
|
| 120 | + $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>'; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if ( $email = $wpi_invoice->get_email() ) { |
|
| 124 | - $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 123 | + if ($email = $wpi_invoice->get_email()) { |
|
| 124 | + $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>'; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | break; |
| 128 | 128 | default: |
| 129 | - $value = isset( $post->$column_name ) ? $post->$column_name : ''; |
|
| 129 | + $value = isset($post->$column_name) ? $post->$column_name : ''; |
|
| 130 | 130 | break; |
| 131 | 131 | |
| 132 | 132 | } |
| 133 | - $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name ); |
|
| 133 | + $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name); |
|
| 134 | 134 | |
| 135 | - if ( $value !== NULL ) { |
|
| 135 | + if ($value !== NULL) { |
|
| 136 | 136 | echo $value; |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -function wpinv_admin_post_id( $id = 0 ) { |
|
| 140 | +function wpinv_admin_post_id($id = 0) { |
|
| 141 | 141 | global $post; |
| 142 | 142 | |
| 143 | - if ( isset( $id ) && ! empty( $id ) ) { |
|
| 143 | + if (isset($id) && !empty($id)) { |
|
| 144 | 144 | return (int)$id; |
| 145 | - } else if ( get_the_ID() ) { |
|
| 146 | - return (int) get_the_ID(); |
|
| 147 | - } else if ( isset( $post->ID ) && !empty( $post->ID ) ) { |
|
| 148 | - return (int) $post->ID; |
|
| 149 | - } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) { |
|
| 150 | - return (int) $_GET['post']; |
|
| 151 | - } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) { |
|
| 152 | - return (int) $_GET['id']; |
|
| 153 | - } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) { |
|
| 154 | - return (int) $_POST['id']; |
|
| 145 | + } else if (get_the_ID()) { |
|
| 146 | + return (int)get_the_ID(); |
|
| 147 | + } else if (isset($post->ID) && !empty($post->ID)) { |
|
| 148 | + return (int)$post->ID; |
|
| 149 | + } else if (isset($_GET['post']) && !empty($_GET['post'])) { |
|
| 150 | + return (int)$_GET['post']; |
|
| 151 | + } else if (isset($_GET['id']) && !empty($_GET['id'])) { |
|
| 152 | + return (int)$_GET['id']; |
|
| 153 | + } else if (isset($_POST['id']) && !empty($_POST['id'])) { |
|
| 154 | + return (int)$_POST['id']; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | return null; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | -function wpinv_admin_post_type( $id = 0 ) { |
|
| 161 | - if ( !$id ) { |
|
| 160 | +function wpinv_admin_post_type($id = 0) { |
|
| 161 | + if (!$id) { |
|
| 162 | 162 | $id = wpinv_admin_post_id(); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - $type = get_post_type( $id ); |
|
| 165 | + $type = get_post_type($id); |
|
| 166 | 166 | |
| 167 | - if ( !$type ) { |
|
| 168 | - $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null; |
|
| 167 | + if (!$type) { |
|
| 168 | + $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - return apply_filters( 'wpinv_admin_post_type', $type, $id ); |
|
| 171 | + return apply_filters('wpinv_admin_post_type', $type, $id); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | function wpinv_admin_messages() { |
| 175 | 175 | global $wpinv_options, $pagenow, $post; |
| 176 | 176 | |
| 177 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 178 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 177 | + if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 178 | + add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated'); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 182 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 181 | + if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 182 | + add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 186 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 185 | + if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 186 | + add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error'); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 190 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 189 | + if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 190 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated'); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 194 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 193 | + if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 194 | + add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error'); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 198 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 197 | + if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 198 | + add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated'); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 202 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 201 | + if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 202 | + add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated'); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 206 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 205 | + if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 206 | + add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error'); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 210 | - add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
|
| 209 | + if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 210 | + add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated'); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 214 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 213 | + if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 214 | + add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated'); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 218 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 217 | + if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 218 | + add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated'); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 222 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 221 | + if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) { |
|
| 222 | + add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated'); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
| 226 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
| 225 | + if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) { |
|
| 226 | + $message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID); |
|
| 227 | 227 | |
| 228 | - if ( !empty( $message ) ) { |
|
| 229 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
| 228 | + if (!empty($message)) { |
|
| 229 | + add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated'); |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - settings_errors( 'wpinv-notices' ); |
|
| 233 | + settings_errors('wpinv-notices'); |
|
| 234 | 234 | } |
| 235 | -add_action( 'admin_notices', 'wpinv_admin_messages' ); |
|
| 235 | +add_action('admin_notices', 'wpinv_admin_messages'); |
|
| 236 | 236 | |
| 237 | -function wpinv_items_columns( $existing_columns ) { |
|
| 237 | +function wpinv_items_columns($existing_columns) { |
|
| 238 | 238 | global $wpinv_euvat; |
| 239 | 239 | |
| 240 | 240 | $columns = array(); |
| 241 | 241 | $columns['cb'] = $existing_columns['cb']; |
| 242 | - $columns['title'] = __( 'Title', 'invoicing' ); |
|
| 243 | - $columns['price'] = __( 'Price', 'invoicing' ); |
|
| 244 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 245 | - $columns['vat_rule'] = __( 'VAT rule type', 'invoicing' ); |
|
| 242 | + $columns['title'] = __('Title', 'invoicing'); |
|
| 243 | + $columns['price'] = __('Price', 'invoicing'); |
|
| 244 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 245 | + $columns['vat_rule'] = __('VAT rule type', 'invoicing'); |
|
| 246 | 246 | } |
| 247 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 248 | - $columns['vat_class'] = __( 'VAT class', 'invoicing' ); |
|
| 247 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 248 | + $columns['vat_class'] = __('VAT class', 'invoicing'); |
|
| 249 | 249 | } |
| 250 | - $columns['type'] = __( 'Type', 'invoicing' ); |
|
| 251 | - $columns['recurring'] = __( 'Recurring', 'invoicing' ); |
|
| 252 | - $columns['date'] = __( 'Date', 'invoicing' ); |
|
| 253 | - $columns['id'] = __( 'ID', 'invoicing' ); |
|
| 250 | + $columns['type'] = __('Type', 'invoicing'); |
|
| 251 | + $columns['recurring'] = __('Recurring', 'invoicing'); |
|
| 252 | + $columns['date'] = __('Date', 'invoicing'); |
|
| 253 | + $columns['id'] = __('ID', 'invoicing'); |
|
| 254 | 254 | |
| 255 | - return apply_filters( 'wpinv_items_columns', $columns ); |
|
| 255 | + return apply_filters('wpinv_items_columns', $columns); |
|
| 256 | 256 | } |
| 257 | -add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' ); |
|
| 257 | +add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns'); |
|
| 258 | 258 | |
| 259 | -function wpinv_items_sortable_columns( $columns ) { |
|
| 259 | +function wpinv_items_sortable_columns($columns) { |
|
| 260 | 260 | $columns['price'] = 'price'; |
| 261 | 261 | $columns['vat_rule'] = 'vat_rule'; |
| 262 | 262 | $columns['vat_class'] = 'vat_class'; |
@@ -266,151 +266,151 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | return $columns; |
| 268 | 268 | } |
| 269 | -add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' ); |
|
| 269 | +add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns'); |
|
| 270 | 270 | |
| 271 | -function wpinv_items_table_custom_column( $column ) { |
|
| 271 | +function wpinv_items_table_custom_column($column) { |
|
| 272 | 272 | global $wpinv_euvat, $post, $wpi_item; |
| 273 | 273 | |
| 274 | - if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) { |
|
| 275 | - $wpi_item = new WPInv_Item( $post->ID ); |
|
| 274 | + if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) { |
|
| 275 | + $wpi_item = new WPInv_Item($post->ID); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - switch ( $column ) { |
|
| 278 | + switch ($column) { |
|
| 279 | 279 | case 'price' : |
| 280 | - echo wpinv_item_price( $post->ID ); |
|
| 280 | + echo wpinv_item_price($post->ID); |
|
| 281 | 281 | break; |
| 282 | 282 | case 'vat_rule' : |
| 283 | - echo $wpinv_euvat->item_rule_label( $post->ID ); |
|
| 283 | + echo $wpinv_euvat->item_rule_label($post->ID); |
|
| 284 | 284 | break; |
| 285 | 285 | case 'vat_class' : |
| 286 | - echo $wpinv_euvat->item_class_label( $post->ID ); |
|
| 286 | + echo $wpinv_euvat->item_class_label($post->ID); |
|
| 287 | 287 | break; |
| 288 | 288 | case 'type' : |
| 289 | - echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
| 289 | + echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>'; |
|
| 290 | 290 | break; |
| 291 | 291 | case 'recurring' : |
| 292 | - echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' ); |
|
| 292 | + echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>'); |
|
| 293 | 293 | break; |
| 294 | 294 | case 'id' : |
| 295 | 295 | echo $post->ID; |
| 296 | 296 | echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
| 297 | - <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
|
| 298 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 299 | - echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
|
| 297 | + <div class="price">' . wpinv_get_item_price($post->ID) . '</div>'; |
|
| 298 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 299 | + echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>'; |
|
| 300 | 300 | } |
| 301 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 302 | - echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>'; |
|
| 301 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 302 | + echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>'; |
|
| 303 | 303 | } |
| 304 | - echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div> |
|
| 304 | + echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div> |
|
| 305 | 305 | </div>'; |
| 306 | 306 | break; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post ); |
|
| 309 | + do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post); |
|
| 310 | 310 | } |
| 311 | -add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' ); |
|
| 311 | +add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column'); |
|
| 312 | 312 | |
| 313 | 313 | function wpinv_add_items_filters() { |
| 314 | 314 | global $wpinv_euvat, $typenow; |
| 315 | 315 | |
| 316 | 316 | // Checks if the current post type is 'item' |
| 317 | - if ( $typenow == 'wpi_item') { |
|
| 318 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
| 319 | - echo wpinv_html_select( array( |
|
| 320 | - 'options' => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ), |
|
| 317 | + if ($typenow == 'wpi_item') { |
|
| 318 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
| 319 | + echo wpinv_html_select(array( |
|
| 320 | + 'options' => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()), |
|
| 321 | 321 | 'name' => 'vat_rule', |
| 322 | 322 | 'id' => 'vat_rule', |
| 323 | - 'selected' => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ), |
|
| 323 | + 'selected' => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''), |
|
| 324 | 324 | 'show_option_all' => false, |
| 325 | 325 | 'show_option_none' => false, |
| 326 | 326 | 'class' => 'gdmbx2-text-medium', |
| 327 | - ) ); |
|
| 327 | + )); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
| 331 | - echo wpinv_html_select( array( |
|
| 332 | - 'options' => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ), |
|
| 330 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
| 331 | + echo wpinv_html_select(array( |
|
| 332 | + 'options' => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()), |
|
| 333 | 333 | 'name' => 'vat_class', |
| 334 | 334 | 'id' => 'vat_class', |
| 335 | - 'selected' => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ), |
|
| 335 | + 'selected' => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''), |
|
| 336 | 336 | 'show_option_all' => false, |
| 337 | 337 | 'show_option_none' => false, |
| 338 | 338 | 'class' => 'gdmbx2-text-medium', |
| 339 | - ) ); |
|
| 339 | + )); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - echo wpinv_html_select( array( |
|
| 343 | - 'options' => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ), |
|
| 342 | + echo wpinv_html_select(array( |
|
| 343 | + 'options' => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()), |
|
| 344 | 344 | 'name' => 'type', |
| 345 | 345 | 'id' => 'type', |
| 346 | - 'selected' => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ), |
|
| 346 | + 'selected' => (isset($_GET['type']) ? $_GET['type'] : ''), |
|
| 347 | 347 | 'show_option_all' => false, |
| 348 | 348 | 'show_option_none' => false, |
| 349 | 349 | 'class' => 'gdmbx2-text-medium', |
| 350 | - ) ); |
|
| 350 | + )); |
|
| 351 | 351 | |
| 352 | - if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) { |
|
| 352 | + if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) { |
|
| 353 | 353 | echo '<input type="hidden" name="all_posts" value="1" />'; |
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | -add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 ); |
|
| 357 | +add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100); |
|
| 358 | 358 | |
| 359 | -function wpinv_send_invoice_after_save( $invoice ) { |
|
| 360 | - if ( empty( $_POST['wpi_save_send'] ) ) { |
|
| 359 | +function wpinv_send_invoice_after_save($invoice) { |
|
| 360 | + if (empty($_POST['wpi_save_send'])) { |
|
| 361 | 361 | return; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) { |
|
| 365 | - wpinv_user_invoice_notification( $invoice->ID ); |
|
| 364 | + if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) { |
|
| 365 | + wpinv_user_invoice_notification($invoice->ID); |
|
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | -add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 ); |
|
| 368 | +add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1); |
|
| 369 | 369 | |
| 370 | -function wpinv_send_register_new_user( $data, $postarr ) { |
|
| 371 | - if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) { |
|
| 372 | - $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false; |
|
| 373 | - $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL; |
|
| 370 | +function wpinv_send_register_new_user($data, $postarr) { |
|
| 371 | + if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) { |
|
| 372 | + $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false; |
|
| 373 | + $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL; |
|
| 374 | 374 | |
| 375 | - if ( $is_new_user && $email && !email_exists( $email ) ) { |
|
| 376 | - $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : ''; |
|
| 377 | - $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : ''; |
|
| 378 | - $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : ''; |
|
| 379 | - $user_nicename = $display_name ? trim( $display_name ) : $email; |
|
| 380 | - $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : ''; |
|
| 375 | + if ($is_new_user && $email && !email_exists($email)) { |
|
| 376 | + $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : ''; |
|
| 377 | + $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : ''; |
|
| 378 | + $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : ''; |
|
| 379 | + $user_nicename = $display_name ? trim($display_name) : $email; |
|
| 380 | + $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : ''; |
|
| 381 | 381 | |
| 382 | - $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true ); |
|
| 383 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 382 | + $user_login = sanitize_user(str_replace(' ', '', $display_name), true); |
|
| 383 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 384 | 384 | $new_user_login = strstr($email, '@', true); |
| 385 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
| 386 | - $user_login = sanitize_user($new_user_login, true ); |
|
| 385 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
| 386 | + $user_login = sanitize_user($new_user_login, true); |
|
| 387 | 387 | } |
| 388 | - if ( validate_username( $user_login ) && username_exists( $user_login ) ) { |
|
| 389 | - $user_append_text = rand(10,1000); |
|
| 390 | - $user_login = sanitize_user($new_user_login.$user_append_text, true ); |
|
| 388 | + if (validate_username($user_login) && username_exists($user_login)) { |
|
| 389 | + $user_append_text = rand(10, 1000); |
|
| 390 | + $user_login = sanitize_user($new_user_login . $user_append_text, true); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) { |
|
| 393 | + if (!(validate_username($user_login) && !username_exists($user_login))) { |
|
| 394 | 394 | $user_login = $email; |
| 395 | 395 | } |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | $userdata = array( |
| 399 | 399 | 'user_login' => $user_login, |
| 400 | - 'user_pass' => wp_generate_password( 12, false ), |
|
| 401 | - 'user_email' => sanitize_text_field( $email ), |
|
| 400 | + 'user_pass' => wp_generate_password(12, false), |
|
| 401 | + 'user_email' => sanitize_text_field($email), |
|
| 402 | 402 | 'first_name' => $first_name, |
| 403 | 403 | 'last_name' => $last_name, |
| 404 | - 'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ), |
|
| 404 | + 'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50), |
|
| 405 | 405 | 'nickname' => $display_name, |
| 406 | 406 | 'display_name' => $display_name, |
| 407 | 407 | ); |
| 408 | 408 | |
| 409 | - $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata ); |
|
| 409 | + $userdata = apply_filters('wpinv_register_new_user_data', $userdata); |
|
| 410 | 410 | |
| 411 | - $new_user_id = wp_insert_user( $userdata ); |
|
| 411 | + $new_user_id = wp_insert_user($userdata); |
|
| 412 | 412 | |
| 413 | - if ( !is_wp_error( $new_user_id ) ) { |
|
| 413 | + if (!is_wp_error($new_user_id)) { |
|
| 414 | 414 | $data['post_author'] = $new_user_id; |
| 415 | 415 | $_POST['post_author'] = $new_user_id; |
| 416 | 416 | $_POST['post_author_override'] = $new_user_id; |
@@ -431,48 +431,48 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | $meta = array(); |
| 433 | 433 | ///$meta['_wpinv_user_id'] = $new_user_id; |
| 434 | - foreach ( $meta_fields as $field ) { |
|
| 435 | - $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : ''; |
|
| 434 | + foreach ($meta_fields as $field) { |
|
| 435 | + $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : ''; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id ); |
|
| 438 | + $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id); |
|
| 439 | 439 | |
| 440 | 440 | // Update user meta. |
| 441 | - foreach ( $meta as $key => $value ) { |
|
| 442 | - update_user_meta( $new_user_id, $key, $value ); |
|
| 441 | + foreach ($meta as $key => $value) { |
|
| 442 | + update_user_meta($new_user_id, $key, $value); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if ( function_exists( 'wp_send_new_user_notifications' ) ) { |
|
| 445 | + if (function_exists('wp_send_new_user_notifications')) { |
|
| 446 | 446 | // Send email notifications related to the creation of new user. |
| 447 | - wp_send_new_user_notifications( $new_user_id, 'user' ); |
|
| 447 | + wp_send_new_user_notifications($new_user_id, 'user'); |
|
| 448 | 448 | } |
| 449 | 449 | } else { |
| 450 | - wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ ); |
|
| 450 | + wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__); |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | return $data; |
| 456 | 456 | } |
| 457 | -add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 ); |
|
| 457 | +add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2); |
|
| 458 | 458 | |
| 459 | -function wpinv_show_recurring_supported_gateways( $item_ID ) { |
|
| 459 | +function wpinv_show_recurring_supported_gateways($item_ID) { |
|
| 460 | 460 | $all_gateways = wpinv_get_payment_gateways(); |
| 461 | 461 | |
| 462 | - if ( !empty( $all_gateways ) ) { |
|
| 462 | + if (!empty($all_gateways)) { |
|
| 463 | 463 | $gateways = array(); |
| 464 | 464 | |
| 465 | - foreach ( $all_gateways as $key => $gateway ) { |
|
| 466 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 465 | + foreach ($all_gateways as $key => $gateway) { |
|
| 466 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 467 | 467 | $gateways[] = $gateway['admin_label']; |
| 468 | 468 | } |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - if ( !empty( $gateways ) ) { |
|
| 471 | + if (!empty($gateways)) { |
|
| 472 | 472 | ?> |
| 473 | - <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span> |
|
| 473 | + <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span> |
|
| 474 | 474 | <?php |
| 475 | 475 | } |
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | -add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 ); |
|
| 479 | 478 | \ No newline at end of file |
| 479 | +add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1); |
|
| 480 | 480 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if (!defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -15,41 +15,41 @@ discard block |
||
| 15 | 15 | 'wpinv_buy' => __CLASS__ . '::buy', |
| 16 | 16 | ); |
| 17 | 17 | |
| 18 | - foreach ( $shortcodes as $shortcode => $function ) { |
|
| 19 | - add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); |
|
| 18 | + foreach ($shortcodes as $shortcode => $function) { |
|
| 19 | + add_shortcode(apply_filters("{$shortcode}_shortcode_tag", $shortcode), $function); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - add_shortcode( 'wpinv_messages', __CLASS__ . '::messages' ); |
|
| 22 | + add_shortcode('wpinv_messages', __CLASS__ . '::messages'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public static function shortcode_wrapper( $function, $atts = array(), $content = null, $wrapper = array( 'class' => 'wpi-g', 'before' => null, 'after' => null ) ) { |
|
| 25 | + public static function shortcode_wrapper($function, $atts = array(), $content = null, $wrapper = array('class' => 'wpi-g', 'before' => null, 'after' => null)) { |
|
| 26 | 26 | ob_start(); |
| 27 | 27 | |
| 28 | - echo empty( $wrapper['before'] ) ? '<div class="' . esc_attr( $wrapper['class'] ) . '">' : $wrapper['before']; |
|
| 29 | - call_user_func( $function, $atts, $content ); |
|
| 30 | - echo empty( $wrapper['after'] ) ? '</div>' : $wrapper['after']; |
|
| 28 | + echo empty($wrapper['before']) ? '<div class="' . esc_attr($wrapper['class']) . '">' : $wrapper['before']; |
|
| 29 | + call_user_func($function, $atts, $content); |
|
| 30 | + echo empty($wrapper['after']) ? '</div>' : $wrapper['after']; |
|
| 31 | 31 | |
| 32 | 32 | return ob_get_clean(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public static function checkout( $atts = array(), $content = null ) { |
|
| 36 | - return self::shortcode_wrapper( array( __CLASS__, 'checkout_output' ), $atts, $content ); |
|
| 35 | + public static function checkout($atts = array(), $content = null) { |
|
| 36 | + return self::shortcode_wrapper(array(__CLASS__, 'checkout_output'), $atts, $content); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public static function checkout_output( $atts = array(), $content = null ) { |
|
| 40 | - do_action( 'wpinv_checkout_content_before' ); |
|
| 41 | - echo wpinv_checkout_form( $atts, $content ); |
|
| 42 | - do_action( 'wpinv_checkout_content_after' ); |
|
| 39 | + public static function checkout_output($atts = array(), $content = null) { |
|
| 40 | + do_action('wpinv_checkout_content_before'); |
|
| 41 | + echo wpinv_checkout_form($atts, $content); |
|
| 42 | + do_action('wpinv_checkout_content_after'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public static function messages( $atts, $content = null ) { |
|
| 45 | + public static function messages($atts, $content = null) { |
|
| 46 | 46 | ob_start(); |
| 47 | 47 | wpinv_print_errors(); |
| 48 | 48 | return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public static function history( $atts, $content = null ) { |
|
| 52 | - return self::shortcode_wrapper( array( __CLASS__, 'history_output' ), $atts ); |
|
| 51 | + public static function history($atts, $content = null) { |
|
| 52 | + return self::shortcode_wrapper(array(__CLASS__, 'history_output'), $atts); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @param array $atts |
| 59 | 59 | */ |
| 60 | - public static function history_output( $atts ) { |
|
| 61 | - do_action( 'wpinv_before_user_invoice_history' ); |
|
| 62 | - wpinv_get_template_part( 'wpinv-invoice-history', $atts ); |
|
| 63 | - do_action( 'wpinv_after_user_invoice_history' ); |
|
| 60 | + public static function history_output($atts) { |
|
| 61 | + do_action('wpinv_before_user_invoice_history'); |
|
| 62 | + wpinv_get_template_part('wpinv-invoice-history', $atts); |
|
| 63 | + do_action('wpinv_after_user_invoice_history'); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public static function success( $atts, $content = null ) { |
|
| 67 | - return self::shortcode_wrapper( array( __CLASS__, 'success_output' ), $atts, $content ); |
|
| 66 | + public static function success($atts, $content = null) { |
|
| 67 | + return self::shortcode_wrapper(array(__CLASS__, 'success_output'), $atts, $content); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -72,24 +72,24 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param array $atts |
| 74 | 74 | */ |
| 75 | - public static function success_output( $atts, $content = null ) { |
|
| 76 | - do_action( 'wpinv_success_content_before' ); |
|
| 77 | - echo wpinv_payment_receipt( $atts, $content ); |
|
| 78 | - do_action( 'wpinv_success_content_after' ); |
|
| 75 | + public static function success_output($atts, $content = null) { |
|
| 76 | + do_action('wpinv_success_content_before'); |
|
| 77 | + echo wpinv_payment_receipt($atts, $content); |
|
| 78 | + do_action('wpinv_success_content_after'); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public static function buy( $atts, $content = null ) { |
|
| 82 | - $a = shortcode_atts( array( |
|
| 81 | + public static function buy($atts, $content = null) { |
|
| 82 | + $a = shortcode_atts(array( |
|
| 83 | 83 | 'items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
| 84 | - 'title' => __( 'Buy Now', 'invoicing' ), // the button title |
|
| 84 | + 'title' => __('Buy Now', 'invoicing'), // the button title |
|
| 85 | 85 | 'post_id' => '', // any related post_id |
| 86 | - ), $atts ); |
|
| 86 | + ), $atts); |
|
| 87 | 87 | |
| 88 | - $post_id = isset( $a['post_id'] ) ? (int)$a['post_id'] : ''; |
|
| 88 | + $post_id = isset($a['post_id']) ? (int)$a['post_id'] : ''; |
|
| 89 | 89 | |
| 90 | 90 | $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
| 91 | 91 | $html .= '<button class="button button-primary wpi-buy-button" type="button" onclick="wpi_buy(this,\'' . $a['items'] . '\',' . $post_id . ');">' . $a['title'] . '</button>'; |
| 92 | - $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
| 92 | + $html .= wp_nonce_field('wpinv_buy_items', 'wpinv_buy_nonce', true, false); |
|
| 93 | 93 | $html .= '</div>'; |
| 94 | 94 | |
| 95 | 95 | return $html; |
@@ -7,15 +7,15 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | class WPInv_Plugin { |
| 15 | 15 | private static $instance; |
| 16 | 16 | |
| 17 | 17 | public static function run() { |
| 18 | - if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) { |
|
| 18 | + if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) { |
|
| 19 | 19 | self::$instance = new WPInv_Plugin; |
| 20 | 20 | self::$instance->includes(); |
| 21 | 21 | self::$instance->actions(); |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | self::$instance->reports = new WPInv_Reports(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - do_action( 'wpinv_loaded' ); |
|
| 26 | + do_action('wpinv_loaded'); |
|
| 27 | 27 | |
| 28 | 28 | return self::$instance; |
| 29 | 29 | } |
@@ -33,31 +33,31 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function define_constants() { |
| 36 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
| 37 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
| 36 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
| 37 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | private function actions() { |
| 41 | 41 | /* Internationalize the text strings used. */ |
| 42 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
| 42 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
| 43 | 43 | |
| 44 | 44 | /* Perform actions on admin initialization. */ |
| 45 | - add_action( 'admin_init', array( &$this, 'admin_init') ); |
|
| 46 | - add_action( 'init', array( &$this, 'init' ), 3 ); |
|
| 47 | - add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) ); |
|
| 48 | - add_action( 'init', array( &$this, 'wpinv_actions' ) ); |
|
| 45 | + add_action('admin_init', array(&$this, 'admin_init')); |
|
| 46 | + add_action('init', array(&$this, 'init'), 3); |
|
| 47 | + add_action('init', array('WPInv_Shortcodes', 'init')); |
|
| 48 | + add_action('init', array(&$this, 'wpinv_actions')); |
|
| 49 | 49 | |
| 50 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 51 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 50 | + if (class_exists('BuddyPress')) { |
|
| 51 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 54 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
| 55 | 55 | |
| 56 | - if ( is_admin() ) { |
|
| 57 | - add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) ); |
|
| 58 | - add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) ); |
|
| 56 | + if (is_admin()) { |
|
| 57 | + add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts')); |
|
| 58 | + add_action('admin_body_class', array(&$this, 'admin_body_class')); |
|
| 59 | 59 | } else { |
| 60 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 60 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference. |
| 69 | 69 | */ |
| 70 | - do_action_ref_array( 'wpinv_actions', array( &$this ) ); |
|
| 70 | + do_action_ref_array('wpinv_actions', array(&$this)); |
|
| 71 | 71 | |
| 72 | - add_action( 'admin_init', array( &$this, 'activation_redirect') ); |
|
| 72 | + add_action('admin_init', array(&$this, 'activation_redirect')); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public function plugins_loaded() { |
@@ -83,196 +83,196 @@ discard block |
||
| 83 | 83 | * @since 1.0 |
| 84 | 84 | */ |
| 85 | 85 | public function load_textdomain() { |
| 86 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 87 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
| 86 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
| 87 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
| 88 | 88 | |
| 89 | - unload_textdomain( 'invoicing' ); |
|
| 90 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 91 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 89 | + unload_textdomain('invoicing'); |
|
| 90 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
| 91 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | 94 | * Define language constants. |
| 95 | 95 | */ |
| 96 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 96 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public function includes() { |
| 100 | 100 | global $wpinv_options; |
| 101 | 101 | |
| 102 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 102 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
| 103 | 103 | $wpinv_options = wpinv_get_settings(); |
| 104 | 104 | |
| 105 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' ); |
|
| 106 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 107 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 108 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 109 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 110 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 111 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 112 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' ); |
|
| 113 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 114 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 115 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 116 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 117 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 118 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' ); |
|
| 105 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php'); |
|
| 106 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
| 107 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
| 108 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
| 109 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
| 110 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
| 111 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
| 112 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php'); |
|
| 113 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
| 114 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
| 115 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
| 116 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
| 117 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
| 118 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php'); |
|
| 119 | 119 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
| 120 | 120 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
| 121 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' ); |
|
| 121 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php'); |
|
| 122 | 122 | //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' ); |
| 123 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' ); |
|
| 124 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' ); |
|
| 125 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' ); |
|
| 126 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 127 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 128 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' ); |
|
| 129 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' ); |
|
| 130 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
| 131 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
| 132 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 123 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php'); |
|
| 124 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php'); |
|
| 125 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php'); |
|
| 126 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
| 127 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
| 128 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php'); |
|
| 129 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php'); |
|
| 130 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
| 131 | + if (!class_exists('WPInv_EUVat')) { |
|
| 132 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
| 136 | - if ( !empty( $gateways ) ) { |
|
| 137 | - foreach ( $gateways as $gateway ) { |
|
| 138 | - if ( $gateway == 'manual' ) { |
|
| 135 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
| 136 | + if (!empty($gateways)) { |
|
| 137 | + foreach ($gateways as $gateway) { |
|
| 138 | + if ($gateway == 'manual') { |
|
| 139 | 139 | continue; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
| 143 | 143 | |
| 144 | - if ( file_exists( $gateway_file ) ) { |
|
| 145 | - require_once( $gateway_file ); |
|
| 144 | + if (file_exists($gateway_file)) { |
|
| 145 | + require_once($gateway_file); |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
| 149 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
| 150 | 150 | |
| 151 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 152 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 153 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 154 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
| 151 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 152 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
| 153 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
| 154 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
| 155 | 155 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
| 156 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
| 157 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
| 158 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 159 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
| 160 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 156 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
| 157 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
| 158 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
| 159 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
| 160 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
| 161 | 161 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // include css inliner |
| 165 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
| 166 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
| 165 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
| 166 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 169 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | public function init() { |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | public function admin_init() { |
| 176 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
| 176 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
| 179 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public function activation_redirect() { |
| 183 | 183 | // Bail if no activation redirect |
| 184 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
| 184 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
| 185 | 185 | return; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Delete the redirect transient |
| 189 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 189 | + delete_transient('_wpinv_activation_redirect'); |
|
| 190 | 190 | |
| 191 | 191 | // Bail if activating from network, or bulk |
| 192 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 192 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 193 | 193 | return; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 196 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
| 197 | 197 | exit; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | public function enqueue_scripts() { |
| 201 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 201 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 202 | 202 | |
| 203 | - wp_deregister_style( 'font-awesome' ); |
|
| 204 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
| 205 | - wp_enqueue_style( 'font-awesome' ); |
|
| 203 | + wp_deregister_style('font-awesome'); |
|
| 204 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
| 205 | + wp_enqueue_style('font-awesome'); |
|
| 206 | 206 | |
| 207 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
| 208 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 207 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
| 208 | + wp_enqueue_style('wpinv_front_style'); |
|
| 209 | 209 | |
| 210 | 210 | // Register scripts |
| 211 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 212 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ), WPINV_VERSION ); |
|
| 211 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 212 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION); |
|
| 213 | 213 | |
| 214 | 214 | $localize = array(); |
| 215 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 216 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 215 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 216 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 217 | 217 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
| 218 | 218 | $localize['currency_pos'] = wpinv_currency_position(); |
| 219 | 219 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 220 | 220 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 221 | 221 | $localize['decimals'] = wpinv_decimals(); |
| 222 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
| 222 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
| 223 | 223 | |
| 224 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 224 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
| 225 | 225 | |
| 226 | - wp_enqueue_script( 'jquery-blockui' ); |
|
| 226 | + wp_enqueue_script('jquery-blockui'); |
|
| 227 | 227 | $autofill_api = wpinv_get_option('address_autofill_api'); |
| 228 | 228 | $autofill_active = wpinv_get_option('address_autofill_active'); |
| 229 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
| 230 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
| 231 | - wp_dequeue_script( 'google-maps-api' ); |
|
| 229 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
| 230 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
| 231 | + wp_dequeue_script('google-maps-api'); |
|
| 232 | 232 | } |
| 233 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
| 234 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
| 233 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
| 234 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
| 235 | 235 | } |
| 236 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
| 237 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 236 | + wp_enqueue_script('wpinv-front-script'); |
|
| 237 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | public function admin_enqueue_scripts() { |
| 241 | 241 | global $post, $pagenow; |
| 242 | 242 | |
| 243 | 243 | $post_type = wpinv_admin_post_type(); |
| 244 | - $suffix = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 245 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
| 244 | + $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 245 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
| 246 | 246 | |
| 247 | - wp_deregister_style( 'font-awesome' ); |
|
| 248 | - wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' ); |
|
| 249 | - wp_enqueue_style( 'font-awesome' ); |
|
| 247 | + wp_deregister_style('font-awesome'); |
|
| 248 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0'); |
|
| 249 | + wp_enqueue_style('font-awesome'); |
|
| 250 | 250 | |
| 251 | 251 | $jquery_ui_css = false; |
| 252 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
| 252 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
| 253 | 253 | $jquery_ui_css = true; |
| 254 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
| 254 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
| 255 | 255 | $jquery_ui_css = true; |
| 256 | 256 | } |
| 257 | - if ( $jquery_ui_css ) { |
|
| 258 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
| 259 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
| 257 | + if ($jquery_ui_css) { |
|
| 258 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
| 259 | + wp_enqueue_style('jquery-ui-css'); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
| 263 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
| 262 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
| 263 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
| 264 | 264 | |
| 265 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
| 266 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
| 265 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
| 266 | + wp_enqueue_style('wpinv_admin_style'); |
|
| 267 | 267 | |
| 268 | - if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
| 269 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 268 | + if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
| 269 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 273 | - wp_enqueue_script( 'wp-color-picker' ); |
|
| 272 | + wp_enqueue_style('wp-color-picker'); |
|
| 273 | + wp_enqueue_script('wp-color-picker'); |
|
| 274 | 274 | |
| 275 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 275 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 276 | 276 | |
| 277 | 277 | if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
| 278 | 278 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -283,17 +283,17 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
| 287 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
| 286 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
| 287 | + wp_enqueue_script('wpinv-admin-script'); |
|
| 288 | 288 | |
| 289 | 289 | $localize = array(); |
| 290 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 291 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
| 292 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 293 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
| 294 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
| 295 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
| 296 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
| 290 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 291 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
| 292 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 293 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
| 294 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
| 295 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
| 296 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
| 297 | 297 | $localize['tax'] = wpinv_tax_amount(); |
| 298 | 298 | $localize['discount'] = wpinv_discount_amount(); |
| 299 | 299 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -301,60 +301,60 @@ discard block |
||
| 301 | 301 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
| 302 | 302 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
| 303 | 303 | $localize['decimals'] = wpinv_decimals(); |
| 304 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
| 305 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
| 306 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
| 307 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
| 308 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
| 309 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
| 310 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
| 311 | - $localize['confirmCalcTotals'] = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ); |
|
| 312 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
| 313 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
| 304 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
| 305 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
| 306 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
| 307 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
| 308 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
| 309 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
| 310 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
| 311 | + $localize['confirmCalcTotals'] = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'); |
|
| 312 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
| 313 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
| 314 | 314 | |
| 315 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
| 315 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
| 316 | 316 | |
| 317 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
| 317 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - public function admin_body_class( $classes ) { |
|
| 320 | + public function admin_body_class($classes) { |
|
| 321 | 321 | global $pagenow, $post, $current_screen; |
| 322 | 322 | |
| 323 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
| 323 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
| 324 | 324 | $classes .= ' wpinv-cpt'; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
| 327 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
| 328 | 328 | |
| 329 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
| 330 | - if ( $add_class ) { |
|
| 331 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
| 329 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
| 330 | + if ($add_class) { |
|
| 331 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | $settings_class = array(); |
| 335 | - if ( $page == 'wpinv-settings' ) { |
|
| 336 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
| 337 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
| 335 | + if ($page == 'wpinv-settings') { |
|
| 336 | + if (!empty($_REQUEST['tab'])) { |
|
| 337 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
| 341 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
| 340 | + if (!empty($_REQUEST['section'])) { |
|
| 341 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
| 342 | 342 | } |
| 343 | 343 | |
| 344 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
| 344 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - if ( !empty( $settings_class ) ) { |
|
| 348 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
| 347 | + if (!empty($settings_class)) { |
|
| 348 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | $post_type = wpinv_admin_post_type(); |
| 352 | 352 | |
| 353 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
| 353 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
| 354 | 354 | return $classes .= ' wpinv'; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
| 357 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
| 358 | 358 | $classes .= ' wpi-editable-n'; |
| 359 | 359 | } |
| 360 | 360 | |
@@ -366,20 +366,20 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | public function wpinv_actions() { |
| 369 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 370 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 369 | + if (isset($_REQUEST['wpi_action'])) { |
|
| 370 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - public function pre_get_posts( $wp_query ) { |
|
| 375 | - if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
| 376 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
| 374 | + public function pre_get_posts($wp_query) { |
|
| 375 | + if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
| 376 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | return $wp_query; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | public function bp_invoicing_init() { |
| 383 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 383 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | \ No newline at end of file |