@@ -8,18 +8,18 @@ |
||
| 8 | 8 | * @var WPInv_Subscription $object |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | $invoice = $object->get_parent_payment(); |
| 14 | 14 | |
| 15 | 15 | // Print the email header. |
| 16 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
| 16 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
| 17 | 17 | |
| 18 | 18 | // Generate the custom message body. |
| 19 | 19 | echo $message_body; |
| 20 | 20 | |
| 21 | 21 | // Print the billing details. |
| 22 | -do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin ); |
|
| 22 | +do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin); |
|
| 23 | 23 | |
| 24 | 24 | // Print the email footer. |
| 25 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
| 25 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // MUST have WordPress. |
| 10 | -if ( !defined( 'WPINC' ) ) { |
|
| 10 | +if (!defined('WPINC')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -24,40 +24,40 @@ discard block |
||
| 24 | 24 | * @param Array $assoc_args Key value arguments stored in associated array format. |
| 25 | 25 | * @since 1.0.13 |
| 26 | 26 | */ |
| 27 | - public function insert_invoice( $args, $assoc_args ) { |
|
| 27 | + public function insert_invoice($args, $assoc_args) { |
|
| 28 | 28 | |
| 29 | 29 | // Fetch invoice data from the args |
| 30 | - $invoice_data = wp_unslash( $assoc_args ); |
|
| 30 | + $invoice_data = wp_unslash($assoc_args); |
|
| 31 | 31 | |
| 32 | 32 | // Abort if no invoice data is provided |
| 33 | - if( empty( $invoice_data ) ) { |
|
| 34 | - return WP_CLI::error( __( 'Invoice data not provided', 'invoicing' ) ); |
|
| 33 | + if (empty($invoice_data)) { |
|
| 34 | + return WP_CLI::error(__('Invoice data not provided', 'invoicing')); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | //Cart details |
| 38 | - if( !empty( $invoice_data['cart_details'] ) ) { |
|
| 39 | - $invoice_data['cart_details'] = json_decode( $invoice_data['cart_details'], true ); |
|
| 38 | + if (!empty($invoice_data['cart_details'])) { |
|
| 39 | + $invoice_data['cart_details'] = json_decode($invoice_data['cart_details'], true); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | //User details |
| 43 | - if( !empty( $invoice_data['user_info'] ) ) { |
|
| 44 | - $invoice_data['user_info'] = json_decode( $invoice_data['user_info'], true ); |
|
| 43 | + if (!empty($invoice_data['user_info'])) { |
|
| 44 | + $invoice_data['user_info'] = json_decode($invoice_data['user_info'], true); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | //Payment info |
| 48 | - if( !empty( $invoice_data['payment_details'] ) ) { |
|
| 49 | - $invoice_data['payment_details'] = json_decode( $invoice_data['payment_details'], true ); |
|
| 48 | + if (!empty($invoice_data['payment_details'])) { |
|
| 49 | + $invoice_data['payment_details'] = json_decode($invoice_data['payment_details'], true); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Try creating the invoice |
| 53 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
| 53 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
| 54 | 54 | |
| 55 | - if ( is_wp_error( $invoice ) ) { |
|
| 56 | - return WP_CLI::error( $invoice->get_error_message() ); |
|
| 55 | + if (is_wp_error($invoice)) { |
|
| 56 | + return WP_CLI::error($invoice->get_error_message()); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $message = sprintf( __( 'Invoice %s created', 'invoicing' ), $invoice->get_id() ); |
|
| 60 | - WP_CLI::success( $message ); |
|
| 59 | + $message = sprintf(__('Invoice %s created', 'invoicing'), $invoice->get_id()); |
|
| 60 | + WP_CLI::success($message); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | |
@@ -8,23 +8,23 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | 13 | ?> |
| 14 | 14 | |
| 15 | 15 | <div class='form-group'> |
| 16 | - <label :for="active_form_element.id + '_edit_heading'"><?php esc_html_e( 'Heading', 'invoicing' ) ?></label> |
|
| 16 | + <label :for="active_form_element.id + '_edit_heading'"><?php esc_html_e('Heading', 'invoicing') ?></label> |
|
| 17 | 17 | <input :id="active_form_element.id + '_edit_heading'" v-model='active_form_element.text' class='form-control' type='text' /> |
| 18 | 18 | </div> |
| 19 | 19 | |
| 20 | 20 | <div class='form-group'> |
| 21 | - <label :for="active_form_element.id + '_edit_level'"><?php esc_html_e( 'Select Heading Level', 'invoicing' ) ?></label> |
|
| 21 | + <label :for="active_form_element.id + '_edit_level'"><?php esc_html_e('Select Heading Level', 'invoicing') ?></label> |
|
| 22 | 22 | <select class='form-control custom-select' :id="active_form_element.id + '_edit_level'" v-model='active_form_element.level'> |
| 23 | - <option value='h1'><?php esc_html_e( 'H1', 'invoicing' ); ?></option> |
|
| 24 | - <option value='h2'><?php esc_html_e( 'H2', 'invoicing' ); ?></option> |
|
| 25 | - <option value='h3'><?php esc_html_e( 'H3', 'invoicing' ); ?></option> |
|
| 26 | - <option value='h4'><?php esc_html_e( 'H4', 'invoicing' ); ?></option> |
|
| 27 | - <option value='h5'><?php esc_html_e( 'H5', 'invoicing' ); ?></option> |
|
| 28 | - <option value='h6'><?php esc_html_e( 'H6', 'invoicing' ); ?></option> |
|
| 23 | + <option value='h1'><?php esc_html_e('H1', 'invoicing'); ?></option> |
|
| 24 | + <option value='h2'><?php esc_html_e('H2', 'invoicing'); ?></option> |
|
| 25 | + <option value='h3'><?php esc_html_e('H3', 'invoicing'); ?></option> |
|
| 26 | + <option value='h4'><?php esc_html_e('H4', 'invoicing'); ?></option> |
|
| 27 | + <option value='h5'><?php esc_html_e('H5', 'invoicing'); ?></option> |
|
| 28 | + <option value='h6'><?php esc_html_e('H6', 'invoicing'); ?></option> |
|
| 29 | 29 | </select> |
| 30 | 30 | </div> |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @version 1.0.19 |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * REST API invoices controller class. |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | 'customers' => array( |
| 55 | - 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
| 55 | + 'description' => __('Limit result set to invoices for specific user ids.', 'invoicing'), |
|
| 56 | 56 | 'type' => 'array', |
| 57 | 57 | 'items' => array( |
| 58 | 58 | 'type' => 'integer', |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | ), |
| 63 | 63 | |
| 64 | 64 | 'exclude_customers' => array( |
| 65 | - 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
| 65 | + 'description' => __('Exclude invoices to specific users.', 'invoicing'), |
|
| 66 | 66 | 'type' => 'array', |
| 67 | 67 | 'items' => array( |
| 68 | 68 | 'type' => 'integer', |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ), |
| 73 | 73 | |
| 74 | 74 | 'parent' => array( |
| 75 | - 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
| 75 | + 'description' => __('Limit result set to those of particular parent IDs.', 'invoicing'), |
|
| 76 | 76 | 'type' => 'array', |
| 77 | 77 | 'items' => array( |
| 78 | 78 | 'type' => 'integer', |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | ), |
| 83 | 83 | |
| 84 | 84 | 'parent_exclude' => array( |
| 85 | - 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
| 85 | + 'description' => __('Limit result set to all items except those of a particular parent ID.', 'invoicing'), |
|
| 86 | 86 | 'type' => 'array', |
| 87 | 87 | 'items' => array( |
| 88 | 88 | 'type' => 'integer', |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | 98 | // Filter collection parameters for the invoices controller. |
| 99 | - return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
| 99 | + return apply_filters('getpaid_rest_invoices_collection_params', $params, $this); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | * @param WP_REST_Request $request Request object. |
| 108 | 108 | * @return array $query_args |
| 109 | 109 | */ |
| 110 | - protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
| 110 | + protected function prepare_items_query($prepared_args = array(), $request = null) { |
|
| 111 | 111 | |
| 112 | - $query_args = parent::prepare_items_query( $prepared_args ); |
|
| 112 | + $query_args = parent::prepare_items_query($prepared_args); |
|
| 113 | 113 | |
| 114 | 114 | // Retrieve invoices for specific customers. |
| 115 | - if ( ! empty( $request['customers'] ) ) { |
|
| 115 | + if (!empty($request['customers'])) { |
|
| 116 | 116 | $query_args['author__in'] = $request['customers']; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Skip invoices for specific customers. |
| 120 | - if ( ! empty( $request['exclude_customers'] ) ) { |
|
| 120 | + if (!empty($request['exclude_customers'])) { |
|
| 121 | 121 | $query_args['author__not_in'] = $request['exclude_customers']; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
| 124 | + return apply_filters('getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this); |
|
| 125 | 125 | |
| 126 | 126 | } |
| 127 | 127 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @return array A list of registered item statuses. |
| 134 | 134 | */ |
| 135 | 135 | public function get_post_statuses() { |
| 136 | - return array_keys( wpinv_get_invoice_statuses( true, false, $this->post_type ) ); |
|
| 136 | + return array_keys(wpinv_get_invoice_statuses(true, false, $this->post_type)); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | * @param WPInv_Invoice $invoice Invoice to save. |
| 143 | 143 | * @return WP_Error|WPInv_Invoice |
| 144 | 144 | */ |
| 145 | - protected function save_object( $invoice ) { |
|
| 145 | + protected function save_object($invoice) { |
|
| 146 | 146 | $invoice->recalculate_total(); |
| 147 | - return parent::save_object( $invoice ); |
|
| 147 | + return parent::save_object($invoice); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | } |
@@ -7,13 +7,13 @@ |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | ?> |
| 13 | 13 | |
| 14 | 14 | <div class='wpinv-address-wrapper row'> |
| 15 | 15 | |
| 16 | - <h4 v-if="form_element.address_type == 'both'" class="col-12 mb-3"><?php _e( 'Billing / Shipping Address', 'invoicing' ); ?></h4> |
|
| 16 | + <h4 v-if="form_element.address_type == 'both'" class="col-12 mb-3"><?php _e('Billing / Shipping Address', 'invoicing'); ?></h4> |
|
| 17 | 17 | |
| 18 | 18 | <div class='form-group address-field-preview wpinv-payment-form-field-preview' v-for='(field, index) in visible_fields( form_element.fields )' :class='grid_class( field )' :key='field.name'> |
| 19 | 19 | <label class="d-block w-100"> |
@@ -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 service class responsible for interacting with MaxMind databases. |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param string|null $database_prefix A prefix for the MaxMind database filename. |
| 37 | 37 | */ |
| 38 | - public function __construct( $database_prefix ) { |
|
| 38 | + public function __construct($database_prefix) { |
|
| 39 | 39 | $this->database_prefix = $database_prefix; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -47,14 +47,14 @@ discard block |
||
| 47 | 47 | public function get_database_path() { |
| 48 | 48 | $uploads_dir = wp_upload_dir(); |
| 49 | 49 | |
| 50 | - $database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/'; |
|
| 51 | - if ( ! empty( $this->database_prefix ) ) { |
|
| 50 | + $database_path = trailingslashit($uploads_dir['basedir']) . 'invoicing/'; |
|
| 51 | + if (!empty($this->database_prefix)) { |
|
| 52 | 52 | $database_path .= $this->database_prefix . '-'; |
| 53 | 53 | } |
| 54 | 54 | $database_path .= self::DATABASE . self::DATABASE_EXTENSION; |
| 55 | 55 | |
| 56 | 56 | // Filter the geolocation database storage path. |
| 57 | - return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path ); |
|
| 57 | + return apply_filters('getpaid_maxmind_geolocation_database_path', $database_path); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | * @param string $license_key The license key to be used when downloading the database. |
| 64 | 64 | * @return string|WP_Error The path to the database file or an error if invalid. |
| 65 | 65 | */ |
| 66 | - public function download_database( $license_key ) { |
|
| 66 | + public function download_database($license_key) { |
|
| 67 | 67 | |
| 68 | 68 | $download_uri = add_query_arg( |
| 69 | 69 | array( |
| 70 | 70 | 'edition_id' => self::DATABASE, |
| 71 | - 'license_key' => urlencode( wpinv_clean( $license_key ) ), |
|
| 71 | + 'license_key' => urlencode(wpinv_clean($license_key)), |
|
| 72 | 72 | 'suffix' => 'tar.gz', |
| 73 | 73 | ), |
| 74 | 74 | 'https://download.maxmind.com/app/geoip_download' |
@@ -77,23 +77,23 @@ discard block |
||
| 77 | 77 | // Needed for the download_url call right below. |
| 78 | 78 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
| 79 | 79 | |
| 80 | - $tmp_archive_path = download_url( esc_url_raw( $download_uri ) ); |
|
| 80 | + $tmp_archive_path = download_url(esc_url_raw($download_uri)); |
|
| 81 | 81 | |
| 82 | - if ( is_wp_error( $tmp_archive_path ) ) { |
|
| 82 | + if (is_wp_error($tmp_archive_path)) { |
|
| 83 | 83 | // Transform the error into something more informative. |
| 84 | 84 | $error_data = $tmp_archive_path->get_error_data(); |
| 85 | - if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) { |
|
| 85 | + if (isset($error_data['code']) && $error_data['code'] == 401) { |
|
| 86 | 86 | return new WP_Error( |
| 87 | 87 | 'getpaid_maxmind_geolocation_database_license_key', |
| 88 | - __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' ) |
|
| 88 | + __('The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing') |
|
| 89 | 89 | ); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) ); |
|
| 92 | + return new WP_Error('getpaid_maxmind_geolocation_database_download', __('Failed to download the MaxMind database.', 'invoicing')); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Extract the database from the archive. |
| 96 | - return $this->extract_downloaded_database( $tmp_archive_path ); |
|
| 96 | + return $this->extract_downloaded_database($tmp_archive_path); |
|
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | |
@@ -103,27 +103,27 @@ discard block |
||
| 103 | 103 | * @param string $tmp_archive_path The database archive path. |
| 104 | 104 | * @return string|WP_Error The path to the database file or an error if invalid. |
| 105 | 105 | */ |
| 106 | - protected function extract_downloaded_database( $tmp_archive_path ) { |
|
| 106 | + protected function extract_downloaded_database($tmp_archive_path) { |
|
| 107 | 107 | |
| 108 | 108 | // Extract the database from the archive. |
| 109 | 109 | $tmp_database_path = ''; |
| 110 | 110 | |
| 111 | 111 | try { |
| 112 | 112 | |
| 113 | - $file = new PharData( $tmp_archive_path ); |
|
| 114 | - $tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION; |
|
| 113 | + $file = new PharData($tmp_archive_path); |
|
| 114 | + $tmp_database_path = trailingslashit(dirname($tmp_archive_path)) . trailingslashit($file->current()->getFilename()) . self::DATABASE . self::DATABASE_EXTENSION; |
|
| 115 | 115 | |
| 116 | 116 | $file->extractTo( |
| 117 | - dirname( $tmp_archive_path ), |
|
| 118 | - trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION, |
|
| 117 | + dirname($tmp_archive_path), |
|
| 118 | + trailingslashit($file->current()->getFilename()) . self::DATABASE . self::DATABASE_EXTENSION, |
|
| 119 | 119 | true |
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | - } catch ( Exception $exception ) { |
|
| 123 | - return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() ); |
|
| 122 | + } catch (Exception $exception) { |
|
| 123 | + return new WP_Error('invoicing_maxmind_geolocation_database_archive', $exception->getMessage()); |
|
| 124 | 124 | } finally { |
| 125 | 125 | // Remove the archive since we only care about a single file in it. |
| 126 | - unlink( $tmp_archive_path ); |
|
| 126 | + unlink($tmp_archive_path); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | return $tmp_database_path; |
@@ -135,29 +135,29 @@ discard block |
||
| 135 | 135 | * @param string $ip_address The IP address to find the country code for. |
| 136 | 136 | * @return string The country code for the IP address, or empty if not found. |
| 137 | 137 | */ |
| 138 | - public function get_iso_country_code_for_ip( $ip_address ) { |
|
| 138 | + public function get_iso_country_code_for_ip($ip_address) { |
|
| 139 | 139 | $country_code = ''; |
| 140 | 140 | |
| 141 | - if ( ! class_exists( 'MaxMind\Db\Reader' ) ) { |
|
| 141 | + if (!class_exists('MaxMind\Db\Reader')) { |
|
| 142 | 142 | return $country_code; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $database_path = $this->get_database_path(); |
| 146 | - if ( ! file_exists( $database_path ) ) { |
|
| 146 | + if (!file_exists($database_path)) { |
|
| 147 | 147 | return $country_code; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | try { |
| 151 | - $reader = new MaxMind\Db\Reader( $database_path ); |
|
| 152 | - $data = $reader->get( $ip_address ); |
|
| 151 | + $reader = new MaxMind\Db\Reader($database_path); |
|
| 152 | + $data = $reader->get($ip_address); |
|
| 153 | 153 | |
| 154 | - if ( isset( $data['country']['iso_code'] ) ) { |
|
| 154 | + if (isset($data['country']['iso_code'])) { |
|
| 155 | 155 | $country_code = $data['country']['iso_code']; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | $reader->close(); |
| 159 | - } catch ( Exception $e ) { |
|
| 160 | - wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' ); |
|
| 159 | + } catch (Exception $e) { |
|
| 160 | + wpinv_error_log($e->getMessage(), 'SOURCE: MaxMind GeoLocation'); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | return $country_code; |
@@ -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_Items Class. |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | * Retrieves the earning sql. |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | - public function get_sql( $range ) { |
|
| 19 | + public function get_sql($range) { |
|
| 20 | 20 | global $wpdb; |
| 21 | 21 | |
| 22 | 22 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 23 | - $clauses = $this->get_range_sql( $range ); |
|
| 23 | + $clauses = $this->get_range_sql($range); |
|
| 24 | 24 | |
| 25 | 25 | $sql = "SELECT |
| 26 | 26 | meta.gateway AS gateway, |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | ORDER BY total DESC |
| 36 | 36 | "; |
| 37 | 37 | |
| 38 | - return apply_filters( 'getpaid_gateways_graphs_get_sql', $sql, $range ); |
|
| 38 | + return apply_filters('getpaid_gateways_graphs_get_sql', $sql, $range); |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
@@ -45,30 +45,30 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function prepare_stats() { |
| 47 | 47 | global $wpdb; |
| 48 | - $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
| 49 | - $this->stats = $this->normalize_stats( $this->stats ); |
|
| 48 | + $this->stats = $wpdb->get_results($this->get_sql($this->get_range())); |
|
| 49 | + $this->stats = $this->normalize_stats($this->stats); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Normalizes the report stats. |
| 54 | 54 | * |
| 55 | 55 | */ |
| 56 | - public function normalize_stats( $stats ) { |
|
| 56 | + public function normalize_stats($stats) { |
|
| 57 | 57 | $normalized = array(); |
| 58 | 58 | $others = 0; |
| 59 | 59 | $did = 0; |
| 60 | 60 | |
| 61 | - foreach ( $stats as $stat ) { |
|
| 61 | + foreach ($stats as $stat) { |
|
| 62 | 62 | |
| 63 | - if ( $did > 4 ) { |
|
| 63 | + if ($did > 4) { |
|
| 64 | 64 | |
| 65 | - $others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ); |
|
| 65 | + $others += wpinv_round_amount(wpinv_sanitize_amount($stat->total)); |
|
| 66 | 66 | |
| 67 | 67 | } else { |
| 68 | 68 | |
| 69 | 69 | $normalized[] = array( |
| 70 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ), |
|
| 71 | - 'gateway' => strip_tags( wpinv_get_gateway_admin_label( $stat->gateway ) ), |
|
| 70 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($stat->total)), |
|
| 71 | + 'gateway' => strip_tags(wpinv_get_gateway_admin_label($stat->gateway)), |
|
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | 74 | } |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | $did++; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if ( $others > 0 ) { |
|
| 79 | + if ($others > 0) { |
|
| 80 | 80 | |
| 81 | 81 | $normalized[] = array( |
| 82 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $others ) ), |
|
| 83 | - 'gateway' => esc_html__( 'Others', 'invoicing' ), |
|
| 82 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($others)), |
|
| 83 | + 'gateway' => esc_html__('Others', 'invoicing'), |
|
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | } |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function get_data() { |
| 96 | 96 | |
| 97 | - $data = wp_list_pluck( $this->stats, 'total' ); |
|
| 98 | - $colors = array( '#009688','#4caf50','#8bc34a','#00bcd4','#03a9f4','#2196f3' ); |
|
| 97 | + $data = wp_list_pluck($this->stats, 'total'); |
|
| 98 | + $colors = array('#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3'); |
|
| 99 | 99 | |
| 100 | - shuffle( $colors ); |
|
| 100 | + shuffle($colors); |
|
| 101 | 101 | |
| 102 | 102 | return array( |
| 103 | 103 | 'data' => $data, |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | */ |
| 113 | 113 | public function get_labels() { |
| 114 | - return wp_list_pluck( $this->stats, 'gateway' ); |
|
| 114 | + return wp_list_pluck($this->stats, 'gateway'); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | type: 'doughnut', |
| 134 | 134 | data: { |
| 135 | - 'labels': <?php echo wp_json_encode( $this->get_labels() ); ?>, |
|
| 136 | - 'datasets': [ <?php echo wp_json_encode( $this->get_data() ); ?> ] |
|
| 135 | + 'labels': <?php echo wp_json_encode($this->get_labels()); ?>, |
|
| 136 | + 'datasets': [ <?php echo wp_json_encode($this->get_data()); ?> ] |
|
| 137 | 137 | }, |
| 138 | 138 | options: { |
| 139 | 139 | legend: { |
@@ -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_Discounts Class. |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | * Retrieves the discounts sql. |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | - public function get_sql( $range ) { |
|
| 19 | + public function get_sql($range) { |
|
| 20 | 20 | global $wpdb; |
| 21 | 21 | |
| 22 | 22 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 23 | - $clauses = $this->get_range_sql( $range ); |
|
| 23 | + $clauses = $this->get_range_sql($range); |
|
| 24 | 24 | |
| 25 | 25 | $sql = "SELECT |
| 26 | 26 | meta.discount_code AS discount_code, |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | ORDER BY total DESC |
| 37 | 37 | "; |
| 38 | 38 | |
| 39 | - return apply_filters( 'getpaid_discounts_graphs_get_sql', $sql, $range ); |
|
| 39 | + return apply_filters('getpaid_discounts_graphs_get_sql', $sql, $range); |
|
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
@@ -46,30 +46,30 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function prepare_stats() { |
| 48 | 48 | global $wpdb; |
| 49 | - $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
| 50 | - $this->stats = $this->normalize_stats( $this->stats ); |
|
| 49 | + $this->stats = $wpdb->get_results($this->get_sql($this->get_range())); |
|
| 50 | + $this->stats = $this->normalize_stats($this->stats); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Normalizes the report stats. |
| 55 | 55 | * |
| 56 | 56 | */ |
| 57 | - public function normalize_stats( $stats ) { |
|
| 57 | + public function normalize_stats($stats) { |
|
| 58 | 58 | $normalized = array(); |
| 59 | 59 | $others = 0; |
| 60 | 60 | $did = 0; |
| 61 | 61 | |
| 62 | - foreach ( $stats as $stat ) { |
|
| 62 | + foreach ($stats as $stat) { |
|
| 63 | 63 | |
| 64 | - if ( $did > 4 ) { |
|
| 64 | + if ($did > 4) { |
|
| 65 | 65 | |
| 66 | - $others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ); |
|
| 66 | + $others += wpinv_round_amount(wpinv_sanitize_amount($stat->total)); |
|
| 67 | 67 | |
| 68 | 68 | } else { |
| 69 | 69 | |
| 70 | 70 | $normalized[] = array( |
| 71 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ), |
|
| 72 | - 'discount_code' => strip_tags( $stat->discount_code ), |
|
| 71 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($stat->total)), |
|
| 72 | + 'discount_code' => strip_tags($stat->discount_code), |
|
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | 75 | } |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | $did++; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if ( $others > 0 ) { |
|
| 80 | + if ($others > 0) { |
|
| 81 | 81 | |
| 82 | 82 | $normalized[] = array( |
| 83 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $others ) ), |
|
| 84 | - 'discount_code' => esc_html__( 'Others', 'invoicing' ), |
|
| 83 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($others)), |
|
| 84 | + 'discount_code' => esc_html__('Others', 'invoicing'), |
|
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | } |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function get_data() { |
| 97 | 97 | |
| 98 | - $data = wp_list_pluck( $this->stats, 'total' ); |
|
| 99 | - $colors = array( '#009688','#4caf50','#8bc34a','#00bcd4','#03a9f4','#2196f3' ); |
|
| 98 | + $data = wp_list_pluck($this->stats, 'total'); |
|
| 99 | + $colors = array('#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3'); |
|
| 100 | 100 | |
| 101 | - shuffle( $colors ); |
|
| 101 | + shuffle($colors); |
|
| 102 | 102 | |
| 103 | 103 | return array( |
| 104 | 104 | 'data' => $data, |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | */ |
| 114 | 114 | public function get_labels() { |
| 115 | - return wp_list_pluck( $this->stats, 'discount_code' ); |
|
| 115 | + return wp_list_pluck($this->stats, 'discount_code'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | { |
| 134 | 134 | type: 'doughnut', |
| 135 | 135 | data: { |
| 136 | - 'labels': <?php echo wp_json_encode( $this->get_labels() ); ?>, |
|
| 137 | - 'datasets': [ <?php echo wp_json_encode( $this->get_data() ); ?> ] |
|
| 136 | + 'labels': <?php echo wp_json_encode($this->get_labels()); ?>, |
|
| 137 | + 'datasets': [ <?php echo wp_json_encode($this->get_data()); ?> ] |
|
| 138 | 138 | }, |
| 139 | 139 | options: { |
| 140 | 140 | legend: { |
@@ -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_Items Class. |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | * Retrieves the earning sql. |
| 17 | 17 | * |
| 18 | 18 | */ |
| 19 | - public function get_sql( $range ) { |
|
| 19 | + public function get_sql($range) { |
|
| 20 | 20 | global $wpdb; |
| 21 | 21 | |
| 22 | 22 | $table = $wpdb->prefix . 'getpaid_invoices'; |
| 23 | 23 | $table2 = $wpdb->prefix . 'getpaid_invoice_items'; |
| 24 | - $clauses = $this->get_range_sql( $range ); |
|
| 24 | + $clauses = $this->get_range_sql($range); |
|
| 25 | 25 | |
| 26 | 26 | $sql = "SELECT |
| 27 | 27 | item.item_name AS item_name, |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | ORDER BY total DESC |
| 39 | 39 | "; |
| 40 | 40 | |
| 41 | - return apply_filters( 'getpaid_items_graphs_get_sql', $sql, $range ); |
|
| 41 | + return apply_filters('getpaid_items_graphs_get_sql', $sql, $range); |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
@@ -48,30 +48,30 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function prepare_stats() { |
| 50 | 50 | global $wpdb; |
| 51 | - $this->stats = $wpdb->get_results( $this->get_sql( $this->get_range() ) ); |
|
| 52 | - $this->stats = $this->normalize_stats( $this->stats ); |
|
| 51 | + $this->stats = $wpdb->get_results($this->get_sql($this->get_range())); |
|
| 52 | + $this->stats = $this->normalize_stats($this->stats); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * Normalizes the report stats. |
| 57 | 57 | * |
| 58 | 58 | */ |
| 59 | - public function normalize_stats( $stats ) { |
|
| 59 | + public function normalize_stats($stats) { |
|
| 60 | 60 | $normalized = array(); |
| 61 | 61 | $others = 0; |
| 62 | 62 | $did = 0; |
| 63 | 63 | |
| 64 | - foreach ( $stats as $stat ) { |
|
| 64 | + foreach ($stats as $stat) { |
|
| 65 | 65 | |
| 66 | - if ( $did > 4 ) { |
|
| 66 | + if ($did > 4) { |
|
| 67 | 67 | |
| 68 | - $others += wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ); |
|
| 68 | + $others += wpinv_round_amount(wpinv_sanitize_amount($stat->total)); |
|
| 69 | 69 | |
| 70 | 70 | } else { |
| 71 | 71 | |
| 72 | 72 | $normalized[] = array( |
| 73 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $stat->total ) ), |
|
| 74 | - 'item_name' => strip_tags( $stat->item_name ), |
|
| 73 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($stat->total)), |
|
| 74 | + 'item_name' => strip_tags($stat->item_name), |
|
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | 77 | } |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | $did++; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( $others > 0 ) { |
|
| 82 | + if ($others > 0) { |
|
| 83 | 83 | |
| 84 | 84 | $normalized[] = array( |
| 85 | - 'total' => wpinv_round_amount( wpinv_sanitize_amount( $others ) ), |
|
| 86 | - 'item_name' => esc_html__( 'Others', 'invoicing' ), |
|
| 85 | + 'total' => wpinv_round_amount(wpinv_sanitize_amount($others)), |
|
| 86 | + 'item_name' => esc_html__('Others', 'invoicing'), |
|
| 87 | 87 | ); |
| 88 | 88 | |
| 89 | 89 | } |
@@ -97,10 +97,10 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function get_data() { |
| 99 | 99 | |
| 100 | - $data = wp_list_pluck( $this->stats, 'total' ); |
|
| 101 | - $colors = array( '#009688','#4caf50','#8bc34a','#00bcd4','#03a9f4','#2196f3' ); |
|
| 100 | + $data = wp_list_pluck($this->stats, 'total'); |
|
| 101 | + $colors = array('#009688', '#4caf50', '#8bc34a', '#00bcd4', '#03a9f4', '#2196f3'); |
|
| 102 | 102 | |
| 103 | - shuffle( $colors ); |
|
| 103 | + shuffle($colors); |
|
| 104 | 104 | |
| 105 | 105 | return array( |
| 106 | 106 | 'data' => $data, |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | */ |
| 116 | 116 | public function get_labels() { |
| 117 | - return wp_list_pluck( $this->stats, 'item_name' ); |
|
| 117 | + return wp_list_pluck($this->stats, 'item_name'); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | type: 'doughnut', |
| 137 | 137 | data: { |
| 138 | - 'labels': <?php echo wp_json_encode( $this->get_labels() ); ?>, |
|
| 139 | - 'datasets': [ <?php echo wp_json_encode( $this->get_data() ); ?> ] |
|
| 138 | + 'labels': <?php echo wp_json_encode($this->get_labels()); ?>, |
|
| 139 | + 'datasets': [ <?php echo wp_json_encode($this->get_data()); ?> ] |
|
| 140 | 140 | }, |
| 141 | 141 | options: { |
| 142 | 142 | legend: { |