@@ -14,70 +14,70 @@ discard block |
||
| 14 | 14 | class GetPaid_Admin { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Local path to this plugins admin directory |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - public $admin_path; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Web path to this plugins admin directory |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - public $admin_url; |
|
| 17 | + * Local path to this plugins admin directory |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + public $admin_path; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Web path to this plugins admin directory |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + public $admin_url; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Reports components. |
|
| 32 | - * |
|
| 33 | - * @var GetPaid_Reports |
|
| 34 | - */ |
|
| 30 | + /** |
|
| 31 | + * Reports components. |
|
| 32 | + * |
|
| 33 | + * @var GetPaid_Reports |
|
| 34 | + */ |
|
| 35 | 35 | public $reports; |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Class constructor. |
|
| 39 | - */ |
|
| 40 | - public function __construct(){ |
|
| 38 | + * Class constructor. |
|
| 39 | + */ |
|
| 40 | + public function __construct(){ |
|
| 41 | 41 | |
| 42 | 42 | $this->admin_path = plugin_dir_path( __FILE__ ); |
| 43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
| 44 | - $this->reports = new GetPaid_Reports(); |
|
| 43 | + $this->admin_url = plugins_url( '/', __FILE__ ); |
|
| 44 | + $this->reports = new GetPaid_Reports(); |
|
| 45 | 45 | |
| 46 | 46 | if ( is_admin() ) { |
| 47 | - $this->init_admin_hooks(); |
|
| 47 | + $this->init_admin_hooks(); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Init action and filter hooks |
|
| 54 | - * |
|
| 55 | - */ |
|
| 56 | - private function init_admin_hooks() { |
|
| 53 | + * Init action and filter hooks |
|
| 54 | + * |
|
| 55 | + */ |
|
| 56 | + private function init_admin_hooks() { |
|
| 57 | 57 | add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
| 58 | 58 | add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
| 59 | 59 | add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
| 60 | 60 | add_action( 'admin_init', array( $this, 'activation_redirect') ); |
| 61 | 61 | add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
| 62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 63 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
| 64 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
| 65 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
| 62 | + add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 63 | + add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
| 64 | + add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
| 65 | + do_action( 'getpaid_init_admin_hooks', $this ); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | - * Register admin scripts |
|
| 71 | - * |
|
| 72 | - */ |
|
| 73 | - public function enqeue_scripts() { |
|
| 70 | + * Register admin scripts |
|
| 71 | + * |
|
| 72 | + */ |
|
| 73 | + public function enqeue_scripts() { |
|
| 74 | 74 | global $current_screen, $pagenow; |
| 75 | 75 | |
| 76 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 77 | - $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
| 76 | + $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 77 | + $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
|
| 78 | 78 | |
| 79 | 79 | if ( ! empty( $current_screen->post_type ) ) { |
| 80 | - $page = $current_screen->post_type; |
|
| 80 | + $page = $current_screen->post_type; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // General styles. |
@@ -101,26 +101,26 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Payment form scripts. |
| 104 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
| 104 | + if ( 'wpi_payment_form' == $page && $editing ) { |
|
| 105 | 105 | $this->load_payment_form_scripts(); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | if ( $page == 'wpinv-subscriptions' ) { |
| 109 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 110 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 111 | - } |
|
| 109 | + wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 110 | + wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 114 | - wp_enqueue_script( 'postbox' ); |
|
| 115 | - } |
|
| 113 | + if ( $page == 'wpinv-subscriptions' ) { |
|
| 114 | + wp_enqueue_script( 'postbox' ); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | - * Returns admin js translations. |
|
| 121 | - * |
|
| 122 | - */ |
|
| 123 | - protected function get_admin_i18() { |
|
| 120 | + * Returns admin js translations. |
|
| 121 | + * |
|
| 122 | + */ |
|
| 123 | + protected function get_admin_i18() { |
|
| 124 | 124 | global $post; |
| 125 | 125 | |
| 126 | 126 | $i18n = array( |
@@ -156,50 +156,50 @@ discard block |
||
| 156 | 156 | 'searching' => __( 'Searching', 'invoicing' ), |
| 157 | 157 | ); |
| 158 | 158 | |
| 159 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 159 | + if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 160 | 160 | |
| 161 | - $invoice = new WPInv_Invoice( $post ); |
|
| 162 | - $i18n['save_invoice'] = sprintf( |
|
| 163 | - __( 'Save %s', 'invoicing' ), |
|
| 164 | - ucfirst( $invoice->get_type() ) |
|
| 165 | - ); |
|
| 161 | + $invoice = new WPInv_Invoice( $post ); |
|
| 162 | + $i18n['save_invoice'] = sprintf( |
|
| 163 | + __( 'Save %s', 'invoicing' ), |
|
| 164 | + ucfirst( $invoice->get_type() ) |
|
| 165 | + ); |
|
| 166 | 166 | |
| 167 | - $i18n['invoice_description'] = sprintf( |
|
| 168 | - __( '%s Description', 'invoicing' ), |
|
| 169 | - ucfirst( $invoice->get_type() ) |
|
| 170 | - ); |
|
| 167 | + $i18n['invoice_description'] = sprintf( |
|
| 168 | + __( '%s Description', 'invoicing' ), |
|
| 169 | + ucfirst( $invoice->get_type() ) |
|
| 170 | + ); |
|
| 171 | 171 | |
| 172 | - } |
|
| 173 | - return $i18n; |
|
| 172 | + } |
|
| 173 | + return $i18n; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Loads payment form js. |
|
| 178 | - * |
|
| 179 | - */ |
|
| 180 | - protected function load_payment_form_scripts() { |
|
| 177 | + * Loads payment form js. |
|
| 178 | + * |
|
| 179 | + */ |
|
| 180 | + protected function load_payment_form_scripts() { |
|
| 181 | 181 | global $post; |
| 182 | 182 | |
| 183 | 183 | wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
| 184 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 185 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 184 | + wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 185 | + wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 186 | 186 | |
| 187 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 188 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 187 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 188 | + wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 189 | 189 | |
| 190 | - wp_localize_script( |
|
| 190 | + wp_localize_script( |
|
| 191 | 191 | 'wpinv-admin-payment-form-script', |
| 192 | 192 | 'wpinvPaymentFormAdmin', |
| 193 | 193 | array( |
| 194 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
| 195 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
| 196 | - 'currency' => wpinv_currency_symbol(), |
|
| 197 | - 'position' => wpinv_currency_position(), |
|
| 198 | - 'decimals' => (int) wpinv_decimals(), |
|
| 199 | - 'thousands_sep' => wpinv_thousands_separator(), |
|
| 200 | - 'decimals_sep' => wpinv_decimal_separator(), |
|
| 201 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
| 202 | - 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
| 194 | + 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
| 195 | + 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
| 196 | + 'currency' => wpinv_currency_symbol(), |
|
| 197 | + 'position' => wpinv_currency_position(), |
|
| 198 | + 'decimals' => (int) wpinv_decimals(), |
|
| 199 | + 'thousands_sep' => wpinv_thousands_separator(), |
|
| 200 | + 'decimals_sep' => wpinv_decimal_separator(), |
|
| 201 | + 'form_items' => gepaid_get_form_items( $post->ID ), |
|
| 202 | + 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
|
| 203 | 203 | ) |
| 204 | 204 | ); |
| 205 | 205 | |
@@ -208,20 +208,20 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
| 211 | - * Add our classes to admin pages. |
|
| 211 | + * Add our classes to admin pages. |
|
| 212 | 212 | * |
| 213 | 213 | * @param string $classes |
| 214 | 214 | * @return string |
| 215 | - * |
|
| 216 | - */ |
|
| 215 | + * |
|
| 216 | + */ |
|
| 217 | 217 | public function admin_body_class( $classes ) { |
| 218 | - global $pagenow, $post, $current_screen; |
|
| 218 | + global $pagenow, $post, $current_screen; |
|
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
| 222 | 222 | |
| 223 | 223 | if ( ! empty( $current_screen->post_type ) ) { |
| 224 | - $page = $current_screen->post_type; |
|
| 224 | + $page = $current_screen->post_type; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | if ( false !== stripos( $page, 'wpi' ) ) { |
@@ -230,29 +230,29 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
| 232 | 232 | $classes .= ' wpinv-cpt wpinv'; |
| 233 | - } |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
| 235 | + if ( getpaid_is_invoice_post_type( $page ) ) { |
|
| 236 | 236 | $classes .= ' getpaid-is-invoice-cpt'; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - return $classes; |
|
| 239 | + return $classes; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
| 243 | - * Maybe show the AyeCode Connect Notice. |
|
| 244 | - */ |
|
| 245 | - public function init_ayecode_connect_helper(){ |
|
| 243 | + * Maybe show the AyeCode Connect Notice. |
|
| 244 | + */ |
|
| 245 | + public function init_ayecode_connect_helper(){ |
|
| 246 | 246 | |
| 247 | 247 | new AyeCode_Connect_Helper( |
| 248 | 248 | array( |
| 249 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 250 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 251 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 252 | - 'connect_button' => __("Connect Site","invoicing"), |
|
| 253 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
| 254 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 255 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 249 | + 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 250 | + 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 251 | + 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 252 | + 'connect_button' => __("Connect Site","invoicing"), |
|
| 253 | + 'connecting_button' => __("Connecting...","invoicing"), |
|
| 254 | + 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 255 | + 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 256 | 256 | ), |
| 257 | 257 | array( 'wpi-addons' ) |
| 258 | 258 | ); |
@@ -264,21 +264,21 @@ discard block |
||
| 264 | 264 | */ |
| 265 | 265 | public function activation_redirect() { |
| 266 | 266 | |
| 267 | - // Bail if no activation redirect. |
|
| 268 | - if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
| 269 | - return; |
|
| 270 | - } |
|
| 267 | + // Bail if no activation redirect. |
|
| 268 | + if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
| 269 | + return; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - // Delete the redirect transient. |
|
| 273 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 272 | + // Delete the redirect transient. |
|
| 273 | + delete_transient( '_wpinv_activation_redirect' ); |
|
| 274 | 274 | |
| 275 | - // Bail if activating from network, or bulk |
|
| 276 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 277 | - return; |
|
| 278 | - } |
|
| 275 | + // Bail if activating from network, or bulk |
|
| 276 | + if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 277 | + return; |
|
| 278 | + } |
|
| 279 | 279 | |
| 280 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 281 | - exit; |
|
| 280 | + wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 281 | + exit; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -293,150 +293,150 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - /** |
|
| 296 | + /** |
|
| 297 | 297 | * Sends a payment reminder to a customer. |
| 298 | - * |
|
| 299 | - * @param array $args |
|
| 298 | + * |
|
| 299 | + * @param array $args |
|
| 300 | 300 | */ |
| 301 | 301 | public function send_customer_invoice( $args ) { |
| 302 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 302 | + $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 303 | 303 | |
| 304 | - if ( $sent ) { |
|
| 305 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 306 | - } else { |
|
| 307 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
| 308 | - } |
|
| 304 | + if ( $sent ) { |
|
| 305 | + $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 306 | + } else { |
|
| 307 | + $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 311 | - exit; |
|
| 312 | - } |
|
| 310 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 311 | + exit; |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - /** |
|
| 314 | + /** |
|
| 315 | 315 | * Sends a payment reminder to a customer. |
| 316 | - * |
|
| 317 | - * @param array $args |
|
| 316 | + * |
|
| 317 | + * @param array $args |
|
| 318 | 318 | */ |
| 319 | 319 | public function send_customer_payment_reminder( $args ) { |
| 320 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 320 | + $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 321 | 321 | |
| 322 | - if ( $sent ) { |
|
| 323 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
| 324 | - } else { |
|
| 325 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
| 326 | - } |
|
| 322 | + if ( $sent ) { |
|
| 323 | + $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
| 324 | + } else { |
|
| 325 | + $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 329 | - exit; |
|
| 330 | - } |
|
| 328 | + wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 329 | + exit; |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | 332 | /** |
| 333 | - * Returns an array of admin notices. |
|
| 334 | - * |
|
| 335 | - * @since 1.0.19 |
|
| 333 | + * Returns an array of admin notices. |
|
| 334 | + * |
|
| 335 | + * @since 1.0.19 |
|
| 336 | 336 | * @return array |
| 337 | - */ |
|
| 338 | - public function get_notices() { |
|
| 339 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
| 337 | + */ |
|
| 338 | + public function get_notices() { |
|
| 339 | + $notices = get_option( 'wpinv_admin_notices' ); |
|
| 340 | 340 | return is_array( $notices ) ? $notices : array(); |
| 341 | - } |
|
| 342 | - |
|
| 343 | - /** |
|
| 344 | - * Clears all admin notices |
|
| 345 | - * |
|
| 346 | - * @access public |
|
| 347 | - * @since 1.0.19 |
|
| 348 | - */ |
|
| 349 | - public function clear_notices() { |
|
| 350 | - delete_option( 'wpinv_admin_notices' ); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * Saves a new admin notice |
|
| 355 | - * |
|
| 356 | - * @access public |
|
| 357 | - * @since 1.0.19 |
|
| 358 | - */ |
|
| 359 | - public function save_notice( $type, $message ) { |
|
| 360 | - $notices = $this->get_notices(); |
|
| 361 | - |
|
| 362 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
| 363 | - $notices[ $type ] = array(); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - $notices[ $type ][] = $message; |
|
| 367 | - |
|
| 368 | - update_option( 'wpinv_admin_notices', $notices ); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * Displays a success notice |
|
| 373 | - * |
|
| 374 | - * @param string $msg The message to qeue. |
|
| 375 | - * @access public |
|
| 376 | - * @since 1.0.19 |
|
| 377 | - */ |
|
| 378 | - public function show_success( $msg ) { |
|
| 379 | - $this->save_notice( 'success', $msg ); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * Displays a error notice |
|
| 384 | - * |
|
| 385 | - * @access public |
|
| 386 | - * @param string $msg The message to qeue. |
|
| 387 | - * @since 1.0.19 |
|
| 388 | - */ |
|
| 389 | - public function show_error( $msg ) { |
|
| 390 | - $this->save_notice( 'error', $msg ); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * Displays a warning notice |
|
| 395 | - * |
|
| 396 | - * @access public |
|
| 397 | - * @param string $msg The message to qeue. |
|
| 398 | - * @since 1.0.19 |
|
| 399 | - */ |
|
| 400 | - public function show_warning( $msg ) { |
|
| 401 | - $this->save_notice( 'warning', $msg ); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - /** |
|
| 405 | - * Displays a info notice |
|
| 406 | - * |
|
| 407 | - * @access public |
|
| 408 | - * @param string $msg The message to qeue. |
|
| 409 | - * @since 1.0.19 |
|
| 410 | - */ |
|
| 411 | - public function show_info( $msg ) { |
|
| 412 | - $this->save_notice( 'info', $msg ); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * Show notices |
|
| 417 | - * |
|
| 418 | - * @access public |
|
| 419 | - * @since 1.0.19 |
|
| 420 | - */ |
|
| 421 | - public function show_notices() { |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + /** |
|
| 344 | + * Clears all admin notices |
|
| 345 | + * |
|
| 346 | + * @access public |
|
| 347 | + * @since 1.0.19 |
|
| 348 | + */ |
|
| 349 | + public function clear_notices() { |
|
| 350 | + delete_option( 'wpinv_admin_notices' ); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * Saves a new admin notice |
|
| 355 | + * |
|
| 356 | + * @access public |
|
| 357 | + * @since 1.0.19 |
|
| 358 | + */ |
|
| 359 | + public function save_notice( $type, $message ) { |
|
| 360 | + $notices = $this->get_notices(); |
|
| 361 | + |
|
| 362 | + if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
| 363 | + $notices[ $type ] = array(); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + $notices[ $type ][] = $message; |
|
| 367 | + |
|
| 368 | + update_option( 'wpinv_admin_notices', $notices ); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * Displays a success notice |
|
| 373 | + * |
|
| 374 | + * @param string $msg The message to qeue. |
|
| 375 | + * @access public |
|
| 376 | + * @since 1.0.19 |
|
| 377 | + */ |
|
| 378 | + public function show_success( $msg ) { |
|
| 379 | + $this->save_notice( 'success', $msg ); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * Displays a error notice |
|
| 384 | + * |
|
| 385 | + * @access public |
|
| 386 | + * @param string $msg The message to qeue. |
|
| 387 | + * @since 1.0.19 |
|
| 388 | + */ |
|
| 389 | + public function show_error( $msg ) { |
|
| 390 | + $this->save_notice( 'error', $msg ); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * Displays a warning notice |
|
| 395 | + * |
|
| 396 | + * @access public |
|
| 397 | + * @param string $msg The message to qeue. |
|
| 398 | + * @since 1.0.19 |
|
| 399 | + */ |
|
| 400 | + public function show_warning( $msg ) { |
|
| 401 | + $this->save_notice( 'warning', $msg ); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + /** |
|
| 405 | + * Displays a info notice |
|
| 406 | + * |
|
| 407 | + * @access public |
|
| 408 | + * @param string $msg The message to qeue. |
|
| 409 | + * @since 1.0.19 |
|
| 410 | + */ |
|
| 411 | + public function show_info( $msg ) { |
|
| 412 | + $this->save_notice( 'info', $msg ); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * Show notices |
|
| 417 | + * |
|
| 418 | + * @access public |
|
| 419 | + * @since 1.0.19 |
|
| 420 | + */ |
|
| 421 | + public function show_notices() { |
|
| 422 | 422 | |
| 423 | 423 | $notices = $this->get_notices(); |
| 424 | 424 | $this->clear_notices(); |
| 425 | 425 | |
| 426 | - foreach ( $notices as $type => $messages ) { |
|
| 426 | + foreach ( $notices as $type => $messages ) { |
|
| 427 | 427 | |
| 428 | - if ( ! is_array( $messages ) ) { |
|
| 429 | - continue; |
|
| 430 | - } |
|
| 428 | + if ( ! is_array( $messages ) ) { |
|
| 429 | + continue; |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | 432 | $type = sanitize_key( $type ); |
| 433 | - foreach ( $messages as $message ) { |
|
| 433 | + foreach ( $messages as $message ) { |
|
| 434 | 434 | $message = wp_kses_post( $message ); |
| 435 | - echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
| 435 | + echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - } |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | 442 | } |
@@ -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 | * The main admin class. |
@@ -37,13 +37,13 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Class constructor. |
| 39 | 39 | */ |
| 40 | - public function __construct(){ |
|
| 40 | + public function __construct() { |
|
| 41 | 41 | |
| 42 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
| 43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
| 42 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
| 43 | + $this->admin_url = plugins_url('/', __FILE__); |
|
| 44 | 44 | $this->reports = new GetPaid_Reports(); |
| 45 | 45 | |
| 46 | - if ( is_admin() ) { |
|
| 46 | + if (is_admin()) { |
|
| 47 | 47 | $this->init_admin_hooks(); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -54,15 +54,15 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | */ |
| 56 | 56 | private function init_admin_hooks() { |
| 57 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) ); |
|
| 58 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
| 59 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
| 60 | - add_action( 'admin_init', array( $this, 'activation_redirect') ); |
|
| 61 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action') ); |
|
| 62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
| 63 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
| 64 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
| 65 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
| 57 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts')); |
|
| 58 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
| 59 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
| 60 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
| 61 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
| 62 | + add_action('admin_notices', array($this, 'show_notices')); |
|
| 63 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
| 64 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
| 65 | + do_action('getpaid_init_admin_hooks', $this); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
@@ -73,45 +73,45 @@ discard block |
||
| 73 | 73 | public function enqeue_scripts() { |
| 74 | 74 | global $current_screen, $pagenow; |
| 75 | 75 | |
| 76 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 76 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
| 77 | 77 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
| 78 | 78 | |
| 79 | - if ( ! empty( $current_screen->post_type ) ) { |
|
| 79 | + if (!empty($current_screen->post_type)) { |
|
| 80 | 80 | $page = $current_screen->post_type; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // General styles. |
| 84 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
| 84 | + if (false !== stripos($page, 'wpi')) { |
|
| 85 | 85 | |
| 86 | 86 | // Styles. |
| 87 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
| 88 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
| 89 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
| 90 | - wp_enqueue_style( 'wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
| 91 | - wp_enqueue_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16' ); |
|
| 87 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
| 88 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
| 89 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
| 90 | + wp_enqueue_style('wp_enqueue_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
| 91 | + wp_enqueue_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.8.16'); |
|
| 92 | 92 | |
| 93 | 93 | // Scripts. |
| 94 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '4.0.13', true ); |
|
| 95 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 94 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '4.0.13', true); |
|
| 95 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
| 96 | 96 | |
| 97 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
| 98 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker' ), $version ); |
|
| 99 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
| 97 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
| 98 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip', 'wp-color-picker', 'jquery-ui-datepicker'), $version); |
|
| 99 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
| 100 | 100 | |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Payment form scripts. |
| 104 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
| 104 | + if ('wpi_payment_form' == $page && $editing) { |
|
| 105 | 105 | $this->load_payment_form_scripts(); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 109 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
| 110 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
| 108 | + if ($page == 'wpinv-subscriptions') { |
|
| 109 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
| 110 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ( $page == 'wpinv-subscriptions' ) { |
|
| 114 | - wp_enqueue_script( 'postbox' ); |
|
| 113 | + if ($page == 'wpinv-subscriptions') { |
|
| 114 | + wp_enqueue_script('postbox'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | } |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | global $post; |
| 125 | 125 | |
| 126 | 126 | $i18n = array( |
| 127 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 128 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
| 129 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
| 130 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
| 131 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
| 132 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
| 133 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
| 127 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 128 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
| 129 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
| 130 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
| 131 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
| 132 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
| 133 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
| 134 | 134 | 'tax' => wpinv_tax_amount(), |
| 135 | 135 | 'discount' => 0, |
| 136 | 136 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -138,35 +138,35 @@ discard block |
||
| 138 | 138 | 'thousand_sep' => wpinv_thousands_separator(), |
| 139 | 139 | 'decimal_sep' => wpinv_decimal_separator(), |
| 140 | 140 | 'decimals' => wpinv_decimals(), |
| 141 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
| 142 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
| 143 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
| 144 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
| 145 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
| 146 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
| 147 | - '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' ), |
|
| 148 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
| 149 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
| 150 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
| 151 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
| 152 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
| 153 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
| 154 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
| 155 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
| 156 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
| 141 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
| 142 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
| 143 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
| 144 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
| 145 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
| 146 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
| 147 | + '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'), |
|
| 148 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
| 149 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
| 150 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
| 151 | + 'action_edit' => __('Edit', 'invoicing'), |
|
| 152 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
| 153 | + 'item_description' => __('Item Description', 'invoicing'), |
|
| 154 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
| 155 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
| 156 | + 'searching' => __('Searching', 'invoicing'), |
|
| 157 | 157 | ); |
| 158 | 158 | |
| 159 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 159 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
| 160 | 160 | |
| 161 | - $invoice = new WPInv_Invoice( $post ); |
|
| 161 | + $invoice = new WPInv_Invoice($post); |
|
| 162 | 162 | $i18n['save_invoice'] = sprintf( |
| 163 | - __( 'Save %s', 'invoicing' ), |
|
| 164 | - ucfirst( $invoice->get_type() ) |
|
| 163 | + __('Save %s', 'invoicing'), |
|
| 164 | + ucfirst($invoice->get_type()) |
|
| 165 | 165 | ); |
| 166 | 166 | |
| 167 | 167 | $i18n['invoice_description'] = sprintf( |
| 168 | - __( '%s Description', 'invoicing' ), |
|
| 169 | - ucfirst( $invoice->get_type() ) |
|
| 168 | + __('%s Description', 'invoicing'), |
|
| 169 | + ucfirst($invoice->get_type()) |
|
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | 172 | } |
@@ -180,30 +180,30 @@ discard block |
||
| 180 | 180 | protected function load_payment_form_scripts() { |
| 181 | 181 | global $post; |
| 182 | 182 | |
| 183 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION ); |
|
| 184 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
| 185 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
| 183 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION); |
|
| 184 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
| 185 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
| 186 | 186 | |
| 187 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' ); |
|
| 188 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ), $version ); |
|
| 187 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js'); |
|
| 188 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version); |
|
| 189 | 189 | |
| 190 | 190 | wp_localize_script( |
| 191 | 191 | 'wpinv-admin-payment-form-script', |
| 192 | 192 | 'wpinvPaymentFormAdmin', |
| 193 | 193 | array( |
| 194 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
| 195 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
| 194 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
| 195 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
| 196 | 196 | 'currency' => wpinv_currency_symbol(), |
| 197 | 197 | 'position' => wpinv_currency_position(), |
| 198 | 198 | 'decimals' => (int) wpinv_decimals(), |
| 199 | 199 | 'thousands_sep' => wpinv_thousands_separator(), |
| 200 | 200 | 'decimals_sep' => wpinv_decimal_separator(), |
| 201 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
| 201 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
| 202 | 202 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
| 203 | 203 | ) |
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
| 206 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
| 207 | 207 | |
| 208 | 208 | } |
| 209 | 209 | |
@@ -214,25 +214,25 @@ discard block |
||
| 214 | 214 | * @return string |
| 215 | 215 | * |
| 216 | 216 | */ |
| 217 | - public function admin_body_class( $classes ) { |
|
| 217 | + public function admin_body_class($classes) { |
|
| 218 | 218 | global $pagenow, $post, $current_screen; |
| 219 | 219 | |
| 220 | 220 | |
| 221 | - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; |
|
| 221 | + $page = isset($_GET['page']) ? $_GET['page'] : ''; |
|
| 222 | 222 | |
| 223 | - if ( ! empty( $current_screen->post_type ) ) { |
|
| 223 | + if (!empty($current_screen->post_type)) { |
|
| 224 | 224 | $page = $current_screen->post_type; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
| 228 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
| 227 | + if (false !== stripos($page, 'wpi')) { |
|
| 228 | + $classes .= ' wpi-' . sanitize_key($page); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
| 231 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
| 232 | 232 | $classes .= ' wpinv-cpt wpinv'; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
| 235 | + if (getpaid_is_invoice_post_type($page)) { |
|
| 236 | 236 | $classes .= ' getpaid-is-invoice-cpt'; |
| 237 | 237 | } |
| 238 | 238 | |
@@ -242,19 +242,19 @@ discard block |
||
| 242 | 242 | /** |
| 243 | 243 | * Maybe show the AyeCode Connect Notice. |
| 244 | 244 | */ |
| 245 | - public function init_ayecode_connect_helper(){ |
|
| 245 | + public function init_ayecode_connect_helper() { |
|
| 246 | 246 | |
| 247 | 247 | new AyeCode_Connect_Helper( |
| 248 | 248 | array( |
| 249 | - 'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"), |
|
| 250 | - 'connect_external' => __( "Please confirm you wish to connect your site?","invoicing" ), |
|
| 251 | - 'connect' => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ), |
|
| 252 | - 'connect_button' => __("Connect Site","invoicing"), |
|
| 253 | - 'connecting_button' => __("Connecting...","invoicing"), |
|
| 254 | - 'error_localhost' => __( "This service will only work with a live domain, not a localhost.","invoicing" ), |
|
| 255 | - 'error' => __( "Something went wrong, please refresh and try again.","invoicing" ), |
|
| 249 | + 'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"), |
|
| 250 | + 'connect_external' => __("Please confirm you wish to connect your site?", "invoicing"), |
|
| 251 | + 'connect' => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"), |
|
| 252 | + 'connect_button' => __("Connect Site", "invoicing"), |
|
| 253 | + 'connecting_button' => __("Connecting...", "invoicing"), |
|
| 254 | + 'error_localhost' => __("This service will only work with a live domain, not a localhost.", "invoicing"), |
|
| 255 | + 'error' => __("Something went wrong, please refresh and try again.", "invoicing"), |
|
| 256 | 256 | ), |
| 257 | - array( 'wpi-addons' ) |
|
| 257 | + array('wpi-addons') |
|
| 258 | 258 | ); |
| 259 | 259 | |
| 260 | 260 | } |
@@ -265,19 +265,19 @@ discard block |
||
| 265 | 265 | public function activation_redirect() { |
| 266 | 266 | |
| 267 | 267 | // Bail if no activation redirect. |
| 268 | - if ( ! get_transient( '_wpinv_activation_redirect' ) || wp_doing_ajax() ) { |
|
| 268 | + if (!get_transient('_wpinv_activation_redirect') || wp_doing_ajax()) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // Delete the redirect transient. |
| 273 | - delete_transient( '_wpinv_activation_redirect' ); |
|
| 273 | + delete_transient('_wpinv_activation_redirect'); |
|
| 274 | 274 | |
| 275 | 275 | // Bail if activating from network, or bulk |
| 276 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 276 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
| 280 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
| 281 | 281 | exit; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | public function maybe_do_admin_action() { |
| 288 | 288 | |
| 289 | - if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
| 290 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
| 291 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
| 289 | + if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
| 290 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
| 291 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | } |
@@ -298,16 +298,16 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @param array $args |
| 300 | 300 | */ |
| 301 | - public function send_customer_invoice( $args ) { |
|
| 302 | - $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 301 | + public function send_customer_invoice($args) { |
|
| 302 | + $sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id'])); |
|
| 303 | 303 | |
| 304 | - if ( $sent ) { |
|
| 305 | - $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) ); |
|
| 304 | + if ($sent) { |
|
| 305 | + $this->show_success(__('Invoice was successfully sent to the customer', 'invoicing')); |
|
| 306 | 306 | } else { |
| 307 | - $this->show_error( __( 'Could not sent the invoice to the customer', 'invoicing' ) ); |
|
| 307 | + $this->show_error(__('Could not sent the invoice to the customer', 'invoicing')); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 310 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
| 311 | 311 | exit; |
| 312 | 312 | } |
| 313 | 313 | |
@@ -316,16 +316,16 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @param array $args |
| 318 | 318 | */ |
| 319 | - public function send_customer_payment_reminder( $args ) { |
|
| 320 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
| 319 | + public function send_customer_payment_reminder($args) { |
|
| 320 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
| 321 | 321 | |
| 322 | - if ( $sent ) { |
|
| 323 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
| 322 | + if ($sent) { |
|
| 323 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
| 324 | 324 | } else { |
| 325 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
| 325 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
| 328 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
| 329 | 329 | exit; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | * @return array |
| 337 | 337 | */ |
| 338 | 338 | public function get_notices() { |
| 339 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
| 340 | - return is_array( $notices ) ? $notices : array(); |
|
| 339 | + $notices = get_option('wpinv_admin_notices'); |
|
| 340 | + return is_array($notices) ? $notices : array(); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @since 1.0.19 |
| 348 | 348 | */ |
| 349 | 349 | public function clear_notices() { |
| 350 | - delete_option( 'wpinv_admin_notices' ); |
|
| 350 | + delete_option('wpinv_admin_notices'); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | * @access public |
| 357 | 357 | * @since 1.0.19 |
| 358 | 358 | */ |
| 359 | - public function save_notice( $type, $message ) { |
|
| 359 | + public function save_notice($type, $message) { |
|
| 360 | 360 | $notices = $this->get_notices(); |
| 361 | 361 | |
| 362 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) { |
|
| 363 | - $notices[ $type ] = array(); |
|
| 362 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
| 363 | + $notices[$type] = array(); |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - $notices[ $type ][] = $message; |
|
| 366 | + $notices[$type][] = $message; |
|
| 367 | 367 | |
| 368 | - update_option( 'wpinv_admin_notices', $notices ); |
|
| 368 | + update_option('wpinv_admin_notices', $notices); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -375,8 +375,8 @@ discard block |
||
| 375 | 375 | * @access public |
| 376 | 376 | * @since 1.0.19 |
| 377 | 377 | */ |
| 378 | - public function show_success( $msg ) { |
|
| 379 | - $this->save_notice( 'success', $msg ); |
|
| 378 | + public function show_success($msg) { |
|
| 379 | + $this->save_notice('success', $msg); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | * @param string $msg The message to qeue. |
| 387 | 387 | * @since 1.0.19 |
| 388 | 388 | */ |
| 389 | - public function show_error( $msg ) { |
|
| 390 | - $this->save_notice( 'error', $msg ); |
|
| 389 | + public function show_error($msg) { |
|
| 390 | + $this->save_notice('error', $msg); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
@@ -397,8 +397,8 @@ discard block |
||
| 397 | 397 | * @param string $msg The message to qeue. |
| 398 | 398 | * @since 1.0.19 |
| 399 | 399 | */ |
| 400 | - public function show_warning( $msg ) { |
|
| 401 | - $this->save_notice( 'warning', $msg ); |
|
| 400 | + public function show_warning($msg) { |
|
| 401 | + $this->save_notice('warning', $msg); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | * @param string $msg The message to qeue. |
| 409 | 409 | * @since 1.0.19 |
| 410 | 410 | */ |
| 411 | - public function show_info( $msg ) { |
|
| 412 | - $this->save_notice( 'info', $msg ); |
|
| 411 | + public function show_info($msg) { |
|
| 412 | + $this->save_notice('info', $msg); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
@@ -423,15 +423,15 @@ discard block |
||
| 423 | 423 | $notices = $this->get_notices(); |
| 424 | 424 | $this->clear_notices(); |
| 425 | 425 | |
| 426 | - foreach ( $notices as $type => $messages ) { |
|
| 426 | + foreach ($notices as $type => $messages) { |
|
| 427 | 427 | |
| 428 | - if ( ! is_array( $messages ) ) { |
|
| 428 | + if (!is_array($messages)) { |
|
| 429 | 429 | continue; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - $type = sanitize_key( $type ); |
|
| 433 | - foreach ( $messages as $message ) { |
|
| 434 | - $message = wp_kses_post( $message ); |
|
| 432 | + $type = sanitize_key($type); |
|
| 433 | + foreach ($messages as $message) { |
|
| 434 | + $message = wp_kses_post($message); |
|
| 435 | 435 | echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>"; |
| 436 | 436 | } |
| 437 | 437 | |
@@ -12,267 +12,267 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Metaboxes { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Only save metaboxes once. |
|
| 17 | - * |
|
| 18 | - * @var boolean |
|
| 19 | - */ |
|
| 20 | - private static $saved_meta_boxes = false; |
|
| 21 | - |
|
| 22 | 15 | /** |
| 23 | - * Hook in methods. |
|
| 24 | - */ |
|
| 25 | - public static function init() { |
|
| 26 | - |
|
| 27 | - // Register metaboxes. |
|
| 28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
| 29 | - |
|
| 30 | - // Remove metaboxes. |
|
| 31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
| 32 | - |
|
| 33 | - // Rename metaboxes. |
|
| 34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
| 35 | - |
|
| 36 | - // Save metaboxes. |
|
| 37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
| 38 | - } |
|
| 16 | + * Only save metaboxes once. |
|
| 17 | + * |
|
| 18 | + * @var boolean |
|
| 19 | + */ |
|
| 20 | + private static $saved_meta_boxes = false; |
|
| 39 | 21 | |
| 40 | - /** |
|
| 41 | - * Register core metaboxes. |
|
| 42 | - */ |
|
| 43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
| 44 | - |
|
| 45 | - // For invoices... |
|
| 46 | - self::add_invoice_meta_boxes( $post_type, $post ); |
|
| 22 | + /** |
|
| 23 | + * Hook in methods. |
|
| 24 | + */ |
|
| 25 | + public static function init() { |
|
| 47 | 26 | |
| 48 | - // For payment forms. |
|
| 49 | - self::add_payment_form_meta_boxes( $post_type ); |
|
| 27 | + // Register metaboxes. |
|
| 28 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
| 50 | 29 | |
| 51 | - // For invoice items. |
|
| 52 | - self::add_item_meta_boxes( $post_type ); |
|
| 30 | + // Remove metaboxes. |
|
| 31 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
| 53 | 32 | |
| 54 | - // For invoice discounts. |
|
| 55 | - if ( $post_type == 'wpi_discount' ) { |
|
| 56 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
| 57 | - } |
|
| 33 | + // Rename metaboxes. |
|
| 34 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
| 58 | 35 | |
| 59 | - } |
|
| 36 | + // Save metaboxes. |
|
| 37 | + add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
| 38 | + } |
|
| 60 | 39 | |
| 61 | - /** |
|
| 62 | - * Register core metaboxes. |
|
| 63 | - */ |
|
| 64 | - protected static function add_payment_form_meta_boxes( $post_type ) { |
|
| 40 | + /** |
|
| 41 | + * Register core metaboxes. |
|
| 42 | + */ |
|
| 43 | + public static function add_meta_boxes( $post_type, $post ) { |
|
| 65 | 44 | |
| 66 | - // For payment forms. |
|
| 67 | - if ( $post_type == 'wpi_payment_form' ) { |
|
| 45 | + // For invoices... |
|
| 46 | + self::add_invoice_meta_boxes( $post_type, $post ); |
|
| 68 | 47 | |
| 69 | - // Design payment form. |
|
| 70 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
| 48 | + // For payment forms. |
|
| 49 | + self::add_payment_form_meta_boxes( $post_type ); |
|
| 71 | 50 | |
| 72 | - // Payment form information. |
|
| 73 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
| 51 | + // For invoice items. |
|
| 52 | + self::add_item_meta_boxes( $post_type ); |
|
| 74 | 53 | |
| 75 | - } |
|
| 54 | + // For invoice discounts. |
|
| 55 | + if ( $post_type == 'wpi_discount' ) { |
|
| 56 | + add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
| 57 | + } |
|
| 76 | 58 | |
| 77 | - } |
|
| 59 | + } |
|
| 78 | 60 | |
| 79 | - /** |
|
| 80 | - * Register core metaboxes. |
|
| 81 | - */ |
|
| 82 | - protected static function add_item_meta_boxes( $post_type ) { |
|
| 61 | + /** |
|
| 62 | + * Register core metaboxes. |
|
| 63 | + */ |
|
| 64 | + protected static function add_payment_form_meta_boxes( $post_type ) { |
|
| 83 | 65 | |
| 84 | - if ( $post_type == 'wpi_item' ) { |
|
| 66 | + // For payment forms. |
|
| 67 | + if ( $post_type == 'wpi_payment_form' ) { |
|
| 85 | 68 | |
| 86 | - // Item details. |
|
| 87 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
| 69 | + // Design payment form. |
|
| 70 | + add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
| 88 | 71 | |
| 89 | - // If taxes are enabled, register the tax metabox. |
|
| 90 | - if ( getpaid_tax()->allow_vat_rules() || getpaid_tax()->allow_vat_classes() ) { |
|
| 91 | - add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
| 92 | - } |
|
| 72 | + // Payment form information. |
|
| 73 | + add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
| 93 | 74 | |
| 94 | - // Item info. |
|
| 95 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
| 75 | + } |
|
| 96 | 76 | |
| 97 | - } |
|
| 77 | + } |
|
| 98 | 78 | |
| 99 | - } |
|
| 79 | + /** |
|
| 80 | + * Register core metaboxes. |
|
| 81 | + */ |
|
| 82 | + protected static function add_item_meta_boxes( $post_type ) { |
|
| 100 | 83 | |
| 101 | - /** |
|
| 102 | - * Register invoice metaboxes. |
|
| 103 | - */ |
|
| 104 | - protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
| 84 | + if ( $post_type == 'wpi_item' ) { |
|
| 105 | 85 | |
| 106 | - // For invoices... |
|
| 107 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
| 108 | - $invoice = new WPInv_Invoice( $post ); |
|
| 86 | + // Item details. |
|
| 87 | + add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
| 109 | 88 | |
| 110 | - // Resend invoice. |
|
| 111 | - if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) { |
|
| 89 | + // If taxes are enabled, register the tax metabox. |
|
| 90 | + if ( getpaid_tax()->allow_vat_rules() || getpaid_tax()->allow_vat_classes() ) { |
|
| 91 | + add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
| 92 | + } |
|
| 112 | 93 | |
| 113 | - add_meta_box( |
|
| 114 | - 'wpinv-mb-resend-invoice', |
|
| 115 | - sprintf( |
|
| 116 | - __( 'Resend %s', 'invoicing' ), |
|
| 117 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 118 | - ), |
|
| 119 | - 'GetPaid_Meta_Box_Resend_Invoice::output', |
|
| 120 | - $post_type, |
|
| 121 | - 'side', |
|
| 122 | - 'low' |
|
| 123 | - ); |
|
| 94 | + // Item info. |
|
| 95 | + add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
| 124 | 96 | |
| 125 | - } |
|
| 97 | + } |
|
| 126 | 98 | |
| 127 | - // Subscriptions. |
|
| 128 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 129 | - if ( ! empty( $subscription ) ) { |
|
| 130 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
| 131 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // Invoice details. |
|
| 135 | - add_meta_box( |
|
| 136 | - 'wpinv-details', |
|
| 137 | - sprintf( |
|
| 138 | - __( '%s Details', 'invoicing' ), |
|
| 139 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 140 | - ), |
|
| 141 | - 'GetPaid_Meta_Box_Invoice_Details::output', |
|
| 142 | - $post_type, |
|
| 143 | - 'side' |
|
| 144 | - ); |
|
| 145 | - |
|
| 146 | - // Payment details. |
|
| 147 | - if ( ! $invoice->is_draft() ) { |
|
| 148 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
| 149 | - } |
|
| 99 | + } |
|
| 150 | 100 | |
| 151 | - // Billing details. |
|
| 152 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
| 101 | + /** |
|
| 102 | + * Register invoice metaboxes. |
|
| 103 | + */ |
|
| 104 | + protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
| 105 | + |
|
| 106 | + // For invoices... |
|
| 107 | + if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
| 108 | + $invoice = new WPInv_Invoice( $post ); |
|
| 109 | + |
|
| 110 | + // Resend invoice. |
|
| 111 | + if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) { |
|
| 112 | + |
|
| 113 | + add_meta_box( |
|
| 114 | + 'wpinv-mb-resend-invoice', |
|
| 115 | + sprintf( |
|
| 116 | + __( 'Resend %s', 'invoicing' ), |
|
| 117 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 118 | + ), |
|
| 119 | + 'GetPaid_Meta_Box_Resend_Invoice::output', |
|
| 120 | + $post_type, |
|
| 121 | + 'side', |
|
| 122 | + 'low' |
|
| 123 | + ); |
|
| 124 | + |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + // Subscriptions. |
|
| 128 | + $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 129 | + if ( ! empty( $subscription ) ) { |
|
| 130 | + add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
| 131 | + add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // Invoice details. |
|
| 135 | + add_meta_box( |
|
| 136 | + 'wpinv-details', |
|
| 137 | + sprintf( |
|
| 138 | + __( '%s Details', 'invoicing' ), |
|
| 139 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 140 | + ), |
|
| 141 | + 'GetPaid_Meta_Box_Invoice_Details::output', |
|
| 142 | + $post_type, |
|
| 143 | + 'side' |
|
| 144 | + ); |
|
| 145 | + |
|
| 146 | + // Payment details. |
|
| 147 | + if ( ! $invoice->is_draft() ) { |
|
| 148 | + add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + // Billing details. |
|
| 152 | + add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
| 153 | 153 | |
| 154 | - // Invoice items. |
|
| 155 | - add_meta_box( |
|
| 156 | - 'wpinv-items', |
|
| 157 | - sprintf( |
|
| 158 | - __( '%s Items', 'invoicing' ), |
|
| 159 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 160 | - ), |
|
| 161 | - 'GetPaid_Meta_Box_Invoice_Items::output', |
|
| 162 | - $post_type, |
|
| 163 | - 'normal', |
|
| 164 | - 'high' |
|
| 165 | - ); |
|
| 154 | + // Invoice items. |
|
| 155 | + add_meta_box( |
|
| 156 | + 'wpinv-items', |
|
| 157 | + sprintf( |
|
| 158 | + __( '%s Items', 'invoicing' ), |
|
| 159 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 160 | + ), |
|
| 161 | + 'GetPaid_Meta_Box_Invoice_Items::output', |
|
| 162 | + $post_type, |
|
| 163 | + 'normal', |
|
| 164 | + 'high' |
|
| 165 | + ); |
|
| 166 | 166 | |
| 167 | - // Invoice notes. |
|
| 168 | - add_meta_box( |
|
| 169 | - 'wpinv-notes', |
|
| 170 | - sprintf( |
|
| 171 | - __( '%s Notes', 'invoicing' ), |
|
| 172 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 173 | - ), |
|
| 174 | - 'WPInv_Meta_Box_Notes::output', |
|
| 175 | - $post_type, |
|
| 176 | - 'side', |
|
| 177 | - 'low' |
|
| 178 | - ); |
|
| 179 | - |
|
| 180 | - // Shipping Address. |
|
| 181 | - if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
| 182 | - add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - // Payment form information. |
|
| 186 | - if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
| 187 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Remove some metaboxes. |
|
| 196 | - */ |
|
| 197 | - public static function remove_meta_boxes() { |
|
| 198 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Rename other metaboxes. |
|
| 203 | - */ |
|
| 204 | - public static function rename_meta_boxes() { |
|
| 167 | + // Invoice notes. |
|
| 168 | + add_meta_box( |
|
| 169 | + 'wpinv-notes', |
|
| 170 | + sprintf( |
|
| 171 | + __( '%s Notes', 'invoicing' ), |
|
| 172 | + ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 173 | + ), |
|
| 174 | + 'WPInv_Meta_Box_Notes::output', |
|
| 175 | + $post_type, |
|
| 176 | + 'side', |
|
| 177 | + 'low' |
|
| 178 | + ); |
|
| 179 | + |
|
| 180 | + // Shipping Address. |
|
| 181 | + if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
| 182 | + add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + // Payment form information. |
|
| 186 | + if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
| 187 | + add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Remove some metaboxes. |
|
| 196 | + */ |
|
| 197 | + public static function remove_meta_boxes() { |
|
| 198 | + remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Rename other metaboxes. |
|
| 203 | + */ |
|
| 204 | + public static function rename_meta_boxes() { |
|
| 205 | 205 | |
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Check if we're saving, then trigger an action based on the post type. |
|
| 210 | - * |
|
| 211 | - * @param int $post_id Post ID. |
|
| 212 | - * @param object $post Post object. |
|
| 213 | - */ |
|
| 214 | - public static function save_meta_boxes( $post_id, $post ) { |
|
| 215 | - $post_id = absint( $post_id ); |
|
| 216 | - $data = wp_unslash( $_POST ); |
|
| 217 | - |
|
| 218 | - // Do not save for ajax requests. |
|
| 219 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
| 220 | - return; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - // $post_id and $post are required |
|
| 224 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
| 225 | - return; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // Dont' save meta boxes for revisions or autosaves. |
|
| 229 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
| 230 | - return; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // Check the nonce. |
|
| 234 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
| 235 | - return; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
| 239 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
| 240 | - return; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - // Check user has permission to edit. |
|
| 244 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 245 | - return; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 249 | - |
|
| 250 | - // We need this save event to run once to avoid potential endless loops. |
|
| 251 | - self::$saved_meta_boxes = true; |
|
| 252 | - |
|
| 253 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
| 254 | - |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - // Ensure this is our post type. |
|
| 258 | - $post_types_map = array( |
|
| 259 | - 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
| 260 | - 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
| 261 | - 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
| 262 | - ); |
|
| 263 | - |
|
| 264 | - // Is this our post type? |
|
| 265 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
| 266 | - return; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - // We need this save event to run once to avoid potential endless loops. |
|
| 270 | - self::$saved_meta_boxes = true; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Check if we're saving, then trigger an action based on the post type. |
|
| 210 | + * |
|
| 211 | + * @param int $post_id Post ID. |
|
| 212 | + * @param object $post Post object. |
|
| 213 | + */ |
|
| 214 | + public static function save_meta_boxes( $post_id, $post ) { |
|
| 215 | + $post_id = absint( $post_id ); |
|
| 216 | + $data = wp_unslash( $_POST ); |
|
| 217 | + |
|
| 218 | + // Do not save for ajax requests. |
|
| 219 | + if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
| 220 | + return; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + // $post_id and $post are required |
|
| 224 | + if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
| 225 | + return; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // Dont' save meta boxes for revisions or autosaves. |
|
| 229 | + if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
| 230 | + return; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // Check the nonce. |
|
| 234 | + if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
| 235 | + return; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
| 239 | + if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
| 240 | + return; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + // Check user has permission to edit. |
|
| 244 | + if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 245 | + return; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 249 | + |
|
| 250 | + // We need this save event to run once to avoid potential endless loops. |
|
| 251 | + self::$saved_meta_boxes = true; |
|
| 252 | + |
|
| 253 | + return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
| 254 | + |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + // Ensure this is our post type. |
|
| 258 | + $post_types_map = array( |
|
| 259 | + 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
| 260 | + 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
| 261 | + 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
| 262 | + ); |
|
| 263 | + |
|
| 264 | + // Is this our post type? |
|
| 265 | + if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
| 266 | + return; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + // We need this save event to run once to avoid potential endless loops. |
|
| 270 | + self::$saved_meta_boxes = true; |
|
| 271 | 271 | |
| 272 | - // Save the post. |
|
| 273 | - $class = $post_types_map[ $post->post_type ]; |
|
| 274 | - $class::save( $post_id, $_POST, $post ); |
|
| 272 | + // Save the post. |
|
| 273 | + $class = $post_types_map[ $post->post_type ]; |
|
| 274 | + $class::save( $post_id, $_POST, $post ); |
|
| 275 | 275 | |
| 276 | - } |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | 278 | } |
@@ -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 | * Metaboxes Admin Class |
@@ -25,35 +25,35 @@ discard block |
||
| 25 | 25 | public static function init() { |
| 26 | 26 | |
| 27 | 27 | // Register metaboxes. |
| 28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 ); |
|
| 28 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2); |
|
| 29 | 29 | |
| 30 | 30 | // Remove metaboxes. |
| 31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
| 31 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30); |
|
| 32 | 32 | |
| 33 | 33 | // Rename metaboxes. |
| 34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
| 34 | + add_action('add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45); |
|
| 35 | 35 | |
| 36 | 36 | // Save metaboxes. |
| 37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
| 37 | + add_action('save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Register core metaboxes. |
| 42 | 42 | */ |
| 43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
| 43 | + public static function add_meta_boxes($post_type, $post) { |
|
| 44 | 44 | |
| 45 | 45 | // For invoices... |
| 46 | - self::add_invoice_meta_boxes( $post_type, $post ); |
|
| 46 | + self::add_invoice_meta_boxes($post_type, $post); |
|
| 47 | 47 | |
| 48 | 48 | // For payment forms. |
| 49 | - self::add_payment_form_meta_boxes( $post_type ); |
|
| 49 | + self::add_payment_form_meta_boxes($post_type); |
|
| 50 | 50 | |
| 51 | 51 | // For invoice items. |
| 52 | - self::add_item_meta_boxes( $post_type ); |
|
| 52 | + self::add_item_meta_boxes($post_type); |
|
| 53 | 53 | |
| 54 | 54 | // For invoice discounts. |
| 55 | - if ( $post_type == 'wpi_discount' ) { |
|
| 56 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
| 55 | + if ($post_type == 'wpi_discount') { |
|
| 56 | + add_meta_box('wpinv_discount_details', __('Discount Details', 'invoicing'), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | } |
@@ -61,16 +61,16 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * Register core metaboxes. |
| 63 | 63 | */ |
| 64 | - protected static function add_payment_form_meta_boxes( $post_type ) { |
|
| 64 | + protected static function add_payment_form_meta_boxes($post_type) { |
|
| 65 | 65 | |
| 66 | 66 | // For payment forms. |
| 67 | - if ( $post_type == 'wpi_payment_form' ) { |
|
| 67 | + if ($post_type == 'wpi_payment_form') { |
|
| 68 | 68 | |
| 69 | 69 | // Design payment form. |
| 70 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
| 70 | + add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal'); |
|
| 71 | 71 | |
| 72 | 72 | // Payment form information. |
| 73 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
| 73 | + add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side'); |
|
| 74 | 74 | |
| 75 | 75 | } |
| 76 | 76 | |
@@ -79,20 +79,20 @@ discard block |
||
| 79 | 79 | /** |
| 80 | 80 | * Register core metaboxes. |
| 81 | 81 | */ |
| 82 | - protected static function add_item_meta_boxes( $post_type ) { |
|
| 82 | + protected static function add_item_meta_boxes($post_type) { |
|
| 83 | 83 | |
| 84 | - if ( $post_type == 'wpi_item' ) { |
|
| 84 | + if ($post_type == 'wpi_item') { |
|
| 85 | 85 | |
| 86 | 86 | // Item details. |
| 87 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
| 87 | + add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high'); |
|
| 88 | 88 | |
| 89 | 89 | // If taxes are enabled, register the tax metabox. |
| 90 | - if ( getpaid_tax()->allow_vat_rules() || getpaid_tax()->allow_vat_classes() ) { |
|
| 91 | - add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
| 90 | + if (getpaid_tax()->allow_vat_rules() || getpaid_tax()->allow_vat_classes()) { |
|
| 91 | + add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high'); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | // Item info. |
| 95 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
| 95 | + add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core'); |
|
| 96 | 96 | |
| 97 | 97 | } |
| 98 | 98 | |
@@ -101,20 +101,20 @@ discard block |
||
| 101 | 101 | /** |
| 102 | 102 | * Register invoice metaboxes. |
| 103 | 103 | */ |
| 104 | - protected static function add_invoice_meta_boxes( $post_type, $post ) { |
|
| 104 | + protected static function add_invoice_meta_boxes($post_type, $post) { |
|
| 105 | 105 | |
| 106 | 106 | // For invoices... |
| 107 | - if ( getpaid_is_invoice_post_type( $post_type ) ) { |
|
| 108 | - $invoice = new WPInv_Invoice( $post ); |
|
| 107 | + if (getpaid_is_invoice_post_type($post_type)) { |
|
| 108 | + $invoice = new WPInv_Invoice($post); |
|
| 109 | 109 | |
| 110 | 110 | // Resend invoice. |
| 111 | - if ( ! $invoice->is_draft() && ! $invoice->is_paid() ) { |
|
| 111 | + if (!$invoice->is_draft() && !$invoice->is_paid()) { |
|
| 112 | 112 | |
| 113 | 113 | add_meta_box( |
| 114 | 114 | 'wpinv-mb-resend-invoice', |
| 115 | 115 | sprintf( |
| 116 | - __( 'Resend %s', 'invoicing' ), |
|
| 117 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 116 | + __('Resend %s', 'invoicing'), |
|
| 117 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 118 | 118 | ), |
| 119 | 119 | 'GetPaid_Meta_Box_Resend_Invoice::output', |
| 120 | 120 | $post_type, |
@@ -125,18 +125,18 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // Subscriptions. |
| 128 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
| 129 | - if ( ! empty( $subscription ) ) { |
|
| 130 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced' ); |
|
| 131 | - add_meta_box( 'wpinv-mb-subscription-invoices', __( 'Related Payments', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced' ); |
|
| 128 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
| 129 | + if (!empty($subscription)) { |
|
| 130 | + add_meta_box('wpinv-mb-subscriptions', __('Subscription Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output', $post_type, 'advanced'); |
|
| 131 | + add_meta_box('wpinv-mb-subscription-invoices', __('Related Payments', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Subscription::output_invoices', $post_type, 'advanced'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Invoice details. |
| 135 | 135 | add_meta_box( |
| 136 | 136 | 'wpinv-details', |
| 137 | 137 | sprintf( |
| 138 | - __( '%s Details', 'invoicing' ), |
|
| 139 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 138 | + __('%s Details', 'invoicing'), |
|
| 139 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 140 | 140 | ), |
| 141 | 141 | 'GetPaid_Meta_Box_Invoice_Details::output', |
| 142 | 142 | $post_type, |
@@ -144,19 +144,19 @@ discard block |
||
| 144 | 144 | ); |
| 145 | 145 | |
| 146 | 146 | // Payment details. |
| 147 | - if ( ! $invoice->is_draft() ) { |
|
| 148 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default' ); |
|
| 147 | + if (!$invoice->is_draft()) { |
|
| 148 | + add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', $post_type, 'side', 'default'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Billing details. |
| 152 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high' ); |
|
| 152 | + add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Address::output', $post_type, 'normal', 'high'); |
|
| 153 | 153 | |
| 154 | 154 | // Invoice items. |
| 155 | 155 | add_meta_box( |
| 156 | 156 | 'wpinv-items', |
| 157 | 157 | sprintf( |
| 158 | - __( '%s Items', 'invoicing' ), |
|
| 159 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 158 | + __('%s Items', 'invoicing'), |
|
| 159 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 160 | 160 | ), |
| 161 | 161 | 'GetPaid_Meta_Box_Invoice_Items::output', |
| 162 | 162 | $post_type, |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | add_meta_box( |
| 169 | 169 | 'wpinv-notes', |
| 170 | 170 | sprintf( |
| 171 | - __( '%s Notes', 'invoicing' ), |
|
| 172 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
| 171 | + __('%s Notes', 'invoicing'), |
|
| 172 | + ucfirst($invoice->get_invoice_quote_type()) |
|
| 173 | 173 | ), |
| 174 | 174 | 'WPInv_Meta_Box_Notes::output', |
| 175 | 175 | $post_type, |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | ); |
| 179 | 179 | |
| 180 | 180 | // Shipping Address. |
| 181 | - if ( get_post_meta( $invoice->get_id(), 'shipping_address', true ) ) { |
|
| 182 | - add_meta_box( 'wpinv-invoice-shipping-details', __( 'Shipping Address', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high' ); |
|
| 181 | + if (get_post_meta($invoice->get_id(), 'shipping_address', true)) { |
|
| 182 | + add_meta_box('wpinv-invoice-shipping-details', __('Shipping Address', 'invoicing'), 'GetPaid_Meta_Box_Invoice_Shipping_Address::output', $post_type, 'side', 'high'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // Payment form information. |
| 186 | - if ( get_post_meta( $invoice->get_id(), 'payment_form_data', true ) ) { |
|
| 187 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high' ); |
|
| 186 | + if (get_post_meta($invoice->get_id(), 'payment_form_data', true)) { |
|
| 187 | + add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', $post_type, 'side', 'high'); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * Remove some metaboxes. |
| 196 | 196 | */ |
| 197 | 197 | public static function remove_meta_boxes() { |
| 198 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
| 198 | + remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -211,46 +211,46 @@ discard block |
||
| 211 | 211 | * @param int $post_id Post ID. |
| 212 | 212 | * @param object $post Post object. |
| 213 | 213 | */ |
| 214 | - public static function save_meta_boxes( $post_id, $post ) { |
|
| 215 | - $post_id = absint( $post_id ); |
|
| 216 | - $data = wp_unslash( $_POST ); |
|
| 214 | + public static function save_meta_boxes($post_id, $post) { |
|
| 215 | + $post_id = absint($post_id); |
|
| 216 | + $data = wp_unslash($_POST); |
|
| 217 | 217 | |
| 218 | 218 | // Do not save for ajax requests. |
| 219 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
| 219 | + if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) { |
|
| 220 | 220 | return; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // $post_id and $post are required |
| 224 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
| 224 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
| 225 | 225 | return; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // Dont' save meta boxes for revisions or autosaves. |
| 229 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
| 229 | + if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
| 230 | 230 | return; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Check the nonce. |
| 234 | - if ( empty( $data['getpaid_meta_nonce'] ) || ! wp_verify_nonce( $data['getpaid_meta_nonce'], 'getpaid_meta_nonce' ) ) { |
|
| 234 | + if (empty($data['getpaid_meta_nonce']) || !wp_verify_nonce($data['getpaid_meta_nonce'], 'getpaid_meta_nonce')) { |
|
| 235 | 235 | return; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
| 239 | - if ( empty( $data['post_ID'] ) || absint( $data['post_ID'] ) !== $post_id ) { |
|
| 239 | + if (empty($data['post_ID']) || absint($data['post_ID']) !== $post_id) { |
|
| 240 | 240 | return; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // Check user has permission to edit. |
| 244 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 244 | + if (!current_user_can('edit_post', $post_id)) { |
|
| 245 | 245 | return; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
| 248 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
| 249 | 249 | |
| 250 | 250 | // We need this save event to run once to avoid potential endless loops. |
| 251 | 251 | self::$saved_meta_boxes = true; |
| 252 | 252 | |
| 253 | - return GetPaid_Meta_Box_Invoice_Address::save( $post_id ); |
|
| 253 | + return GetPaid_Meta_Box_Invoice_Address::save($post_id); |
|
| 254 | 254 | |
| 255 | 255 | } |
| 256 | 256 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | ); |
| 263 | 263 | |
| 264 | 264 | // Is this our post type? |
| 265 | - if ( ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
| 265 | + if (!isset($post_types_map[$post->post_type])) { |
|
| 266 | 266 | return; |
| 267 | 267 | } |
| 268 | 268 | |
@@ -270,8 +270,8 @@ discard block |
||
| 270 | 270 | self::$saved_meta_boxes = true; |
| 271 | 271 | |
| 272 | 272 | // Save the post. |
| 273 | - $class = $post_types_map[ $post->post_type ]; |
|
| 274 | - $class::save( $post_id, $_POST, $post ); |
|
| 273 | + $class = $post_types_map[$post->post_type]; |
|
| 274 | + $class::save($post_id, $_POST, $post); |
|
| 275 | 275 | |
| 276 | 276 | } |
| 277 | 277 | |
@@ -14,501 +14,501 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class WPInv_Plugin { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * GetPaid version. |
|
| 19 | - * |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - public $version; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Data container. |
|
| 26 | - * |
|
| 27 | - * @var array |
|
| 28 | - */ |
|
| 29 | - protected $data = array(); |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Form elements instance. |
|
| 33 | - * |
|
| 34 | - * @var WPInv_Payment_Form_Elements |
|
| 35 | - */ |
|
| 36 | - public $form_elements; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Tax instance. |
|
| 40 | - * |
|
| 41 | - * @var WPInv_EUVat |
|
| 42 | - */ |
|
| 43 | - public $tax; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @param array An array of payment gateways. |
|
| 47 | - */ |
|
| 48 | - public $gateways; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Class constructor. |
|
| 52 | - */ |
|
| 53 | - public function __construct() { |
|
| 54 | - $this->define_constants(); |
|
| 55 | - $this->includes(); |
|
| 56 | - $this->init_hooks(); |
|
| 57 | - $this->set_properties(); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Sets a custom data property. |
|
| 62 | - * |
|
| 63 | - * @param string $prop The prop to set. |
|
| 64 | - * @param mixed $value The value to retrieve. |
|
| 65 | - */ |
|
| 66 | - public function set( $prop, $value ) { |
|
| 67 | - $this->data[ $prop ] = $value; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Gets a custom data property. |
|
| 72 | - * |
|
| 73 | - * @param string $prop The prop to set. |
|
| 74 | - * @return mixed The value. |
|
| 75 | - */ |
|
| 76 | - public function get( $prop ) { |
|
| 77 | - |
|
| 78 | - if ( isset( $this->data[ $prop ] ) ) { |
|
| 79 | - return $this->data[ $prop ]; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - return null; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Define class properties. |
|
| 87 | - */ |
|
| 88 | - public function set_properties() { |
|
| 89 | - |
|
| 90 | - // Sessions. |
|
| 91 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
| 92 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
| 93 | - $this->tax = new WPInv_EUVat(); |
|
| 94 | - $this->tax->init(); |
|
| 95 | - $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
|
| 96 | - |
|
| 97 | - // Init other objects. |
|
| 98 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
| 99 | - $this->set( 'notes', new WPInv_Notes() ); |
|
| 100 | - $this->set( 'api', new WPInv_API() ); |
|
| 101 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
| 102 | - $this->set( 'template', new GetPaid_Template() ); |
|
| 103 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
| 104 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
| 105 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
| 106 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
| 107 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
| 108 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
| 109 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
| 110 | - |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Define plugin constants. |
|
| 115 | - */ |
|
| 116 | - public function define_constants() { |
|
| 117 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
| 118 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
| 119 | - $this->version = WPINV_VERSION; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Hook into actions and filters. |
|
| 124 | - * |
|
| 125 | - * @since 1.0.19 |
|
| 126 | - */ |
|
| 127 | - protected function init_hooks() { |
|
| 128 | - /* Internationalize the text strings used. */ |
|
| 129 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
| 130 | - |
|
| 131 | - // Init the plugin after WordPress inits. |
|
| 132 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
| 133 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
| 134 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
| 135 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
| 136 | - |
|
| 137 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 138 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 142 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
| 143 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
| 144 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
| 145 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 146 | - |
|
| 147 | - // Fires after registering actions. |
|
| 148 | - do_action( 'wpinv_actions', $this ); |
|
| 149 | - do_action( 'getpaid_actions', $this ); |
|
| 150 | - |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - public function plugins_loaded() { |
|
| 154 | - /* Internationalize the text strings used. */ |
|
| 155 | - $this->load_textdomain(); |
|
| 156 | - |
|
| 157 | - do_action( 'wpinv_loaded' ); |
|
| 158 | - |
|
| 159 | - // Fix oxygen page builder conflict |
|
| 160 | - if ( function_exists( 'ct_css_output' ) ) { |
|
| 161 | - wpinv_oxygen_fix_conflict(); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Load the translation of the plugin. |
|
| 167 | - * |
|
| 168 | - * @since 1.0 |
|
| 169 | - */ |
|
| 170 | - public function load_textdomain( $locale = NULL ) { |
|
| 171 | - if ( empty( $locale ) ) { |
|
| 172 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
| 176 | - |
|
| 177 | - unload_textdomain( 'invoicing' ); |
|
| 178 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 179 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Define language constants. |
|
| 183 | - */ |
|
| 184 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * Include required core files used in admin and on the frontend. |
|
| 189 | - */ |
|
| 190 | - public function includes() { |
|
| 191 | - |
|
| 192 | - // Start with the settings. |
|
| 193 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 194 | - |
|
| 195 | - // Packages/libraries. |
|
| 196 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
| 197 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
| 198 | - |
|
| 199 | - // Load functions. |
|
| 200 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
| 201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 205 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 206 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 207 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
| 208 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
| 209 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 210 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 211 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 212 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 213 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 214 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
| 215 | - |
|
| 216 | - // Register autoloader. |
|
| 217 | - try { |
|
| 218 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
| 219 | - } catch ( Exception $e ) { |
|
| 220 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
| 224 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
| 225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 227 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
| 228 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
| 229 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
| 230 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
| 231 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
| 232 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
| 233 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
| 234 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
| 235 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
| 236 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 237 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 238 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 239 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 240 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 241 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
| 242 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * Load the tax class. |
|
| 246 | - */ |
|
| 247 | - if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
| 248 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 252 | - GetPaid_Post_Types_Admin::init(); |
|
| 253 | - |
|
| 254 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 255 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 256 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
| 257 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 258 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 259 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
| 260 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 261 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
| 262 | - // load the user class only on the users.php page |
|
| 263 | - global $pagenow; |
|
| 264 | - if($pagenow=='users.php'){ |
|
| 265 | - new WPInv_Admin_Users(); |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - // Register cli commands |
|
| 270 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 271 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
| 272 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * Class autoloader |
|
| 280 | - * |
|
| 281 | - * @param string $class_name The name of the class to load. |
|
| 282 | - * @access public |
|
| 283 | - * @since 1.0.19 |
|
| 284 | - * @return void |
|
| 285 | - */ |
|
| 286 | - public function autoload( $class_name ) { |
|
| 287 | - |
|
| 288 | - // Normalize the class name... |
|
| 289 | - $class_name = strtolower( $class_name ); |
|
| 290 | - |
|
| 291 | - // ... and make sure it is our class. |
|
| 292 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
| 293 | - return; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - // Next, prepare the file name from the class. |
|
| 297 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
| 298 | - |
|
| 299 | - // Base path of the classes. |
|
| 300 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
| 301 | - |
|
| 302 | - // And an array of possible locations in order of importance. |
|
| 303 | - $locations = array( |
|
| 304 | - "$plugin_path/includes", |
|
| 305 | - "$plugin_path/includes/data-stores", |
|
| 306 | - "$plugin_path/includes/gateways", |
|
| 307 | - "$plugin_path/includes/payments", |
|
| 308 | - "$plugin_path/includes/geolocation", |
|
| 309 | - "$plugin_path/includes/reports", |
|
| 310 | - "$plugin_path/includes/api", |
|
| 311 | - "$plugin_path/includes/admin", |
|
| 312 | - "$plugin_path/includes/admin/meta-boxes", |
|
| 313 | - ); |
|
| 314 | - |
|
| 315 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
| 316 | - |
|
| 317 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
| 318 | - include trailingslashit( $location ) . $file_name; |
|
| 319 | - break; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * Inits hooks etc. |
|
| 328 | - */ |
|
| 329 | - public function init() { |
|
| 330 | - |
|
| 331 | - // Fires before getpaid inits. |
|
| 332 | - do_action( 'before_getpaid_init', $this ); |
|
| 333 | - |
|
| 334 | - // Load default gateways. |
|
| 335 | - $gateways = apply_filters( |
|
| 336 | - 'getpaid_default_gateways', |
|
| 337 | - array( |
|
| 338 | - 'manual' => 'GetPaid_Manual_Gateway', |
|
| 339 | - 'paypal' => 'GetPaid_Paypal_Gateway', |
|
| 340 | - 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
| 341 | - 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
| 342 | - 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
| 343 | - ) |
|
| 344 | - ); |
|
| 345 | - |
|
| 346 | - foreach ( $gateways as $id => $class ) { |
|
| 347 | - $this->gateways[ $id ] = new $class(); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - // Fires after getpaid inits. |
|
| 351 | - do_action( 'getpaid_init', $this ); |
|
| 352 | - |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * Checks if this is an IPN request and processes it. |
|
| 357 | - */ |
|
| 358 | - public function maybe_process_ipn() { |
|
| 359 | - |
|
| 360 | - // Ensure that this is an IPN request. |
|
| 361 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
| 362 | - return; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
| 366 | - |
|
| 367 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
| 368 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
| 369 | - exit; |
|
| 370 | - |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - public function enqueue_scripts() { |
|
| 374 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 375 | - |
|
| 376 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
| 377 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
| 378 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 379 | - |
|
| 380 | - // Register scripts |
|
| 381 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 382 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
| 383 | - |
|
| 384 | - $localize = array(); |
|
| 385 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 386 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 387 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
| 388 | - $localize['UseTaxes'] = wpinv_use_taxes(); |
|
| 389 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 390 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
| 391 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
| 392 | - |
|
| 393 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 394 | - |
|
| 395 | - wp_enqueue_script( 'jquery-blockui' ); |
|
| 396 | - |
|
| 397 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
| 398 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 399 | - |
|
| 400 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
| 401 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 402 | - |
|
| 403 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
| 404 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - public function wpinv_actions() { |
|
| 408 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 409 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 410 | - } |
|
| 411 | - } |
|
| 17 | + /** |
|
| 18 | + * GetPaid version. |
|
| 19 | + * |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + public $version; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Data container. |
|
| 26 | + * |
|
| 27 | + * @var array |
|
| 28 | + */ |
|
| 29 | + protected $data = array(); |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Form elements instance. |
|
| 33 | + * |
|
| 34 | + * @var WPInv_Payment_Form_Elements |
|
| 35 | + */ |
|
| 36 | + public $form_elements; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Tax instance. |
|
| 40 | + * |
|
| 41 | + * @var WPInv_EUVat |
|
| 42 | + */ |
|
| 43 | + public $tax; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @param array An array of payment gateways. |
|
| 47 | + */ |
|
| 48 | + public $gateways; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Class constructor. |
|
| 52 | + */ |
|
| 53 | + public function __construct() { |
|
| 54 | + $this->define_constants(); |
|
| 55 | + $this->includes(); |
|
| 56 | + $this->init_hooks(); |
|
| 57 | + $this->set_properties(); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Sets a custom data property. |
|
| 62 | + * |
|
| 63 | + * @param string $prop The prop to set. |
|
| 64 | + * @param mixed $value The value to retrieve. |
|
| 65 | + */ |
|
| 66 | + public function set( $prop, $value ) { |
|
| 67 | + $this->data[ $prop ] = $value; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Gets a custom data property. |
|
| 72 | + * |
|
| 73 | + * @param string $prop The prop to set. |
|
| 74 | + * @return mixed The value. |
|
| 75 | + */ |
|
| 76 | + public function get( $prop ) { |
|
| 77 | + |
|
| 78 | + if ( isset( $this->data[ $prop ] ) ) { |
|
| 79 | + return $this->data[ $prop ]; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + return null; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Define class properties. |
|
| 87 | + */ |
|
| 88 | + public function set_properties() { |
|
| 89 | + |
|
| 90 | + // Sessions. |
|
| 91 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
| 92 | + $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
| 93 | + $this->tax = new WPInv_EUVat(); |
|
| 94 | + $this->tax->init(); |
|
| 95 | + $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
|
| 96 | + |
|
| 97 | + // Init other objects. |
|
| 98 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
| 99 | + $this->set( 'notes', new WPInv_Notes() ); |
|
| 100 | + $this->set( 'api', new WPInv_API() ); |
|
| 101 | + $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
| 102 | + $this->set( 'template', new GetPaid_Template() ); |
|
| 103 | + $this->set( 'admin', new GetPaid_Admin() ); |
|
| 104 | + $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
| 105 | + $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
| 106 | + $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
| 107 | + $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
| 108 | + $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
| 109 | + $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
| 110 | + |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Define plugin constants. |
|
| 115 | + */ |
|
| 116 | + public function define_constants() { |
|
| 117 | + define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
| 118 | + define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
| 119 | + $this->version = WPINV_VERSION; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Hook into actions and filters. |
|
| 124 | + * |
|
| 125 | + * @since 1.0.19 |
|
| 126 | + */ |
|
| 127 | + protected function init_hooks() { |
|
| 128 | + /* Internationalize the text strings used. */ |
|
| 129 | + add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
| 130 | + |
|
| 131 | + // Init the plugin after WordPress inits. |
|
| 132 | + add_action( 'init', array( $this, 'init' ), 1 ); |
|
| 133 | + add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
| 134 | + add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
| 135 | + add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
| 136 | + |
|
| 137 | + if ( class_exists( 'BuddyPress' ) ) { |
|
| 138 | + add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 142 | + add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
| 143 | + add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
| 144 | + add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
| 145 | + add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 146 | + |
|
| 147 | + // Fires after registering actions. |
|
| 148 | + do_action( 'wpinv_actions', $this ); |
|
| 149 | + do_action( 'getpaid_actions', $this ); |
|
| 150 | + |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + public function plugins_loaded() { |
|
| 154 | + /* Internationalize the text strings used. */ |
|
| 155 | + $this->load_textdomain(); |
|
| 156 | + |
|
| 157 | + do_action( 'wpinv_loaded' ); |
|
| 158 | + |
|
| 159 | + // Fix oxygen page builder conflict |
|
| 160 | + if ( function_exists( 'ct_css_output' ) ) { |
|
| 161 | + wpinv_oxygen_fix_conflict(); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Load the translation of the plugin. |
|
| 167 | + * |
|
| 168 | + * @since 1.0 |
|
| 169 | + */ |
|
| 170 | + public function load_textdomain( $locale = NULL ) { |
|
| 171 | + if ( empty( $locale ) ) { |
|
| 172 | + $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
| 176 | + |
|
| 177 | + unload_textdomain( 'invoicing' ); |
|
| 178 | + load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 179 | + load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * Define language constants. |
|
| 183 | + */ |
|
| 184 | + require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * Include required core files used in admin and on the frontend. |
|
| 189 | + */ |
|
| 190 | + public function includes() { |
|
| 191 | + |
|
| 192 | + // Start with the settings. |
|
| 193 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 194 | + |
|
| 195 | + // Packages/libraries. |
|
| 196 | + require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
| 197 | + require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
| 198 | + |
|
| 199 | + // Load functions. |
|
| 200 | + require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
| 201 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 202 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 203 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 204 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 205 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 206 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 207 | + require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
| 208 | + require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
| 209 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 210 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 211 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 212 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 213 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 214 | + require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
| 215 | + |
|
| 216 | + // Register autoloader. |
|
| 217 | + try { |
|
| 218 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
| 219 | + } catch ( Exception $e ) { |
|
| 220 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
| 224 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
| 225 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 226 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 227 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
| 228 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
| 229 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
| 230 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
| 231 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
| 232 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
| 233 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
| 234 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
| 235 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
| 236 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 237 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 238 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 239 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 240 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 241 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
| 242 | + require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * Load the tax class. |
|
| 246 | + */ |
|
| 247 | + if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
| 248 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 252 | + GetPaid_Post_Types_Admin::init(); |
|
| 253 | + |
|
| 254 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 255 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 256 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
| 257 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 258 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 259 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
| 260 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 261 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
| 262 | + // load the user class only on the users.php page |
|
| 263 | + global $pagenow; |
|
| 264 | + if($pagenow=='users.php'){ |
|
| 265 | + new WPInv_Admin_Users(); |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + // Register cli commands |
|
| 270 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 271 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
| 272 | + WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * Class autoloader |
|
| 280 | + * |
|
| 281 | + * @param string $class_name The name of the class to load. |
|
| 282 | + * @access public |
|
| 283 | + * @since 1.0.19 |
|
| 284 | + * @return void |
|
| 285 | + */ |
|
| 286 | + public function autoload( $class_name ) { |
|
| 412 | 287 | |
| 413 | - /** |
|
| 288 | + // Normalize the class name... |
|
| 289 | + $class_name = strtolower( $class_name ); |
|
| 290 | + |
|
| 291 | + // ... and make sure it is our class. |
|
| 292 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
| 293 | + return; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + // Next, prepare the file name from the class. |
|
| 297 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
| 298 | + |
|
| 299 | + // Base path of the classes. |
|
| 300 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
| 301 | + |
|
| 302 | + // And an array of possible locations in order of importance. |
|
| 303 | + $locations = array( |
|
| 304 | + "$plugin_path/includes", |
|
| 305 | + "$plugin_path/includes/data-stores", |
|
| 306 | + "$plugin_path/includes/gateways", |
|
| 307 | + "$plugin_path/includes/payments", |
|
| 308 | + "$plugin_path/includes/geolocation", |
|
| 309 | + "$plugin_path/includes/reports", |
|
| 310 | + "$plugin_path/includes/api", |
|
| 311 | + "$plugin_path/includes/admin", |
|
| 312 | + "$plugin_path/includes/admin/meta-boxes", |
|
| 313 | + ); |
|
| 314 | + |
|
| 315 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
| 316 | + |
|
| 317 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
| 318 | + include trailingslashit( $location ) . $file_name; |
|
| 319 | + break; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * Inits hooks etc. |
|
| 328 | + */ |
|
| 329 | + public function init() { |
|
| 330 | + |
|
| 331 | + // Fires before getpaid inits. |
|
| 332 | + do_action( 'before_getpaid_init', $this ); |
|
| 333 | + |
|
| 334 | + // Load default gateways. |
|
| 335 | + $gateways = apply_filters( |
|
| 336 | + 'getpaid_default_gateways', |
|
| 337 | + array( |
|
| 338 | + 'manual' => 'GetPaid_Manual_Gateway', |
|
| 339 | + 'paypal' => 'GetPaid_Paypal_Gateway', |
|
| 340 | + 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
| 341 | + 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
| 342 | + 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
| 343 | + ) |
|
| 344 | + ); |
|
| 345 | + |
|
| 346 | + foreach ( $gateways as $id => $class ) { |
|
| 347 | + $this->gateways[ $id ] = new $class(); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + // Fires after getpaid inits. |
|
| 351 | + do_action( 'getpaid_init', $this ); |
|
| 352 | + |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * Checks if this is an IPN request and processes it. |
|
| 357 | + */ |
|
| 358 | + public function maybe_process_ipn() { |
|
| 359 | + |
|
| 360 | + // Ensure that this is an IPN request. |
|
| 361 | + if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
| 362 | + return; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
| 366 | + |
|
| 367 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
| 368 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
| 369 | + exit; |
|
| 370 | + |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + public function enqueue_scripts() { |
|
| 374 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 375 | + |
|
| 376 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
| 377 | + wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
| 378 | + wp_enqueue_style( 'wpinv_front_style' ); |
|
| 379 | + |
|
| 380 | + // Register scripts |
|
| 381 | + wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 382 | + wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
| 383 | + |
|
| 384 | + $localize = array(); |
|
| 385 | + $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 386 | + $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 387 | + $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
| 388 | + $localize['UseTaxes'] = wpinv_use_taxes(); |
|
| 389 | + $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 390 | + $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
| 391 | + $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
| 392 | + |
|
| 393 | + $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 394 | + |
|
| 395 | + wp_enqueue_script( 'jquery-blockui' ); |
|
| 396 | + |
|
| 397 | + wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
| 398 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 399 | + |
|
| 400 | + wp_enqueue_script( 'wpinv-front-script' ); |
|
| 401 | + wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 402 | + |
|
| 403 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
| 404 | + wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + public function wpinv_actions() { |
|
| 408 | + if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 409 | + do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | 414 | * Fires an action after verifying that a user can fire them. |
| 415 | - * |
|
| 416 | - * Note: If the action is on an invoice, subscription etc, esure that the |
|
| 417 | - * current user owns the invoice/subscription. |
|
| 415 | + * |
|
| 416 | + * Note: If the action is on an invoice, subscription etc, esure that the |
|
| 417 | + * current user owns the invoice/subscription. |
|
| 418 | 418 | */ |
| 419 | 419 | public function maybe_do_authenticated_action() { |
| 420 | 420 | |
| 421 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
| 421 | + if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
| 422 | 422 | |
| 423 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
| 424 | - if ( is_user_logged_in() ) { |
|
| 425 | - do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
| 426 | - } |
|
| 423 | + $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
| 424 | + if ( is_user_logged_in() ) { |
|
| 425 | + do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | - do_action( "getpaid_unauthenticated_action_$key", $_REQUEST ); |
|
| 428 | + do_action( "getpaid_unauthenticated_action_$key", $_REQUEST ); |
|
| 429 | 429 | |
| 430 | - } |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | 432 | |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - public function pre_get_posts( $wp_query ) { |
|
| 436 | - |
|
| 437 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
| 438 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - return $wp_query; |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - public function bp_invoicing_init() { |
|
| 445 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * Register widgets |
|
| 450 | - * |
|
| 451 | - */ |
|
| 452 | - public function register_widgets() { |
|
| 453 | - $widgets = apply_filters( |
|
| 454 | - 'getpaid_widget_classes', |
|
| 455 | - array( |
|
| 456 | - 'WPInv_Checkout_Widget', |
|
| 457 | - 'WPInv_History_Widget', |
|
| 458 | - 'WPInv_Receipt_Widget', |
|
| 459 | - 'WPInv_Subscriptions_Widget', |
|
| 460 | - 'WPInv_Buy_Item_Widget', |
|
| 461 | - 'WPInv_Messages_Widget', |
|
| 462 | - 'WPInv_GetPaid_Widget' |
|
| 463 | - ) |
|
| 464 | - ); |
|
| 465 | - |
|
| 466 | - foreach ( $widgets as $widget ) { |
|
| 467 | - register_widget( $widget ); |
|
| 468 | - } |
|
| 435 | + public function pre_get_posts( $wp_query ) { |
|
| 436 | + |
|
| 437 | + if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
| 438 | + $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + return $wp_query; |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + public function bp_invoicing_init() { |
|
| 445 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * Register widgets |
|
| 450 | + * |
|
| 451 | + */ |
|
| 452 | + public function register_widgets() { |
|
| 453 | + $widgets = apply_filters( |
|
| 454 | + 'getpaid_widget_classes', |
|
| 455 | + array( |
|
| 456 | + 'WPInv_Checkout_Widget', |
|
| 457 | + 'WPInv_History_Widget', |
|
| 458 | + 'WPInv_Receipt_Widget', |
|
| 459 | + 'WPInv_Subscriptions_Widget', |
|
| 460 | + 'WPInv_Buy_Item_Widget', |
|
| 461 | + 'WPInv_Messages_Widget', |
|
| 462 | + 'WPInv_GetPaid_Widget' |
|
| 463 | + ) |
|
| 464 | + ); |
|
| 465 | + |
|
| 466 | + foreach ( $widgets as $widget ) { |
|
| 467 | + register_widget( $widget ); |
|
| 468 | + } |
|
| 469 | 469 | |
| 470 | - } |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - /** |
|
| 473 | - * Remove our pages from yoast sitemaps. |
|
| 474 | - * |
|
| 475 | - * @since 1.0.19 |
|
| 476 | - * @param int[] $excluded_posts_ids |
|
| 477 | - */ |
|
| 478 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
| 472 | + /** |
|
| 473 | + * Remove our pages from yoast sitemaps. |
|
| 474 | + * |
|
| 475 | + * @since 1.0.19 |
|
| 476 | + * @param int[] $excluded_posts_ids |
|
| 477 | + */ |
|
| 478 | + public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
| 479 | 479 | |
| 480 | - // Ensure that we have an array. |
|
| 481 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
| 482 | - $excluded_posts_ids = array(); |
|
| 483 | - } |
|
| 480 | + // Ensure that we have an array. |
|
| 481 | + if ( ! is_array( $excluded_posts_ids ) ) { |
|
| 482 | + $excluded_posts_ids = array(); |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | - // Prepare our pages. |
|
| 486 | - $our_pages = array(); |
|
| 485 | + // Prepare our pages. |
|
| 486 | + $our_pages = array(); |
|
| 487 | 487 | |
| 488 | - // Checkout page. |
|
| 489 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
| 488 | + // Checkout page. |
|
| 489 | + $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
| 490 | 490 | |
| 491 | - // Success page. |
|
| 492 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
| 491 | + // Success page. |
|
| 492 | + $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
| 493 | 493 | |
| 494 | - // Failure page. |
|
| 495 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
| 494 | + // Failure page. |
|
| 495 | + $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
| 496 | 496 | |
| 497 | - // History page. |
|
| 498 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
| 497 | + // History page. |
|
| 498 | + $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
| 499 | 499 | |
| 500 | - // Subscriptions page. |
|
| 501 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
| 500 | + // Subscriptions page. |
|
| 501 | + $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
| 502 | 502 | |
| 503 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
| 503 | + $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
| 504 | 504 | |
| 505 | - $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
| 506 | - return array_unique( $excluded_posts_ids ); |
|
| 505 | + $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
| 506 | + return array_unique( $excluded_posts_ids ); |
|
| 507 | 507 | |
| 508 | - } |
|
| 508 | + } |
|
| 509 | 509 | |
| 510 | - public function wp_footer() { |
|
| 511 | - echo ' |
|
| 510 | + public function wp_footer() { |
|
| 511 | + echo ' |
|
| 512 | 512 | <div class="bsui"> |
| 513 | 513 | <div id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog"> |
| 514 | 514 | <div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;"> |
@@ -524,6 +524,6 @@ discard block |
||
| 524 | 524 | </div> |
| 525 | 525 | </div> |
| 526 | 526 | '; |
| 527 | - } |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | 529 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @since 1.0.0 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Main Invoicing class. |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | * @param string $prop The prop to set. |
| 64 | 64 | * @param mixed $value The value to retrieve. |
| 65 | 65 | */ |
| 66 | - public function set( $prop, $value ) { |
|
| 67 | - $this->data[ $prop ] = $value; |
|
| 66 | + public function set($prop, $value) { |
|
| 67 | + $this->data[$prop] = $value; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | * @param string $prop The prop to set. |
| 74 | 74 | * @return mixed The value. |
| 75 | 75 | */ |
| 76 | - public function get( $prop ) { |
|
| 76 | + public function get($prop) { |
|
| 77 | 77 | |
| 78 | - if ( isset( $this->data[ $prop ] ) ) { |
|
| 79 | - return $this->data[ $prop ]; |
|
| 78 | + if (isset($this->data[$prop])) { |
|
| 79 | + return $this->data[$prop]; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return null; |
@@ -88,25 +88,25 @@ discard block |
||
| 88 | 88 | public function set_properties() { |
| 89 | 89 | |
| 90 | 90 | // Sessions. |
| 91 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
| 92 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
| 91 | + $this->set('session', new WPInv_Session_Handler()); |
|
| 92 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
| 93 | 93 | $this->tax = new WPInv_EUVat(); |
| 94 | 94 | $this->tax->init(); |
| 95 | 95 | $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility. |
| 96 | 96 | |
| 97 | 97 | // Init other objects. |
| 98 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
| 99 | - $this->set( 'notes', new WPInv_Notes() ); |
|
| 100 | - $this->set( 'api', new WPInv_API() ); |
|
| 101 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
| 102 | - $this->set( 'template', new GetPaid_Template() ); |
|
| 103 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
| 104 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
| 105 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
| 106 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
| 107 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
| 108 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
| 109 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
| 98 | + $this->set('session', new WPInv_Session_Handler()); |
|
| 99 | + $this->set('notes', new WPInv_Notes()); |
|
| 100 | + $this->set('api', new WPInv_API()); |
|
| 101 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
| 102 | + $this->set('template', new GetPaid_Template()); |
|
| 103 | + $this->set('admin', new GetPaid_Admin()); |
|
| 104 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
| 105 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
| 106 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
| 107 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
| 108 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
| 109 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
| 110 | 110 | |
| 111 | 111 | } |
| 112 | 112 | |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | * Define plugin constants. |
| 115 | 115 | */ |
| 116 | 116 | public function define_constants() { |
| 117 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
| 118 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
| 117 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
| 118 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
| 119 | 119 | $this->version = WPINV_VERSION; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -126,27 +126,27 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | protected function init_hooks() { |
| 128 | 128 | /* Internationalize the text strings used. */ |
| 129 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
| 129 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
| 130 | 130 | |
| 131 | 131 | // Init the plugin after WordPress inits. |
| 132 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
| 133 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
| 134 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
| 135 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
| 132 | + add_action('init', array($this, 'init'), 1); |
|
| 133 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
| 134 | + add_action('init', array($this, 'wpinv_actions')); |
|
| 135 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
| 136 | 136 | |
| 137 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 138 | - add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) ); |
|
| 137 | + if (class_exists('BuddyPress')) { |
|
| 138 | + add_action('bp_include', array(&$this, 'bp_invoicing_init')); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) ); |
|
| 142 | - add_action( 'wp_footer', array( &$this, 'wp_footer' ) ); |
|
| 143 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
| 144 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
| 145 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
| 141 | + add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts')); |
|
| 142 | + add_action('wp_footer', array(&$this, 'wp_footer')); |
|
| 143 | + add_action('widgets_init', array(&$this, 'register_widgets')); |
|
| 144 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
| 145 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
| 146 | 146 | |
| 147 | 147 | // Fires after registering actions. |
| 148 | - do_action( 'wpinv_actions', $this ); |
|
| 149 | - do_action( 'getpaid_actions', $this ); |
|
| 148 | + do_action('wpinv_actions', $this); |
|
| 149 | + do_action('getpaid_actions', $this); |
|
| 150 | 150 | |
| 151 | 151 | } |
| 152 | 152 | |
@@ -154,10 +154,10 @@ discard block |
||
| 154 | 154 | /* Internationalize the text strings used. */ |
| 155 | 155 | $this->load_textdomain(); |
| 156 | 156 | |
| 157 | - do_action( 'wpinv_loaded' ); |
|
| 157 | + do_action('wpinv_loaded'); |
|
| 158 | 158 | |
| 159 | 159 | // Fix oxygen page builder conflict |
| 160 | - if ( function_exists( 'ct_css_output' ) ) { |
|
| 160 | + if (function_exists('ct_css_output')) { |
|
| 161 | 161 | wpinv_oxygen_fix_conflict(); |
| 162 | 162 | } |
| 163 | 163 | } |
@@ -167,21 +167,21 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @since 1.0 |
| 169 | 169 | */ |
| 170 | - public function load_textdomain( $locale = NULL ) { |
|
| 171 | - if ( empty( $locale ) ) { |
|
| 172 | - $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); |
|
| 170 | + public function load_textdomain($locale = NULL) { |
|
| 171 | + if (empty($locale)) { |
|
| 172 | + $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale(); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' ); |
|
| 175 | + $locale = apply_filters('plugin_locale', $locale, 'invoicing'); |
|
| 176 | 176 | |
| 177 | - unload_textdomain( 'invoicing' ); |
|
| 178 | - load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' ); |
|
| 179 | - load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' ); |
|
| 177 | + unload_textdomain('invoicing'); |
|
| 178 | + load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo'); |
|
| 179 | + load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages'); |
|
| 180 | 180 | |
| 181 | 181 | /** |
| 182 | 182 | * Define language constants. |
| 183 | 183 | */ |
| 184 | - require_once( WPINV_PLUGIN_DIR . 'language.php' ); |
|
| 184 | + require_once(WPINV_PLUGIN_DIR . 'language.php'); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -190,89 +190,89 @@ discard block |
||
| 190 | 190 | public function includes() { |
| 191 | 191 | |
| 192 | 192 | // Start with the settings. |
| 193 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
| 193 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php'); |
|
| 194 | 194 | |
| 195 | 195 | // Packages/libraries. |
| 196 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
| 197 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
| 196 | + require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php'); |
|
| 197 | + require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php'); |
|
| 198 | 198 | |
| 199 | 199 | // Load functions. |
| 200 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
| 201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
| 202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
| 203 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
| 204 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
| 205 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
| 206 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
| 207 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
| 208 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
| 209 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
| 210 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
| 211 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
| 212 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
| 213 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' ); |
|
| 214 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
| 200 | + require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php'); |
|
| 201 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php'); |
|
| 202 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php'); |
|
| 203 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php'); |
|
| 204 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php'); |
|
| 205 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php'); |
|
| 206 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php'); |
|
| 207 | + require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php'); |
|
| 208 | + require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php'); |
|
| 209 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php'); |
|
| 210 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php'); |
|
| 211 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php'); |
|
| 212 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php'); |
|
| 213 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php'); |
|
| 214 | + require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php'); |
|
| 215 | 215 | |
| 216 | 216 | // Register autoloader. |
| 217 | 217 | try { |
| 218 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
| 219 | - } catch ( Exception $e ) { |
|
| 220 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
| 218 | + spl_autoload_register(array($this, 'autoload'), true); |
|
| 219 | + } catch (Exception $e) { |
|
| 220 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
| 224 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
| 225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
| 226 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
| 227 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
| 228 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
| 229 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
| 230 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
| 231 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
| 232 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
| 233 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
| 234 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
| 235 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
| 236 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
| 237 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
| 238 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
| 239 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
| 240 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
| 241 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
| 242 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
| 223 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'); |
|
| 224 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php'); |
|
| 225 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php'); |
|
| 226 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php'); |
|
| 227 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php'); |
|
| 228 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php'); |
|
| 229 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php'); |
|
| 230 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php'); |
|
| 231 | + require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php'); |
|
| 232 | + require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php'); |
|
| 233 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php'); |
|
| 234 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php'); |
|
| 235 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php'); |
|
| 236 | + require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php'); |
|
| 237 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php'); |
|
| 238 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php'); |
|
| 239 | + require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php'); |
|
| 240 | + require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php'); |
|
| 241 | + require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php'); |
|
| 242 | + require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php'); |
|
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | 245 | * Load the tax class. |
| 246 | 246 | */ |
| 247 | - if ( ! class_exists( 'WPInv_EUVat' ) ) { |
|
| 248 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
| 247 | + if (!class_exists('WPInv_EUVat')) { |
|
| 248 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
| 251 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
| 252 | 252 | GetPaid_Post_Types_Admin::init(); |
| 253 | 253 | |
| 254 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
| 255 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
| 256 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
| 257 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
| 258 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
| 259 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
| 260 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
| 261 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
| 254 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
| 255 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
| 256 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php'); |
|
| 257 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
| 258 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
| 259 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
| 260 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
| 261 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'); |
|
| 262 | 262 | // load the user class only on the users.php page |
| 263 | 263 | global $pagenow; |
| 264 | - if($pagenow=='users.php'){ |
|
| 264 | + if ($pagenow == 'users.php') { |
|
| 265 | 265 | new WPInv_Admin_Users(); |
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // Register cli commands |
| 270 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
| 271 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
| 272 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
| 270 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 271 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'); |
|
| 272 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
| 275 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -283,21 +283,21 @@ discard block |
||
| 283 | 283 | * @since 1.0.19 |
| 284 | 284 | * @return void |
| 285 | 285 | */ |
| 286 | - public function autoload( $class_name ) { |
|
| 286 | + public function autoload($class_name) { |
|
| 287 | 287 | |
| 288 | 288 | // Normalize the class name... |
| 289 | - $class_name = strtolower( $class_name ); |
|
| 289 | + $class_name = strtolower($class_name); |
|
| 290 | 290 | |
| 291 | 291 | // ... and make sure it is our class. |
| 292 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
| 292 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
| 293 | 293 | return; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | // Next, prepare the file name from the class. |
| 297 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
| 297 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
| 298 | 298 | |
| 299 | 299 | // Base path of the classes. |
| 300 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
| 300 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
| 301 | 301 | |
| 302 | 302 | // And an array of possible locations in order of importance. |
| 303 | 303 | $locations = array( |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | "$plugin_path/includes/admin/meta-boxes", |
| 313 | 313 | ); |
| 314 | 314 | |
| 315 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
| 315 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
| 316 | 316 | |
| 317 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
| 318 | - include trailingslashit( $location ) . $file_name; |
|
| 317 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
| 318 | + include trailingslashit($location) . $file_name; |
|
| 319 | 319 | break; |
| 320 | 320 | } |
| 321 | 321 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | public function init() { |
| 330 | 330 | |
| 331 | 331 | // Fires before getpaid inits. |
| 332 | - do_action( 'before_getpaid_init', $this ); |
|
| 332 | + do_action('before_getpaid_init', $this); |
|
| 333 | 333 | |
| 334 | 334 | // Load default gateways. |
| 335 | 335 | $gateways = apply_filters( |
@@ -343,12 +343,12 @@ discard block |
||
| 343 | 343 | ) |
| 344 | 344 | ); |
| 345 | 345 | |
| 346 | - foreach ( $gateways as $id => $class ) { |
|
| 347 | - $this->gateways[ $id ] = new $class(); |
|
| 346 | + foreach ($gateways as $id => $class) { |
|
| 347 | + $this->gateways[$id] = new $class(); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | // Fires after getpaid inits. |
| 351 | - do_action( 'getpaid_init', $this ); |
|
| 351 | + do_action('getpaid_init', $this); |
|
| 352 | 352 | |
| 353 | 353 | } |
| 354 | 354 | |
@@ -358,55 +358,55 @@ discard block |
||
| 358 | 358 | public function maybe_process_ipn() { |
| 359 | 359 | |
| 360 | 360 | // Ensure that this is an IPN request. |
| 361 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
| 361 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
| 362 | 362 | return; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
| 365 | + $gateway = wpinv_clean($_GET['wpi-gateway']); |
|
| 366 | 366 | |
| 367 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
| 368 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
| 367 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
| 368 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
| 369 | 369 | exit; |
| 370 | 370 | |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | public function enqueue_scripts() { |
| 374 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 374 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 375 | 375 | |
| 376 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' ); |
|
| 377 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version ); |
|
| 378 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
| 376 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css'); |
|
| 377 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version); |
|
| 378 | + wp_enqueue_style('wpinv_front_style'); |
|
| 379 | 379 | |
| 380 | 380 | // Register scripts |
| 381 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
| 382 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) ); |
|
| 381 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
| 382 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js')); |
|
| 383 | 383 | |
| 384 | 384 | $localize = array(); |
| 385 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
| 386 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
| 387 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
| 385 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
| 386 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
| 387 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
| 388 | 388 | $localize['UseTaxes'] = wpinv_use_taxes(); |
| 389 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
| 390 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
| 391 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
| 389 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
| 390 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
| 391 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
| 392 | 392 | |
| 393 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
| 393 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
| 394 | 394 | |
| 395 | - wp_enqueue_script( 'jquery-blockui' ); |
|
| 395 | + wp_enqueue_script('jquery-blockui'); |
|
| 396 | 396 | |
| 397 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all' ); |
|
| 398 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
| 397 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), WPINV_VERSION, 'all'); |
|
| 398 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
| 399 | 399 | |
| 400 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
| 401 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
| 400 | + wp_enqueue_script('wpinv-front-script'); |
|
| 401 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
| 402 | 402 | |
| 403 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
| 404 | - wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ), $version, true ); |
|
| 403 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
| 404 | + wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | public function wpinv_actions() { |
| 408 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
| 409 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
| 408 | + if (isset($_REQUEST['wpi_action'])) { |
|
| 409 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | |
@@ -418,31 +418,31 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | public function maybe_do_authenticated_action() { |
| 420 | 420 | |
| 421 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
| 421 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
| 422 | 422 | |
| 423 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
| 424 | - if ( is_user_logged_in() ) { |
|
| 425 | - do_action( "getpaid_authenticated_action_$key", $_REQUEST ); |
|
| 423 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
| 424 | + if (is_user_logged_in()) { |
|
| 425 | + do_action("getpaid_authenticated_action_$key", $_REQUEST); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - do_action( "getpaid_unauthenticated_action_$key", $_REQUEST ); |
|
| 428 | + do_action("getpaid_unauthenticated_action_$key", $_REQUEST); |
|
| 429 | 429 | |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | - public function pre_get_posts( $wp_query ) { |
|
| 435 | + public function pre_get_posts($wp_query) { |
|
| 436 | 436 | |
| 437 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
| 438 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
| 437 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
| 438 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | return $wp_query; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | public function bp_invoicing_init() { |
| 445 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
| 445 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /** |
@@ -463,8 +463,8 @@ discard block |
||
| 463 | 463 | ) |
| 464 | 464 | ); |
| 465 | 465 | |
| 466 | - foreach ( $widgets as $widget ) { |
|
| 467 | - register_widget( $widget ); |
|
| 466 | + foreach ($widgets as $widget) { |
|
| 467 | + register_widget($widget); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | } |
@@ -475,10 +475,10 @@ discard block |
||
| 475 | 475 | * @since 1.0.19 |
| 476 | 476 | * @param int[] $excluded_posts_ids |
| 477 | 477 | */ |
| 478 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
| 478 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
| 479 | 479 | |
| 480 | 480 | // Ensure that we have an array. |
| 481 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
| 481 | + if (!is_array($excluded_posts_ids)) { |
|
| 482 | 482 | $excluded_posts_ids = array(); |
| 483 | 483 | } |
| 484 | 484 | |
@@ -486,24 +486,24 @@ discard block |
||
| 486 | 486 | $our_pages = array(); |
| 487 | 487 | |
| 488 | 488 | // Checkout page. |
| 489 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
| 489 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
| 490 | 490 | |
| 491 | 491 | // Success page. |
| 492 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
| 492 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
| 493 | 493 | |
| 494 | 494 | // Failure page. |
| 495 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
| 495 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
| 496 | 496 | |
| 497 | 497 | // History page. |
| 498 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
| 498 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
| 499 | 499 | |
| 500 | 500 | // Subscriptions page. |
| 501 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
| 501 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
| 502 | 502 | |
| 503 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
| 503 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
| 504 | 504 | |
| 505 | 505 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
| 506 | - return array_unique( $excluded_posts_ids ); |
|
| 506 | + return array_unique($excluded_posts_ids); |
|
| 507 | 507 | |
| 508 | 508 | } |
| 509 | 509 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | <div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;"> |
| 515 | 515 | <div class="modal-content"> |
| 516 | 516 | <div class="modal-body"> |
| 517 | - <button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="' . esc_attr__( 'Close', 'invoicing' ) . '"> |
|
| 517 | + <button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="' . esc_attr__('Close', 'invoicing') . '"> |
|
| 518 | 518 | <i class="fa fa-times" aria-hidden="true"></i> |
| 519 | 519 | </button> |
| 520 | 520 | <div class="modal-body-wrapper"></div> |
@@ -4,99 +4,99 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Displays an invoice. |
| 11 | 11 | * |
| 12 | 12 | * @param WPInv_Invoice $invoice. |
| 13 | 13 | */ |
| 14 | -function getpaid_invoice( $invoice ) { |
|
| 15 | - if ( ! empty( $invoice ) ) { |
|
| 16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
| 14 | +function getpaid_invoice($invoice) { |
|
| 15 | + if (!empty($invoice)) { |
|
| 16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
| 17 | 17 | } |
| 18 | 18 | } |
| 19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
| 19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Displays the invoice footer. |
| 23 | 23 | */ |
| 24 | -function getpaid_invoice_footer( $invoice ) { |
|
| 25 | - if ( ! empty( $invoice ) ) { |
|
| 26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
| 24 | +function getpaid_invoice_footer($invoice) { |
|
| 25 | + if (!empty($invoice)) { |
|
| 26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
| 29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * Displays the invoice top bar. |
| 33 | 33 | */ |
| 34 | -function getpaid_invoice_header( $invoice ) { |
|
| 35 | - if ( ! empty( $invoice ) ) { |
|
| 36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
| 34 | +function getpaid_invoice_header($invoice) { |
|
| 35 | + if (!empty($invoice)) { |
|
| 36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
| 39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Displays actions on the left side of the header. |
| 43 | 43 | */ |
| 44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
| 45 | - if ( ! empty( $invoice ) ) { |
|
| 46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
| 44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
| 45 | + if (!empty($invoice)) { |
|
| 46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
| 49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Displays actions on the right side of the invoice top bar. |
| 53 | 53 | */ |
| 54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
| 55 | - if ( ! empty( $invoice ) ) { |
|
| 56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
| 54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
| 55 | + if (!empty($invoice)) { |
|
| 56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
| 59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * Displays the invoice title, watermark, logo etc. |
| 63 | 63 | */ |
| 64 | -function getpaid_invoice_details_top( $invoice ) { |
|
| 65 | - if ( ! empty( $invoice ) ) { |
|
| 66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
| 64 | +function getpaid_invoice_details_top($invoice) { |
|
| 65 | + if (!empty($invoice)) { |
|
| 66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
| 69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Displays the company logo. |
| 73 | 73 | */ |
| 74 | -function getpaid_invoice_logo( $invoice ) { |
|
| 75 | - if ( ! empty( $invoice ) ) { |
|
| 76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
| 74 | +function getpaid_invoice_logo($invoice) { |
|
| 75 | + if (!empty($invoice)) { |
|
| 76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
| 79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * Displays the type of invoice. |
| 83 | 83 | */ |
| 84 | -function getpaid_invoice_type( $invoice ) { |
|
| 85 | - if ( ! empty( $invoice ) ) { |
|
| 86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
| 84 | +function getpaid_invoice_type($invoice) { |
|
| 85 | + if (!empty($invoice)) { |
|
| 86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
| 89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Displays the invoice details. |
| 93 | 93 | */ |
| 94 | -function getpaid_invoice_details_main( $invoice ) { |
|
| 95 | - if ( ! empty( $invoice ) ) { |
|
| 96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
| 94 | +function getpaid_invoice_details_main($invoice) { |
|
| 95 | + if (!empty($invoice)) { |
|
| 96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
| 99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
| 125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 127 | 127 | */ |
| 128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 129 | - return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
| 128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 129 | + return getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 141 | 141 | */ |
| 142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
| 142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
| 143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @return string |
| 150 | 150 | */ |
| 151 | 151 | function wpinv_template_path() { |
| 152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
| 152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @return string |
| 159 | 159 | */ |
| 160 | 160 | function wpinv_get_theme_template_dir_name() { |
| 161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
| 161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -170,56 +170,56 @@ discard block |
||
| 170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
| 171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 172 | 172 | */ |
| 173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
| 173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
| 174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
| 178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
| 178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
| 179 | 179 | |
| 180 | 180 | // Setup possible parts |
| 181 | 181 | $templates = array(); |
| 182 | - if ( isset( $name ) ) |
|
| 182 | + if (isset($name)) |
|
| 183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
| 184 | 184 | $templates[] = $slug . '.php'; |
| 185 | 185 | |
| 186 | 186 | // Allow template parts to be filtered |
| 187 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 187 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
| 188 | 188 | |
| 189 | 189 | // Return the part that is found |
| 190 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 190 | + return wpinv_locate_tmpl($templates, $load, false); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
| 193 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
| 194 | 194 | // No file found yet |
| 195 | 195 | $located = false; |
| 196 | 196 | |
| 197 | 197 | // Try to find a template file |
| 198 | - foreach ( (array)$template_names as $template_name ) { |
|
| 198 | + foreach ((array) $template_names as $template_name) { |
|
| 199 | 199 | |
| 200 | 200 | // Continue if template is empty |
| 201 | - if ( empty( $template_name ) ) |
|
| 201 | + if (empty($template_name)) |
|
| 202 | 202 | continue; |
| 203 | 203 | |
| 204 | 204 | // Trim off any slashes from the template name |
| 205 | - $template_name = ltrim( $template_name, '/' ); |
|
| 205 | + $template_name = ltrim($template_name, '/'); |
|
| 206 | 206 | |
| 207 | 207 | // try locating this template file by looping through the template paths |
| 208 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 208 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
| 209 | 209 | |
| 210 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 210 | + if (file_exists($template_path . $template_name)) { |
|
| 211 | 211 | $located = $template_path . $template_name; |
| 212 | 212 | break; |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if( !empty( $located ) ) { |
|
| 216 | + if (!empty($located)) { |
|
| 217 | 217 | break; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 222 | - load_template( $located, $require_once ); |
|
| 221 | + if ((true == $load) && !empty($located)) |
|
| 222 | + load_template($located, $require_once); |
|
| 223 | 223 | |
| 224 | 224 | return $located; |
| 225 | 225 | } |
@@ -228,127 +228,127 @@ discard block |
||
| 228 | 228 | $template_dir = wpinv_get_theme_template_dir_name(); |
| 229 | 229 | |
| 230 | 230 | $file_paths = array( |
| 231 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 232 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 231 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
| 232 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
| 233 | 233 | 100 => wpinv_get_templates_dir() |
| 234 | 234 | ); |
| 235 | 235 | |
| 236 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 236 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
| 237 | 237 | |
| 238 | 238 | // sort the file paths based on priority |
| 239 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 239 | + ksort($file_paths, SORT_NUMERIC); |
|
| 240 | 240 | |
| 241 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 241 | + return array_map('trailingslashit', $file_paths); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | function wpinv_checkout_meta_tags() { |
| 245 | 245 | |
| 246 | 246 | $pages = array(); |
| 247 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 248 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 249 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 250 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
| 247 | + $pages[] = wpinv_get_option('success_page'); |
|
| 248 | + $pages[] = wpinv_get_option('failure_page'); |
|
| 249 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
| 250 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
| 251 | 251 | |
| 252 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 252 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
| 253 | 253 | return; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
| 257 | 257 | } |
| 258 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
| 258 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
| 259 | 259 | |
| 260 | -function wpinv_add_body_classes( $class ) { |
|
| 261 | - $classes = (array)$class; |
|
| 260 | +function wpinv_add_body_classes($class) { |
|
| 261 | + $classes = (array) $class; |
|
| 262 | 262 | |
| 263 | - if( wpinv_is_checkout() ) { |
|
| 263 | + if (wpinv_is_checkout()) { |
|
| 264 | 264 | $classes[] = 'wpinv-checkout'; |
| 265 | 265 | $classes[] = 'wpinv-page'; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if( wpinv_is_success_page() ) { |
|
| 268 | + if (wpinv_is_success_page()) { |
|
| 269 | 269 | $classes[] = 'wpinv-success'; |
| 270 | 270 | $classes[] = 'wpinv-page'; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 273 | + if (wpinv_is_failed_transaction_page()) { |
|
| 274 | 274 | $classes[] = 'wpinv-failed-transaction'; |
| 275 | 275 | $classes[] = 'wpinv-page'; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - if( wpinv_is_invoice_history_page() ) { |
|
| 278 | + if (wpinv_is_invoice_history_page()) { |
|
| 279 | 279 | $classes[] = 'wpinv-history'; |
| 280 | 280 | $classes[] = 'wpinv-page'; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if( wpinv_is_subscriptions_history_page() ) { |
|
| 283 | + if (wpinv_is_subscriptions_history_page()) { |
|
| 284 | 284 | $classes[] = 'wpinv-subscription'; |
| 285 | 285 | $classes[] = 'wpinv-page'; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if( wpinv_is_test_mode() ) { |
|
| 288 | + if (wpinv_is_test_mode()) { |
|
| 289 | 289 | $classes[] = 'wpinv-test-mode'; |
| 290 | 290 | $classes[] = 'wpinv-page'; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - return array_unique( $classes ); |
|
| 293 | + return array_unique($classes); |
|
| 294 | 294 | } |
| 295 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
| 295 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
| 296 | 296 | |
| 297 | -function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
| 298 | - $current = date( 'Y' ); |
|
| 299 | - $start_year = $current - absint( $years_before ); |
|
| 300 | - $end_year = $current + absint( $years_after ); |
|
| 301 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
| 297 | +function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
| 298 | + $current = date('Y'); |
|
| 299 | + $start_year = $current - absint($years_before); |
|
| 300 | + $end_year = $current + absint($years_after); |
|
| 301 | + $selected = empty($selected) ? date('Y') : $selected; |
|
| 302 | 302 | $options = array(); |
| 303 | 303 | |
| 304 | - while ( $start_year <= $end_year ) { |
|
| 305 | - $options[ absint( $start_year ) ] = $start_year; |
|
| 304 | + while ($start_year <= $end_year) { |
|
| 305 | + $options[absint($start_year)] = $start_year; |
|
| 306 | 306 | $start_year++; |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | - $output = wpinv_html_select( array( |
|
| 309 | + $output = wpinv_html_select(array( |
|
| 310 | 310 | 'name' => $name, |
| 311 | 311 | 'selected' => $selected, |
| 312 | 312 | 'options' => $options, |
| 313 | 313 | 'show_option_all' => false, |
| 314 | 314 | 'show_option_none' => false |
| 315 | - ) ); |
|
| 315 | + )); |
|
| 316 | 316 | |
| 317 | 317 | return $output; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | -function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) { |
|
| 320 | +function wpinv_html_month_dropdown($name = 'month', $selected = 0) { |
|
| 321 | 321 | |
| 322 | 322 | $options = array( |
| 323 | - '1' => __( 'January', 'invoicing' ), |
|
| 324 | - '2' => __( 'February', 'invoicing' ), |
|
| 325 | - '3' => __( 'March', 'invoicing' ), |
|
| 326 | - '4' => __( 'April', 'invoicing' ), |
|
| 327 | - '5' => __( 'May', 'invoicing' ), |
|
| 328 | - '6' => __( 'June', 'invoicing' ), |
|
| 329 | - '7' => __( 'July', 'invoicing' ), |
|
| 330 | - '8' => __( 'August', 'invoicing' ), |
|
| 331 | - '9' => __( 'September', 'invoicing' ), |
|
| 332 | - '10' => __( 'October', 'invoicing' ), |
|
| 333 | - '11' => __( 'November', 'invoicing' ), |
|
| 334 | - '12' => __( 'December', 'invoicing' ), |
|
| 323 | + '1' => __('January', 'invoicing'), |
|
| 324 | + '2' => __('February', 'invoicing'), |
|
| 325 | + '3' => __('March', 'invoicing'), |
|
| 326 | + '4' => __('April', 'invoicing'), |
|
| 327 | + '5' => __('May', 'invoicing'), |
|
| 328 | + '6' => __('June', 'invoicing'), |
|
| 329 | + '7' => __('July', 'invoicing'), |
|
| 330 | + '8' => __('August', 'invoicing'), |
|
| 331 | + '9' => __('September', 'invoicing'), |
|
| 332 | + '10' => __('October', 'invoicing'), |
|
| 333 | + '11' => __('November', 'invoicing'), |
|
| 334 | + '12' => __('December', 'invoicing'), |
|
| 335 | 335 | ); |
| 336 | 336 | |
| 337 | 337 | // If no month is selected, default to the current month |
| 338 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
| 338 | + $selected = empty($selected) ? date('n') : $selected; |
|
| 339 | 339 | |
| 340 | - $output = wpinv_html_select( array( |
|
| 340 | + $output = wpinv_html_select(array( |
|
| 341 | 341 | 'name' => $name, |
| 342 | 342 | 'selected' => $selected, |
| 343 | 343 | 'options' => $options, |
| 344 | 344 | 'show_option_all' => false, |
| 345 | 345 | 'show_option_none' => false |
| 346 | - ) ); |
|
| 346 | + )); |
|
| 347 | 347 | |
| 348 | 348 | return $output; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | -function wpinv_html_select( $args = array() ) { |
|
| 351 | +function wpinv_html_select($args = array()) { |
|
| 352 | 352 | $defaults = array( |
| 353 | 353 | 'options' => array(), |
| 354 | 354 | 'name' => null, |
@@ -357,8 +357,8 @@ discard block |
||
| 357 | 357 | 'selected' => 0, |
| 358 | 358 | 'placeholder' => null, |
| 359 | 359 | 'multiple' => false, |
| 360 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
| 361 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
| 360 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
| 361 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
| 362 | 362 | 'data' => array(), |
| 363 | 363 | 'onchange' => null, |
| 364 | 364 | 'required' => false, |
@@ -366,74 +366,74 @@ discard block |
||
| 366 | 366 | 'readonly' => false, |
| 367 | 367 | ); |
| 368 | 368 | |
| 369 | - $args = wp_parse_args( $args, $defaults ); |
|
| 369 | + $args = wp_parse_args($args, $defaults); |
|
| 370 | 370 | |
| 371 | 371 | $data_elements = ''; |
| 372 | - foreach ( $args['data'] as $key => $value ) { |
|
| 373 | - $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
| 372 | + foreach ($args['data'] as $key => $value) { |
|
| 373 | + $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if( $args['multiple'] ) { |
|
| 376 | + if ($args['multiple']) { |
|
| 377 | 377 | $multiple = ' MULTIPLE'; |
| 378 | 378 | } else { |
| 379 | 379 | $multiple = ''; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if( $args['placeholder'] ) { |
|
| 382 | + if ($args['placeholder']) { |
|
| 383 | 383 | $placeholder = $args['placeholder']; |
| 384 | 384 | } else { |
| 385 | 385 | $placeholder = ''; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | $options = ''; |
| 389 | - if( !empty( $args['onchange'] ) ) { |
|
| 390 | - $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
|
| 389 | + if (!empty($args['onchange'])) { |
|
| 390 | + $options .= ' onchange="' . esc_attr($args['onchange']) . '"'; |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - if( !empty( $args['required'] ) ) { |
|
| 393 | + if (!empty($args['required'])) { |
|
| 394 | 394 | $options .= ' required="required"'; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - if( !empty( $args['disabled'] ) ) { |
|
| 397 | + if (!empty($args['disabled'])) { |
|
| 398 | 398 | $options .= ' disabled'; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - if( !empty( $args['readonly'] ) ) { |
|
| 401 | + if (!empty($args['readonly'])) { |
|
| 402 | 402 | $options .= ' readonly'; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 406 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>'; |
|
| 405 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 406 | + $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>'; |
|
| 407 | 407 | |
| 408 | - if ( $args['show_option_all'] ) { |
|
| 409 | - if( $args['multiple'] ) { |
|
| 410 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
| 408 | + if ($args['show_option_all']) { |
|
| 409 | + if ($args['multiple']) { |
|
| 410 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
| 411 | 411 | } else { |
| 412 | - $selected = selected( $args['selected'], 0, false ); |
|
| 412 | + $selected = selected($args['selected'], 0, false); |
|
| 413 | 413 | } |
| 414 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
| 414 | + $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - if ( !empty( $args['options'] ) ) { |
|
| 417 | + if (!empty($args['options'])) { |
|
| 418 | 418 | |
| 419 | - if ( $args['show_option_none'] ) { |
|
| 420 | - if( $args['multiple'] ) { |
|
| 421 | - $selected = selected( true, in_array( "", $args['selected'] ), false ); |
|
| 419 | + if ($args['show_option_none']) { |
|
| 420 | + if ($args['multiple']) { |
|
| 421 | + $selected = selected(true, in_array("", $args['selected']), false); |
|
| 422 | 422 | } else { |
| 423 | - $selected = selected( $args['selected'] === "", true, false ); |
|
| 423 | + $selected = selected($args['selected'] === "", true, false); |
|
| 424 | 424 | } |
| 425 | - $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
| 425 | + $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - foreach( $args['options'] as $key => $option ) { |
|
| 428 | + foreach ($args['options'] as $key => $option) { |
|
| 429 | 429 | |
| 430 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
| 431 | - $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false ); |
|
| 430 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
| 431 | + $selected = selected(true, (bool) in_array($key, $args['selected']), false); |
|
| 432 | 432 | } else { |
| 433 | - $selected = selected( $args['selected'], $key, false ); |
|
| 433 | + $selected = selected($args['selected'], $key, false); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
| 436 | + $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>'; |
|
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | return $output; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | -function wpinv_item_dropdown( $args = array() ) { |
|
| 445 | +function wpinv_item_dropdown($args = array()) { |
|
| 446 | 446 | $defaults = array( |
| 447 | 447 | 'name' => 'wpi_item', |
| 448 | 448 | 'id' => 'wpi_item', |
@@ -450,14 +450,14 @@ discard block |
||
| 450 | 450 | 'multiple' => false, |
| 451 | 451 | 'selected' => 0, |
| 452 | 452 | 'number' => 100, |
| 453 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
| 454 | - 'data' => array( 'search-type' => 'item' ), |
|
| 453 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
| 454 | + 'data' => array('search-type' => 'item'), |
|
| 455 | 455 | 'show_option_all' => false, |
| 456 | 456 | 'show_option_none' => false, |
| 457 | 457 | 'show_recurring' => false, |
| 458 | 458 | ); |
| 459 | 459 | |
| 460 | - $args = wp_parse_args( $args, $defaults ); |
|
| 460 | + $args = wp_parse_args($args, $defaults); |
|
| 461 | 461 | |
| 462 | 462 | $item_args = array( |
| 463 | 463 | 'post_type' => 'wpi_item', |
@@ -466,44 +466,44 @@ discard block |
||
| 466 | 466 | 'posts_per_page' => $args['number'] |
| 467 | 467 | ); |
| 468 | 468 | |
| 469 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
| 469 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
| 470 | 470 | |
| 471 | - $items = get_posts( $item_args ); |
|
| 471 | + $items = get_posts($item_args); |
|
| 472 | 472 | $options = array(); |
| 473 | - if ( $items ) { |
|
| 474 | - foreach ( $items as $item ) { |
|
| 475 | - $title = esc_html( $item->post_title ); |
|
| 473 | + if ($items) { |
|
| 474 | + foreach ($items as $item) { |
|
| 475 | + $title = esc_html($item->post_title); |
|
| 476 | 476 | |
| 477 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 478 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
| 477 | + if (!empty($args['show_recurring'])) { |
|
| 478 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - $options[ absint( $item->ID ) ] = $title; |
|
| 481 | + $options[absint($item->ID)] = $title; |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | // This ensures that any selected items are included in the drop down |
| 486 | - if( is_array( $args['selected'] ) ) { |
|
| 487 | - foreach( $args['selected'] as $item ) { |
|
| 488 | - if( ! in_array( $item, $options ) ) { |
|
| 489 | - $title = get_the_title( $item ); |
|
| 490 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 491 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
| 486 | + if (is_array($args['selected'])) { |
|
| 487 | + foreach ($args['selected'] as $item) { |
|
| 488 | + if (!in_array($item, $options)) { |
|
| 489 | + $title = get_the_title($item); |
|
| 490 | + if (!empty($args['show_recurring'])) { |
|
| 491 | + $title .= wpinv_get_item_suffix($item, false); |
|
| 492 | 492 | } |
| 493 | 493 | $options[$item] = $title; |
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
| 497 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
| 498 | - $title = get_the_title( $args['selected'] ); |
|
| 499 | - if ( !empty( $args['show_recurring'] ) ) { |
|
| 500 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
| 496 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
| 497 | + if (!in_array($args['selected'], $options)) { |
|
| 498 | + $title = get_the_title($args['selected']); |
|
| 499 | + if (!empty($args['show_recurring'])) { |
|
| 500 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
| 501 | 501 | } |
| 502 | - $options[$args['selected']] = get_the_title( $args['selected'] ); |
|
| 502 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - $output = wpinv_html_select( array( |
|
| 506 | + $output = wpinv_html_select(array( |
|
| 507 | 507 | 'name' => $args['name'], |
| 508 | 508 | 'selected' => $args['selected'], |
| 509 | 509 | 'id' => $args['id'], |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | 'show_option_all' => $args['show_option_all'], |
| 515 | 515 | 'show_option_none' => $args['show_option_none'], |
| 516 | 516 | 'data' => $args['data'], |
| 517 | - ) ); |
|
| 517 | + )); |
|
| 518 | 518 | |
| 519 | 519 | return $output; |
| 520 | 520 | } |
@@ -534,16 +534,16 @@ discard block |
||
| 534 | 534 | ); |
| 535 | 535 | |
| 536 | 536 | $options = array(); |
| 537 | - if ( $items ) { |
|
| 538 | - foreach ( $items as $item ) { |
|
| 539 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
| 537 | + if ($items) { |
|
| 538 | + foreach ($items as $item) { |
|
| 539 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | return $options; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | -function wpinv_html_checkbox( $args = array() ) { |
|
| 546 | +function wpinv_html_checkbox($args = array()) { |
|
| 547 | 547 | $defaults = array( |
| 548 | 548 | 'name' => null, |
| 549 | 549 | 'current' => null, |
@@ -554,17 +554,17 @@ discard block |
||
| 554 | 554 | ) |
| 555 | 555 | ); |
| 556 | 556 | |
| 557 | - $args = wp_parse_args( $args, $defaults ); |
|
| 557 | + $args = wp_parse_args($args, $defaults); |
|
| 558 | 558 | |
| 559 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 559 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 560 | 560 | $options = ''; |
| 561 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
| 561 | + if (!empty($args['options']['disabled'])) { |
|
| 562 | 562 | $options .= ' disabled="disabled"'; |
| 563 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
| 563 | + } elseif (!empty($args['options']['readonly'])) { |
|
| 564 | 564 | $options .= ' readonly'; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
| 567 | + $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
| 568 | 568 | |
| 569 | 569 | return $output; |
| 570 | 570 | } |
@@ -572,9 +572,9 @@ discard block |
||
| 572 | 572 | /** |
| 573 | 573 | * Displays a hidden field. |
| 574 | 574 | */ |
| 575 | -function getpaid_hidden_field( $name, $value ) { |
|
| 576 | - $name = sanitize_text_field( $name ); |
|
| 577 | - $value = esc_attr( $value ); |
|
| 575 | +function getpaid_hidden_field($name, $value) { |
|
| 576 | + $name = sanitize_text_field($name); |
|
| 577 | + $value = esc_attr($value); |
|
| 578 | 578 | |
| 579 | 579 | echo "<input type='hidden' name='$name' value='$value' />"; |
| 580 | 580 | } |
@@ -582,31 +582,31 @@ discard block |
||
| 582 | 582 | /** |
| 583 | 583 | * Displays a submit field. |
| 584 | 584 | */ |
| 585 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
| 586 | - $name = sanitize_text_field( $name ); |
|
| 587 | - $value = esc_attr( $value ); |
|
| 588 | - $class = esc_attr( $class ); |
|
| 585 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
| 586 | + $name = sanitize_text_field($name); |
|
| 587 | + $value = esc_attr($value); |
|
| 588 | + $class = esc_attr($class); |
|
| 589 | 589 | |
| 590 | 590 | echo "<input type='submit' name='$name' value='$value' class='btn $class' />"; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | -function wpinv_html_text( $args = array() ) { |
|
| 593 | +function wpinv_html_text($args = array()) { |
|
| 594 | 594 | // Backwards compatibility |
| 595 | - if ( func_num_args() > 1 ) { |
|
| 595 | + if (func_num_args() > 1) { |
|
| 596 | 596 | $args = func_get_args(); |
| 597 | 597 | |
| 598 | 598 | $name = $args[0]; |
| 599 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
| 600 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
| 601 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
| 599 | + $value = isset($args[1]) ? $args[1] : ''; |
|
| 600 | + $label = isset($args[2]) ? $args[2] : ''; |
|
| 601 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | $defaults = array( |
| 605 | 605 | 'id' => '', |
| 606 | - 'name' => isset( $name ) ? $name : 'text', |
|
| 607 | - 'value' => isset( $value ) ? $value : null, |
|
| 608 | - 'label' => isset( $label ) ? $label : null, |
|
| 609 | - 'desc' => isset( $desc ) ? $desc : null, |
|
| 606 | + 'name' => isset($name) ? $name : 'text', |
|
| 607 | + 'value' => isset($value) ? $value : null, |
|
| 608 | + 'label' => isset($label) ? $label : null, |
|
| 609 | + 'desc' => isset($desc) ? $desc : null, |
|
| 610 | 610 | 'placeholder' => '', |
| 611 | 611 | 'class' => 'regular-text', |
| 612 | 612 | 'disabled' => false, |
@@ -616,51 +616,51 @@ discard block |
||
| 616 | 616 | 'data' => false |
| 617 | 617 | ); |
| 618 | 618 | |
| 619 | - $args = wp_parse_args( $args, $defaults ); |
|
| 619 | + $args = wp_parse_args($args, $defaults); |
|
| 620 | 620 | |
| 621 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 621 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 622 | 622 | $options = ''; |
| 623 | - if( $args['required'] ) { |
|
| 623 | + if ($args['required']) { |
|
| 624 | 624 | $options .= ' required="required"'; |
| 625 | 625 | } |
| 626 | - if( $args['readonly'] ) { |
|
| 626 | + if ($args['readonly']) { |
|
| 627 | 627 | $options .= ' readonly'; |
| 628 | 628 | } |
| 629 | - if( $args['readonly'] ) { |
|
| 629 | + if ($args['readonly']) { |
|
| 630 | 630 | $options .= ' readonly'; |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | $data = ''; |
| 634 | - if ( !empty( $args['data'] ) ) { |
|
| 635 | - foreach ( $args['data'] as $key => $value ) { |
|
| 636 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
| 634 | + if (!empty($args['data'])) { |
|
| 635 | + foreach ($args['data'] as $key => $value) { |
|
| 636 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
| 637 | 637 | } |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 641 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 642 | - if ( ! empty( $args['desc'] ) ) { |
|
| 643 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 640 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 641 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 642 | + if (!empty($args['desc'])) { |
|
| 643 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
| 646 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
| 647 | 647 | |
| 648 | 648 | $output .= '</span>'; |
| 649 | 649 | |
| 650 | 650 | return $output; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | -function wpinv_html_date_field( $args = array() ) { |
|
| 654 | - if( empty( $args['class'] ) ) { |
|
| 653 | +function wpinv_html_date_field($args = array()) { |
|
| 654 | + if (empty($args['class'])) { |
|
| 655 | 655 | $args['class'] = 'wpiDatepicker'; |
| 656 | - } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) { |
|
| 656 | + } elseif (!strpos($args['class'], 'wpiDatepicker')) { |
|
| 657 | 657 | $args['class'] .= ' wpiDatepicker'; |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - return wpinv_html_text( $args ); |
|
| 660 | + return wpinv_html_text($args); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | -function wpinv_html_textarea( $args = array() ) { |
|
| 663 | +function wpinv_html_textarea($args = array()) { |
|
| 664 | 664 | $defaults = array( |
| 665 | 665 | 'name' => 'textarea', |
| 666 | 666 | 'value' => null, |
@@ -671,31 +671,31 @@ discard block |
||
| 671 | 671 | 'placeholder' => '', |
| 672 | 672 | ); |
| 673 | 673 | |
| 674 | - $args = wp_parse_args( $args, $defaults ); |
|
| 674 | + $args = wp_parse_args($args, $defaults); |
|
| 675 | 675 | |
| 676 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
| 676 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
| 677 | 677 | $disabled = ''; |
| 678 | - if( $args['disabled'] ) { |
|
| 678 | + if ($args['disabled']) { |
|
| 679 | 679 | $disabled = ' disabled="disabled"'; |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
| 683 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
| 684 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
| 682 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
| 683 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
| 684 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
| 685 | 685 | |
| 686 | - if ( ! empty( $args['desc'] ) ) { |
|
| 687 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
| 686 | + if (!empty($args['desc'])) { |
|
| 687 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
| 688 | 688 | } |
| 689 | 689 | $output .= '</span>'; |
| 690 | 690 | |
| 691 | 691 | return $output; |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
| 694 | +function wpinv_html_ajax_user_search($args = array()) { |
|
| 695 | 695 | $defaults = array( |
| 696 | 696 | 'name' => 'user_id', |
| 697 | 697 | 'value' => null, |
| 698 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
| 698 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
| 699 | 699 | 'label' => null, |
| 700 | 700 | 'desc' => null, |
| 701 | 701 | 'class' => '', |
@@ -704,13 +704,13 @@ discard block |
||
| 704 | 704 | 'data' => false |
| 705 | 705 | ); |
| 706 | 706 | |
| 707 | - $args = wp_parse_args( $args, $defaults ); |
|
| 707 | + $args = wp_parse_args($args, $defaults); |
|
| 708 | 708 | |
| 709 | 709 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
| 710 | 710 | |
| 711 | 711 | $output = '<span class="wpinv_user_search_wrap">'; |
| 712 | - $output .= wpinv_html_text( $args ); |
|
| 713 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
| 712 | + $output .= wpinv_html_text($args); |
|
| 713 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
| 714 | 714 | $output .= '</span>'; |
| 715 | 715 | |
| 716 | 716 | return $output; |
@@ -721,20 +721,20 @@ discard block |
||
| 721 | 721 | * |
| 722 | 722 | * @param string $template the template that is currently being used. |
| 723 | 723 | */ |
| 724 | -function wpinv_template( $template ) { |
|
| 724 | +function wpinv_template($template) { |
|
| 725 | 725 | global $post; |
| 726 | 726 | |
| 727 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
| 727 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
| 728 | 728 | |
| 729 | 729 | // If the user can view this invoice, display it. |
| 730 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
| 730 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
| 731 | 731 | |
| 732 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
| 732 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
| 733 | 733 | |
| 734 | 734 | // Else display an error message. |
| 735 | 735 | } else { |
| 736 | 736 | |
| 737 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
| 737 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
| 738 | 738 | |
| 739 | 739 | } |
| 740 | 740 | |
@@ -742,46 +742,46 @@ discard block |
||
| 742 | 742 | |
| 743 | 743 | return $template; |
| 744 | 744 | } |
| 745 | -add_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 745 | +add_filter('template_include', 'wpinv_template', 10, 1); |
|
| 746 | 746 | |
| 747 | 747 | function wpinv_get_business_address() { |
| 748 | 748 | $business_address = wpinv_store_address(); |
| 749 | - $business_address = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : ''; |
|
| 749 | + $business_address = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : ''; |
|
| 750 | 750 | |
| 751 | 751 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
| 752 | 752 | |
| 753 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
| 753 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
| 757 | 757 | * Displays the company address. |
| 758 | 758 | */ |
| 759 | 759 | function wpinv_display_from_address() { |
| 760 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
| 760 | + wpinv_get_template('invoice/company-address.php'); |
|
| 761 | 761 | } |
| 762 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
| 762 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
| 763 | 763 | |
| 764 | -function wpinv_watermark( $id = 0 ) { |
|
| 765 | - $output = wpinv_get_watermark( $id ); |
|
| 766 | - return apply_filters( 'wpinv_get_watermark', $output, $id ); |
|
| 764 | +function wpinv_watermark($id = 0) { |
|
| 765 | + $output = wpinv_get_watermark($id); |
|
| 766 | + return apply_filters('wpinv_get_watermark', $output, $id); |
|
| 767 | 767 | } |
| 768 | 768 | |
| 769 | -function wpinv_get_watermark( $id ) { |
|
| 770 | - if ( !$id > 0 ) { |
|
| 769 | +function wpinv_get_watermark($id) { |
|
| 770 | + if (!$id > 0) { |
|
| 771 | 771 | return NULL; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - $invoice = wpinv_get_invoice( $id ); |
|
| 774 | + $invoice = wpinv_get_invoice($id); |
|
| 775 | 775 | |
| 776 | - if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) { |
|
| 777 | - if ( $invoice->is_paid() ) { |
|
| 778 | - return __( 'Paid', 'invoicing' ); |
|
| 776 | + if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) { |
|
| 777 | + if ($invoice->is_paid()) { |
|
| 778 | + return __('Paid', 'invoicing'); |
|
| 779 | 779 | } |
| 780 | - if ( $invoice->is_refunded() ) { |
|
| 781 | - return __( 'Refunded', 'invoicing' ); |
|
| 780 | + if ($invoice->is_refunded()) { |
|
| 781 | + return __('Refunded', 'invoicing'); |
|
| 782 | 782 | } |
| 783 | - if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) { |
|
| 784 | - return __( 'Cancelled', 'invoicing' ); |
|
| 783 | + if ($invoice->has_status(array('wpi-cancelled'))) { |
|
| 784 | + return __('Cancelled', 'invoicing'); |
|
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | |
@@ -791,30 +791,30 @@ discard block |
||
| 791 | 791 | /** |
| 792 | 792 | * @deprecated |
| 793 | 793 | */ |
| 794 | -function wpinv_display_invoice_details( $invoice ) { |
|
| 795 | - return getpaid_invoice_meta( $invoice ); |
|
| 794 | +function wpinv_display_invoice_details($invoice) { |
|
| 795 | + return getpaid_invoice_meta($invoice); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | /** |
| 799 | 799 | * Displays invoice meta. |
| 800 | 800 | */ |
| 801 | -function getpaid_invoice_meta( $invoice ) { |
|
| 801 | +function getpaid_invoice_meta($invoice) { |
|
| 802 | 802 | |
| 803 | - $invoice = new WPInv_Invoice( $invoice ); |
|
| 803 | + $invoice = new WPInv_Invoice($invoice); |
|
| 804 | 804 | |
| 805 | 805 | // Ensure that we have an invoice. |
| 806 | - if ( 0 == $invoice->get_id() ) { |
|
| 806 | + if (0 == $invoice->get_id()) { |
|
| 807 | 807 | return; |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | // Get the invoice meta. |
| 811 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
| 811 | + $meta = getpaid_get_invoice_meta($invoice); |
|
| 812 | 812 | |
| 813 | 813 | // Display the meta. |
| 814 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
| 814 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
| 815 | 815 | |
| 816 | 816 | } |
| 817 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
| 817 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
| 818 | 818 | |
| 819 | 819 | /** |
| 820 | 820 | * Retrieves the address markup to use on Invoices. |
@@ -826,29 +826,29 @@ discard block |
||
| 826 | 826 | * @param string $separator How to separate address lines. |
| 827 | 827 | * @return string |
| 828 | 828 | */ |
| 829 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
| 829 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
| 830 | 830 | |
| 831 | 831 | // Retrieve the address markup... |
| 832 | - $country= empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
| 833 | - $format = wpinv_get_full_address_format( $country ); |
|
| 832 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
| 833 | + $format = wpinv_get_full_address_format($country); |
|
| 834 | 834 | |
| 835 | 835 | // ... and the replacements. |
| 836 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
| 836 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
| 837 | 837 | |
| 838 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
| 838 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
| 839 | 839 | |
| 840 | 840 | // Remove unavailable tags. |
| 841 | - $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
|
| 841 | + $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address); |
|
| 842 | 842 | |
| 843 | 843 | // Clean up white space. |
| 844 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
| 845 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
| 844 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
| 845 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
| 846 | 846 | |
| 847 | 847 | // Break newlines apart and remove empty lines/trim commas and white space. |
| 848 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
| 848 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
| 849 | 849 | |
| 850 | 850 | // Add html breaks. |
| 851 | - $formatted_address = implode( $separator, $formatted_address ); |
|
| 851 | + $formatted_address = implode($separator, $formatted_address); |
|
| 852 | 852 | |
| 853 | 853 | // We're done! |
| 854 | 854 | return $formatted_address; |
@@ -860,88 +860,88 @@ discard block |
||
| 860 | 860 | * |
| 861 | 861 | * @param WPInv_Invoice $invoice |
| 862 | 862 | */ |
| 863 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
| 864 | - if ( ! empty( $invoice ) ) { |
|
| 865 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
| 863 | +function wpinv_display_to_address($invoice = 0) { |
|
| 864 | + if (!empty($invoice)) { |
|
| 865 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
| 866 | 866 | } |
| 867 | 867 | } |
| 868 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
| 868 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
| 869 | 869 | |
| 870 | 870 | |
| 871 | 871 | /** |
| 872 | 872 | * Displays invoice line items. |
| 873 | 873 | */ |
| 874 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
| 874 | +function wpinv_display_line_items($invoice_id = 0) { |
|
| 875 | 875 | |
| 876 | 876 | // Prepare the invoice. |
| 877 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 877 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 878 | 878 | |
| 879 | 879 | // Abort if there is no invoice. |
| 880 | - if ( 0 == $invoice->get_id() ) { |
|
| 880 | + if (0 == $invoice->get_id()) { |
|
| 881 | 881 | return; |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | 884 | // Line item columns. |
| 885 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
| 886 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
| 885 | + $columns = getpaid_invoice_item_columns($invoice); |
|
| 886 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
| 887 | 887 | |
| 888 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
| 888 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
| 889 | 889 | } |
| 890 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
| 890 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
| 891 | 891 | |
| 892 | 892 | /** |
| 893 | 893 | * Displays invoice notices on invoices. |
| 894 | 894 | */ |
| 895 | 895 | function wpinv_display_invoice_notice() { |
| 896 | 896 | |
| 897 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
| 898 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
| 897 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
| 898 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
| 899 | 899 | |
| 900 | - if ( empty( $label ) && empty( $notice ) ) { |
|
| 900 | + if (empty($label) && empty($notice)) { |
|
| 901 | 901 | return; |
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
| 905 | 905 | |
| 906 | - if ( ! empty( $label ) ) { |
|
| 907 | - $label = sanitize_text_field( $label ); |
|
| 906 | + if (!empty($label)) { |
|
| 907 | + $label = sanitize_text_field($label); |
|
| 908 | 908 | echo "<h5>$label</h5>"; |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | - if ( ! empty( $notice ) ) { |
|
| 912 | - echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>'; |
|
| 911 | + if (!empty($notice)) { |
|
| 912 | + echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>'; |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | echo '</div>'; |
| 916 | 916 | } |
| 917 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
| 917 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
| 918 | 918 | |
| 919 | 919 | /** |
| 920 | 920 | * @param WPInv_Invoice $invoice |
| 921 | 921 | */ |
| 922 | -function wpinv_display_invoice_notes( $invoice ) { |
|
| 922 | +function wpinv_display_invoice_notes($invoice) { |
|
| 923 | 923 | |
| 924 | 924 | // Retrieve the notes. |
| 925 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
| 925 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
| 926 | 926 | |
| 927 | 927 | // Abort if we have non. |
| 928 | - if ( empty( $notes ) ) { |
|
| 928 | + if (empty($notes)) { |
|
| 929 | 929 | return; |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | // Echo the note. |
| 933 | 933 | echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">'; |
| 934 | - echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>'; |
|
| 934 | + echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>'; |
|
| 935 | 935 | echo '<ul class="getpaid-invoice-notes mt-4 p-0">'; |
| 936 | 936 | |
| 937 | - foreach( $notes as $note ) { |
|
| 938 | - wpinv_get_invoice_note_line_item( $note ); |
|
| 937 | + foreach ($notes as $note) { |
|
| 938 | + wpinv_get_invoice_note_line_item($note); |
|
| 939 | 939 | } |
| 940 | 940 | |
| 941 | 941 | echo '</ul>'; |
| 942 | 942 | echo '</div>'; |
| 943 | 943 | } |
| 944 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
| 944 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
| 945 | 945 | |
| 946 | 946 | /** |
| 947 | 947 | * Loads scripts on our invoice templates. |
@@ -949,32 +949,32 @@ discard block |
||
| 949 | 949 | function wpinv_display_style() { |
| 950 | 950 | |
| 951 | 951 | // Make sure that all scripts have been loaded. |
| 952 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
| 953 | - do_action( 'wp_enqueue_scripts' ); |
|
| 952 | + if (!did_action('wp_enqueue_scripts')) { |
|
| 953 | + do_action('wp_enqueue_scripts'); |
|
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | // Register the invoices style. |
| 957 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
| 957 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
| 958 | 958 | |
| 959 | 959 | // Load required styles |
| 960 | - wp_print_styles( 'open-sans' ); |
|
| 961 | - wp_print_styles( 'wpinv-single-style' ); |
|
| 962 | - wp_print_styles( 'ayecode-ui' ); |
|
| 960 | + wp_print_styles('open-sans'); |
|
| 961 | + wp_print_styles('wpinv-single-style'); |
|
| 962 | + wp_print_styles('ayecode-ui'); |
|
| 963 | 963 | |
| 964 | 964 | // Maybe load custom css. |
| 965 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
| 965 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
| 966 | 966 | |
| 967 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
| 968 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
| 969 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
| 967 | + if (isset($custom_css) && !empty($custom_css)) { |
|
| 968 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
| 969 | + $custom_css = str_replace('>', '>', $custom_css); |
|
| 970 | 970 | echo '<style type="text/css">'; |
| 971 | 971 | echo $custom_css; |
| 972 | 972 | echo '</style>'; |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | } |
| 976 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
| 977 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
| 976 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
| 977 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
| 978 | 978 | |
| 979 | 979 | |
| 980 | 980 | /** |
@@ -986,41 +986,41 @@ discard block |
||
| 986 | 986 | // Retrieve the current invoice. |
| 987 | 987 | $invoice_id = getpaid_get_current_invoice_id(); |
| 988 | 988 | |
| 989 | - if ( empty( $invoice_id ) ) { |
|
| 989 | + if (empty($invoice_id)) { |
|
| 990 | 990 | |
| 991 | 991 | return aui()->alert( |
| 992 | 992 | array( |
| 993 | 993 | 'type' => 'warning', |
| 994 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
| 994 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
| 995 | 995 | ) |
| 996 | 996 | ); |
| 997 | 997 | |
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | // Can the user view this invoice? |
| 1001 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
| 1001 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
| 1002 | 1002 | |
| 1003 | 1003 | return aui()->alert( |
| 1004 | 1004 | array( |
| 1005 | 1005 | 'type' => 'warning', |
| 1006 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
| 1006 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
| 1007 | 1007 | ) |
| 1008 | 1008 | ); |
| 1009 | 1009 | |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | // Ensure that it is not yet paid for. |
| 1013 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 1013 | + $invoice = new WPInv_Invoice($invoice_id); |
|
| 1014 | 1014 | |
| 1015 | 1015 | // Maybe mark it as viewed. |
| 1016 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
| 1016 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
| 1017 | 1017 | |
| 1018 | - if ( $invoice->is_paid() ) { |
|
| 1018 | + if ($invoice->is_paid()) { |
|
| 1019 | 1019 | |
| 1020 | 1020 | return aui()->alert( |
| 1021 | 1021 | array( |
| 1022 | 1022 | 'type' => 'success', |
| 1023 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
| 1023 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
| 1024 | 1024 | ) |
| 1025 | 1025 | ); |
| 1026 | 1026 | |
@@ -1030,14 +1030,14 @@ discard block |
||
| 1030 | 1030 | $wpi_checkout_id = $invoice_id; |
| 1031 | 1031 | |
| 1032 | 1032 | // We'll display this invoice via the default form. |
| 1033 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1033 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1034 | 1034 | |
| 1035 | - if ( 0 == $form->get_id() ) { |
|
| 1035 | + if (0 == $form->get_id()) { |
|
| 1036 | 1036 | |
| 1037 | 1037 | return aui()->alert( |
| 1038 | 1038 | array( |
| 1039 | 1039 | 'type' => 'warning', |
| 1040 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
| 1040 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
| 1041 | 1041 | ) |
| 1042 | 1042 | ); |
| 1043 | 1043 | |
@@ -1045,7 +1045,7 @@ discard block |
||
| 1045 | 1045 | |
| 1046 | 1046 | // Set the invoice. |
| 1047 | 1047 | $form->invoice = $invoice; |
| 1048 | - $form->set_items( $invoice->get_items() ); |
|
| 1048 | + $form->set_items($invoice->get_items()); |
|
| 1049 | 1049 | |
| 1050 | 1050 | // Generate the html. |
| 1051 | 1051 | return $form->get_html(); |
@@ -1053,7 +1053,7 @@ discard block |
||
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | function wpinv_empty_cart_message() { |
| 1056 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1056 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | /** |
@@ -1070,38 +1070,38 @@ discard block |
||
| 1070 | 1070 | ) |
| 1071 | 1071 | ); |
| 1072 | 1072 | } |
| 1073 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
| 1073 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
| 1074 | 1074 | |
| 1075 | -function wpinv_receipt_billing_address( $invoice_id = 0 ) { |
|
| 1076 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1075 | +function wpinv_receipt_billing_address($invoice_id = 0) { |
|
| 1076 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1077 | 1077 | |
| 1078 | - if ( empty( $invoice ) ) { |
|
| 1078 | + if (empty($invoice)) { |
|
| 1079 | 1079 | return NULL; |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | 1082 | $billing_details = $invoice->get_user_info(); |
| 1083 | - $address_row = wpinv_get_invoice_address_markup( $billing_details ); |
|
| 1083 | + $address_row = wpinv_get_invoice_address_markup($billing_details); |
|
| 1084 | 1084 | |
| 1085 | 1085 | ob_start(); |
| 1086 | 1086 | ?> |
| 1087 | 1087 | <table class="table table-bordered table-sm wpi-billing-details"> |
| 1088 | 1088 | <tbody> |
| 1089 | 1089 | <tr class="wpi-receipt-name"> |
| 1090 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
| 1091 | - <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td> |
|
| 1090 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
| 1091 | + <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td> |
|
| 1092 | 1092 | </tr> |
| 1093 | 1093 | <tr class="wpi-receipt-email"> |
| 1094 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
| 1095 | - <td><?php echo $billing_details['email'] ;?></td> |
|
| 1094 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
| 1095 | + <td><?php echo $billing_details['email']; ?></td> |
|
| 1096 | 1096 | </tr> |
| 1097 | 1097 | <tr class="wpi-receipt-address"> |
| 1098 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
| 1099 | - <td><?php echo $address_row ;?></td> |
|
| 1098 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
| 1099 | + <td><?php echo $address_row; ?></td> |
|
| 1100 | 1100 | </tr> |
| 1101 | - <?php if ( $billing_details['phone'] ) { ?> |
|
| 1101 | + <?php if ($billing_details['phone']) { ?> |
|
| 1102 | 1102 | <tr class="wpi-receipt-phone"> |
| 1103 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
| 1104 | - <td><?php echo esc_html( $billing_details['phone'] ) ;?></td> |
|
| 1103 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
| 1104 | + <td><?php echo esc_html($billing_details['phone']); ?></td> |
|
| 1105 | 1105 | </tr> |
| 1106 | 1106 | <?php } ?> |
| 1107 | 1107 | </tbody> |
@@ -1109,7 +1109,7 @@ discard block |
||
| 1109 | 1109 | <?php |
| 1110 | 1110 | $output = ob_get_clean(); |
| 1111 | 1111 | |
| 1112 | - $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id ); |
|
| 1112 | + $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id); |
|
| 1113 | 1113 | |
| 1114 | 1114 | echo $output; |
| 1115 | 1115 | } |
@@ -1117,66 +1117,66 @@ discard block |
||
| 1117 | 1117 | /** |
| 1118 | 1118 | * Filters the receipt page. |
| 1119 | 1119 | */ |
| 1120 | -function wpinv_filter_success_page_content( $content ) { |
|
| 1120 | +function wpinv_filter_success_page_content($content) { |
|
| 1121 | 1121 | |
| 1122 | 1122 | // Ensure this is our page. |
| 1123 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
| 1123 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
| 1124 | 1124 | |
| 1125 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
| 1126 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
| 1125 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
| 1126 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
| 1127 | 1127 | |
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | 1130 | return $content; |
| 1131 | 1131 | } |
| 1132 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
| 1132 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
| 1133 | 1133 | |
| 1134 | -function wpinv_invoice_link( $invoice_id ) { |
|
| 1135 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1134 | +function wpinv_invoice_link($invoice_id) { |
|
| 1135 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1136 | 1136 | |
| 1137 | - if ( empty( $invoice ) ) { |
|
| 1137 | + if (empty($invoice)) { |
|
| 1138 | 1138 | return NULL; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
| 1141 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
| 1142 | 1142 | |
| 1143 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
| 1143 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
| 1144 | 1144 | } |
| 1145 | 1145 | |
| 1146 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
| 1147 | - if ( empty( $note ) ) { |
|
| 1146 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
| 1147 | + if (empty($note)) { |
|
| 1148 | 1148 | return NULL; |
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | - if ( is_int( $note ) ) { |
|
| 1152 | - $note = get_comment( $note ); |
|
| 1151 | + if (is_int($note)) { |
|
| 1152 | + $note = get_comment($note); |
|
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | - if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
| 1155 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
| 1156 | 1156 | return NULL; |
| 1157 | 1157 | } |
| 1158 | 1158 | |
| 1159 | - $note_classes = array( 'note' ); |
|
| 1160 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
| 1159 | + $note_classes = array('note'); |
|
| 1160 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
| 1161 | 1161 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
| 1162 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
| 1163 | - $note_classes = !empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
| 1162 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
| 1163 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
| 1164 | 1164 | |
| 1165 | 1165 | ob_start(); |
| 1166 | 1166 | ?> |
| 1167 | - <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3"> |
|
| 1167 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3"> |
|
| 1168 | 1168 | <div class="note_content bg-light border position-relative p-4"> |
| 1169 | 1169 | |
| 1170 | - <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?> |
|
| 1170 | + <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?> |
|
| 1171 | 1171 | |
| 1172 | - <?php if ( ! is_admin() ) : ?> |
|
| 1172 | + <?php if (!is_admin()) : ?> |
|
| 1173 | 1173 | <em class="meta position-absolute form-text"> |
| 1174 | 1174 | <?php |
| 1175 | 1175 | printf( |
| 1176 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1176 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1177 | 1177 | $note->comment_author, |
| 1178 | - getpaid_format_date_value( $note->comment_date ), |
|
| 1179 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
| 1178 | + getpaid_format_date_value($note->comment_date), |
|
| 1179 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
| 1180 | 1180 | ); |
| 1181 | 1181 | ?> |
| 1182 | 1182 | </em> |
@@ -1184,21 +1184,21 @@ discard block |
||
| 1184 | 1184 | |
| 1185 | 1185 | </div> |
| 1186 | 1186 | |
| 1187 | - <?php if ( is_admin() ) : ?> |
|
| 1187 | + <?php if (is_admin()) : ?> |
|
| 1188 | 1188 | |
| 1189 | 1189 | <p class="meta px-4 py-2"> |
| 1190 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
| 1190 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
| 1191 | 1191 | <?php |
| 1192 | 1192 | printf( |
| 1193 | - __( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
| 1193 | + __('%1$s - %2$s at %3$s', 'invoicing'), |
|
| 1194 | 1194 | $note->comment_author, |
| 1195 | - getpaid_format_date_value( $note->comment_date ), |
|
| 1196 | - date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) |
|
| 1195 | + getpaid_format_date_value($note->comment_date), |
|
| 1196 | + date_i18n(get_option('time_format'), strtotime($note->comment_date)) |
|
| 1197 | 1197 | ); |
| 1198 | 1198 | ?> |
| 1199 | 1199 | </abbr> |
| 1200 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
| 1201 | - <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a> |
|
| 1200 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
| 1201 | + <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a> |
|
| 1202 | 1202 | <?php } ?> |
| 1203 | 1203 | </p> |
| 1204 | 1204 | |
@@ -1207,9 +1207,9 @@ discard block |
||
| 1207 | 1207 | </li> |
| 1208 | 1208 | <?php |
| 1209 | 1209 | $note_content = ob_get_clean(); |
| 1210 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
| 1210 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
| 1211 | 1211 | |
| 1212 | - if ( $echo ) { |
|
| 1212 | + if ($echo) { |
|
| 1213 | 1213 | echo $note_content; |
| 1214 | 1214 | } else { |
| 1215 | 1215 | return $note_content; |
@@ -1219,36 +1219,36 @@ discard block |
||
| 1219 | 1219 | function wpinv_invalid_invoice_content() { |
| 1220 | 1220 | global $post; |
| 1221 | 1221 | |
| 1222 | - $invoice = wpinv_get_invoice( $post->ID ); |
|
| 1222 | + $invoice = wpinv_get_invoice($post->ID); |
|
| 1223 | 1223 | |
| 1224 | - $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' ); |
|
| 1225 | - if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) { |
|
| 1226 | - if ( is_user_logged_in() ) { |
|
| 1227 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 1228 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 1229 | - $error = __( 'You are not allowed to view this invoice.', 'invoicing' ); |
|
| 1224 | + $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing'); |
|
| 1225 | + if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) { |
|
| 1226 | + if (is_user_logged_in()) { |
|
| 1227 | + if (wpinv_require_login_to_checkout()) { |
|
| 1228 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 1229 | + $error = __('You are not allowed to view this invoice.', 'invoicing'); |
|
| 1230 | 1230 | } |
| 1231 | 1231 | } |
| 1232 | 1232 | } else { |
| 1233 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 1234 | - if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 1235 | - $error = __( 'You must be logged in to view this invoice.', 'invoicing' ); |
|
| 1233 | + if (wpinv_require_login_to_checkout()) { |
|
| 1234 | + if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) { |
|
| 1235 | + $error = __('You must be logged in to view this invoice.', 'invoicing'); |
|
| 1236 | 1236 | } |
| 1237 | 1237 | } |
| 1238 | 1238 | } |
| 1239 | 1239 | } else { |
| 1240 | - $error = __( 'This invoice is deleted or does not exist.', 'invoicing' ); |
|
| 1240 | + $error = __('This invoice is deleted or does not exist.', 'invoicing'); |
|
| 1241 | 1241 | } |
| 1242 | 1242 | ?> |
| 1243 | 1243 | <div class="row wpinv-row-invalid"> |
| 1244 | 1244 | <div class="col-md-6 col-md-offset-3 wpinv-message error"> |
| 1245 | - <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3> |
|
| 1245 | + <h3><?php _e('Access Denied', 'invoicing'); ?></h3> |
|
| 1246 | 1246 | <p class="wpinv-msg-text"><?php echo $error; ?></p> |
| 1247 | 1247 | </div> |
| 1248 | 1248 | </div> |
| 1249 | 1249 | <?php |
| 1250 | 1250 | } |
| 1251 | -add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' ); |
|
| 1251 | +add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content'); |
|
| 1252 | 1252 | |
| 1253 | 1253 | /** |
| 1254 | 1254 | * Function to get privacy policy text. |
@@ -1257,21 +1257,21 @@ discard block |
||
| 1257 | 1257 | * @return string |
| 1258 | 1258 | */ |
| 1259 | 1259 | function wpinv_get_policy_text() { |
| 1260 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
| 1260 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
| 1261 | 1261 | |
| 1262 | - $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' )); |
|
| 1262 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
| 1263 | 1263 | |
| 1264 | - if(!$privacy_page_id){ |
|
| 1265 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
| 1264 | + if (!$privacy_page_id) { |
|
| 1265 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
| 1268 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
| 1269 | 1269 | |
| 1270 | 1270 | $find_replace = array( |
| 1271 | 1271 | '[wpinv_privacy_policy]' => $privacy_link, |
| 1272 | 1272 | ); |
| 1273 | 1273 | |
| 1274 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
| 1274 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
| 1275 | 1275 | |
| 1276 | 1276 | return wp_kses_post(wpautop($privacy_text)); |
| 1277 | 1277 | } |
@@ -1279,21 +1279,21 @@ discard block |
||
| 1279 | 1279 | function wpinv_oxygen_fix_conflict() { |
| 1280 | 1280 | global $ct_ignore_post_types; |
| 1281 | 1281 | |
| 1282 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
| 1282 | + if (!is_array($ct_ignore_post_types)) { |
|
| 1283 | 1283 | $ct_ignore_post_types = array(); |
| 1284 | 1284 | } |
| 1285 | 1285 | |
| 1286 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' ); |
|
| 1286 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item'); |
|
| 1287 | 1287 | |
| 1288 | - foreach ( $post_types as $post_type ) { |
|
| 1288 | + foreach ($post_types as $post_type) { |
|
| 1289 | 1289 | $ct_ignore_post_types[] = $post_type; |
| 1290 | 1290 | |
| 1291 | 1291 | // Ignore post type |
| 1292 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
| 1292 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
| 1296 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
| 1295 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
| 1296 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | 1299 | /** |
@@ -1301,10 +1301,10 @@ discard block |
||
| 1301 | 1301 | * |
| 1302 | 1302 | * @param GetPaid_Payment_Form $form |
| 1303 | 1303 | */ |
| 1304 | -function getpaid_display_payment_form( $form ) { |
|
| 1304 | +function getpaid_display_payment_form($form) { |
|
| 1305 | 1305 | |
| 1306 | - if ( is_numeric( $form ) ) { |
|
| 1307 | - $form = new GetPaid_Payment_Form( $form ); |
|
| 1306 | + if (is_numeric($form)) { |
|
| 1307 | + $form = new GetPaid_Payment_Form($form); |
|
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | 1310 | $form->display(); |
@@ -1314,55 +1314,55 @@ discard block |
||
| 1314 | 1314 | /** |
| 1315 | 1315 | * Helper function to display a item payment form on the frontend. |
| 1316 | 1316 | */ |
| 1317 | -function getpaid_display_item_payment_form( $items ) { |
|
| 1317 | +function getpaid_display_item_payment_form($items) { |
|
| 1318 | 1318 | |
| 1319 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1320 | - $form->set_items( $items ); |
|
| 1319 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1320 | + $form->set_items($items); |
|
| 1321 | 1321 | |
| 1322 | - if ( 0 == count( $form->get_items() ) ) { |
|
| 1322 | + if (0 == count($form->get_items())) { |
|
| 1323 | 1323 | echo aui()->alert( |
| 1324 | 1324 | array( |
| 1325 | 1325 | 'type' => 'warning', |
| 1326 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
| 1326 | + 'content' => __('No published items found', 'invoicing'), |
|
| 1327 | 1327 | ) |
| 1328 | 1328 | ); |
| 1329 | 1329 | return; |
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | - $form_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
| 1332 | + $form_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
| 1333 | 1333 | $form_items = "<input type='hidden' name='getpaid-form-items' value='$form_items' />"; |
| 1334 | - $form->display( $form_items ); |
|
| 1334 | + $form->display($form_items); |
|
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | 1337 | /** |
| 1338 | 1338 | * Helper function to display an invoice payment form on the frontend. |
| 1339 | 1339 | */ |
| 1340 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
| 1340 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
| 1341 | 1341 | |
| 1342 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
| 1342 | + $invoice = wpinv_get_invoice($invoice_id); |
|
| 1343 | 1343 | |
| 1344 | - if ( empty( $invoice ) ) { |
|
| 1344 | + if (empty($invoice)) { |
|
| 1345 | 1345 | echo aui()->alert( |
| 1346 | 1346 | array( |
| 1347 | 1347 | 'type' => 'warning', |
| 1348 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
| 1348 | + 'content' => __('Invoice not found', 'invoicing'), |
|
| 1349 | 1349 | ) |
| 1350 | 1350 | ); |
| 1351 | 1351 | return; |
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | - if ( $invoice->is_paid() ) { |
|
| 1354 | + if ($invoice->is_paid()) { |
|
| 1355 | 1355 | echo aui()->alert( |
| 1356 | 1356 | array( |
| 1357 | 1357 | 'type' => 'warning', |
| 1358 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
| 1358 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
| 1359 | 1359 | ) |
| 1360 | 1360 | ); |
| 1361 | 1361 | return; |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
| 1365 | - $form->set_items( $invoice->get_items() ); |
|
| 1364 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
| 1365 | + $form->set_items($invoice->get_items()); |
|
| 1366 | 1366 | |
| 1367 | 1367 | $form->display(); |
| 1368 | 1368 | } |
@@ -1370,23 +1370,23 @@ discard block |
||
| 1370 | 1370 | /** |
| 1371 | 1371 | * Helper function to convert item string to array. |
| 1372 | 1372 | */ |
| 1373 | -function getpaid_convert_items_to_array( $items ) { |
|
| 1374 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
| 1373 | +function getpaid_convert_items_to_array($items) { |
|
| 1374 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
| 1375 | 1375 | $prepared = array(); |
| 1376 | 1376 | |
| 1377 | - foreach ( $items as $item ) { |
|
| 1378 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
| 1377 | + foreach ($items as $item) { |
|
| 1378 | + $data = array_map('trim', explode('|', $item)); |
|
| 1379 | 1379 | |
| 1380 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
| 1380 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
| 1381 | 1381 | continue; |
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | $quantity = 1; |
| 1385 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
| 1385 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
| 1386 | 1386 | $quantity = (int) $data[1]; |
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | - $prepared[ $data[0] ] = $quantity; |
|
| 1389 | + $prepared[$data[0]] = $quantity; |
|
| 1390 | 1390 | |
| 1391 | 1391 | } |
| 1392 | 1392 | |
@@ -1396,13 +1396,13 @@ discard block |
||
| 1396 | 1396 | /** |
| 1397 | 1397 | * Helper function to convert item array to string. |
| 1398 | 1398 | */ |
| 1399 | -function getpaid_convert_items_to_string( $items ) { |
|
| 1399 | +function getpaid_convert_items_to_string($items) { |
|
| 1400 | 1400 | $prepared = array(); |
| 1401 | 1401 | |
| 1402 | - foreach ( $items as $item => $quantity ) { |
|
| 1402 | + foreach ($items as $item => $quantity) { |
|
| 1403 | 1403 | $prepared[] = "$item|$quantity"; |
| 1404 | 1404 | } |
| 1405 | - return implode( ',', $prepared ); |
|
| 1405 | + return implode(',', $prepared); |
|
| 1406 | 1406 | } |
| 1407 | 1407 | |
| 1408 | 1408 | /** |
@@ -1410,21 +1410,21 @@ discard block |
||
| 1410 | 1410 | * |
| 1411 | 1411 | * Provide a label and one of $form, $items or $invoice. |
| 1412 | 1412 | */ |
| 1413 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
| 1414 | - $label = sanitize_text_field( $label ); |
|
| 1413 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
| 1414 | + $label = sanitize_text_field($label); |
|
| 1415 | 1415 | |
| 1416 | - if ( ! empty( $form ) ) { |
|
| 1417 | - $form = esc_attr( $form ); |
|
| 1416 | + if (!empty($form)) { |
|
| 1417 | + $form = esc_attr($form); |
|
| 1418 | 1418 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | - if ( ! empty( $items ) ) { |
|
| 1422 | - $items = esc_attr( $items ); |
|
| 1421 | + if (!empty($items)) { |
|
| 1422 | + $items = esc_attr($items); |
|
| 1423 | 1423 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | - if ( ! empty( $invoice ) ) { |
|
| 1427 | - $invoice = esc_attr( $invoice ); |
|
| 1426 | + if (!empty($invoice)) { |
|
| 1427 | + $invoice = esc_attr($invoice); |
|
| 1428 | 1428 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
| 1429 | 1429 | } |
| 1430 | 1430 | |
@@ -1435,17 +1435,17 @@ discard block |
||
| 1435 | 1435 | * |
| 1436 | 1436 | * @param WPInv_Invoice $invoice |
| 1437 | 1437 | */ |
| 1438 | -function getpaid_the_invoice_description( $invoice ) { |
|
| 1438 | +function getpaid_the_invoice_description($invoice) { |
|
| 1439 | 1439 | $description = $invoice->get_description(); |
| 1440 | 1440 | |
| 1441 | - if ( empty( $description ) ) { |
|
| 1441 | + if (empty($description)) { |
|
| 1442 | 1442 | return; |
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | - $description = wp_kses_post( $description ); |
|
| 1445 | + $description = wp_kses_post($description); |
|
| 1446 | 1446 | echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>"; |
| 1447 | 1447 | } |
| 1448 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
| 1448 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
| 1449 | 1449 | |
| 1450 | 1450 | /** |
| 1451 | 1451 | * Render element on a form. |
@@ -1453,60 +1453,60 @@ discard block |
||
| 1453 | 1453 | * @param array $element |
| 1454 | 1454 | * @param GetPaid_Payment_Form $form |
| 1455 | 1455 | */ |
| 1456 | -function getpaid_payment_form_element( $element, $form ) { |
|
| 1456 | +function getpaid_payment_form_element($element, $form) { |
|
| 1457 | 1457 | |
| 1458 | 1458 | // Set up the args. |
| 1459 | - $element_type = trim( $element['type'] ); |
|
| 1459 | + $element_type = trim($element['type']); |
|
| 1460 | 1460 | $element['form'] = $form; |
| 1461 | - extract( $element ); |
|
| 1461 | + extract($element); |
|
| 1462 | 1462 | |
| 1463 | 1463 | // Try to locate the appropriate template. |
| 1464 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
| 1464 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
| 1465 | 1465 | |
| 1466 | 1466 | // Abort if this is not our element. |
| 1467 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1467 | + if (empty($located) || !file_exists($located)) { |
|
| 1468 | 1468 | return; |
| 1469 | 1469 | } |
| 1470 | 1470 | |
| 1471 | 1471 | // Generate the class and id of the element. |
| 1472 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
| 1473 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
| 1472 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
| 1473 | + $id = isset($id) ? $id : uniqid('gp'); |
|
| 1474 | 1474 | |
| 1475 | 1475 | // Echo the opening wrapper. |
| 1476 | 1476 | echo "<div class='getpaid-payment-form-element $wrapper_class'>"; |
| 1477 | 1477 | |
| 1478 | 1478 | // Fires before displaying a given element type's content. |
| 1479 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
| 1479 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
| 1480 | 1480 | |
| 1481 | 1481 | // Include the template for the element. |
| 1482 | 1482 | include $located; |
| 1483 | 1483 | |
| 1484 | 1484 | // Fires after displaying a given element type's content. |
| 1485 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
| 1485 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
| 1486 | 1486 | |
| 1487 | 1487 | // Echo the closing wrapper. |
| 1488 | 1488 | echo '</div>'; |
| 1489 | 1489 | } |
| 1490 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
| 1490 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
| 1491 | 1491 | |
| 1492 | 1492 | /** |
| 1493 | 1493 | * Render an element's edit page. |
| 1494 | 1494 | * |
| 1495 | 1495 | * @param WP_Post $post |
| 1496 | 1496 | */ |
| 1497 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
| 1497 | +function getpaid_payment_form_edit_element_template($post) { |
|
| 1498 | 1498 | |
| 1499 | 1499 | // Retrieve all elements. |
| 1500 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1500 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1501 | 1501 | |
| 1502 | - foreach ( $all_elements as $element ) { |
|
| 1502 | + foreach ($all_elements as $element) { |
|
| 1503 | 1503 | |
| 1504 | 1504 | // Try to locate the appropriate template. |
| 1505 | - $element = sanitize_key( $element ); |
|
| 1506 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
| 1505 | + $element = sanitize_key($element); |
|
| 1506 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
| 1507 | 1507 | |
| 1508 | 1508 | // Continue if this is not our element. |
| 1509 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1509 | + if (empty($located) || !file_exists($located)) { |
|
| 1510 | 1510 | continue; |
| 1511 | 1511 | } |
| 1512 | 1512 | |
@@ -1517,7 +1517,7 @@ discard block |
||
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | } |
| 1520 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
| 1520 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
| 1521 | 1521 | |
| 1522 | 1522 | /** |
| 1523 | 1523 | * Render an element's preview. |
@@ -1526,16 +1526,16 @@ discard block |
||
| 1526 | 1526 | function getpaid_payment_form_render_element_preview_template() { |
| 1527 | 1527 | |
| 1528 | 1528 | // Retrieve all elements. |
| 1529 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
| 1529 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
| 1530 | 1530 | |
| 1531 | - foreach ( $all_elements as $element ) { |
|
| 1531 | + foreach ($all_elements as $element) { |
|
| 1532 | 1532 | |
| 1533 | 1533 | // Try to locate the appropriate template. |
| 1534 | - $element = sanitize_key( $element ); |
|
| 1535 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
| 1534 | + $element = sanitize_key($element); |
|
| 1535 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
| 1536 | 1536 | |
| 1537 | 1537 | // Continue if this is not our element. |
| 1538 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
| 1538 | + if (empty($located) || !file_exists($located)) { |
|
| 1539 | 1539 | continue; |
| 1540 | 1540 | } |
| 1541 | 1541 | |
@@ -1546,7 +1546,7 @@ discard block |
||
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | 1548 | } |
| 1549 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
| 1549 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
| 1550 | 1550 | |
| 1551 | 1551 | /** |
| 1552 | 1552 | * Shows a list of gateways that support recurring payments. |
@@ -1554,17 +1554,17 @@ discard block |
||
| 1554 | 1554 | function wpinv_get_recurring_gateways_text() { |
| 1555 | 1555 | $gateways = array(); |
| 1556 | 1556 | |
| 1557 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
| 1558 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
| 1559 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
| 1557 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
| 1558 | + if (wpinv_gateway_support_subscription($key)) { |
|
| 1559 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
| 1560 | 1560 | } |
| 1561 | 1561 | } |
| 1562 | 1562 | |
| 1563 | - if ( empty( $gateways ) ) { |
|
| 1564 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>"; |
|
| 1563 | + if (empty($gateways)) { |
|
| 1564 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>"; |
|
| 1565 | 1565 | } |
| 1566 | 1566 | |
| 1567 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>"; |
|
| 1567 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>"; |
|
| 1568 | 1568 | |
| 1569 | 1569 | } |
| 1570 | 1570 | |
@@ -1574,7 +1574,7 @@ discard block |
||
| 1574 | 1574 | * @return GetPaid_Template |
| 1575 | 1575 | */ |
| 1576 | 1576 | function getpaid_template() { |
| 1577 | - return getpaid()->get( 'template' ); |
|
| 1577 | + return getpaid()->get('template'); |
|
| 1578 | 1578 | } |
| 1579 | 1579 | |
| 1580 | 1580 | /** |
@@ -1583,23 +1583,23 @@ discard block |
||
| 1583 | 1583 | * @param array args |
| 1584 | 1584 | * @return string |
| 1585 | 1585 | */ |
| 1586 | -function getpaid_paginate_links( $args ) { |
|
| 1586 | +function getpaid_paginate_links($args) { |
|
| 1587 | 1587 | |
| 1588 | 1588 | $args['type'] = 'array'; |
| 1589 | 1589 | $args['mid_size'] = 1; |
| 1590 | - $pages = paginate_links( $args ); |
|
| 1590 | + $pages = paginate_links($args); |
|
| 1591 | 1591 | |
| 1592 | - if ( ! is_array( $pages ) ) { |
|
| 1592 | + if (!is_array($pages)) { |
|
| 1593 | 1593 | return ''; |
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | 1596 | $_pages = array(); |
| 1597 | - foreach ( $pages as $page ) { |
|
| 1598 | - $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page ); |
|
| 1597 | + foreach ($pages as $page) { |
|
| 1598 | + $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page); |
|
| 1599 | 1599 | } |
| 1600 | 1600 | |
| 1601 | 1601 | $links = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>"; |
| 1602 | - $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages ); |
|
| 1602 | + $links .= join("</li>\n\t\t<li class='page-item'>", $_pages); |
|
| 1603 | 1603 | $links .= "</li>\n\t</ul>\n</nav>\n"; |
| 1604 | 1604 | |
| 1605 | 1605 | return $links; |
@@ -1612,21 +1612,21 @@ discard block |
||
| 1612 | 1612 | * @param string state |
| 1613 | 1613 | * @return string |
| 1614 | 1614 | */ |
| 1615 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state' ) { |
|
| 1615 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state') { |
|
| 1616 | 1616 | |
| 1617 | - $states = wpinv_get_country_states( $country ); |
|
| 1618 | - $uniqid = uniqid( '_' ); |
|
| 1617 | + $states = wpinv_get_country_states($country); |
|
| 1618 | + $uniqid = uniqid('_'); |
|
| 1619 | 1619 | |
| 1620 | - if ( ! empty( $states ) ) { |
|
| 1620 | + if (!empty($states)) { |
|
| 1621 | 1621 | |
| 1622 | - return aui()->select( array( |
|
| 1622 | + return aui()->select(array( |
|
| 1623 | 1623 | 'options' => $states, |
| 1624 | - 'name' => esc_attr( $field_name ), |
|
| 1625 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1626 | - 'value' => sanitize_text_field( $state ), |
|
| 1624 | + 'name' => esc_attr($field_name), |
|
| 1625 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 1626 | + 'value' => sanitize_text_field($state), |
|
| 1627 | 1627 | 'placeholder' => $placeholder, |
| 1628 | 1628 | 'required' => $required, |
| 1629 | - 'label' => wp_kses_post( $label ), |
|
| 1629 | + 'label' => wp_kses_post($label), |
|
| 1630 | 1630 | 'label_type' => 'vertical', |
| 1631 | 1631 | 'help_text' => $help_text, |
| 1632 | 1632 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1638,14 +1638,14 @@ discard block |
||
| 1638 | 1638 | |
| 1639 | 1639 | return aui()->input( |
| 1640 | 1640 | array( |
| 1641 | - 'name' => esc_attr( $field_name ), |
|
| 1642 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
| 1641 | + 'name' => esc_attr($field_name), |
|
| 1642 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
| 1643 | 1643 | 'placeholder' => $placeholder, |
| 1644 | 1644 | 'required' => $required, |
| 1645 | - 'label' => wp_kses_post( $label ), |
|
| 1645 | + 'label' => wp_kses_post($label), |
|
| 1646 | 1646 | 'label_type' => 'vertical', |
| 1647 | 1647 | 'help_text' => $help_text, |
| 1648 | - 'value' => sanitize_text_field( $state ), |
|
| 1648 | + 'value' => sanitize_text_field($state), |
|
| 1649 | 1649 | 'class' => 'getpaid-address-field wpinv_state', |
| 1650 | 1650 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
| 1651 | 1651 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1660,16 +1660,16 @@ discard block |
||
| 1660 | 1660 | * @param array $element |
| 1661 | 1661 | * @return string |
| 1662 | 1662 | */ |
| 1663 | -function getpaid_get_form_element_grid_class( $element ) { |
|
| 1663 | +function getpaid_get_form_element_grid_class($element) { |
|
| 1664 | 1664 | |
| 1665 | 1665 | $class = "col-12"; |
| 1666 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
| 1666 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
| 1667 | 1667 | |
| 1668 | - if ( $width == 'half' ) { |
|
| 1668 | + if ($width == 'half') { |
|
| 1669 | 1669 | $class = "col-12 col-md-6"; |
| 1670 | 1670 | } |
| 1671 | 1671 | |
| 1672 | - if ( $width == 'third' ) { |
|
| 1672 | + if ($width == 'third') { |
|
| 1673 | 1673 | $class = "col-12 col-md-4"; |
| 1674 | 1674 | } |
| 1675 | 1675 | |
@@ -14,30 +14,30 @@ discard block |
||
| 14 | 14 | class WPInv_Invoice extends GetPaid_Data { |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * Which data store to load. |
|
| 18 | - * |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 17 | + * Which data store to load. |
|
| 18 | + * |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | 21 | protected $data_store_name = 'invoice'; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * This is the name of this object type. |
|
| 25 | - * |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 24 | + * This is the name of this object type. |
|
| 25 | + * |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | 28 | protected $object_type = 'invoice'; |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | - * |
|
| 33 | - * @since 1.0.19 |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - protected $data = array( |
|
| 37 | - 'parent_id' => 0, |
|
| 38 | - 'status' => 'wpi-pending', |
|
| 39 | - 'version' => '', |
|
| 40 | - 'date_created' => null, |
|
| 31 | + * Item Data array. This is the core item data exposed in APIs. |
|
| 32 | + * |
|
| 33 | + * @since 1.0.19 |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + protected $data = array( |
|
| 37 | + 'parent_id' => 0, |
|
| 38 | + 'status' => 'wpi-pending', |
|
| 39 | + 'version' => '', |
|
| 40 | + 'date_created' => null, |
|
| 41 | 41 | 'date_modified' => null, |
| 42 | 42 | 'due_date' => null, |
| 43 | 43 | 'completed_date' => null, |
@@ -79,22 +79,22 @@ discard block |
||
| 79 | 79 | 'transaction_id' => '', |
| 80 | 80 | 'currency' => '', |
| 81 | 81 | 'disable_taxes' => false, |
| 82 | - 'subscription_id' => null, |
|
| 83 | - 'remote_subscription_id' => null, |
|
| 84 | - 'is_viewed' => false, |
|
| 85 | - 'email_cc' => '', |
|
| 86 | - 'template' => 'quantity', // hours, amount only |
|
| 87 | - 'created_via' => null, |
|
| 82 | + 'subscription_id' => null, |
|
| 83 | + 'remote_subscription_id' => null, |
|
| 84 | + 'is_viewed' => false, |
|
| 85 | + 'email_cc' => '', |
|
| 86 | + 'template' => 'quantity', // hours, amount only |
|
| 87 | + 'created_via' => null, |
|
| 88 | 88 | ); |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | - * Stores meta in cache for future reads. |
|
| 92 | - * |
|
| 93 | - * A group must be set to to enable caching. |
|
| 94 | - * |
|
| 95 | - * @var string |
|
| 96 | - */ |
|
| 97 | - protected $cache_group = 'getpaid_invoices'; |
|
| 91 | + * Stores meta in cache for future reads. |
|
| 92 | + * |
|
| 93 | + * A group must be set to to enable caching. |
|
| 94 | + * |
|
| 95 | + * @var string |
|
| 96 | + */ |
|
| 97 | + protected $cache_group = 'getpaid_invoices'; |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Stores a reference to the original WP_Post object |
@@ -108,104 +108,104 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @var int |
| 110 | 110 | */ |
| 111 | - protected $recurring_item = null; |
|
| 111 | + protected $recurring_item = null; |
|
| 112 | 112 | |
| 113 | - /** |
|
| 113 | + /** |
|
| 114 | 114 | * Stores an array of item totals. |
| 115 | - * |
|
| 116 | - * e.g $totals['discount'] = array( |
|
| 117 | - * 'initial' => 10, |
|
| 118 | - * 'recurring' => 10, |
|
| 119 | - * ) |
|
| 115 | + * |
|
| 116 | + * e.g $totals['discount'] = array( |
|
| 117 | + * 'initial' => 10, |
|
| 118 | + * 'recurring' => 10, |
|
| 119 | + * ) |
|
| 120 | 120 | * |
| 121 | 121 | * @var array |
| 122 | 122 | */ |
| 123 | - protected $totals = array(); |
|
| 123 | + protected $totals = array(); |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Stores the status transition information. |
|
| 127 | - * |
|
| 128 | - * @since 1.0.19 |
|
| 129 | - * @var bool|array |
|
| 130 | - */ |
|
| 131 | - protected $status_transition = false; |
|
| 125 | + /** |
|
| 126 | + * Stores the status transition information. |
|
| 127 | + * |
|
| 128 | + * @since 1.0.19 |
|
| 129 | + * @var bool|array |
|
| 130 | + */ |
|
| 131 | + protected $status_transition = false; |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | - * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 135 | - * |
|
| 136 | - * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 137 | - */ |
|
| 134 | + * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
| 135 | + * |
|
| 136 | + * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
|
| 137 | + */ |
|
| 138 | 138 | public function __construct( $invoice = 0 ) { |
| 139 | 139 | |
| 140 | 140 | parent::__construct( $invoice ); |
| 141 | 141 | |
| 142 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
| 143 | - $this->set_id( (int) $invoice ); |
|
| 144 | - } elseif ( $invoice instanceof self ) { |
|
| 145 | - $this->set_id( $invoice->get_id() ); |
|
| 146 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 147 | - $this->set_id( $invoice->ID ); |
|
| 148 | - } elseif ( is_array( $invoice ) ) { |
|
| 149 | - $this->set_props( $invoice ); |
|
| 150 | - |
|
| 151 | - if ( isset( $invoice['ID'] ) ) { |
|
| 152 | - $this->set_id( $invoice['ID'] ); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 160 | - $this->set_id( $invoice_id ); |
|
| 161 | - }else { |
|
| 162 | - $this->set_object_read( true ); |
|
| 163 | - } |
|
| 142 | + if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
| 143 | + $this->set_id( (int) $invoice ); |
|
| 144 | + } elseif ( $invoice instanceof self ) { |
|
| 145 | + $this->set_id( $invoice->get_id() ); |
|
| 146 | + } elseif ( ! empty( $invoice->ID ) ) { |
|
| 147 | + $this->set_id( $invoice->ID ); |
|
| 148 | + } elseif ( is_array( $invoice ) ) { |
|
| 149 | + $this->set_props( $invoice ); |
|
| 150 | + |
|
| 151 | + if ( isset( $invoice['ID'] ) ) { |
|
| 152 | + $this->set_id( $invoice['ID'] ); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 156 | + $this->set_id( $invoice_id ); |
|
| 157 | + } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 158 | + $this->set_id( $invoice_id ); |
|
| 159 | + } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 160 | + $this->set_id( $invoice_id ); |
|
| 161 | + }else { |
|
| 162 | + $this->set_object_read( true ); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | // Load the datastore. |
| 166 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 166 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 167 | 167 | |
| 168 | - if ( $this->get_id() > 0 ) { |
|
| 168 | + if ( $this->get_id() > 0 ) { |
|
| 169 | 169 | $this->post = get_post( $this->get_id() ); |
| 170 | 170 | $this->ID = $this->get_id(); |
| 171 | - $this->data_store->read( $this ); |
|
| 171 | + $this->data_store->read( $this ); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
| 177 | - * Given an invoice key/number, it returns its id. |
|
| 178 | - * |
|
| 179 | - * |
|
| 180 | - * @static |
|
| 181 | - * @param string $value The invoice key or number |
|
| 182 | - * @param string $field Either key, transaction_id or number. |
|
| 183 | - * @since 1.0.15 |
|
| 184 | - * @return int |
|
| 185 | - */ |
|
| 186 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 177 | + * Given an invoice key/number, it returns its id. |
|
| 178 | + * |
|
| 179 | + * |
|
| 180 | + * @static |
|
| 181 | + * @param string $value The invoice key or number |
|
| 182 | + * @param string $field Either key, transaction_id or number. |
|
| 183 | + * @since 1.0.15 |
|
| 184 | + * @return int |
|
| 185 | + */ |
|
| 186 | + public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 187 | 187 | global $wpdb; |
| 188 | 188 | |
| 189 | - // Trim the value. |
|
| 190 | - $value = trim( $value ); |
|
| 189 | + // Trim the value. |
|
| 190 | + $value = trim( $value ); |
|
| 191 | 191 | |
| 192 | - if ( empty( $value ) ) { |
|
| 193 | - return 0; |
|
| 194 | - } |
|
| 192 | + if ( empty( $value ) ) { |
|
| 193 | + return 0; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | 196 | // Valid fields. |
| 197 | 197 | $fields = array( 'key', 'number', 'transaction_id' ); |
| 198 | 198 | |
| 199 | - // Ensure a field has been passed. |
|
| 200 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 201 | - return 0; |
|
| 202 | - } |
|
| 199 | + // Ensure a field has been passed. |
|
| 200 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 201 | + return 0; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - // Maybe retrieve from the cache. |
|
| 205 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 206 | - if ( false !== $invoice_id ) { |
|
| 207 | - return $invoice_id; |
|
| 208 | - } |
|
| 204 | + // Maybe retrieve from the cache. |
|
| 205 | + $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 206 | + if ( false !== $invoice_id ) { |
|
| 207 | + return $invoice_id; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | 210 | // Fetch from the db. |
| 211 | 211 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | - // Update the cache with our data |
|
| 217 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 216 | + // Update the cache with our data |
|
| 217 | + wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 218 | 218 | |
| 219 | - return $invoice_id; |
|
| 219 | + return $invoice_id; |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -242,72 +242,72 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | - * Get parent invoice ID. |
|
| 246 | - * |
|
| 247 | - * @since 1.0.19 |
|
| 248 | - * @param string $context View or edit context. |
|
| 249 | - * @return int |
|
| 250 | - */ |
|
| 251 | - public function get_parent_id( $context = 'view' ) { |
|
| 252 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 245 | + * Get parent invoice ID. |
|
| 246 | + * |
|
| 247 | + * @since 1.0.19 |
|
| 248 | + * @param string $context View or edit context. |
|
| 249 | + * @return int |
|
| 250 | + */ |
|
| 251 | + public function get_parent_id( $context = 'view' ) { |
|
| 252 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | - * Get parent invoice. |
|
| 257 | - * |
|
| 258 | - * @since 1.0.19 |
|
| 259 | - * @return WPInv_Invoice |
|
| 260 | - */ |
|
| 256 | + * Get parent invoice. |
|
| 257 | + * |
|
| 258 | + * @since 1.0.19 |
|
| 259 | + * @return WPInv_Invoice |
|
| 260 | + */ |
|
| 261 | 261 | public function get_parent_payment() { |
| 262 | 262 | return new WPInv_Invoice( $this->get_parent_id() ); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | - * Alias for self::get_parent_payment(). |
|
| 267 | - * |
|
| 268 | - * @since 1.0.19 |
|
| 269 | - * @return WPInv_Invoice |
|
| 270 | - */ |
|
| 266 | + * Alias for self::get_parent_payment(). |
|
| 267 | + * |
|
| 268 | + * @since 1.0.19 |
|
| 269 | + * @return WPInv_Invoice |
|
| 270 | + */ |
|
| 271 | 271 | public function get_parent() { |
| 272 | 272 | return $this->get_parent_payment(); |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | - * Get invoice status. |
|
| 277 | - * |
|
| 278 | - * @since 1.0.19 |
|
| 279 | - * @param string $context View or edit context. |
|
| 280 | - * @return string |
|
| 281 | - */ |
|
| 282 | - public function get_status( $context = 'view' ) { |
|
| 283 | - return $this->get_prop( 'status', $context ); |
|
| 284 | - } |
|
| 276 | + * Get invoice status. |
|
| 277 | + * |
|
| 278 | + * @since 1.0.19 |
|
| 279 | + * @param string $context View or edit context. |
|
| 280 | + * @return string |
|
| 281 | + */ |
|
| 282 | + public function get_status( $context = 'view' ) { |
|
| 283 | + return $this->get_prop( 'status', $context ); |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - /** |
|
| 287 | - * Retrieves an array of possible invoice statuses. |
|
| 288 | - * |
|
| 289 | - * @since 1.0.19 |
|
| 290 | - * @return array |
|
| 291 | - */ |
|
| 292 | - public function get_all_statuses() { |
|
| 293 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * Get invoice status nice name. |
|
| 298 | - * |
|
| 299 | - * @since 1.0.19 |
|
| 300 | - * @return string |
|
| 301 | - */ |
|
| 286 | + /** |
|
| 287 | + * Retrieves an array of possible invoice statuses. |
|
| 288 | + * |
|
| 289 | + * @since 1.0.19 |
|
| 290 | + * @return array |
|
| 291 | + */ |
|
| 292 | + public function get_all_statuses() { |
|
| 293 | + return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * Get invoice status nice name. |
|
| 298 | + * |
|
| 299 | + * @since 1.0.19 |
|
| 300 | + * @return string |
|
| 301 | + */ |
|
| 302 | 302 | public function get_status_nicename() { |
| 303 | - $statuses = $this->get_all_statuses(); |
|
| 303 | + $statuses = $this->get_all_statuses(); |
|
| 304 | 304 | |
| 305 | 305 | $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
| 306 | 306 | |
| 307 | 307 | return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - /** |
|
| 310 | + /** |
|
| 311 | 311 | * Retrieves the invoice status label html |
| 312 | 312 | * |
| 313 | 313 | * @since 1.0.0 |
@@ -315,262 +315,262 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | public function get_status_label_html() { |
| 317 | 317 | |
| 318 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 319 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 318 | + $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 319 | + $status = sanitize_html_class( $this->get_status() ); |
|
| 320 | 320 | |
| 321 | - return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
|
| 322 | - } |
|
| 321 | + return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | 324 | /** |
| 325 | - * Get plugin version when the invoice was created. |
|
| 326 | - * |
|
| 327 | - * @since 1.0.19 |
|
| 328 | - * @param string $context View or edit context. |
|
| 329 | - * @return string |
|
| 330 | - */ |
|
| 331 | - public function get_version( $context = 'view' ) { |
|
| 332 | - return $this->get_prop( 'version', $context ); |
|
| 333 | - } |
|
| 325 | + * Get plugin version when the invoice was created. |
|
| 326 | + * |
|
| 327 | + * @since 1.0.19 |
|
| 328 | + * @param string $context View or edit context. |
|
| 329 | + * @return string |
|
| 330 | + */ |
|
| 331 | + public function get_version( $context = 'view' ) { |
|
| 332 | + return $this->get_prop( 'version', $context ); |
|
| 333 | + } |
|
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * @deprecated |
|
| 337 | - */ |
|
| 338 | - public function get_invoice_date( $format = true ) { |
|
| 339 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 340 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 341 | - $formatted = getpaid_format_date( $date ); |
|
| 335 | + /** |
|
| 336 | + * @deprecated |
|
| 337 | + */ |
|
| 338 | + public function get_invoice_date( $format = true ) { |
|
| 339 | + $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 340 | + $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 341 | + $formatted = getpaid_format_date( $date ); |
|
| 342 | 342 | |
| 343 | - if ( $format ) { |
|
| 344 | - return $formatted; |
|
| 345 | - } |
|
| 343 | + if ( $format ) { |
|
| 344 | + return $formatted; |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | - return empty( $formatted ) ? '' : $date; |
|
| 347 | + return empty( $formatted ) ? '' : $date; |
|
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | - * Get date when the invoice was created. |
|
| 353 | - * |
|
| 354 | - * @since 1.0.19 |
|
| 355 | - * @param string $context View or edit context. |
|
| 356 | - * @return string |
|
| 357 | - */ |
|
| 358 | - public function get_date_created( $context = 'view' ) { |
|
| 359 | - return $this->get_prop( 'date_created', $context ); |
|
| 360 | - } |
|
| 352 | + * Get date when the invoice was created. |
|
| 353 | + * |
|
| 354 | + * @since 1.0.19 |
|
| 355 | + * @param string $context View or edit context. |
|
| 356 | + * @return string |
|
| 357 | + */ |
|
| 358 | + public function get_date_created( $context = 'view' ) { |
|
| 359 | + return $this->get_prop( 'date_created', $context ); |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - /** |
|
| 363 | - * Alias for self::get_date_created(). |
|
| 364 | - * |
|
| 365 | - * @since 1.0.19 |
|
| 366 | - * @param string $context View or edit context. |
|
| 367 | - * @return string |
|
| 368 | - */ |
|
| 369 | - public function get_created_date( $context = 'view' ) { |
|
| 370 | - return $this->get_date_created( $context ); |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - /** |
|
| 374 | - * Get GMT date when the invoice was created. |
|
| 375 | - * |
|
| 376 | - * @since 1.0.19 |
|
| 377 | - * @param string $context View or edit context. |
|
| 378 | - * @return string |
|
| 379 | - */ |
|
| 380 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 362 | + /** |
|
| 363 | + * Alias for self::get_date_created(). |
|
| 364 | + * |
|
| 365 | + * @since 1.0.19 |
|
| 366 | + * @param string $context View or edit context. |
|
| 367 | + * @return string |
|
| 368 | + */ |
|
| 369 | + public function get_created_date( $context = 'view' ) { |
|
| 370 | + return $this->get_date_created( $context ); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * Get GMT date when the invoice was created. |
|
| 375 | + * |
|
| 376 | + * @since 1.0.19 |
|
| 377 | + * @param string $context View or edit context. |
|
| 378 | + * @return string |
|
| 379 | + */ |
|
| 380 | + public function get_date_created_gmt( $context = 'view' ) { |
|
| 381 | 381 | $date = $this->get_date_created( $context ); |
| 382 | 382 | |
| 383 | 383 | if ( $date ) { |
| 384 | 384 | $date = get_gmt_from_date( $date ); |
| 385 | 385 | } |
| 386 | - return $date; |
|
| 386 | + return $date; |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | - * Get date when the invoice was last modified. |
|
| 391 | - * |
|
| 392 | - * @since 1.0.19 |
|
| 393 | - * @param string $context View or edit context. |
|
| 394 | - * @return string |
|
| 395 | - */ |
|
| 396 | - public function get_date_modified( $context = 'view' ) { |
|
| 397 | - return $this->get_prop( 'date_modified', $context ); |
|
| 398 | - } |
|
| 390 | + * Get date when the invoice was last modified. |
|
| 391 | + * |
|
| 392 | + * @since 1.0.19 |
|
| 393 | + * @param string $context View or edit context. |
|
| 394 | + * @return string |
|
| 395 | + */ |
|
| 396 | + public function get_date_modified( $context = 'view' ) { |
|
| 397 | + return $this->get_prop( 'date_modified', $context ); |
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | - /** |
|
| 401 | - * Alias for self::get_date_modified(). |
|
| 402 | - * |
|
| 403 | - * @since 1.0.19 |
|
| 404 | - * @param string $context View or edit context. |
|
| 405 | - * @return string |
|
| 406 | - */ |
|
| 407 | - public function get_modified_date( $context = 'view' ) { |
|
| 408 | - return $this->get_date_modified( $context ); |
|
| 400 | + /** |
|
| 401 | + * Alias for self::get_date_modified(). |
|
| 402 | + * |
|
| 403 | + * @since 1.0.19 |
|
| 404 | + * @param string $context View or edit context. |
|
| 405 | + * @return string |
|
| 406 | + */ |
|
| 407 | + public function get_modified_date( $context = 'view' ) { |
|
| 408 | + return $this->get_date_modified( $context ); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
| 412 | - * Get GMT date when the invoice was last modified. |
|
| 413 | - * |
|
| 414 | - * @since 1.0.19 |
|
| 415 | - * @param string $context View or edit context. |
|
| 416 | - * @return string |
|
| 417 | - */ |
|
| 418 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 412 | + * Get GMT date when the invoice was last modified. |
|
| 413 | + * |
|
| 414 | + * @since 1.0.19 |
|
| 415 | + * @param string $context View or edit context. |
|
| 416 | + * @return string |
|
| 417 | + */ |
|
| 418 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
| 419 | 419 | $date = $this->get_date_modified( $context ); |
| 420 | 420 | |
| 421 | 421 | if ( $date ) { |
| 422 | 422 | $date = get_gmt_from_date( $date ); |
| 423 | 423 | } |
| 424 | - return $date; |
|
| 424 | + return $date; |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
| 428 | - * Get the invoice due date. |
|
| 429 | - * |
|
| 430 | - * @since 1.0.19 |
|
| 431 | - * @param string $context View or edit context. |
|
| 432 | - * @return string |
|
| 433 | - */ |
|
| 434 | - public function get_due_date( $context = 'view' ) { |
|
| 435 | - return $this->get_prop( 'due_date', $context ); |
|
| 428 | + * Get the invoice due date. |
|
| 429 | + * |
|
| 430 | + * @since 1.0.19 |
|
| 431 | + * @param string $context View or edit context. |
|
| 432 | + * @return string |
|
| 433 | + */ |
|
| 434 | + public function get_due_date( $context = 'view' ) { |
|
| 435 | + return $this->get_prop( 'due_date', $context ); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
| 439 | - * Alias for self::get_due_date(). |
|
| 440 | - * |
|
| 441 | - * @since 1.0.19 |
|
| 442 | - * @param string $context View or edit context. |
|
| 443 | - * @return string |
|
| 444 | - */ |
|
| 445 | - public function get_date_due( $context = 'view' ) { |
|
| 446 | - return $this->get_due_date( $context ); |
|
| 439 | + * Alias for self::get_due_date(). |
|
| 440 | + * |
|
| 441 | + * @since 1.0.19 |
|
| 442 | + * @param string $context View or edit context. |
|
| 443 | + * @return string |
|
| 444 | + */ |
|
| 445 | + public function get_date_due( $context = 'view' ) { |
|
| 446 | + return $this->get_due_date( $context ); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
| 450 | - * Get the invoice GMT due date. |
|
| 451 | - * |
|
| 452 | - * @since 1.0.19 |
|
| 453 | - * @param string $context View or edit context. |
|
| 454 | - * @return string |
|
| 455 | - */ |
|
| 456 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 450 | + * Get the invoice GMT due date. |
|
| 451 | + * |
|
| 452 | + * @since 1.0.19 |
|
| 453 | + * @param string $context View or edit context. |
|
| 454 | + * @return string |
|
| 455 | + */ |
|
| 456 | + public function get_due_date_gmt( $context = 'view' ) { |
|
| 457 | 457 | $date = $this->get_due_date( $context ); |
| 458 | 458 | |
| 459 | 459 | if ( $date ) { |
| 460 | 460 | $date = get_gmt_from_date( $date ); |
| 461 | 461 | } |
| 462 | - return $date; |
|
| 462 | + return $date; |
|
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | /** |
| 466 | - * Alias for self::get_due_date_gmt(). |
|
| 467 | - * |
|
| 468 | - * @since 1.0.19 |
|
| 469 | - * @param string $context View or edit context. |
|
| 470 | - * @return string |
|
| 471 | - */ |
|
| 472 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 473 | - return $this->get_due_date_gmt( $context ); |
|
| 466 | + * Alias for self::get_due_date_gmt(). |
|
| 467 | + * |
|
| 468 | + * @since 1.0.19 |
|
| 469 | + * @param string $context View or edit context. |
|
| 470 | + * @return string |
|
| 471 | + */ |
|
| 472 | + public function get_gmt_date_due( $context = 'view' ) { |
|
| 473 | + return $this->get_due_date_gmt( $context ); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
| 477 | - * Get date when the invoice was completed. |
|
| 478 | - * |
|
| 479 | - * @since 1.0.19 |
|
| 480 | - * @param string $context View or edit context. |
|
| 481 | - * @return string |
|
| 482 | - */ |
|
| 483 | - public function get_completed_date( $context = 'view' ) { |
|
| 484 | - return $this->get_prop( 'completed_date', $context ); |
|
| 477 | + * Get date when the invoice was completed. |
|
| 478 | + * |
|
| 479 | + * @since 1.0.19 |
|
| 480 | + * @param string $context View or edit context. |
|
| 481 | + * @return string |
|
| 482 | + */ |
|
| 483 | + public function get_completed_date( $context = 'view' ) { |
|
| 484 | + return $this->get_prop( 'completed_date', $context ); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
| 488 | - * Alias for self::get_completed_date(). |
|
| 489 | - * |
|
| 490 | - * @since 1.0.19 |
|
| 491 | - * @param string $context View or edit context. |
|
| 492 | - * @return string |
|
| 493 | - */ |
|
| 494 | - public function get_date_completed( $context = 'view' ) { |
|
| 495 | - return $this->get_completed_date( $context ); |
|
| 488 | + * Alias for self::get_completed_date(). |
|
| 489 | + * |
|
| 490 | + * @since 1.0.19 |
|
| 491 | + * @param string $context View or edit context. |
|
| 492 | + * @return string |
|
| 493 | + */ |
|
| 494 | + public function get_date_completed( $context = 'view' ) { |
|
| 495 | + return $this->get_completed_date( $context ); |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | /** |
| 499 | - * Get GMT date when the invoice was was completed. |
|
| 500 | - * |
|
| 501 | - * @since 1.0.19 |
|
| 502 | - * @param string $context View or edit context. |
|
| 503 | - * @return string |
|
| 504 | - */ |
|
| 505 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 499 | + * Get GMT date when the invoice was was completed. |
|
| 500 | + * |
|
| 501 | + * @since 1.0.19 |
|
| 502 | + * @param string $context View or edit context. |
|
| 503 | + * @return string |
|
| 504 | + */ |
|
| 505 | + public function get_completed_date_gmt( $context = 'view' ) { |
|
| 506 | 506 | $date = $this->get_completed_date( $context ); |
| 507 | 507 | |
| 508 | 508 | if ( $date ) { |
| 509 | 509 | $date = get_gmt_from_date( $date ); |
| 510 | 510 | } |
| 511 | - return $date; |
|
| 511 | + return $date; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
| 515 | - * Alias for self::get_completed_date_gmt(). |
|
| 516 | - * |
|
| 517 | - * @since 1.0.19 |
|
| 518 | - * @param string $context View or edit context. |
|
| 519 | - * @return string |
|
| 520 | - */ |
|
| 521 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 522 | - return $this->get_completed_date_gmt( $context ); |
|
| 515 | + * Alias for self::get_completed_date_gmt(). |
|
| 516 | + * |
|
| 517 | + * @since 1.0.19 |
|
| 518 | + * @param string $context View or edit context. |
|
| 519 | + * @return string |
|
| 520 | + */ |
|
| 521 | + public function get_gmt_completed_date( $context = 'view' ) { |
|
| 522 | + return $this->get_completed_date_gmt( $context ); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
| 526 | - * Get the invoice number. |
|
| 527 | - * |
|
| 528 | - * @since 1.0.19 |
|
| 529 | - * @param string $context View or edit context. |
|
| 530 | - * @return string |
|
| 531 | - */ |
|
| 532 | - public function get_number( $context = 'view' ) { |
|
| 533 | - $number = $this->get_prop( 'number', $context ); |
|
| 526 | + * Get the invoice number. |
|
| 527 | + * |
|
| 528 | + * @since 1.0.19 |
|
| 529 | + * @param string $context View or edit context. |
|
| 530 | + * @return string |
|
| 531 | + */ |
|
| 532 | + public function get_number( $context = 'view' ) { |
|
| 533 | + $number = $this->get_prop( 'number', $context ); |
|
| 534 | 534 | |
| 535 | - if ( empty( $number ) ) { |
|
| 536 | - $number = $this->generate_number(); |
|
| 537 | - $this->set_number( $this->generate_number() ); |
|
| 538 | - } |
|
| 535 | + if ( empty( $number ) ) { |
|
| 536 | + $number = $this->generate_number(); |
|
| 537 | + $this->set_number( $this->generate_number() ); |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | - return $number; |
|
| 540 | + return $number; |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - /** |
|
| 544 | - * Set the invoice number. |
|
| 545 | - * |
|
| 546 | - * @since 1.0.19 |
|
| 547 | - */ |
|
| 548 | - public function maybe_set_number() { |
|
| 543 | + /** |
|
| 544 | + * Set the invoice number. |
|
| 545 | + * |
|
| 546 | + * @since 1.0.19 |
|
| 547 | + */ |
|
| 548 | + public function maybe_set_number() { |
|
| 549 | 549 | $number = $this->get_number(); |
| 550 | 550 | |
| 551 | 551 | if ( empty( $number ) || $this->get_id() == $number ) { |
| 552 | - $this->set_number( $this->generate_number() ); |
|
| 552 | + $this->set_number( $this->generate_number() ); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | - } |
|
| 555 | + } |
|
| 556 | 556 | |
| 557 | 557 | /** |
| 558 | - * Get the invoice key. |
|
| 559 | - * |
|
| 560 | - * @since 1.0.19 |
|
| 561 | - * @param string $context View or edit context. |
|
| 562 | - * @return string |
|
| 563 | - */ |
|
| 564 | - public function get_key( $context = 'view' ) { |
|
| 558 | + * Get the invoice key. |
|
| 559 | + * |
|
| 560 | + * @since 1.0.19 |
|
| 561 | + * @param string $context View or edit context. |
|
| 562 | + * @return string |
|
| 563 | + */ |
|
| 564 | + public function get_key( $context = 'view' ) { |
|
| 565 | 565 | return $this->get_prop( 'key', $context ); |
| 566 | - } |
|
| 567 | - |
|
| 568 | - /** |
|
| 569 | - * Set the invoice key. |
|
| 570 | - * |
|
| 571 | - * @since 1.0.19 |
|
| 572 | - */ |
|
| 573 | - public function maybe_set_key() { |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + /** |
|
| 569 | + * Set the invoice key. |
|
| 570 | + * |
|
| 571 | + * @since 1.0.19 |
|
| 572 | + */ |
|
| 573 | + public function maybe_set_key() { |
|
| 574 | 574 | $key = $this->get_key(); |
| 575 | 575 | |
| 576 | 576 | if ( empty( $key ) ) { |
@@ -581,129 +581,129 @@ discard block |
||
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /** |
| 584 | - * Get the invoice type. |
|
| 585 | - * |
|
| 586 | - * @since 1.0.19 |
|
| 587 | - * @param string $context View or edit context. |
|
| 588 | - * @return string |
|
| 589 | - */ |
|
| 590 | - public function get_type( $context = 'view' ) { |
|
| 584 | + * Get the invoice type. |
|
| 585 | + * |
|
| 586 | + * @since 1.0.19 |
|
| 587 | + * @param string $context View or edit context. |
|
| 588 | + * @return string |
|
| 589 | + */ |
|
| 590 | + public function get_type( $context = 'view' ) { |
|
| 591 | 591 | return $this->get_prop( 'type', $context ); |
| 592 | - } |
|
| 593 | - |
|
| 594 | - /** |
|
| 595 | - * Returns the post type name. |
|
| 596 | - * |
|
| 597 | - * @since 1.0.19 |
|
| 598 | - * @return string |
|
| 599 | - */ |
|
| 600 | - public function get_invoice_quote_type() { |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + /** |
|
| 595 | + * Returns the post type name. |
|
| 596 | + * |
|
| 597 | + * @since 1.0.19 |
|
| 598 | + * @return string |
|
| 599 | + */ |
|
| 600 | + public function get_invoice_quote_type() { |
|
| 601 | 601 | return getpaid_get_post_type_label( $this->get_post_type(), false ); |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
| 605 | - * Get the invoice post type. |
|
| 606 | - * |
|
| 607 | - * @since 1.0.19 |
|
| 608 | - * @param string $context View or edit context. |
|
| 609 | - * @return string |
|
| 610 | - */ |
|
| 611 | - public function get_post_type( $context = 'view' ) { |
|
| 605 | + * Get the invoice post type. |
|
| 606 | + * |
|
| 607 | + * @since 1.0.19 |
|
| 608 | + * @param string $context View or edit context. |
|
| 609 | + * @return string |
|
| 610 | + */ |
|
| 611 | + public function get_post_type( $context = 'view' ) { |
|
| 612 | 612 | return $this->get_prop( 'post_type', $context ); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
| 616 | - * Get the invoice mode. |
|
| 617 | - * |
|
| 618 | - * @since 1.0.19 |
|
| 619 | - * @param string $context View or edit context. |
|
| 620 | - * @return string |
|
| 621 | - */ |
|
| 622 | - public function get_mode( $context = 'view' ) { |
|
| 616 | + * Get the invoice mode. |
|
| 617 | + * |
|
| 618 | + * @since 1.0.19 |
|
| 619 | + * @param string $context View or edit context. |
|
| 620 | + * @return string |
|
| 621 | + */ |
|
| 622 | + public function get_mode( $context = 'view' ) { |
|
| 623 | 623 | return $this->get_prop( 'mode', $context ); |
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | /** |
| 627 | - * Get the invoice path. |
|
| 628 | - * |
|
| 629 | - * @since 1.0.19 |
|
| 630 | - * @param string $context View or edit context. |
|
| 631 | - * @return string |
|
| 632 | - */ |
|
| 633 | - public function get_path( $context = 'view' ) { |
|
| 627 | + * Get the invoice path. |
|
| 628 | + * |
|
| 629 | + * @since 1.0.19 |
|
| 630 | + * @param string $context View or edit context. |
|
| 631 | + * @return string |
|
| 632 | + */ |
|
| 633 | + public function get_path( $context = 'view' ) { |
|
| 634 | 634 | $path = $this->get_prop( 'path', $context ); |
| 635 | - $prefix = $this->get_type(); |
|
| 635 | + $prefix = $this->get_type(); |
|
| 636 | 636 | |
| 637 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 638 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 639 | - $this->set_path( $path ); |
|
| 640 | - } |
|
| 637 | + if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 638 | + $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 639 | + $this->set_path( $path ); |
|
| 640 | + } |
|
| 641 | 641 | |
| 642 | - return $path; |
|
| 642 | + return $path; |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /** |
| 646 | - * Get the invoice name/title. |
|
| 647 | - * |
|
| 648 | - * @since 1.0.19 |
|
| 649 | - * @param string $context View or edit context. |
|
| 650 | - * @return string |
|
| 651 | - */ |
|
| 652 | - public function get_name( $context = 'view' ) { |
|
| 646 | + * Get the invoice name/title. |
|
| 647 | + * |
|
| 648 | + * @since 1.0.19 |
|
| 649 | + * @param string $context View or edit context. |
|
| 650 | + * @return string |
|
| 651 | + */ |
|
| 652 | + public function get_name( $context = 'view' ) { |
|
| 653 | 653 | return $this->get_prop( 'title', $context ); |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | /** |
| 657 | - * Alias of self::get_name(). |
|
| 658 | - * |
|
| 659 | - * @since 1.0.19 |
|
| 660 | - * @param string $context View or edit context. |
|
| 661 | - * @return string |
|
| 662 | - */ |
|
| 663 | - public function get_title( $context = 'view' ) { |
|
| 664 | - return $this->get_name( $context ); |
|
| 657 | + * Alias of self::get_name(). |
|
| 658 | + * |
|
| 659 | + * @since 1.0.19 |
|
| 660 | + * @param string $context View or edit context. |
|
| 661 | + * @return string |
|
| 662 | + */ |
|
| 663 | + public function get_title( $context = 'view' ) { |
|
| 664 | + return $this->get_name( $context ); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
| 668 | - * Get the invoice description. |
|
| 669 | - * |
|
| 670 | - * @since 1.0.19 |
|
| 671 | - * @param string $context View or edit context. |
|
| 672 | - * @return string |
|
| 673 | - */ |
|
| 674 | - public function get_description( $context = 'view' ) { |
|
| 675 | - return $this->get_prop( 'description', $context ); |
|
| 668 | + * Get the invoice description. |
|
| 669 | + * |
|
| 670 | + * @since 1.0.19 |
|
| 671 | + * @param string $context View or edit context. |
|
| 672 | + * @return string |
|
| 673 | + */ |
|
| 674 | + public function get_description( $context = 'view' ) { |
|
| 675 | + return $this->get_prop( 'description', $context ); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
| 679 | - * Alias of self::get_description(). |
|
| 680 | - * |
|
| 681 | - * @since 1.0.19 |
|
| 682 | - * @param string $context View or edit context. |
|
| 683 | - * @return string |
|
| 684 | - */ |
|
| 685 | - public function get_excerpt( $context = 'view' ) { |
|
| 686 | - return $this->get_description( $context ); |
|
| 679 | + * Alias of self::get_description(). |
|
| 680 | + * |
|
| 681 | + * @since 1.0.19 |
|
| 682 | + * @param string $context View or edit context. |
|
| 683 | + * @return string |
|
| 684 | + */ |
|
| 685 | + public function get_excerpt( $context = 'view' ) { |
|
| 686 | + return $this->get_description( $context ); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | /** |
| 690 | - * Alias of self::get_description(). |
|
| 691 | - * |
|
| 692 | - * @since 1.0.19 |
|
| 693 | - * @param string $context View or edit context. |
|
| 694 | - * @return string |
|
| 695 | - */ |
|
| 696 | - public function get_summary( $context = 'view' ) { |
|
| 697 | - return $this->get_description( $context ); |
|
| 690 | + * Alias of self::get_description(). |
|
| 691 | + * |
|
| 692 | + * @since 1.0.19 |
|
| 693 | + * @param string $context View or edit context. |
|
| 694 | + * @return string |
|
| 695 | + */ |
|
| 696 | + public function get_summary( $context = 'view' ) { |
|
| 697 | + return $this->get_description( $context ); |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | /** |
| 701 | - * Returns the user info. |
|
| 702 | - * |
|
| 703 | - * @since 1.0.19 |
|
| 701 | + * Returns the user info. |
|
| 702 | + * |
|
| 703 | + * @since 1.0.19 |
|
| 704 | 704 | * @param string $context View or edit context. |
| 705 | - * @return array |
|
| 706 | - */ |
|
| 705 | + * @return array |
|
| 706 | + */ |
|
| 707 | 707 | public function get_user_info( $context = 'view' ) { |
| 708 | 708 | |
| 709 | 709 | $user_info = array( |
@@ -720,616 +720,616 @@ discard block |
||
| 720 | 720 | 'company' => $this->get_company( $context ), |
| 721 | 721 | 'vat_number' => $this->get_vat_number( $context ), |
| 722 | 722 | 'discount' => $this->get_discount_code( $context ), |
| 723 | - ); |
|
| 723 | + ); |
|
| 724 | 724 | |
| 725 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 725 | + return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 726 | 726 | |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | /** |
| 730 | - * Get the customer id. |
|
| 731 | - * |
|
| 732 | - * @since 1.0.19 |
|
| 733 | - * @param string $context View or edit context. |
|
| 734 | - * @return int |
|
| 735 | - */ |
|
| 736 | - public function get_author( $context = 'view' ) { |
|
| 737 | - return (int) $this->get_prop( 'author', $context ); |
|
| 730 | + * Get the customer id. |
|
| 731 | + * |
|
| 732 | + * @since 1.0.19 |
|
| 733 | + * @param string $context View or edit context. |
|
| 734 | + * @return int |
|
| 735 | + */ |
|
| 736 | + public function get_author( $context = 'view' ) { |
|
| 737 | + return (int) $this->get_prop( 'author', $context ); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
| 741 | - * Alias of self::get_author(). |
|
| 742 | - * |
|
| 743 | - * @since 1.0.19 |
|
| 744 | - * @param string $context View or edit context. |
|
| 745 | - * @return int |
|
| 746 | - */ |
|
| 747 | - public function get_user_id( $context = 'view' ) { |
|
| 748 | - return $this->get_author( $context ); |
|
| 741 | + * Alias of self::get_author(). |
|
| 742 | + * |
|
| 743 | + * @since 1.0.19 |
|
| 744 | + * @param string $context View or edit context. |
|
| 745 | + * @return int |
|
| 746 | + */ |
|
| 747 | + public function get_user_id( $context = 'view' ) { |
|
| 748 | + return $this->get_author( $context ); |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - /** |
|
| 752 | - * Alias of self::get_author(). |
|
| 753 | - * |
|
| 754 | - * @since 1.0.19 |
|
| 755 | - * @param string $context View or edit context. |
|
| 756 | - * @return int |
|
| 757 | - */ |
|
| 758 | - public function get_customer_id( $context = 'view' ) { |
|
| 759 | - return $this->get_author( $context ); |
|
| 751 | + /** |
|
| 752 | + * Alias of self::get_author(). |
|
| 753 | + * |
|
| 754 | + * @since 1.0.19 |
|
| 755 | + * @param string $context View or edit context. |
|
| 756 | + * @return int |
|
| 757 | + */ |
|
| 758 | + public function get_customer_id( $context = 'view' ) { |
|
| 759 | + return $this->get_author( $context ); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
| 763 | - * Get the customer's ip. |
|
| 764 | - * |
|
| 765 | - * @since 1.0.19 |
|
| 766 | - * @param string $context View or edit context. |
|
| 767 | - * @return string |
|
| 768 | - */ |
|
| 769 | - public function get_ip( $context = 'view' ) { |
|
| 770 | - return $this->get_prop( 'user_ip', $context ); |
|
| 763 | + * Get the customer's ip. |
|
| 764 | + * |
|
| 765 | + * @since 1.0.19 |
|
| 766 | + * @param string $context View or edit context. |
|
| 767 | + * @return string |
|
| 768 | + */ |
|
| 769 | + public function get_ip( $context = 'view' ) { |
|
| 770 | + return $this->get_prop( 'user_ip', $context ); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
| 774 | - * Alias of self::get_ip(). |
|
| 775 | - * |
|
| 776 | - * @since 1.0.19 |
|
| 777 | - * @param string $context View or edit context. |
|
| 778 | - * @return string |
|
| 779 | - */ |
|
| 780 | - public function get_user_ip( $context = 'view' ) { |
|
| 781 | - return $this->get_ip( $context ); |
|
| 774 | + * Alias of self::get_ip(). |
|
| 775 | + * |
|
| 776 | + * @since 1.0.19 |
|
| 777 | + * @param string $context View or edit context. |
|
| 778 | + * @return string |
|
| 779 | + */ |
|
| 780 | + public function get_user_ip( $context = 'view' ) { |
|
| 781 | + return $this->get_ip( $context ); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - /** |
|
| 785 | - * Alias of self::get_ip(). |
|
| 786 | - * |
|
| 787 | - * @since 1.0.19 |
|
| 788 | - * @param string $context View or edit context. |
|
| 789 | - * @return string |
|
| 790 | - */ |
|
| 791 | - public function get_customer_ip( $context = 'view' ) { |
|
| 792 | - return $this->get_ip( $context ); |
|
| 784 | + /** |
|
| 785 | + * Alias of self::get_ip(). |
|
| 786 | + * |
|
| 787 | + * @since 1.0.19 |
|
| 788 | + * @param string $context View or edit context. |
|
| 789 | + * @return string |
|
| 790 | + */ |
|
| 791 | + public function get_customer_ip( $context = 'view' ) { |
|
| 792 | + return $this->get_ip( $context ); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
| 796 | - * Get the customer's first name. |
|
| 797 | - * |
|
| 798 | - * @since 1.0.19 |
|
| 799 | - * @param string $context View or edit context. |
|
| 800 | - * @return string |
|
| 801 | - */ |
|
| 802 | - public function get_first_name( $context = 'view' ) { |
|
| 803 | - return $this->get_prop( 'first_name', $context ); |
|
| 796 | + * Get the customer's first name. |
|
| 797 | + * |
|
| 798 | + * @since 1.0.19 |
|
| 799 | + * @param string $context View or edit context. |
|
| 800 | + * @return string |
|
| 801 | + */ |
|
| 802 | + public function get_first_name( $context = 'view' ) { |
|
| 803 | + return $this->get_prop( 'first_name', $context ); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | /** |
| 807 | - * Alias of self::get_first_name(). |
|
| 808 | - * |
|
| 809 | - * @since 1.0.19 |
|
| 810 | - * @param string $context View or edit context. |
|
| 811 | - * @return string |
|
| 812 | - */ |
|
| 813 | - public function get_user_first_name( $context = 'view' ) { |
|
| 814 | - return $this->get_first_name( $context ); |
|
| 807 | + * Alias of self::get_first_name(). |
|
| 808 | + * |
|
| 809 | + * @since 1.0.19 |
|
| 810 | + * @param string $context View or edit context. |
|
| 811 | + * @return string |
|
| 812 | + */ |
|
| 813 | + public function get_user_first_name( $context = 'view' ) { |
|
| 814 | + return $this->get_first_name( $context ); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | - /** |
|
| 818 | - * Alias of self::get_first_name(). |
|
| 819 | - * |
|
| 820 | - * @since 1.0.19 |
|
| 821 | - * @param string $context View or edit context. |
|
| 822 | - * @return string |
|
| 823 | - */ |
|
| 824 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 825 | - return $this->get_first_name( $context ); |
|
| 817 | + /** |
|
| 818 | + * Alias of self::get_first_name(). |
|
| 819 | + * |
|
| 820 | + * @since 1.0.19 |
|
| 821 | + * @param string $context View or edit context. |
|
| 822 | + * @return string |
|
| 823 | + */ |
|
| 824 | + public function get_customer_first_name( $context = 'view' ) { |
|
| 825 | + return $this->get_first_name( $context ); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | /** |
| 829 | - * Get the customer's last name. |
|
| 830 | - * |
|
| 831 | - * @since 1.0.19 |
|
| 832 | - * @param string $context View or edit context. |
|
| 833 | - * @return string |
|
| 834 | - */ |
|
| 835 | - public function get_last_name( $context = 'view' ) { |
|
| 836 | - return $this->get_prop( 'last_name', $context ); |
|
| 829 | + * Get the customer's last name. |
|
| 830 | + * |
|
| 831 | + * @since 1.0.19 |
|
| 832 | + * @param string $context View or edit context. |
|
| 833 | + * @return string |
|
| 834 | + */ |
|
| 835 | + public function get_last_name( $context = 'view' ) { |
|
| 836 | + return $this->get_prop( 'last_name', $context ); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
| 840 | - * Alias of self::get_last_name(). |
|
| 841 | - * |
|
| 842 | - * @since 1.0.19 |
|
| 843 | - * @param string $context View or edit context. |
|
| 844 | - * @return string |
|
| 845 | - */ |
|
| 846 | - public function get_user_last_name( $context = 'view' ) { |
|
| 847 | - return $this->get_last_name( $context ); |
|
| 840 | + * Alias of self::get_last_name(). |
|
| 841 | + * |
|
| 842 | + * @since 1.0.19 |
|
| 843 | + * @param string $context View or edit context. |
|
| 844 | + * @return string |
|
| 845 | + */ |
|
| 846 | + public function get_user_last_name( $context = 'view' ) { |
|
| 847 | + return $this->get_last_name( $context ); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | /** |
| 851 | - * Alias of self::get_last_name(). |
|
| 852 | - * |
|
| 853 | - * @since 1.0.19 |
|
| 854 | - * @param string $context View or edit context. |
|
| 855 | - * @return string |
|
| 856 | - */ |
|
| 857 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 858 | - return $this->get_last_name( $context ); |
|
| 851 | + * Alias of self::get_last_name(). |
|
| 852 | + * |
|
| 853 | + * @since 1.0.19 |
|
| 854 | + * @param string $context View or edit context. |
|
| 855 | + * @return string |
|
| 856 | + */ |
|
| 857 | + public function get_customer_last_name( $context = 'view' ) { |
|
| 858 | + return $this->get_last_name( $context ); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | /** |
| 862 | - * Get the customer's full name. |
|
| 863 | - * |
|
| 864 | - * @since 1.0.19 |
|
| 865 | - * @param string $context View or edit context. |
|
| 866 | - * @return string |
|
| 867 | - */ |
|
| 868 | - public function get_full_name( $context = 'view' ) { |
|
| 869 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 862 | + * Get the customer's full name. |
|
| 863 | + * |
|
| 864 | + * @since 1.0.19 |
|
| 865 | + * @param string $context View or edit context. |
|
| 866 | + * @return string |
|
| 867 | + */ |
|
| 868 | + public function get_full_name( $context = 'view' ) { |
|
| 869 | + return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | /** |
| 873 | - * Alias of self::get_full_name(). |
|
| 874 | - * |
|
| 875 | - * @since 1.0.19 |
|
| 876 | - * @param string $context View or edit context. |
|
| 877 | - * @return string |
|
| 878 | - */ |
|
| 879 | - public function get_user_full_name( $context = 'view' ) { |
|
| 880 | - return $this->get_full_name( $context ); |
|
| 873 | + * Alias of self::get_full_name(). |
|
| 874 | + * |
|
| 875 | + * @since 1.0.19 |
|
| 876 | + * @param string $context View or edit context. |
|
| 877 | + * @return string |
|
| 878 | + */ |
|
| 879 | + public function get_user_full_name( $context = 'view' ) { |
|
| 880 | + return $this->get_full_name( $context ); |
|
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | /** |
| 884 | - * Alias of self::get_full_name(). |
|
| 885 | - * |
|
| 886 | - * @since 1.0.19 |
|
| 887 | - * @param string $context View or edit context. |
|
| 888 | - * @return string |
|
| 889 | - */ |
|
| 890 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 891 | - return $this->get_full_name( $context ); |
|
| 884 | + * Alias of self::get_full_name(). |
|
| 885 | + * |
|
| 886 | + * @since 1.0.19 |
|
| 887 | + * @param string $context View or edit context. |
|
| 888 | + * @return string |
|
| 889 | + */ |
|
| 890 | + public function get_customer_full_name( $context = 'view' ) { |
|
| 891 | + return $this->get_full_name( $context ); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | /** |
| 895 | - * Get the customer's phone number. |
|
| 896 | - * |
|
| 897 | - * @since 1.0.19 |
|
| 898 | - * @param string $context View or edit context. |
|
| 899 | - * @return string |
|
| 900 | - */ |
|
| 901 | - public function get_phone( $context = 'view' ) { |
|
| 902 | - return $this->get_prop( 'phone', $context ); |
|
| 895 | + * Get the customer's phone number. |
|
| 896 | + * |
|
| 897 | + * @since 1.0.19 |
|
| 898 | + * @param string $context View or edit context. |
|
| 899 | + * @return string |
|
| 900 | + */ |
|
| 901 | + public function get_phone( $context = 'view' ) { |
|
| 902 | + return $this->get_prop( 'phone', $context ); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
| 906 | - * Alias of self::get_phone(). |
|
| 907 | - * |
|
| 908 | - * @since 1.0.19 |
|
| 909 | - * @param string $context View or edit context. |
|
| 910 | - * @return string |
|
| 911 | - */ |
|
| 912 | - public function get_phone_number( $context = 'view' ) { |
|
| 913 | - return $this->get_phone( $context ); |
|
| 906 | + * Alias of self::get_phone(). |
|
| 907 | + * |
|
| 908 | + * @since 1.0.19 |
|
| 909 | + * @param string $context View or edit context. |
|
| 910 | + * @return string |
|
| 911 | + */ |
|
| 912 | + public function get_phone_number( $context = 'view' ) { |
|
| 913 | + return $this->get_phone( $context ); |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | /** |
| 917 | - * Alias of self::get_phone(). |
|
| 918 | - * |
|
| 919 | - * @since 1.0.19 |
|
| 920 | - * @param string $context View or edit context. |
|
| 921 | - * @return string |
|
| 922 | - */ |
|
| 923 | - public function get_user_phone( $context = 'view' ) { |
|
| 924 | - return $this->get_phone( $context ); |
|
| 917 | + * Alias of self::get_phone(). |
|
| 918 | + * |
|
| 919 | + * @since 1.0.19 |
|
| 920 | + * @param string $context View or edit context. |
|
| 921 | + * @return string |
|
| 922 | + */ |
|
| 923 | + public function get_user_phone( $context = 'view' ) { |
|
| 924 | + return $this->get_phone( $context ); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | /** |
| 928 | - * Alias of self::get_phone(). |
|
| 929 | - * |
|
| 930 | - * @since 1.0.19 |
|
| 931 | - * @param string $context View or edit context. |
|
| 932 | - * @return string |
|
| 933 | - */ |
|
| 934 | - public function get_customer_phone( $context = 'view' ) { |
|
| 935 | - return $this->get_phone( $context ); |
|
| 928 | + * Alias of self::get_phone(). |
|
| 929 | + * |
|
| 930 | + * @since 1.0.19 |
|
| 931 | + * @param string $context View or edit context. |
|
| 932 | + * @return string |
|
| 933 | + */ |
|
| 934 | + public function get_customer_phone( $context = 'view' ) { |
|
| 935 | + return $this->get_phone( $context ); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | /** |
| 939 | - * Get the customer's email address. |
|
| 940 | - * |
|
| 941 | - * @since 1.0.19 |
|
| 942 | - * @param string $context View or edit context. |
|
| 943 | - * @return string |
|
| 944 | - */ |
|
| 945 | - public function get_email( $context = 'view' ) { |
|
| 946 | - return $this->get_prop( 'email', $context ); |
|
| 939 | + * Get the customer's email address. |
|
| 940 | + * |
|
| 941 | + * @since 1.0.19 |
|
| 942 | + * @param string $context View or edit context. |
|
| 943 | + * @return string |
|
| 944 | + */ |
|
| 945 | + public function get_email( $context = 'view' ) { |
|
| 946 | + return $this->get_prop( 'email', $context ); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | /** |
| 950 | - * Alias of self::get_email(). |
|
| 951 | - * |
|
| 952 | - * @since 1.0.19 |
|
| 953 | - * @param string $context View or edit context. |
|
| 954 | - * @return string |
|
| 955 | - */ |
|
| 956 | - public function get_email_address( $context = 'view' ) { |
|
| 957 | - return $this->get_email( $context ); |
|
| 950 | + * Alias of self::get_email(). |
|
| 951 | + * |
|
| 952 | + * @since 1.0.19 |
|
| 953 | + * @param string $context View or edit context. |
|
| 954 | + * @return string |
|
| 955 | + */ |
|
| 956 | + public function get_email_address( $context = 'view' ) { |
|
| 957 | + return $this->get_email( $context ); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /** |
| 961 | - * Alias of self::get_email(). |
|
| 962 | - * |
|
| 963 | - * @since 1.0.19 |
|
| 964 | - * @param string $context View or edit context. |
|
| 965 | - * @return string |
|
| 966 | - */ |
|
| 967 | - public function get_user_email( $context = 'view' ) { |
|
| 968 | - return $this->get_email( $context ); |
|
| 961 | + * Alias of self::get_email(). |
|
| 962 | + * |
|
| 963 | + * @since 1.0.19 |
|
| 964 | + * @param string $context View or edit context. |
|
| 965 | + * @return string |
|
| 966 | + */ |
|
| 967 | + public function get_user_email( $context = 'view' ) { |
|
| 968 | + return $this->get_email( $context ); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | /** |
| 972 | - * Alias of self::get_email(). |
|
| 973 | - * |
|
| 974 | - * @since 1.0.19 |
|
| 975 | - * @param string $context View or edit context. |
|
| 976 | - * @return string |
|
| 977 | - */ |
|
| 978 | - public function get_customer_email( $context = 'view' ) { |
|
| 979 | - return $this->get_email( $context ); |
|
| 972 | + * Alias of self::get_email(). |
|
| 973 | + * |
|
| 974 | + * @since 1.0.19 |
|
| 975 | + * @param string $context View or edit context. |
|
| 976 | + * @return string |
|
| 977 | + */ |
|
| 978 | + public function get_customer_email( $context = 'view' ) { |
|
| 979 | + return $this->get_email( $context ); |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | /** |
| 983 | - * Get the customer's country. |
|
| 984 | - * |
|
| 985 | - * @since 1.0.19 |
|
| 986 | - * @param string $context View or edit context. |
|
| 987 | - * @return string |
|
| 988 | - */ |
|
| 989 | - public function get_country( $context = 'view' ) { |
|
| 990 | - $country = $this->get_prop( 'country', $context ); |
|
| 991 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 983 | + * Get the customer's country. |
|
| 984 | + * |
|
| 985 | + * @since 1.0.19 |
|
| 986 | + * @param string $context View or edit context. |
|
| 987 | + * @return string |
|
| 988 | + */ |
|
| 989 | + public function get_country( $context = 'view' ) { |
|
| 990 | + $country = $this->get_prop( 'country', $context ); |
|
| 991 | + return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | /** |
| 995 | - * Alias of self::get_country(). |
|
| 996 | - * |
|
| 997 | - * @since 1.0.19 |
|
| 998 | - * @param string $context View or edit context. |
|
| 999 | - * @return string |
|
| 1000 | - */ |
|
| 1001 | - public function get_user_country( $context = 'view' ) { |
|
| 1002 | - return $this->get_country( $context ); |
|
| 995 | + * Alias of self::get_country(). |
|
| 996 | + * |
|
| 997 | + * @since 1.0.19 |
|
| 998 | + * @param string $context View or edit context. |
|
| 999 | + * @return string |
|
| 1000 | + */ |
|
| 1001 | + public function get_user_country( $context = 'view' ) { |
|
| 1002 | + return $this->get_country( $context ); |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | /** |
| 1006 | - * Alias of self::get_country(). |
|
| 1007 | - * |
|
| 1008 | - * @since 1.0.19 |
|
| 1009 | - * @param string $context View or edit context. |
|
| 1010 | - * @return string |
|
| 1011 | - */ |
|
| 1012 | - public function get_customer_country( $context = 'view' ) { |
|
| 1013 | - return $this->get_country( $context ); |
|
| 1006 | + * Alias of self::get_country(). |
|
| 1007 | + * |
|
| 1008 | + * @since 1.0.19 |
|
| 1009 | + * @param string $context View or edit context. |
|
| 1010 | + * @return string |
|
| 1011 | + */ |
|
| 1012 | + public function get_customer_country( $context = 'view' ) { |
|
| 1013 | + return $this->get_country( $context ); |
|
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | /** |
| 1017 | - * Get the customer's state. |
|
| 1018 | - * |
|
| 1019 | - * @since 1.0.19 |
|
| 1020 | - * @param string $context View or edit context. |
|
| 1021 | - * @return string |
|
| 1022 | - */ |
|
| 1023 | - public function get_state( $context = 'view' ) { |
|
| 1024 | - $state = $this->get_prop( 'state', $context ); |
|
| 1025 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1017 | + * Get the customer's state. |
|
| 1018 | + * |
|
| 1019 | + * @since 1.0.19 |
|
| 1020 | + * @param string $context View or edit context. |
|
| 1021 | + * @return string |
|
| 1022 | + */ |
|
| 1023 | + public function get_state( $context = 'view' ) { |
|
| 1024 | + $state = $this->get_prop( 'state', $context ); |
|
| 1025 | + return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | /** |
| 1029 | - * Alias of self::get_state(). |
|
| 1030 | - * |
|
| 1031 | - * @since 1.0.19 |
|
| 1032 | - * @param string $context View or edit context. |
|
| 1033 | - * @return string |
|
| 1034 | - */ |
|
| 1035 | - public function get_user_state( $context = 'view' ) { |
|
| 1036 | - return $this->get_state( $context ); |
|
| 1029 | + * Alias of self::get_state(). |
|
| 1030 | + * |
|
| 1031 | + * @since 1.0.19 |
|
| 1032 | + * @param string $context View or edit context. |
|
| 1033 | + * @return string |
|
| 1034 | + */ |
|
| 1035 | + public function get_user_state( $context = 'view' ) { |
|
| 1036 | + return $this->get_state( $context ); |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | /** |
| 1040 | - * Alias of self::get_state(). |
|
| 1041 | - * |
|
| 1042 | - * @since 1.0.19 |
|
| 1043 | - * @param string $context View or edit context. |
|
| 1044 | - * @return string |
|
| 1045 | - */ |
|
| 1046 | - public function get_customer_state( $context = 'view' ) { |
|
| 1047 | - return $this->get_state( $context ); |
|
| 1040 | + * Alias of self::get_state(). |
|
| 1041 | + * |
|
| 1042 | + * @since 1.0.19 |
|
| 1043 | + * @param string $context View or edit context. |
|
| 1044 | + * @return string |
|
| 1045 | + */ |
|
| 1046 | + public function get_customer_state( $context = 'view' ) { |
|
| 1047 | + return $this->get_state( $context ); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | 1050 | /** |
| 1051 | - * Get the customer's city. |
|
| 1052 | - * |
|
| 1053 | - * @since 1.0.19 |
|
| 1054 | - * @param string $context View or edit context. |
|
| 1055 | - * @return string |
|
| 1056 | - */ |
|
| 1057 | - public function get_city( $context = 'view' ) { |
|
| 1058 | - return $this->get_prop( 'city', $context ); |
|
| 1051 | + * Get the customer's city. |
|
| 1052 | + * |
|
| 1053 | + * @since 1.0.19 |
|
| 1054 | + * @param string $context View or edit context. |
|
| 1055 | + * @return string |
|
| 1056 | + */ |
|
| 1057 | + public function get_city( $context = 'view' ) { |
|
| 1058 | + return $this->get_prop( 'city', $context ); |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | /** |
| 1062 | - * Alias of self::get_city(). |
|
| 1063 | - * |
|
| 1064 | - * @since 1.0.19 |
|
| 1065 | - * @param string $context View or edit context. |
|
| 1066 | - * @return string |
|
| 1067 | - */ |
|
| 1068 | - public function get_user_city( $context = 'view' ) { |
|
| 1069 | - return $this->get_city( $context ); |
|
| 1062 | + * Alias of self::get_city(). |
|
| 1063 | + * |
|
| 1064 | + * @since 1.0.19 |
|
| 1065 | + * @param string $context View or edit context. |
|
| 1066 | + * @return string |
|
| 1067 | + */ |
|
| 1068 | + public function get_user_city( $context = 'view' ) { |
|
| 1069 | + return $this->get_city( $context ); |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | /** |
| 1073 | - * Alias of self::get_city(). |
|
| 1074 | - * |
|
| 1075 | - * @since 1.0.19 |
|
| 1076 | - * @param string $context View or edit context. |
|
| 1077 | - * @return string |
|
| 1078 | - */ |
|
| 1079 | - public function get_customer_city( $context = 'view' ) { |
|
| 1080 | - return $this->get_city( $context ); |
|
| 1073 | + * Alias of self::get_city(). |
|
| 1074 | + * |
|
| 1075 | + * @since 1.0.19 |
|
| 1076 | + * @param string $context View or edit context. |
|
| 1077 | + * @return string |
|
| 1078 | + */ |
|
| 1079 | + public function get_customer_city( $context = 'view' ) { |
|
| 1080 | + return $this->get_city( $context ); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | /** |
| 1084 | - * Get the customer's zip. |
|
| 1085 | - * |
|
| 1086 | - * @since 1.0.19 |
|
| 1087 | - * @param string $context View or edit context. |
|
| 1088 | - * @return string |
|
| 1089 | - */ |
|
| 1090 | - public function get_zip( $context = 'view' ) { |
|
| 1091 | - return $this->get_prop( 'zip', $context ); |
|
| 1084 | + * Get the customer's zip. |
|
| 1085 | + * |
|
| 1086 | + * @since 1.0.19 |
|
| 1087 | + * @param string $context View or edit context. |
|
| 1088 | + * @return string |
|
| 1089 | + */ |
|
| 1090 | + public function get_zip( $context = 'view' ) { |
|
| 1091 | + return $this->get_prop( 'zip', $context ); |
|
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | /** |
| 1095 | - * Alias of self::get_zip(). |
|
| 1096 | - * |
|
| 1097 | - * @since 1.0.19 |
|
| 1098 | - * @param string $context View or edit context. |
|
| 1099 | - * @return string |
|
| 1100 | - */ |
|
| 1101 | - public function get_user_zip( $context = 'view' ) { |
|
| 1102 | - return $this->get_zip( $context ); |
|
| 1095 | + * Alias of self::get_zip(). |
|
| 1096 | + * |
|
| 1097 | + * @since 1.0.19 |
|
| 1098 | + * @param string $context View or edit context. |
|
| 1099 | + * @return string |
|
| 1100 | + */ |
|
| 1101 | + public function get_user_zip( $context = 'view' ) { |
|
| 1102 | + return $this->get_zip( $context ); |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | 1105 | /** |
| 1106 | - * Alias of self::get_zip(). |
|
| 1107 | - * |
|
| 1108 | - * @since 1.0.19 |
|
| 1109 | - * @param string $context View or edit context. |
|
| 1110 | - * @return string |
|
| 1111 | - */ |
|
| 1112 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1113 | - return $this->get_zip( $context ); |
|
| 1106 | + * Alias of self::get_zip(). |
|
| 1107 | + * |
|
| 1108 | + * @since 1.0.19 |
|
| 1109 | + * @param string $context View or edit context. |
|
| 1110 | + * @return string |
|
| 1111 | + */ |
|
| 1112 | + public function get_customer_zip( $context = 'view' ) { |
|
| 1113 | + return $this->get_zip( $context ); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | /** |
| 1117 | - * Get the customer's company. |
|
| 1118 | - * |
|
| 1119 | - * @since 1.0.19 |
|
| 1120 | - * @param string $context View or edit context. |
|
| 1121 | - * @return string |
|
| 1122 | - */ |
|
| 1123 | - public function get_company( $context = 'view' ) { |
|
| 1124 | - return $this->get_prop( 'company', $context ); |
|
| 1117 | + * Get the customer's company. |
|
| 1118 | + * |
|
| 1119 | + * @since 1.0.19 |
|
| 1120 | + * @param string $context View or edit context. |
|
| 1121 | + * @return string |
|
| 1122 | + */ |
|
| 1123 | + public function get_company( $context = 'view' ) { |
|
| 1124 | + return $this->get_prop( 'company', $context ); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | /** |
| 1128 | - * Alias of self::get_company(). |
|
| 1129 | - * |
|
| 1130 | - * @since 1.0.19 |
|
| 1131 | - * @param string $context View or edit context. |
|
| 1132 | - * @return string |
|
| 1133 | - */ |
|
| 1134 | - public function get_user_company( $context = 'view' ) { |
|
| 1135 | - return $this->get_company( $context ); |
|
| 1128 | + * Alias of self::get_company(). |
|
| 1129 | + * |
|
| 1130 | + * @since 1.0.19 |
|
| 1131 | + * @param string $context View or edit context. |
|
| 1132 | + * @return string |
|
| 1133 | + */ |
|
| 1134 | + public function get_user_company( $context = 'view' ) { |
|
| 1135 | + return $this->get_company( $context ); |
|
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | 1138 | /** |
| 1139 | - * Alias of self::get_company(). |
|
| 1140 | - * |
|
| 1141 | - * @since 1.0.19 |
|
| 1142 | - * @param string $context View or edit context. |
|
| 1143 | - * @return string |
|
| 1144 | - */ |
|
| 1145 | - public function get_customer_company( $context = 'view' ) { |
|
| 1146 | - return $this->get_company( $context ); |
|
| 1139 | + * Alias of self::get_company(). |
|
| 1140 | + * |
|
| 1141 | + * @since 1.0.19 |
|
| 1142 | + * @param string $context View or edit context. |
|
| 1143 | + * @return string |
|
| 1144 | + */ |
|
| 1145 | + public function get_customer_company( $context = 'view' ) { |
|
| 1146 | + return $this->get_company( $context ); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | /** |
| 1150 | - * Get the customer's vat number. |
|
| 1151 | - * |
|
| 1152 | - * @since 1.0.19 |
|
| 1153 | - * @param string $context View or edit context. |
|
| 1154 | - * @return string |
|
| 1155 | - */ |
|
| 1156 | - public function get_vat_number( $context = 'view' ) { |
|
| 1157 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1150 | + * Get the customer's vat number. |
|
| 1151 | + * |
|
| 1152 | + * @since 1.0.19 |
|
| 1153 | + * @param string $context View or edit context. |
|
| 1154 | + * @return string |
|
| 1155 | + */ |
|
| 1156 | + public function get_vat_number( $context = 'view' ) { |
|
| 1157 | + return $this->get_prop( 'vat_number', $context ); |
|
| 1158 | + } |
|
| 1159 | + |
|
| 1160 | + /** |
|
| 1161 | + * Alias of self::get_vat_number(). |
|
| 1162 | + * |
|
| 1163 | + * @since 1.0.19 |
|
| 1164 | + * @param string $context View or edit context. |
|
| 1165 | + * @return string |
|
| 1166 | + */ |
|
| 1167 | + public function get_user_vat_number( $context = 'view' ) { |
|
| 1168 | + return $this->get_vat_number( $context ); |
|
| 1169 | + } |
|
| 1170 | + |
|
| 1171 | + /** |
|
| 1172 | + * Alias of self::get_vat_number(). |
|
| 1173 | + * |
|
| 1174 | + * @since 1.0.19 |
|
| 1175 | + * @param string $context View or edit context. |
|
| 1176 | + * @return string |
|
| 1177 | + */ |
|
| 1178 | + public function get_customer_vat_number( $context = 'view' ) { |
|
| 1179 | + return $this->get_vat_number( $context ); |
|
| 1180 | + } |
|
| 1181 | + |
|
| 1182 | + /** |
|
| 1183 | + * Get the customer's vat rate. |
|
| 1184 | + * |
|
| 1185 | + * @since 1.0.19 |
|
| 1186 | + * @param string $context View or edit context. |
|
| 1187 | + * @return string |
|
| 1188 | + */ |
|
| 1189 | + public function get_vat_rate( $context = 'view' ) { |
|
| 1190 | + return $this->get_prop( 'vat_rate', $context ); |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + /** |
|
| 1194 | + * Alias of self::get_vat_rate(). |
|
| 1195 | + * |
|
| 1196 | + * @since 1.0.19 |
|
| 1197 | + * @param string $context View or edit context. |
|
| 1198 | + * @return string |
|
| 1199 | + */ |
|
| 1200 | + public function get_user_vat_rate( $context = 'view' ) { |
|
| 1201 | + return $this->get_vat_rate( $context ); |
|
| 1158 | 1202 | } |
| 1159 | 1203 | |
| 1160 | 1204 | /** |
| 1161 | - * Alias of self::get_vat_number(). |
|
| 1162 | - * |
|
| 1163 | - * @since 1.0.19 |
|
| 1164 | - * @param string $context View or edit context. |
|
| 1165 | - * @return string |
|
| 1166 | - */ |
|
| 1167 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1168 | - return $this->get_vat_number( $context ); |
|
| 1205 | + * Alias of self::get_vat_rate(). |
|
| 1206 | + * |
|
| 1207 | + * @since 1.0.19 |
|
| 1208 | + * @param string $context View or edit context. |
|
| 1209 | + * @return string |
|
| 1210 | + */ |
|
| 1211 | + public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1212 | + return $this->get_vat_rate( $context ); |
|
| 1169 | 1213 | } |
| 1170 | 1214 | |
| 1171 | 1215 | /** |
| 1172 | - * Alias of self::get_vat_number(). |
|
| 1173 | - * |
|
| 1174 | - * @since 1.0.19 |
|
| 1175 | - * @param string $context View or edit context. |
|
| 1176 | - * @return string |
|
| 1177 | - */ |
|
| 1178 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1179 | - return $this->get_vat_number( $context ); |
|
| 1216 | + * Get the customer's address. |
|
| 1217 | + * |
|
| 1218 | + * @since 1.0.19 |
|
| 1219 | + * @param string $context View or edit context. |
|
| 1220 | + * @return string |
|
| 1221 | + */ |
|
| 1222 | + public function get_address( $context = 'view' ) { |
|
| 1223 | + return $this->get_prop( 'address', $context ); |
|
| 1224 | + } |
|
| 1225 | + |
|
| 1226 | + /** |
|
| 1227 | + * Alias of self::get_address(). |
|
| 1228 | + * |
|
| 1229 | + * @since 1.0.19 |
|
| 1230 | + * @param string $context View or edit context. |
|
| 1231 | + * @return string |
|
| 1232 | + */ |
|
| 1233 | + public function get_user_address( $context = 'view' ) { |
|
| 1234 | + return $this->get_address( $context ); |
|
| 1235 | + } |
|
| 1236 | + |
|
| 1237 | + /** |
|
| 1238 | + * Alias of self::get_address(). |
|
| 1239 | + * |
|
| 1240 | + * @since 1.0.19 |
|
| 1241 | + * @param string $context View or edit context. |
|
| 1242 | + * @return string |
|
| 1243 | + */ |
|
| 1244 | + public function get_customer_address( $context = 'view' ) { |
|
| 1245 | + return $this->get_address( $context ); |
|
| 1180 | 1246 | } |
| 1181 | 1247 | |
| 1182 | 1248 | /** |
| 1183 | - * Get the customer's vat rate. |
|
| 1184 | - * |
|
| 1185 | - * @since 1.0.19 |
|
| 1186 | - * @param string $context View or edit context. |
|
| 1187 | - * @return string |
|
| 1188 | - */ |
|
| 1189 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1190 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1191 | - } |
|
| 1192 | - |
|
| 1193 | - /** |
|
| 1194 | - * Alias of self::get_vat_rate(). |
|
| 1195 | - * |
|
| 1196 | - * @since 1.0.19 |
|
| 1197 | - * @param string $context View or edit context. |
|
| 1198 | - * @return string |
|
| 1199 | - */ |
|
| 1200 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1201 | - return $this->get_vat_rate( $context ); |
|
| 1202 | - } |
|
| 1203 | - |
|
| 1204 | - /** |
|
| 1205 | - * Alias of self::get_vat_rate(). |
|
| 1206 | - * |
|
| 1207 | - * @since 1.0.19 |
|
| 1208 | - * @param string $context View or edit context. |
|
| 1209 | - * @return string |
|
| 1210 | - */ |
|
| 1211 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1212 | - return $this->get_vat_rate( $context ); |
|
| 1213 | - } |
|
| 1214 | - |
|
| 1215 | - /** |
|
| 1216 | - * Get the customer's address. |
|
| 1217 | - * |
|
| 1218 | - * @since 1.0.19 |
|
| 1219 | - * @param string $context View or edit context. |
|
| 1220 | - * @return string |
|
| 1221 | - */ |
|
| 1222 | - public function get_address( $context = 'view' ) { |
|
| 1223 | - return $this->get_prop( 'address', $context ); |
|
| 1224 | - } |
|
| 1225 | - |
|
| 1226 | - /** |
|
| 1227 | - * Alias of self::get_address(). |
|
| 1228 | - * |
|
| 1229 | - * @since 1.0.19 |
|
| 1230 | - * @param string $context View or edit context. |
|
| 1231 | - * @return string |
|
| 1232 | - */ |
|
| 1233 | - public function get_user_address( $context = 'view' ) { |
|
| 1234 | - return $this->get_address( $context ); |
|
| 1235 | - } |
|
| 1236 | - |
|
| 1237 | - /** |
|
| 1238 | - * Alias of self::get_address(). |
|
| 1239 | - * |
|
| 1240 | - * @since 1.0.19 |
|
| 1241 | - * @param string $context View or edit context. |
|
| 1242 | - * @return string |
|
| 1243 | - */ |
|
| 1244 | - public function get_customer_address( $context = 'view' ) { |
|
| 1245 | - return $this->get_address( $context ); |
|
| 1246 | - } |
|
| 1247 | - |
|
| 1248 | - /** |
|
| 1249 | - * Get whether the customer has viewed the invoice or not. |
|
| 1250 | - * |
|
| 1251 | - * @since 1.0.19 |
|
| 1252 | - * @param string $context View or edit context. |
|
| 1253 | - * @return bool |
|
| 1254 | - */ |
|
| 1255 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1256 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1257 | - } |
|
| 1258 | - |
|
| 1259 | - /** |
|
| 1260 | - * Get other recipients for invoice communications. |
|
| 1261 | - * |
|
| 1262 | - * @since 1.0.19 |
|
| 1263 | - * @param string $context View or edit context. |
|
| 1264 | - * @return bool |
|
| 1265 | - */ |
|
| 1266 | - public function get_email_cc( $context = 'view' ) { |
|
| 1267 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1268 | - } |
|
| 1269 | - |
|
| 1270 | - /** |
|
| 1271 | - * Get invoice template. |
|
| 1272 | - * |
|
| 1273 | - * @since 1.0.19 |
|
| 1274 | - * @param string $context View or edit context. |
|
| 1275 | - * @return bool |
|
| 1276 | - */ |
|
| 1277 | - public function get_template( $context = 'view' ) { |
|
| 1278 | - return $this->get_prop( 'template', $context ); |
|
| 1279 | - } |
|
| 1280 | - |
|
| 1281 | - /** |
|
| 1282 | - * Get invoice source. |
|
| 1283 | - * |
|
| 1284 | - * @since 1.0.19 |
|
| 1285 | - * @param string $context View or edit context. |
|
| 1286 | - * @return bool |
|
| 1287 | - */ |
|
| 1288 | - public function get_created_via( $context = 'view' ) { |
|
| 1289 | - return $this->get_prop( 'created_via', $context ); |
|
| 1290 | - } |
|
| 1291 | - |
|
| 1292 | - /** |
|
| 1293 | - * Get whether the customer has confirmed their address. |
|
| 1294 | - * |
|
| 1295 | - * @since 1.0.19 |
|
| 1296 | - * @param string $context View or edit context. |
|
| 1297 | - * @return bool |
|
| 1298 | - */ |
|
| 1299 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1300 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1301 | - } |
|
| 1302 | - |
|
| 1303 | - /** |
|
| 1304 | - * Alias of self::get_address_confirmed(). |
|
| 1305 | - * |
|
| 1306 | - * @since 1.0.19 |
|
| 1307 | - * @param string $context View or edit context. |
|
| 1308 | - * @return bool |
|
| 1309 | - */ |
|
| 1310 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1311 | - return $this->get_address_confirmed( $context ); |
|
| 1312 | - } |
|
| 1313 | - |
|
| 1314 | - /** |
|
| 1315 | - * Alias of self::get_address(). |
|
| 1316 | - * |
|
| 1317 | - * @since 1.0.19 |
|
| 1318 | - * @param string $context View or edit context. |
|
| 1319 | - * @return bool |
|
| 1320 | - */ |
|
| 1321 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1322 | - return $this->get_address_confirmed( $context ); |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - /** |
|
| 1326 | - * Get the invoice subtotal. |
|
| 1327 | - * |
|
| 1328 | - * @since 1.0.19 |
|
| 1329 | - * @param string $context View or edit context. |
|
| 1330 | - * @return float |
|
| 1331 | - */ |
|
| 1332 | - public function get_subtotal( $context = 'view' ) { |
|
| 1249 | + * Get whether the customer has viewed the invoice or not. |
|
| 1250 | + * |
|
| 1251 | + * @since 1.0.19 |
|
| 1252 | + * @param string $context View or edit context. |
|
| 1253 | + * @return bool |
|
| 1254 | + */ |
|
| 1255 | + public function get_is_viewed( $context = 'view' ) { |
|
| 1256 | + return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1257 | + } |
|
| 1258 | + |
|
| 1259 | + /** |
|
| 1260 | + * Get other recipients for invoice communications. |
|
| 1261 | + * |
|
| 1262 | + * @since 1.0.19 |
|
| 1263 | + * @param string $context View or edit context. |
|
| 1264 | + * @return bool |
|
| 1265 | + */ |
|
| 1266 | + public function get_email_cc( $context = 'view' ) { |
|
| 1267 | + return $this->get_prop( 'email_cc', $context ); |
|
| 1268 | + } |
|
| 1269 | + |
|
| 1270 | + /** |
|
| 1271 | + * Get invoice template. |
|
| 1272 | + * |
|
| 1273 | + * @since 1.0.19 |
|
| 1274 | + * @param string $context View or edit context. |
|
| 1275 | + * @return bool |
|
| 1276 | + */ |
|
| 1277 | + public function get_template( $context = 'view' ) { |
|
| 1278 | + return $this->get_prop( 'template', $context ); |
|
| 1279 | + } |
|
| 1280 | + |
|
| 1281 | + /** |
|
| 1282 | + * Get invoice source. |
|
| 1283 | + * |
|
| 1284 | + * @since 1.0.19 |
|
| 1285 | + * @param string $context View or edit context. |
|
| 1286 | + * @return bool |
|
| 1287 | + */ |
|
| 1288 | + public function get_created_via( $context = 'view' ) { |
|
| 1289 | + return $this->get_prop( 'created_via', $context ); |
|
| 1290 | + } |
|
| 1291 | + |
|
| 1292 | + /** |
|
| 1293 | + * Get whether the customer has confirmed their address. |
|
| 1294 | + * |
|
| 1295 | + * @since 1.0.19 |
|
| 1296 | + * @param string $context View or edit context. |
|
| 1297 | + * @return bool |
|
| 1298 | + */ |
|
| 1299 | + public function get_address_confirmed( $context = 'view' ) { |
|
| 1300 | + return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1301 | + } |
|
| 1302 | + |
|
| 1303 | + /** |
|
| 1304 | + * Alias of self::get_address_confirmed(). |
|
| 1305 | + * |
|
| 1306 | + * @since 1.0.19 |
|
| 1307 | + * @param string $context View or edit context. |
|
| 1308 | + * @return bool |
|
| 1309 | + */ |
|
| 1310 | + public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1311 | + return $this->get_address_confirmed( $context ); |
|
| 1312 | + } |
|
| 1313 | + |
|
| 1314 | + /** |
|
| 1315 | + * Alias of self::get_address(). |
|
| 1316 | + * |
|
| 1317 | + * @since 1.0.19 |
|
| 1318 | + * @param string $context View or edit context. |
|
| 1319 | + * @return bool |
|
| 1320 | + */ |
|
| 1321 | + public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1322 | + return $this->get_address_confirmed( $context ); |
|
| 1323 | + } |
|
| 1324 | + |
|
| 1325 | + /** |
|
| 1326 | + * Get the invoice subtotal. |
|
| 1327 | + * |
|
| 1328 | + * @since 1.0.19 |
|
| 1329 | + * @param string $context View or edit context. |
|
| 1330 | + * @return float |
|
| 1331 | + */ |
|
| 1332 | + public function get_subtotal( $context = 'view' ) { |
|
| 1333 | 1333 | $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
| 1334 | 1334 | |
| 1335 | 1335 | // Backwards compatibility. |
@@ -1341,165 +1341,165 @@ discard block |
||
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | /** |
| 1344 | - * Get the invoice discount total. |
|
| 1345 | - * |
|
| 1346 | - * @since 1.0.19 |
|
| 1347 | - * @param string $context View or edit context. |
|
| 1348 | - * @return float |
|
| 1349 | - */ |
|
| 1350 | - public function get_total_discount( $context = 'view' ) { |
|
| 1351 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1344 | + * Get the invoice discount total. |
|
| 1345 | + * |
|
| 1346 | + * @since 1.0.19 |
|
| 1347 | + * @param string $context View or edit context. |
|
| 1348 | + * @return float |
|
| 1349 | + */ |
|
| 1350 | + public function get_total_discount( $context = 'view' ) { |
|
| 1351 | + return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1352 | + } |
|
| 1353 | + |
|
| 1354 | + /** |
|
| 1355 | + * Get the invoice tax total. |
|
| 1356 | + * |
|
| 1357 | + * @since 1.0.19 |
|
| 1358 | + * @param string $context View or edit context. |
|
| 1359 | + * @return float |
|
| 1360 | + */ |
|
| 1361 | + public function get_total_tax( $context = 'view' ) { |
|
| 1362 | + return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1352 | 1363 | } |
| 1353 | 1364 | |
| 1354 | 1365 | /** |
| 1355 | - * Get the invoice tax total. |
|
| 1356 | - * |
|
| 1357 | - * @since 1.0.19 |
|
| 1358 | - * @param string $context View or edit context. |
|
| 1359 | - * @return float |
|
| 1360 | - */ |
|
| 1361 | - public function get_total_tax( $context = 'view' ) { |
|
| 1362 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1363 | - } |
|
| 1364 | - |
|
| 1365 | - /** |
|
| 1366 | - * @deprecated |
|
| 1367 | - */ |
|
| 1368 | - public function get_final_tax( $currency = false ) { |
|
| 1369 | - $tax = $this->get_total_tax(); |
|
| 1366 | + * @deprecated |
|
| 1367 | + */ |
|
| 1368 | + public function get_final_tax( $currency = false ) { |
|
| 1369 | + $tax = $this->get_total_tax(); |
|
| 1370 | 1370 | |
| 1371 | 1371 | if ( $currency ) { |
| 1372 | - return wpinv_price( $tax, $this->get_currency() ); |
|
| 1372 | + return wpinv_price( $tax, $this->get_currency() ); |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | return $tax; |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | /** |
| 1379 | - * Get the invoice fees total. |
|
| 1380 | - * |
|
| 1381 | - * @since 1.0.19 |
|
| 1382 | - * @param string $context View or edit context. |
|
| 1383 | - * @return float |
|
| 1384 | - */ |
|
| 1385 | - public function get_total_fees( $context = 'view' ) { |
|
| 1386 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1379 | + * Get the invoice fees total. |
|
| 1380 | + * |
|
| 1381 | + * @since 1.0.19 |
|
| 1382 | + * @param string $context View or edit context. |
|
| 1383 | + * @return float |
|
| 1384 | + */ |
|
| 1385 | + public function get_total_fees( $context = 'view' ) { |
|
| 1386 | + return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | /** |
| 1390 | - * Alias for self::get_total_fees(). |
|
| 1391 | - * |
|
| 1392 | - * @since 1.0.19 |
|
| 1393 | - * @param string $context View or edit context. |
|
| 1394 | - * @return float |
|
| 1395 | - */ |
|
| 1396 | - public function get_fees_total( $context = 'view' ) { |
|
| 1397 | - return $this->get_total_fees( $context ); |
|
| 1390 | + * Alias for self::get_total_fees(). |
|
| 1391 | + * |
|
| 1392 | + * @since 1.0.19 |
|
| 1393 | + * @param string $context View or edit context. |
|
| 1394 | + * @return float |
|
| 1395 | + */ |
|
| 1396 | + public function get_fees_total( $context = 'view' ) { |
|
| 1397 | + return $this->get_total_fees( $context ); |
|
| 1398 | 1398 | } |
| 1399 | 1399 | |
| 1400 | 1400 | /** |
| 1401 | - * Get the invoice total. |
|
| 1402 | - * |
|
| 1403 | - * @since 1.0.19 |
|
| 1401 | + * Get the invoice total. |
|
| 1402 | + * |
|
| 1403 | + * @since 1.0.19 |
|
| 1404 | 1404 | * @return float |
| 1405 | - */ |
|
| 1406 | - public function get_total() { |
|
| 1407 | - $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1408 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1409 | - } |
|
| 1405 | + */ |
|
| 1406 | + public function get_total() { |
|
| 1407 | + $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
| 1408 | + return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1409 | + } |
|
| 1410 | 1410 | |
| 1411 | - /** |
|
| 1412 | - * Get the invoice totals. |
|
| 1413 | - * |
|
| 1414 | - * @since 1.0.19 |
|
| 1411 | + /** |
|
| 1412 | + * Get the invoice totals. |
|
| 1413 | + * |
|
| 1414 | + * @since 1.0.19 |
|
| 1415 | 1415 | * @return array |
| 1416 | - */ |
|
| 1417 | - public function get_totals() { |
|
| 1418 | - return $this->totals; |
|
| 1416 | + */ |
|
| 1417 | + public function get_totals() { |
|
| 1418 | + return $this->totals; |
|
| 1419 | 1419 | } |
| 1420 | 1420 | |
| 1421 | 1421 | /** |
| 1422 | - * Get the initial invoice total. |
|
| 1423 | - * |
|
| 1424 | - * @since 1.0.19 |
|
| 1422 | + * Get the initial invoice total. |
|
| 1423 | + * |
|
| 1424 | + * @since 1.0.19 |
|
| 1425 | 1425 | * @param string $context View or edit context. |
| 1426 | 1426 | * @return float |
| 1427 | - */ |
|
| 1427 | + */ |
|
| 1428 | 1428 | public function get_initial_total() { |
| 1429 | 1429 | |
| 1430 | - if ( empty( $this->totals ) ) { |
|
| 1431 | - $this->recalculate_total(); |
|
| 1432 | - } |
|
| 1430 | + if ( empty( $this->totals ) ) { |
|
| 1431 | + $this->recalculate_total(); |
|
| 1432 | + } |
|
| 1433 | 1433 | |
| 1434 | - $tax = $this->totals['tax']['initial']; |
|
| 1435 | - $fee = $this->totals['fee']['initial']; |
|
| 1436 | - $discount = $this->totals['discount']['initial']; |
|
| 1437 | - $subtotal = $this->totals['subtotal']['initial']; |
|
| 1438 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1434 | + $tax = $this->totals['tax']['initial']; |
|
| 1435 | + $fee = $this->totals['fee']['initial']; |
|
| 1436 | + $discount = $this->totals['discount']['initial']; |
|
| 1437 | + $subtotal = $this->totals['subtotal']['initial']; |
|
| 1438 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1439 | 1439 | |
| 1440 | - if ( 0 > $total ) { |
|
| 1441 | - $total = 0; |
|
| 1442 | - } |
|
| 1440 | + if ( 0 > $total ) { |
|
| 1441 | + $total = 0; |
|
| 1442 | + } |
|
| 1443 | 1443 | |
| 1444 | 1444 | return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
| 1445 | - } |
|
| 1445 | + } |
|
| 1446 | 1446 | |
| 1447 | - /** |
|
| 1448 | - * Get the recurring invoice total. |
|
| 1449 | - * |
|
| 1450 | - * @since 1.0.19 |
|
| 1447 | + /** |
|
| 1448 | + * Get the recurring invoice total. |
|
| 1449 | + * |
|
| 1450 | + * @since 1.0.19 |
|
| 1451 | 1451 | * @param string $context View or edit context. |
| 1452 | 1452 | * @return float |
| 1453 | - */ |
|
| 1453 | + */ |
|
| 1454 | 1454 | public function get_recurring_total() { |
| 1455 | 1455 | |
| 1456 | - if ( empty( $this->totals ) ) { |
|
| 1457 | - $this->recalculate_total(); |
|
| 1458 | - } |
|
| 1456 | + if ( empty( $this->totals ) ) { |
|
| 1457 | + $this->recalculate_total(); |
|
| 1458 | + } |
|
| 1459 | 1459 | |
| 1460 | - $tax = $this->totals['tax']['recurring']; |
|
| 1461 | - $fee = $this->totals['fee']['recurring']; |
|
| 1462 | - $discount = $this->totals['discount']['recurring']; |
|
| 1463 | - $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1464 | - $total = $tax + $fee - $discount + $subtotal; |
|
| 1460 | + $tax = $this->totals['tax']['recurring']; |
|
| 1461 | + $fee = $this->totals['fee']['recurring']; |
|
| 1462 | + $discount = $this->totals['discount']['recurring']; |
|
| 1463 | + $subtotal = $this->totals['subtotal']['recurring']; |
|
| 1464 | + $total = $tax + $fee - $discount + $subtotal; |
|
| 1465 | 1465 | |
| 1466 | - if ( 0 > $total ) { |
|
| 1467 | - $total = 0; |
|
| 1468 | - } |
|
| 1466 | + if ( 0 > $total ) { |
|
| 1467 | + $total = 0; |
|
| 1468 | + } |
|
| 1469 | 1469 | |
| 1470 | 1470 | return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
| 1471 | - } |
|
| 1471 | + } |
|
| 1472 | 1472 | |
| 1473 | - /** |
|
| 1474 | - * Returns recurring payment details. |
|
| 1475 | - * |
|
| 1476 | - * @since 1.0.19 |
|
| 1473 | + /** |
|
| 1474 | + * Returns recurring payment details. |
|
| 1475 | + * |
|
| 1476 | + * @since 1.0.19 |
|
| 1477 | 1477 | * @param string $field Optionally provide a field to return. |
| 1478 | - * @param string $currency Whether to include the currency. |
|
| 1478 | + * @param string $currency Whether to include the currency. |
|
| 1479 | 1479 | * @return float|string |
| 1480 | - */ |
|
| 1480 | + */ |
|
| 1481 | 1481 | public function get_recurring_details( $field = '', $currency = false ) { |
| 1482 | 1482 | |
| 1483 | - // Maybe recalculate totals. |
|
| 1484 | - if ( empty( $this->totals ) ) { |
|
| 1485 | - $this->recalculate_total(); |
|
| 1486 | - } |
|
| 1483 | + // Maybe recalculate totals. |
|
| 1484 | + if ( empty( $this->totals ) ) { |
|
| 1485 | + $this->recalculate_total(); |
|
| 1486 | + } |
|
| 1487 | 1487 | |
| 1488 | - // Prepare recurring totals. |
|
| 1488 | + // Prepare recurring totals. |
|
| 1489 | 1489 | $data = apply_filters( |
| 1490 | - 'wpinv_get_invoice_recurring_details', |
|
| 1491 | - array( |
|
| 1492 | - 'cart_details' => $this->get_cart_details(), |
|
| 1493 | - 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1494 | - 'discount' => $this->totals['discount']['recurring'], |
|
| 1495 | - 'tax' => $this->totals['tax']['recurring'], |
|
| 1496 | - 'fee' => $this->totals['fee']['recurring'], |
|
| 1497 | - 'total' => $this->get_recurring_total(), |
|
| 1498 | - ), |
|
| 1499 | - $this, |
|
| 1500 | - $field, |
|
| 1501 | - $currency |
|
| 1502 | - ); |
|
| 1490 | + 'wpinv_get_invoice_recurring_details', |
|
| 1491 | + array( |
|
| 1492 | + 'cart_details' => $this->get_cart_details(), |
|
| 1493 | + 'subtotal' => $this->totals['subtotal']['recurring'], |
|
| 1494 | + 'discount' => $this->totals['discount']['recurring'], |
|
| 1495 | + 'tax' => $this->totals['tax']['recurring'], |
|
| 1496 | + 'fee' => $this->totals['fee']['recurring'], |
|
| 1497 | + 'total' => $this->get_recurring_total(), |
|
| 1498 | + ), |
|
| 1499 | + $this, |
|
| 1500 | + $field, |
|
| 1501 | + $currency |
|
| 1502 | + ); |
|
| 1503 | 1503 | |
| 1504 | 1504 | if ( isset( $data[$field] ) ) { |
| 1505 | 1505 | return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
@@ -1509,156 +1509,156 @@ discard block |
||
| 1509 | 1509 | } |
| 1510 | 1510 | |
| 1511 | 1511 | /** |
| 1512 | - * Get the invoice fees. |
|
| 1513 | - * |
|
| 1514 | - * @since 1.0.19 |
|
| 1515 | - * @param string $context View or edit context. |
|
| 1516 | - * @return array |
|
| 1517 | - */ |
|
| 1518 | - public function get_fees( $context = 'view' ) { |
|
| 1519 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1512 | + * Get the invoice fees. |
|
| 1513 | + * |
|
| 1514 | + * @since 1.0.19 |
|
| 1515 | + * @param string $context View or edit context. |
|
| 1516 | + * @return array |
|
| 1517 | + */ |
|
| 1518 | + public function get_fees( $context = 'view' ) { |
|
| 1519 | + return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | /** |
| 1523 | - * Get the invoice discounts. |
|
| 1524 | - * |
|
| 1525 | - * @since 1.0.19 |
|
| 1526 | - * @param string $context View or edit context. |
|
| 1527 | - * @return array |
|
| 1528 | - */ |
|
| 1529 | - public function get_discounts( $context = 'view' ) { |
|
| 1530 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1523 | + * Get the invoice discounts. |
|
| 1524 | + * |
|
| 1525 | + * @since 1.0.19 |
|
| 1526 | + * @param string $context View or edit context. |
|
| 1527 | + * @return array |
|
| 1528 | + */ |
|
| 1529 | + public function get_discounts( $context = 'view' ) { |
|
| 1530 | + return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | 1533 | /** |
| 1534 | - * Get the invoice taxes. |
|
| 1535 | - * |
|
| 1536 | - * @since 1.0.19 |
|
| 1537 | - * @param string $context View or edit context. |
|
| 1538 | - * @return array |
|
| 1539 | - */ |
|
| 1540 | - public function get_taxes( $context = 'view' ) { |
|
| 1541 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1534 | + * Get the invoice taxes. |
|
| 1535 | + * |
|
| 1536 | + * @since 1.0.19 |
|
| 1537 | + * @param string $context View or edit context. |
|
| 1538 | + * @return array |
|
| 1539 | + */ |
|
| 1540 | + public function get_taxes( $context = 'view' ) { |
|
| 1541 | + return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | 1544 | /** |
| 1545 | - * Get the invoice items. |
|
| 1546 | - * |
|
| 1547 | - * @since 1.0.19 |
|
| 1548 | - * @param string $context View or edit context. |
|
| 1549 | - * @return GetPaid_Form_Item[] |
|
| 1550 | - */ |
|
| 1551 | - public function get_items( $context = 'view' ) { |
|
| 1545 | + * Get the invoice items. |
|
| 1546 | + * |
|
| 1547 | + * @since 1.0.19 |
|
| 1548 | + * @param string $context View or edit context. |
|
| 1549 | + * @return GetPaid_Form_Item[] |
|
| 1550 | + */ |
|
| 1551 | + public function get_items( $context = 'view' ) { |
|
| 1552 | 1552 | return $this->get_prop( 'items', $context ); |
| 1553 | 1553 | } |
| 1554 | 1554 | |
| 1555 | 1555 | /** |
| 1556 | - * Get the invoice's payment form. |
|
| 1557 | - * |
|
| 1558 | - * @since 1.0.19 |
|
| 1559 | - * @param string $context View or edit context. |
|
| 1560 | - * @return int |
|
| 1561 | - */ |
|
| 1562 | - public function get_payment_form( $context = 'view' ) { |
|
| 1563 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1556 | + * Get the invoice's payment form. |
|
| 1557 | + * |
|
| 1558 | + * @since 1.0.19 |
|
| 1559 | + * @param string $context View or edit context. |
|
| 1560 | + * @return int |
|
| 1561 | + */ |
|
| 1562 | + public function get_payment_form( $context = 'view' ) { |
|
| 1563 | + return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | /** |
| 1567 | - * Get the invoice's submission id. |
|
| 1568 | - * |
|
| 1569 | - * @since 1.0.19 |
|
| 1570 | - * @param string $context View or edit context. |
|
| 1571 | - * @return string |
|
| 1572 | - */ |
|
| 1573 | - public function get_submission_id( $context = 'view' ) { |
|
| 1574 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1567 | + * Get the invoice's submission id. |
|
| 1568 | + * |
|
| 1569 | + * @since 1.0.19 |
|
| 1570 | + * @param string $context View or edit context. |
|
| 1571 | + * @return string |
|
| 1572 | + */ |
|
| 1573 | + public function get_submission_id( $context = 'view' ) { |
|
| 1574 | + return $this->get_prop( 'submission_id', $context ); |
|
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | /** |
| 1578 | - * Get the invoice's discount code. |
|
| 1579 | - * |
|
| 1580 | - * @since 1.0.19 |
|
| 1581 | - * @param string $context View or edit context. |
|
| 1582 | - * @return string |
|
| 1583 | - */ |
|
| 1584 | - public function get_discount_code( $context = 'view' ) { |
|
| 1585 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1578 | + * Get the invoice's discount code. |
|
| 1579 | + * |
|
| 1580 | + * @since 1.0.19 |
|
| 1581 | + * @param string $context View or edit context. |
|
| 1582 | + * @return string |
|
| 1583 | + */ |
|
| 1584 | + public function get_discount_code( $context = 'view' ) { |
|
| 1585 | + return $this->get_prop( 'discount_code', $context ); |
|
| 1586 | 1586 | } |
| 1587 | 1587 | |
| 1588 | 1588 | /** |
| 1589 | - * Get the invoice's gateway. |
|
| 1590 | - * |
|
| 1591 | - * @since 1.0.19 |
|
| 1592 | - * @param string $context View or edit context. |
|
| 1593 | - * @return string |
|
| 1594 | - */ |
|
| 1595 | - public function get_gateway( $context = 'view' ) { |
|
| 1596 | - return $this->get_prop( 'gateway', $context ); |
|
| 1589 | + * Get the invoice's gateway. |
|
| 1590 | + * |
|
| 1591 | + * @since 1.0.19 |
|
| 1592 | + * @param string $context View or edit context. |
|
| 1593 | + * @return string |
|
| 1594 | + */ |
|
| 1595 | + public function get_gateway( $context = 'view' ) { |
|
| 1596 | + return $this->get_prop( 'gateway', $context ); |
|
| 1597 | 1597 | } |
| 1598 | 1598 | |
| 1599 | 1599 | /** |
| 1600 | - * Get the invoice's gateway display title. |
|
| 1601 | - * |
|
| 1602 | - * @since 1.0.19 |
|
| 1603 | - * @return string |
|
| 1604 | - */ |
|
| 1600 | + * Get the invoice's gateway display title. |
|
| 1601 | + * |
|
| 1602 | + * @since 1.0.19 |
|
| 1603 | + * @return string |
|
| 1604 | + */ |
|
| 1605 | 1605 | public function get_gateway_title() { |
| 1606 | 1606 | $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
| 1607 | 1607 | return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | /** |
| 1611 | - * Get the invoice's transaction id. |
|
| 1612 | - * |
|
| 1613 | - * @since 1.0.19 |
|
| 1614 | - * @param string $context View or edit context. |
|
| 1615 | - * @return string |
|
| 1616 | - */ |
|
| 1617 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1618 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1611 | + * Get the invoice's transaction id. |
|
| 1612 | + * |
|
| 1613 | + * @since 1.0.19 |
|
| 1614 | + * @param string $context View or edit context. |
|
| 1615 | + * @return string |
|
| 1616 | + */ |
|
| 1617 | + public function get_transaction_id( $context = 'view' ) { |
|
| 1618 | + return $this->get_prop( 'transaction_id', $context ); |
|
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | /** |
| 1622 | - * Get the invoice's currency. |
|
| 1623 | - * |
|
| 1624 | - * @since 1.0.19 |
|
| 1625 | - * @param string $context View or edit context. |
|
| 1626 | - * @return string |
|
| 1627 | - */ |
|
| 1628 | - public function get_currency( $context = 'view' ) { |
|
| 1622 | + * Get the invoice's currency. |
|
| 1623 | + * |
|
| 1624 | + * @since 1.0.19 |
|
| 1625 | + * @param string $context View or edit context. |
|
| 1626 | + * @return string |
|
| 1627 | + */ |
|
| 1628 | + public function get_currency( $context = 'view' ) { |
|
| 1629 | 1629 | $currency = $this->get_prop( 'currency', $context ); |
| 1630 | 1630 | return empty( $currency ) ? wpinv_get_currency() : $currency; |
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | /** |
| 1634 | - * Checks if we are charging taxes for this invoice. |
|
| 1635 | - * |
|
| 1636 | - * @since 1.0.19 |
|
| 1637 | - * @param string $context View or edit context. |
|
| 1638 | - * @return bool |
|
| 1639 | - */ |
|
| 1640 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1634 | + * Checks if we are charging taxes for this invoice. |
|
| 1635 | + * |
|
| 1636 | + * @since 1.0.19 |
|
| 1637 | + * @param string $context View or edit context. |
|
| 1638 | + * @return bool |
|
| 1639 | + */ |
|
| 1640 | + public function get_disable_taxes( $context = 'view' ) { |
|
| 1641 | 1641 | return (bool) $this->get_prop( 'disable_taxes', $context ); |
| 1642 | 1642 | } |
| 1643 | 1643 | |
| 1644 | 1644 | /** |
| 1645 | - * Retrieves the subscription id for an invoice. |
|
| 1646 | - * |
|
| 1647 | - * @since 1.0.19 |
|
| 1648 | - * @param string $context View or edit context. |
|
| 1649 | - * @return int |
|
| 1650 | - */ |
|
| 1645 | + * Retrieves the subscription id for an invoice. |
|
| 1646 | + * |
|
| 1647 | + * @since 1.0.19 |
|
| 1648 | + * @param string $context View or edit context. |
|
| 1649 | + * @return int |
|
| 1650 | + */ |
|
| 1651 | 1651 | public function get_subscription_id( $context = 'view' ) { |
| 1652 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1653 | - } |
|
| 1654 | - |
|
| 1655 | - /** |
|
| 1656 | - * Retrieves the remote subscription id for an invoice. |
|
| 1657 | - * |
|
| 1658 | - * @since 1.0.19 |
|
| 1659 | - * @param string $context View or edit context. |
|
| 1660 | - * @return int |
|
| 1661 | - */ |
|
| 1652 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1653 | + } |
|
| 1654 | + |
|
| 1655 | + /** |
|
| 1656 | + * Retrieves the remote subscription id for an invoice. |
|
| 1657 | + * |
|
| 1658 | + * @since 1.0.19 |
|
| 1659 | + * @param string $context View or edit context. |
|
| 1660 | + * @return int |
|
| 1661 | + */ |
|
| 1662 | 1662 | public function get_remote_subscription_id( $context = 'view' ) { |
| 1663 | 1663 | $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
| 1664 | 1664 | |
@@ -1671,12 +1671,12 @@ discard block |
||
| 1671 | 1671 | } |
| 1672 | 1672 | |
| 1673 | 1673 | /** |
| 1674 | - * Retrieves the payment meta for an invoice. |
|
| 1675 | - * |
|
| 1676 | - * @since 1.0.19 |
|
| 1677 | - * @param string $context View or edit context. |
|
| 1678 | - * @return array |
|
| 1679 | - */ |
|
| 1674 | + * Retrieves the payment meta for an invoice. |
|
| 1675 | + * |
|
| 1676 | + * @since 1.0.19 |
|
| 1677 | + * @param string $context View or edit context. |
|
| 1678 | + * @return array |
|
| 1679 | + */ |
|
| 1680 | 1680 | public function get_payment_meta( $context = 'view' ) { |
| 1681 | 1681 | |
| 1682 | 1682 | return array( |
@@ -1696,31 +1696,31 @@ discard block |
||
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | 1698 | /** |
| 1699 | - * Retrieves the cart details for an invoice. |
|
| 1700 | - * |
|
| 1701 | - * @since 1.0.19 |
|
| 1702 | - * @return array |
|
| 1703 | - */ |
|
| 1699 | + * Retrieves the cart details for an invoice. |
|
| 1700 | + * |
|
| 1701 | + * @since 1.0.19 |
|
| 1702 | + * @return array |
|
| 1703 | + */ |
|
| 1704 | 1704 | public function get_cart_details() { |
| 1705 | 1705 | $items = $this->get_items(); |
| 1706 | 1706 | $cart_details = array(); |
| 1707 | 1707 | |
| 1708 | 1708 | foreach ( $items as $item_id => $item ) { |
| 1709 | - $item->invoice_id = $this->get_id(); |
|
| 1709 | + $item->invoice_id = $this->get_id(); |
|
| 1710 | 1710 | $cart_details[] = $item->prepare_data_for_saving(); |
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | 1713 | return $cart_details; |
| 1714 | - } |
|
| 1714 | + } |
|
| 1715 | 1715 | |
| 1716 | - /** |
|
| 1717 | - * Retrieves the recurring item. |
|
| 1718 | - * |
|
| 1719 | - * @return null|GetPaid_Form_Item|int |
|
| 1720 | - */ |
|
| 1721 | - public function get_recurring( $object = false ) { |
|
| 1716 | + /** |
|
| 1717 | + * Retrieves the recurring item. |
|
| 1718 | + * |
|
| 1719 | + * @return null|GetPaid_Form_Item|int |
|
| 1720 | + */ |
|
| 1721 | + public function get_recurring( $object = false ) { |
|
| 1722 | 1722 | |
| 1723 | - // Are we returning an object? |
|
| 1723 | + // Are we returning an object? |
|
| 1724 | 1724 | if ( $object ) { |
| 1725 | 1725 | return $this->get_item( $this->recurring_item ); |
| 1726 | 1726 | } |
@@ -1728,114 +1728,114 @@ discard block |
||
| 1728 | 1728 | return $this->recurring_item; |
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | - /** |
|
| 1732 | - * Retrieves the subscription name. |
|
| 1733 | - * |
|
| 1734 | - * @since 1.0.19 |
|
| 1735 | - * @return string |
|
| 1736 | - */ |
|
| 1737 | - public function get_subscription_name() { |
|
| 1731 | + /** |
|
| 1732 | + * Retrieves the subscription name. |
|
| 1733 | + * |
|
| 1734 | + * @since 1.0.19 |
|
| 1735 | + * @return string |
|
| 1736 | + */ |
|
| 1737 | + public function get_subscription_name() { |
|
| 1738 | 1738 | |
| 1739 | - // Retrieve the recurring name |
|
| 1739 | + // Retrieve the recurring name |
|
| 1740 | 1740 | $item = $this->get_recurring( true ); |
| 1741 | 1741 | |
| 1742 | - // Abort if it does not exist. |
|
| 1742 | + // Abort if it does not exist. |
|
| 1743 | 1743 | if ( empty( $item ) ) { |
| 1744 | 1744 | return ''; |
| 1745 | 1745 | } |
| 1746 | 1746 | |
| 1747 | - // Return the item name. |
|
| 1747 | + // Return the item name. |
|
| 1748 | 1748 | return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
| 1749 | - } |
|
| 1750 | - |
|
| 1751 | - /** |
|
| 1752 | - * Retrieves the view url. |
|
| 1753 | - * |
|
| 1754 | - * @since 1.0.19 |
|
| 1755 | - * @return string |
|
| 1756 | - */ |
|
| 1757 | - public function get_view_url() { |
|
| 1749 | + } |
|
| 1750 | + |
|
| 1751 | + /** |
|
| 1752 | + * Retrieves the view url. |
|
| 1753 | + * |
|
| 1754 | + * @since 1.0.19 |
|
| 1755 | + * @return string |
|
| 1756 | + */ |
|
| 1757 | + public function get_view_url() { |
|
| 1758 | 1758 | $invoice_url = get_permalink( $this->get_id() ); |
| 1759 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1759 | + $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1760 | 1760 | return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
| 1761 | - } |
|
| 1761 | + } |
|
| 1762 | 1762 | |
| 1763 | - /** |
|
| 1764 | - * Retrieves the payment url. |
|
| 1765 | - * |
|
| 1766 | - * @since 1.0.19 |
|
| 1767 | - * @return string |
|
| 1768 | - */ |
|
| 1769 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1763 | + /** |
|
| 1764 | + * Retrieves the payment url. |
|
| 1765 | + * |
|
| 1766 | + * @since 1.0.19 |
|
| 1767 | + * @return string |
|
| 1768 | + */ |
|
| 1769 | + public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1770 | 1770 | |
| 1771 | - // Retrieve the checkout url. |
|
| 1771 | + // Retrieve the checkout url. |
|
| 1772 | 1772 | $pay_url = wpinv_get_checkout_uri(); |
| 1773 | 1773 | |
| 1774 | - // Maybe force ssl. |
|
| 1774 | + // Maybe force ssl. |
|
| 1775 | 1775 | if ( is_ssl() ) { |
| 1776 | 1776 | $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
| 1777 | 1777 | } |
| 1778 | 1778 | |
| 1779 | - // Add the invoice key. |
|
| 1780 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1779 | + // Add the invoice key. |
|
| 1780 | + $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1781 | 1781 | |
| 1782 | - // (Maybe?) add a secret |
|
| 1782 | + // (Maybe?) add a secret |
|
| 1783 | 1783 | if ( $secret ) { |
| 1784 | 1784 | $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | 1787 | return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
| 1788 | - } |
|
| 1788 | + } |
|
| 1789 | 1789 | |
| 1790 | - /** |
|
| 1791 | - * Retrieves the receipt url. |
|
| 1792 | - * |
|
| 1793 | - * @since 1.0.19 |
|
| 1794 | - * @return string |
|
| 1795 | - */ |
|
| 1796 | - public function get_receipt_url() { |
|
| 1797 | - |
|
| 1798 | - // Retrieve the checkout url. |
|
| 1790 | + /** |
|
| 1791 | + * Retrieves the receipt url. |
|
| 1792 | + * |
|
| 1793 | + * @since 1.0.19 |
|
| 1794 | + * @return string |
|
| 1795 | + */ |
|
| 1796 | + public function get_receipt_url() { |
|
| 1797 | + |
|
| 1798 | + // Retrieve the checkout url. |
|
| 1799 | 1799 | $receipt_url = wpinv_get_success_page_uri(); |
| 1800 | 1800 | |
| 1801 | - // Maybe force ssl. |
|
| 1801 | + // Maybe force ssl. |
|
| 1802 | 1802 | if ( is_ssl() ) { |
| 1803 | 1803 | $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
| 1804 | 1804 | } |
| 1805 | 1805 | |
| 1806 | - // Add the invoice key. |
|
| 1807 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1806 | + // Add the invoice key. |
|
| 1807 | + $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1808 | 1808 | |
| 1809 | 1809 | return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
| 1810 | - } |
|
| 1810 | + } |
|
| 1811 | 1811 | |
| 1812 | - /** |
|
| 1813 | - * Retrieves the default status. |
|
| 1814 | - * |
|
| 1815 | - * @since 1.0.19 |
|
| 1816 | - * @return string |
|
| 1817 | - */ |
|
| 1818 | - public function get_default_status() { |
|
| 1819 | - |
|
| 1820 | - $type = $this->get_type(); |
|
| 1821 | - $status = "wpi-$type-pending"; |
|
| 1822 | - return str_replace( '-invoice', '', $status ); |
|
| 1823 | - |
|
| 1824 | - } |
|
| 1825 | - |
|
| 1826 | - /** |
|
| 1827 | - * Magic method for accessing invoice properties. |
|
| 1828 | - * |
|
| 1829 | - * @since 1.0.15 |
|
| 1830 | - * @access public |
|
| 1831 | - * |
|
| 1832 | - * @param string $key Discount data to retrieve |
|
| 1833 | - * @param string $context View or edit context. |
|
| 1834 | - * @return mixed Value of the given invoice property (if set). |
|
| 1835 | - */ |
|
| 1836 | - public function get( $key, $context = 'view' ) { |
|
| 1812 | + /** |
|
| 1813 | + * Retrieves the default status. |
|
| 1814 | + * |
|
| 1815 | + * @since 1.0.19 |
|
| 1816 | + * @return string |
|
| 1817 | + */ |
|
| 1818 | + public function get_default_status() { |
|
| 1819 | + |
|
| 1820 | + $type = $this->get_type(); |
|
| 1821 | + $status = "wpi-$type-pending"; |
|
| 1822 | + return str_replace( '-invoice', '', $status ); |
|
| 1823 | + |
|
| 1824 | + } |
|
| 1825 | + |
|
| 1826 | + /** |
|
| 1827 | + * Magic method for accessing invoice properties. |
|
| 1828 | + * |
|
| 1829 | + * @since 1.0.15 |
|
| 1830 | + * @access public |
|
| 1831 | + * |
|
| 1832 | + * @param string $key Discount data to retrieve |
|
| 1833 | + * @param string $context View or edit context. |
|
| 1834 | + * @return mixed Value of the given invoice property (if set). |
|
| 1835 | + */ |
|
| 1836 | + public function get( $key, $context = 'view' ) { |
|
| 1837 | 1837 | return $this->get_prop( $key, $context ); |
| 1838 | - } |
|
| 1838 | + } |
|
| 1839 | 1839 | |
| 1840 | 1840 | /* |
| 1841 | 1841 | |-------------------------------------------------------------------------- |
@@ -1848,130 +1848,130 @@ discard block |
||
| 1848 | 1848 | */ |
| 1849 | 1849 | |
| 1850 | 1850 | /** |
| 1851 | - * Magic method for setting invoice properties. |
|
| 1852 | - * |
|
| 1853 | - * @since 1.0.19 |
|
| 1854 | - * @access public |
|
| 1855 | - * |
|
| 1856 | - * @param string $key Discount data to retrieve |
|
| 1857 | - * @param mixed $value new value. |
|
| 1858 | - * @return mixed Value of the given invoice property (if set). |
|
| 1859 | - */ |
|
| 1860 | - public function set( $key, $value ) { |
|
| 1851 | + * Magic method for setting invoice properties. |
|
| 1852 | + * |
|
| 1853 | + * @since 1.0.19 |
|
| 1854 | + * @access public |
|
| 1855 | + * |
|
| 1856 | + * @param string $key Discount data to retrieve |
|
| 1857 | + * @param mixed $value new value. |
|
| 1858 | + * @return mixed Value of the given invoice property (if set). |
|
| 1859 | + */ |
|
| 1860 | + public function set( $key, $value ) { |
|
| 1861 | 1861 | |
| 1862 | 1862 | $setter = "set_$key"; |
| 1863 | 1863 | if ( is_callable( array( $this, $setter ) ) ) { |
| 1864 | 1864 | $this->{$setter}( $value ); |
| 1865 | 1865 | } |
| 1866 | 1866 | |
| 1867 | - } |
|
| 1867 | + } |
|
| 1868 | 1868 | |
| 1869 | - /** |
|
| 1870 | - * Sets item status. |
|
| 1871 | - * |
|
| 1872 | - * @since 1.0.19 |
|
| 1873 | - * @param string $new_status New status. |
|
| 1874 | - * @param string $note Optional note to add. |
|
| 1875 | - * @param bool $manual_update Is this a manual status change?. |
|
| 1876 | - * @return array details of change. |
|
| 1877 | - */ |
|
| 1878 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1879 | - $old_status = $this->get_status(); |
|
| 1869 | + /** |
|
| 1870 | + * Sets item status. |
|
| 1871 | + * |
|
| 1872 | + * @since 1.0.19 |
|
| 1873 | + * @param string $new_status New status. |
|
| 1874 | + * @param string $note Optional note to add. |
|
| 1875 | + * @param bool $manual_update Is this a manual status change?. |
|
| 1876 | + * @return array details of change. |
|
| 1877 | + */ |
|
| 1878 | + public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1879 | + $old_status = $this->get_status(); |
|
| 1880 | 1880 | |
| 1881 | - $statuses = $this->get_all_statuses(); |
|
| 1881 | + $statuses = $this->get_all_statuses(); |
|
| 1882 | 1882 | |
| 1883 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1884 | - unset( $statuses[ 'draft' ] ); |
|
| 1885 | - } |
|
| 1883 | + if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1884 | + unset( $statuses[ 'draft' ] ); |
|
| 1885 | + } |
|
| 1886 | 1886 | |
| 1887 | - $this->set_prop( 'status', $new_status ); |
|
| 1887 | + $this->set_prop( 'status', $new_status ); |
|
| 1888 | 1888 | |
| 1889 | - // If setting the status, ensure it's set to a valid status. |
|
| 1890 | - if ( true === $this->object_read ) { |
|
| 1889 | + // If setting the status, ensure it's set to a valid status. |
|
| 1890 | + if ( true === $this->object_read ) { |
|
| 1891 | 1891 | |
| 1892 | - // Only allow valid new status. |
|
| 1893 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1894 | - $new_status = $this->get_default_status(); |
|
| 1895 | - } |
|
| 1892 | + // Only allow valid new status. |
|
| 1893 | + if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1894 | + $new_status = $this->get_default_status(); |
|
| 1895 | + } |
|
| 1896 | 1896 | |
| 1897 | - // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1898 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1899 | - $old_status = $this->get_default_status(); |
|
| 1900 | - } |
|
| 1897 | + // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
| 1898 | + if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1899 | + $old_status = $this->get_default_status(); |
|
| 1900 | + } |
|
| 1901 | 1901 | |
| 1902 | - // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1903 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1904 | - $old_status = 'wpi-pending'; |
|
| 1905 | - } |
|
| 1902 | + // Paid - Renewal (i.e when duplicating a parent invoice ) |
|
| 1903 | + if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1904 | + $old_status = 'wpi-pending'; |
|
| 1905 | + } |
|
| 1906 | 1906 | |
| 1907 | - } |
|
| 1907 | + } |
|
| 1908 | 1908 | |
| 1909 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1910 | - $this->status_transition = array( |
|
| 1911 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1912 | - 'to' => $new_status, |
|
| 1913 | - 'note' => $note, |
|
| 1914 | - 'manual' => (bool) $manual_update, |
|
| 1915 | - ); |
|
| 1909 | + if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1910 | + $this->status_transition = array( |
|
| 1911 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1912 | + 'to' => $new_status, |
|
| 1913 | + 'note' => $note, |
|
| 1914 | + 'manual' => (bool) $manual_update, |
|
| 1915 | + ); |
|
| 1916 | 1916 | |
| 1917 | - if ( $manual_update ) { |
|
| 1918 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1919 | - } |
|
| 1917 | + if ( $manual_update ) { |
|
| 1918 | + do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1919 | + } |
|
| 1920 | 1920 | |
| 1921 | - $this->maybe_set_date_paid(); |
|
| 1921 | + $this->maybe_set_date_paid(); |
|
| 1922 | 1922 | |
| 1923 | - } |
|
| 1923 | + } |
|
| 1924 | 1924 | |
| 1925 | - return array( |
|
| 1926 | - 'from' => $old_status, |
|
| 1927 | - 'to' => $new_status, |
|
| 1928 | - ); |
|
| 1929 | - } |
|
| 1925 | + return array( |
|
| 1926 | + 'from' => $old_status, |
|
| 1927 | + 'to' => $new_status, |
|
| 1928 | + ); |
|
| 1929 | + } |
|
| 1930 | 1930 | |
| 1931 | - /** |
|
| 1932 | - * Maybe set date paid. |
|
| 1933 | - * |
|
| 1934 | - * Sets the date paid variable when transitioning to the payment complete |
|
| 1935 | - * order status. |
|
| 1936 | - * |
|
| 1937 | - * @since 1.0.19 |
|
| 1938 | - */ |
|
| 1939 | - public function maybe_set_date_paid() { |
|
| 1931 | + /** |
|
| 1932 | + * Maybe set date paid. |
|
| 1933 | + * |
|
| 1934 | + * Sets the date paid variable when transitioning to the payment complete |
|
| 1935 | + * order status. |
|
| 1936 | + * |
|
| 1937 | + * @since 1.0.19 |
|
| 1938 | + */ |
|
| 1939 | + public function maybe_set_date_paid() { |
|
| 1940 | 1940 | |
| 1941 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1942 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1943 | - } |
|
| 1944 | - } |
|
| 1941 | + if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1942 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1943 | + } |
|
| 1944 | + } |
|
| 1945 | 1945 | |
| 1946 | 1946 | /** |
| 1947 | - * Set parent invoice ID. |
|
| 1948 | - * |
|
| 1949 | - * @since 1.0.19 |
|
| 1950 | - */ |
|
| 1951 | - public function set_parent_id( $value ) { |
|
| 1952 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1953 | - return; |
|
| 1954 | - } |
|
| 1955 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1947 | + * Set parent invoice ID. |
|
| 1948 | + * |
|
| 1949 | + * @since 1.0.19 |
|
| 1950 | + */ |
|
| 1951 | + public function set_parent_id( $value ) { |
|
| 1952 | + if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1953 | + return; |
|
| 1954 | + } |
|
| 1955 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | /** |
| 1959 | - * Set plugin version when the invoice was created. |
|
| 1960 | - * |
|
| 1961 | - * @since 1.0.19 |
|
| 1962 | - */ |
|
| 1963 | - public function set_version( $value ) { |
|
| 1964 | - $this->set_prop( 'version', $value ); |
|
| 1959 | + * Set plugin version when the invoice was created. |
|
| 1960 | + * |
|
| 1961 | + * @since 1.0.19 |
|
| 1962 | + */ |
|
| 1963 | + public function set_version( $value ) { |
|
| 1964 | + $this->set_prop( 'version', $value ); |
|
| 1965 | 1965 | } |
| 1966 | - |
|
| 1967 | - /** |
|
| 1968 | - * Set date when the invoice was created. |
|
| 1969 | - * |
|
| 1970 | - * @since 1.0.19 |
|
| 1971 | - * @param string $value Value to set. |
|
| 1966 | + |
|
| 1967 | + /** |
|
| 1968 | + * Set date when the invoice was created. |
|
| 1969 | + * |
|
| 1970 | + * @since 1.0.19 |
|
| 1971 | + * @param string $value Value to set. |
|
| 1972 | 1972 | * @return bool Whether or not the date was set. |
| 1973 | - */ |
|
| 1974 | - public function set_date_created( $value ) { |
|
| 1973 | + */ |
|
| 1974 | + public function set_date_created( $value ) { |
|
| 1975 | 1975 | $date = strtotime( $value ); |
| 1976 | 1976 | |
| 1977 | 1977 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1979,19 +1979,19 @@ discard block |
||
| 1979 | 1979 | return true; |
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | - $this->set_prop( 'date_created', '' ); |
|
| 1983 | - return false; |
|
| 1982 | + $this->set_prop( 'date_created', '' ); |
|
| 1983 | + return false; |
|
| 1984 | 1984 | |
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | /** |
| 1988 | - * Set date invoice due date. |
|
| 1989 | - * |
|
| 1990 | - * @since 1.0.19 |
|
| 1991 | - * @param string $value Value to set. |
|
| 1988 | + * Set date invoice due date. |
|
| 1989 | + * |
|
| 1990 | + * @since 1.0.19 |
|
| 1991 | + * @param string $value Value to set. |
|
| 1992 | 1992 | * @return bool Whether or not the date was set. |
| 1993 | - */ |
|
| 1994 | - public function set_due_date( $value ) { |
|
| 1993 | + */ |
|
| 1994 | + public function set_due_date( $value ) { |
|
| 1995 | 1995 | $date = strtotime( $value ); |
| 1996 | 1996 | |
| 1997 | 1997 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1999,29 +1999,29 @@ discard block |
||
| 1999 | 1999 | return true; |
| 2000 | 2000 | } |
| 2001 | 2001 | |
| 2002 | - $this->set_prop( 'due_date', '' ); |
|
| 2002 | + $this->set_prop( 'due_date', '' ); |
|
| 2003 | 2003 | return false; |
| 2004 | 2004 | |
| 2005 | 2005 | } |
| 2006 | 2006 | |
| 2007 | 2007 | /** |
| 2008 | - * Alias of self::set_due_date(). |
|
| 2009 | - * |
|
| 2010 | - * @since 1.0.19 |
|
| 2011 | - * @param string $value New name. |
|
| 2012 | - */ |
|
| 2013 | - public function set_date_due( $value ) { |
|
| 2014 | - $this->set_due_date( $value ); |
|
| 2008 | + * Alias of self::set_due_date(). |
|
| 2009 | + * |
|
| 2010 | + * @since 1.0.19 |
|
| 2011 | + * @param string $value New name. |
|
| 2012 | + */ |
|
| 2013 | + public function set_date_due( $value ) { |
|
| 2014 | + $this->set_due_date( $value ); |
|
| 2015 | 2015 | } |
| 2016 | 2016 | |
| 2017 | 2017 | /** |
| 2018 | - * Set date invoice was completed. |
|
| 2019 | - * |
|
| 2020 | - * @since 1.0.19 |
|
| 2021 | - * @param string $value Value to set. |
|
| 2018 | + * Set date invoice was completed. |
|
| 2019 | + * |
|
| 2020 | + * @since 1.0.19 |
|
| 2021 | + * @param string $value Value to set. |
|
| 2022 | 2022 | * @return bool Whether or not the date was set. |
| 2023 | - */ |
|
| 2024 | - public function set_completed_date( $value ) { |
|
| 2023 | + */ |
|
| 2024 | + public function set_completed_date( $value ) { |
|
| 2025 | 2025 | $date = strtotime( $value ); |
| 2026 | 2026 | |
| 2027 | 2027 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2029,29 +2029,29 @@ discard block |
||
| 2029 | 2029 | return true; |
| 2030 | 2030 | } |
| 2031 | 2031 | |
| 2032 | - $this->set_prop( 'completed_date', '' ); |
|
| 2032 | + $this->set_prop( 'completed_date', '' ); |
|
| 2033 | 2033 | return false; |
| 2034 | 2034 | |
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | 2037 | /** |
| 2038 | - * Alias of self::set_completed_date(). |
|
| 2039 | - * |
|
| 2040 | - * @since 1.0.19 |
|
| 2041 | - * @param string $value New name. |
|
| 2042 | - */ |
|
| 2043 | - public function set_date_completed( $value ) { |
|
| 2044 | - $this->set_completed_date( $value ); |
|
| 2038 | + * Alias of self::set_completed_date(). |
|
| 2039 | + * |
|
| 2040 | + * @since 1.0.19 |
|
| 2041 | + * @param string $value New name. |
|
| 2042 | + */ |
|
| 2043 | + public function set_date_completed( $value ) { |
|
| 2044 | + $this->set_completed_date( $value ); |
|
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | 2047 | /** |
| 2048 | - * Set date when the invoice was last modified. |
|
| 2049 | - * |
|
| 2050 | - * @since 1.0.19 |
|
| 2051 | - * @param string $value Value to set. |
|
| 2048 | + * Set date when the invoice was last modified. |
|
| 2049 | + * |
|
| 2050 | + * @since 1.0.19 |
|
| 2051 | + * @param string $value Value to set. |
|
| 2052 | 2052 | * @return bool Whether or not the date was set. |
| 2053 | - */ |
|
| 2054 | - public function set_date_modified( $value ) { |
|
| 2053 | + */ |
|
| 2054 | + public function set_date_modified( $value ) { |
|
| 2055 | 2055 | $date = strtotime( $value ); |
| 2056 | 2056 | |
| 2057 | 2057 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -2059,763 +2059,763 @@ discard block |
||
| 2059 | 2059 | return true; |
| 2060 | 2060 | } |
| 2061 | 2061 | |
| 2062 | - $this->set_prop( 'date_modified', '' ); |
|
| 2062 | + $this->set_prop( 'date_modified', '' ); |
|
| 2063 | 2063 | return false; |
| 2064 | 2064 | |
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | /** |
| 2068 | - * Set the invoice number. |
|
| 2069 | - * |
|
| 2070 | - * @since 1.0.19 |
|
| 2071 | - * @param string $value New number. |
|
| 2072 | - */ |
|
| 2073 | - public function set_number( $value ) { |
|
| 2068 | + * Set the invoice number. |
|
| 2069 | + * |
|
| 2070 | + * @since 1.0.19 |
|
| 2071 | + * @param string $value New number. |
|
| 2072 | + */ |
|
| 2073 | + public function set_number( $value ) { |
|
| 2074 | 2074 | $number = sanitize_text_field( $value ); |
| 2075 | - $this->set_prop( 'number', $number ); |
|
| 2075 | + $this->set_prop( 'number', $number ); |
|
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | 2078 | /** |
| 2079 | - * Set the invoice type. |
|
| 2080 | - * |
|
| 2081 | - * @since 1.0.19 |
|
| 2082 | - * @param string $value Type. |
|
| 2083 | - */ |
|
| 2084 | - public function set_type( $value ) { |
|
| 2079 | + * Set the invoice type. |
|
| 2080 | + * |
|
| 2081 | + * @since 1.0.19 |
|
| 2082 | + * @param string $value Type. |
|
| 2083 | + */ |
|
| 2084 | + public function set_type( $value ) { |
|
| 2085 | 2085 | $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
| 2086 | - $this->set_prop( 'type', $type ); |
|
| 2087 | - } |
|
| 2086 | + $this->set_prop( 'type', $type ); |
|
| 2087 | + } |
|
| 2088 | 2088 | |
| 2089 | 2089 | /** |
| 2090 | - * Set the invoice post type. |
|
| 2091 | - * |
|
| 2092 | - * @since 1.0.19 |
|
| 2093 | - * @param string $value Post type. |
|
| 2094 | - */ |
|
| 2095 | - public function set_post_type( $value ) { |
|
| 2090 | + * Set the invoice post type. |
|
| 2091 | + * |
|
| 2092 | + * @since 1.0.19 |
|
| 2093 | + * @param string $value Post type. |
|
| 2094 | + */ |
|
| 2095 | + public function set_post_type( $value ) { |
|
| 2096 | 2096 | if ( getpaid_is_invoice_post_type( $value ) ) { |
| 2097 | - $this->set_type( $value ); |
|
| 2097 | + $this->set_type( $value ); |
|
| 2098 | 2098 | $this->set_prop( 'post_type', $value ); |
| 2099 | 2099 | } |
| 2100 | 2100 | } |
| 2101 | 2101 | |
| 2102 | 2102 | /** |
| 2103 | - * Set the invoice key. |
|
| 2104 | - * |
|
| 2105 | - * @since 1.0.19 |
|
| 2106 | - * @param string $value New key. |
|
| 2107 | - */ |
|
| 2108 | - public function set_key( $value ) { |
|
| 2103 | + * Set the invoice key. |
|
| 2104 | + * |
|
| 2105 | + * @since 1.0.19 |
|
| 2106 | + * @param string $value New key. |
|
| 2107 | + */ |
|
| 2108 | + public function set_key( $value ) { |
|
| 2109 | 2109 | $key = sanitize_text_field( $value ); |
| 2110 | - $this->set_prop( 'key', $key ); |
|
| 2110 | + $this->set_prop( 'key', $key ); |
|
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | 2113 | /** |
| 2114 | - * Set the invoice mode. |
|
| 2115 | - * |
|
| 2116 | - * @since 1.0.19 |
|
| 2117 | - * @param string $value mode. |
|
| 2118 | - */ |
|
| 2119 | - public function set_mode( $value ) { |
|
| 2114 | + * Set the invoice mode. |
|
| 2115 | + * |
|
| 2116 | + * @since 1.0.19 |
|
| 2117 | + * @param string $value mode. |
|
| 2118 | + */ |
|
| 2119 | + public function set_mode( $value ) { |
|
| 2120 | 2120 | if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
| 2121 | 2121 | $this->set_prop( 'value', $value ); |
| 2122 | 2122 | } |
| 2123 | 2123 | } |
| 2124 | 2124 | |
| 2125 | 2125 | /** |
| 2126 | - * Set the invoice path. |
|
| 2127 | - * |
|
| 2128 | - * @since 1.0.19 |
|
| 2129 | - * @param string $value path. |
|
| 2130 | - */ |
|
| 2131 | - public function set_path( $value ) { |
|
| 2126 | + * Set the invoice path. |
|
| 2127 | + * |
|
| 2128 | + * @since 1.0.19 |
|
| 2129 | + * @param string $value path. |
|
| 2130 | + */ |
|
| 2131 | + public function set_path( $value ) { |
|
| 2132 | 2132 | $this->set_prop( 'path', $value ); |
| 2133 | 2133 | } |
| 2134 | 2134 | |
| 2135 | 2135 | /** |
| 2136 | - * Set the invoice name. |
|
| 2137 | - * |
|
| 2138 | - * @since 1.0.19 |
|
| 2139 | - * @param string $value New name. |
|
| 2140 | - */ |
|
| 2141 | - public function set_name( $value ) { |
|
| 2136 | + * Set the invoice name. |
|
| 2137 | + * |
|
| 2138 | + * @since 1.0.19 |
|
| 2139 | + * @param string $value New name. |
|
| 2140 | + */ |
|
| 2141 | + public function set_name( $value ) { |
|
| 2142 | 2142 | $name = sanitize_text_field( $value ); |
| 2143 | - $this->set_prop( 'name', $name ); |
|
| 2143 | + $this->set_prop( 'name', $name ); |
|
| 2144 | 2144 | } |
| 2145 | 2145 | |
| 2146 | 2146 | /** |
| 2147 | - * Alias of self::set_name(). |
|
| 2148 | - * |
|
| 2149 | - * @since 1.0.19 |
|
| 2150 | - * @param string $value New name. |
|
| 2151 | - */ |
|
| 2152 | - public function set_title( $value ) { |
|
| 2153 | - $this->set_name( $value ); |
|
| 2147 | + * Alias of self::set_name(). |
|
| 2148 | + * |
|
| 2149 | + * @since 1.0.19 |
|
| 2150 | + * @param string $value New name. |
|
| 2151 | + */ |
|
| 2152 | + public function set_title( $value ) { |
|
| 2153 | + $this->set_name( $value ); |
|
| 2154 | 2154 | } |
| 2155 | 2155 | |
| 2156 | 2156 | /** |
| 2157 | - * Set the invoice description. |
|
| 2158 | - * |
|
| 2159 | - * @since 1.0.19 |
|
| 2160 | - * @param string $value New description. |
|
| 2161 | - */ |
|
| 2162 | - public function set_description( $value ) { |
|
| 2157 | + * Set the invoice description. |
|
| 2158 | + * |
|
| 2159 | + * @since 1.0.19 |
|
| 2160 | + * @param string $value New description. |
|
| 2161 | + */ |
|
| 2162 | + public function set_description( $value ) { |
|
| 2163 | 2163 | $description = wp_kses_post( $value ); |
| 2164 | - $this->set_prop( 'description', $description ); |
|
| 2164 | + $this->set_prop( 'description', $description ); |
|
| 2165 | + } |
|
| 2166 | + |
|
| 2167 | + /** |
|
| 2168 | + * Alias of self::set_description(). |
|
| 2169 | + * |
|
| 2170 | + * @since 1.0.19 |
|
| 2171 | + * @param string $value New description. |
|
| 2172 | + */ |
|
| 2173 | + public function set_excerpt( $value ) { |
|
| 2174 | + $this->set_description( $value ); |
|
| 2175 | + } |
|
| 2176 | + |
|
| 2177 | + /** |
|
| 2178 | + * Alias of self::set_description(). |
|
| 2179 | + * |
|
| 2180 | + * @since 1.0.19 |
|
| 2181 | + * @param string $value New description. |
|
| 2182 | + */ |
|
| 2183 | + public function set_summary( $value ) { |
|
| 2184 | + $this->set_description( $value ); |
|
| 2165 | 2185 | } |
| 2166 | 2186 | |
| 2167 | 2187 | /** |
| 2168 | - * Alias of self::set_description(). |
|
| 2169 | - * |
|
| 2170 | - * @since 1.0.19 |
|
| 2171 | - * @param string $value New description. |
|
| 2172 | - */ |
|
| 2173 | - public function set_excerpt( $value ) { |
|
| 2174 | - $this->set_description( $value ); |
|
| 2188 | + * Set the receiver of the invoice. |
|
| 2189 | + * |
|
| 2190 | + * @since 1.0.19 |
|
| 2191 | + * @param int $value New author. |
|
| 2192 | + */ |
|
| 2193 | + public function set_author( $value ) { |
|
| 2194 | + $user = get_user_by( 'id', (int) $value ); |
|
| 2195 | + |
|
| 2196 | + if ( $user && $user->ID ) { |
|
| 2197 | + $this->set_prop( 'author', $user->ID ); |
|
| 2198 | + $this->set_prop( 'email', $user->user_email ); |
|
| 2199 | + } |
|
| 2200 | + |
|
| 2175 | 2201 | } |
| 2176 | 2202 | |
| 2177 | 2203 | /** |
| 2178 | - * Alias of self::set_description(). |
|
| 2179 | - * |
|
| 2180 | - * @since 1.0.19 |
|
| 2181 | - * @param string $value New description. |
|
| 2182 | - */ |
|
| 2183 | - public function set_summary( $value ) { |
|
| 2184 | - $this->set_description( $value ); |
|
| 2204 | + * Alias of self::set_author(). |
|
| 2205 | + * |
|
| 2206 | + * @since 1.0.19 |
|
| 2207 | + * @param int $value New user id. |
|
| 2208 | + */ |
|
| 2209 | + public function set_user_id( $value ) { |
|
| 2210 | + $this->set_author( $value ); |
|
| 2185 | 2211 | } |
| 2186 | 2212 | |
| 2187 | 2213 | /** |
| 2188 | - * Set the receiver of the invoice. |
|
| 2189 | - * |
|
| 2190 | - * @since 1.0.19 |
|
| 2191 | - * @param int $value New author. |
|
| 2192 | - */ |
|
| 2193 | - public function set_author( $value ) { |
|
| 2194 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2214 | + * Alias of self::set_author(). |
|
| 2215 | + * |
|
| 2216 | + * @since 1.0.19 |
|
| 2217 | + * @param int $value New user id. |
|
| 2218 | + */ |
|
| 2219 | + public function set_customer_id( $value ) { |
|
| 2220 | + $this->set_author( $value ); |
|
| 2221 | + } |
|
| 2195 | 2222 | |
| 2196 | - if ( $user && $user->ID ) { |
|
| 2197 | - $this->set_prop( 'author', $user->ID ); |
|
| 2198 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2199 | - } |
|
| 2223 | + /** |
|
| 2224 | + * Set the customer's ip. |
|
| 2225 | + * |
|
| 2226 | + * @since 1.0.19 |
|
| 2227 | + * @param string $value ip address. |
|
| 2228 | + */ |
|
| 2229 | + public function set_ip( $value ) { |
|
| 2230 | + $this->set_prop( 'ip', $value ); |
|
| 2231 | + } |
|
| 2200 | 2232 | |
| 2233 | + /** |
|
| 2234 | + * Alias of self::set_ip(). |
|
| 2235 | + * |
|
| 2236 | + * @since 1.0.19 |
|
| 2237 | + * @param string $value ip address. |
|
| 2238 | + */ |
|
| 2239 | + public function set_user_ip( $value ) { |
|
| 2240 | + $this->set_ip( $value ); |
|
| 2201 | 2241 | } |
| 2202 | 2242 | |
| 2203 | 2243 | /** |
| 2204 | - * Alias of self::set_author(). |
|
| 2205 | - * |
|
| 2206 | - * @since 1.0.19 |
|
| 2207 | - * @param int $value New user id. |
|
| 2208 | - */ |
|
| 2209 | - public function set_user_id( $value ) { |
|
| 2210 | - $this->set_author( $value ); |
|
| 2244 | + * Set the customer's first name. |
|
| 2245 | + * |
|
| 2246 | + * @since 1.0.19 |
|
| 2247 | + * @param string $value first name. |
|
| 2248 | + */ |
|
| 2249 | + public function set_first_name( $value ) { |
|
| 2250 | + $this->set_prop( 'first_name', $value ); |
|
| 2211 | 2251 | } |
| 2212 | 2252 | |
| 2213 | 2253 | /** |
| 2214 | - * Alias of self::set_author(). |
|
| 2215 | - * |
|
| 2216 | - * @since 1.0.19 |
|
| 2217 | - * @param int $value New user id. |
|
| 2218 | - */ |
|
| 2219 | - public function set_customer_id( $value ) { |
|
| 2220 | - $this->set_author( $value ); |
|
| 2254 | + * Alias of self::set_first_name(). |
|
| 2255 | + * |
|
| 2256 | + * @since 1.0.19 |
|
| 2257 | + * @param string $value first name. |
|
| 2258 | + */ |
|
| 2259 | + public function set_user_first_name( $value ) { |
|
| 2260 | + $this->set_first_name( $value ); |
|
| 2221 | 2261 | } |
| 2222 | 2262 | |
| 2223 | 2263 | /** |
| 2224 | - * Set the customer's ip. |
|
| 2225 | - * |
|
| 2226 | - * @since 1.0.19 |
|
| 2227 | - * @param string $value ip address. |
|
| 2228 | - */ |
|
| 2229 | - public function set_ip( $value ) { |
|
| 2230 | - $this->set_prop( 'ip', $value ); |
|
| 2264 | + * Alias of self::set_first_name(). |
|
| 2265 | + * |
|
| 2266 | + * @since 1.0.19 |
|
| 2267 | + * @param string $value first name. |
|
| 2268 | + */ |
|
| 2269 | + public function set_customer_first_name( $value ) { |
|
| 2270 | + $this->set_first_name( $value ); |
|
| 2231 | 2271 | } |
| 2232 | 2272 | |
| 2233 | 2273 | /** |
| 2234 | - * Alias of self::set_ip(). |
|
| 2235 | - * |
|
| 2236 | - * @since 1.0.19 |
|
| 2237 | - * @param string $value ip address. |
|
| 2238 | - */ |
|
| 2239 | - public function set_user_ip( $value ) { |
|
| 2240 | - $this->set_ip( $value ); |
|
| 2274 | + * Set the customer's last name. |
|
| 2275 | + * |
|
| 2276 | + * @since 1.0.19 |
|
| 2277 | + * @param string $value last name. |
|
| 2278 | + */ |
|
| 2279 | + public function set_last_name( $value ) { |
|
| 2280 | + $this->set_prop( 'last_name', $value ); |
|
| 2241 | 2281 | } |
| 2242 | 2282 | |
| 2243 | 2283 | /** |
| 2244 | - * Set the customer's first name. |
|
| 2245 | - * |
|
| 2246 | - * @since 1.0.19 |
|
| 2247 | - * @param string $value first name. |
|
| 2248 | - */ |
|
| 2249 | - public function set_first_name( $value ) { |
|
| 2250 | - $this->set_prop( 'first_name', $value ); |
|
| 2284 | + * Alias of self::set_last_name(). |
|
| 2285 | + * |
|
| 2286 | + * @since 1.0.19 |
|
| 2287 | + * @param string $value last name. |
|
| 2288 | + */ |
|
| 2289 | + public function set_user_last_name( $value ) { |
|
| 2290 | + $this->set_last_name( $value ); |
|
| 2251 | 2291 | } |
| 2252 | 2292 | |
| 2253 | 2293 | /** |
| 2254 | - * Alias of self::set_first_name(). |
|
| 2255 | - * |
|
| 2256 | - * @since 1.0.19 |
|
| 2257 | - * @param string $value first name. |
|
| 2258 | - */ |
|
| 2259 | - public function set_user_first_name( $value ) { |
|
| 2260 | - $this->set_first_name( $value ); |
|
| 2294 | + * Alias of self::set_last_name(). |
|
| 2295 | + * |
|
| 2296 | + * @since 1.0.19 |
|
| 2297 | + * @param string $value last name. |
|
| 2298 | + */ |
|
| 2299 | + public function set_customer_last_name( $value ) { |
|
| 2300 | + $this->set_last_name( $value ); |
|
| 2261 | 2301 | } |
| 2262 | 2302 | |
| 2263 | 2303 | /** |
| 2264 | - * Alias of self::set_first_name(). |
|
| 2265 | - * |
|
| 2266 | - * @since 1.0.19 |
|
| 2267 | - * @param string $value first name. |
|
| 2268 | - */ |
|
| 2269 | - public function set_customer_first_name( $value ) { |
|
| 2270 | - $this->set_first_name( $value ); |
|
| 2304 | + * Set the customer's phone number. |
|
| 2305 | + * |
|
| 2306 | + * @since 1.0.19 |
|
| 2307 | + * @param string $value phone. |
|
| 2308 | + */ |
|
| 2309 | + public function set_phone( $value ) { |
|
| 2310 | + $this->set_prop( 'phone', $value ); |
|
| 2271 | 2311 | } |
| 2272 | 2312 | |
| 2273 | 2313 | /** |
| 2274 | - * Set the customer's last name. |
|
| 2275 | - * |
|
| 2276 | - * @since 1.0.19 |
|
| 2277 | - * @param string $value last name. |
|
| 2278 | - */ |
|
| 2279 | - public function set_last_name( $value ) { |
|
| 2280 | - $this->set_prop( 'last_name', $value ); |
|
| 2314 | + * Alias of self::set_phone(). |
|
| 2315 | + * |
|
| 2316 | + * @since 1.0.19 |
|
| 2317 | + * @param string $value phone. |
|
| 2318 | + */ |
|
| 2319 | + public function set_user_phone( $value ) { |
|
| 2320 | + $this->set_phone( $value ); |
|
| 2281 | 2321 | } |
| 2282 | 2322 | |
| 2283 | 2323 | /** |
| 2284 | - * Alias of self::set_last_name(). |
|
| 2285 | - * |
|
| 2286 | - * @since 1.0.19 |
|
| 2287 | - * @param string $value last name. |
|
| 2288 | - */ |
|
| 2289 | - public function set_user_last_name( $value ) { |
|
| 2290 | - $this->set_last_name( $value ); |
|
| 2324 | + * Alias of self::set_phone(). |
|
| 2325 | + * |
|
| 2326 | + * @since 1.0.19 |
|
| 2327 | + * @param string $value phone. |
|
| 2328 | + */ |
|
| 2329 | + public function set_customer_phone( $value ) { |
|
| 2330 | + $this->set_phone( $value ); |
|
| 2291 | 2331 | } |
| 2292 | 2332 | |
| 2293 | 2333 | /** |
| 2294 | - * Alias of self::set_last_name(). |
|
| 2295 | - * |
|
| 2296 | - * @since 1.0.19 |
|
| 2297 | - * @param string $value last name. |
|
| 2298 | - */ |
|
| 2299 | - public function set_customer_last_name( $value ) { |
|
| 2300 | - $this->set_last_name( $value ); |
|
| 2334 | + * Alias of self::set_phone(). |
|
| 2335 | + * |
|
| 2336 | + * @since 1.0.19 |
|
| 2337 | + * @param string $value phone. |
|
| 2338 | + */ |
|
| 2339 | + public function set_phone_number( $value ) { |
|
| 2340 | + $this->set_phone( $value ); |
|
| 2301 | 2341 | } |
| 2302 | 2342 | |
| 2303 | 2343 | /** |
| 2304 | - * Set the customer's phone number. |
|
| 2305 | - * |
|
| 2306 | - * @since 1.0.19 |
|
| 2307 | - * @param string $value phone. |
|
| 2308 | - */ |
|
| 2309 | - public function set_phone( $value ) { |
|
| 2310 | - $this->set_prop( 'phone', $value ); |
|
| 2344 | + * Set the customer's email address. |
|
| 2345 | + * |
|
| 2346 | + * @since 1.0.19 |
|
| 2347 | + * @param string $value email address. |
|
| 2348 | + */ |
|
| 2349 | + public function set_email( $value ) { |
|
| 2350 | + $this->set_prop( 'email', $value ); |
|
| 2311 | 2351 | } |
| 2312 | 2352 | |
| 2313 | 2353 | /** |
| 2314 | - * Alias of self::set_phone(). |
|
| 2315 | - * |
|
| 2316 | - * @since 1.0.19 |
|
| 2317 | - * @param string $value phone. |
|
| 2318 | - */ |
|
| 2319 | - public function set_user_phone( $value ) { |
|
| 2320 | - $this->set_phone( $value ); |
|
| 2354 | + * Alias of self::set_email(). |
|
| 2355 | + * |
|
| 2356 | + * @since 1.0.19 |
|
| 2357 | + * @param string $value email address. |
|
| 2358 | + */ |
|
| 2359 | + public function set_user_email( $value ) { |
|
| 2360 | + $this->set_email( $value ); |
|
| 2321 | 2361 | } |
| 2322 | 2362 | |
| 2323 | 2363 | /** |
| 2324 | - * Alias of self::set_phone(). |
|
| 2325 | - * |
|
| 2326 | - * @since 1.0.19 |
|
| 2327 | - * @param string $value phone. |
|
| 2328 | - */ |
|
| 2329 | - public function set_customer_phone( $value ) { |
|
| 2330 | - $this->set_phone( $value ); |
|
| 2364 | + * Alias of self::set_email(). |
|
| 2365 | + * |
|
| 2366 | + * @since 1.0.19 |
|
| 2367 | + * @param string $value email address. |
|
| 2368 | + */ |
|
| 2369 | + public function set_email_address( $value ) { |
|
| 2370 | + $this->set_email( $value ); |
|
| 2331 | 2371 | } |
| 2332 | 2372 | |
| 2333 | 2373 | /** |
| 2334 | - * Alias of self::set_phone(). |
|
| 2335 | - * |
|
| 2336 | - * @since 1.0.19 |
|
| 2337 | - * @param string $value phone. |
|
| 2338 | - */ |
|
| 2339 | - public function set_phone_number( $value ) { |
|
| 2340 | - $this->set_phone( $value ); |
|
| 2374 | + * Alias of self::set_email(). |
|
| 2375 | + * |
|
| 2376 | + * @since 1.0.19 |
|
| 2377 | + * @param string $value email address. |
|
| 2378 | + */ |
|
| 2379 | + public function set_customer_email( $value ) { |
|
| 2380 | + $this->set_email( $value ); |
|
| 2341 | 2381 | } |
| 2342 | 2382 | |
| 2343 | 2383 | /** |
| 2344 | - * Set the customer's email address. |
|
| 2345 | - * |
|
| 2346 | - * @since 1.0.19 |
|
| 2347 | - * @param string $value email address. |
|
| 2348 | - */ |
|
| 2349 | - public function set_email( $value ) { |
|
| 2350 | - $this->set_prop( 'email', $value ); |
|
| 2384 | + * Set the customer's country. |
|
| 2385 | + * |
|
| 2386 | + * @since 1.0.19 |
|
| 2387 | + * @param string $value country. |
|
| 2388 | + */ |
|
| 2389 | + public function set_country( $value ) { |
|
| 2390 | + $this->set_prop( 'country', $value ); |
|
| 2351 | 2391 | } |
| 2352 | 2392 | |
| 2353 | 2393 | /** |
| 2354 | - * Alias of self::set_email(). |
|
| 2355 | - * |
|
| 2356 | - * @since 1.0.19 |
|
| 2357 | - * @param string $value email address. |
|
| 2358 | - */ |
|
| 2359 | - public function set_user_email( $value ) { |
|
| 2360 | - $this->set_email( $value ); |
|
| 2394 | + * Alias of self::set_country(). |
|
| 2395 | + * |
|
| 2396 | + * @since 1.0.19 |
|
| 2397 | + * @param string $value country. |
|
| 2398 | + */ |
|
| 2399 | + public function set_user_country( $value ) { |
|
| 2400 | + $this->set_country( $value ); |
|
| 2361 | 2401 | } |
| 2362 | 2402 | |
| 2363 | 2403 | /** |
| 2364 | - * Alias of self::set_email(). |
|
| 2365 | - * |
|
| 2366 | - * @since 1.0.19 |
|
| 2367 | - * @param string $value email address. |
|
| 2368 | - */ |
|
| 2369 | - public function set_email_address( $value ) { |
|
| 2370 | - $this->set_email( $value ); |
|
| 2404 | + * Alias of self::set_country(). |
|
| 2405 | + * |
|
| 2406 | + * @since 1.0.19 |
|
| 2407 | + * @param string $value country. |
|
| 2408 | + */ |
|
| 2409 | + public function set_customer_country( $value ) { |
|
| 2410 | + $this->set_country( $value ); |
|
| 2371 | 2411 | } |
| 2372 | 2412 | |
| 2373 | 2413 | /** |
| 2374 | - * Alias of self::set_email(). |
|
| 2375 | - * |
|
| 2376 | - * @since 1.0.19 |
|
| 2377 | - * @param string $value email address. |
|
| 2378 | - */ |
|
| 2379 | - public function set_customer_email( $value ) { |
|
| 2380 | - $this->set_email( $value ); |
|
| 2414 | + * Set the customer's state. |
|
| 2415 | + * |
|
| 2416 | + * @since 1.0.19 |
|
| 2417 | + * @param string $value state. |
|
| 2418 | + */ |
|
| 2419 | + public function set_state( $value ) { |
|
| 2420 | + $this->set_prop( 'state', $value ); |
|
| 2381 | 2421 | } |
| 2382 | 2422 | |
| 2383 | 2423 | /** |
| 2384 | - * Set the customer's country. |
|
| 2385 | - * |
|
| 2386 | - * @since 1.0.19 |
|
| 2387 | - * @param string $value country. |
|
| 2388 | - */ |
|
| 2389 | - public function set_country( $value ) { |
|
| 2390 | - $this->set_prop( 'country', $value ); |
|
| 2424 | + * Alias of self::set_state(). |
|
| 2425 | + * |
|
| 2426 | + * @since 1.0.19 |
|
| 2427 | + * @param string $value state. |
|
| 2428 | + */ |
|
| 2429 | + public function set_user_state( $value ) { |
|
| 2430 | + $this->set_state( $value ); |
|
| 2391 | 2431 | } |
| 2392 | 2432 | |
| 2393 | 2433 | /** |
| 2394 | - * Alias of self::set_country(). |
|
| 2395 | - * |
|
| 2396 | - * @since 1.0.19 |
|
| 2397 | - * @param string $value country. |
|
| 2398 | - */ |
|
| 2399 | - public function set_user_country( $value ) { |
|
| 2400 | - $this->set_country( $value ); |
|
| 2434 | + * Alias of self::set_state(). |
|
| 2435 | + * |
|
| 2436 | + * @since 1.0.19 |
|
| 2437 | + * @param string $value state. |
|
| 2438 | + */ |
|
| 2439 | + public function set_customer_state( $value ) { |
|
| 2440 | + $this->set_state( $value ); |
|
| 2401 | 2441 | } |
| 2402 | 2442 | |
| 2403 | 2443 | /** |
| 2404 | - * Alias of self::set_country(). |
|
| 2405 | - * |
|
| 2406 | - * @since 1.0.19 |
|
| 2407 | - * @param string $value country. |
|
| 2408 | - */ |
|
| 2409 | - public function set_customer_country( $value ) { |
|
| 2410 | - $this->set_country( $value ); |
|
| 2444 | + * Set the customer's city. |
|
| 2445 | + * |
|
| 2446 | + * @since 1.0.19 |
|
| 2447 | + * @param string $value city. |
|
| 2448 | + */ |
|
| 2449 | + public function set_city( $value ) { |
|
| 2450 | + $this->set_prop( 'city', $value ); |
|
| 2411 | 2451 | } |
| 2412 | 2452 | |
| 2413 | 2453 | /** |
| 2414 | - * Set the customer's state. |
|
| 2415 | - * |
|
| 2416 | - * @since 1.0.19 |
|
| 2417 | - * @param string $value state. |
|
| 2418 | - */ |
|
| 2419 | - public function set_state( $value ) { |
|
| 2420 | - $this->set_prop( 'state', $value ); |
|
| 2454 | + * Alias of self::set_city(). |
|
| 2455 | + * |
|
| 2456 | + * @since 1.0.19 |
|
| 2457 | + * @param string $value city. |
|
| 2458 | + */ |
|
| 2459 | + public function set_user_city( $value ) { |
|
| 2460 | + $this->set_city( $value ); |
|
| 2421 | 2461 | } |
| 2422 | 2462 | |
| 2423 | 2463 | /** |
| 2424 | - * Alias of self::set_state(). |
|
| 2425 | - * |
|
| 2426 | - * @since 1.0.19 |
|
| 2427 | - * @param string $value state. |
|
| 2428 | - */ |
|
| 2429 | - public function set_user_state( $value ) { |
|
| 2430 | - $this->set_state( $value ); |
|
| 2464 | + * Alias of self::set_city(). |
|
| 2465 | + * |
|
| 2466 | + * @since 1.0.19 |
|
| 2467 | + * @param string $value city. |
|
| 2468 | + */ |
|
| 2469 | + public function set_customer_city( $value ) { |
|
| 2470 | + $this->set_city( $value ); |
|
| 2431 | 2471 | } |
| 2432 | 2472 | |
| 2433 | 2473 | /** |
| 2434 | - * Alias of self::set_state(). |
|
| 2435 | - * |
|
| 2436 | - * @since 1.0.19 |
|
| 2437 | - * @param string $value state. |
|
| 2438 | - */ |
|
| 2439 | - public function set_customer_state( $value ) { |
|
| 2440 | - $this->set_state( $value ); |
|
| 2474 | + * Set the customer's zip code. |
|
| 2475 | + * |
|
| 2476 | + * @since 1.0.19 |
|
| 2477 | + * @param string $value zip. |
|
| 2478 | + */ |
|
| 2479 | + public function set_zip( $value ) { |
|
| 2480 | + $this->set_prop( 'zip', $value ); |
|
| 2441 | 2481 | } |
| 2442 | 2482 | |
| 2443 | 2483 | /** |
| 2444 | - * Set the customer's city. |
|
| 2445 | - * |
|
| 2446 | - * @since 1.0.19 |
|
| 2447 | - * @param string $value city. |
|
| 2448 | - */ |
|
| 2449 | - public function set_city( $value ) { |
|
| 2450 | - $this->set_prop( 'city', $value ); |
|
| 2484 | + * Alias of self::set_zip(). |
|
| 2485 | + * |
|
| 2486 | + * @since 1.0.19 |
|
| 2487 | + * @param string $value zip. |
|
| 2488 | + */ |
|
| 2489 | + public function set_user_zip( $value ) { |
|
| 2490 | + $this->set_zip( $value ); |
|
| 2451 | 2491 | } |
| 2452 | 2492 | |
| 2453 | 2493 | /** |
| 2454 | - * Alias of self::set_city(). |
|
| 2455 | - * |
|
| 2456 | - * @since 1.0.19 |
|
| 2457 | - * @param string $value city. |
|
| 2458 | - */ |
|
| 2459 | - public function set_user_city( $value ) { |
|
| 2460 | - $this->set_city( $value ); |
|
| 2494 | + * Alias of self::set_zip(). |
|
| 2495 | + * |
|
| 2496 | + * @since 1.0.19 |
|
| 2497 | + * @param string $value zip. |
|
| 2498 | + */ |
|
| 2499 | + public function set_customer_zip( $value ) { |
|
| 2500 | + $this->set_zip( $value ); |
|
| 2461 | 2501 | } |
| 2462 | 2502 | |
| 2463 | 2503 | /** |
| 2464 | - * Alias of self::set_city(). |
|
| 2465 | - * |
|
| 2466 | - * @since 1.0.19 |
|
| 2467 | - * @param string $value city. |
|
| 2468 | - */ |
|
| 2469 | - public function set_customer_city( $value ) { |
|
| 2470 | - $this->set_city( $value ); |
|
| 2504 | + * Set the customer's company. |
|
| 2505 | + * |
|
| 2506 | + * @since 1.0.19 |
|
| 2507 | + * @param string $value company. |
|
| 2508 | + */ |
|
| 2509 | + public function set_company( $value ) { |
|
| 2510 | + $this->set_prop( 'company', $value ); |
|
| 2471 | 2511 | } |
| 2472 | 2512 | |
| 2473 | 2513 | /** |
| 2474 | - * Set the customer's zip code. |
|
| 2475 | - * |
|
| 2476 | - * @since 1.0.19 |
|
| 2477 | - * @param string $value zip. |
|
| 2478 | - */ |
|
| 2479 | - public function set_zip( $value ) { |
|
| 2480 | - $this->set_prop( 'zip', $value ); |
|
| 2514 | + * Alias of self::set_company(). |
|
| 2515 | + * |
|
| 2516 | + * @since 1.0.19 |
|
| 2517 | + * @param string $value company. |
|
| 2518 | + */ |
|
| 2519 | + public function set_user_company( $value ) { |
|
| 2520 | + $this->set_company( $value ); |
|
| 2481 | 2521 | } |
| 2482 | 2522 | |
| 2483 | 2523 | /** |
| 2484 | - * Alias of self::set_zip(). |
|
| 2485 | - * |
|
| 2486 | - * @since 1.0.19 |
|
| 2487 | - * @param string $value zip. |
|
| 2488 | - */ |
|
| 2489 | - public function set_user_zip( $value ) { |
|
| 2490 | - $this->set_zip( $value ); |
|
| 2524 | + * Alias of self::set_company(). |
|
| 2525 | + * |
|
| 2526 | + * @since 1.0.19 |
|
| 2527 | + * @param string $value company. |
|
| 2528 | + */ |
|
| 2529 | + public function set_customer_company( $value ) { |
|
| 2530 | + $this->set_company( $value ); |
|
| 2491 | 2531 | } |
| 2492 | 2532 | |
| 2493 | 2533 | /** |
| 2494 | - * Alias of self::set_zip(). |
|
| 2495 | - * |
|
| 2496 | - * @since 1.0.19 |
|
| 2497 | - * @param string $value zip. |
|
| 2498 | - */ |
|
| 2499 | - public function set_customer_zip( $value ) { |
|
| 2500 | - $this->set_zip( $value ); |
|
| 2534 | + * Set the customer's var number. |
|
| 2535 | + * |
|
| 2536 | + * @since 1.0.19 |
|
| 2537 | + * @param string $value var number. |
|
| 2538 | + */ |
|
| 2539 | + public function set_vat_number( $value ) { |
|
| 2540 | + $this->set_prop( 'vat_number', $value ); |
|
| 2501 | 2541 | } |
| 2502 | 2542 | |
| 2503 | 2543 | /** |
| 2504 | - * Set the customer's company. |
|
| 2505 | - * |
|
| 2506 | - * @since 1.0.19 |
|
| 2507 | - * @param string $value company. |
|
| 2508 | - */ |
|
| 2509 | - public function set_company( $value ) { |
|
| 2510 | - $this->set_prop( 'company', $value ); |
|
| 2544 | + * Alias of self::set_vat_number(). |
|
| 2545 | + * |
|
| 2546 | + * @since 1.0.19 |
|
| 2547 | + * @param string $value var number. |
|
| 2548 | + */ |
|
| 2549 | + public function set_user_vat_number( $value ) { |
|
| 2550 | + $this->set_vat_number( $value ); |
|
| 2511 | 2551 | } |
| 2512 | 2552 | |
| 2513 | 2553 | /** |
| 2514 | - * Alias of self::set_company(). |
|
| 2515 | - * |
|
| 2516 | - * @since 1.0.19 |
|
| 2517 | - * @param string $value company. |
|
| 2518 | - */ |
|
| 2519 | - public function set_user_company( $value ) { |
|
| 2520 | - $this->set_company( $value ); |
|
| 2554 | + * Alias of self::set_vat_number(). |
|
| 2555 | + * |
|
| 2556 | + * @since 1.0.19 |
|
| 2557 | + * @param string $value var number. |
|
| 2558 | + */ |
|
| 2559 | + public function set_customer_vat_number( $value ) { |
|
| 2560 | + $this->set_vat_number( $value ); |
|
| 2521 | 2561 | } |
| 2522 | 2562 | |
| 2523 | 2563 | /** |
| 2524 | - * Alias of self::set_company(). |
|
| 2525 | - * |
|
| 2526 | - * @since 1.0.19 |
|
| 2527 | - * @param string $value company. |
|
| 2528 | - */ |
|
| 2529 | - public function set_customer_company( $value ) { |
|
| 2530 | - $this->set_company( $value ); |
|
| 2564 | + * Set the customer's vat rate. |
|
| 2565 | + * |
|
| 2566 | + * @since 1.0.19 |
|
| 2567 | + * @param string $value var rate. |
|
| 2568 | + */ |
|
| 2569 | + public function set_vat_rate( $value ) { |
|
| 2570 | + $this->set_prop( 'vat_rate', $value ); |
|
| 2531 | 2571 | } |
| 2532 | 2572 | |
| 2533 | 2573 | /** |
| 2534 | - * Set the customer's var number. |
|
| 2535 | - * |
|
| 2536 | - * @since 1.0.19 |
|
| 2537 | - * @param string $value var number. |
|
| 2538 | - */ |
|
| 2539 | - public function set_vat_number( $value ) { |
|
| 2540 | - $this->set_prop( 'vat_number', $value ); |
|
| 2574 | + * Alias of self::set_vat_rate(). |
|
| 2575 | + * |
|
| 2576 | + * @since 1.0.19 |
|
| 2577 | + * @param string $value var number. |
|
| 2578 | + */ |
|
| 2579 | + public function set_user_vat_rate( $value ) { |
|
| 2580 | + $this->set_vat_rate( $value ); |
|
| 2541 | 2581 | } |
| 2542 | 2582 | |
| 2543 | 2583 | /** |
| 2544 | - * Alias of self::set_vat_number(). |
|
| 2545 | - * |
|
| 2546 | - * @since 1.0.19 |
|
| 2547 | - * @param string $value var number. |
|
| 2548 | - */ |
|
| 2549 | - public function set_user_vat_number( $value ) { |
|
| 2550 | - $this->set_vat_number( $value ); |
|
| 2584 | + * Alias of self::set_vat_rate(). |
|
| 2585 | + * |
|
| 2586 | + * @since 1.0.19 |
|
| 2587 | + * @param string $value var number. |
|
| 2588 | + */ |
|
| 2589 | + public function set_customer_vat_rate( $value ) { |
|
| 2590 | + $this->set_vat_rate( $value ); |
|
| 2551 | 2591 | } |
| 2552 | 2592 | |
| 2553 | 2593 | /** |
| 2554 | - * Alias of self::set_vat_number(). |
|
| 2555 | - * |
|
| 2556 | - * @since 1.0.19 |
|
| 2557 | - * @param string $value var number. |
|
| 2558 | - */ |
|
| 2559 | - public function set_customer_vat_number( $value ) { |
|
| 2560 | - $this->set_vat_number( $value ); |
|
| 2594 | + * Set the customer's address. |
|
| 2595 | + * |
|
| 2596 | + * @since 1.0.19 |
|
| 2597 | + * @param string $value address. |
|
| 2598 | + */ |
|
| 2599 | + public function set_address( $value ) { |
|
| 2600 | + $this->set_prop( 'address', $value ); |
|
| 2561 | 2601 | } |
| 2562 | 2602 | |
| 2563 | 2603 | /** |
| 2564 | - * Set the customer's vat rate. |
|
| 2565 | - * |
|
| 2566 | - * @since 1.0.19 |
|
| 2567 | - * @param string $value var rate. |
|
| 2568 | - */ |
|
| 2569 | - public function set_vat_rate( $value ) { |
|
| 2570 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2604 | + * Alias of self::set_address(). |
|
| 2605 | + * |
|
| 2606 | + * @since 1.0.19 |
|
| 2607 | + * @param string $value address. |
|
| 2608 | + */ |
|
| 2609 | + public function set_user_address( $value ) { |
|
| 2610 | + $this->set_address( $value ); |
|
| 2571 | 2611 | } |
| 2572 | 2612 | |
| 2573 | 2613 | /** |
| 2574 | - * Alias of self::set_vat_rate(). |
|
| 2575 | - * |
|
| 2576 | - * @since 1.0.19 |
|
| 2577 | - * @param string $value var number. |
|
| 2578 | - */ |
|
| 2579 | - public function set_user_vat_rate( $value ) { |
|
| 2580 | - $this->set_vat_rate( $value ); |
|
| 2614 | + * Alias of self::set_address(). |
|
| 2615 | + * |
|
| 2616 | + * @since 1.0.19 |
|
| 2617 | + * @param string $value address. |
|
| 2618 | + */ |
|
| 2619 | + public function set_customer_address( $value ) { |
|
| 2620 | + $this->set_address( $value ); |
|
| 2581 | 2621 | } |
| 2582 | 2622 | |
| 2583 | 2623 | /** |
| 2584 | - * Alias of self::set_vat_rate(). |
|
| 2585 | - * |
|
| 2586 | - * @since 1.0.19 |
|
| 2587 | - * @param string $value var number. |
|
| 2588 | - */ |
|
| 2589 | - public function set_customer_vat_rate( $value ) { |
|
| 2590 | - $this->set_vat_rate( $value ); |
|
| 2624 | + * Set whether the customer has viewed the invoice or not. |
|
| 2625 | + * |
|
| 2626 | + * @since 1.0.19 |
|
| 2627 | + * @param int|bool $value confirmed. |
|
| 2628 | + */ |
|
| 2629 | + public function set_is_viewed( $value ) { |
|
| 2630 | + $this->set_prop( 'is_viewed', $value ); |
|
| 2591 | 2631 | } |
| 2592 | 2632 | |
| 2593 | 2633 | /** |
| 2594 | - * Set the customer's address. |
|
| 2595 | - * |
|
| 2596 | - * @since 1.0.19 |
|
| 2597 | - * @param string $value address. |
|
| 2598 | - */ |
|
| 2599 | - public function set_address( $value ) { |
|
| 2600 | - $this->set_prop( 'address', $value ); |
|
| 2634 | + * Set extra email recipients. |
|
| 2635 | + * |
|
| 2636 | + * @since 1.0.19 |
|
| 2637 | + * @param string $value email recipients. |
|
| 2638 | + */ |
|
| 2639 | + public function set_email_cc( $value ) { |
|
| 2640 | + $this->set_prop( 'email_cc', $value ); |
|
| 2601 | 2641 | } |
| 2602 | 2642 | |
| 2603 | 2643 | /** |
| 2604 | - * Alias of self::set_address(). |
|
| 2605 | - * |
|
| 2606 | - * @since 1.0.19 |
|
| 2607 | - * @param string $value address. |
|
| 2608 | - */ |
|
| 2609 | - public function set_user_address( $value ) { |
|
| 2610 | - $this->set_address( $value ); |
|
| 2644 | + * Set the invoice template. |
|
| 2645 | + * |
|
| 2646 | + * @since 1.0.19 |
|
| 2647 | + * @param string $value template. |
|
| 2648 | + */ |
|
| 2649 | + public function set_template( $value ) { |
|
| 2650 | + if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2651 | + $this->set_prop( 'template', $value ); |
|
| 2652 | + } |
|
| 2611 | 2653 | } |
| 2612 | 2654 | |
| 2613 | 2655 | /** |
| 2614 | - * Alias of self::set_address(). |
|
| 2615 | - * |
|
| 2616 | - * @since 1.0.19 |
|
| 2617 | - * @param string $value address. |
|
| 2618 | - */ |
|
| 2619 | - public function set_customer_address( $value ) { |
|
| 2620 | - $this->set_address( $value ); |
|
| 2656 | + * Set the invoice source. |
|
| 2657 | + * |
|
| 2658 | + * @since 1.0.19 |
|
| 2659 | + * @param string $value email recipients. |
|
| 2660 | + */ |
|
| 2661 | + public function created_via( $value ) { |
|
| 2662 | + $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2621 | 2663 | } |
| 2622 | 2664 | |
| 2623 | 2665 | /** |
| 2624 | - * Set whether the customer has viewed the invoice or not. |
|
| 2625 | - * |
|
| 2626 | - * @since 1.0.19 |
|
| 2627 | - * @param int|bool $value confirmed. |
|
| 2628 | - */ |
|
| 2629 | - public function set_is_viewed( $value ) { |
|
| 2630 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2631 | - } |
|
| 2632 | - |
|
| 2633 | - /** |
|
| 2634 | - * Set extra email recipients. |
|
| 2635 | - * |
|
| 2636 | - * @since 1.0.19 |
|
| 2637 | - * @param string $value email recipients. |
|
| 2638 | - */ |
|
| 2639 | - public function set_email_cc( $value ) { |
|
| 2640 | - $this->set_prop( 'email_cc', $value ); |
|
| 2641 | - } |
|
| 2642 | - |
|
| 2643 | - /** |
|
| 2644 | - * Set the invoice template. |
|
| 2645 | - * |
|
| 2646 | - * @since 1.0.19 |
|
| 2647 | - * @param string $value template. |
|
| 2648 | - */ |
|
| 2649 | - public function set_template( $value ) { |
|
| 2650 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2651 | - $this->set_prop( 'template', $value ); |
|
| 2652 | - } |
|
| 2653 | - } |
|
| 2654 | - |
|
| 2655 | - /** |
|
| 2656 | - * Set the invoice source. |
|
| 2657 | - * |
|
| 2658 | - * @since 1.0.19 |
|
| 2659 | - * @param string $value email recipients. |
|
| 2660 | - */ |
|
| 2661 | - public function created_via( $value ) { |
|
| 2662 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2663 | - } |
|
| 2664 | - |
|
| 2665 | - /** |
|
| 2666 | - * Set the customer's address confirmed status. |
|
| 2667 | - * |
|
| 2668 | - * @since 1.0.19 |
|
| 2669 | - * @param int|bool $value confirmed. |
|
| 2670 | - */ |
|
| 2671 | - public function set_address_confirmed( $value ) { |
|
| 2672 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2666 | + * Set the customer's address confirmed status. |
|
| 2667 | + * |
|
| 2668 | + * @since 1.0.19 |
|
| 2669 | + * @param int|bool $value confirmed. |
|
| 2670 | + */ |
|
| 2671 | + public function set_address_confirmed( $value ) { |
|
| 2672 | + $this->set_prop( 'address_confirmed', $value ); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | 2675 | /** |
| 2676 | - * Alias of self::set_address_confirmed(). |
|
| 2677 | - * |
|
| 2678 | - * @since 1.0.19 |
|
| 2679 | - * @param int|bool $value confirmed. |
|
| 2680 | - */ |
|
| 2681 | - public function set_user_address_confirmed( $value ) { |
|
| 2682 | - $this->set_address_confirmed( $value ); |
|
| 2676 | + * Alias of self::set_address_confirmed(). |
|
| 2677 | + * |
|
| 2678 | + * @since 1.0.19 |
|
| 2679 | + * @param int|bool $value confirmed. |
|
| 2680 | + */ |
|
| 2681 | + public function set_user_address_confirmed( $value ) { |
|
| 2682 | + $this->set_address_confirmed( $value ); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | /** |
| 2686 | - * Alias of self::set_address_confirmed(). |
|
| 2687 | - * |
|
| 2688 | - * @since 1.0.19 |
|
| 2689 | - * @param int|bool $value confirmed. |
|
| 2690 | - */ |
|
| 2691 | - public function set_customer_address_confirmed( $value ) { |
|
| 2692 | - $this->set_address_confirmed( $value ); |
|
| 2686 | + * Alias of self::set_address_confirmed(). |
|
| 2687 | + * |
|
| 2688 | + * @since 1.0.19 |
|
| 2689 | + * @param int|bool $value confirmed. |
|
| 2690 | + */ |
|
| 2691 | + public function set_customer_address_confirmed( $value ) { |
|
| 2692 | + $this->set_address_confirmed( $value ); |
|
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | 2695 | /** |
| 2696 | - * Set the invoice sub total. |
|
| 2697 | - * |
|
| 2698 | - * @since 1.0.19 |
|
| 2699 | - * @param float $value sub total. |
|
| 2700 | - */ |
|
| 2701 | - public function set_subtotal( $value ) { |
|
| 2702 | - $this->set_prop( 'subtotal', $value ); |
|
| 2696 | + * Set the invoice sub total. |
|
| 2697 | + * |
|
| 2698 | + * @since 1.0.19 |
|
| 2699 | + * @param float $value sub total. |
|
| 2700 | + */ |
|
| 2701 | + public function set_subtotal( $value ) { |
|
| 2702 | + $this->set_prop( 'subtotal', $value ); |
|
| 2703 | 2703 | } |
| 2704 | 2704 | |
| 2705 | 2705 | /** |
| 2706 | - * Set the invoice discount amount. |
|
| 2707 | - * |
|
| 2708 | - * @since 1.0.19 |
|
| 2709 | - * @param float $value discount total. |
|
| 2710 | - */ |
|
| 2711 | - public function set_total_discount( $value ) { |
|
| 2712 | - $this->set_prop( 'total_discount', $value ); |
|
| 2706 | + * Set the invoice discount amount. |
|
| 2707 | + * |
|
| 2708 | + * @since 1.0.19 |
|
| 2709 | + * @param float $value discount total. |
|
| 2710 | + */ |
|
| 2711 | + public function set_total_discount( $value ) { |
|
| 2712 | + $this->set_prop( 'total_discount', $value ); |
|
| 2713 | 2713 | } |
| 2714 | 2714 | |
| 2715 | 2715 | /** |
| 2716 | - * Alias of self::set_total_discount(). |
|
| 2717 | - * |
|
| 2718 | - * @since 1.0.19 |
|
| 2719 | - * @param float $value discount total. |
|
| 2720 | - */ |
|
| 2721 | - public function set_discount( $value ) { |
|
| 2722 | - $this->set_total_discount( $value ); |
|
| 2716 | + * Alias of self::set_total_discount(). |
|
| 2717 | + * |
|
| 2718 | + * @since 1.0.19 |
|
| 2719 | + * @param float $value discount total. |
|
| 2720 | + */ |
|
| 2721 | + public function set_discount( $value ) { |
|
| 2722 | + $this->set_total_discount( $value ); |
|
| 2723 | 2723 | } |
| 2724 | 2724 | |
| 2725 | 2725 | /** |
| 2726 | - * Set the invoice tax amount. |
|
| 2727 | - * |
|
| 2728 | - * @since 1.0.19 |
|
| 2729 | - * @param float $value tax total. |
|
| 2730 | - */ |
|
| 2731 | - public function set_total_tax( $value ) { |
|
| 2732 | - $this->set_prop( 'total_tax', $value ); |
|
| 2726 | + * Set the invoice tax amount. |
|
| 2727 | + * |
|
| 2728 | + * @since 1.0.19 |
|
| 2729 | + * @param float $value tax total. |
|
| 2730 | + */ |
|
| 2731 | + public function set_total_tax( $value ) { |
|
| 2732 | + $this->set_prop( 'total_tax', $value ); |
|
| 2733 | 2733 | } |
| 2734 | 2734 | |
| 2735 | 2735 | /** |
| 2736 | - * Alias of self::set_total_tax(). |
|
| 2737 | - * |
|
| 2738 | - * @since 1.0.19 |
|
| 2739 | - * @param float $value tax total. |
|
| 2740 | - */ |
|
| 2741 | - public function set_tax_total( $value ) { |
|
| 2742 | - $this->set_total_tax( $value ); |
|
| 2736 | + * Alias of self::set_total_tax(). |
|
| 2737 | + * |
|
| 2738 | + * @since 1.0.19 |
|
| 2739 | + * @param float $value tax total. |
|
| 2740 | + */ |
|
| 2741 | + public function set_tax_total( $value ) { |
|
| 2742 | + $this->set_total_tax( $value ); |
|
| 2743 | 2743 | } |
| 2744 | 2744 | |
| 2745 | 2745 | /** |
| 2746 | - * Set the invoice fees amount. |
|
| 2747 | - * |
|
| 2748 | - * @since 1.0.19 |
|
| 2749 | - * @param float $value fees total. |
|
| 2750 | - */ |
|
| 2751 | - public function set_total_fees( $value ) { |
|
| 2752 | - $this->set_prop( 'total_fees', $value ); |
|
| 2746 | + * Set the invoice fees amount. |
|
| 2747 | + * |
|
| 2748 | + * @since 1.0.19 |
|
| 2749 | + * @param float $value fees total. |
|
| 2750 | + */ |
|
| 2751 | + public function set_total_fees( $value ) { |
|
| 2752 | + $this->set_prop( 'total_fees', $value ); |
|
| 2753 | 2753 | } |
| 2754 | 2754 | |
| 2755 | 2755 | /** |
| 2756 | - * Alias of self::set_total_fees(). |
|
| 2757 | - * |
|
| 2758 | - * @since 1.0.19 |
|
| 2759 | - * @param float $value fees total. |
|
| 2760 | - */ |
|
| 2761 | - public function set_fees_total( $value ) { |
|
| 2762 | - $this->set_total_fees( $value ); |
|
| 2756 | + * Alias of self::set_total_fees(). |
|
| 2757 | + * |
|
| 2758 | + * @since 1.0.19 |
|
| 2759 | + * @param float $value fees total. |
|
| 2760 | + */ |
|
| 2761 | + public function set_fees_total( $value ) { |
|
| 2762 | + $this->set_total_fees( $value ); |
|
| 2763 | 2763 | } |
| 2764 | 2764 | |
| 2765 | 2765 | /** |
| 2766 | - * Set the invoice fees. |
|
| 2767 | - * |
|
| 2768 | - * @since 1.0.19 |
|
| 2769 | - * @param array $value fees. |
|
| 2770 | - */ |
|
| 2771 | - public function set_fees( $value ) { |
|
| 2766 | + * Set the invoice fees. |
|
| 2767 | + * |
|
| 2768 | + * @since 1.0.19 |
|
| 2769 | + * @param array $value fees. |
|
| 2770 | + */ |
|
| 2771 | + public function set_fees( $value ) { |
|
| 2772 | 2772 | |
| 2773 | - if ( ! is_array( $value ) ) { |
|
| 2774 | - $value = array(); |
|
| 2775 | - } |
|
| 2773 | + if ( ! is_array( $value ) ) { |
|
| 2774 | + $value = array(); |
|
| 2775 | + } |
|
| 2776 | 2776 | |
| 2777 | - $this->set_prop( 'fees', $value ); |
|
| 2777 | + $this->set_prop( 'fees', $value ); |
|
| 2778 | 2778 | |
| 2779 | 2779 | } |
| 2780 | 2780 | |
| 2781 | 2781 | /** |
| 2782 | - * Set the invoice taxes. |
|
| 2783 | - * |
|
| 2784 | - * @since 1.0.19 |
|
| 2785 | - * @param array $value taxes. |
|
| 2786 | - */ |
|
| 2787 | - public function set_taxes( $value ) { |
|
| 2782 | + * Set the invoice taxes. |
|
| 2783 | + * |
|
| 2784 | + * @since 1.0.19 |
|
| 2785 | + * @param array $value taxes. |
|
| 2786 | + */ |
|
| 2787 | + public function set_taxes( $value ) { |
|
| 2788 | 2788 | |
| 2789 | - if ( ! is_array( $value ) ) { |
|
| 2790 | - $value = array(); |
|
| 2791 | - } |
|
| 2789 | + if ( ! is_array( $value ) ) { |
|
| 2790 | + $value = array(); |
|
| 2791 | + } |
|
| 2792 | 2792 | |
| 2793 | - $this->set_prop( 'taxes', $value ); |
|
| 2793 | + $this->set_prop( 'taxes', $value ); |
|
| 2794 | 2794 | |
| 2795 | 2795 | } |
| 2796 | 2796 | |
| 2797 | 2797 | /** |
| 2798 | - * Set the invoice discounts. |
|
| 2799 | - * |
|
| 2800 | - * @since 1.0.19 |
|
| 2801 | - * @param array $value discounts. |
|
| 2802 | - */ |
|
| 2803 | - public function set_discounts( $value ) { |
|
| 2798 | + * Set the invoice discounts. |
|
| 2799 | + * |
|
| 2800 | + * @since 1.0.19 |
|
| 2801 | + * @param array $value discounts. |
|
| 2802 | + */ |
|
| 2803 | + public function set_discounts( $value ) { |
|
| 2804 | 2804 | |
| 2805 | - if ( ! is_array( $value ) ) { |
|
| 2806 | - $value = array(); |
|
| 2807 | - } |
|
| 2805 | + if ( ! is_array( $value ) ) { |
|
| 2806 | + $value = array(); |
|
| 2807 | + } |
|
| 2808 | 2808 | |
| 2809 | - $this->set_prop( 'discounts', $value ); |
|
| 2809 | + $this->set_prop( 'discounts', $value ); |
|
| 2810 | 2810 | } |
| 2811 | 2811 | |
| 2812 | 2812 | /** |
| 2813 | - * Set the invoice items. |
|
| 2814 | - * |
|
| 2815 | - * @since 1.0.19 |
|
| 2816 | - * @param GetPaid_Form_Item[] $value items. |
|
| 2817 | - */ |
|
| 2818 | - public function set_items( $value ) { |
|
| 2813 | + * Set the invoice items. |
|
| 2814 | + * |
|
| 2815 | + * @since 1.0.19 |
|
| 2816 | + * @param GetPaid_Form_Item[] $value items. |
|
| 2817 | + */ |
|
| 2818 | + public function set_items( $value ) { |
|
| 2819 | 2819 | |
| 2820 | 2820 | // Remove existing items. |
| 2821 | 2821 | $this->set_prop( 'items', array() ); |
@@ -2832,95 +2832,95 @@ discard block |
||
| 2832 | 2832 | } |
| 2833 | 2833 | |
| 2834 | 2834 | /** |
| 2835 | - * Set the payment form. |
|
| 2836 | - * |
|
| 2837 | - * @since 1.0.19 |
|
| 2838 | - * @param int $value payment form. |
|
| 2839 | - */ |
|
| 2840 | - public function set_payment_form( $value ) { |
|
| 2841 | - $this->set_prop( 'payment_form', $value ); |
|
| 2835 | + * Set the payment form. |
|
| 2836 | + * |
|
| 2837 | + * @since 1.0.19 |
|
| 2838 | + * @param int $value payment form. |
|
| 2839 | + */ |
|
| 2840 | + public function set_payment_form( $value ) { |
|
| 2841 | + $this->set_prop( 'payment_form', $value ); |
|
| 2842 | 2842 | } |
| 2843 | 2843 | |
| 2844 | 2844 | /** |
| 2845 | - * Set the submission id. |
|
| 2846 | - * |
|
| 2847 | - * @since 1.0.19 |
|
| 2848 | - * @param string $value submission id. |
|
| 2849 | - */ |
|
| 2850 | - public function set_submission_id( $value ) { |
|
| 2851 | - $this->set_prop( 'submission_id', $value ); |
|
| 2845 | + * Set the submission id. |
|
| 2846 | + * |
|
| 2847 | + * @since 1.0.19 |
|
| 2848 | + * @param string $value submission id. |
|
| 2849 | + */ |
|
| 2850 | + public function set_submission_id( $value ) { |
|
| 2851 | + $this->set_prop( 'submission_id', $value ); |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | /** |
| 2855 | - * Set the discount code. |
|
| 2856 | - * |
|
| 2857 | - * @since 1.0.19 |
|
| 2858 | - * @param string $value discount code. |
|
| 2859 | - */ |
|
| 2860 | - public function set_discount_code( $value ) { |
|
| 2861 | - $this->set_prop( 'discount_code', $value ); |
|
| 2855 | + * Set the discount code. |
|
| 2856 | + * |
|
| 2857 | + * @since 1.0.19 |
|
| 2858 | + * @param string $value discount code. |
|
| 2859 | + */ |
|
| 2860 | + public function set_discount_code( $value ) { |
|
| 2861 | + $this->set_prop( 'discount_code', $value ); |
|
| 2862 | 2862 | } |
| 2863 | 2863 | |
| 2864 | 2864 | /** |
| 2865 | - * Set the gateway. |
|
| 2866 | - * |
|
| 2867 | - * @since 1.0.19 |
|
| 2868 | - * @param string $value gateway. |
|
| 2869 | - */ |
|
| 2870 | - public function set_gateway( $value ) { |
|
| 2871 | - $this->set_prop( 'gateway', $value ); |
|
| 2865 | + * Set the gateway. |
|
| 2866 | + * |
|
| 2867 | + * @since 1.0.19 |
|
| 2868 | + * @param string $value gateway. |
|
| 2869 | + */ |
|
| 2870 | + public function set_gateway( $value ) { |
|
| 2871 | + $this->set_prop( 'gateway', $value ); |
|
| 2872 | 2872 | } |
| 2873 | 2873 | |
| 2874 | 2874 | /** |
| 2875 | - * Set the transaction id. |
|
| 2876 | - * |
|
| 2877 | - * @since 1.0.19 |
|
| 2878 | - * @param string $value transaction id. |
|
| 2879 | - */ |
|
| 2880 | - public function set_transaction_id( $value ) { |
|
| 2881 | - if ( ! empty( $value ) ) { |
|
| 2882 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2883 | - } |
|
| 2875 | + * Set the transaction id. |
|
| 2876 | + * |
|
| 2877 | + * @since 1.0.19 |
|
| 2878 | + * @param string $value transaction id. |
|
| 2879 | + */ |
|
| 2880 | + public function set_transaction_id( $value ) { |
|
| 2881 | + if ( ! empty( $value ) ) { |
|
| 2882 | + $this->set_prop( 'transaction_id', $value ); |
|
| 2883 | + } |
|
| 2884 | 2884 | } |
| 2885 | 2885 | |
| 2886 | 2886 | /** |
| 2887 | - * Set the currency id. |
|
| 2888 | - * |
|
| 2889 | - * @since 1.0.19 |
|
| 2890 | - * @param string $value currency id. |
|
| 2891 | - */ |
|
| 2892 | - public function set_currency( $value ) { |
|
| 2893 | - $this->set_prop( 'currency', $value ); |
|
| 2887 | + * Set the currency id. |
|
| 2888 | + * |
|
| 2889 | + * @since 1.0.19 |
|
| 2890 | + * @param string $value currency id. |
|
| 2891 | + */ |
|
| 2892 | + public function set_currency( $value ) { |
|
| 2893 | + $this->set_prop( 'currency', $value ); |
|
| 2894 | 2894 | } |
| 2895 | 2895 | |
| 2896 | - /** |
|
| 2897 | - * Set whether to disable taxes. |
|
| 2898 | - * |
|
| 2899 | - * @since 1.0.19 |
|
| 2900 | - * @param bool $value value. |
|
| 2901 | - */ |
|
| 2902 | - public function set_disable_taxes( $value ) { |
|
| 2903 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2904 | - } |
|
| 2896 | + /** |
|
| 2897 | + * Set whether to disable taxes. |
|
| 2898 | + * |
|
| 2899 | + * @since 1.0.19 |
|
| 2900 | + * @param bool $value value. |
|
| 2901 | + */ |
|
| 2902 | + public function set_disable_taxes( $value ) { |
|
| 2903 | + $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2904 | + } |
|
| 2905 | 2905 | |
| 2906 | 2906 | /** |
| 2907 | - * Set the subscription id. |
|
| 2908 | - * |
|
| 2909 | - * @since 1.0.19 |
|
| 2910 | - * @param string $value subscription id. |
|
| 2911 | - */ |
|
| 2912 | - public function set_subscription_id( $value ) { |
|
| 2913 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2914 | - } |
|
| 2907 | + * Set the subscription id. |
|
| 2908 | + * |
|
| 2909 | + * @since 1.0.19 |
|
| 2910 | + * @param string $value subscription id. |
|
| 2911 | + */ |
|
| 2912 | + public function set_subscription_id( $value ) { |
|
| 2913 | + $this->set_prop( 'subscription_id', $value ); |
|
| 2914 | + } |
|
| 2915 | 2915 | |
| 2916 | - /** |
|
| 2917 | - * Set the remote subscription id. |
|
| 2918 | - * |
|
| 2919 | - * @since 1.0.19 |
|
| 2920 | - * @param string $value subscription id. |
|
| 2921 | - */ |
|
| 2922 | - public function set_remote_subscription_id( $value ) { |
|
| 2923 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 2916 | + /** |
|
| 2917 | + * Set the remote subscription id. |
|
| 2918 | + * |
|
| 2919 | + * @since 1.0.19 |
|
| 2920 | + * @param string $value subscription id. |
|
| 2921 | + */ |
|
| 2922 | + public function set_remote_subscription_id( $value ) { |
|
| 2923 | + $this->set_prop( 'remote_subscription_id', $value ); |
|
| 2924 | 2924 | } |
| 2925 | 2925 | |
| 2926 | 2926 | /* |
@@ -2959,24 +2959,24 @@ discard block |
||
| 2959 | 2959 | */ |
| 2960 | 2960 | public function is_taxable() { |
| 2961 | 2961 | return ! $this->get_disable_taxes(); |
| 2962 | - } |
|
| 2962 | + } |
|
| 2963 | 2963 | |
| 2964 | - /** |
|
| 2965 | - * @deprecated |
|
| 2966 | - */ |
|
| 2967 | - public function has_vat() { |
|
| 2964 | + /** |
|
| 2965 | + * @deprecated |
|
| 2966 | + */ |
|
| 2967 | + public function has_vat() { |
|
| 2968 | 2968 | return $this->is_taxable(); |
| 2969 | - } |
|
| 2969 | + } |
|
| 2970 | 2970 | |
| 2971 | - /** |
|
| 2972 | - * Checks to see if the invoice requires payment. |
|
| 2973 | - */ |
|
| 2974 | - public function is_free() { |
|
| 2971 | + /** |
|
| 2972 | + * Checks to see if the invoice requires payment. |
|
| 2973 | + */ |
|
| 2974 | + public function is_free() { |
|
| 2975 | 2975 | $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
| 2976 | 2976 | |
| 2977 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2978 | - $is_free = false; |
|
| 2979 | - } |
|
| 2977 | + if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2978 | + $is_free = false; |
|
| 2979 | + } |
|
| 2980 | 2980 | |
| 2981 | 2981 | return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
| 2982 | 2982 | } |
@@ -2987,46 +2987,46 @@ discard block |
||
| 2987 | 2987 | public function is_paid() { |
| 2988 | 2988 | $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
| 2989 | 2989 | return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
| 2990 | - } |
|
| 2990 | + } |
|
| 2991 | 2991 | |
| 2992 | - /** |
|
| 2992 | + /** |
|
| 2993 | 2993 | * Checks if the invoice needs payment. |
| 2994 | 2994 | */ |
| 2995 | - public function needs_payment() { |
|
| 2996 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2995 | + public function needs_payment() { |
|
| 2996 | + $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2997 | 2997 | return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
| 2998 | 2998 | } |
| 2999 | 2999 | |
| 3000 | - /** |
|
| 3000 | + /** |
|
| 3001 | 3001 | * Checks if the invoice is refunded. |
| 3002 | 3002 | */ |
| 3003 | - public function is_refunded() { |
|
| 3003 | + public function is_refunded() { |
|
| 3004 | 3004 | $is_refunded = $this->has_status( 'wpi-refunded' ); |
| 3005 | 3005 | return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
| 3006 | - } |
|
| 3006 | + } |
|
| 3007 | 3007 | |
| 3008 | - /** |
|
| 3008 | + /** |
|
| 3009 | 3009 | * Checks if the invoice is held. |
| 3010 | 3010 | */ |
| 3011 | - public function is_held() { |
|
| 3011 | + public function is_held() { |
|
| 3012 | 3012 | $is_held = $this->has_status( 'wpi-onhold' ); |
| 3013 | 3013 | return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
| 3014 | - } |
|
| 3014 | + } |
|
| 3015 | 3015 | |
| 3016 | - /** |
|
| 3016 | + /** |
|
| 3017 | 3017 | * Checks if the invoice is due. |
| 3018 | 3018 | */ |
| 3019 | - public function is_due() { |
|
| 3020 | - $due_date = $this->get_due_date(); |
|
| 3021 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3022 | - } |
|
| 3019 | + public function is_due() { |
|
| 3020 | + $due_date = $this->get_due_date(); |
|
| 3021 | + return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3022 | + } |
|
| 3023 | 3023 | |
| 3024 | - /** |
|
| 3024 | + /** |
|
| 3025 | 3025 | * Checks if the invoice is draft. |
| 3026 | 3026 | */ |
| 3027 | - public function is_draft() { |
|
| 3027 | + public function is_draft() { |
|
| 3028 | 3028 | return $this->has_status( 'draft, auto-draft' ); |
| 3029 | - } |
|
| 3029 | + } |
|
| 3030 | 3030 | |
| 3031 | 3031 | /** |
| 3032 | 3032 | * Checks if the invoice has a given status. |
@@ -3034,9 +3034,9 @@ discard block |
||
| 3034 | 3034 | public function has_status( $status ) { |
| 3035 | 3035 | $status = wpinv_parse_list( $status ); |
| 3036 | 3036 | return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
| 3037 | - } |
|
| 3037 | + } |
|
| 3038 | 3038 | |
| 3039 | - /** |
|
| 3039 | + /** |
|
| 3040 | 3040 | * Checks if the invoice is of a given type. |
| 3041 | 3041 | */ |
| 3042 | 3042 | public function is_type( $type ) { |
@@ -3059,25 +3059,25 @@ discard block |
||
| 3059 | 3059 | */ |
| 3060 | 3060 | public function has_free_trial() { |
| 3061 | 3061 | return $this->is_recurring() && 0 == $this->get_initial_total(); |
| 3062 | - } |
|
| 3062 | + } |
|
| 3063 | 3063 | |
| 3064 | - /** |
|
| 3064 | + /** |
|
| 3065 | 3065 | * @deprecated |
| 3066 | 3066 | */ |
| 3067 | 3067 | public function is_free_trial() { |
| 3068 | 3068 | $this->has_free_trial(); |
| 3069 | 3069 | } |
| 3070 | 3070 | |
| 3071 | - /** |
|
| 3071 | + /** |
|
| 3072 | 3072 | * Check if the initial payment if 0. |
| 3073 | 3073 | * |
| 3074 | 3074 | */ |
| 3075 | - public function is_initial_free() { |
|
| 3075 | + public function is_initial_free() { |
|
| 3076 | 3076 | $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
| 3077 | 3077 | return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
| 3078 | 3078 | } |
| 3079 | 3079 | |
| 3080 | - /** |
|
| 3080 | + /** |
|
| 3081 | 3081 | * Check if the recurring item has a free trial. |
| 3082 | 3082 | * |
| 3083 | 3083 | */ |
@@ -3090,21 +3090,21 @@ discard block |
||
| 3090 | 3090 | |
| 3091 | 3091 | $item = $this->get_recurring( true ); |
| 3092 | 3092 | return $item->has_free_trial(); |
| 3093 | - } |
|
| 3093 | + } |
|
| 3094 | 3094 | |
| 3095 | - /** |
|
| 3095 | + /** |
|
| 3096 | 3096 | * Check if the free trial is a result of a discount. |
| 3097 | 3097 | */ |
| 3098 | 3098 | public function is_free_trial_from_discount() { |
| 3099 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3100 | - } |
|
| 3099 | + return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3100 | + } |
|
| 3101 | 3101 | |
| 3102 | - /** |
|
| 3102 | + /** |
|
| 3103 | 3103 | * @deprecated |
| 3104 | 3104 | */ |
| 3105 | 3105 | public function discount_first_payment_only() { |
| 3106 | 3106 | |
| 3107 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
| 3107 | + $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
| 3108 | 3108 | if ( ! $discount->exists() || ! $this->is_recurring() ) { |
| 3109 | 3109 | return true; |
| 3110 | 3110 | } |
@@ -3129,28 +3129,28 @@ discard block |
||
| 3129 | 3129 | */ |
| 3130 | 3130 | public function add_item( $item ) { |
| 3131 | 3131 | |
| 3132 | - if ( is_array( $item ) ) { |
|
| 3133 | - $item = $this->process_array_item( $item ); |
|
| 3134 | - } |
|
| 3132 | + if ( is_array( $item ) ) { |
|
| 3133 | + $item = $this->process_array_item( $item ); |
|
| 3134 | + } |
|
| 3135 | 3135 | |
| 3136 | - if ( is_numeric( $item ) ) { |
|
| 3137 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3138 | - } |
|
| 3136 | + if ( is_numeric( $item ) ) { |
|
| 3137 | + $item = new GetPaid_Form_Item( $item ); |
|
| 3138 | + } |
|
| 3139 | 3139 | |
| 3140 | 3140 | // Make sure that it is available for purchase. |
| 3141 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3142 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3141 | + if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3142 | + return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3143 | 3143 | } |
| 3144 | 3144 | |
| 3145 | 3145 | // Do we have a recurring item? |
| 3146 | - if ( $item->is_recurring() ) { |
|
| 3146 | + if ( $item->is_recurring() ) { |
|
| 3147 | 3147 | |
| 3148 | - // An invoice can only contain one recurring item. |
|
| 3149 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3150 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3151 | - } |
|
| 3148 | + // An invoice can only contain one recurring item. |
|
| 3149 | + if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3150 | + return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3151 | + } |
|
| 3152 | 3152 | |
| 3153 | - $this->recurring_item = $item->get_id(); |
|
| 3153 | + $this->recurring_item = $item->get_id(); |
|
| 3154 | 3154 | } |
| 3155 | 3155 | |
| 3156 | 3156 | // Invoice id. |
@@ -3161,60 +3161,60 @@ discard block |
||
| 3161 | 3161 | $items[ (int) $item->get_id() ] = $item; |
| 3162 | 3162 | |
| 3163 | 3163 | $this->set_prop( 'items', $items ); |
| 3164 | - return true; |
|
| 3165 | - } |
|
| 3164 | + return true; |
|
| 3165 | + } |
|
| 3166 | 3166 | |
| 3167 | - /** |
|
| 3168 | - * Converts an array to an item. |
|
| 3169 | - * |
|
| 3170 | - * @since 1.0.19 |
|
| 3171 | - * @return GetPaid_Form_Item |
|
| 3172 | - */ |
|
| 3173 | - protected function process_array_item( $array ) { |
|
| 3167 | + /** |
|
| 3168 | + * Converts an array to an item. |
|
| 3169 | + * |
|
| 3170 | + * @since 1.0.19 |
|
| 3171 | + * @return GetPaid_Form_Item |
|
| 3172 | + */ |
|
| 3173 | + protected function process_array_item( $array ) { |
|
| 3174 | 3174 | |
| 3175 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3176 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3175 | + $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3176 | + $item = new GetPaid_Form_Item( $item_id ); |
|
| 3177 | 3177 | |
| 3178 | - // Set item data. |
|
| 3179 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3180 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3181 | - $method = "set_$key"; |
|
| 3182 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3183 | - } |
|
| 3184 | - } |
|
| 3178 | + // Set item data. |
|
| 3179 | + foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3180 | + if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3181 | + $method = "set_$key"; |
|
| 3182 | + $item->$method( $array[ "item_$key" ] ); |
|
| 3183 | + } |
|
| 3184 | + } |
|
| 3185 | 3185 | |
| 3186 | - if ( isset( $array['quantity'] ) ) { |
|
| 3187 | - $item->set_quantity( $array['quantity'] ); |
|
| 3188 | - } |
|
| 3186 | + if ( isset( $array['quantity'] ) ) { |
|
| 3187 | + $item->set_quantity( $array['quantity'] ); |
|
| 3188 | + } |
|
| 3189 | 3189 | |
| 3190 | - // Set item meta. |
|
| 3191 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3192 | - $item->set_item_meta( $array['meta'] ); |
|
| 3193 | - } |
|
| 3190 | + // Set item meta. |
|
| 3191 | + if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3192 | + $item->set_item_meta( $array['meta'] ); |
|
| 3193 | + } |
|
| 3194 | 3194 | |
| 3195 | - return $item; |
|
| 3195 | + return $item; |
|
| 3196 | 3196 | |
| 3197 | - } |
|
| 3197 | + } |
|
| 3198 | 3198 | |
| 3199 | 3199 | /** |
| 3200 | - * Retrieves a specific item. |
|
| 3201 | - * |
|
| 3202 | - * @since 1.0.19 |
|
| 3203 | - */ |
|
| 3204 | - public function get_item( $item_id ) { |
|
| 3205 | - $items = $this->get_items(); |
|
| 3206 | - $item_id = (int) $item_id; |
|
| 3207 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3200 | + * Retrieves a specific item. |
|
| 3201 | + * |
|
| 3202 | + * @since 1.0.19 |
|
| 3203 | + */ |
|
| 3204 | + public function get_item( $item_id ) { |
|
| 3205 | + $items = $this->get_items(); |
|
| 3206 | + $item_id = (int) $item_id; |
|
| 3207 | + return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3208 | 3208 | } |
| 3209 | 3209 | |
| 3210 | 3210 | /** |
| 3211 | - * Removes a specific item. |
|
| 3212 | - * |
|
| 3213 | - * @since 1.0.19 |
|
| 3214 | - */ |
|
| 3215 | - public function remove_item( $item_id ) { |
|
| 3216 | - $items = $this->get_items(); |
|
| 3217 | - $item_id = (int) $item_id; |
|
| 3211 | + * Removes a specific item. |
|
| 3212 | + * |
|
| 3213 | + * @since 1.0.19 |
|
| 3214 | + */ |
|
| 3215 | + public function remove_item( $item_id ) { |
|
| 3216 | + $items = $this->get_items(); |
|
| 3217 | + $item_id = (int) $item_id; |
|
| 3218 | 3218 | |
| 3219 | 3219 | if ( $item_id == $this->recurring_item ) { |
| 3220 | 3220 | $this->recurring_item = null; |
@@ -3227,35 +3227,35 @@ discard block |
||
| 3227 | 3227 | } |
| 3228 | 3228 | |
| 3229 | 3229 | /** |
| 3230 | - * Adds a fee to the invoice. |
|
| 3231 | - * |
|
| 3232 | - * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3233 | - * @since 1.0.19 |
|
| 3234 | - */ |
|
| 3230 | + * Adds a fee to the invoice. |
|
| 3231 | + * |
|
| 3232 | + * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
| 3233 | + * @since 1.0.19 |
|
| 3234 | + */ |
|
| 3235 | 3235 | public function add_fee( $fee ) { |
| 3236 | 3236 | |
| 3237 | - $fees = $this->get_fees(); |
|
| 3238 | - $fees[ $fee['name'] ] = $fee; |
|
| 3239 | - $this->set_prop( 'fees', $fees ); |
|
| 3237 | + $fees = $this->get_fees(); |
|
| 3238 | + $fees[ $fee['name'] ] = $fee; |
|
| 3239 | + $this->set_prop( 'fees', $fees ); |
|
| 3240 | 3240 | |
| 3241 | 3241 | } |
| 3242 | 3242 | |
| 3243 | 3243 | /** |
| 3244 | - * Retrieves a specific fee. |
|
| 3245 | - * |
|
| 3246 | - * @since 1.0.19 |
|
| 3247 | - */ |
|
| 3248 | - public function get_fee( $fee ) { |
|
| 3244 | + * Retrieves a specific fee. |
|
| 3245 | + * |
|
| 3246 | + * @since 1.0.19 |
|
| 3247 | + */ |
|
| 3248 | + public function get_fee( $fee ) { |
|
| 3249 | 3249 | $fees = $this->get_fees(); |
| 3250 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3250 | + return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3251 | 3251 | } |
| 3252 | 3252 | |
| 3253 | 3253 | /** |
| 3254 | - * Removes a specific fee. |
|
| 3255 | - * |
|
| 3256 | - * @since 1.0.19 |
|
| 3257 | - */ |
|
| 3258 | - public function remove_fee( $fee ) { |
|
| 3254 | + * Removes a specific fee. |
|
| 3255 | + * |
|
| 3256 | + * @since 1.0.19 |
|
| 3257 | + */ |
|
| 3258 | + public function remove_fee( $fee ) { |
|
| 3259 | 3259 | $fees = $this->get_fees(); |
| 3260 | 3260 | if ( isset( $fees[ $fee ] ) ) { |
| 3261 | 3261 | unset( $fees[ $fee ] ); |
@@ -3263,43 +3263,43 @@ discard block |
||
| 3263 | 3263 | } |
| 3264 | 3264 | } |
| 3265 | 3265 | |
| 3266 | - /** |
|
| 3267 | - * Adds a discount to the invoice. |
|
| 3268 | - * |
|
| 3269 | - * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3270 | - * @since 1.0.19 |
|
| 3271 | - */ |
|
| 3272 | - public function add_discount( $discount ) { |
|
| 3266 | + /** |
|
| 3267 | + * Adds a discount to the invoice. |
|
| 3268 | + * |
|
| 3269 | + * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
| 3270 | + * @since 1.0.19 |
|
| 3271 | + */ |
|
| 3272 | + public function add_discount( $discount ) { |
|
| 3273 | 3273 | |
| 3274 | - $discounts = $this->get_discounts(); |
|
| 3275 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3276 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3274 | + $discounts = $this->get_discounts(); |
|
| 3275 | + $discounts[ $discount['name'] ] = $discount; |
|
| 3276 | + $this->set_prop( 'discounts', $discounts ); |
|
| 3277 | 3277 | |
| 3278 | - } |
|
| 3278 | + } |
|
| 3279 | 3279 | |
| 3280 | 3280 | /** |
| 3281 | - * Retrieves a specific discount. |
|
| 3282 | - * |
|
| 3283 | - * @since 1.0.19 |
|
| 3284 | - * @return float |
|
| 3285 | - */ |
|
| 3286 | - public function get_discount( $discount = false ) { |
|
| 3281 | + * Retrieves a specific discount. |
|
| 3282 | + * |
|
| 3283 | + * @since 1.0.19 |
|
| 3284 | + * @return float |
|
| 3285 | + */ |
|
| 3286 | + public function get_discount( $discount = false ) { |
|
| 3287 | 3287 | |
| 3288 | - // Backwards compatibilty. |
|
| 3289 | - if ( empty( $discount ) ) { |
|
| 3290 | - return $this->get_total_discount(); |
|
| 3291 | - } |
|
| 3288 | + // Backwards compatibilty. |
|
| 3289 | + if ( empty( $discount ) ) { |
|
| 3290 | + return $this->get_total_discount(); |
|
| 3291 | + } |
|
| 3292 | 3292 | |
| 3293 | 3293 | $discounts = $this->get_discounts(); |
| 3294 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3294 | + return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3295 | 3295 | } |
| 3296 | 3296 | |
| 3297 | 3297 | /** |
| 3298 | - * Removes a specific discount. |
|
| 3299 | - * |
|
| 3300 | - * @since 1.0.19 |
|
| 3301 | - */ |
|
| 3302 | - public function remove_discount( $discount ) { |
|
| 3298 | + * Removes a specific discount. |
|
| 3299 | + * |
|
| 3300 | + * @since 1.0.19 |
|
| 3301 | + */ |
|
| 3302 | + public function remove_discount( $discount ) { |
|
| 3303 | 3303 | $discounts = $this->get_discounts(); |
| 3304 | 3304 | if ( isset( $discounts[ $discount ] ) ) { |
| 3305 | 3305 | unset( $discounts[ $discount ] ); |
@@ -3316,34 +3316,34 @@ discard block |
||
| 3316 | 3316 | if ( $this->is_taxable() ) { |
| 3317 | 3317 | |
| 3318 | 3318 | $taxes = $this->get_taxes(); |
| 3319 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3320 | - $this->set_prop( 'taxes', $tax ); |
|
| 3319 | + $taxes[ $tax['name'] ] = $tax; |
|
| 3320 | + $this->set_prop( 'taxes', $tax ); |
|
| 3321 | 3321 | |
| 3322 | 3322 | } |
| 3323 | 3323 | } |
| 3324 | 3324 | |
| 3325 | 3325 | /** |
| 3326 | - * Retrieves a specific tax. |
|
| 3327 | - * |
|
| 3328 | - * @since 1.0.19 |
|
| 3329 | - */ |
|
| 3330 | - public function get_tax( $tax = null ) { |
|
| 3326 | + * Retrieves a specific tax. |
|
| 3327 | + * |
|
| 3328 | + * @since 1.0.19 |
|
| 3329 | + */ |
|
| 3330 | + public function get_tax( $tax = null ) { |
|
| 3331 | 3331 | |
| 3332 | - // Backwards compatility. |
|
| 3333 | - if ( empty( $tax ) ) { |
|
| 3334 | - return $this->get_total_tax(); |
|
| 3335 | - } |
|
| 3332 | + // Backwards compatility. |
|
| 3333 | + if ( empty( $tax ) ) { |
|
| 3334 | + return $this->get_total_tax(); |
|
| 3335 | + } |
|
| 3336 | 3336 | |
| 3337 | 3337 | $taxes = $this->get_taxes(); |
| 3338 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3338 | + return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3339 | 3339 | } |
| 3340 | 3340 | |
| 3341 | 3341 | /** |
| 3342 | - * Removes a specific tax. |
|
| 3343 | - * |
|
| 3344 | - * @since 1.0.19 |
|
| 3345 | - */ |
|
| 3346 | - public function remove_tax( $tax ) { |
|
| 3342 | + * Removes a specific tax. |
|
| 3343 | + * |
|
| 3344 | + * @since 1.0.19 |
|
| 3345 | + */ |
|
| 3346 | + public function remove_tax( $tax ) { |
|
| 3347 | 3347 | $taxes = $this->get_taxes(); |
| 3348 | 3348 | if ( isset( $taxes[ $tax ] ) ) { |
| 3349 | 3349 | unset( $taxes[ $tax ] ); |
@@ -3352,134 +3352,134 @@ discard block |
||
| 3352 | 3352 | } |
| 3353 | 3353 | |
| 3354 | 3354 | /** |
| 3355 | - * Recalculates the invoice subtotal. |
|
| 3356 | - * |
|
| 3357 | - * @since 1.0.19 |
|
| 3358 | - * @return float The recalculated subtotal |
|
| 3359 | - */ |
|
| 3360 | - public function recalculate_subtotal() { |
|
| 3355 | + * Recalculates the invoice subtotal. |
|
| 3356 | + * |
|
| 3357 | + * @since 1.0.19 |
|
| 3358 | + * @return float The recalculated subtotal |
|
| 3359 | + */ |
|
| 3360 | + public function recalculate_subtotal() { |
|
| 3361 | 3361 | $items = $this->get_items(); |
| 3362 | - $subtotal = 0; |
|
| 3363 | - $recurring = 0; |
|
| 3362 | + $subtotal = 0; |
|
| 3363 | + $recurring = 0; |
|
| 3364 | 3364 | |
| 3365 | 3365 | foreach ( $items as $item ) { |
| 3366 | - $subtotal += $item->get_sub_total(); |
|
| 3367 | - $recurring += $item->get_recurring_sub_total(); |
|
| 3366 | + $subtotal += $item->get_sub_total(); |
|
| 3367 | + $recurring += $item->get_recurring_sub_total(); |
|
| 3368 | 3368 | } |
| 3369 | 3369 | |
| 3370 | - $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3371 | - $this->set_subtotal( $current ); |
|
| 3370 | + $current = $this->is_renewal() ? $recurring : $subtotal; |
|
| 3371 | + $this->set_subtotal( $current ); |
|
| 3372 | 3372 | |
| 3373 | - $this->totals['subtotal'] = array( |
|
| 3374 | - 'initial' => $subtotal, |
|
| 3375 | - 'recurring' => $recurring, |
|
| 3376 | - ); |
|
| 3373 | + $this->totals['subtotal'] = array( |
|
| 3374 | + 'initial' => $subtotal, |
|
| 3375 | + 'recurring' => $recurring, |
|
| 3376 | + ); |
|
| 3377 | 3377 | |
| 3378 | 3378 | return $current; |
| 3379 | 3379 | } |
| 3380 | 3380 | |
| 3381 | 3381 | /** |
| 3382 | - * Recalculates the invoice discount total. |
|
| 3383 | - * |
|
| 3384 | - * @since 1.0.19 |
|
| 3385 | - * @return float The recalculated discount |
|
| 3386 | - */ |
|
| 3387 | - public function recalculate_total_discount() { |
|
| 3382 | + * Recalculates the invoice discount total. |
|
| 3383 | + * |
|
| 3384 | + * @since 1.0.19 |
|
| 3385 | + * @return float The recalculated discount |
|
| 3386 | + */ |
|
| 3387 | + public function recalculate_total_discount() { |
|
| 3388 | 3388 | $discounts = $this->get_discounts(); |
| 3389 | - $discount = 0; |
|
| 3390 | - $recurring = 0; |
|
| 3389 | + $discount = 0; |
|
| 3390 | + $recurring = 0; |
|
| 3391 | 3391 | |
| 3392 | 3392 | foreach ( $discounts as $data ) { |
| 3393 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3394 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3395 | - } |
|
| 3393 | + $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3394 | + $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3395 | + } |
|
| 3396 | 3396 | |
| 3397 | - $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3397 | + $current = $this->is_renewal() ? $recurring : $discount; |
|
| 3398 | 3398 | |
| 3399 | - $this->set_total_discount( $current ); |
|
| 3399 | + $this->set_total_discount( $current ); |
|
| 3400 | 3400 | |
| 3401 | - $this->totals['discount'] = array( |
|
| 3402 | - 'initial' => $discount, |
|
| 3403 | - 'recurring' => $recurring, |
|
| 3404 | - ); |
|
| 3401 | + $this->totals['discount'] = array( |
|
| 3402 | + 'initial' => $discount, |
|
| 3403 | + 'recurring' => $recurring, |
|
| 3404 | + ); |
|
| 3405 | 3405 | |
| 3406 | - return $current; |
|
| 3406 | + return $current; |
|
| 3407 | 3407 | |
| 3408 | 3408 | } |
| 3409 | 3409 | |
| 3410 | 3410 | /** |
| 3411 | - * Recalculates the invoice tax total. |
|
| 3412 | - * |
|
| 3413 | - * @since 1.0.19 |
|
| 3414 | - * @return float The recalculated tax |
|
| 3415 | - */ |
|
| 3416 | - public function recalculate_total_tax() { |
|
| 3411 | + * Recalculates the invoice tax total. |
|
| 3412 | + * |
|
| 3413 | + * @since 1.0.19 |
|
| 3414 | + * @return float The recalculated tax |
|
| 3415 | + */ |
|
| 3416 | + public function recalculate_total_tax() { |
|
| 3417 | 3417 | $taxes = $this->get_taxes(); |
| 3418 | - $tax = 0; |
|
| 3419 | - $recurring = 0; |
|
| 3418 | + $tax = 0; |
|
| 3419 | + $recurring = 0; |
|
| 3420 | 3420 | |
| 3421 | 3421 | foreach ( $taxes as $data ) { |
| 3422 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
| 3423 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
| 3424 | - } |
|
| 3422 | + $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
| 3423 | + $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
| 3424 | + } |
|
| 3425 | 3425 | |
| 3426 | - $current = $this->is_renewal() ? $recurring : $tax; |
|
| 3427 | - $this->set_total_tax( $current ); |
|
| 3426 | + $current = $this->is_renewal() ? $recurring : $tax; |
|
| 3427 | + $this->set_total_tax( $current ); |
|
| 3428 | 3428 | |
| 3429 | - $this->totals['tax'] = array( |
|
| 3430 | - 'initial' => $tax, |
|
| 3431 | - 'recurring' => $recurring, |
|
| 3432 | - ); |
|
| 3429 | + $this->totals['tax'] = array( |
|
| 3430 | + 'initial' => $tax, |
|
| 3431 | + 'recurring' => $recurring, |
|
| 3432 | + ); |
|
| 3433 | 3433 | |
| 3434 | - return $current; |
|
| 3434 | + return $current; |
|
| 3435 | 3435 | |
| 3436 | 3436 | } |
| 3437 | 3437 | |
| 3438 | 3438 | /** |
| 3439 | - * Recalculates the invoice fees total. |
|
| 3440 | - * |
|
| 3441 | - * @since 1.0.19 |
|
| 3442 | - * @return float The recalculated fee |
|
| 3443 | - */ |
|
| 3444 | - public function recalculate_total_fees() { |
|
| 3445 | - $fees = $this->get_fees(); |
|
| 3446 | - $fee = 0; |
|
| 3447 | - $recurring = 0; |
|
| 3439 | + * Recalculates the invoice fees total. |
|
| 3440 | + * |
|
| 3441 | + * @since 1.0.19 |
|
| 3442 | + * @return float The recalculated fee |
|
| 3443 | + */ |
|
| 3444 | + public function recalculate_total_fees() { |
|
| 3445 | + $fees = $this->get_fees(); |
|
| 3446 | + $fee = 0; |
|
| 3447 | + $recurring = 0; |
|
| 3448 | 3448 | |
| 3449 | 3449 | foreach ( $fees as $data ) { |
| 3450 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3451 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3452 | - } |
|
| 3450 | + $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3451 | + $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3452 | + } |
|
| 3453 | 3453 | |
| 3454 | - $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3455 | - $this->set_total_fees( $current ); |
|
| 3454 | + $current = $this->is_renewal() ? $recurring : $fee; |
|
| 3455 | + $this->set_total_fees( $current ); |
|
| 3456 | 3456 | |
| 3457 | - $this->totals['fee'] = array( |
|
| 3458 | - 'initial' => $fee, |
|
| 3459 | - 'recurring' => $recurring, |
|
| 3460 | - ); |
|
| 3457 | + $this->totals['fee'] = array( |
|
| 3458 | + 'initial' => $fee, |
|
| 3459 | + 'recurring' => $recurring, |
|
| 3460 | + ); |
|
| 3461 | 3461 | |
| 3462 | 3462 | $this->set_total_fees( $fee ); |
| 3463 | 3463 | return $current; |
| 3464 | 3464 | } |
| 3465 | 3465 | |
| 3466 | 3466 | /** |
| 3467 | - * Recalculates the invoice total. |
|
| 3468 | - * |
|
| 3469 | - * @since 1.0.19 |
|
| 3467 | + * Recalculates the invoice total. |
|
| 3468 | + * |
|
| 3469 | + * @since 1.0.19 |
|
| 3470 | 3470 | * @return float The invoice total |
| 3471 | - */ |
|
| 3472 | - public function recalculate_total() { |
|
| 3471 | + */ |
|
| 3472 | + public function recalculate_total() { |
|
| 3473 | 3473 | $this->recalculate_subtotal(); |
| 3474 | 3474 | $this->recalculate_total_fees(); |
| 3475 | 3475 | $this->recalculate_total_discount(); |
| 3476 | 3476 | $this->recalculate_total_tax(); |
| 3477 | - return $this->get_total(); |
|
| 3478 | - } |
|
| 3477 | + return $this->get_total(); |
|
| 3478 | + } |
|
| 3479 | 3479 | |
| 3480 | - /** |
|
| 3481 | - * @deprecated |
|
| 3482 | - */ |
|
| 3480 | + /** |
|
| 3481 | + * @deprecated |
|
| 3482 | + */ |
|
| 3483 | 3483 | public function recalculate_totals( $temp = false ) { |
| 3484 | 3484 | $this->update_items( $temp ); |
| 3485 | 3485 | $this->save( true ); |
@@ -3497,7 +3497,7 @@ discard block |
||
| 3497 | 3497 | * Adds a note to an invoice. |
| 3498 | 3498 | * |
| 3499 | 3499 | * @param string $note The note being added. |
| 3500 | - * @return int|false The new note's ID on success, false on failure. |
|
| 3500 | + * @return int|false The new note's ID on success, false on failure. |
|
| 3501 | 3501 | * |
| 3502 | 3502 | */ |
| 3503 | 3503 | public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
@@ -3507,21 +3507,21 @@ discard block |
||
| 3507 | 3507 | return false; |
| 3508 | 3508 | } |
| 3509 | 3509 | |
| 3510 | - $author = 'System'; |
|
| 3511 | - $author_email = '[email protected]'; |
|
| 3510 | + $author = 'System'; |
|
| 3511 | + $author_email = '[email protected]'; |
|
| 3512 | 3512 | |
| 3513 | - // If this is an admin comment or it has been added by the user. |
|
| 3514 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3515 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3513 | + // If this is an admin comment or it has been added by the user. |
|
| 3514 | + if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3515 | + $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3516 | 3516 | $author = $user->display_name; |
| 3517 | 3517 | $author_email = $user->user_email; |
| 3518 | - } |
|
| 3518 | + } |
|
| 3519 | 3519 | |
| 3520 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3520 | + return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3521 | 3521 | |
| 3522 | - } |
|
| 3522 | + } |
|
| 3523 | 3523 | |
| 3524 | - /** |
|
| 3524 | + /** |
|
| 3525 | 3525 | * Generates a unique key for the invoice. |
| 3526 | 3526 | */ |
| 3527 | 3527 | public function generate_key( $string = '' ) { |
@@ -3541,113 +3541,113 @@ discard block |
||
| 3541 | 3541 | $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
| 3542 | 3542 | } |
| 3543 | 3543 | |
| 3544 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3545 | - |
|
| 3546 | - } |
|
| 3547 | - |
|
| 3548 | - /** |
|
| 3549 | - * Handle the status transition. |
|
| 3550 | - */ |
|
| 3551 | - protected function status_transition() { |
|
| 3552 | - $status_transition = $this->status_transition; |
|
| 3553 | - |
|
| 3554 | - // Reset status transition variable. |
|
| 3555 | - $this->status_transition = false; |
|
| 3556 | - |
|
| 3557 | - if ( $status_transition ) { |
|
| 3558 | - try { |
|
| 3544 | + return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3559 | 3545 | |
| 3560 | - // Fire a hook for the status change. |
|
| 3561 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3562 | - |
|
| 3563 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3564 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3565 | - |
|
| 3566 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3567 | - |
|
| 3568 | - /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3569 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3570 | - |
|
| 3571 | - // Fire another hook. |
|
| 3572 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3573 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3574 | - |
|
| 3575 | - // @deprecated this is deprecated and will be removed in the future. |
|
| 3576 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3577 | - |
|
| 3578 | - // Note the transition occurred. |
|
| 3579 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3580 | - |
|
| 3581 | - // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3582 | - if ( |
|
| 3583 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3584 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3585 | - ) { |
|
| 3586 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3587 | - } |
|
| 3588 | - |
|
| 3589 | - // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3590 | - if ( |
|
| 3591 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3592 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3593 | - ) { |
|
| 3594 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3595 | - } |
|
| 3596 | - } else { |
|
| 3597 | - /* translators: %s: new invoice status */ |
|
| 3598 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3599 | - |
|
| 3600 | - // Note the transition occurred. |
|
| 3601 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3546 | + } |
|
| 3602 | 3547 | |
| 3603 | - } |
|
| 3604 | - } catch ( Exception $e ) { |
|
| 3605 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3606 | - } |
|
| 3607 | - } |
|
| 3608 | - } |
|
| 3548 | + /** |
|
| 3549 | + * Handle the status transition. |
|
| 3550 | + */ |
|
| 3551 | + protected function status_transition() { |
|
| 3552 | + $status_transition = $this->status_transition; |
|
| 3553 | + |
|
| 3554 | + // Reset status transition variable. |
|
| 3555 | + $this->status_transition = false; |
|
| 3556 | + |
|
| 3557 | + if ( $status_transition ) { |
|
| 3558 | + try { |
|
| 3559 | + |
|
| 3560 | + // Fire a hook for the status change. |
|
| 3561 | + do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3562 | + |
|
| 3563 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3564 | + do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3565 | + |
|
| 3566 | + if ( ! empty( $status_transition['from'] ) ) { |
|
| 3567 | + |
|
| 3568 | + /* translators: 1: old invoice status 2: new invoice status */ |
|
| 3569 | + $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3570 | + |
|
| 3571 | + // Fire another hook. |
|
| 3572 | + do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3573 | + do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3574 | + |
|
| 3575 | + // @deprecated this is deprecated and will be removed in the future. |
|
| 3576 | + do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3577 | + |
|
| 3578 | + // Note the transition occurred. |
|
| 3579 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3580 | + |
|
| 3581 | + // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
| 3582 | + if ( |
|
| 3583 | + in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3584 | + && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3585 | + ) { |
|
| 3586 | + do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3587 | + } |
|
| 3588 | + |
|
| 3589 | + // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
|
| 3590 | + if ( |
|
| 3591 | + in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3592 | + && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3593 | + ) { |
|
| 3594 | + do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3595 | + } |
|
| 3596 | + } else { |
|
| 3597 | + /* translators: %s: new invoice status */ |
|
| 3598 | + $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3599 | + |
|
| 3600 | + // Note the transition occurred. |
|
| 3601 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3602 | + |
|
| 3603 | + } |
|
| 3604 | + } catch ( Exception $e ) { |
|
| 3605 | + $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3606 | + } |
|
| 3607 | + } |
|
| 3608 | + } |
|
| 3609 | 3609 | |
| 3610 | - /** |
|
| 3611 | - * Updates an invoice status. |
|
| 3612 | - */ |
|
| 3613 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3610 | + /** |
|
| 3611 | + * Updates an invoice status. |
|
| 3612 | + */ |
|
| 3613 | + public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3614 | 3614 | |
| 3615 | - // Fires before updating a status. |
|
| 3616 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3615 | + // Fires before updating a status. |
|
| 3616 | + do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3617 | 3617 | |
| 3618 | - // Update the status. |
|
| 3619 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3618 | + // Update the status. |
|
| 3619 | + $this->set_status( $new_status, $note, $manual ); |
|
| 3620 | 3620 | |
| 3621 | - // Save the order. |
|
| 3622 | - return $this->save(); |
|
| 3621 | + // Save the order. |
|
| 3622 | + return $this->save(); |
|
| 3623 | 3623 | |
| 3624 | - } |
|
| 3624 | + } |
|
| 3625 | 3625 | |
| 3626 | - /** |
|
| 3627 | - * @deprecated |
|
| 3628 | - */ |
|
| 3629 | - public function refresh_item_ids() { |
|
| 3626 | + /** |
|
| 3627 | + * @deprecated |
|
| 3628 | + */ |
|
| 3629 | + public function refresh_item_ids() { |
|
| 3630 | 3630 | $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
| 3631 | 3631 | update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
| 3632 | - } |
|
| 3632 | + } |
|
| 3633 | 3633 | |
| 3634 | - /** |
|
| 3635 | - * @deprecated |
|
| 3636 | - */ |
|
| 3637 | - public function update_items( $temp = false ) { |
|
| 3634 | + /** |
|
| 3635 | + * @deprecated |
|
| 3636 | + */ |
|
| 3637 | + public function update_items( $temp = false ) { |
|
| 3638 | 3638 | |
| 3639 | - $this->set_items( $this->get_items() ); |
|
| 3639 | + $this->set_items( $this->get_items() ); |
|
| 3640 | 3640 | |
| 3641 | - if ( ! $temp ) { |
|
| 3642 | - $this->save(); |
|
| 3643 | - } |
|
| 3641 | + if ( ! $temp ) { |
|
| 3642 | + $this->save(); |
|
| 3643 | + } |
|
| 3644 | 3644 | |
| 3645 | 3645 | return $this; |
| 3646 | - } |
|
| 3646 | + } |
|
| 3647 | 3647 | |
| 3648 | - /** |
|
| 3649 | - * @deprecated |
|
| 3650 | - */ |
|
| 3648 | + /** |
|
| 3649 | + * @deprecated |
|
| 3650 | + */ |
|
| 3651 | 3651 | public function validate_discount() { |
| 3652 | 3652 | |
| 3653 | 3653 | $discount_code = $this->get_discount_code(); |
@@ -3663,97 +3663,97 @@ discard block |
||
| 3663 | 3663 | |
| 3664 | 3664 | } |
| 3665 | 3665 | |
| 3666 | - /** |
|
| 3667 | - * Refunds an invoice. |
|
| 3668 | - */ |
|
| 3666 | + /** |
|
| 3667 | + * Refunds an invoice. |
|
| 3668 | + */ |
|
| 3669 | 3669 | public function refund() { |
| 3670 | - $this->set_status( 'wpi-refunded' ); |
|
| 3670 | + $this->set_status( 'wpi-refunded' ); |
|
| 3671 | 3671 | $this->save(); |
| 3672 | - } |
|
| 3672 | + } |
|
| 3673 | 3673 | |
| 3674 | - /** |
|
| 3675 | - * Marks an invoice as paid. |
|
| 3676 | - * |
|
| 3677 | - * @param string $transaction_id |
|
| 3678 | - */ |
|
| 3674 | + /** |
|
| 3675 | + * Marks an invoice as paid. |
|
| 3676 | + * |
|
| 3677 | + * @param string $transaction_id |
|
| 3678 | + */ |
|
| 3679 | 3679 | public function mark_paid( $transaction_id = null, $note = '' ) { |
| 3680 | 3680 | |
| 3681 | - // Set the transaction id. |
|
| 3682 | - if ( empty( $transaction_id ) ) { |
|
| 3683 | - $transaction_id = $this->generate_key('trans_'); |
|
| 3684 | - } |
|
| 3681 | + // Set the transaction id. |
|
| 3682 | + if ( empty( $transaction_id ) ) { |
|
| 3683 | + $transaction_id = $this->generate_key('trans_'); |
|
| 3684 | + } |
|
| 3685 | 3685 | |
| 3686 | - if ( ! $this->get_transaction_id() ) { |
|
| 3687 | - $this->set_transaction_id( $transaction_id ); |
|
| 3688 | - } |
|
| 3686 | + if ( ! $this->get_transaction_id() ) { |
|
| 3687 | + $this->set_transaction_id( $transaction_id ); |
|
| 3688 | + } |
|
| 3689 | 3689 | |
| 3690 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3691 | - return $this->save(); |
|
| 3692 | - } |
|
| 3690 | + if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3691 | + return $this->save(); |
|
| 3692 | + } |
|
| 3693 | 3693 | |
| 3694 | - // Set the completed date. |
|
| 3695 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3694 | + // Set the completed date. |
|
| 3695 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3696 | 3696 | |
| 3697 | - // Set the new status. |
|
| 3698 | - if ( $this->is_renewal() ) { |
|
| 3697 | + // Set the new status. |
|
| 3698 | + if ( $this->is_renewal() ) { |
|
| 3699 | 3699 | |
| 3700 | - $_note = sprintf( |
|
| 3701 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3702 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3703 | - ); |
|
| 3700 | + $_note = sprintf( |
|
| 3701 | + __( 'Renewed via %s', 'invoicing' ), |
|
| 3702 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3703 | + ); |
|
| 3704 | 3704 | |
| 3705 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3706 | - $_note = $note; |
|
| 3707 | - } |
|
| 3705 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3706 | + $_note = $note; |
|
| 3707 | + } |
|
| 3708 | 3708 | |
| 3709 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3709 | + $this->set_status( 'wpi-renewal', $_note ); |
|
| 3710 | 3710 | |
| 3711 | - } else { |
|
| 3711 | + } else { |
|
| 3712 | 3712 | |
| 3713 | - $_note = sprintf( |
|
| 3714 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3715 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3716 | - ); |
|
| 3713 | + $_note = sprintf( |
|
| 3714 | + __( 'Paid via %s', 'invoicing' ), |
|
| 3715 | + $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3716 | + ); |
|
| 3717 | 3717 | |
| 3718 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3719 | - $_note = $note; |
|
| 3720 | - } |
|
| 3718 | + if ( 'none' == $this->get_gateway() ) { |
|
| 3719 | + $_note = $note; |
|
| 3720 | + } |
|
| 3721 | 3721 | |
| 3722 | - $this->set_status( 'publish',$_note ); |
|
| 3722 | + $this->set_status( 'publish',$_note ); |
|
| 3723 | 3723 | |
| 3724 | - } |
|
| 3724 | + } |
|
| 3725 | 3725 | |
| 3726 | - // Set checkout mode. |
|
| 3727 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3728 | - $this->set_mode( $mode ); |
|
| 3726 | + // Set checkout mode. |
|
| 3727 | + $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3728 | + $this->set_mode( $mode ); |
|
| 3729 | 3729 | |
| 3730 | - // Save the invoice. |
|
| 3730 | + // Save the invoice. |
|
| 3731 | 3731 | $this->save(); |
| 3732 | - } |
|
| 3733 | - |
|
| 3734 | - |
|
| 3735 | - /** |
|
| 3736 | - * Save data to the database. |
|
| 3737 | - * |
|
| 3738 | - * @since 1.0.19 |
|
| 3739 | - * @return int invoice ID |
|
| 3740 | - */ |
|
| 3741 | - public function save() { |
|
| 3742 | - $this->maybe_set_date_paid(); |
|
| 3743 | - $this->maybe_set_key(); |
|
| 3744 | - parent::save(); |
|
| 3745 | - $this->clear_cache(); |
|
| 3746 | - $this->status_transition(); |
|
| 3747 | - return $this->get_id(); |
|
| 3748 | - } |
|
| 3749 | - |
|
| 3750 | - /** |
|
| 3732 | + } |
|
| 3733 | + |
|
| 3734 | + |
|
| 3735 | + /** |
|
| 3736 | + * Save data to the database. |
|
| 3737 | + * |
|
| 3738 | + * @since 1.0.19 |
|
| 3739 | + * @return int invoice ID |
|
| 3740 | + */ |
|
| 3741 | + public function save() { |
|
| 3742 | + $this->maybe_set_date_paid(); |
|
| 3743 | + $this->maybe_set_key(); |
|
| 3744 | + parent::save(); |
|
| 3745 | + $this->clear_cache(); |
|
| 3746 | + $this->status_transition(); |
|
| 3747 | + return $this->get_id(); |
|
| 3748 | + } |
|
| 3749 | + |
|
| 3750 | + /** |
|
| 3751 | 3751 | * Clears the subscription's cache. |
| 3752 | 3752 | */ |
| 3753 | 3753 | public function clear_cache() { |
| 3754 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3755 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3756 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3757 | - } |
|
| 3754 | + wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3755 | + wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3756 | + wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3757 | + } |
|
| 3758 | 3758 | |
| 3759 | 3759 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Invoicing |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Invoice class. |
@@ -135,40 +135,40 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
| 137 | 137 | */ |
| 138 | - public function __construct( $invoice = 0 ) { |
|
| 138 | + public function __construct($invoice = 0) { |
|
| 139 | 139 | |
| 140 | - parent::__construct( $invoice ); |
|
| 140 | + parent::__construct($invoice); |
|
| 141 | 141 | |
| 142 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
| 143 | - $this->set_id( (int) $invoice ); |
|
| 144 | - } elseif ( $invoice instanceof self ) { |
|
| 145 | - $this->set_id( $invoice->get_id() ); |
|
| 146 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
| 147 | - $this->set_id( $invoice->ID ); |
|
| 148 | - } elseif ( is_array( $invoice ) ) { |
|
| 149 | - $this->set_props( $invoice ); |
|
| 142 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) { |
|
| 143 | + $this->set_id((int) $invoice); |
|
| 144 | + } elseif ($invoice instanceof self) { |
|
| 145 | + $this->set_id($invoice->get_id()); |
|
| 146 | + } elseif (!empty($invoice->ID)) { |
|
| 147 | + $this->set_id($invoice->ID); |
|
| 148 | + } elseif (is_array($invoice)) { |
|
| 149 | + $this->set_props($invoice); |
|
| 150 | 150 | |
| 151 | - if ( isset( $invoice['ID'] ) ) { |
|
| 152 | - $this->set_id( $invoice['ID'] ); |
|
| 151 | + if (isset($invoice['ID'])) { |
|
| 152 | + $this->set_id($invoice['ID']); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
| 156 | - $this->set_id( $invoice_id ); |
|
| 157 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
| 158 | - $this->set_id( $invoice_id ); |
|
| 159 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
| 160 | - $this->set_id( $invoice_id ); |
|
| 161 | - }else { |
|
| 162 | - $this->set_object_read( true ); |
|
| 155 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
| 156 | + $this->set_id($invoice_id); |
|
| 157 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
| 158 | + $this->set_id($invoice_id); |
|
| 159 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
| 160 | + $this->set_id($invoice_id); |
|
| 161 | + } else { |
|
| 162 | + $this->set_object_read(true); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Load the datastore. |
| 166 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
| 166 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
| 167 | 167 | |
| 168 | - if ( $this->get_id() > 0 ) { |
|
| 169 | - $this->post = get_post( $this->get_id() ); |
|
| 168 | + if ($this->get_id() > 0) { |
|
| 169 | + $this->post = get_post($this->get_id()); |
|
| 170 | 170 | $this->ID = $this->get_id(); |
| 171 | - $this->data_store->read( $this ); |
|
| 171 | + $this->data_store->read($this); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | } |
@@ -183,38 +183,38 @@ discard block |
||
| 183 | 183 | * @since 1.0.15 |
| 184 | 184 | * @return int |
| 185 | 185 | */ |
| 186 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
| 186 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
| 187 | 187 | global $wpdb; |
| 188 | 188 | |
| 189 | 189 | // Trim the value. |
| 190 | - $value = trim( $value ); |
|
| 190 | + $value = trim($value); |
|
| 191 | 191 | |
| 192 | - if ( empty( $value ) ) { |
|
| 192 | + if (empty($value)) { |
|
| 193 | 193 | return 0; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Valid fields. |
| 197 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
| 197 | + $fields = array('key', 'number', 'transaction_id'); |
|
| 198 | 198 | |
| 199 | 199 | // Ensure a field has been passed. |
| 200 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
| 200 | + if (empty($field) || !in_array($field, $fields)) { |
|
| 201 | 201 | return 0; |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Maybe retrieve from the cache. |
| 205 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 206 | - if ( false !== $invoice_id ) { |
|
| 205 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 206 | + if (false !== $invoice_id) { |
|
| 207 | 207 | return $invoice_id; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // Fetch from the db. |
| 211 | 211 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 212 | 212 | $invoice_id = (int) $wpdb->get_var( |
| 213 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
| 213 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | 216 | // Update the cache with our data |
| 217 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
| 217 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
| 218 | 218 | |
| 219 | 219 | return $invoice_id; |
| 220 | 220 | } |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | /** |
| 223 | 223 | * Checks if an invoice key is set. |
| 224 | 224 | */ |
| 225 | - public function _isset( $key ) { |
|
| 226 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
| 225 | + public function _isset($key) { |
|
| 226 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /* |
@@ -248,8 +248,8 @@ discard block |
||
| 248 | 248 | * @param string $context View or edit context. |
| 249 | 249 | * @return int |
| 250 | 250 | */ |
| 251 | - public function get_parent_id( $context = 'view' ) { |
|
| 252 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
| 251 | + public function get_parent_id($context = 'view') { |
|
| 252 | + return (int) $this->get_prop('parent_id', $context); |
|
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | /** |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @return WPInv_Invoice |
| 260 | 260 | */ |
| 261 | 261 | public function get_parent_payment() { |
| 262 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
| 262 | + return new WPInv_Invoice($this->get_parent_id()); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -279,8 +279,8 @@ discard block |
||
| 279 | 279 | * @param string $context View or edit context. |
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | - public function get_status( $context = 'view' ) { |
|
| 283 | - return $this->get_prop( 'status', $context ); |
|
| 282 | + public function get_status($context = 'view') { |
|
| 283 | + return $this->get_prop('status', $context); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @return array |
| 291 | 291 | */ |
| 292 | 292 | public function get_all_statuses() { |
| 293 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
| 293 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | public function get_status_nicename() { |
| 303 | 303 | $statuses = $this->get_all_statuses(); |
| 304 | 304 | |
| 305 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
| 305 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
| 306 | 306 | |
| 307 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
| 307 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -315,8 +315,8 @@ discard block |
||
| 315 | 315 | */ |
| 316 | 316 | public function get_status_label_html() { |
| 317 | 317 | |
| 318 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
| 319 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 318 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
| 319 | + $status = sanitize_html_class($this->get_status()); |
|
| 320 | 320 | |
| 321 | 321 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
| 322 | 322 | } |
@@ -328,23 +328,23 @@ discard block |
||
| 328 | 328 | * @param string $context View or edit context. |
| 329 | 329 | * @return string |
| 330 | 330 | */ |
| 331 | - public function get_version( $context = 'view' ) { |
|
| 332 | - return $this->get_prop( 'version', $context ); |
|
| 331 | + public function get_version($context = 'view') { |
|
| 332 | + return $this->get_prop('version', $context); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * @deprecated |
| 337 | 337 | */ |
| 338 | - public function get_invoice_date( $format = true ) { |
|
| 339 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
| 340 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 341 | - $formatted = getpaid_format_date( $date ); |
|
| 338 | + public function get_invoice_date($format = true) { |
|
| 339 | + $date = getpaid_format_date($this->get_date_completed()); |
|
| 340 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
| 341 | + $formatted = getpaid_format_date($date); |
|
| 342 | 342 | |
| 343 | - if ( $format ) { |
|
| 343 | + if ($format) { |
|
| 344 | 344 | return $formatted; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | - return empty( $formatted ) ? '' : $date; |
|
| 347 | + return empty($formatted) ? '' : $date; |
|
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
@@ -355,8 +355,8 @@ discard block |
||
| 355 | 355 | * @param string $context View or edit context. |
| 356 | 356 | * @return string |
| 357 | 357 | */ |
| 358 | - public function get_date_created( $context = 'view' ) { |
|
| 359 | - return $this->get_prop( 'date_created', $context ); |
|
| 358 | + public function get_date_created($context = 'view') { |
|
| 359 | + return $this->get_prop('date_created', $context); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -366,8 +366,8 @@ discard block |
||
| 366 | 366 | * @param string $context View or edit context. |
| 367 | 367 | * @return string |
| 368 | 368 | */ |
| 369 | - public function get_created_date( $context = 'view' ) { |
|
| 370 | - return $this->get_date_created( $context ); |
|
| 369 | + public function get_created_date($context = 'view') { |
|
| 370 | + return $this->get_date_created($context); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | /** |
@@ -377,11 +377,11 @@ discard block |
||
| 377 | 377 | * @param string $context View or edit context. |
| 378 | 378 | * @return string |
| 379 | 379 | */ |
| 380 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 381 | - $date = $this->get_date_created( $context ); |
|
| 380 | + public function get_date_created_gmt($context = 'view') { |
|
| 381 | + $date = $this->get_date_created($context); |
|
| 382 | 382 | |
| 383 | - if ( $date ) { |
|
| 384 | - $date = get_gmt_from_date( $date ); |
|
| 383 | + if ($date) { |
|
| 384 | + $date = get_gmt_from_date($date); |
|
| 385 | 385 | } |
| 386 | 386 | return $date; |
| 387 | 387 | } |
@@ -393,8 +393,8 @@ discard block |
||
| 393 | 393 | * @param string $context View or edit context. |
| 394 | 394 | * @return string |
| 395 | 395 | */ |
| 396 | - public function get_date_modified( $context = 'view' ) { |
|
| 397 | - return $this->get_prop( 'date_modified', $context ); |
|
| 396 | + public function get_date_modified($context = 'view') { |
|
| 397 | + return $this->get_prop('date_modified', $context); |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | * @param string $context View or edit context. |
| 405 | 405 | * @return string |
| 406 | 406 | */ |
| 407 | - public function get_modified_date( $context = 'view' ) { |
|
| 408 | - return $this->get_date_modified( $context ); |
|
| 407 | + public function get_modified_date($context = 'view') { |
|
| 408 | + return $this->get_date_modified($context); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -415,11 +415,11 @@ discard block |
||
| 415 | 415 | * @param string $context View or edit context. |
| 416 | 416 | * @return string |
| 417 | 417 | */ |
| 418 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
| 419 | - $date = $this->get_date_modified( $context ); |
|
| 418 | + public function get_date_modified_gmt($context = 'view') { |
|
| 419 | + $date = $this->get_date_modified($context); |
|
| 420 | 420 | |
| 421 | - if ( $date ) { |
|
| 422 | - $date = get_gmt_from_date( $date ); |
|
| 421 | + if ($date) { |
|
| 422 | + $date = get_gmt_from_date($date); |
|
| 423 | 423 | } |
| 424 | 424 | return $date; |
| 425 | 425 | } |
@@ -431,8 +431,8 @@ discard block |
||
| 431 | 431 | * @param string $context View or edit context. |
| 432 | 432 | * @return string |
| 433 | 433 | */ |
| 434 | - public function get_due_date( $context = 'view' ) { |
|
| 435 | - return $this->get_prop( 'due_date', $context ); |
|
| 434 | + public function get_due_date($context = 'view') { |
|
| 435 | + return $this->get_prop('due_date', $context); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -442,8 +442,8 @@ discard block |
||
| 442 | 442 | * @param string $context View or edit context. |
| 443 | 443 | * @return string |
| 444 | 444 | */ |
| 445 | - public function get_date_due( $context = 'view' ) { |
|
| 446 | - return $this->get_due_date( $context ); |
|
| 445 | + public function get_date_due($context = 'view') { |
|
| 446 | + return $this->get_due_date($context); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
@@ -453,11 +453,11 @@ discard block |
||
| 453 | 453 | * @param string $context View or edit context. |
| 454 | 454 | * @return string |
| 455 | 455 | */ |
| 456 | - public function get_due_date_gmt( $context = 'view' ) { |
|
| 457 | - $date = $this->get_due_date( $context ); |
|
| 456 | + public function get_due_date_gmt($context = 'view') { |
|
| 457 | + $date = $this->get_due_date($context); |
|
| 458 | 458 | |
| 459 | - if ( $date ) { |
|
| 460 | - $date = get_gmt_from_date( $date ); |
|
| 459 | + if ($date) { |
|
| 460 | + $date = get_gmt_from_date($date); |
|
| 461 | 461 | } |
| 462 | 462 | return $date; |
| 463 | 463 | } |
@@ -469,8 +469,8 @@ discard block |
||
| 469 | 469 | * @param string $context View or edit context. |
| 470 | 470 | * @return string |
| 471 | 471 | */ |
| 472 | - public function get_gmt_date_due( $context = 'view' ) { |
|
| 473 | - return $this->get_due_date_gmt( $context ); |
|
| 472 | + public function get_gmt_date_due($context = 'view') { |
|
| 473 | + return $this->get_due_date_gmt($context); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | * @param string $context View or edit context. |
| 481 | 481 | * @return string |
| 482 | 482 | */ |
| 483 | - public function get_completed_date( $context = 'view' ) { |
|
| 484 | - return $this->get_prop( 'completed_date', $context ); |
|
| 483 | + public function get_completed_date($context = 'view') { |
|
| 484 | + return $this->get_prop('completed_date', $context); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -491,8 +491,8 @@ discard block |
||
| 491 | 491 | * @param string $context View or edit context. |
| 492 | 492 | * @return string |
| 493 | 493 | */ |
| 494 | - public function get_date_completed( $context = 'view' ) { |
|
| 495 | - return $this->get_completed_date( $context ); |
|
| 494 | + public function get_date_completed($context = 'view') { |
|
| 495 | + return $this->get_completed_date($context); |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | /** |
@@ -502,11 +502,11 @@ discard block |
||
| 502 | 502 | * @param string $context View or edit context. |
| 503 | 503 | * @return string |
| 504 | 504 | */ |
| 505 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
| 506 | - $date = $this->get_completed_date( $context ); |
|
| 505 | + public function get_completed_date_gmt($context = 'view') { |
|
| 506 | + $date = $this->get_completed_date($context); |
|
| 507 | 507 | |
| 508 | - if ( $date ) { |
|
| 509 | - $date = get_gmt_from_date( $date ); |
|
| 508 | + if ($date) { |
|
| 509 | + $date = get_gmt_from_date($date); |
|
| 510 | 510 | } |
| 511 | 511 | return $date; |
| 512 | 512 | } |
@@ -518,8 +518,8 @@ discard block |
||
| 518 | 518 | * @param string $context View or edit context. |
| 519 | 519 | * @return string |
| 520 | 520 | */ |
| 521 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
| 522 | - return $this->get_completed_date_gmt( $context ); |
|
| 521 | + public function get_gmt_completed_date($context = 'view') { |
|
| 522 | + return $this->get_completed_date_gmt($context); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | /** |
@@ -529,12 +529,12 @@ discard block |
||
| 529 | 529 | * @param string $context View or edit context. |
| 530 | 530 | * @return string |
| 531 | 531 | */ |
| 532 | - public function get_number( $context = 'view' ) { |
|
| 533 | - $number = $this->get_prop( 'number', $context ); |
|
| 532 | + public function get_number($context = 'view') { |
|
| 533 | + $number = $this->get_prop('number', $context); |
|
| 534 | 534 | |
| 535 | - if ( empty( $number ) ) { |
|
| 535 | + if (empty($number)) { |
|
| 536 | 536 | $number = $this->generate_number(); |
| 537 | - $this->set_number( $this->generate_number() ); |
|
| 537 | + $this->set_number($this->generate_number()); |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | return $number; |
@@ -548,8 +548,8 @@ discard block |
||
| 548 | 548 | public function maybe_set_number() { |
| 549 | 549 | $number = $this->get_number(); |
| 550 | 550 | |
| 551 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
| 552 | - $this->set_number( $this->generate_number() ); |
|
| 551 | + if (empty($number) || $this->get_id() == $number) { |
|
| 552 | + $this->set_number($this->generate_number()); |
|
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | } |
@@ -561,8 +561,8 @@ discard block |
||
| 561 | 561 | * @param string $context View or edit context. |
| 562 | 562 | * @return string |
| 563 | 563 | */ |
| 564 | - public function get_key( $context = 'view' ) { |
|
| 565 | - return $this->get_prop( 'key', $context ); |
|
| 564 | + public function get_key($context = 'view') { |
|
| 565 | + return $this->get_prop('key', $context); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -573,9 +573,9 @@ discard block |
||
| 573 | 573 | public function maybe_set_key() { |
| 574 | 574 | $key = $this->get_key(); |
| 575 | 575 | |
| 576 | - if ( empty( $key ) ) { |
|
| 577 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
| 578 | - $this->set_key( $key ); |
|
| 576 | + if (empty($key)) { |
|
| 577 | + $key = $this->generate_key($this->get_type() . '_'); |
|
| 578 | + $this->set_key($key); |
|
| 579 | 579 | } |
| 580 | 580 | |
| 581 | 581 | } |
@@ -587,8 +587,8 @@ discard block |
||
| 587 | 587 | * @param string $context View or edit context. |
| 588 | 588 | * @return string |
| 589 | 589 | */ |
| 590 | - public function get_type( $context = 'view' ) { |
|
| 591 | - return $this->get_prop( 'type', $context ); |
|
| 590 | + public function get_type($context = 'view') { |
|
| 591 | + return $this->get_prop('type', $context); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | * @return string |
| 599 | 599 | */ |
| 600 | 600 | public function get_invoice_quote_type() { |
| 601 | - return getpaid_get_post_type_label( $this->get_post_type(), false ); |
|
| 601 | + return getpaid_get_post_type_label($this->get_post_type(), false); |
|
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /** |
@@ -608,8 +608,8 @@ discard block |
||
| 608 | 608 | * @param string $context View or edit context. |
| 609 | 609 | * @return string |
| 610 | 610 | */ |
| 611 | - public function get_post_type( $context = 'view' ) { |
|
| 612 | - return $this->get_prop( 'post_type', $context ); |
|
| 611 | + public function get_post_type($context = 'view') { |
|
| 612 | + return $this->get_prop('post_type', $context); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -619,8 +619,8 @@ discard block |
||
| 619 | 619 | * @param string $context View or edit context. |
| 620 | 620 | * @return string |
| 621 | 621 | */ |
| 622 | - public function get_mode( $context = 'view' ) { |
|
| 623 | - return $this->get_prop( 'mode', $context ); |
|
| 622 | + public function get_mode($context = 'view') { |
|
| 623 | + return $this->get_prop('mode', $context); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | /** |
@@ -630,13 +630,13 @@ discard block |
||
| 630 | 630 | * @param string $context View or edit context. |
| 631 | 631 | * @return string |
| 632 | 632 | */ |
| 633 | - public function get_path( $context = 'view' ) { |
|
| 634 | - $path = $this->get_prop( 'path', $context ); |
|
| 633 | + public function get_path($context = 'view') { |
|
| 634 | + $path = $this->get_prop('path', $context); |
|
| 635 | 635 | $prefix = $this->get_type(); |
| 636 | 636 | |
| 637 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
| 638 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
| 639 | - $this->set_path( $path ); |
|
| 637 | + if (0 !== strpos($path, $prefix)) { |
|
| 638 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
| 639 | + $this->set_path($path); |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | return $path; |
@@ -649,8 +649,8 @@ discard block |
||
| 649 | 649 | * @param string $context View or edit context. |
| 650 | 650 | * @return string |
| 651 | 651 | */ |
| 652 | - public function get_name( $context = 'view' ) { |
|
| 653 | - return $this->get_prop( 'title', $context ); |
|
| 652 | + public function get_name($context = 'view') { |
|
| 653 | + return $this->get_prop('title', $context); |
|
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | /** |
@@ -660,8 +660,8 @@ discard block |
||
| 660 | 660 | * @param string $context View or edit context. |
| 661 | 661 | * @return string |
| 662 | 662 | */ |
| 663 | - public function get_title( $context = 'view' ) { |
|
| 664 | - return $this->get_name( $context ); |
|
| 663 | + public function get_title($context = 'view') { |
|
| 664 | + return $this->get_name($context); |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
@@ -671,8 +671,8 @@ discard block |
||
| 671 | 671 | * @param string $context View or edit context. |
| 672 | 672 | * @return string |
| 673 | 673 | */ |
| 674 | - public function get_description( $context = 'view' ) { |
|
| 675 | - return $this->get_prop( 'description', $context ); |
|
| 674 | + public function get_description($context = 'view') { |
|
| 675 | + return $this->get_prop('description', $context); |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -682,8 +682,8 @@ discard block |
||
| 682 | 682 | * @param string $context View or edit context. |
| 683 | 683 | * @return string |
| 684 | 684 | */ |
| 685 | - public function get_excerpt( $context = 'view' ) { |
|
| 686 | - return $this->get_description( $context ); |
|
| 685 | + public function get_excerpt($context = 'view') { |
|
| 686 | + return $this->get_description($context); |
|
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | /** |
@@ -693,8 +693,8 @@ discard block |
||
| 693 | 693 | * @param string $context View or edit context. |
| 694 | 694 | * @return string |
| 695 | 695 | */ |
| 696 | - public function get_summary( $context = 'view' ) { |
|
| 697 | - return $this->get_description( $context ); |
|
| 696 | + public function get_summary($context = 'view') { |
|
| 697 | + return $this->get_description($context); |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | /** |
@@ -704,25 +704,25 @@ discard block |
||
| 704 | 704 | * @param string $context View or edit context. |
| 705 | 705 | * @return array |
| 706 | 706 | */ |
| 707 | - public function get_user_info( $context = 'view' ) { |
|
| 707 | + public function get_user_info($context = 'view') { |
|
| 708 | 708 | |
| 709 | 709 | $user_info = array( |
| 710 | - 'user_id' => $this->get_user_id( $context ), |
|
| 711 | - 'email' => $this->get_email( $context ), |
|
| 712 | - 'first_name' => $this->get_first_name( $context ), |
|
| 713 | - 'last_name' => $this->get_last_name( $context ), |
|
| 714 | - 'address' => $this->get_address( $context ), |
|
| 715 | - 'phone' => $this->get_phone( $context ), |
|
| 716 | - 'city' => $this->get_city( $context ), |
|
| 717 | - 'country' => $this->get_country( $context ), |
|
| 718 | - 'state' => $this->get_state( $context ), |
|
| 719 | - 'zip' => $this->get_zip( $context ), |
|
| 720 | - 'company' => $this->get_company( $context ), |
|
| 721 | - 'vat_number' => $this->get_vat_number( $context ), |
|
| 722 | - 'discount' => $this->get_discount_code( $context ), |
|
| 710 | + 'user_id' => $this->get_user_id($context), |
|
| 711 | + 'email' => $this->get_email($context), |
|
| 712 | + 'first_name' => $this->get_first_name($context), |
|
| 713 | + 'last_name' => $this->get_last_name($context), |
|
| 714 | + 'address' => $this->get_address($context), |
|
| 715 | + 'phone' => $this->get_phone($context), |
|
| 716 | + 'city' => $this->get_city($context), |
|
| 717 | + 'country' => $this->get_country($context), |
|
| 718 | + 'state' => $this->get_state($context), |
|
| 719 | + 'zip' => $this->get_zip($context), |
|
| 720 | + 'company' => $this->get_company($context), |
|
| 721 | + 'vat_number' => $this->get_vat_number($context), |
|
| 722 | + 'discount' => $this->get_discount_code($context), |
|
| 723 | 723 | ); |
| 724 | 724 | |
| 725 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
| 725 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
| 726 | 726 | |
| 727 | 727 | } |
| 728 | 728 | |
@@ -733,8 +733,8 @@ discard block |
||
| 733 | 733 | * @param string $context View or edit context. |
| 734 | 734 | * @return int |
| 735 | 735 | */ |
| 736 | - public function get_author( $context = 'view' ) { |
|
| 737 | - return (int) $this->get_prop( 'author', $context ); |
|
| 736 | + public function get_author($context = 'view') { |
|
| 737 | + return (int) $this->get_prop('author', $context); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | /** |
@@ -744,8 +744,8 @@ discard block |
||
| 744 | 744 | * @param string $context View or edit context. |
| 745 | 745 | * @return int |
| 746 | 746 | */ |
| 747 | - public function get_user_id( $context = 'view' ) { |
|
| 748 | - return $this->get_author( $context ); |
|
| 747 | + public function get_user_id($context = 'view') { |
|
| 748 | + return $this->get_author($context); |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | /** |
@@ -755,8 +755,8 @@ discard block |
||
| 755 | 755 | * @param string $context View or edit context. |
| 756 | 756 | * @return int |
| 757 | 757 | */ |
| 758 | - public function get_customer_id( $context = 'view' ) { |
|
| 759 | - return $this->get_author( $context ); |
|
| 758 | + public function get_customer_id($context = 'view') { |
|
| 759 | + return $this->get_author($context); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
@@ -766,8 +766,8 @@ discard block |
||
| 766 | 766 | * @param string $context View or edit context. |
| 767 | 767 | * @return string |
| 768 | 768 | */ |
| 769 | - public function get_ip( $context = 'view' ) { |
|
| 770 | - return $this->get_prop( 'user_ip', $context ); |
|
| 769 | + public function get_ip($context = 'view') { |
|
| 770 | + return $this->get_prop('user_ip', $context); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
@@ -777,8 +777,8 @@ discard block |
||
| 777 | 777 | * @param string $context View or edit context. |
| 778 | 778 | * @return string |
| 779 | 779 | */ |
| 780 | - public function get_user_ip( $context = 'view' ) { |
|
| 781 | - return $this->get_ip( $context ); |
|
| 780 | + public function get_user_ip($context = 'view') { |
|
| 781 | + return $this->get_ip($context); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | /** |
@@ -788,8 +788,8 @@ discard block |
||
| 788 | 788 | * @param string $context View or edit context. |
| 789 | 789 | * @return string |
| 790 | 790 | */ |
| 791 | - public function get_customer_ip( $context = 'view' ) { |
|
| 792 | - return $this->get_ip( $context ); |
|
| 791 | + public function get_customer_ip($context = 'view') { |
|
| 792 | + return $this->get_ip($context); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | /** |
@@ -799,8 +799,8 @@ discard block |
||
| 799 | 799 | * @param string $context View or edit context. |
| 800 | 800 | * @return string |
| 801 | 801 | */ |
| 802 | - public function get_first_name( $context = 'view' ) { |
|
| 803 | - return $this->get_prop( 'first_name', $context ); |
|
| 802 | + public function get_first_name($context = 'view') { |
|
| 803 | + return $this->get_prop('first_name', $context); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | /** |
@@ -810,8 +810,8 @@ discard block |
||
| 810 | 810 | * @param string $context View or edit context. |
| 811 | 811 | * @return string |
| 812 | 812 | */ |
| 813 | - public function get_user_first_name( $context = 'view' ) { |
|
| 814 | - return $this->get_first_name( $context ); |
|
| 813 | + public function get_user_first_name($context = 'view') { |
|
| 814 | + return $this->get_first_name($context); |
|
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | /** |
@@ -821,8 +821,8 @@ discard block |
||
| 821 | 821 | * @param string $context View or edit context. |
| 822 | 822 | * @return string |
| 823 | 823 | */ |
| 824 | - public function get_customer_first_name( $context = 'view' ) { |
|
| 825 | - return $this->get_first_name( $context ); |
|
| 824 | + public function get_customer_first_name($context = 'view') { |
|
| 825 | + return $this->get_first_name($context); |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | /** |
@@ -832,8 +832,8 @@ discard block |
||
| 832 | 832 | * @param string $context View or edit context. |
| 833 | 833 | * @return string |
| 834 | 834 | */ |
| 835 | - public function get_last_name( $context = 'view' ) { |
|
| 836 | - return $this->get_prop( 'last_name', $context ); |
|
| 835 | + public function get_last_name($context = 'view') { |
|
| 836 | + return $this->get_prop('last_name', $context); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
@@ -843,8 +843,8 @@ discard block |
||
| 843 | 843 | * @param string $context View or edit context. |
| 844 | 844 | * @return string |
| 845 | 845 | */ |
| 846 | - public function get_user_last_name( $context = 'view' ) { |
|
| 847 | - return $this->get_last_name( $context ); |
|
| 846 | + public function get_user_last_name($context = 'view') { |
|
| 847 | + return $this->get_last_name($context); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | /** |
@@ -854,8 +854,8 @@ discard block |
||
| 854 | 854 | * @param string $context View or edit context. |
| 855 | 855 | * @return string |
| 856 | 856 | */ |
| 857 | - public function get_customer_last_name( $context = 'view' ) { |
|
| 858 | - return $this->get_last_name( $context ); |
|
| 857 | + public function get_customer_last_name($context = 'view') { |
|
| 858 | + return $this->get_last_name($context); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | /** |
@@ -865,8 +865,8 @@ discard block |
||
| 865 | 865 | * @param string $context View or edit context. |
| 866 | 866 | * @return string |
| 867 | 867 | */ |
| 868 | - public function get_full_name( $context = 'view' ) { |
|
| 869 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
| 868 | + public function get_full_name($context = 'view') { |
|
| 869 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | /** |
@@ -876,8 +876,8 @@ discard block |
||
| 876 | 876 | * @param string $context View or edit context. |
| 877 | 877 | * @return string |
| 878 | 878 | */ |
| 879 | - public function get_user_full_name( $context = 'view' ) { |
|
| 880 | - return $this->get_full_name( $context ); |
|
| 879 | + public function get_user_full_name($context = 'view') { |
|
| 880 | + return $this->get_full_name($context); |
|
| 881 | 881 | } |
| 882 | 882 | |
| 883 | 883 | /** |
@@ -887,8 +887,8 @@ discard block |
||
| 887 | 887 | * @param string $context View or edit context. |
| 888 | 888 | * @return string |
| 889 | 889 | */ |
| 890 | - public function get_customer_full_name( $context = 'view' ) { |
|
| 891 | - return $this->get_full_name( $context ); |
|
| 890 | + public function get_customer_full_name($context = 'view') { |
|
| 891 | + return $this->get_full_name($context); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | /** |
@@ -898,8 +898,8 @@ discard block |
||
| 898 | 898 | * @param string $context View or edit context. |
| 899 | 899 | * @return string |
| 900 | 900 | */ |
| 901 | - public function get_phone( $context = 'view' ) { |
|
| 902 | - return $this->get_prop( 'phone', $context ); |
|
| 901 | + public function get_phone($context = 'view') { |
|
| 902 | + return $this->get_prop('phone', $context); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /** |
@@ -909,8 +909,8 @@ discard block |
||
| 909 | 909 | * @param string $context View or edit context. |
| 910 | 910 | * @return string |
| 911 | 911 | */ |
| 912 | - public function get_phone_number( $context = 'view' ) { |
|
| 913 | - return $this->get_phone( $context ); |
|
| 912 | + public function get_phone_number($context = 'view') { |
|
| 913 | + return $this->get_phone($context); |
|
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | /** |
@@ -920,8 +920,8 @@ discard block |
||
| 920 | 920 | * @param string $context View or edit context. |
| 921 | 921 | * @return string |
| 922 | 922 | */ |
| 923 | - public function get_user_phone( $context = 'view' ) { |
|
| 924 | - return $this->get_phone( $context ); |
|
| 923 | + public function get_user_phone($context = 'view') { |
|
| 924 | + return $this->get_phone($context); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | /** |
@@ -931,8 +931,8 @@ discard block |
||
| 931 | 931 | * @param string $context View or edit context. |
| 932 | 932 | * @return string |
| 933 | 933 | */ |
| 934 | - public function get_customer_phone( $context = 'view' ) { |
|
| 935 | - return $this->get_phone( $context ); |
|
| 934 | + public function get_customer_phone($context = 'view') { |
|
| 935 | + return $this->get_phone($context); |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | /** |
@@ -942,8 +942,8 @@ discard block |
||
| 942 | 942 | * @param string $context View or edit context. |
| 943 | 943 | * @return string |
| 944 | 944 | */ |
| 945 | - public function get_email( $context = 'view' ) { |
|
| 946 | - return $this->get_prop( 'email', $context ); |
|
| 945 | + public function get_email($context = 'view') { |
|
| 946 | + return $this->get_prop('email', $context); |
|
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | /** |
@@ -953,8 +953,8 @@ discard block |
||
| 953 | 953 | * @param string $context View or edit context. |
| 954 | 954 | * @return string |
| 955 | 955 | */ |
| 956 | - public function get_email_address( $context = 'view' ) { |
|
| 957 | - return $this->get_email( $context ); |
|
| 956 | + public function get_email_address($context = 'view') { |
|
| 957 | + return $this->get_email($context); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /** |
@@ -964,8 +964,8 @@ discard block |
||
| 964 | 964 | * @param string $context View or edit context. |
| 965 | 965 | * @return string |
| 966 | 966 | */ |
| 967 | - public function get_user_email( $context = 'view' ) { |
|
| 968 | - return $this->get_email( $context ); |
|
| 967 | + public function get_user_email($context = 'view') { |
|
| 968 | + return $this->get_email($context); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | /** |
@@ -975,8 +975,8 @@ discard block |
||
| 975 | 975 | * @param string $context View or edit context. |
| 976 | 976 | * @return string |
| 977 | 977 | */ |
| 978 | - public function get_customer_email( $context = 'view' ) { |
|
| 979 | - return $this->get_email( $context ); |
|
| 978 | + public function get_customer_email($context = 'view') { |
|
| 979 | + return $this->get_email($context); |
|
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | /** |
@@ -986,9 +986,9 @@ discard block |
||
| 986 | 986 | * @param string $context View or edit context. |
| 987 | 987 | * @return string |
| 988 | 988 | */ |
| 989 | - public function get_country( $context = 'view' ) { |
|
| 990 | - $country = $this->get_prop( 'country', $context ); |
|
| 991 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
| 989 | + public function get_country($context = 'view') { |
|
| 990 | + $country = $this->get_prop('country', $context); |
|
| 991 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | /** |
@@ -998,8 +998,8 @@ discard block |
||
| 998 | 998 | * @param string $context View or edit context. |
| 999 | 999 | * @return string |
| 1000 | 1000 | */ |
| 1001 | - public function get_user_country( $context = 'view' ) { |
|
| 1002 | - return $this->get_country( $context ); |
|
| 1001 | + public function get_user_country($context = 'view') { |
|
| 1002 | + return $this->get_country($context); |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | /** |
@@ -1009,8 +1009,8 @@ discard block |
||
| 1009 | 1009 | * @param string $context View or edit context. |
| 1010 | 1010 | * @return string |
| 1011 | 1011 | */ |
| 1012 | - public function get_customer_country( $context = 'view' ) { |
|
| 1013 | - return $this->get_country( $context ); |
|
| 1012 | + public function get_customer_country($context = 'view') { |
|
| 1013 | + return $this->get_country($context); |
|
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | /** |
@@ -1020,9 +1020,9 @@ discard block |
||
| 1020 | 1020 | * @param string $context View or edit context. |
| 1021 | 1021 | * @return string |
| 1022 | 1022 | */ |
| 1023 | - public function get_state( $context = 'view' ) { |
|
| 1024 | - $state = $this->get_prop( 'state', $context ); |
|
| 1025 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
| 1023 | + public function get_state($context = 'view') { |
|
| 1024 | + $state = $this->get_prop('state', $context); |
|
| 1025 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | /** |
@@ -1032,8 +1032,8 @@ discard block |
||
| 1032 | 1032 | * @param string $context View or edit context. |
| 1033 | 1033 | * @return string |
| 1034 | 1034 | */ |
| 1035 | - public function get_user_state( $context = 'view' ) { |
|
| 1036 | - return $this->get_state( $context ); |
|
| 1035 | + public function get_user_state($context = 'view') { |
|
| 1036 | + return $this->get_state($context); |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | /** |
@@ -1043,8 +1043,8 @@ discard block |
||
| 1043 | 1043 | * @param string $context View or edit context. |
| 1044 | 1044 | * @return string |
| 1045 | 1045 | */ |
| 1046 | - public function get_customer_state( $context = 'view' ) { |
|
| 1047 | - return $this->get_state( $context ); |
|
| 1046 | + public function get_customer_state($context = 'view') { |
|
| 1047 | + return $this->get_state($context); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | 1050 | /** |
@@ -1054,8 +1054,8 @@ discard block |
||
| 1054 | 1054 | * @param string $context View or edit context. |
| 1055 | 1055 | * @return string |
| 1056 | 1056 | */ |
| 1057 | - public function get_city( $context = 'view' ) { |
|
| 1058 | - return $this->get_prop( 'city', $context ); |
|
| 1057 | + public function get_city($context = 'view') { |
|
| 1058 | + return $this->get_prop('city', $context); |
|
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | /** |
@@ -1065,8 +1065,8 @@ discard block |
||
| 1065 | 1065 | * @param string $context View or edit context. |
| 1066 | 1066 | * @return string |
| 1067 | 1067 | */ |
| 1068 | - public function get_user_city( $context = 'view' ) { |
|
| 1069 | - return $this->get_city( $context ); |
|
| 1068 | + public function get_user_city($context = 'view') { |
|
| 1069 | + return $this->get_city($context); |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | /** |
@@ -1076,8 +1076,8 @@ discard block |
||
| 1076 | 1076 | * @param string $context View or edit context. |
| 1077 | 1077 | * @return string |
| 1078 | 1078 | */ |
| 1079 | - public function get_customer_city( $context = 'view' ) { |
|
| 1080 | - return $this->get_city( $context ); |
|
| 1079 | + public function get_customer_city($context = 'view') { |
|
| 1080 | + return $this->get_city($context); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | /** |
@@ -1087,8 +1087,8 @@ discard block |
||
| 1087 | 1087 | * @param string $context View or edit context. |
| 1088 | 1088 | * @return string |
| 1089 | 1089 | */ |
| 1090 | - public function get_zip( $context = 'view' ) { |
|
| 1091 | - return $this->get_prop( 'zip', $context ); |
|
| 1090 | + public function get_zip($context = 'view') { |
|
| 1091 | + return $this->get_prop('zip', $context); |
|
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | /** |
@@ -1098,8 +1098,8 @@ discard block |
||
| 1098 | 1098 | * @param string $context View or edit context. |
| 1099 | 1099 | * @return string |
| 1100 | 1100 | */ |
| 1101 | - public function get_user_zip( $context = 'view' ) { |
|
| 1102 | - return $this->get_zip( $context ); |
|
| 1101 | + public function get_user_zip($context = 'view') { |
|
| 1102 | + return $this->get_zip($context); |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | 1105 | /** |
@@ -1109,8 +1109,8 @@ discard block |
||
| 1109 | 1109 | * @param string $context View or edit context. |
| 1110 | 1110 | * @return string |
| 1111 | 1111 | */ |
| 1112 | - public function get_customer_zip( $context = 'view' ) { |
|
| 1113 | - return $this->get_zip( $context ); |
|
| 1112 | + public function get_customer_zip($context = 'view') { |
|
| 1113 | + return $this->get_zip($context); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | /** |
@@ -1120,8 +1120,8 @@ discard block |
||
| 1120 | 1120 | * @param string $context View or edit context. |
| 1121 | 1121 | * @return string |
| 1122 | 1122 | */ |
| 1123 | - public function get_company( $context = 'view' ) { |
|
| 1124 | - return $this->get_prop( 'company', $context ); |
|
| 1123 | + public function get_company($context = 'view') { |
|
| 1124 | + return $this->get_prop('company', $context); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | /** |
@@ -1131,8 +1131,8 @@ discard block |
||
| 1131 | 1131 | * @param string $context View or edit context. |
| 1132 | 1132 | * @return string |
| 1133 | 1133 | */ |
| 1134 | - public function get_user_company( $context = 'view' ) { |
|
| 1135 | - return $this->get_company( $context ); |
|
| 1134 | + public function get_user_company($context = 'view') { |
|
| 1135 | + return $this->get_company($context); |
|
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | 1138 | /** |
@@ -1142,8 +1142,8 @@ discard block |
||
| 1142 | 1142 | * @param string $context View or edit context. |
| 1143 | 1143 | * @return string |
| 1144 | 1144 | */ |
| 1145 | - public function get_customer_company( $context = 'view' ) { |
|
| 1146 | - return $this->get_company( $context ); |
|
| 1145 | + public function get_customer_company($context = 'view') { |
|
| 1146 | + return $this->get_company($context); |
|
| 1147 | 1147 | } |
| 1148 | 1148 | |
| 1149 | 1149 | /** |
@@ -1153,8 +1153,8 @@ discard block |
||
| 1153 | 1153 | * @param string $context View or edit context. |
| 1154 | 1154 | * @return string |
| 1155 | 1155 | */ |
| 1156 | - public function get_vat_number( $context = 'view' ) { |
|
| 1157 | - return $this->get_prop( 'vat_number', $context ); |
|
| 1156 | + public function get_vat_number($context = 'view') { |
|
| 1157 | + return $this->get_prop('vat_number', $context); |
|
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | /** |
@@ -1164,8 +1164,8 @@ discard block |
||
| 1164 | 1164 | * @param string $context View or edit context. |
| 1165 | 1165 | * @return string |
| 1166 | 1166 | */ |
| 1167 | - public function get_user_vat_number( $context = 'view' ) { |
|
| 1168 | - return $this->get_vat_number( $context ); |
|
| 1167 | + public function get_user_vat_number($context = 'view') { |
|
| 1168 | + return $this->get_vat_number($context); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | /** |
@@ -1175,8 +1175,8 @@ discard block |
||
| 1175 | 1175 | * @param string $context View or edit context. |
| 1176 | 1176 | * @return string |
| 1177 | 1177 | */ |
| 1178 | - public function get_customer_vat_number( $context = 'view' ) { |
|
| 1179 | - return $this->get_vat_number( $context ); |
|
| 1178 | + public function get_customer_vat_number($context = 'view') { |
|
| 1179 | + return $this->get_vat_number($context); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | /** |
@@ -1186,8 +1186,8 @@ discard block |
||
| 1186 | 1186 | * @param string $context View or edit context. |
| 1187 | 1187 | * @return string |
| 1188 | 1188 | */ |
| 1189 | - public function get_vat_rate( $context = 'view' ) { |
|
| 1190 | - return $this->get_prop( 'vat_rate', $context ); |
|
| 1189 | + public function get_vat_rate($context = 'view') { |
|
| 1190 | + return $this->get_prop('vat_rate', $context); |
|
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | 1193 | /** |
@@ -1197,8 +1197,8 @@ discard block |
||
| 1197 | 1197 | * @param string $context View or edit context. |
| 1198 | 1198 | * @return string |
| 1199 | 1199 | */ |
| 1200 | - public function get_user_vat_rate( $context = 'view' ) { |
|
| 1201 | - return $this->get_vat_rate( $context ); |
|
| 1200 | + public function get_user_vat_rate($context = 'view') { |
|
| 1201 | + return $this->get_vat_rate($context); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | /** |
@@ -1208,8 +1208,8 @@ discard block |
||
| 1208 | 1208 | * @param string $context View or edit context. |
| 1209 | 1209 | * @return string |
| 1210 | 1210 | */ |
| 1211 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
| 1212 | - return $this->get_vat_rate( $context ); |
|
| 1211 | + public function get_customer_vat_rate($context = 'view') { |
|
| 1212 | + return $this->get_vat_rate($context); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | /** |
@@ -1219,8 +1219,8 @@ discard block |
||
| 1219 | 1219 | * @param string $context View or edit context. |
| 1220 | 1220 | * @return string |
| 1221 | 1221 | */ |
| 1222 | - public function get_address( $context = 'view' ) { |
|
| 1223 | - return $this->get_prop( 'address', $context ); |
|
| 1222 | + public function get_address($context = 'view') { |
|
| 1223 | + return $this->get_prop('address', $context); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | /** |
@@ -1230,8 +1230,8 @@ discard block |
||
| 1230 | 1230 | * @param string $context View or edit context. |
| 1231 | 1231 | * @return string |
| 1232 | 1232 | */ |
| 1233 | - public function get_user_address( $context = 'view' ) { |
|
| 1234 | - return $this->get_address( $context ); |
|
| 1233 | + public function get_user_address($context = 'view') { |
|
| 1234 | + return $this->get_address($context); |
|
| 1235 | 1235 | } |
| 1236 | 1236 | |
| 1237 | 1237 | /** |
@@ -1241,8 +1241,8 @@ discard block |
||
| 1241 | 1241 | * @param string $context View or edit context. |
| 1242 | 1242 | * @return string |
| 1243 | 1243 | */ |
| 1244 | - public function get_customer_address( $context = 'view' ) { |
|
| 1245 | - return $this->get_address( $context ); |
|
| 1244 | + public function get_customer_address($context = 'view') { |
|
| 1245 | + return $this->get_address($context); |
|
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | /** |
@@ -1252,8 +1252,8 @@ discard block |
||
| 1252 | 1252 | * @param string $context View or edit context. |
| 1253 | 1253 | * @return bool |
| 1254 | 1254 | */ |
| 1255 | - public function get_is_viewed( $context = 'view' ) { |
|
| 1256 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
| 1255 | + public function get_is_viewed($context = 'view') { |
|
| 1256 | + return (bool) $this->get_prop('is_viewed', $context); |
|
| 1257 | 1257 | } |
| 1258 | 1258 | |
| 1259 | 1259 | /** |
@@ -1263,8 +1263,8 @@ discard block |
||
| 1263 | 1263 | * @param string $context View or edit context. |
| 1264 | 1264 | * @return bool |
| 1265 | 1265 | */ |
| 1266 | - public function get_email_cc( $context = 'view' ) { |
|
| 1267 | - return $this->get_prop( 'email_cc', $context ); |
|
| 1266 | + public function get_email_cc($context = 'view') { |
|
| 1267 | + return $this->get_prop('email_cc', $context); |
|
| 1268 | 1268 | } |
| 1269 | 1269 | |
| 1270 | 1270 | /** |
@@ -1274,8 +1274,8 @@ discard block |
||
| 1274 | 1274 | * @param string $context View or edit context. |
| 1275 | 1275 | * @return bool |
| 1276 | 1276 | */ |
| 1277 | - public function get_template( $context = 'view' ) { |
|
| 1278 | - return $this->get_prop( 'template', $context ); |
|
| 1277 | + public function get_template($context = 'view') { |
|
| 1278 | + return $this->get_prop('template', $context); |
|
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | 1281 | /** |
@@ -1285,8 +1285,8 @@ discard block |
||
| 1285 | 1285 | * @param string $context View or edit context. |
| 1286 | 1286 | * @return bool |
| 1287 | 1287 | */ |
| 1288 | - public function get_created_via( $context = 'view' ) { |
|
| 1289 | - return $this->get_prop( 'created_via', $context ); |
|
| 1288 | + public function get_created_via($context = 'view') { |
|
| 1289 | + return $this->get_prop('created_via', $context); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | 1292 | /** |
@@ -1296,8 +1296,8 @@ discard block |
||
| 1296 | 1296 | * @param string $context View or edit context. |
| 1297 | 1297 | * @return bool |
| 1298 | 1298 | */ |
| 1299 | - public function get_address_confirmed( $context = 'view' ) { |
|
| 1300 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
| 1299 | + public function get_address_confirmed($context = 'view') { |
|
| 1300 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | /** |
@@ -1307,8 +1307,8 @@ discard block |
||
| 1307 | 1307 | * @param string $context View or edit context. |
| 1308 | 1308 | * @return bool |
| 1309 | 1309 | */ |
| 1310 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
| 1311 | - return $this->get_address_confirmed( $context ); |
|
| 1310 | + public function get_user_address_confirmed($context = 'view') { |
|
| 1311 | + return $this->get_address_confirmed($context); |
|
| 1312 | 1312 | } |
| 1313 | 1313 | |
| 1314 | 1314 | /** |
@@ -1318,8 +1318,8 @@ discard block |
||
| 1318 | 1318 | * @param string $context View or edit context. |
| 1319 | 1319 | * @return bool |
| 1320 | 1320 | */ |
| 1321 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
| 1322 | - return $this->get_address_confirmed( $context ); |
|
| 1321 | + public function get_customer_address_confirmed($context = 'view') { |
|
| 1322 | + return $this->get_address_confirmed($context); |
|
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | /** |
@@ -1329,12 +1329,12 @@ discard block |
||
| 1329 | 1329 | * @param string $context View or edit context. |
| 1330 | 1330 | * @return float |
| 1331 | 1331 | */ |
| 1332 | - public function get_subtotal( $context = 'view' ) { |
|
| 1333 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
| 1332 | + public function get_subtotal($context = 'view') { |
|
| 1333 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
| 1334 | 1334 | |
| 1335 | 1335 | // Backwards compatibility. |
| 1336 | - if ( is_bool( $context ) && $context ) { |
|
| 1337 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
| 1336 | + if (is_bool($context) && $context) { |
|
| 1337 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | return $subtotal; |
@@ -1347,8 +1347,8 @@ discard block |
||
| 1347 | 1347 | * @param string $context View or edit context. |
| 1348 | 1348 | * @return float |
| 1349 | 1349 | */ |
| 1350 | - public function get_total_discount( $context = 'view' ) { |
|
| 1351 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
| 1350 | + public function get_total_discount($context = 'view') { |
|
| 1351 | + return (float) $this->get_prop('total_discount', $context); |
|
| 1352 | 1352 | } |
| 1353 | 1353 | |
| 1354 | 1354 | /** |
@@ -1358,18 +1358,18 @@ discard block |
||
| 1358 | 1358 | * @param string $context View or edit context. |
| 1359 | 1359 | * @return float |
| 1360 | 1360 | */ |
| 1361 | - public function get_total_tax( $context = 'view' ) { |
|
| 1362 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
| 1361 | + public function get_total_tax($context = 'view') { |
|
| 1362 | + return (float) $this->get_prop('total_tax', $context); |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | /** |
| 1366 | 1366 | * @deprecated |
| 1367 | 1367 | */ |
| 1368 | - public function get_final_tax( $currency = false ) { |
|
| 1368 | + public function get_final_tax($currency = false) { |
|
| 1369 | 1369 | $tax = $this->get_total_tax(); |
| 1370 | 1370 | |
| 1371 | - if ( $currency ) { |
|
| 1372 | - return wpinv_price( $tax, $this->get_currency() ); |
|
| 1371 | + if ($currency) { |
|
| 1372 | + return wpinv_price($tax, $this->get_currency()); |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | return $tax; |
@@ -1382,8 +1382,8 @@ discard block |
||
| 1382 | 1382 | * @param string $context View or edit context. |
| 1383 | 1383 | * @return float |
| 1384 | 1384 | */ |
| 1385 | - public function get_total_fees( $context = 'view' ) { |
|
| 1386 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
| 1385 | + public function get_total_fees($context = 'view') { |
|
| 1386 | + return (float) $this->get_prop('total_fees', $context); |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | /** |
@@ -1393,8 +1393,8 @@ discard block |
||
| 1393 | 1393 | * @param string $context View or edit context. |
| 1394 | 1394 | * @return float |
| 1395 | 1395 | */ |
| 1396 | - public function get_fees_total( $context = 'view' ) { |
|
| 1397 | - return $this->get_total_fees( $context ); |
|
| 1396 | + public function get_fees_total($context = 'view') { |
|
| 1397 | + return $this->get_total_fees($context); |
|
| 1398 | 1398 | } |
| 1399 | 1399 | |
| 1400 | 1400 | /** |
@@ -1405,7 +1405,7 @@ discard block |
||
| 1405 | 1405 | */ |
| 1406 | 1406 | public function get_total() { |
| 1407 | 1407 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
| 1408 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
| 1408 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | 1411 | /** |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | */ |
| 1428 | 1428 | public function get_initial_total() { |
| 1429 | 1429 | |
| 1430 | - if ( empty( $this->totals ) ) { |
|
| 1430 | + if (empty($this->totals)) { |
|
| 1431 | 1431 | $this->recalculate_total(); |
| 1432 | 1432 | } |
| 1433 | 1433 | |
@@ -1437,11 +1437,11 @@ discard block |
||
| 1437 | 1437 | $subtotal = $this->totals['subtotal']['initial']; |
| 1438 | 1438 | $total = $tax + $fee - $discount + $subtotal; |
| 1439 | 1439 | |
| 1440 | - if ( 0 > $total ) { |
|
| 1440 | + if (0 > $total) { |
|
| 1441 | 1441 | $total = 0; |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
| 1444 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | 1447 | /** |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | */ |
| 1454 | 1454 | public function get_recurring_total() { |
| 1455 | 1455 | |
| 1456 | - if ( empty( $this->totals ) ) { |
|
| 1456 | + if (empty($this->totals)) { |
|
| 1457 | 1457 | $this->recalculate_total(); |
| 1458 | 1458 | } |
| 1459 | 1459 | |
@@ -1463,11 +1463,11 @@ discard block |
||
| 1463 | 1463 | $subtotal = $this->totals['subtotal']['recurring']; |
| 1464 | 1464 | $total = $tax + $fee - $discount + $subtotal; |
| 1465 | 1465 | |
| 1466 | - if ( 0 > $total ) { |
|
| 1466 | + if (0 > $total) { |
|
| 1467 | 1467 | $total = 0; |
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
| 1470 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | /** |
@@ -1478,10 +1478,10 @@ discard block |
||
| 1478 | 1478 | * @param string $currency Whether to include the currency. |
| 1479 | 1479 | * @return float|string |
| 1480 | 1480 | */ |
| 1481 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
| 1481 | + public function get_recurring_details($field = '', $currency = false) { |
|
| 1482 | 1482 | |
| 1483 | 1483 | // Maybe recalculate totals. |
| 1484 | - if ( empty( $this->totals ) ) { |
|
| 1484 | + if (empty($this->totals)) { |
|
| 1485 | 1485 | $this->recalculate_total(); |
| 1486 | 1486 | } |
| 1487 | 1487 | |
@@ -1501,8 +1501,8 @@ discard block |
||
| 1501 | 1501 | $currency |
| 1502 | 1502 | ); |
| 1503 | 1503 | |
| 1504 | - if ( isset( $data[$field] ) ) { |
|
| 1505 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
| 1504 | + if (isset($data[$field])) { |
|
| 1505 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | 1508 | return $data; |
@@ -1515,8 +1515,8 @@ discard block |
||
| 1515 | 1515 | * @param string $context View or edit context. |
| 1516 | 1516 | * @return array |
| 1517 | 1517 | */ |
| 1518 | - public function get_fees( $context = 'view' ) { |
|
| 1519 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
| 1518 | + public function get_fees($context = 'view') { |
|
| 1519 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | /** |
@@ -1526,8 +1526,8 @@ discard block |
||
| 1526 | 1526 | * @param string $context View or edit context. |
| 1527 | 1527 | * @return array |
| 1528 | 1528 | */ |
| 1529 | - public function get_discounts( $context = 'view' ) { |
|
| 1530 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
| 1529 | + public function get_discounts($context = 'view') { |
|
| 1530 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | 1533 | /** |
@@ -1537,8 +1537,8 @@ discard block |
||
| 1537 | 1537 | * @param string $context View or edit context. |
| 1538 | 1538 | * @return array |
| 1539 | 1539 | */ |
| 1540 | - public function get_taxes( $context = 'view' ) { |
|
| 1541 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
| 1540 | + public function get_taxes($context = 'view') { |
|
| 1541 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
| 1542 | 1542 | } |
| 1543 | 1543 | |
| 1544 | 1544 | /** |
@@ -1548,8 +1548,8 @@ discard block |
||
| 1548 | 1548 | * @param string $context View or edit context. |
| 1549 | 1549 | * @return GetPaid_Form_Item[] |
| 1550 | 1550 | */ |
| 1551 | - public function get_items( $context = 'view' ) { |
|
| 1552 | - return $this->get_prop( 'items', $context ); |
|
| 1551 | + public function get_items($context = 'view') { |
|
| 1552 | + return $this->get_prop('items', $context); |
|
| 1553 | 1553 | } |
| 1554 | 1554 | |
| 1555 | 1555 | /** |
@@ -1559,8 +1559,8 @@ discard block |
||
| 1559 | 1559 | * @param string $context View or edit context. |
| 1560 | 1560 | * @return int |
| 1561 | 1561 | */ |
| 1562 | - public function get_payment_form( $context = 'view' ) { |
|
| 1563 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
| 1562 | + public function get_payment_form($context = 'view') { |
|
| 1563 | + return intval($this->get_prop('payment_form', $context)); |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | /** |
@@ -1570,8 +1570,8 @@ discard block |
||
| 1570 | 1570 | * @param string $context View or edit context. |
| 1571 | 1571 | * @return string |
| 1572 | 1572 | */ |
| 1573 | - public function get_submission_id( $context = 'view' ) { |
|
| 1574 | - return $this->get_prop( 'submission_id', $context ); |
|
| 1573 | + public function get_submission_id($context = 'view') { |
|
| 1574 | + return $this->get_prop('submission_id', $context); |
|
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | /** |
@@ -1581,8 +1581,8 @@ discard block |
||
| 1581 | 1581 | * @param string $context View or edit context. |
| 1582 | 1582 | * @return string |
| 1583 | 1583 | */ |
| 1584 | - public function get_discount_code( $context = 'view' ) { |
|
| 1585 | - return $this->get_prop( 'discount_code', $context ); |
|
| 1584 | + public function get_discount_code($context = 'view') { |
|
| 1585 | + return $this->get_prop('discount_code', $context); |
|
| 1586 | 1586 | } |
| 1587 | 1587 | |
| 1588 | 1588 | /** |
@@ -1592,8 +1592,8 @@ discard block |
||
| 1592 | 1592 | * @param string $context View or edit context. |
| 1593 | 1593 | * @return string |
| 1594 | 1594 | */ |
| 1595 | - public function get_gateway( $context = 'view' ) { |
|
| 1596 | - return $this->get_prop( 'gateway', $context ); |
|
| 1595 | + public function get_gateway($context = 'view') { |
|
| 1596 | + return $this->get_prop('gateway', $context); |
|
| 1597 | 1597 | } |
| 1598 | 1598 | |
| 1599 | 1599 | /** |
@@ -1603,8 +1603,8 @@ discard block |
||
| 1603 | 1603 | * @return string |
| 1604 | 1604 | */ |
| 1605 | 1605 | public function get_gateway_title() { |
| 1606 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
| 1607 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
| 1606 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
| 1607 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | 1610 | /** |
@@ -1614,8 +1614,8 @@ discard block |
||
| 1614 | 1614 | * @param string $context View or edit context. |
| 1615 | 1615 | * @return string |
| 1616 | 1616 | */ |
| 1617 | - public function get_transaction_id( $context = 'view' ) { |
|
| 1618 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 1617 | + public function get_transaction_id($context = 'view') { |
|
| 1618 | + return $this->get_prop('transaction_id', $context); |
|
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | /** |
@@ -1625,9 +1625,9 @@ discard block |
||
| 1625 | 1625 | * @param string $context View or edit context. |
| 1626 | 1626 | * @return string |
| 1627 | 1627 | */ |
| 1628 | - public function get_currency( $context = 'view' ) { |
|
| 1629 | - $currency = $this->get_prop( 'currency', $context ); |
|
| 1630 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
| 1628 | + public function get_currency($context = 'view') { |
|
| 1629 | + $currency = $this->get_prop('currency', $context); |
|
| 1630 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
| 1631 | 1631 | } |
| 1632 | 1632 | |
| 1633 | 1633 | /** |
@@ -1637,8 +1637,8 @@ discard block |
||
| 1637 | 1637 | * @param string $context View or edit context. |
| 1638 | 1638 | * @return bool |
| 1639 | 1639 | */ |
| 1640 | - public function get_disable_taxes( $context = 'view' ) { |
|
| 1641 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
| 1640 | + public function get_disable_taxes($context = 'view') { |
|
| 1641 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
| 1642 | 1642 | } |
| 1643 | 1643 | |
| 1644 | 1644 | /** |
@@ -1648,8 +1648,8 @@ discard block |
||
| 1648 | 1648 | * @param string $context View or edit context. |
| 1649 | 1649 | * @return int |
| 1650 | 1650 | */ |
| 1651 | - public function get_subscription_id( $context = 'view' ) { |
|
| 1652 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
| 1651 | + public function get_subscription_id($context = 'view') { |
|
| 1652 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
| 1653 | 1653 | } |
| 1654 | 1654 | |
| 1655 | 1655 | /** |
@@ -1659,12 +1659,12 @@ discard block |
||
| 1659 | 1659 | * @param string $context View or edit context. |
| 1660 | 1660 | * @return int |
| 1661 | 1661 | */ |
| 1662 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
| 1663 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
| 1662 | + public function get_remote_subscription_id($context = 'view') { |
|
| 1663 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
| 1664 | 1664 | |
| 1665 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
| 1665 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
| 1666 | 1666 | $parent = $this->get_parent(); |
| 1667 | - return $parent->get_subscription_id( $context ); |
|
| 1667 | + return $parent->get_subscription_id($context); |
|
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | 1670 | return $subscription_id; |
@@ -1677,20 +1677,20 @@ discard block |
||
| 1677 | 1677 | * @param string $context View or edit context. |
| 1678 | 1678 | * @return array |
| 1679 | 1679 | */ |
| 1680 | - public function get_payment_meta( $context = 'view' ) { |
|
| 1680 | + public function get_payment_meta($context = 'view') { |
|
| 1681 | 1681 | |
| 1682 | 1682 | return array( |
| 1683 | - 'price' => $this->get_total( $context ), |
|
| 1684 | - 'date' => $this->get_date_created( $context ), |
|
| 1685 | - 'user_email' => $this->get_email( $context ), |
|
| 1686 | - 'invoice_key' => $this->get_key( $context ), |
|
| 1687 | - 'currency' => $this->get_currency( $context ), |
|
| 1688 | - 'items' => $this->get_items( $context ), |
|
| 1689 | - 'user_info' => $this->get_user_info( $context ), |
|
| 1683 | + 'price' => $this->get_total($context), |
|
| 1684 | + 'date' => $this->get_date_created($context), |
|
| 1685 | + 'user_email' => $this->get_email($context), |
|
| 1686 | + 'invoice_key' => $this->get_key($context), |
|
| 1687 | + 'currency' => $this->get_currency($context), |
|
| 1688 | + 'items' => $this->get_items($context), |
|
| 1689 | + 'user_info' => $this->get_user_info($context), |
|
| 1690 | 1690 | 'cart_details' => $this->get_cart_details(), |
| 1691 | - 'status' => $this->get_status( $context ), |
|
| 1692 | - 'fees' => $this->get_fees( $context ), |
|
| 1693 | - 'taxes' => $this->get_taxes( $context ), |
|
| 1691 | + 'status' => $this->get_status($context), |
|
| 1692 | + 'fees' => $this->get_fees($context), |
|
| 1693 | + 'taxes' => $this->get_taxes($context), |
|
| 1694 | 1694 | ); |
| 1695 | 1695 | |
| 1696 | 1696 | } |
@@ -1705,9 +1705,9 @@ discard block |
||
| 1705 | 1705 | $items = $this->get_items(); |
| 1706 | 1706 | $cart_details = array(); |
| 1707 | 1707 | |
| 1708 | - foreach ( $items as $item_id => $item ) { |
|
| 1708 | + foreach ($items as $item_id => $item) { |
|
| 1709 | 1709 | $item->invoice_id = $this->get_id(); |
| 1710 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1710 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | 1713 | return $cart_details; |
@@ -1718,11 +1718,11 @@ discard block |
||
| 1718 | 1718 | * |
| 1719 | 1719 | * @return null|GetPaid_Form_Item|int |
| 1720 | 1720 | */ |
| 1721 | - public function get_recurring( $object = false ) { |
|
| 1721 | + public function get_recurring($object = false) { |
|
| 1722 | 1722 | |
| 1723 | 1723 | // Are we returning an object? |
| 1724 | - if ( $object ) { |
|
| 1725 | - return $this->get_item( $this->recurring_item ); |
|
| 1724 | + if ($object) { |
|
| 1725 | + return $this->get_item($this->recurring_item); |
|
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | 1728 | return $this->recurring_item; |
@@ -1737,15 +1737,15 @@ discard block |
||
| 1737 | 1737 | public function get_subscription_name() { |
| 1738 | 1738 | |
| 1739 | 1739 | // Retrieve the recurring name |
| 1740 | - $item = $this->get_recurring( true ); |
|
| 1740 | + $item = $this->get_recurring(true); |
|
| 1741 | 1741 | |
| 1742 | 1742 | // Abort if it does not exist. |
| 1743 | - if ( empty( $item ) ) { |
|
| 1743 | + if (empty($item)) { |
|
| 1744 | 1744 | return ''; |
| 1745 | 1745 | } |
| 1746 | 1746 | |
| 1747 | 1747 | // Return the item name. |
| 1748 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
| 1748 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | 1751 | /** |
@@ -1755,9 +1755,9 @@ discard block |
||
| 1755 | 1755 | * @return string |
| 1756 | 1756 | */ |
| 1757 | 1757 | public function get_view_url() { |
| 1758 | - $invoice_url = get_permalink( $this->get_id() ); |
|
| 1759 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
| 1760 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
| 1758 | + $invoice_url = get_permalink($this->get_id()); |
|
| 1759 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
| 1760 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | 1763 | /** |
@@ -1766,25 +1766,25 @@ discard block |
||
| 1766 | 1766 | * @since 1.0.19 |
| 1767 | 1767 | * @return string |
| 1768 | 1768 | */ |
| 1769 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
| 1769 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
| 1770 | 1770 | |
| 1771 | 1771 | // Retrieve the checkout url. |
| 1772 | 1772 | $pay_url = wpinv_get_checkout_uri(); |
| 1773 | 1773 | |
| 1774 | 1774 | // Maybe force ssl. |
| 1775 | - if ( is_ssl() ) { |
|
| 1776 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
| 1775 | + if (is_ssl()) { |
|
| 1776 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
| 1777 | 1777 | } |
| 1778 | 1778 | |
| 1779 | 1779 | // Add the invoice key. |
| 1780 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
| 1780 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
| 1781 | 1781 | |
| 1782 | 1782 | // (Maybe?) add a secret |
| 1783 | - if ( $secret ) { |
|
| 1784 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
| 1783 | + if ($secret) { |
|
| 1784 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
| 1787 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | 1790 | /** |
@@ -1799,14 +1799,14 @@ discard block |
||
| 1799 | 1799 | $receipt_url = wpinv_get_success_page_uri(); |
| 1800 | 1800 | |
| 1801 | 1801 | // Maybe force ssl. |
| 1802 | - if ( is_ssl() ) { |
|
| 1803 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
| 1802 | + if (is_ssl()) { |
|
| 1803 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
| 1804 | 1804 | } |
| 1805 | 1805 | |
| 1806 | 1806 | // Add the invoice key. |
| 1807 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
| 1807 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
| 1808 | 1808 | |
| 1809 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
| 1809 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | 1812 | /** |
@@ -1819,7 +1819,7 @@ discard block |
||
| 1819 | 1819 | |
| 1820 | 1820 | $type = $this->get_type(); |
| 1821 | 1821 | $status = "wpi-$type-pending"; |
| 1822 | - return str_replace( '-invoice', '', $status ); |
|
| 1822 | + return str_replace('-invoice', '', $status); |
|
| 1823 | 1823 | |
| 1824 | 1824 | } |
| 1825 | 1825 | |
@@ -1833,8 +1833,8 @@ discard block |
||
| 1833 | 1833 | * @param string $context View or edit context. |
| 1834 | 1834 | * @return mixed Value of the given invoice property (if set). |
| 1835 | 1835 | */ |
| 1836 | - public function get( $key, $context = 'view' ) { |
|
| 1837 | - return $this->get_prop( $key, $context ); |
|
| 1836 | + public function get($key, $context = 'view') { |
|
| 1837 | + return $this->get_prop($key, $context); |
|
| 1838 | 1838 | } |
| 1839 | 1839 | |
| 1840 | 1840 | /* |
@@ -1857,11 +1857,11 @@ discard block |
||
| 1857 | 1857 | * @param mixed $value new value. |
| 1858 | 1858 | * @return mixed Value of the given invoice property (if set). |
| 1859 | 1859 | */ |
| 1860 | - public function set( $key, $value ) { |
|
| 1860 | + public function set($key, $value) { |
|
| 1861 | 1861 | |
| 1862 | 1862 | $setter = "set_$key"; |
| 1863 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
| 1864 | - $this->{$setter}( $value ); |
|
| 1863 | + if (is_callable(array($this, $setter))) { |
|
| 1864 | + $this->{$setter}($value); |
|
| 1865 | 1865 | } |
| 1866 | 1866 | |
| 1867 | 1867 | } |
@@ -1875,47 +1875,47 @@ discard block |
||
| 1875 | 1875 | * @param bool $manual_update Is this a manual status change?. |
| 1876 | 1876 | * @return array details of change. |
| 1877 | 1877 | */ |
| 1878 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
| 1878 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
| 1879 | 1879 | $old_status = $this->get_status(); |
| 1880 | 1880 | |
| 1881 | 1881 | $statuses = $this->get_all_statuses(); |
| 1882 | 1882 | |
| 1883 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
| 1884 | - unset( $statuses[ 'draft' ] ); |
|
| 1883 | + if (isset($statuses['draft'])) { |
|
| 1884 | + unset($statuses['draft']); |
|
| 1885 | 1885 | } |
| 1886 | 1886 | |
| 1887 | - $this->set_prop( 'status', $new_status ); |
|
| 1887 | + $this->set_prop('status', $new_status); |
|
| 1888 | 1888 | |
| 1889 | 1889 | // If setting the status, ensure it's set to a valid status. |
| 1890 | - if ( true === $this->object_read ) { |
|
| 1890 | + if (true === $this->object_read) { |
|
| 1891 | 1891 | |
| 1892 | 1892 | // Only allow valid new status. |
| 1893 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1893 | + if (!array_key_exists($new_status, $statuses)) { |
|
| 1894 | 1894 | $new_status = $this->get_default_status(); |
| 1895 | 1895 | } |
| 1896 | 1896 | |
| 1897 | 1897 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
| 1898 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
| 1898 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
| 1899 | 1899 | $old_status = $this->get_default_status(); |
| 1900 | 1900 | } |
| 1901 | 1901 | |
| 1902 | 1902 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
| 1903 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
| 1903 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
| 1904 | 1904 | $old_status = 'wpi-pending'; |
| 1905 | 1905 | } |
| 1906 | 1906 | |
| 1907 | 1907 | } |
| 1908 | 1908 | |
| 1909 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 1909 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
| 1910 | 1910 | $this->status_transition = array( |
| 1911 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
| 1911 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
| 1912 | 1912 | 'to' => $new_status, |
| 1913 | 1913 | 'note' => $note, |
| 1914 | 1914 | 'manual' => (bool) $manual_update, |
| 1915 | 1915 | ); |
| 1916 | 1916 | |
| 1917 | - if ( $manual_update ) { |
|
| 1918 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
| 1917 | + if ($manual_update) { |
|
| 1918 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
| 1919 | 1919 | } |
| 1920 | 1920 | |
| 1921 | 1921 | $this->maybe_set_date_paid(); |
@@ -1938,8 +1938,8 @@ discard block |
||
| 1938 | 1938 | */ |
| 1939 | 1939 | public function maybe_set_date_paid() { |
| 1940 | 1940 | |
| 1941 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
| 1942 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 1941 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
| 1942 | + $this->set_date_completed(current_time('mysql')); |
|
| 1943 | 1943 | } |
| 1944 | 1944 | } |
| 1945 | 1945 | |
@@ -1948,11 +1948,11 @@ discard block |
||
| 1948 | 1948 | * |
| 1949 | 1949 | * @since 1.0.19 |
| 1950 | 1950 | */ |
| 1951 | - public function set_parent_id( $value ) { |
|
| 1952 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
| 1951 | + public function set_parent_id($value) { |
|
| 1952 | + if ($value && ($value === $this->get_id())) { |
|
| 1953 | 1953 | return; |
| 1954 | 1954 | } |
| 1955 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
| 1955 | + $this->set_prop('parent_id', absint($value)); |
|
| 1956 | 1956 | } |
| 1957 | 1957 | |
| 1958 | 1958 | /** |
@@ -1960,8 +1960,8 @@ discard block |
||
| 1960 | 1960 | * |
| 1961 | 1961 | * @since 1.0.19 |
| 1962 | 1962 | */ |
| 1963 | - public function set_version( $value ) { |
|
| 1964 | - $this->set_prop( 'version', $value ); |
|
| 1963 | + public function set_version($value) { |
|
| 1964 | + $this->set_prop('version', $value); |
|
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | 1967 | /** |
@@ -1971,15 +1971,15 @@ discard block |
||
| 1971 | 1971 | * @param string $value Value to set. |
| 1972 | 1972 | * @return bool Whether or not the date was set. |
| 1973 | 1973 | */ |
| 1974 | - public function set_date_created( $value ) { |
|
| 1975 | - $date = strtotime( $value ); |
|
| 1974 | + public function set_date_created($value) { |
|
| 1975 | + $date = strtotime($value); |
|
| 1976 | 1976 | |
| 1977 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1978 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1977 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1978 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
| 1979 | 1979 | return true; |
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | - $this->set_prop( 'date_created', '' ); |
|
| 1982 | + $this->set_prop('date_created', ''); |
|
| 1983 | 1983 | return false; |
| 1984 | 1984 | |
| 1985 | 1985 | } |
@@ -1991,15 +1991,15 @@ discard block |
||
| 1991 | 1991 | * @param string $value Value to set. |
| 1992 | 1992 | * @return bool Whether or not the date was set. |
| 1993 | 1993 | */ |
| 1994 | - public function set_due_date( $value ) { |
|
| 1995 | - $date = strtotime( $value ); |
|
| 1994 | + public function set_due_date($value) { |
|
| 1995 | + $date = strtotime($value); |
|
| 1996 | 1996 | |
| 1997 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 1998 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 1997 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 1998 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
| 1999 | 1999 | return true; |
| 2000 | 2000 | } |
| 2001 | 2001 | |
| 2002 | - $this->set_prop( 'due_date', '' ); |
|
| 2002 | + $this->set_prop('due_date', ''); |
|
| 2003 | 2003 | return false; |
| 2004 | 2004 | |
| 2005 | 2005 | } |
@@ -2010,8 +2010,8 @@ discard block |
||
| 2010 | 2010 | * @since 1.0.19 |
| 2011 | 2011 | * @param string $value New name. |
| 2012 | 2012 | */ |
| 2013 | - public function set_date_due( $value ) { |
|
| 2014 | - $this->set_due_date( $value ); |
|
| 2013 | + public function set_date_due($value) { |
|
| 2014 | + $this->set_due_date($value); |
|
| 2015 | 2015 | } |
| 2016 | 2016 | |
| 2017 | 2017 | /** |
@@ -2021,15 +2021,15 @@ discard block |
||
| 2021 | 2021 | * @param string $value Value to set. |
| 2022 | 2022 | * @return bool Whether or not the date was set. |
| 2023 | 2023 | */ |
| 2024 | - public function set_completed_date( $value ) { |
|
| 2025 | - $date = strtotime( $value ); |
|
| 2024 | + public function set_completed_date($value) { |
|
| 2025 | + $date = strtotime($value); |
|
| 2026 | 2026 | |
| 2027 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2028 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2027 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2028 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
| 2029 | 2029 | return true; |
| 2030 | 2030 | } |
| 2031 | 2031 | |
| 2032 | - $this->set_prop( 'completed_date', '' ); |
|
| 2032 | + $this->set_prop('completed_date', ''); |
|
| 2033 | 2033 | return false; |
| 2034 | 2034 | |
| 2035 | 2035 | } |
@@ -2040,8 +2040,8 @@ discard block |
||
| 2040 | 2040 | * @since 1.0.19 |
| 2041 | 2041 | * @param string $value New name. |
| 2042 | 2042 | */ |
| 2043 | - public function set_date_completed( $value ) { |
|
| 2044 | - $this->set_completed_date( $value ); |
|
| 2043 | + public function set_date_completed($value) { |
|
| 2044 | + $this->set_completed_date($value); |
|
| 2045 | 2045 | } |
| 2046 | 2046 | |
| 2047 | 2047 | /** |
@@ -2051,15 +2051,15 @@ discard block |
||
| 2051 | 2051 | * @param string $value Value to set. |
| 2052 | 2052 | * @return bool Whether or not the date was set. |
| 2053 | 2053 | */ |
| 2054 | - public function set_date_modified( $value ) { |
|
| 2055 | - $date = strtotime( $value ); |
|
| 2054 | + public function set_date_modified($value) { |
|
| 2055 | + $date = strtotime($value); |
|
| 2056 | 2056 | |
| 2057 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 2058 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
| 2057 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 2058 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
| 2059 | 2059 | return true; |
| 2060 | 2060 | } |
| 2061 | 2061 | |
| 2062 | - $this->set_prop( 'date_modified', '' ); |
|
| 2062 | + $this->set_prop('date_modified', ''); |
|
| 2063 | 2063 | return false; |
| 2064 | 2064 | |
| 2065 | 2065 | } |
@@ -2070,9 +2070,9 @@ discard block |
||
| 2070 | 2070 | * @since 1.0.19 |
| 2071 | 2071 | * @param string $value New number. |
| 2072 | 2072 | */ |
| 2073 | - public function set_number( $value ) { |
|
| 2074 | - $number = sanitize_text_field( $value ); |
|
| 2075 | - $this->set_prop( 'number', $number ); |
|
| 2073 | + public function set_number($value) { |
|
| 2074 | + $number = sanitize_text_field($value); |
|
| 2075 | + $this->set_prop('number', $number); |
|
| 2076 | 2076 | } |
| 2077 | 2077 | |
| 2078 | 2078 | /** |
@@ -2081,9 +2081,9 @@ discard block |
||
| 2081 | 2081 | * @since 1.0.19 |
| 2082 | 2082 | * @param string $value Type. |
| 2083 | 2083 | */ |
| 2084 | - public function set_type( $value ) { |
|
| 2085 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
| 2086 | - $this->set_prop( 'type', $type ); |
|
| 2084 | + public function set_type($value) { |
|
| 2085 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
| 2086 | + $this->set_prop('type', $type); |
|
| 2087 | 2087 | } |
| 2088 | 2088 | |
| 2089 | 2089 | /** |
@@ -2092,10 +2092,10 @@ discard block |
||
| 2092 | 2092 | * @since 1.0.19 |
| 2093 | 2093 | * @param string $value Post type. |
| 2094 | 2094 | */ |
| 2095 | - public function set_post_type( $value ) { |
|
| 2096 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
| 2097 | - $this->set_type( $value ); |
|
| 2098 | - $this->set_prop( 'post_type', $value ); |
|
| 2095 | + public function set_post_type($value) { |
|
| 2096 | + if (getpaid_is_invoice_post_type($value)) { |
|
| 2097 | + $this->set_type($value); |
|
| 2098 | + $this->set_prop('post_type', $value); |
|
| 2099 | 2099 | } |
| 2100 | 2100 | } |
| 2101 | 2101 | |
@@ -2105,9 +2105,9 @@ discard block |
||
| 2105 | 2105 | * @since 1.0.19 |
| 2106 | 2106 | * @param string $value New key. |
| 2107 | 2107 | */ |
| 2108 | - public function set_key( $value ) { |
|
| 2109 | - $key = sanitize_text_field( $value ); |
|
| 2110 | - $this->set_prop( 'key', $key ); |
|
| 2108 | + public function set_key($value) { |
|
| 2109 | + $key = sanitize_text_field($value); |
|
| 2110 | + $this->set_prop('key', $key); |
|
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | 2113 | /** |
@@ -2116,9 +2116,9 @@ discard block |
||
| 2116 | 2116 | * @since 1.0.19 |
| 2117 | 2117 | * @param string $value mode. |
| 2118 | 2118 | */ |
| 2119 | - public function set_mode( $value ) { |
|
| 2120 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
| 2121 | - $this->set_prop( 'value', $value ); |
|
| 2119 | + public function set_mode($value) { |
|
| 2120 | + if (!in_array($value, array('live', 'test'))) { |
|
| 2121 | + $this->set_prop('value', $value); |
|
| 2122 | 2122 | } |
| 2123 | 2123 | } |
| 2124 | 2124 | |
@@ -2128,8 +2128,8 @@ discard block |
||
| 2128 | 2128 | * @since 1.0.19 |
| 2129 | 2129 | * @param string $value path. |
| 2130 | 2130 | */ |
| 2131 | - public function set_path( $value ) { |
|
| 2132 | - $this->set_prop( 'path', $value ); |
|
| 2131 | + public function set_path($value) { |
|
| 2132 | + $this->set_prop('path', $value); |
|
| 2133 | 2133 | } |
| 2134 | 2134 | |
| 2135 | 2135 | /** |
@@ -2138,9 +2138,9 @@ discard block |
||
| 2138 | 2138 | * @since 1.0.19 |
| 2139 | 2139 | * @param string $value New name. |
| 2140 | 2140 | */ |
| 2141 | - public function set_name( $value ) { |
|
| 2142 | - $name = sanitize_text_field( $value ); |
|
| 2143 | - $this->set_prop( 'name', $name ); |
|
| 2141 | + public function set_name($value) { |
|
| 2142 | + $name = sanitize_text_field($value); |
|
| 2143 | + $this->set_prop('name', $name); |
|
| 2144 | 2144 | } |
| 2145 | 2145 | |
| 2146 | 2146 | /** |
@@ -2149,8 +2149,8 @@ discard block |
||
| 2149 | 2149 | * @since 1.0.19 |
| 2150 | 2150 | * @param string $value New name. |
| 2151 | 2151 | */ |
| 2152 | - public function set_title( $value ) { |
|
| 2153 | - $this->set_name( $value ); |
|
| 2152 | + public function set_title($value) { |
|
| 2153 | + $this->set_name($value); |
|
| 2154 | 2154 | } |
| 2155 | 2155 | |
| 2156 | 2156 | /** |
@@ -2159,9 +2159,9 @@ discard block |
||
| 2159 | 2159 | * @since 1.0.19 |
| 2160 | 2160 | * @param string $value New description. |
| 2161 | 2161 | */ |
| 2162 | - public function set_description( $value ) { |
|
| 2163 | - $description = wp_kses_post( $value ); |
|
| 2164 | - $this->set_prop( 'description', $description ); |
|
| 2162 | + public function set_description($value) { |
|
| 2163 | + $description = wp_kses_post($value); |
|
| 2164 | + $this->set_prop('description', $description); |
|
| 2165 | 2165 | } |
| 2166 | 2166 | |
| 2167 | 2167 | /** |
@@ -2170,8 +2170,8 @@ discard block |
||
| 2170 | 2170 | * @since 1.0.19 |
| 2171 | 2171 | * @param string $value New description. |
| 2172 | 2172 | */ |
| 2173 | - public function set_excerpt( $value ) { |
|
| 2174 | - $this->set_description( $value ); |
|
| 2173 | + public function set_excerpt($value) { |
|
| 2174 | + $this->set_description($value); |
|
| 2175 | 2175 | } |
| 2176 | 2176 | |
| 2177 | 2177 | /** |
@@ -2180,8 +2180,8 @@ discard block |
||
| 2180 | 2180 | * @since 1.0.19 |
| 2181 | 2181 | * @param string $value New description. |
| 2182 | 2182 | */ |
| 2183 | - public function set_summary( $value ) { |
|
| 2184 | - $this->set_description( $value ); |
|
| 2183 | + public function set_summary($value) { |
|
| 2184 | + $this->set_description($value); |
|
| 2185 | 2185 | } |
| 2186 | 2186 | |
| 2187 | 2187 | /** |
@@ -2190,12 +2190,12 @@ discard block |
||
| 2190 | 2190 | * @since 1.0.19 |
| 2191 | 2191 | * @param int $value New author. |
| 2192 | 2192 | */ |
| 2193 | - public function set_author( $value ) { |
|
| 2194 | - $user = get_user_by( 'id', (int) $value ); |
|
| 2193 | + public function set_author($value) { |
|
| 2194 | + $user = get_user_by('id', (int) $value); |
|
| 2195 | 2195 | |
| 2196 | - if ( $user && $user->ID ) { |
|
| 2197 | - $this->set_prop( 'author', $user->ID ); |
|
| 2198 | - $this->set_prop( 'email', $user->user_email ); |
|
| 2196 | + if ($user && $user->ID) { |
|
| 2197 | + $this->set_prop('author', $user->ID); |
|
| 2198 | + $this->set_prop('email', $user->user_email); |
|
| 2199 | 2199 | } |
| 2200 | 2200 | |
| 2201 | 2201 | } |
@@ -2206,8 +2206,8 @@ discard block |
||
| 2206 | 2206 | * @since 1.0.19 |
| 2207 | 2207 | * @param int $value New user id. |
| 2208 | 2208 | */ |
| 2209 | - public function set_user_id( $value ) { |
|
| 2210 | - $this->set_author( $value ); |
|
| 2209 | + public function set_user_id($value) { |
|
| 2210 | + $this->set_author($value); |
|
| 2211 | 2211 | } |
| 2212 | 2212 | |
| 2213 | 2213 | /** |
@@ -2216,8 +2216,8 @@ discard block |
||
| 2216 | 2216 | * @since 1.0.19 |
| 2217 | 2217 | * @param int $value New user id. |
| 2218 | 2218 | */ |
| 2219 | - public function set_customer_id( $value ) { |
|
| 2220 | - $this->set_author( $value ); |
|
| 2219 | + public function set_customer_id($value) { |
|
| 2220 | + $this->set_author($value); |
|
| 2221 | 2221 | } |
| 2222 | 2222 | |
| 2223 | 2223 | /** |
@@ -2226,8 +2226,8 @@ discard block |
||
| 2226 | 2226 | * @since 1.0.19 |
| 2227 | 2227 | * @param string $value ip address. |
| 2228 | 2228 | */ |
| 2229 | - public function set_ip( $value ) { |
|
| 2230 | - $this->set_prop( 'ip', $value ); |
|
| 2229 | + public function set_ip($value) { |
|
| 2230 | + $this->set_prop('ip', $value); |
|
| 2231 | 2231 | } |
| 2232 | 2232 | |
| 2233 | 2233 | /** |
@@ -2236,8 +2236,8 @@ discard block |
||
| 2236 | 2236 | * @since 1.0.19 |
| 2237 | 2237 | * @param string $value ip address. |
| 2238 | 2238 | */ |
| 2239 | - public function set_user_ip( $value ) { |
|
| 2240 | - $this->set_ip( $value ); |
|
| 2239 | + public function set_user_ip($value) { |
|
| 2240 | + $this->set_ip($value); |
|
| 2241 | 2241 | } |
| 2242 | 2242 | |
| 2243 | 2243 | /** |
@@ -2246,8 +2246,8 @@ discard block |
||
| 2246 | 2246 | * @since 1.0.19 |
| 2247 | 2247 | * @param string $value first name. |
| 2248 | 2248 | */ |
| 2249 | - public function set_first_name( $value ) { |
|
| 2250 | - $this->set_prop( 'first_name', $value ); |
|
| 2249 | + public function set_first_name($value) { |
|
| 2250 | + $this->set_prop('first_name', $value); |
|
| 2251 | 2251 | } |
| 2252 | 2252 | |
| 2253 | 2253 | /** |
@@ -2256,8 +2256,8 @@ discard block |
||
| 2256 | 2256 | * @since 1.0.19 |
| 2257 | 2257 | * @param string $value first name. |
| 2258 | 2258 | */ |
| 2259 | - public function set_user_first_name( $value ) { |
|
| 2260 | - $this->set_first_name( $value ); |
|
| 2259 | + public function set_user_first_name($value) { |
|
| 2260 | + $this->set_first_name($value); |
|
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | /** |
@@ -2266,8 +2266,8 @@ discard block |
||
| 2266 | 2266 | * @since 1.0.19 |
| 2267 | 2267 | * @param string $value first name. |
| 2268 | 2268 | */ |
| 2269 | - public function set_customer_first_name( $value ) { |
|
| 2270 | - $this->set_first_name( $value ); |
|
| 2269 | + public function set_customer_first_name($value) { |
|
| 2270 | + $this->set_first_name($value); |
|
| 2271 | 2271 | } |
| 2272 | 2272 | |
| 2273 | 2273 | /** |
@@ -2276,8 +2276,8 @@ discard block |
||
| 2276 | 2276 | * @since 1.0.19 |
| 2277 | 2277 | * @param string $value last name. |
| 2278 | 2278 | */ |
| 2279 | - public function set_last_name( $value ) { |
|
| 2280 | - $this->set_prop( 'last_name', $value ); |
|
| 2279 | + public function set_last_name($value) { |
|
| 2280 | + $this->set_prop('last_name', $value); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | |
| 2283 | 2283 | /** |
@@ -2286,8 +2286,8 @@ discard block |
||
| 2286 | 2286 | * @since 1.0.19 |
| 2287 | 2287 | * @param string $value last name. |
| 2288 | 2288 | */ |
| 2289 | - public function set_user_last_name( $value ) { |
|
| 2290 | - $this->set_last_name( $value ); |
|
| 2289 | + public function set_user_last_name($value) { |
|
| 2290 | + $this->set_last_name($value); |
|
| 2291 | 2291 | } |
| 2292 | 2292 | |
| 2293 | 2293 | /** |
@@ -2296,8 +2296,8 @@ discard block |
||
| 2296 | 2296 | * @since 1.0.19 |
| 2297 | 2297 | * @param string $value last name. |
| 2298 | 2298 | */ |
| 2299 | - public function set_customer_last_name( $value ) { |
|
| 2300 | - $this->set_last_name( $value ); |
|
| 2299 | + public function set_customer_last_name($value) { |
|
| 2300 | + $this->set_last_name($value); |
|
| 2301 | 2301 | } |
| 2302 | 2302 | |
| 2303 | 2303 | /** |
@@ -2306,8 +2306,8 @@ discard block |
||
| 2306 | 2306 | * @since 1.0.19 |
| 2307 | 2307 | * @param string $value phone. |
| 2308 | 2308 | */ |
| 2309 | - public function set_phone( $value ) { |
|
| 2310 | - $this->set_prop( 'phone', $value ); |
|
| 2309 | + public function set_phone($value) { |
|
| 2310 | + $this->set_prop('phone', $value); |
|
| 2311 | 2311 | } |
| 2312 | 2312 | |
| 2313 | 2313 | /** |
@@ -2316,8 +2316,8 @@ discard block |
||
| 2316 | 2316 | * @since 1.0.19 |
| 2317 | 2317 | * @param string $value phone. |
| 2318 | 2318 | */ |
| 2319 | - public function set_user_phone( $value ) { |
|
| 2320 | - $this->set_phone( $value ); |
|
| 2319 | + public function set_user_phone($value) { |
|
| 2320 | + $this->set_phone($value); |
|
| 2321 | 2321 | } |
| 2322 | 2322 | |
| 2323 | 2323 | /** |
@@ -2326,8 +2326,8 @@ discard block |
||
| 2326 | 2326 | * @since 1.0.19 |
| 2327 | 2327 | * @param string $value phone. |
| 2328 | 2328 | */ |
| 2329 | - public function set_customer_phone( $value ) { |
|
| 2330 | - $this->set_phone( $value ); |
|
| 2329 | + public function set_customer_phone($value) { |
|
| 2330 | + $this->set_phone($value); |
|
| 2331 | 2331 | } |
| 2332 | 2332 | |
| 2333 | 2333 | /** |
@@ -2336,8 +2336,8 @@ discard block |
||
| 2336 | 2336 | * @since 1.0.19 |
| 2337 | 2337 | * @param string $value phone. |
| 2338 | 2338 | */ |
| 2339 | - public function set_phone_number( $value ) { |
|
| 2340 | - $this->set_phone( $value ); |
|
| 2339 | + public function set_phone_number($value) { |
|
| 2340 | + $this->set_phone($value); |
|
| 2341 | 2341 | } |
| 2342 | 2342 | |
| 2343 | 2343 | /** |
@@ -2346,8 +2346,8 @@ discard block |
||
| 2346 | 2346 | * @since 1.0.19 |
| 2347 | 2347 | * @param string $value email address. |
| 2348 | 2348 | */ |
| 2349 | - public function set_email( $value ) { |
|
| 2350 | - $this->set_prop( 'email', $value ); |
|
| 2349 | + public function set_email($value) { |
|
| 2350 | + $this->set_prop('email', $value); |
|
| 2351 | 2351 | } |
| 2352 | 2352 | |
| 2353 | 2353 | /** |
@@ -2356,8 +2356,8 @@ discard block |
||
| 2356 | 2356 | * @since 1.0.19 |
| 2357 | 2357 | * @param string $value email address. |
| 2358 | 2358 | */ |
| 2359 | - public function set_user_email( $value ) { |
|
| 2360 | - $this->set_email( $value ); |
|
| 2359 | + public function set_user_email($value) { |
|
| 2360 | + $this->set_email($value); |
|
| 2361 | 2361 | } |
| 2362 | 2362 | |
| 2363 | 2363 | /** |
@@ -2366,8 +2366,8 @@ discard block |
||
| 2366 | 2366 | * @since 1.0.19 |
| 2367 | 2367 | * @param string $value email address. |
| 2368 | 2368 | */ |
| 2369 | - public function set_email_address( $value ) { |
|
| 2370 | - $this->set_email( $value ); |
|
| 2369 | + public function set_email_address($value) { |
|
| 2370 | + $this->set_email($value); |
|
| 2371 | 2371 | } |
| 2372 | 2372 | |
| 2373 | 2373 | /** |
@@ -2376,8 +2376,8 @@ discard block |
||
| 2376 | 2376 | * @since 1.0.19 |
| 2377 | 2377 | * @param string $value email address. |
| 2378 | 2378 | */ |
| 2379 | - public function set_customer_email( $value ) { |
|
| 2380 | - $this->set_email( $value ); |
|
| 2379 | + public function set_customer_email($value) { |
|
| 2380 | + $this->set_email($value); |
|
| 2381 | 2381 | } |
| 2382 | 2382 | |
| 2383 | 2383 | /** |
@@ -2386,8 +2386,8 @@ discard block |
||
| 2386 | 2386 | * @since 1.0.19 |
| 2387 | 2387 | * @param string $value country. |
| 2388 | 2388 | */ |
| 2389 | - public function set_country( $value ) { |
|
| 2390 | - $this->set_prop( 'country', $value ); |
|
| 2389 | + public function set_country($value) { |
|
| 2390 | + $this->set_prop('country', $value); |
|
| 2391 | 2391 | } |
| 2392 | 2392 | |
| 2393 | 2393 | /** |
@@ -2396,8 +2396,8 @@ discard block |
||
| 2396 | 2396 | * @since 1.0.19 |
| 2397 | 2397 | * @param string $value country. |
| 2398 | 2398 | */ |
| 2399 | - public function set_user_country( $value ) { |
|
| 2400 | - $this->set_country( $value ); |
|
| 2399 | + public function set_user_country($value) { |
|
| 2400 | + $this->set_country($value); |
|
| 2401 | 2401 | } |
| 2402 | 2402 | |
| 2403 | 2403 | /** |
@@ -2406,8 +2406,8 @@ discard block |
||
| 2406 | 2406 | * @since 1.0.19 |
| 2407 | 2407 | * @param string $value country. |
| 2408 | 2408 | */ |
| 2409 | - public function set_customer_country( $value ) { |
|
| 2410 | - $this->set_country( $value ); |
|
| 2409 | + public function set_customer_country($value) { |
|
| 2410 | + $this->set_country($value); |
|
| 2411 | 2411 | } |
| 2412 | 2412 | |
| 2413 | 2413 | /** |
@@ -2416,8 +2416,8 @@ discard block |
||
| 2416 | 2416 | * @since 1.0.19 |
| 2417 | 2417 | * @param string $value state. |
| 2418 | 2418 | */ |
| 2419 | - public function set_state( $value ) { |
|
| 2420 | - $this->set_prop( 'state', $value ); |
|
| 2419 | + public function set_state($value) { |
|
| 2420 | + $this->set_prop('state', $value); |
|
| 2421 | 2421 | } |
| 2422 | 2422 | |
| 2423 | 2423 | /** |
@@ -2426,8 +2426,8 @@ discard block |
||
| 2426 | 2426 | * @since 1.0.19 |
| 2427 | 2427 | * @param string $value state. |
| 2428 | 2428 | */ |
| 2429 | - public function set_user_state( $value ) { |
|
| 2430 | - $this->set_state( $value ); |
|
| 2429 | + public function set_user_state($value) { |
|
| 2430 | + $this->set_state($value); |
|
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | 2433 | /** |
@@ -2436,8 +2436,8 @@ discard block |
||
| 2436 | 2436 | * @since 1.0.19 |
| 2437 | 2437 | * @param string $value state. |
| 2438 | 2438 | */ |
| 2439 | - public function set_customer_state( $value ) { |
|
| 2440 | - $this->set_state( $value ); |
|
| 2439 | + public function set_customer_state($value) { |
|
| 2440 | + $this->set_state($value); |
|
| 2441 | 2441 | } |
| 2442 | 2442 | |
| 2443 | 2443 | /** |
@@ -2446,8 +2446,8 @@ discard block |
||
| 2446 | 2446 | * @since 1.0.19 |
| 2447 | 2447 | * @param string $value city. |
| 2448 | 2448 | */ |
| 2449 | - public function set_city( $value ) { |
|
| 2450 | - $this->set_prop( 'city', $value ); |
|
| 2449 | + public function set_city($value) { |
|
| 2450 | + $this->set_prop('city', $value); |
|
| 2451 | 2451 | } |
| 2452 | 2452 | |
| 2453 | 2453 | /** |
@@ -2456,8 +2456,8 @@ discard block |
||
| 2456 | 2456 | * @since 1.0.19 |
| 2457 | 2457 | * @param string $value city. |
| 2458 | 2458 | */ |
| 2459 | - public function set_user_city( $value ) { |
|
| 2460 | - $this->set_city( $value ); |
|
| 2459 | + public function set_user_city($value) { |
|
| 2460 | + $this->set_city($value); |
|
| 2461 | 2461 | } |
| 2462 | 2462 | |
| 2463 | 2463 | /** |
@@ -2466,8 +2466,8 @@ discard block |
||
| 2466 | 2466 | * @since 1.0.19 |
| 2467 | 2467 | * @param string $value city. |
| 2468 | 2468 | */ |
| 2469 | - public function set_customer_city( $value ) { |
|
| 2470 | - $this->set_city( $value ); |
|
| 2469 | + public function set_customer_city($value) { |
|
| 2470 | + $this->set_city($value); |
|
| 2471 | 2471 | } |
| 2472 | 2472 | |
| 2473 | 2473 | /** |
@@ -2476,8 +2476,8 @@ discard block |
||
| 2476 | 2476 | * @since 1.0.19 |
| 2477 | 2477 | * @param string $value zip. |
| 2478 | 2478 | */ |
| 2479 | - public function set_zip( $value ) { |
|
| 2480 | - $this->set_prop( 'zip', $value ); |
|
| 2479 | + public function set_zip($value) { |
|
| 2480 | + $this->set_prop('zip', $value); |
|
| 2481 | 2481 | } |
| 2482 | 2482 | |
| 2483 | 2483 | /** |
@@ -2486,8 +2486,8 @@ discard block |
||
| 2486 | 2486 | * @since 1.0.19 |
| 2487 | 2487 | * @param string $value zip. |
| 2488 | 2488 | */ |
| 2489 | - public function set_user_zip( $value ) { |
|
| 2490 | - $this->set_zip( $value ); |
|
| 2489 | + public function set_user_zip($value) { |
|
| 2490 | + $this->set_zip($value); |
|
| 2491 | 2491 | } |
| 2492 | 2492 | |
| 2493 | 2493 | /** |
@@ -2496,8 +2496,8 @@ discard block |
||
| 2496 | 2496 | * @since 1.0.19 |
| 2497 | 2497 | * @param string $value zip. |
| 2498 | 2498 | */ |
| 2499 | - public function set_customer_zip( $value ) { |
|
| 2500 | - $this->set_zip( $value ); |
|
| 2499 | + public function set_customer_zip($value) { |
|
| 2500 | + $this->set_zip($value); |
|
| 2501 | 2501 | } |
| 2502 | 2502 | |
| 2503 | 2503 | /** |
@@ -2506,8 +2506,8 @@ discard block |
||
| 2506 | 2506 | * @since 1.0.19 |
| 2507 | 2507 | * @param string $value company. |
| 2508 | 2508 | */ |
| 2509 | - public function set_company( $value ) { |
|
| 2510 | - $this->set_prop( 'company', $value ); |
|
| 2509 | + public function set_company($value) { |
|
| 2510 | + $this->set_prop('company', $value); |
|
| 2511 | 2511 | } |
| 2512 | 2512 | |
| 2513 | 2513 | /** |
@@ -2516,8 +2516,8 @@ discard block |
||
| 2516 | 2516 | * @since 1.0.19 |
| 2517 | 2517 | * @param string $value company. |
| 2518 | 2518 | */ |
| 2519 | - public function set_user_company( $value ) { |
|
| 2520 | - $this->set_company( $value ); |
|
| 2519 | + public function set_user_company($value) { |
|
| 2520 | + $this->set_company($value); |
|
| 2521 | 2521 | } |
| 2522 | 2522 | |
| 2523 | 2523 | /** |
@@ -2526,8 +2526,8 @@ discard block |
||
| 2526 | 2526 | * @since 1.0.19 |
| 2527 | 2527 | * @param string $value company. |
| 2528 | 2528 | */ |
| 2529 | - public function set_customer_company( $value ) { |
|
| 2530 | - $this->set_company( $value ); |
|
| 2529 | + public function set_customer_company($value) { |
|
| 2530 | + $this->set_company($value); |
|
| 2531 | 2531 | } |
| 2532 | 2532 | |
| 2533 | 2533 | /** |
@@ -2536,8 +2536,8 @@ discard block |
||
| 2536 | 2536 | * @since 1.0.19 |
| 2537 | 2537 | * @param string $value var number. |
| 2538 | 2538 | */ |
| 2539 | - public function set_vat_number( $value ) { |
|
| 2540 | - $this->set_prop( 'vat_number', $value ); |
|
| 2539 | + public function set_vat_number($value) { |
|
| 2540 | + $this->set_prop('vat_number', $value); |
|
| 2541 | 2541 | } |
| 2542 | 2542 | |
| 2543 | 2543 | /** |
@@ -2546,8 +2546,8 @@ discard block |
||
| 2546 | 2546 | * @since 1.0.19 |
| 2547 | 2547 | * @param string $value var number. |
| 2548 | 2548 | */ |
| 2549 | - public function set_user_vat_number( $value ) { |
|
| 2550 | - $this->set_vat_number( $value ); |
|
| 2549 | + public function set_user_vat_number($value) { |
|
| 2550 | + $this->set_vat_number($value); |
|
| 2551 | 2551 | } |
| 2552 | 2552 | |
| 2553 | 2553 | /** |
@@ -2556,8 +2556,8 @@ discard block |
||
| 2556 | 2556 | * @since 1.0.19 |
| 2557 | 2557 | * @param string $value var number. |
| 2558 | 2558 | */ |
| 2559 | - public function set_customer_vat_number( $value ) { |
|
| 2560 | - $this->set_vat_number( $value ); |
|
| 2559 | + public function set_customer_vat_number($value) { |
|
| 2560 | + $this->set_vat_number($value); |
|
| 2561 | 2561 | } |
| 2562 | 2562 | |
| 2563 | 2563 | /** |
@@ -2566,8 +2566,8 @@ discard block |
||
| 2566 | 2566 | * @since 1.0.19 |
| 2567 | 2567 | * @param string $value var rate. |
| 2568 | 2568 | */ |
| 2569 | - public function set_vat_rate( $value ) { |
|
| 2570 | - $this->set_prop( 'vat_rate', $value ); |
|
| 2569 | + public function set_vat_rate($value) { |
|
| 2570 | + $this->set_prop('vat_rate', $value); |
|
| 2571 | 2571 | } |
| 2572 | 2572 | |
| 2573 | 2573 | /** |
@@ -2576,8 +2576,8 @@ discard block |
||
| 2576 | 2576 | * @since 1.0.19 |
| 2577 | 2577 | * @param string $value var number. |
| 2578 | 2578 | */ |
| 2579 | - public function set_user_vat_rate( $value ) { |
|
| 2580 | - $this->set_vat_rate( $value ); |
|
| 2579 | + public function set_user_vat_rate($value) { |
|
| 2580 | + $this->set_vat_rate($value); |
|
| 2581 | 2581 | } |
| 2582 | 2582 | |
| 2583 | 2583 | /** |
@@ -2586,8 +2586,8 @@ discard block |
||
| 2586 | 2586 | * @since 1.0.19 |
| 2587 | 2587 | * @param string $value var number. |
| 2588 | 2588 | */ |
| 2589 | - public function set_customer_vat_rate( $value ) { |
|
| 2590 | - $this->set_vat_rate( $value ); |
|
| 2589 | + public function set_customer_vat_rate($value) { |
|
| 2590 | + $this->set_vat_rate($value); |
|
| 2591 | 2591 | } |
| 2592 | 2592 | |
| 2593 | 2593 | /** |
@@ -2596,8 +2596,8 @@ discard block |
||
| 2596 | 2596 | * @since 1.0.19 |
| 2597 | 2597 | * @param string $value address. |
| 2598 | 2598 | */ |
| 2599 | - public function set_address( $value ) { |
|
| 2600 | - $this->set_prop( 'address', $value ); |
|
| 2599 | + public function set_address($value) { |
|
| 2600 | + $this->set_prop('address', $value); |
|
| 2601 | 2601 | } |
| 2602 | 2602 | |
| 2603 | 2603 | /** |
@@ -2606,8 +2606,8 @@ discard block |
||
| 2606 | 2606 | * @since 1.0.19 |
| 2607 | 2607 | * @param string $value address. |
| 2608 | 2608 | */ |
| 2609 | - public function set_user_address( $value ) { |
|
| 2610 | - $this->set_address( $value ); |
|
| 2609 | + public function set_user_address($value) { |
|
| 2610 | + $this->set_address($value); |
|
| 2611 | 2611 | } |
| 2612 | 2612 | |
| 2613 | 2613 | /** |
@@ -2616,8 +2616,8 @@ discard block |
||
| 2616 | 2616 | * @since 1.0.19 |
| 2617 | 2617 | * @param string $value address. |
| 2618 | 2618 | */ |
| 2619 | - public function set_customer_address( $value ) { |
|
| 2620 | - $this->set_address( $value ); |
|
| 2619 | + public function set_customer_address($value) { |
|
| 2620 | + $this->set_address($value); |
|
| 2621 | 2621 | } |
| 2622 | 2622 | |
| 2623 | 2623 | /** |
@@ -2626,8 +2626,8 @@ discard block |
||
| 2626 | 2626 | * @since 1.0.19 |
| 2627 | 2627 | * @param int|bool $value confirmed. |
| 2628 | 2628 | */ |
| 2629 | - public function set_is_viewed( $value ) { |
|
| 2630 | - $this->set_prop( 'is_viewed', $value ); |
|
| 2629 | + public function set_is_viewed($value) { |
|
| 2630 | + $this->set_prop('is_viewed', $value); |
|
| 2631 | 2631 | } |
| 2632 | 2632 | |
| 2633 | 2633 | /** |
@@ -2636,8 +2636,8 @@ discard block |
||
| 2636 | 2636 | * @since 1.0.19 |
| 2637 | 2637 | * @param string $value email recipients. |
| 2638 | 2638 | */ |
| 2639 | - public function set_email_cc( $value ) { |
|
| 2640 | - $this->set_prop( 'email_cc', $value ); |
|
| 2639 | + public function set_email_cc($value) { |
|
| 2640 | + $this->set_prop('email_cc', $value); |
|
| 2641 | 2641 | } |
| 2642 | 2642 | |
| 2643 | 2643 | /** |
@@ -2646,9 +2646,9 @@ discard block |
||
| 2646 | 2646 | * @since 1.0.19 |
| 2647 | 2647 | * @param string $value template. |
| 2648 | 2648 | */ |
| 2649 | - public function set_template( $value ) { |
|
| 2650 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
| 2651 | - $this->set_prop( 'template', $value ); |
|
| 2649 | + public function set_template($value) { |
|
| 2650 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
| 2651 | + $this->set_prop('template', $value); |
|
| 2652 | 2652 | } |
| 2653 | 2653 | } |
| 2654 | 2654 | |
@@ -2658,8 +2658,8 @@ discard block |
||
| 2658 | 2658 | * @since 1.0.19 |
| 2659 | 2659 | * @param string $value email recipients. |
| 2660 | 2660 | */ |
| 2661 | - public function created_via( $value ) { |
|
| 2662 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
| 2661 | + public function created_via($value) { |
|
| 2662 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
| 2663 | 2663 | } |
| 2664 | 2664 | |
| 2665 | 2665 | /** |
@@ -2668,8 +2668,8 @@ discard block |
||
| 2668 | 2668 | * @since 1.0.19 |
| 2669 | 2669 | * @param int|bool $value confirmed. |
| 2670 | 2670 | */ |
| 2671 | - public function set_address_confirmed( $value ) { |
|
| 2672 | - $this->set_prop( 'address_confirmed', $value ); |
|
| 2671 | + public function set_address_confirmed($value) { |
|
| 2672 | + $this->set_prop('address_confirmed', $value); |
|
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | 2675 | /** |
@@ -2678,8 +2678,8 @@ discard block |
||
| 2678 | 2678 | * @since 1.0.19 |
| 2679 | 2679 | * @param int|bool $value confirmed. |
| 2680 | 2680 | */ |
| 2681 | - public function set_user_address_confirmed( $value ) { |
|
| 2682 | - $this->set_address_confirmed( $value ); |
|
| 2681 | + public function set_user_address_confirmed($value) { |
|
| 2682 | + $this->set_address_confirmed($value); |
|
| 2683 | 2683 | } |
| 2684 | 2684 | |
| 2685 | 2685 | /** |
@@ -2688,8 +2688,8 @@ discard block |
||
| 2688 | 2688 | * @since 1.0.19 |
| 2689 | 2689 | * @param int|bool $value confirmed. |
| 2690 | 2690 | */ |
| 2691 | - public function set_customer_address_confirmed( $value ) { |
|
| 2692 | - $this->set_address_confirmed( $value ); |
|
| 2691 | + public function set_customer_address_confirmed($value) { |
|
| 2692 | + $this->set_address_confirmed($value); |
|
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | 2695 | /** |
@@ -2698,8 +2698,8 @@ discard block |
||
| 2698 | 2698 | * @since 1.0.19 |
| 2699 | 2699 | * @param float $value sub total. |
| 2700 | 2700 | */ |
| 2701 | - public function set_subtotal( $value ) { |
|
| 2702 | - $this->set_prop( 'subtotal', $value ); |
|
| 2701 | + public function set_subtotal($value) { |
|
| 2702 | + $this->set_prop('subtotal', $value); |
|
| 2703 | 2703 | } |
| 2704 | 2704 | |
| 2705 | 2705 | /** |
@@ -2708,8 +2708,8 @@ discard block |
||
| 2708 | 2708 | * @since 1.0.19 |
| 2709 | 2709 | * @param float $value discount total. |
| 2710 | 2710 | */ |
| 2711 | - public function set_total_discount( $value ) { |
|
| 2712 | - $this->set_prop( 'total_discount', $value ); |
|
| 2711 | + public function set_total_discount($value) { |
|
| 2712 | + $this->set_prop('total_discount', $value); |
|
| 2713 | 2713 | } |
| 2714 | 2714 | |
| 2715 | 2715 | /** |
@@ -2718,8 +2718,8 @@ discard block |
||
| 2718 | 2718 | * @since 1.0.19 |
| 2719 | 2719 | * @param float $value discount total. |
| 2720 | 2720 | */ |
| 2721 | - public function set_discount( $value ) { |
|
| 2722 | - $this->set_total_discount( $value ); |
|
| 2721 | + public function set_discount($value) { |
|
| 2722 | + $this->set_total_discount($value); |
|
| 2723 | 2723 | } |
| 2724 | 2724 | |
| 2725 | 2725 | /** |
@@ -2728,8 +2728,8 @@ discard block |
||
| 2728 | 2728 | * @since 1.0.19 |
| 2729 | 2729 | * @param float $value tax total. |
| 2730 | 2730 | */ |
| 2731 | - public function set_total_tax( $value ) { |
|
| 2732 | - $this->set_prop( 'total_tax', $value ); |
|
| 2731 | + public function set_total_tax($value) { |
|
| 2732 | + $this->set_prop('total_tax', $value); |
|
| 2733 | 2733 | } |
| 2734 | 2734 | |
| 2735 | 2735 | /** |
@@ -2738,8 +2738,8 @@ discard block |
||
| 2738 | 2738 | * @since 1.0.19 |
| 2739 | 2739 | * @param float $value tax total. |
| 2740 | 2740 | */ |
| 2741 | - public function set_tax_total( $value ) { |
|
| 2742 | - $this->set_total_tax( $value ); |
|
| 2741 | + public function set_tax_total($value) { |
|
| 2742 | + $this->set_total_tax($value); |
|
| 2743 | 2743 | } |
| 2744 | 2744 | |
| 2745 | 2745 | /** |
@@ -2748,8 +2748,8 @@ discard block |
||
| 2748 | 2748 | * @since 1.0.19 |
| 2749 | 2749 | * @param float $value fees total. |
| 2750 | 2750 | */ |
| 2751 | - public function set_total_fees( $value ) { |
|
| 2752 | - $this->set_prop( 'total_fees', $value ); |
|
| 2751 | + public function set_total_fees($value) { |
|
| 2752 | + $this->set_prop('total_fees', $value); |
|
| 2753 | 2753 | } |
| 2754 | 2754 | |
| 2755 | 2755 | /** |
@@ -2758,8 +2758,8 @@ discard block |
||
| 2758 | 2758 | * @since 1.0.19 |
| 2759 | 2759 | * @param float $value fees total. |
| 2760 | 2760 | */ |
| 2761 | - public function set_fees_total( $value ) { |
|
| 2762 | - $this->set_total_fees( $value ); |
|
| 2761 | + public function set_fees_total($value) { |
|
| 2762 | + $this->set_total_fees($value); |
|
| 2763 | 2763 | } |
| 2764 | 2764 | |
| 2765 | 2765 | /** |
@@ -2768,13 +2768,13 @@ discard block |
||
| 2768 | 2768 | * @since 1.0.19 |
| 2769 | 2769 | * @param array $value fees. |
| 2770 | 2770 | */ |
| 2771 | - public function set_fees( $value ) { |
|
| 2771 | + public function set_fees($value) { |
|
| 2772 | 2772 | |
| 2773 | - if ( ! is_array( $value ) ) { |
|
| 2773 | + if (!is_array($value)) { |
|
| 2774 | 2774 | $value = array(); |
| 2775 | 2775 | } |
| 2776 | 2776 | |
| 2777 | - $this->set_prop( 'fees', $value ); |
|
| 2777 | + $this->set_prop('fees', $value); |
|
| 2778 | 2778 | |
| 2779 | 2779 | } |
| 2780 | 2780 | |
@@ -2784,13 +2784,13 @@ discard block |
||
| 2784 | 2784 | * @since 1.0.19 |
| 2785 | 2785 | * @param array $value taxes. |
| 2786 | 2786 | */ |
| 2787 | - public function set_taxes( $value ) { |
|
| 2787 | + public function set_taxes($value) { |
|
| 2788 | 2788 | |
| 2789 | - if ( ! is_array( $value ) ) { |
|
| 2789 | + if (!is_array($value)) { |
|
| 2790 | 2790 | $value = array(); |
| 2791 | 2791 | } |
| 2792 | 2792 | |
| 2793 | - $this->set_prop( 'taxes', $value ); |
|
| 2793 | + $this->set_prop('taxes', $value); |
|
| 2794 | 2794 | |
| 2795 | 2795 | } |
| 2796 | 2796 | |
@@ -2800,13 +2800,13 @@ discard block |
||
| 2800 | 2800 | * @since 1.0.19 |
| 2801 | 2801 | * @param array $value discounts. |
| 2802 | 2802 | */ |
| 2803 | - public function set_discounts( $value ) { |
|
| 2803 | + public function set_discounts($value) { |
|
| 2804 | 2804 | |
| 2805 | - if ( ! is_array( $value ) ) { |
|
| 2805 | + if (!is_array($value)) { |
|
| 2806 | 2806 | $value = array(); |
| 2807 | 2807 | } |
| 2808 | 2808 | |
| 2809 | - $this->set_prop( 'discounts', $value ); |
|
| 2809 | + $this->set_prop('discounts', $value); |
|
| 2810 | 2810 | } |
| 2811 | 2811 | |
| 2812 | 2812 | /** |
@@ -2815,18 +2815,18 @@ discard block |
||
| 2815 | 2815 | * @since 1.0.19 |
| 2816 | 2816 | * @param GetPaid_Form_Item[] $value items. |
| 2817 | 2817 | */ |
| 2818 | - public function set_items( $value ) { |
|
| 2818 | + public function set_items($value) { |
|
| 2819 | 2819 | |
| 2820 | 2820 | // Remove existing items. |
| 2821 | - $this->set_prop( 'items', array() ); |
|
| 2821 | + $this->set_prop('items', array()); |
|
| 2822 | 2822 | |
| 2823 | 2823 | // Ensure that we have an array. |
| 2824 | - if ( ! is_array( $value ) ) { |
|
| 2824 | + if (!is_array($value)) { |
|
| 2825 | 2825 | return; |
| 2826 | 2826 | } |
| 2827 | 2827 | |
| 2828 | - foreach ( $value as $item ) { |
|
| 2829 | - $this->add_item( $item ); |
|
| 2828 | + foreach ($value as $item) { |
|
| 2829 | + $this->add_item($item); |
|
| 2830 | 2830 | } |
| 2831 | 2831 | |
| 2832 | 2832 | } |
@@ -2837,8 +2837,8 @@ discard block |
||
| 2837 | 2837 | * @since 1.0.19 |
| 2838 | 2838 | * @param int $value payment form. |
| 2839 | 2839 | */ |
| 2840 | - public function set_payment_form( $value ) { |
|
| 2841 | - $this->set_prop( 'payment_form', $value ); |
|
| 2840 | + public function set_payment_form($value) { |
|
| 2841 | + $this->set_prop('payment_form', $value); |
|
| 2842 | 2842 | } |
| 2843 | 2843 | |
| 2844 | 2844 | /** |
@@ -2847,8 +2847,8 @@ discard block |
||
| 2847 | 2847 | * @since 1.0.19 |
| 2848 | 2848 | * @param string $value submission id. |
| 2849 | 2849 | */ |
| 2850 | - public function set_submission_id( $value ) { |
|
| 2851 | - $this->set_prop( 'submission_id', $value ); |
|
| 2850 | + public function set_submission_id($value) { |
|
| 2851 | + $this->set_prop('submission_id', $value); |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | /** |
@@ -2857,8 +2857,8 @@ discard block |
||
| 2857 | 2857 | * @since 1.0.19 |
| 2858 | 2858 | * @param string $value discount code. |
| 2859 | 2859 | */ |
| 2860 | - public function set_discount_code( $value ) { |
|
| 2861 | - $this->set_prop( 'discount_code', $value ); |
|
| 2860 | + public function set_discount_code($value) { |
|
| 2861 | + $this->set_prop('discount_code', $value); |
|
| 2862 | 2862 | } |
| 2863 | 2863 | |
| 2864 | 2864 | /** |
@@ -2867,8 +2867,8 @@ discard block |
||
| 2867 | 2867 | * @since 1.0.19 |
| 2868 | 2868 | * @param string $value gateway. |
| 2869 | 2869 | */ |
| 2870 | - public function set_gateway( $value ) { |
|
| 2871 | - $this->set_prop( 'gateway', $value ); |
|
| 2870 | + public function set_gateway($value) { |
|
| 2871 | + $this->set_prop('gateway', $value); |
|
| 2872 | 2872 | } |
| 2873 | 2873 | |
| 2874 | 2874 | /** |
@@ -2877,9 +2877,9 @@ discard block |
||
| 2877 | 2877 | * @since 1.0.19 |
| 2878 | 2878 | * @param string $value transaction id. |
| 2879 | 2879 | */ |
| 2880 | - public function set_transaction_id( $value ) { |
|
| 2881 | - if ( ! empty( $value ) ) { |
|
| 2882 | - $this->set_prop( 'transaction_id', $value ); |
|
| 2880 | + public function set_transaction_id($value) { |
|
| 2881 | + if (!empty($value)) { |
|
| 2882 | + $this->set_prop('transaction_id', $value); |
|
| 2883 | 2883 | } |
| 2884 | 2884 | } |
| 2885 | 2885 | |
@@ -2889,8 +2889,8 @@ discard block |
||
| 2889 | 2889 | * @since 1.0.19 |
| 2890 | 2890 | * @param string $value currency id. |
| 2891 | 2891 | */ |
| 2892 | - public function set_currency( $value ) { |
|
| 2893 | - $this->set_prop( 'currency', $value ); |
|
| 2892 | + public function set_currency($value) { |
|
| 2893 | + $this->set_prop('currency', $value); |
|
| 2894 | 2894 | } |
| 2895 | 2895 | |
| 2896 | 2896 | /** |
@@ -2899,8 +2899,8 @@ discard block |
||
| 2899 | 2899 | * @since 1.0.19 |
| 2900 | 2900 | * @param bool $value value. |
| 2901 | 2901 | */ |
| 2902 | - public function set_disable_taxes( $value ) { |
|
| 2903 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
| 2902 | + public function set_disable_taxes($value) { |
|
| 2903 | + $this->set_prop('disable_taxes', (bool) $value); |
|
| 2904 | 2904 | } |
| 2905 | 2905 | |
| 2906 | 2906 | /** |
@@ -2909,8 +2909,8 @@ discard block |
||
| 2909 | 2909 | * @since 1.0.19 |
| 2910 | 2910 | * @param string $value subscription id. |
| 2911 | 2911 | */ |
| 2912 | - public function set_subscription_id( $value ) { |
|
| 2913 | - $this->set_prop( 'subscription_id', $value ); |
|
| 2912 | + public function set_subscription_id($value) { |
|
| 2913 | + $this->set_prop('subscription_id', $value); |
|
| 2914 | 2914 | } |
| 2915 | 2915 | |
| 2916 | 2916 | /** |
@@ -2919,8 +2919,8 @@ discard block |
||
| 2919 | 2919 | * @since 1.0.19 |
| 2920 | 2920 | * @param string $value subscription id. |
| 2921 | 2921 | */ |
| 2922 | - public function set_remote_subscription_id( $value ) { |
|
| 2923 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
| 2922 | + public function set_remote_subscription_id($value) { |
|
| 2923 | + $this->set_prop('remote_subscription_id', $value); |
|
| 2924 | 2924 | } |
| 2925 | 2925 | |
| 2926 | 2926 | /* |
@@ -2937,28 +2937,28 @@ discard block |
||
| 2937 | 2937 | */ |
| 2938 | 2938 | public function is_parent() { |
| 2939 | 2939 | $parent = $this->get_parent_id(); |
| 2940 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
| 2940 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
| 2941 | 2941 | } |
| 2942 | 2942 | |
| 2943 | 2943 | /** |
| 2944 | 2944 | * Checks if this is a renewal invoice. |
| 2945 | 2945 | */ |
| 2946 | 2946 | public function is_renewal() { |
| 2947 | - return ! $this->is_parent(); |
|
| 2947 | + return !$this->is_parent(); |
|
| 2948 | 2948 | } |
| 2949 | 2949 | |
| 2950 | 2950 | /** |
| 2951 | 2951 | * Checks if this is a recurring invoice. |
| 2952 | 2952 | */ |
| 2953 | 2953 | public function is_recurring() { |
| 2954 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
| 2954 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
| 2955 | 2955 | } |
| 2956 | 2956 | |
| 2957 | 2957 | /** |
| 2958 | 2958 | * Checks if this is a taxable invoice. |
| 2959 | 2959 | */ |
| 2960 | 2960 | public function is_taxable() { |
| 2961 | - return ! $this->get_disable_taxes(); |
|
| 2961 | + return !$this->get_disable_taxes(); |
|
| 2962 | 2962 | } |
| 2963 | 2963 | |
| 2964 | 2964 | /** |
@@ -2972,45 +2972,45 @@ discard block |
||
| 2972 | 2972 | * Checks to see if the invoice requires payment. |
| 2973 | 2973 | */ |
| 2974 | 2974 | public function is_free() { |
| 2975 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
| 2975 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
| 2976 | 2976 | |
| 2977 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
| 2977 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
| 2978 | 2978 | $is_free = false; |
| 2979 | 2979 | } |
| 2980 | 2980 | |
| 2981 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
| 2981 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
| 2982 | 2982 | } |
| 2983 | 2983 | |
| 2984 | 2984 | /** |
| 2985 | 2985 | * Checks if the invoice is paid. |
| 2986 | 2986 | */ |
| 2987 | 2987 | public function is_paid() { |
| 2988 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
| 2989 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
| 2988 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
| 2989 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
| 2990 | 2990 | } |
| 2991 | 2991 | |
| 2992 | 2992 | /** |
| 2993 | 2993 | * Checks if the invoice needs payment. |
| 2994 | 2994 | */ |
| 2995 | 2995 | public function needs_payment() { |
| 2996 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
| 2997 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
| 2996 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
| 2997 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
| 2998 | 2998 | } |
| 2999 | 2999 | |
| 3000 | 3000 | /** |
| 3001 | 3001 | * Checks if the invoice is refunded. |
| 3002 | 3002 | */ |
| 3003 | 3003 | public function is_refunded() { |
| 3004 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
| 3005 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
| 3004 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
| 3005 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
| 3006 | 3006 | } |
| 3007 | 3007 | |
| 3008 | 3008 | /** |
| 3009 | 3009 | * Checks if the invoice is held. |
| 3010 | 3010 | */ |
| 3011 | 3011 | public function is_held() { |
| 3012 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
| 3013 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
| 3012 | + $is_held = $this->has_status('wpi-onhold'); |
|
| 3013 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
| 3014 | 3014 | } |
| 3015 | 3015 | |
| 3016 | 3016 | /** |
@@ -3018,30 +3018,30 @@ discard block |
||
| 3018 | 3018 | */ |
| 3019 | 3019 | public function is_due() { |
| 3020 | 3020 | $due_date = $this->get_due_date(); |
| 3021 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
| 3021 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
| 3022 | 3022 | } |
| 3023 | 3023 | |
| 3024 | 3024 | /** |
| 3025 | 3025 | * Checks if the invoice is draft. |
| 3026 | 3026 | */ |
| 3027 | 3027 | public function is_draft() { |
| 3028 | - return $this->has_status( 'draft, auto-draft' ); |
|
| 3028 | + return $this->has_status('draft, auto-draft'); |
|
| 3029 | 3029 | } |
| 3030 | 3030 | |
| 3031 | 3031 | /** |
| 3032 | 3032 | * Checks if the invoice has a given status. |
| 3033 | 3033 | */ |
| 3034 | - public function has_status( $status ) { |
|
| 3035 | - $status = wpinv_parse_list( $status ); |
|
| 3036 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
| 3034 | + public function has_status($status) { |
|
| 3035 | + $status = wpinv_parse_list($status); |
|
| 3036 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
| 3037 | 3037 | } |
| 3038 | 3038 | |
| 3039 | 3039 | /** |
| 3040 | 3040 | * Checks if the invoice is of a given type. |
| 3041 | 3041 | */ |
| 3042 | - public function is_type( $type ) { |
|
| 3043 | - $type = wpinv_parse_list( $type ); |
|
| 3044 | - return in_array( $this->get_type(), $type ); |
|
| 3042 | + public function is_type($type) { |
|
| 3043 | + $type = wpinv_parse_list($type); |
|
| 3044 | + return in_array($this->get_type(), $type); |
|
| 3045 | 3045 | } |
| 3046 | 3046 | |
| 3047 | 3047 | /** |
@@ -3073,8 +3073,8 @@ discard block |
||
| 3073 | 3073 | * |
| 3074 | 3074 | */ |
| 3075 | 3075 | public function is_initial_free() { |
| 3076 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
| 3077 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
| 3076 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
| 3077 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
| 3078 | 3078 | } |
| 3079 | 3079 | |
| 3080 | 3080 | /** |
@@ -3084,11 +3084,11 @@ discard block |
||
| 3084 | 3084 | public function item_has_free_trial() { |
| 3085 | 3085 | |
| 3086 | 3086 | // Ensure we have a recurring item. |
| 3087 | - if ( ! $this->is_recurring() ) { |
|
| 3087 | + if (!$this->is_recurring()) { |
|
| 3088 | 3088 | return false; |
| 3089 | 3089 | } |
| 3090 | 3090 | |
| 3091 | - $item = $this->get_recurring( true ); |
|
| 3091 | + $item = $this->get_recurring(true); |
|
| 3092 | 3092 | return $item->has_free_trial(); |
| 3093 | 3093 | } |
| 3094 | 3094 | |
@@ -3096,7 +3096,7 @@ discard block |
||
| 3096 | 3096 | * Check if the free trial is a result of a discount. |
| 3097 | 3097 | */ |
| 3098 | 3098 | public function is_free_trial_from_discount() { |
| 3099 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
| 3099 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
| 3100 | 3100 | } |
| 3101 | 3101 | |
| 3102 | 3102 | /** |
@@ -3104,12 +3104,12 @@ discard block |
||
| 3104 | 3104 | */ |
| 3105 | 3105 | public function discount_first_payment_only() { |
| 3106 | 3106 | |
| 3107 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
| 3108 | - if ( ! $discount->exists() || ! $this->is_recurring() ) { |
|
| 3107 | + $discount = wpinv_get_discount_obj($this->get_discount_code()); |
|
| 3108 | + if (!$discount->exists() || !$this->is_recurring()) { |
|
| 3109 | 3109 | return true; |
| 3110 | 3110 | } |
| 3111 | 3111 | |
| 3112 | - return ! $discount->get_is_recurring(); |
|
| 3112 | + return !$discount->get_is_recurring(); |
|
| 3113 | 3113 | } |
| 3114 | 3114 | |
| 3115 | 3115 | /* |
@@ -3127,27 +3127,27 @@ discard block |
||
| 3127 | 3127 | * @param GetPaid_Form_Item|array $item |
| 3128 | 3128 | * @return WP_Error|Bool |
| 3129 | 3129 | */ |
| 3130 | - public function add_item( $item ) { |
|
| 3130 | + public function add_item($item) { |
|
| 3131 | 3131 | |
| 3132 | - if ( is_array( $item ) ) { |
|
| 3133 | - $item = $this->process_array_item( $item ); |
|
| 3132 | + if (is_array($item)) { |
|
| 3133 | + $item = $this->process_array_item($item); |
|
| 3134 | 3134 | } |
| 3135 | 3135 | |
| 3136 | - if ( is_numeric( $item ) ) { |
|
| 3137 | - $item = new GetPaid_Form_Item( $item ); |
|
| 3136 | + if (is_numeric($item)) { |
|
| 3137 | + $item = new GetPaid_Form_Item($item); |
|
| 3138 | 3138 | } |
| 3139 | 3139 | |
| 3140 | 3140 | // Make sure that it is available for purchase. |
| 3141 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
| 3142 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
| 3141 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
| 3142 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
| 3143 | 3143 | } |
| 3144 | 3144 | |
| 3145 | 3145 | // Do we have a recurring item? |
| 3146 | - if ( $item->is_recurring() ) { |
|
| 3146 | + if ($item->is_recurring()) { |
|
| 3147 | 3147 | |
| 3148 | 3148 | // An invoice can only contain one recurring item. |
| 3149 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
| 3150 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
| 3149 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
| 3150 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
| 3151 | 3151 | } |
| 3152 | 3152 | |
| 3153 | 3153 | $this->recurring_item = $item->get_id(); |
@@ -3158,9 +3158,9 @@ discard block |
||
| 3158 | 3158 | |
| 3159 | 3159 | // Retrieve all items. |
| 3160 | 3160 | $items = $this->get_items(); |
| 3161 | - $items[ (int) $item->get_id() ] = $item; |
|
| 3161 | + $items[(int) $item->get_id()] = $item; |
|
| 3162 | 3162 | |
| 3163 | - $this->set_prop( 'items', $items ); |
|
| 3163 | + $this->set_prop('items', $items); |
|
| 3164 | 3164 | return true; |
| 3165 | 3165 | } |
| 3166 | 3166 | |
@@ -3170,26 +3170,26 @@ discard block |
||
| 3170 | 3170 | * @since 1.0.19 |
| 3171 | 3171 | * @return GetPaid_Form_Item |
| 3172 | 3172 | */ |
| 3173 | - protected function process_array_item( $array ) { |
|
| 3173 | + protected function process_array_item($array) { |
|
| 3174 | 3174 | |
| 3175 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
| 3176 | - $item = new GetPaid_Form_Item( $item_id ); |
|
| 3175 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
| 3176 | + $item = new GetPaid_Form_Item($item_id); |
|
| 3177 | 3177 | |
| 3178 | 3178 | // Set item data. |
| 3179 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
| 3180 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
| 3179 | + foreach (array('name', 'price', 'description') as $key) { |
|
| 3180 | + if (isset($array["item_$key"])) { |
|
| 3181 | 3181 | $method = "set_$key"; |
| 3182 | - $item->$method( $array[ "item_$key" ] ); |
|
| 3182 | + $item->$method($array["item_$key"]); |
|
| 3183 | 3183 | } |
| 3184 | 3184 | } |
| 3185 | 3185 | |
| 3186 | - if ( isset( $array['quantity'] ) ) { |
|
| 3187 | - $item->set_quantity( $array['quantity'] ); |
|
| 3186 | + if (isset($array['quantity'])) { |
|
| 3187 | + $item->set_quantity($array['quantity']); |
|
| 3188 | 3188 | } |
| 3189 | 3189 | |
| 3190 | 3190 | // Set item meta. |
| 3191 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
| 3192 | - $item->set_item_meta( $array['meta'] ); |
|
| 3191 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
| 3192 | + $item->set_item_meta($array['meta']); |
|
| 3193 | 3193 | } |
| 3194 | 3194 | |
| 3195 | 3195 | return $item; |
@@ -3201,10 +3201,10 @@ discard block |
||
| 3201 | 3201 | * |
| 3202 | 3202 | * @since 1.0.19 |
| 3203 | 3203 | */ |
| 3204 | - public function get_item( $item_id ) { |
|
| 3204 | + public function get_item($item_id) { |
|
| 3205 | 3205 | $items = $this->get_items(); |
| 3206 | 3206 | $item_id = (int) $item_id; |
| 3207 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
| 3207 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
| 3208 | 3208 | } |
| 3209 | 3209 | |
| 3210 | 3210 | /** |
@@ -3212,17 +3212,17 @@ discard block |
||
| 3212 | 3212 | * |
| 3213 | 3213 | * @since 1.0.19 |
| 3214 | 3214 | */ |
| 3215 | - public function remove_item( $item_id ) { |
|
| 3215 | + public function remove_item($item_id) { |
|
| 3216 | 3216 | $items = $this->get_items(); |
| 3217 | 3217 | $item_id = (int) $item_id; |
| 3218 | 3218 | |
| 3219 | - if ( $item_id == $this->recurring_item ) { |
|
| 3219 | + if ($item_id == $this->recurring_item) { |
|
| 3220 | 3220 | $this->recurring_item = null; |
| 3221 | 3221 | } |
| 3222 | 3222 | |
| 3223 | - if ( isset( $items[ $item_id ] ) ) { |
|
| 3224 | - unset( $items[ $item_id ] ); |
|
| 3225 | - $this->set_prop( 'items', $items ); |
|
| 3223 | + if (isset($items[$item_id])) { |
|
| 3224 | + unset($items[$item_id]); |
|
| 3225 | + $this->set_prop('items', $items); |
|
| 3226 | 3226 | } |
| 3227 | 3227 | } |
| 3228 | 3228 | |
@@ -3232,11 +3232,11 @@ discard block |
||
| 3232 | 3232 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
| 3233 | 3233 | * @since 1.0.19 |
| 3234 | 3234 | */ |
| 3235 | - public function add_fee( $fee ) { |
|
| 3235 | + public function add_fee($fee) { |
|
| 3236 | 3236 | |
| 3237 | 3237 | $fees = $this->get_fees(); |
| 3238 | - $fees[ $fee['name'] ] = $fee; |
|
| 3239 | - $this->set_prop( 'fees', $fees ); |
|
| 3238 | + $fees[$fee['name']] = $fee; |
|
| 3239 | + $this->set_prop('fees', $fees); |
|
| 3240 | 3240 | |
| 3241 | 3241 | } |
| 3242 | 3242 | |
@@ -3245,9 +3245,9 @@ discard block |
||
| 3245 | 3245 | * |
| 3246 | 3246 | * @since 1.0.19 |
| 3247 | 3247 | */ |
| 3248 | - public function get_fee( $fee ) { |
|
| 3248 | + public function get_fee($fee) { |
|
| 3249 | 3249 | $fees = $this->get_fees(); |
| 3250 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
| 3250 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
| 3251 | 3251 | } |
| 3252 | 3252 | |
| 3253 | 3253 | /** |
@@ -3255,11 +3255,11 @@ discard block |
||
| 3255 | 3255 | * |
| 3256 | 3256 | * @since 1.0.19 |
| 3257 | 3257 | */ |
| 3258 | - public function remove_fee( $fee ) { |
|
| 3258 | + public function remove_fee($fee) { |
|
| 3259 | 3259 | $fees = $this->get_fees(); |
| 3260 | - if ( isset( $fees[ $fee ] ) ) { |
|
| 3261 | - unset( $fees[ $fee ] ); |
|
| 3262 | - $this->set_prop( 'fees', $fees ); |
|
| 3260 | + if (isset($fees[$fee])) { |
|
| 3261 | + unset($fees[$fee]); |
|
| 3262 | + $this->set_prop('fees', $fees); |
|
| 3263 | 3263 | } |
| 3264 | 3264 | } |
| 3265 | 3265 | |
@@ -3269,11 +3269,11 @@ discard block |
||
| 3269 | 3269 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
| 3270 | 3270 | * @since 1.0.19 |
| 3271 | 3271 | */ |
| 3272 | - public function add_discount( $discount ) { |
|
| 3272 | + public function add_discount($discount) { |
|
| 3273 | 3273 | |
| 3274 | 3274 | $discounts = $this->get_discounts(); |
| 3275 | - $discounts[ $discount['name'] ] = $discount; |
|
| 3276 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3275 | + $discounts[$discount['name']] = $discount; |
|
| 3276 | + $this->set_prop('discounts', $discounts); |
|
| 3277 | 3277 | |
| 3278 | 3278 | } |
| 3279 | 3279 | |
@@ -3283,15 +3283,15 @@ discard block |
||
| 3283 | 3283 | * @since 1.0.19 |
| 3284 | 3284 | * @return float |
| 3285 | 3285 | */ |
| 3286 | - public function get_discount( $discount = false ) { |
|
| 3286 | + public function get_discount($discount = false) { |
|
| 3287 | 3287 | |
| 3288 | 3288 | // Backwards compatibilty. |
| 3289 | - if ( empty( $discount ) ) { |
|
| 3289 | + if (empty($discount)) { |
|
| 3290 | 3290 | return $this->get_total_discount(); |
| 3291 | 3291 | } |
| 3292 | 3292 | |
| 3293 | 3293 | $discounts = $this->get_discounts(); |
| 3294 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
| 3294 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
| 3295 | 3295 | } |
| 3296 | 3296 | |
| 3297 | 3297 | /** |
@@ -3299,11 +3299,11 @@ discard block |
||
| 3299 | 3299 | * |
| 3300 | 3300 | * @since 1.0.19 |
| 3301 | 3301 | */ |
| 3302 | - public function remove_discount( $discount ) { |
|
| 3302 | + public function remove_discount($discount) { |
|
| 3303 | 3303 | $discounts = $this->get_discounts(); |
| 3304 | - if ( isset( $discounts[ $discount ] ) ) { |
|
| 3305 | - unset( $discounts[ $discount ] ); |
|
| 3306 | - $this->set_prop( 'discounts', $discounts ); |
|
| 3304 | + if (isset($discounts[$discount])) { |
|
| 3305 | + unset($discounts[$discount]); |
|
| 3306 | + $this->set_prop('discounts', $discounts); |
|
| 3307 | 3307 | } |
| 3308 | 3308 | } |
| 3309 | 3309 | |
@@ -3312,12 +3312,12 @@ discard block |
||
| 3312 | 3312 | * |
| 3313 | 3313 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
| 3314 | 3314 | */ |
| 3315 | - public function add_tax( $tax ) { |
|
| 3316 | - if ( $this->is_taxable() ) { |
|
| 3315 | + public function add_tax($tax) { |
|
| 3316 | + if ($this->is_taxable()) { |
|
| 3317 | 3317 | |
| 3318 | - $taxes = $this->get_taxes(); |
|
| 3319 | - $taxes[ $tax['name'] ] = $tax; |
|
| 3320 | - $this->set_prop( 'taxes', $tax ); |
|
| 3318 | + $taxes = $this->get_taxes(); |
|
| 3319 | + $taxes[$tax['name']] = $tax; |
|
| 3320 | + $this->set_prop('taxes', $tax); |
|
| 3321 | 3321 | |
| 3322 | 3322 | } |
| 3323 | 3323 | } |
@@ -3327,15 +3327,15 @@ discard block |
||
| 3327 | 3327 | * |
| 3328 | 3328 | * @since 1.0.19 |
| 3329 | 3329 | */ |
| 3330 | - public function get_tax( $tax = null ) { |
|
| 3330 | + public function get_tax($tax = null) { |
|
| 3331 | 3331 | |
| 3332 | 3332 | // Backwards compatility. |
| 3333 | - if ( empty( $tax ) ) { |
|
| 3333 | + if (empty($tax)) { |
|
| 3334 | 3334 | return $this->get_total_tax(); |
| 3335 | 3335 | } |
| 3336 | 3336 | |
| 3337 | 3337 | $taxes = $this->get_taxes(); |
| 3338 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
| 3338 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
| 3339 | 3339 | } |
| 3340 | 3340 | |
| 3341 | 3341 | /** |
@@ -3343,11 +3343,11 @@ discard block |
||
| 3343 | 3343 | * |
| 3344 | 3344 | * @since 1.0.19 |
| 3345 | 3345 | */ |
| 3346 | - public function remove_tax( $tax ) { |
|
| 3346 | + public function remove_tax($tax) { |
|
| 3347 | 3347 | $taxes = $this->get_taxes(); |
| 3348 | - if ( isset( $taxes[ $tax ] ) ) { |
|
| 3349 | - unset( $taxes[ $tax ] ); |
|
| 3350 | - $this->set_prop( 'taxes', $taxes ); |
|
| 3348 | + if (isset($taxes[$tax])) { |
|
| 3349 | + unset($taxes[$tax]); |
|
| 3350 | + $this->set_prop('taxes', $taxes); |
|
| 3351 | 3351 | } |
| 3352 | 3352 | } |
| 3353 | 3353 | |
@@ -3358,17 +3358,17 @@ discard block |
||
| 3358 | 3358 | * @return float The recalculated subtotal |
| 3359 | 3359 | */ |
| 3360 | 3360 | public function recalculate_subtotal() { |
| 3361 | - $items = $this->get_items(); |
|
| 3361 | + $items = $this->get_items(); |
|
| 3362 | 3362 | $subtotal = 0; |
| 3363 | 3363 | $recurring = 0; |
| 3364 | 3364 | |
| 3365 | - foreach ( $items as $item ) { |
|
| 3365 | + foreach ($items as $item) { |
|
| 3366 | 3366 | $subtotal += $item->get_sub_total(); |
| 3367 | 3367 | $recurring += $item->get_recurring_sub_total(); |
| 3368 | 3368 | } |
| 3369 | 3369 | |
| 3370 | 3370 | $current = $this->is_renewal() ? $recurring : $subtotal; |
| 3371 | - $this->set_subtotal( $current ); |
|
| 3371 | + $this->set_subtotal($current); |
|
| 3372 | 3372 | |
| 3373 | 3373 | $this->totals['subtotal'] = array( |
| 3374 | 3374 | 'initial' => $subtotal, |
@@ -3389,14 +3389,14 @@ discard block |
||
| 3389 | 3389 | $discount = 0; |
| 3390 | 3390 | $recurring = 0; |
| 3391 | 3391 | |
| 3392 | - foreach ( $discounts as $data ) { |
|
| 3393 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
| 3394 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
| 3392 | + foreach ($discounts as $data) { |
|
| 3393 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
| 3394 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
| 3395 | 3395 | } |
| 3396 | 3396 | |
| 3397 | 3397 | $current = $this->is_renewal() ? $recurring : $discount; |
| 3398 | 3398 | |
| 3399 | - $this->set_total_discount( $current ); |
|
| 3399 | + $this->set_total_discount($current); |
|
| 3400 | 3400 | |
| 3401 | 3401 | $this->totals['discount'] = array( |
| 3402 | 3402 | 'initial' => $discount, |
@@ -3414,17 +3414,17 @@ discard block |
||
| 3414 | 3414 | * @return float The recalculated tax |
| 3415 | 3415 | */ |
| 3416 | 3416 | public function recalculate_total_tax() { |
| 3417 | - $taxes = $this->get_taxes(); |
|
| 3417 | + $taxes = $this->get_taxes(); |
|
| 3418 | 3418 | $tax = 0; |
| 3419 | 3419 | $recurring = 0; |
| 3420 | 3420 | |
| 3421 | - foreach ( $taxes as $data ) { |
|
| 3422 | - $tax += wpinv_sanitize_amount( $data['initial_tax'] ); |
|
| 3423 | - $recurring += wpinv_sanitize_amount( $data['recurring_tax'] ); |
|
| 3421 | + foreach ($taxes as $data) { |
|
| 3422 | + $tax += wpinv_sanitize_amount($data['initial_tax']); |
|
| 3423 | + $recurring += wpinv_sanitize_amount($data['recurring_tax']); |
|
| 3424 | 3424 | } |
| 3425 | 3425 | |
| 3426 | 3426 | $current = $this->is_renewal() ? $recurring : $tax; |
| 3427 | - $this->set_total_tax( $current ); |
|
| 3427 | + $this->set_total_tax($current); |
|
| 3428 | 3428 | |
| 3429 | 3429 | $this->totals['tax'] = array( |
| 3430 | 3430 | 'initial' => $tax, |
@@ -3446,20 +3446,20 @@ discard block |
||
| 3446 | 3446 | $fee = 0; |
| 3447 | 3447 | $recurring = 0; |
| 3448 | 3448 | |
| 3449 | - foreach ( $fees as $data ) { |
|
| 3450 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
| 3451 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
| 3449 | + foreach ($fees as $data) { |
|
| 3450 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
| 3451 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
| 3452 | 3452 | } |
| 3453 | 3453 | |
| 3454 | 3454 | $current = $this->is_renewal() ? $recurring : $fee; |
| 3455 | - $this->set_total_fees( $current ); |
|
| 3455 | + $this->set_total_fees($current); |
|
| 3456 | 3456 | |
| 3457 | 3457 | $this->totals['fee'] = array( |
| 3458 | 3458 | 'initial' => $fee, |
| 3459 | 3459 | 'recurring' => $recurring, |
| 3460 | 3460 | ); |
| 3461 | 3461 | |
| 3462 | - $this->set_total_fees( $fee ); |
|
| 3462 | + $this->set_total_fees($fee); |
|
| 3463 | 3463 | return $current; |
| 3464 | 3464 | } |
| 3465 | 3465 | |
@@ -3480,9 +3480,9 @@ discard block |
||
| 3480 | 3480 | /** |
| 3481 | 3481 | * @deprecated |
| 3482 | 3482 | */ |
| 3483 | - public function recalculate_totals( $temp = false ) { |
|
| 3484 | - $this->update_items( $temp ); |
|
| 3485 | - $this->save( true ); |
|
| 3483 | + public function recalculate_totals($temp = false) { |
|
| 3484 | + $this->update_items($temp); |
|
| 3485 | + $this->save(true); |
|
| 3486 | 3486 | return $this; |
| 3487 | 3487 | } |
| 3488 | 3488 | |
@@ -3500,10 +3500,10 @@ discard block |
||
| 3500 | 3500 | * @return int|false The new note's ID on success, false on failure. |
| 3501 | 3501 | * |
| 3502 | 3502 | */ |
| 3503 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
| 3503 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
| 3504 | 3504 | |
| 3505 | 3505 | // Bail if no note specified or this invoice is not yet saved. |
| 3506 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
| 3506 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
| 3507 | 3507 | return false; |
| 3508 | 3508 | } |
| 3509 | 3509 | |
@@ -3511,23 +3511,23 @@ discard block |
||
| 3511 | 3511 | $author_email = '[email protected]'; |
| 3512 | 3512 | |
| 3513 | 3513 | // If this is an admin comment or it has been added by the user. |
| 3514 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
| 3515 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
| 3514 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
| 3515 | + $user = get_user_by('id', get_current_user_id()); |
|
| 3516 | 3516 | $author = $user->display_name; |
| 3517 | 3517 | $author_email = $user->user_email; |
| 3518 | 3518 | } |
| 3519 | 3519 | |
| 3520 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
| 3520 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
| 3521 | 3521 | |
| 3522 | 3522 | } |
| 3523 | 3523 | |
| 3524 | 3524 | /** |
| 3525 | 3525 | * Generates a unique key for the invoice. |
| 3526 | 3526 | */ |
| 3527 | - public function generate_key( $string = '' ) { |
|
| 3528 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 3527 | + public function generate_key($string = '') { |
|
| 3528 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 3529 | 3529 | return strtolower( |
| 3530 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
| 3530 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
| 3531 | 3531 | ); |
| 3532 | 3532 | } |
| 3533 | 3533 | |
@@ -3537,11 +3537,11 @@ discard block |
||
| 3537 | 3537 | public function generate_number() { |
| 3538 | 3538 | $number = $this->get_id(); |
| 3539 | 3539 | |
| 3540 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
| 3541 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
| 3540 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
| 3541 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
| 3542 | 3542 | } |
| 3543 | 3543 | |
| 3544 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
| 3544 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
| 3545 | 3545 | |
| 3546 | 3546 | } |
| 3547 | 3547 | |
@@ -3554,55 +3554,55 @@ discard block |
||
| 3554 | 3554 | // Reset status transition variable. |
| 3555 | 3555 | $this->status_transition = false; |
| 3556 | 3556 | |
| 3557 | - if ( $status_transition ) { |
|
| 3557 | + if ($status_transition) { |
|
| 3558 | 3558 | try { |
| 3559 | 3559 | |
| 3560 | 3560 | // Fire a hook for the status change. |
| 3561 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
| 3561 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
| 3562 | 3562 | |
| 3563 | 3563 | // @deprecated this is deprecated and will be removed in the future. |
| 3564 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3564 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3565 | 3565 | |
| 3566 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 3566 | + if (!empty($status_transition['from'])) { |
|
| 3567 | 3567 | |
| 3568 | 3568 | /* translators: 1: old invoice status 2: new invoice status */ |
| 3569 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3569 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
| 3570 | 3570 | |
| 3571 | 3571 | // Fire another hook. |
| 3572 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
| 3573 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 3572 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
| 3573 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
| 3574 | 3574 | |
| 3575 | 3575 | // @deprecated this is deprecated and will be removed in the future. |
| 3576 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
| 3576 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
| 3577 | 3577 | |
| 3578 | 3578 | // Note the transition occurred. |
| 3579 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
| 3579 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
| 3580 | 3580 | |
| 3581 | 3581 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
| 3582 | 3582 | if ( |
| 3583 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3584 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3583 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3584 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3585 | 3585 | ) { |
| 3586 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
| 3586 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
| 3587 | 3587 | } |
| 3588 | 3588 | |
| 3589 | 3589 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
| 3590 | 3590 | if ( |
| 3591 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
| 3592 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
| 3591 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
| 3592 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
| 3593 | 3593 | ) { |
| 3594 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
| 3594 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
| 3595 | 3595 | } |
| 3596 | 3596 | } else { |
| 3597 | 3597 | /* translators: %s: new invoice status */ |
| 3598 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
| 3598 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
| 3599 | 3599 | |
| 3600 | 3600 | // Note the transition occurred. |
| 3601 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
| 3601 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
| 3602 | 3602 | |
| 3603 | 3603 | } |
| 3604 | - } catch ( Exception $e ) { |
|
| 3605 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 3604 | + } catch (Exception $e) { |
|
| 3605 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
| 3606 | 3606 | } |
| 3607 | 3607 | } |
| 3608 | 3608 | } |
@@ -3610,13 +3610,13 @@ discard block |
||
| 3610 | 3610 | /** |
| 3611 | 3611 | * Updates an invoice status. |
| 3612 | 3612 | */ |
| 3613 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
| 3613 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
| 3614 | 3614 | |
| 3615 | 3615 | // Fires before updating a status. |
| 3616 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
| 3616 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
| 3617 | 3617 | |
| 3618 | 3618 | // Update the status. |
| 3619 | - $this->set_status( $new_status, $note, $manual ); |
|
| 3619 | + $this->set_status($new_status, $note, $manual); |
|
| 3620 | 3620 | |
| 3621 | 3621 | // Save the order. |
| 3622 | 3622 | return $this->save(); |
@@ -3627,18 +3627,18 @@ discard block |
||
| 3627 | 3627 | * @deprecated |
| 3628 | 3628 | */ |
| 3629 | 3629 | public function refresh_item_ids() { |
| 3630 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
| 3631 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
| 3630 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
| 3631 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
| 3632 | 3632 | } |
| 3633 | 3633 | |
| 3634 | 3634 | /** |
| 3635 | 3635 | * @deprecated |
| 3636 | 3636 | */ |
| 3637 | - public function update_items( $temp = false ) { |
|
| 3637 | + public function update_items($temp = false) { |
|
| 3638 | 3638 | |
| 3639 | - $this->set_items( $this->get_items() ); |
|
| 3639 | + $this->set_items($this->get_items()); |
|
| 3640 | 3640 | |
| 3641 | - if ( ! $temp ) { |
|
| 3641 | + if (!$temp) { |
|
| 3642 | 3642 | $this->save(); |
| 3643 | 3643 | } |
| 3644 | 3644 | |
@@ -3652,11 +3652,11 @@ discard block |
||
| 3652 | 3652 | |
| 3653 | 3653 | $discount_code = $this->get_discount_code(); |
| 3654 | 3654 | |
| 3655 | - if ( empty( $discount_code ) ) { |
|
| 3655 | + if (empty($discount_code)) { |
|
| 3656 | 3656 | return false; |
| 3657 | 3657 | } |
| 3658 | 3658 | |
| 3659 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
| 3659 | + $discount = wpinv_get_discount_obj($discount_code); |
|
| 3660 | 3660 | |
| 3661 | 3661 | // Ensure it is active. |
| 3662 | 3662 | return $discount->exists(); |
@@ -3667,7 +3667,7 @@ discard block |
||
| 3667 | 3667 | * Refunds an invoice. |
| 3668 | 3668 | */ |
| 3669 | 3669 | public function refund() { |
| 3670 | - $this->set_status( 'wpi-refunded' ); |
|
| 3670 | + $this->set_status('wpi-refunded'); |
|
| 3671 | 3671 | $this->save(); |
| 3672 | 3672 | } |
| 3673 | 3673 | |
@@ -3676,56 +3676,56 @@ discard block |
||
| 3676 | 3676 | * |
| 3677 | 3677 | * @param string $transaction_id |
| 3678 | 3678 | */ |
| 3679 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
| 3679 | + public function mark_paid($transaction_id = null, $note = '') { |
|
| 3680 | 3680 | |
| 3681 | 3681 | // Set the transaction id. |
| 3682 | - if ( empty( $transaction_id ) ) { |
|
| 3682 | + if (empty($transaction_id)) { |
|
| 3683 | 3683 | $transaction_id = $this->generate_key('trans_'); |
| 3684 | 3684 | } |
| 3685 | 3685 | |
| 3686 | - if ( ! $this->get_transaction_id() ) { |
|
| 3687 | - $this->set_transaction_id( $transaction_id ); |
|
| 3686 | + if (!$this->get_transaction_id()) { |
|
| 3687 | + $this->set_transaction_id($transaction_id); |
|
| 3688 | 3688 | } |
| 3689 | 3689 | |
| 3690 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
| 3690 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
| 3691 | 3691 | return $this->save(); |
| 3692 | 3692 | } |
| 3693 | 3693 | |
| 3694 | 3694 | // Set the completed date. |
| 3695 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
| 3695 | + $this->set_date_completed(current_time('mysql')); |
|
| 3696 | 3696 | |
| 3697 | 3697 | // Set the new status. |
| 3698 | - if ( $this->is_renewal() ) { |
|
| 3698 | + if ($this->is_renewal()) { |
|
| 3699 | 3699 | |
| 3700 | 3700 | $_note = sprintf( |
| 3701 | - __( 'Renewed via %s', 'invoicing' ), |
|
| 3702 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3701 | + __('Renewed via %s', 'invoicing'), |
|
| 3702 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3703 | 3703 | ); |
| 3704 | 3704 | |
| 3705 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3705 | + if ('none' == $this->get_gateway()) { |
|
| 3706 | 3706 | $_note = $note; |
| 3707 | 3707 | } |
| 3708 | 3708 | |
| 3709 | - $this->set_status( 'wpi-renewal', $_note ); |
|
| 3709 | + $this->set_status('wpi-renewal', $_note); |
|
| 3710 | 3710 | |
| 3711 | 3711 | } else { |
| 3712 | 3712 | |
| 3713 | 3713 | $_note = sprintf( |
| 3714 | - __( 'Paid via %s', 'invoicing' ), |
|
| 3715 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
| 3714 | + __('Paid via %s', 'invoicing'), |
|
| 3715 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
| 3716 | 3716 | ); |
| 3717 | 3717 | |
| 3718 | - if ( 'none' == $this->get_gateway() ) { |
|
| 3718 | + if ('none' == $this->get_gateway()) { |
|
| 3719 | 3719 | $_note = $note; |
| 3720 | 3720 | } |
| 3721 | 3721 | |
| 3722 | - $this->set_status( 'publish',$_note ); |
|
| 3722 | + $this->set_status('publish', $_note); |
|
| 3723 | 3723 | |
| 3724 | 3724 | } |
| 3725 | 3725 | |
| 3726 | 3726 | // Set checkout mode. |
| 3727 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
| 3728 | - $this->set_mode( $mode ); |
|
| 3727 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
| 3728 | + $this->set_mode($mode); |
|
| 3729 | 3729 | |
| 3730 | 3730 | // Save the invoice. |
| 3731 | 3731 | $this->save(); |
@@ -3751,9 +3751,9 @@ discard block |
||
| 3751 | 3751 | * Clears the subscription's cache. |
| 3752 | 3752 | */ |
| 3753 | 3753 | public function clear_cache() { |
| 3754 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
| 3755 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
| 3756 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
| 3754 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
| 3755 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
| 3756 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
| 3757 | 3757 | } |
| 3758 | 3758 | |
| 3759 | 3759 | } |
@@ -12,46 +12,46 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Reports { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class constructor. |
|
| 17 | - * |
|
| 18 | - */ |
|
| 19 | - public function __construct() { |
|
| 20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
| 21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
| 22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Registers the reports page. |
|
| 27 | - * |
|
| 28 | - */ |
|
| 29 | - public function register_reports_page() { |
|
| 30 | - |
|
| 31 | - add_submenu_page( |
|
| 15 | + /** |
|
| 16 | + * Class constructor. |
|
| 17 | + * |
|
| 18 | + */ |
|
| 19 | + public function __construct() { |
|
| 20 | + add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
| 21 | + add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
| 22 | + add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Registers the reports page. |
|
| 27 | + * |
|
| 28 | + */ |
|
| 29 | + public function register_reports_page() { |
|
| 30 | + |
|
| 31 | + add_submenu_page( |
|
| 32 | 32 | 'wpinv', |
| 33 | 33 | __( 'Reports', 'invoicing' ), |
| 34 | 34 | __( 'Reports', 'invoicing' ), |
| 35 | 35 | wpinv_get_capability(), |
| 36 | 36 | 'wpinv-reports', |
| 37 | 37 | array( $this, 'display_reports_page' ) |
| 38 | - ); |
|
| 38 | + ); |
|
| 39 | 39 | |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Displays the reports page. |
|
| 44 | - * |
|
| 45 | - */ |
|
| 46 | - public function display_reports_page() { |
|
| 42 | + /** |
|
| 43 | + * Displays the reports page. |
|
| 44 | + * |
|
| 45 | + */ |
|
| 46 | + public function display_reports_page() { |
|
| 47 | 47 | |
| 48 | - // Prepare variables. |
|
| 49 | - $tabs = $this->get_tabs(); |
|
| 50 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
| 51 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
| 48 | + // Prepare variables. |
|
| 49 | + $tabs = $this->get_tabs(); |
|
| 50 | + $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
| 51 | + $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
| 52 | 52 | |
| 53 | - // Display the current tab. |
|
| 54 | - ?> |
|
| 53 | + // Display the current tab. |
|
| 54 | + ?> |
|
| 55 | 55 | |
| 56 | 56 | <div class="wrap"> |
| 57 | 57 | |
@@ -60,19 +60,19 @@ discard block |
||
| 60 | 60 | <nav class="nav-tab-wrapper"> |
| 61 | 61 | |
| 62 | 62 | <?php |
| 63 | - foreach( $tabs as $key => $label ) { |
|
| 63 | + foreach( $tabs as $key => $label ) { |
|
| 64 | 64 | |
| 65 | - $key = sanitize_text_field( $key ); |
|
| 66 | - $label = sanitize_text_field( $label ); |
|
| 67 | - $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
| 68 | - $url = esc_url( |
|
| 69 | - add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
| 70 | - ); |
|
| 65 | + $key = sanitize_text_field( $key ); |
|
| 66 | + $label = sanitize_text_field( $label ); |
|
| 67 | + $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
|
| 68 | + $url = esc_url( |
|
| 69 | + add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
| 70 | + ); |
|
| 71 | 71 | |
| 72 | - echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
| 72 | + echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
|
| 73 | 73 | |
| 74 | - } |
|
| 75 | - ?> |
|
| 74 | + } |
|
| 75 | + ?> |
|
| 76 | 76 | |
| 77 | 77 | </nav> |
| 78 | 78 | |
@@ -83,46 +83,46 @@ discard block |
||
| 83 | 83 | </div> |
| 84 | 84 | <?php |
| 85 | 85 | |
| 86 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
|
| 87 | - wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
|
| 86 | + wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
|
| 87 | + wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
|
| 88 | 88 | |
| 89 | - } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Retrieves reports page tabs. |
|
| 93 | - * |
|
| 94 | - * @return array |
|
| 95 | - */ |
|
| 96 | - public function get_tabs() { |
|
| 91 | + /** |
|
| 92 | + * Retrieves reports page tabs. |
|
| 93 | + * |
|
| 94 | + * @return array |
|
| 95 | + */ |
|
| 96 | + public function get_tabs() { |
|
| 97 | 97 | |
| 98 | - $tabs = array( |
|
| 99 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
| 100 | - 'export' => __( 'Export', 'invoicing' ), |
|
| 101 | - ); |
|
| 98 | + $tabs = array( |
|
| 99 | + 'reports' => __( 'Reports', 'invoicing' ), |
|
| 100 | + 'export' => __( 'Export', 'invoicing' ), |
|
| 101 | + ); |
|
| 102 | 102 | |
| 103 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
| 104 | - } |
|
| 103 | + return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Displays the reports tab. |
|
| 108 | - * |
|
| 109 | - */ |
|
| 110 | - public function display_reports_tab() { |
|
| 106 | + /** |
|
| 107 | + * Displays the reports tab. |
|
| 108 | + * |
|
| 109 | + */ |
|
| 110 | + public function display_reports_tab() { |
|
| 111 | 111 | |
| 112 | - $reports = new GetPaid_Reports_Report(); |
|
| 113 | - $reports->display(); |
|
| 112 | + $reports = new GetPaid_Reports_Report(); |
|
| 113 | + $reports->display(); |
|
| 114 | 114 | |
| 115 | - } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Displays the exports tab. |
|
| 119 | - * |
|
| 120 | - */ |
|
| 121 | - public function display_exports_tab() { |
|
| 117 | + /** |
|
| 118 | + * Displays the exports tab. |
|
| 119 | + * |
|
| 120 | + */ |
|
| 121 | + public function display_exports_tab() { |
|
| 122 | 122 | |
| 123 | - $exports = new GetPaid_Reports_Export(); |
|
| 124 | - $exports->display(); |
|
| 123 | + $exports = new GetPaid_Reports_Export(); |
|
| 124 | + $exports->display(); |
|
| 125 | 125 | |
| 126 | - } |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | 128 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * GetPaid_Reports Class. |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | 19 | public function __construct() { |
| 20 | - add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 ); |
|
| 21 | - add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) ); |
|
| 22 | - add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) ); |
|
| 20 | + add_action('admin_menu', array($this, 'register_reports_page'), 20); |
|
| 21 | + add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab')); |
|
| 22 | + add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab')); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | add_submenu_page( |
| 32 | 32 | 'wpinv', |
| 33 | - __( 'Reports', 'invoicing' ), |
|
| 34 | - __( 'Reports', 'invoicing' ), |
|
| 33 | + __('Reports', 'invoicing'), |
|
| 34 | + __('Reports', 'invoicing'), |
|
| 35 | 35 | wpinv_get_capability(), |
| 36 | 36 | 'wpinv-reports', |
| 37 | - array( $this, 'display_reports_page' ) |
|
| 37 | + array($this, 'display_reports_page') |
|
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | } |
@@ -47,26 +47,26 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | // Prepare variables. |
| 49 | 49 | $tabs = $this->get_tabs(); |
| 50 | - $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports'; |
|
| 51 | - $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports'; |
|
| 50 | + $current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports'; |
|
| 51 | + $current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports'; |
|
| 52 | 52 | |
| 53 | 53 | // Display the current tab. |
| 54 | 54 | ?> |
| 55 | 55 | |
| 56 | 56 | <div class="wrap"> |
| 57 | 57 | |
| 58 | - <h1><?php echo sanitize_text_field( $tabs[ $current_tab ] ); ?></h1> |
|
| 58 | + <h1><?php echo sanitize_text_field($tabs[$current_tab]); ?></h1> |
|
| 59 | 59 | |
| 60 | 60 | <nav class="nav-tab-wrapper"> |
| 61 | 61 | |
| 62 | 62 | <?php |
| 63 | - foreach( $tabs as $key => $label ) { |
|
| 63 | + foreach ($tabs as $key => $label) { |
|
| 64 | 64 | |
| 65 | - $key = sanitize_text_field( $key ); |
|
| 66 | - $label = sanitize_text_field( $label ); |
|
| 65 | + $key = sanitize_text_field($key); |
|
| 66 | + $label = sanitize_text_field($label); |
|
| 67 | 67 | $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab'; |
| 68 | 68 | $url = esc_url( |
| 69 | - add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) ) |
|
| 69 | + add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports')) |
|
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | 72 | echo "\n\t\t\t<a href='$url' class='$class'>$label</a>"; |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | </nav> |
| 78 | 78 | |
| 79 | - <div class="bsui <?php echo esc_attr( $current_tab ); ?>"> |
|
| 80 | - <?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?> |
|
| 79 | + <div class="bsui <?php echo esc_attr($current_tab); ?>"> |
|
| 80 | + <?php do_action("wpinv_reports_tab_{$current_tab}"); ?> |
|
| 81 | 81 | </div> |
| 82 | 82 | |
| 83 | 83 | </div> |
| 84 | 84 | <?php |
| 85 | 85 | |
| 86 | - wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true ); |
|
| 87 | - wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' ); |
|
| 86 | + wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array('jquery'), '2.9.4', true); |
|
| 87 | + wp_enqueue_style('chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4'); |
|
| 88 | 88 | |
| 89 | 89 | } |
| 90 | 90 | |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | public function get_tabs() { |
| 97 | 97 | |
| 98 | 98 | $tabs = array( |
| 99 | - 'reports' => __( 'Reports', 'invoicing' ), |
|
| 100 | - 'export' => __( 'Export', 'invoicing' ), |
|
| 99 | + 'reports' => __('Reports', 'invoicing'), |
|
| 100 | + 'export' => __('Export', 'invoicing'), |
|
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | - return apply_filters( 'getpaid_report_tabs', $tabs ); |
|
| 103 | + return apply_filters('getpaid_report_tabs', $tabs); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -12,72 +12,72 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | abstract class GetPaid_Reports_Abstract_Report { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var array |
|
| 17 | - */ |
|
| 18 | - public $stats; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Class constructor. |
|
| 22 | - * |
|
| 23 | - */ |
|
| 24 | - public function __construct() { |
|
| 25 | - $this->prepare_stats(); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Retrieves the current range. |
|
| 30 | - * |
|
| 31 | - */ |
|
| 32 | - public function get_range() { |
|
| 33 | - $valid_ranges = $this->get_periods(); |
|
| 34 | - |
|
| 35 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
| 36 | - return sanitize_key( $_GET['date_range'] ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - return '7_days'; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Returns an array of date ranges. |
|
| 44 | - * |
|
| 45 | - * @return array |
|
| 46 | - */ |
|
| 47 | - public function get_periods() { |
|
| 48 | - |
|
| 49 | - $periods = array( |
|
| 15 | + /** |
|
| 16 | + * @var array |
|
| 17 | + */ |
|
| 18 | + public $stats; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Class constructor. |
|
| 22 | + * |
|
| 23 | + */ |
|
| 24 | + public function __construct() { |
|
| 25 | + $this->prepare_stats(); |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Retrieves the current range. |
|
| 30 | + * |
|
| 31 | + */ |
|
| 32 | + public function get_range() { |
|
| 33 | + $valid_ranges = $this->get_periods(); |
|
| 34 | + |
|
| 35 | + if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
| 36 | + return sanitize_key( $_GET['date_range'] ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + return '7_days'; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Returns an array of date ranges. |
|
| 44 | + * |
|
| 45 | + * @return array |
|
| 46 | + */ |
|
| 47 | + public function get_periods() { |
|
| 48 | + |
|
| 49 | + $periods = array( |
|
| 50 | 50 | 'today' => __( 'Today', 'invoicing' ), |
| 51 | 51 | 'yesterday' => __( 'Yesterday', 'invoicing' ), |
| 52 | 52 | '7_days' => __( 'Last 7 days', 'invoicing' ), |
| 53 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
| 54 | - '60_days' => __( 'Last 60 days', 'invoicing' ), |
|
| 55 | - '90_days' => __( 'Last 90 days', 'invoicing' ), |
|
| 56 | - '180_days' => __( 'Last 180 days', 'invoicing' ), |
|
| 57 | - '360_days' => __( 'Last 360 days', 'invoicing' ), |
|
| 58 | - ); |
|
| 59 | - |
|
| 60 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Retrieves the current range's sql. |
|
| 65 | - * |
|
| 66 | - */ |
|
| 67 | - public function get_range_sql( $range ) { |
|
| 68 | - |
|
| 69 | - $date = 'CAST(meta.completed_date AS DATE)'; |
|
| 53 | + '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
| 54 | + '60_days' => __( 'Last 60 days', 'invoicing' ), |
|
| 55 | + '90_days' => __( 'Last 90 days', 'invoicing' ), |
|
| 56 | + '180_days' => __( 'Last 180 days', 'invoicing' ), |
|
| 57 | + '360_days' => __( 'Last 360 days', 'invoicing' ), |
|
| 58 | + ); |
|
| 59 | + |
|
| 60 | + return apply_filters( 'getpaid_earning_periods', $periods ); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Retrieves the current range's sql. |
|
| 65 | + * |
|
| 66 | + */ |
|
| 67 | + public function get_range_sql( $range ) { |
|
| 68 | + |
|
| 69 | + $date = 'CAST(meta.completed_date AS DATE)'; |
|
| 70 | 70 | $datetime = 'meta.completed_date'; |
| 71 | 71 | |
| 72 | 72 | // Prepare durations. |
| 73 | 73 | $today = current_time( 'Y-m-d' ); |
| 74 | - $yesterday = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) ); |
|
| 75 | - $seven_days_ago = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) ); |
|
| 76 | - $thirty_days_ago = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) ); |
|
| 77 | - $ninety_days_ago = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) ); |
|
| 78 | - $sixty_days_ago = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) ); |
|
| 79 | - $one_eighty_days_ago = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) ); |
|
| 80 | - $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) ); |
|
| 74 | + $yesterday = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) ); |
|
| 75 | + $seven_days_ago = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) ); |
|
| 76 | + $thirty_days_ago = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) ); |
|
| 77 | + $ninety_days_ago = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) ); |
|
| 78 | + $sixty_days_ago = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) ); |
|
| 79 | + $one_eighty_days_ago = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) ); |
|
| 80 | + $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) ); |
|
| 81 | 81 | |
| 82 | 82 | $ranges = array( |
| 83 | 83 | |
@@ -94,130 +94,130 @@ discard block |
||
| 94 | 94 | '7_days' => array( |
| 95 | 95 | "DATE($datetime)", |
| 96 | 96 | "$date BETWEEN '$seven_days_ago' AND '$today'" |
| 97 | - ), |
|
| 97 | + ), |
|
| 98 | 98 | |
| 99 | - '30_days' => array( |
|
| 99 | + '30_days' => array( |
|
| 100 | 100 | "DATE($datetime)", |
| 101 | 101 | "$date BETWEEN '$thirty_days_ago' AND '$today'" |
| 102 | - ), |
|
| 102 | + ), |
|
| 103 | 103 | |
| 104 | - '60_days' => array( |
|
| 104 | + '60_days' => array( |
|
| 105 | 105 | "DATE($datetime)", |
| 106 | 106 | "$date BETWEEN '$sixty_days_ago' AND '$today'" |
| 107 | - ), |
|
| 107 | + ), |
|
| 108 | 108 | |
| 109 | - '90_days' => array( |
|
| 109 | + '90_days' => array( |
|
| 110 | 110 | "WEEK($datetime)", |
| 111 | 111 | "$date BETWEEN '$ninety_days_ago' AND '$today'" |
| 112 | - ), |
|
| 112 | + ), |
|
| 113 | 113 | |
| 114 | - '180_days' => array( |
|
| 114 | + '180_days' => array( |
|
| 115 | 115 | "WEEK($datetime)", |
| 116 | 116 | "$date BETWEEN '$one_eighty_days_ago' AND '$today'" |
| 117 | - ), |
|
| 117 | + ), |
|
| 118 | 118 | |
| 119 | - '360_days' => array( |
|
| 119 | + '360_days' => array( |
|
| 120 | 120 | "WEEK($datetime)", |
| 121 | 121 | "$date BETWEEN '$three_sixty_days_ago' AND '$today'" |
| 122 | 122 | ), |
| 123 | 123 | |
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ]; |
|
| 127 | - return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range ); |
|
| 128 | - |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Retrieves the hours in a day |
|
| 133 | - * |
|
| 134 | - */ |
|
| 135 | - public function get_hours_in_a_day() { |
|
| 136 | - |
|
| 137 | - return array( |
|
| 138 | - '12AM' => __( '12 AM', 'invoicing'), |
|
| 139 | - '1AM' => __( '1 AM', 'invoicing'), |
|
| 140 | - '2AM' => __( '2 AM', 'invoicing'), |
|
| 141 | - '3AM' => __( '3 AM', 'invoicing'), |
|
| 142 | - '4AM' => __( '4 AM', 'invoicing'), |
|
| 143 | - '5AM' => __( '5 AM', 'invoicing'), |
|
| 144 | - '6AM' => __( '6 AM', 'invoicing'), |
|
| 145 | - '7AM' => __( '7 AM', 'invoicing'), |
|
| 146 | - '8AM' => __( '8 AM', 'invoicing'), |
|
| 147 | - '9AM' => __( '9 AM', 'invoicing'), |
|
| 148 | - '10AM' => __( '10 AM', 'invoicing'), |
|
| 149 | - '11AM' => __( '11 AM', 'invoicing'), |
|
| 150 | - '12pm' => __( '12 PM', 'invoicing'), |
|
| 151 | - '1PM' => __( '1 PM', 'invoicing'), |
|
| 152 | - '2PM' => __( '2 PM', 'invoicing'), |
|
| 153 | - '3PM' => __( '3 PM', 'invoicing'), |
|
| 154 | - '4PM' => __( '4 PM', 'invoicing'), |
|
| 155 | - '5PM' => __( '5 PM', 'invoicing'), |
|
| 156 | - '6PM' => __( '6 PM', 'invoicing'), |
|
| 157 | - '7PM' => __( '7 PM', 'invoicing'), |
|
| 158 | - '8PM' => __( '8 PM', 'invoicing'), |
|
| 159 | - '9PM' => __( '9 PM', 'invoicing'), |
|
| 160 | - '10PM' => __( '10 PM', 'invoicing'), |
|
| 161 | - '11PM' => __( '11 PM', 'invoicing'), |
|
| 162 | - ); |
|
| 163 | - |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Retrieves the days in a period |
|
| 168 | - * |
|
| 169 | - */ |
|
| 170 | - public function get_days_in_period( $days ) { |
|
| 171 | - |
|
| 172 | - $return = array(); |
|
| 173 | - $format = 'Y-m-d'; |
|
| 174 | - |
|
| 175 | - if ( $days < 8 ) { |
|
| 176 | - $format = 'D'; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if ( $days < 32 ) { |
|
| 180 | - $format = 'M j'; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - while ( $days > 0 ) { |
|
| 184 | - |
|
| 185 | - $key = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 186 | - $label = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 187 | - $return[ $key ] = $label; |
|
| 188 | - $days--; |
|
| 189 | - |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - return $return; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Retrieves the weeks in a period |
|
| 197 | - * |
|
| 198 | - */ |
|
| 199 | - public function get_weeks_in_period( $days ) { |
|
| 200 | - |
|
| 201 | - $return = array(); |
|
| 202 | - |
|
| 203 | - while ( $days > 0 ) { |
|
| 204 | - |
|
| 205 | - $key = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 206 | - $label = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 207 | - $return[ $key ] = $label; |
|
| 208 | - $days--; |
|
| 209 | - |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - return $return; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Displays the report card. |
|
| 217 | - * |
|
| 218 | - */ |
|
| 219 | - public function display() { |
|
| 220 | - ?> |
|
| 126 | + $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ]; |
|
| 127 | + return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range ); |
|
| 128 | + |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Retrieves the hours in a day |
|
| 133 | + * |
|
| 134 | + */ |
|
| 135 | + public function get_hours_in_a_day() { |
|
| 136 | + |
|
| 137 | + return array( |
|
| 138 | + '12AM' => __( '12 AM', 'invoicing'), |
|
| 139 | + '1AM' => __( '1 AM', 'invoicing'), |
|
| 140 | + '2AM' => __( '2 AM', 'invoicing'), |
|
| 141 | + '3AM' => __( '3 AM', 'invoicing'), |
|
| 142 | + '4AM' => __( '4 AM', 'invoicing'), |
|
| 143 | + '5AM' => __( '5 AM', 'invoicing'), |
|
| 144 | + '6AM' => __( '6 AM', 'invoicing'), |
|
| 145 | + '7AM' => __( '7 AM', 'invoicing'), |
|
| 146 | + '8AM' => __( '8 AM', 'invoicing'), |
|
| 147 | + '9AM' => __( '9 AM', 'invoicing'), |
|
| 148 | + '10AM' => __( '10 AM', 'invoicing'), |
|
| 149 | + '11AM' => __( '11 AM', 'invoicing'), |
|
| 150 | + '12pm' => __( '12 PM', 'invoicing'), |
|
| 151 | + '1PM' => __( '1 PM', 'invoicing'), |
|
| 152 | + '2PM' => __( '2 PM', 'invoicing'), |
|
| 153 | + '3PM' => __( '3 PM', 'invoicing'), |
|
| 154 | + '4PM' => __( '4 PM', 'invoicing'), |
|
| 155 | + '5PM' => __( '5 PM', 'invoicing'), |
|
| 156 | + '6PM' => __( '6 PM', 'invoicing'), |
|
| 157 | + '7PM' => __( '7 PM', 'invoicing'), |
|
| 158 | + '8PM' => __( '8 PM', 'invoicing'), |
|
| 159 | + '9PM' => __( '9 PM', 'invoicing'), |
|
| 160 | + '10PM' => __( '10 PM', 'invoicing'), |
|
| 161 | + '11PM' => __( '11 PM', 'invoicing'), |
|
| 162 | + ); |
|
| 163 | + |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Retrieves the days in a period |
|
| 168 | + * |
|
| 169 | + */ |
|
| 170 | + public function get_days_in_period( $days ) { |
|
| 171 | + |
|
| 172 | + $return = array(); |
|
| 173 | + $format = 'Y-m-d'; |
|
| 174 | + |
|
| 175 | + if ( $days < 8 ) { |
|
| 176 | + $format = 'D'; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if ( $days < 32 ) { |
|
| 180 | + $format = 'M j'; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + while ( $days > 0 ) { |
|
| 184 | + |
|
| 185 | + $key = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 186 | + $label = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 187 | + $return[ $key ] = $label; |
|
| 188 | + $days--; |
|
| 189 | + |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + return $return; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Retrieves the weeks in a period |
|
| 197 | + * |
|
| 198 | + */ |
|
| 199 | + public function get_weeks_in_period( $days ) { |
|
| 200 | + |
|
| 201 | + $return = array(); |
|
| 202 | + |
|
| 203 | + while ( $days > 0 ) { |
|
| 204 | + |
|
| 205 | + $key = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 206 | + $label = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 207 | + $return[ $key ] = $label; |
|
| 208 | + $days--; |
|
| 209 | + |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + return $return; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Displays the report card. |
|
| 217 | + * |
|
| 218 | + */ |
|
| 219 | + public function display() { |
|
| 220 | + ?> |
|
| 221 | 221 | |
| 222 | 222 | <div class="row"> |
| 223 | 223 | <div class="col-12"> |
@@ -231,20 +231,20 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | <?php |
| 233 | 233 | |
| 234 | - } |
|
| 235 | - |
|
| 236 | - /** |
|
| 237 | - * Prepares the report stats. |
|
| 238 | - * |
|
| 239 | - * Extend this in child classes. |
|
| 240 | - */ |
|
| 241 | - abstract public function prepare_stats(); |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Displays the actual report. |
|
| 245 | - * |
|
| 246 | - * Extend this in child classes. |
|
| 247 | - */ |
|
| 248 | - abstract public function display_stats(); |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + /** |
|
| 237 | + * Prepares the report stats. |
|
| 238 | + * |
|
| 239 | + * Extend this in child classes. |
|
| 240 | + */ |
|
| 241 | + abstract public function prepare_stats(); |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Displays the actual report. |
|
| 245 | + * |
|
| 246 | + * Extend this in child classes. |
|
| 247 | + */ |
|
| 248 | + abstract public function display_stats(); |
|
| 249 | 249 | |
| 250 | 250 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * GetPaid_Reports_Abstract_Report Class. |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | public function get_range() { |
| 33 | 33 | $valid_ranges = $this->get_periods(); |
| 34 | 34 | |
| 35 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
| 36 | - return sanitize_key( $_GET['date_range'] ); |
|
| 35 | + if (isset($_GET['date_range']) && array_key_exists($_GET['date_range'], $valid_ranges)) { |
|
| 36 | + return sanitize_key($_GET['date_range']); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | return '7_days'; |
@@ -47,37 +47,37 @@ discard block |
||
| 47 | 47 | public function get_periods() { |
| 48 | 48 | |
| 49 | 49 | $periods = array( |
| 50 | - 'today' => __( 'Today', 'invoicing' ), |
|
| 51 | - 'yesterday' => __( 'Yesterday', 'invoicing' ), |
|
| 52 | - '7_days' => __( 'Last 7 days', 'invoicing' ), |
|
| 53 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
| 54 | - '60_days' => __( 'Last 60 days', 'invoicing' ), |
|
| 55 | - '90_days' => __( 'Last 90 days', 'invoicing' ), |
|
| 56 | - '180_days' => __( 'Last 180 days', 'invoicing' ), |
|
| 57 | - '360_days' => __( 'Last 360 days', 'invoicing' ), |
|
| 50 | + 'today' => __('Today', 'invoicing'), |
|
| 51 | + 'yesterday' => __('Yesterday', 'invoicing'), |
|
| 52 | + '7_days' => __('Last 7 days', 'invoicing'), |
|
| 53 | + '30_days' => __('Last 30 days', 'invoicing'), |
|
| 54 | + '60_days' => __('Last 60 days', 'invoicing'), |
|
| 55 | + '90_days' => __('Last 90 days', 'invoicing'), |
|
| 56 | + '180_days' => __('Last 180 days', 'invoicing'), |
|
| 57 | + '360_days' => __('Last 360 days', 'invoicing'), |
|
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
| 60 | + return apply_filters('getpaid_earning_periods', $periods); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * Retrieves the current range's sql. |
| 65 | 65 | * |
| 66 | 66 | */ |
| 67 | - public function get_range_sql( $range ) { |
|
| 67 | + public function get_range_sql($range) { |
|
| 68 | 68 | |
| 69 | - $date = 'CAST(meta.completed_date AS DATE)'; |
|
| 69 | + $date = 'CAST(meta.completed_date AS DATE)'; |
|
| 70 | 70 | $datetime = 'meta.completed_date'; |
| 71 | 71 | |
| 72 | 72 | // Prepare durations. |
| 73 | - $today = current_time( 'Y-m-d' ); |
|
| 74 | - $yesterday = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) ); |
|
| 75 | - $seven_days_ago = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) ); |
|
| 76 | - $thirty_days_ago = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) ); |
|
| 77 | - $ninety_days_ago = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) ); |
|
| 78 | - $sixty_days_ago = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) ); |
|
| 79 | - $one_eighty_days_ago = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) ); |
|
| 80 | - $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) ); |
|
| 73 | + $today = current_time('Y-m-d'); |
|
| 74 | + $yesterday = date('Y-m-d', strtotime('-1 day', current_time('timestamp'))); |
|
| 75 | + $seven_days_ago = date('Y-m-d', strtotime('-7 days', current_time('timestamp'))); |
|
| 76 | + $thirty_days_ago = date('Y-m-d', strtotime('-30 days', current_time('timestamp'))); |
|
| 77 | + $ninety_days_ago = date('Y-m-d', strtotime('-90 days', current_time('timestamp'))); |
|
| 78 | + $sixty_days_ago = date('Y-m-d', strtotime('-60 days', current_time('timestamp'))); |
|
| 79 | + $one_eighty_days_ago = date('Y-m-d', strtotime('-180 days', current_time('timestamp'))); |
|
| 80 | + $three_sixty_days_ago = date('Y-m-d', strtotime('-360 days', current_time('timestamp'))); |
|
| 81 | 81 | |
| 82 | 82 | $ranges = array( |
| 83 | 83 | |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ]; |
|
| 127 | - return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range ); |
|
| 126 | + $sql = isset($ranges[$range]) ? $ranges[$range] : $ranges['7_days']; |
|
| 127 | + return apply_filters('getpaid_earning_graphs_get_range_sql', $sql, $range); |
|
| 128 | 128 | |
| 129 | 129 | } |
| 130 | 130 | |
@@ -135,30 +135,30 @@ discard block |
||
| 135 | 135 | public function get_hours_in_a_day() { |
| 136 | 136 | |
| 137 | 137 | return array( |
| 138 | - '12AM' => __( '12 AM', 'invoicing'), |
|
| 139 | - '1AM' => __( '1 AM', 'invoicing'), |
|
| 140 | - '2AM' => __( '2 AM', 'invoicing'), |
|
| 141 | - '3AM' => __( '3 AM', 'invoicing'), |
|
| 142 | - '4AM' => __( '4 AM', 'invoicing'), |
|
| 143 | - '5AM' => __( '5 AM', 'invoicing'), |
|
| 144 | - '6AM' => __( '6 AM', 'invoicing'), |
|
| 145 | - '7AM' => __( '7 AM', 'invoicing'), |
|
| 146 | - '8AM' => __( '8 AM', 'invoicing'), |
|
| 147 | - '9AM' => __( '9 AM', 'invoicing'), |
|
| 148 | - '10AM' => __( '10 AM', 'invoicing'), |
|
| 149 | - '11AM' => __( '11 AM', 'invoicing'), |
|
| 150 | - '12pm' => __( '12 PM', 'invoicing'), |
|
| 151 | - '1PM' => __( '1 PM', 'invoicing'), |
|
| 152 | - '2PM' => __( '2 PM', 'invoicing'), |
|
| 153 | - '3PM' => __( '3 PM', 'invoicing'), |
|
| 154 | - '4PM' => __( '4 PM', 'invoicing'), |
|
| 155 | - '5PM' => __( '5 PM', 'invoicing'), |
|
| 156 | - '6PM' => __( '6 PM', 'invoicing'), |
|
| 157 | - '7PM' => __( '7 PM', 'invoicing'), |
|
| 158 | - '8PM' => __( '8 PM', 'invoicing'), |
|
| 159 | - '9PM' => __( '9 PM', 'invoicing'), |
|
| 160 | - '10PM' => __( '10 PM', 'invoicing'), |
|
| 161 | - '11PM' => __( '11 PM', 'invoicing'), |
|
| 138 | + '12AM' => __('12 AM', 'invoicing'), |
|
| 139 | + '1AM' => __('1 AM', 'invoicing'), |
|
| 140 | + '2AM' => __('2 AM', 'invoicing'), |
|
| 141 | + '3AM' => __('3 AM', 'invoicing'), |
|
| 142 | + '4AM' => __('4 AM', 'invoicing'), |
|
| 143 | + '5AM' => __('5 AM', 'invoicing'), |
|
| 144 | + '6AM' => __('6 AM', 'invoicing'), |
|
| 145 | + '7AM' => __('7 AM', 'invoicing'), |
|
| 146 | + '8AM' => __('8 AM', 'invoicing'), |
|
| 147 | + '9AM' => __('9 AM', 'invoicing'), |
|
| 148 | + '10AM' => __('10 AM', 'invoicing'), |
|
| 149 | + '11AM' => __('11 AM', 'invoicing'), |
|
| 150 | + '12pm' => __('12 PM', 'invoicing'), |
|
| 151 | + '1PM' => __('1 PM', 'invoicing'), |
|
| 152 | + '2PM' => __('2 PM', 'invoicing'), |
|
| 153 | + '3PM' => __('3 PM', 'invoicing'), |
|
| 154 | + '4PM' => __('4 PM', 'invoicing'), |
|
| 155 | + '5PM' => __('5 PM', 'invoicing'), |
|
| 156 | + '6PM' => __('6 PM', 'invoicing'), |
|
| 157 | + '7PM' => __('7 PM', 'invoicing'), |
|
| 158 | + '8PM' => __('8 PM', 'invoicing'), |
|
| 159 | + '9PM' => __('9 PM', 'invoicing'), |
|
| 160 | + '10PM' => __('10 PM', 'invoicing'), |
|
| 161 | + '11PM' => __('11 PM', 'invoicing'), |
|
| 162 | 162 | ); |
| 163 | 163 | |
| 164 | 164 | } |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | * Retrieves the days in a period |
| 168 | 168 | * |
| 169 | 169 | */ |
| 170 | - public function get_days_in_period( $days ) { |
|
| 170 | + public function get_days_in_period($days) { |
|
| 171 | 171 | |
| 172 | 172 | $return = array(); |
| 173 | 173 | $format = 'Y-m-d'; |
| 174 | 174 | |
| 175 | - if ( $days < 8 ) { |
|
| 175 | + if ($days < 8) { |
|
| 176 | 176 | $format = 'D'; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( $days < 32 ) { |
|
| 179 | + if ($days < 32) { |
|
| 180 | 180 | $format = 'M j'; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - while ( $days > 0 ) { |
|
| 183 | + while ($days > 0) { |
|
| 184 | 184 | |
| 185 | - $key = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 186 | - $label = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 187 | - $return[ $key ] = $label; |
|
| 185 | + $key = date('Y-m-d', strtotime("-$days days", current_time('timestamp'))); |
|
| 186 | + $label = date_i18n($format, strtotime("-$days days", current_time('timestamp'))); |
|
| 187 | + $return[$key] = $label; |
|
| 188 | 188 | $days--; |
| 189 | 189 | |
| 190 | 190 | } |
@@ -196,15 +196,15 @@ discard block |
||
| 196 | 196 | * Retrieves the weeks in a period |
| 197 | 197 | * |
| 198 | 198 | */ |
| 199 | - public function get_weeks_in_period( $days ) { |
|
| 199 | + public function get_weeks_in_period($days) { |
|
| 200 | 200 | |
| 201 | 201 | $return = array(); |
| 202 | 202 | |
| 203 | - while ( $days > 0 ) { |
|
| 203 | + while ($days > 0) { |
|
| 204 | 204 | |
| 205 | - $key = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 206 | - $label = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
| 207 | - $return[ $key ] = $label; |
|
| 205 | + $key = date('W', strtotime("-$days days", current_time('timestamp'))); |
|
| 206 | + $label = date_i18n('Y-m-d', strtotime("-$days days", current_time('timestamp'))); |
|
| 207 | + $return[$key] = $label; |
|
| 208 | 208 | $days--; |
| 209 | 209 | |
| 210 | 210 | } |
@@ -12,43 +12,43 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Reports_Report_Earnings extends GetPaid_Reports_Abstract_Report { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Retrieves the earning graphs. |
|
| 17 | - * |
|
| 18 | - */ |
|
| 19 | - public function get_graphs() { |
|
| 15 | + /** |
|
| 16 | + * Retrieves the earning graphs. |
|
| 17 | + * |
|
| 18 | + */ |
|
| 19 | + public function get_graphs() { |
|
| 20 | 20 | |
| 21 | - $graphs = array( |
|
| 21 | + $graphs = array( |
|
| 22 | 22 | |
| 23 | 23 | 'total' => __( 'Earnings', 'invoicing' ), |
| 24 | 24 | 'discount' => __( 'Discount', 'invoicing' ), |
| 25 | - 'fees_total' => __( 'Fees', 'invoicing' ), |
|
| 26 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 25 | + 'fees_total' => __( 'Fees', 'invoicing' ), |
|
| 26 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
| 27 | 27 | |
| 28 | - ); |
|
| 28 | + ); |
|
| 29 | 29 | |
| 30 | - return apply_filters( 'getpaid_earning_graphs', $graphs ); |
|
| 30 | + return apply_filters( 'getpaid_earning_graphs', $graphs ); |
|
| 31 | 31 | |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Retrieves the earning sql. |
|
| 36 | - * |
|
| 37 | - */ |
|
| 38 | - public function get_sql( $range ) { |
|
| 39 | - global $wpdb; |
|
| 34 | + /** |
|
| 35 | + * Retrieves the earning sql. |
|
| 36 | + * |
|
| 37 | + */ |
|
| 38 | + public function get_sql( $range ) { |
|
| 39 | + global $wpdb; |
|
| 40 | 40 | |
| 41 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 42 | - $clauses = $this->get_range_sql( $range ); |
|
| 43 | - $graphs = array_keys( $this->get_graphs() ); |
|
| 44 | - $graphs_sql = array(); |
|
| 41 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
| 42 | + $clauses = $this->get_range_sql( $range ); |
|
| 43 | + $graphs = array_keys( $this->get_graphs() ); |
|
| 44 | + $graphs_sql = array(); |
|
| 45 | 45 | |
| 46 | - foreach ( $graphs as $graph ) { |
|
| 47 | - $graphs_sql[] = "SUM( meta.$graph ) AS $graph"; |
|
| 48 | - } |
|
| 46 | + foreach ( $graphs as $graph ) { |
|
| 47 | + $graphs_sql[] = "SUM( meta.$graph ) AS $graph"; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - $graphs_sql = implode( ', ', $graphs_sql ); |
|
| 51 | - $sql = "SELECT {$clauses[0]} AS completed_date, $graphs_sql |
|
| 50 | + $graphs_sql = implode( ', ', $graphs_sql ); |
|
| 51 | + $sql = "SELECT {$clauses[0]} AS completed_date, $graphs_sql |
|
| 52 | 52 | FROM $wpdb->posts |
| 53 | 53 | LEFT JOIN $table as meta ON meta.post_id = $wpdb->posts.ID |
| 54 | 54 | WHERE meta.post_id IS NOT NULL |
@@ -58,94 +58,94 @@ discard block |
||
| 58 | 58 | GROUP BY {$clauses[0]} |
| 59 | 59 | "; |
| 60 | 60 | |
| 61 | - return apply_filters( 'getpaid_earning_graphs_get_sql', $sql, $range ); |
|
| 62 | - |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Prepares the report stats. |
|
| 67 | - * |
|
| 68 | - */ |
|
| 69 | - public function prepare_stats() { |
|
| 70 | - global $wpdb; |
|
| 71 | - $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Retrieves report labels. |
|
| 76 | - * |
|
| 77 | - */ |
|
| 78 | - public function get_labels( $range ) { |
|
| 79 | - |
|
| 80 | - $labels = array( |
|
| 81 | - 'today' => $this->get_hours_in_a_day(), |
|
| 82 | - 'yesterday' => $this->get_hours_in_a_day(), |
|
| 83 | - '7_days' => $this->get_days_in_period( 7 ), |
|
| 84 | - '30_days' => $this->get_days_in_period( 30 ), |
|
| 85 | - '60_days' => $this->get_days_in_period( 60 ), |
|
| 86 | - '90_days' => $this->get_weeks_in_period( 90 ), |
|
| 87 | - '180_days' => $this->get_weeks_in_period( 180 ), |
|
| 88 | - '360_days' => $this->get_weeks_in_period( 360 ), |
|
| 89 | - ); |
|
| 90 | - |
|
| 91 | - $label = isset( $labels[ $range ] ) ? $labels[ $range ] : $labels[ '7_days' ]; |
|
| 92 | - return apply_filters( 'getpaid_earning_graphs_get_labels', $label, $range ); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Retrieves report datasets. |
|
| 97 | - * |
|
| 98 | - */ |
|
| 99 | - public function get_datasets( $labels ) { |
|
| 100 | - |
|
| 101 | - $datasets = array(); |
|
| 102 | - |
|
| 103 | - foreach ( $this->get_graphs() as $key => $label ) { |
|
| 104 | - $datasets[ $key ] = array( |
|
| 105 | - 'label' => $label, |
|
| 106 | - 'data' => $this->get_data( $key, $labels ) |
|
| 107 | - ); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - return apply_filters( 'getpaid_earning_graphs_get_datasets', $datasets, $key, $labels ); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Retrieves report data. |
|
| 115 | - * |
|
| 116 | - */ |
|
| 117 | - public function get_data( $key, $labels ) { |
|
| 118 | - |
|
| 119 | - $data = wp_list_pluck( $this->stats, $key, 'completed_date' ); |
|
| 120 | - $prepared = array(); |
|
| 121 | - |
|
| 122 | - foreach ( $labels as $label ) { |
|
| 123 | - |
|
| 124 | - $value = 0; |
|
| 125 | - if ( isset( $data[ $label ] ) ) { |
|
| 126 | - $value = wpinv_round_amount( wpinv_sanitize_amount( $data[ $label ] ) ); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - $prepared[] = $value; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - return apply_filters( 'getpaid_earning_graphs_get_data', $prepared, $key, $labels ); |
|
| 133 | - |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Displays the report card. |
|
| 138 | - * |
|
| 139 | - */ |
|
| 140 | - public function display() { |
|
| 141 | - |
|
| 142 | - $labels = $this->get_labels( $this->get_range() ); |
|
| 143 | - $chart_data = array( |
|
| 144 | - 'labels' => array_values( $labels ), |
|
| 145 | - 'datasets' => $this->get_datasets( array_keys( $labels ) ), |
|
| 146 | - ); |
|
| 147 | - |
|
| 148 | - ?> |
|
| 61 | + return apply_filters( 'getpaid_earning_graphs_get_sql', $sql, $range ); |
|
| 62 | + |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Prepares the report stats. |
|
| 67 | + * |
|
| 68 | + */ |
|
| 69 | + public function prepare_stats() { |
|
| 70 | + global $wpdb; |
|
| 71 | + $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Retrieves report labels. |
|
| 76 | + * |
|
| 77 | + */ |
|
| 78 | + public function get_labels( $range ) { |
|
| 79 | + |
|
| 80 | + $labels = array( |
|
| 81 | + 'today' => $this->get_hours_in_a_day(), |
|
| 82 | + 'yesterday' => $this->get_hours_in_a_day(), |
|
| 83 | + '7_days' => $this->get_days_in_period( 7 ), |
|
| 84 | + '30_days' => $this->get_days_in_period( 30 ), |
|
| 85 | + '60_days' => $this->get_days_in_period( 60 ), |
|
| 86 | + '90_days' => $this->get_weeks_in_period( 90 ), |
|
| 87 | + '180_days' => $this->get_weeks_in_period( 180 ), |
|
| 88 | + '360_days' => $this->get_weeks_in_period( 360 ), |
|
| 89 | + ); |
|
| 90 | + |
|
| 91 | + $label = isset( $labels[ $range ] ) ? $labels[ $range ] : $labels[ '7_days' ]; |
|
| 92 | + return apply_filters( 'getpaid_earning_graphs_get_labels', $label, $range ); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Retrieves report datasets. |
|
| 97 | + * |
|
| 98 | + */ |
|
| 99 | + public function get_datasets( $labels ) { |
|
| 100 | + |
|
| 101 | + $datasets = array(); |
|
| 102 | + |
|
| 103 | + foreach ( $this->get_graphs() as $key => $label ) { |
|
| 104 | + $datasets[ $key ] = array( |
|
| 105 | + 'label' => $label, |
|
| 106 | + 'data' => $this->get_data( $key, $labels ) |
|
| 107 | + ); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + return apply_filters( 'getpaid_earning_graphs_get_datasets', $datasets, $key, $labels ); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Retrieves report data. |
|
| 115 | + * |
|
| 116 | + */ |
|
| 117 | + public function get_data( $key, $labels ) { |
|
| 118 | + |
|
| 119 | + $data = wp_list_pluck( $this->stats, $key, 'completed_date' ); |
|
| 120 | + $prepared = array(); |
|
| 121 | + |
|
| 122 | + foreach ( $labels as $label ) { |
|
| 123 | + |
|
| 124 | + $value = 0; |
|
| 125 | + if ( isset( $data[ $label ] ) ) { |
|
| 126 | + $value = wpinv_round_amount( wpinv_sanitize_amount( $data[ $label ] ) ); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + $prepared[] = $value; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + return apply_filters( 'getpaid_earning_graphs_get_data', $prepared, $key, $labels ); |
|
| 133 | + |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Displays the report card. |
|
| 138 | + * |
|
| 139 | + */ |
|
| 140 | + public function display() { |
|
| 141 | + |
|
| 142 | + $labels = $this->get_labels( $this->get_range() ); |
|
| 143 | + $chart_data = array( |
|
| 144 | + 'labels' => array_values( $labels ), |
|
| 145 | + 'datasets' => $this->get_datasets( array_keys( $labels ) ), |
|
| 146 | + ); |
|
| 147 | + |
|
| 148 | + ?> |
|
| 149 | 149 | |
| 150 | 150 | <?php foreach ( $chart_data['datasets'] as $key => $dataset ) : ?> |
| 151 | 151 | <div class="row mb-4"> |
@@ -165,15 +165,15 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | <?php |
| 167 | 167 | |
| 168 | - } |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * Displays the actual report. |
|
| 172 | - * |
|
| 173 | - */ |
|
| 174 | - public function display_graph( $key, $dataset, $labels ) { |
|
| 170 | + /** |
|
| 171 | + * Displays the actual report. |
|
| 172 | + * |
|
| 173 | + */ |
|
| 174 | + public function display_graph( $key, $dataset, $labels ) { |
|
| 175 | 175 | |
| 176 | - ?> |
|
| 176 | + ?> |
|
| 177 | 177 | |
| 178 | 178 | <canvas id="getpaid-chartjs-earnings-<?php echo sanitize_key( $key ); ?>"></canvas> |
| 179 | 179 | |
@@ -223,49 +223,49 @@ discard block |
||
| 223 | 223 | </script> |
| 224 | 224 | |
| 225 | 225 | <?php |
| 226 | - } |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - /** |
|
| 229 | - * Displays the actual report. |
|
| 230 | - * |
|
| 231 | - */ |
|
| 232 | - public function display_stats() {} |
|
| 228 | + /** |
|
| 229 | + * Displays the actual report. |
|
| 230 | + * |
|
| 231 | + */ |
|
| 232 | + public function display_stats() {} |
|
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * Displays the range selector. |
|
| 236 | - * |
|
| 237 | - */ |
|
| 238 | - public function display_range_selector() { |
|
| 234 | + /** |
|
| 235 | + * Displays the range selector. |
|
| 236 | + * |
|
| 237 | + */ |
|
| 238 | + public function display_range_selector() { |
|
| 239 | 239 | |
| 240 | - ?> |
|
| 240 | + ?> |
|
| 241 | 241 | |
| 242 | 242 | <form method="get" class="getpaid-filter-earnings"> |
| 243 | 243 | <?php |
| 244 | 244 | |
| 245 | - getpaid_hidden_field( 'page', 'wpinv-reports' ); |
|
| 246 | - getpaid_hidden_field( 'tab', 'reports' ); |
|
| 247 | - |
|
| 248 | - $html = aui()->select( |
|
| 249 | - array( |
|
| 250 | - 'name' => 'date_range', |
|
| 251 | - 'id' => 'view' . uniqid( '_' ), |
|
| 252 | - 'placeholder' => __( 'Select a date range', 'invoicing' ), |
|
| 253 | - 'label' => __( 'Date Range', 'invoicing' ), |
|
| 254 | - 'options' => $this->get_periods(), |
|
| 255 | - 'value' => $this->get_range(), |
|
| 256 | - 'no_wrap' => true, |
|
| 257 | - 'extra_attributes' => array( |
|
| 258 | - 'onChange' => 'this.form.submit()', |
|
| 259 | - ), |
|
| 260 | - ) |
|
| 261 | - ); |
|
| 262 | - |
|
| 263 | - echo str_replace( 'custom-select', '', $html ); |
|
| 264 | - ?> |
|
| 245 | + getpaid_hidden_field( 'page', 'wpinv-reports' ); |
|
| 246 | + getpaid_hidden_field( 'tab', 'reports' ); |
|
| 247 | + |
|
| 248 | + $html = aui()->select( |
|
| 249 | + array( |
|
| 250 | + 'name' => 'date_range', |
|
| 251 | + 'id' => 'view' . uniqid( '_' ), |
|
| 252 | + 'placeholder' => __( 'Select a date range', 'invoicing' ), |
|
| 253 | + 'label' => __( 'Date Range', 'invoicing' ), |
|
| 254 | + 'options' => $this->get_periods(), |
|
| 255 | + 'value' => $this->get_range(), |
|
| 256 | + 'no_wrap' => true, |
|
| 257 | + 'extra_attributes' => array( |
|
| 258 | + 'onChange' => 'this.form.submit()', |
|
| 259 | + ), |
|
| 260 | + ) |
|
| 261 | + ); |
|
| 262 | + |
|
| 263 | + echo str_replace( 'custom-select', '', $html ); |
|
| 264 | + ?> |
|
| 265 | 265 | |
| 266 | 266 | </form> |
| 267 | 267 | |
| 268 | 268 | <?php |
| 269 | - } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | 271 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * GetPaid_Reports_Report_Earnings Class. |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $graphs = array( |
| 22 | 22 | |
| 23 | - 'total' => __( 'Earnings', 'invoicing' ), |
|
| 24 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 25 | - 'fees_total' => __( 'Fees', 'invoicing' ), |
|
| 26 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 23 | + 'total' => __('Earnings', 'invoicing'), |
|
| 24 | + 'discount' => __('Discount', 'invoicing'), |
|
| 25 | + 'fees_total' => __('Fees', 'invoicing'), |
|
| 26 | + 'tax' => __('Tax', 'invoicing'), |
|
| 27 | 27 | |
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | - return apply_filters( 'getpaid_earning_graphs', $graphs ); |
|
| 30 | + return apply_filters('getpaid_earning_graphs', $graphs); |
|
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
@@ -35,19 +35,19 @@ discard block |
||
| 35 | 35 | * Retrieves the earning sql. |
| 36 | 36 | * |
| 37 | 37 | */ |
| 38 | - public function get_sql( $range ) { |
|
| 38 | + public function get_sql($range) { |
|
| 39 | 39 | global $wpdb; |
| 40 | 40 | |
| 41 | 41 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 42 | - $clauses = $this->get_range_sql( $range ); |
|
| 43 | - $graphs = array_keys( $this->get_graphs() ); |
|
| 42 | + $clauses = $this->get_range_sql($range); |
|
| 43 | + $graphs = array_keys($this->get_graphs()); |
|
| 44 | 44 | $graphs_sql = array(); |
| 45 | 45 | |
| 46 | - foreach ( $graphs as $graph ) { |
|
| 46 | + foreach ($graphs as $graph) { |
|
| 47 | 47 | $graphs_sql[] = "SUM( meta.$graph ) AS $graph"; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $graphs_sql = implode( ', ', $graphs_sql ); |
|
| 50 | + $graphs_sql = implode(', ', $graphs_sql); |
|
| 51 | 51 | $sql = "SELECT {$clauses[0]} AS completed_date, $graphs_sql |
| 52 | 52 | FROM $wpdb->posts |
| 53 | 53 | LEFT JOIN $table as meta ON meta.post_id = $wpdb->posts.ID |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | GROUP BY {$clauses[0]} |
| 59 | 59 | "; |
| 60 | 60 | |
| 61 | - return apply_filters( 'getpaid_earning_graphs_get_sql', $sql, $range ); |
|
| 61 | + return apply_filters('getpaid_earning_graphs_get_sql', $sql, $range); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
@@ -68,68 +68,68 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function prepare_stats() { |
| 70 | 70 | global $wpdb; |
| 71 | - $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
| 71 | + $this->stats = $wpdb->get_results($this->get_sql($this->get_range())); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * Retrieves report labels. |
| 76 | 76 | * |
| 77 | 77 | */ |
| 78 | - public function get_labels( $range ) { |
|
| 78 | + public function get_labels($range) { |
|
| 79 | 79 | |
| 80 | 80 | $labels = array( |
| 81 | 81 | 'today' => $this->get_hours_in_a_day(), |
| 82 | 82 | 'yesterday' => $this->get_hours_in_a_day(), |
| 83 | - '7_days' => $this->get_days_in_period( 7 ), |
|
| 84 | - '30_days' => $this->get_days_in_period( 30 ), |
|
| 85 | - '60_days' => $this->get_days_in_period( 60 ), |
|
| 86 | - '90_days' => $this->get_weeks_in_period( 90 ), |
|
| 87 | - '180_days' => $this->get_weeks_in_period( 180 ), |
|
| 88 | - '360_days' => $this->get_weeks_in_period( 360 ), |
|
| 83 | + '7_days' => $this->get_days_in_period(7), |
|
| 84 | + '30_days' => $this->get_days_in_period(30), |
|
| 85 | + '60_days' => $this->get_days_in_period(60), |
|
| 86 | + '90_days' => $this->get_weeks_in_period(90), |
|
| 87 | + '180_days' => $this->get_weeks_in_period(180), |
|
| 88 | + '360_days' => $this->get_weeks_in_period(360), |
|
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | - $label = isset( $labels[ $range ] ) ? $labels[ $range ] : $labels[ '7_days' ]; |
|
| 92 | - return apply_filters( 'getpaid_earning_graphs_get_labels', $label, $range ); |
|
| 91 | + $label = isset($labels[$range]) ? $labels[$range] : $labels['7_days']; |
|
| 92 | + return apply_filters('getpaid_earning_graphs_get_labels', $label, $range); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * Retrieves report datasets. |
| 97 | 97 | * |
| 98 | 98 | */ |
| 99 | - public function get_datasets( $labels ) { |
|
| 99 | + public function get_datasets($labels) { |
|
| 100 | 100 | |
| 101 | 101 | $datasets = array(); |
| 102 | 102 | |
| 103 | - foreach ( $this->get_graphs() as $key => $label ) { |
|
| 104 | - $datasets[ $key ] = array( |
|
| 103 | + foreach ($this->get_graphs() as $key => $label) { |
|
| 104 | + $datasets[$key] = array( |
|
| 105 | 105 | 'label' => $label, |
| 106 | - 'data' => $this->get_data( $key, $labels ) |
|
| 106 | + 'data' => $this->get_data($key, $labels) |
|
| 107 | 107 | ); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - return apply_filters( 'getpaid_earning_graphs_get_datasets', $datasets, $key, $labels ); |
|
| 110 | + return apply_filters('getpaid_earning_graphs_get_datasets', $datasets, $key, $labels); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * Retrieves report data. |
| 115 | 115 | * |
| 116 | 116 | */ |
| 117 | - public function get_data( $key, $labels ) { |
|
| 117 | + public function get_data($key, $labels) { |
|
| 118 | 118 | |
| 119 | - $data = wp_list_pluck( $this->stats, $key, 'completed_date' ); |
|
| 119 | + $data = wp_list_pluck($this->stats, $key, 'completed_date'); |
|
| 120 | 120 | $prepared = array(); |
| 121 | 121 | |
| 122 | - foreach ( $labels as $label ) { |
|
| 122 | + foreach ($labels as $label) { |
|
| 123 | 123 | |
| 124 | 124 | $value = 0; |
| 125 | - if ( isset( $data[ $label ] ) ) { |
|
| 126 | - $value = wpinv_round_amount( wpinv_sanitize_amount( $data[ $label ] ) ); |
|
| 125 | + if (isset($data[$label])) { |
|
| 126 | + $value = wpinv_round_amount(wpinv_sanitize_amount($data[$label])); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $prepared[] = $value; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - return apply_filters( 'getpaid_earning_graphs_get_data', $prepared, $key, $labels ); |
|
| 132 | + return apply_filters('getpaid_earning_graphs_get_data', $prepared, $key, $labels); |
|
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
@@ -139,15 +139,15 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function display() { |
| 141 | 141 | |
| 142 | - $labels = $this->get_labels( $this->get_range() ); |
|
| 142 | + $labels = $this->get_labels($this->get_range()); |
|
| 143 | 143 | $chart_data = array( |
| 144 | - 'labels' => array_values( $labels ), |
|
| 145 | - 'datasets' => $this->get_datasets( array_keys( $labels ) ), |
|
| 144 | + 'labels' => array_values($labels), |
|
| 145 | + 'datasets' => $this->get_datasets(array_keys($labels)), |
|
| 146 | 146 | ); |
| 147 | 147 | |
| 148 | 148 | ?> |
| 149 | 149 | |
| 150 | - <?php foreach ( $chart_data['datasets'] as $key => $dataset ) : ?> |
|
| 150 | + <?php foreach ($chart_data['datasets'] as $key => $dataset) : ?> |
|
| 151 | 151 | <div class="row mb-4"> |
| 152 | 152 | <div class="col-12"> |
| 153 | 153 | <div class="card m-0 p-0" style="max-width:100%"> |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | <?php $this->display_range_selector(); ?> |
| 157 | 157 | </div> |
| 158 | 158 | <div class="card-body"> |
| 159 | - <?php $this->display_graph( $key, $dataset, $chart_data['labels'] ); ?> |
|
| 159 | + <?php $this->display_graph($key, $dataset, $chart_data['labels']); ?> |
|
| 160 | 160 | </div> |
| 161 | 161 | </div> |
| 162 | 162 | </div> |
@@ -171,26 +171,26 @@ discard block |
||
| 171 | 171 | * Displays the actual report. |
| 172 | 172 | * |
| 173 | 173 | */ |
| 174 | - public function display_graph( $key, $dataset, $labels ) { |
|
| 174 | + public function display_graph($key, $dataset, $labels) { |
|
| 175 | 175 | |
| 176 | 176 | ?> |
| 177 | 177 | |
| 178 | - <canvas id="getpaid-chartjs-earnings-<?php echo sanitize_key( $key ); ?>"></canvas> |
|
| 178 | + <canvas id="getpaid-chartjs-earnings-<?php echo sanitize_key($key); ?>"></canvas> |
|
| 179 | 179 | |
| 180 | 180 | <script> |
| 181 | 181 | window.addEventListener( 'DOMContentLoaded', function() { |
| 182 | 182 | |
| 183 | - var ctx = document.getElementById( 'getpaid-chartjs-earnings-<?php echo sanitize_key( $key ); ?>' ).getContext('2d'); |
|
| 183 | + var ctx = document.getElementById( 'getpaid-chartjs-earnings-<?php echo sanitize_key($key); ?>' ).getContext('2d'); |
|
| 184 | 184 | new Chart( |
| 185 | 185 | ctx, |
| 186 | 186 | { |
| 187 | 187 | type: 'line', |
| 188 | 188 | data: { |
| 189 | - 'labels': <?php echo wp_json_encode( $labels ); ?>, |
|
| 189 | + 'labels': <?php echo wp_json_encode($labels); ?>, |
|
| 190 | 190 | 'datasets': [ |
| 191 | 191 | { |
| 192 | - label: '<?php echo esc_attr( $dataset['label'] ); ?>', |
|
| 193 | - data: <?php echo wp_json_encode( $dataset['data'] ); ?>, |
|
| 192 | + label: '<?php echo esc_attr($dataset['label']); ?>', |
|
| 193 | + data: <?php echo wp_json_encode($dataset['data']); ?>, |
|
| 194 | 194 | backgroundColor: 'rgba(54, 162, 235, 0.1)', |
| 195 | 195 | borderColor: 'rgb(54, 162, 235)', |
| 196 | 196 | borderWidth: 4, |
@@ -242,15 +242,15 @@ discard block |
||
| 242 | 242 | <form method="get" class="getpaid-filter-earnings"> |
| 243 | 243 | <?php |
| 244 | 244 | |
| 245 | - getpaid_hidden_field( 'page', 'wpinv-reports' ); |
|
| 246 | - getpaid_hidden_field( 'tab', 'reports' ); |
|
| 245 | + getpaid_hidden_field('page', 'wpinv-reports'); |
|
| 246 | + getpaid_hidden_field('tab', 'reports'); |
|
| 247 | 247 | |
| 248 | 248 | $html = aui()->select( |
| 249 | 249 | array( |
| 250 | 250 | 'name' => 'date_range', |
| 251 | - 'id' => 'view' . uniqid( '_' ), |
|
| 252 | - 'placeholder' => __( 'Select a date range', 'invoicing' ), |
|
| 253 | - 'label' => __( 'Date Range', 'invoicing' ), |
|
| 251 | + 'id' => 'view' . uniqid('_'), |
|
| 252 | + 'placeholder' => __('Select a date range', 'invoicing'), |
|
| 253 | + 'label' => __('Date Range', 'invoicing'), |
|
| 254 | 254 | 'options' => $this->get_periods(), |
| 255 | 255 | 'value' => $this->get_range(), |
| 256 | 256 | 'no_wrap' => true, |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | ) |
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | - echo str_replace( 'custom-select', '', $html ); |
|
| 263 | + echo str_replace('custom-select', '', $html); |
|
| 264 | 264 | ?> |
| 265 | 265 | |
| 266 | 266 | </form> |
@@ -12,41 +12,41 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Reports_Report { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var array |
|
| 17 | - */ |
|
| 18 | - public $views; |
|
| 15 | + /** |
|
| 16 | + * @var array |
|
| 17 | + */ |
|
| 18 | + public $views; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Class constructor. |
|
| 22 | - * |
|
| 23 | - */ |
|
| 24 | - public function __construct() { |
|
| 20 | + /** |
|
| 21 | + * Class constructor. |
|
| 22 | + * |
|
| 23 | + */ |
|
| 24 | + public function __construct() { |
|
| 25 | 25 | |
| 26 | - $this->views = array( |
|
| 26 | + $this->views = array( |
|
| 27 | 27 | |
| 28 | 28 | 'items' => array( |
| 29 | - 'label' => __( 'Items', 'invoicing' ), |
|
| 30 | - 'class' => 'GetPaid_Reports_Report_Items', |
|
| 31 | - ), |
|
| 29 | + 'label' => __( 'Items', 'invoicing' ), |
|
| 30 | + 'class' => 'GetPaid_Reports_Report_Items', |
|
| 31 | + ), |
|
| 32 | 32 | |
| 33 | - 'gateways' => array( |
|
| 34 | - 'label' => __( 'Payment Methods', 'invoicing' ), |
|
| 35 | - 'class' => 'GetPaid_Reports_Report_Gateways', |
|
| 36 | - ), |
|
| 33 | + 'gateways' => array( |
|
| 34 | + 'label' => __( 'Payment Methods', 'invoicing' ), |
|
| 35 | + 'class' => 'GetPaid_Reports_Report_Gateways', |
|
| 36 | + ), |
|
| 37 | 37 | |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | - $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
| 40 | + $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
| 41 | 41 | |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Displays the reports tab. |
|
| 46 | - * |
|
| 47 | - */ |
|
| 48 | - public function display() { |
|
| 49 | - ?> |
|
| 44 | + /** |
|
| 45 | + * Displays the reports tab. |
|
| 46 | + * |
|
| 47 | + */ |
|
| 48 | + public function display() { |
|
| 49 | + ?> |
|
| 50 | 50 | |
| 51 | 51 | <div class="mt-4" style="max-width: 1200px;"> |
| 52 | 52 | |
@@ -64,24 +64,24 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | <?php |
| 66 | 66 | |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Displays the left side. |
|
| 71 | - * |
|
| 72 | - */ |
|
| 73 | - public function display_left() { |
|
| 74 | - $earnings = new GetPaid_Reports_Report_Earnings(); |
|
| 75 | - $earnings->display(); |
|
| 76 | - } |
|
| 69 | + /** |
|
| 70 | + * Displays the left side. |
|
| 71 | + * |
|
| 72 | + */ |
|
| 73 | + public function display_left() { |
|
| 74 | + $earnings = new GetPaid_Reports_Report_Earnings(); |
|
| 75 | + $earnings->display(); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Displays the right side. |
|
| 80 | - * |
|
| 81 | - */ |
|
| 82 | - public function display_right() { |
|
| 78 | + /** |
|
| 79 | + * Displays the right side. |
|
| 80 | + * |
|
| 81 | + */ |
|
| 82 | + public function display_right() { |
|
| 83 | 83 | |
| 84 | - ?> |
|
| 84 | + ?> |
|
| 85 | 85 | |
| 86 | 86 | <?php foreach ( $this->views as $view ) : ?> |
| 87 | 87 | <div class="row mb-4"> |
@@ -92,10 +92,10 @@ discard block |
||
| 92 | 92 | </div> |
| 93 | 93 | <div class="card-body"> |
| 94 | 94 | <?php |
| 95 | - $class = $view['class']; |
|
| 96 | - $class = new $class(); |
|
| 97 | - $class->display_stats(); |
|
| 98 | - ?> |
|
| 95 | + $class = $view['class']; |
|
| 96 | + $class = new $class(); |
|
| 97 | + $class->display_stats(); |
|
| 98 | + ?> |
|
| 99 | 99 | </div> |
| 100 | 100 | </div> |
| 101 | 101 | </div> |
@@ -104,6 +104,6 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | <?php |
| 106 | 106 | |
| 107 | - } |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * GetPaid_Reports_Report Class. |
@@ -23,21 +23,21 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | public function __construct() { |
| 25 | 25 | |
| 26 | - $this->views = array( |
|
| 26 | + $this->views = array( |
|
| 27 | 27 | |
| 28 | 28 | 'items' => array( |
| 29 | - 'label' => __( 'Items', 'invoicing' ), |
|
| 29 | + 'label' => __('Items', 'invoicing'), |
|
| 30 | 30 | 'class' => 'GetPaid_Reports_Report_Items', |
| 31 | 31 | ), |
| 32 | 32 | |
| 33 | 33 | 'gateways' => array( |
| 34 | - 'label' => __( 'Payment Methods', 'invoicing' ), |
|
| 34 | + 'label' => __('Payment Methods', 'invoicing'), |
|
| 35 | 35 | 'class' => 'GetPaid_Reports_Report_Gateways', |
| 36 | 36 | ), |
| 37 | 37 | |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | - $this->views = apply_filters( 'wpinv_report_views', $this->views ); |
|
| 40 | + $this->views = apply_filters('wpinv_report_views', $this->views); |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | ?> |
| 85 | 85 | |
| 86 | - <?php foreach ( $this->views as $view ) : ?> |
|
| 86 | + <?php foreach ($this->views as $view) : ?> |
|
| 87 | 87 | <div class="row mb-4"> |
| 88 | 88 | <div class="col-12"> |
| 89 | 89 | <div class="card m-0 p-0" style="max-width:100%"> |