@@ -55,27 +55,27 @@ |
||
55 | 55 | public static function vat_rates_settings() {} |
56 | 56 | |
57 | 57 | /** |
58 | - * |
|
59 | - * @deprecated |
|
60 | - */ |
|
58 | + * |
|
59 | + * @deprecated |
|
60 | + */ |
|
61 | 61 | public static function vat_settings() {} |
62 | 62 | |
63 | 63 | /** |
64 | - * |
|
65 | - * @deprecated |
|
66 | - */ |
|
64 | + * |
|
65 | + * @deprecated |
|
66 | + */ |
|
67 | 67 | public static function maxmind_folder() {} |
68 | 68 | |
69 | 69 | /** |
70 | - * |
|
71 | - * @deprecated |
|
72 | - */ |
|
70 | + * |
|
71 | + * @deprecated |
|
72 | + */ |
|
73 | 73 | public static function geoip2_download_database() {} |
74 | 74 | |
75 | 75 | /** |
76 | - * |
|
77 | - * @deprecated |
|
78 | - */ |
|
76 | + * |
|
77 | + * @deprecated |
|
78 | + */ |
|
79 | 79 | public static function geoip2_download_file() {} |
80 | 80 | |
81 | 81 | /** |
@@ -18,102 +18,102 @@ |
||
18 | 18 | */ |
19 | 19 | class GetPaid_REST_Report_Invoice_Counts_Controller extends GetPaid_REST_Reports_Controller { |
20 | 20 | |
21 | - /** |
|
22 | - * Route base. |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $rest_base = 'reports/invoices/counts'; |
|
27 | - |
|
28 | - /** |
|
29 | - * Prepare a report object for serialization. |
|
30 | - * |
|
31 | - * @param stdClass $report Report data. |
|
32 | - * @param WP_REST_Request $request Request object. |
|
33 | - * @return WP_REST_Response $response Response data. |
|
34 | - */ |
|
35 | - public function prepare_item_for_response( $report, $request ) { |
|
36 | - |
|
37 | - $data = (array) $report; |
|
38 | - $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
39 | - $data = $this->add_additional_fields_to_object( $data, $request ); |
|
40 | - $data = $this->filter_response_by_context( $data, $context ); |
|
41 | - |
|
42 | - // Wrap the data in a response object. |
|
43 | - $response = rest_ensure_response( $data ); |
|
44 | - |
|
45 | - $response->add_links( |
|
46 | - array( |
|
47 | - 'about' => array( |
|
48 | - 'href' => rest_url( sprintf( '%s/reports', $this->namespace ) ), |
|
49 | - ), |
|
50 | - ) |
|
51 | - ); |
|
52 | - |
|
53 | - return apply_filters( 'getpaid_rest_prepare_report_invoices_count', $response, $report, $request ); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Get reports list. |
|
58 | - * |
|
59 | - * @since 2.0.0 |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - protected function get_reports() { |
|
63 | - |
|
64 | - $counts = wp_count_posts( 'wpi_invoice' ); |
|
65 | - $data = array(); |
|
66 | - |
|
67 | - foreach ( wpinv_get_invoice_statuses() as $slug => $name ) { |
|
68 | - |
|
69 | - if ( ! isset( $counts->$slug ) ) { |
|
70 | - continue; |
|
71 | - } |
|
72 | - |
|
73 | - $data[] = array( |
|
74 | - 'slug' => $slug, |
|
75 | - 'name' => $name, |
|
76 | - 'count' => (int) $counts->$slug, |
|
77 | - ); |
|
78 | - |
|
79 | - } |
|
80 | - |
|
81 | - return $data; |
|
82 | - |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Get the Report's schema, conforming to JSON Schema. |
|
87 | - * |
|
88 | - * @return array |
|
89 | - */ |
|
90 | - public function get_item_schema() { |
|
91 | - $schema = array( |
|
92 | - '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
93 | - 'title' => 'report_invoice_counts', |
|
94 | - 'type' => 'object', |
|
95 | - 'properties' => array( |
|
96 | - 'slug' => array( |
|
97 | - 'description' => __( 'An alphanumeric identifier for the resource.', 'invoicing' ), |
|
98 | - 'type' => 'string', |
|
99 | - 'context' => array( 'view' ), |
|
100 | - 'readonly' => true, |
|
101 | - ), |
|
102 | - 'name' => array( |
|
103 | - 'description' => __( 'Invoice status name.', 'invoicing' ), |
|
104 | - 'type' => 'string', |
|
105 | - 'context' => array( 'view' ), |
|
106 | - 'readonly' => true, |
|
107 | - ), |
|
108 | - 'count' => array( |
|
109 | - 'description' => __( 'Number of invoices.', 'invoicing' ), |
|
110 | - 'type' => 'string', |
|
111 | - 'context' => array( 'view' ), |
|
112 | - 'readonly' => true, |
|
113 | - ), |
|
114 | - ), |
|
115 | - ); |
|
116 | - |
|
117 | - return $this->add_additional_fields_schema( $schema ); |
|
118 | - } |
|
21 | + /** |
|
22 | + * Route base. |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $rest_base = 'reports/invoices/counts'; |
|
27 | + |
|
28 | + /** |
|
29 | + * Prepare a report object for serialization. |
|
30 | + * |
|
31 | + * @param stdClass $report Report data. |
|
32 | + * @param WP_REST_Request $request Request object. |
|
33 | + * @return WP_REST_Response $response Response data. |
|
34 | + */ |
|
35 | + public function prepare_item_for_response( $report, $request ) { |
|
36 | + |
|
37 | + $data = (array) $report; |
|
38 | + $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; |
|
39 | + $data = $this->add_additional_fields_to_object( $data, $request ); |
|
40 | + $data = $this->filter_response_by_context( $data, $context ); |
|
41 | + |
|
42 | + // Wrap the data in a response object. |
|
43 | + $response = rest_ensure_response( $data ); |
|
44 | + |
|
45 | + $response->add_links( |
|
46 | + array( |
|
47 | + 'about' => array( |
|
48 | + 'href' => rest_url( sprintf( '%s/reports', $this->namespace ) ), |
|
49 | + ), |
|
50 | + ) |
|
51 | + ); |
|
52 | + |
|
53 | + return apply_filters( 'getpaid_rest_prepare_report_invoices_count', $response, $report, $request ); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Get reports list. |
|
58 | + * |
|
59 | + * @since 2.0.0 |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + protected function get_reports() { |
|
63 | + |
|
64 | + $counts = wp_count_posts( 'wpi_invoice' ); |
|
65 | + $data = array(); |
|
66 | + |
|
67 | + foreach ( wpinv_get_invoice_statuses() as $slug => $name ) { |
|
68 | + |
|
69 | + if ( ! isset( $counts->$slug ) ) { |
|
70 | + continue; |
|
71 | + } |
|
72 | + |
|
73 | + $data[] = array( |
|
74 | + 'slug' => $slug, |
|
75 | + 'name' => $name, |
|
76 | + 'count' => (int) $counts->$slug, |
|
77 | + ); |
|
78 | + |
|
79 | + } |
|
80 | + |
|
81 | + return $data; |
|
82 | + |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Get the Report's schema, conforming to JSON Schema. |
|
87 | + * |
|
88 | + * @return array |
|
89 | + */ |
|
90 | + public function get_item_schema() { |
|
91 | + $schema = array( |
|
92 | + '$schema' => 'http://json-schema.org/draft-04/schema#', |
|
93 | + 'title' => 'report_invoice_counts', |
|
94 | + 'type' => 'object', |
|
95 | + 'properties' => array( |
|
96 | + 'slug' => array( |
|
97 | + 'description' => __( 'An alphanumeric identifier for the resource.', 'invoicing' ), |
|
98 | + 'type' => 'string', |
|
99 | + 'context' => array( 'view' ), |
|
100 | + 'readonly' => true, |
|
101 | + ), |
|
102 | + 'name' => array( |
|
103 | + 'description' => __( 'Invoice status name.', 'invoicing' ), |
|
104 | + 'type' => 'string', |
|
105 | + 'context' => array( 'view' ), |
|
106 | + 'readonly' => true, |
|
107 | + ), |
|
108 | + 'count' => array( |
|
109 | + 'description' => __( 'Number of invoices.', 'invoicing' ), |
|
110 | + 'type' => 'string', |
|
111 | + 'context' => array( 'view' ), |
|
112 | + 'readonly' => true, |
|
113 | + ), |
|
114 | + ), |
|
115 | + ); |
|
116 | + |
|
117 | + return $this->add_additional_fields_schema( $schema ); |
|
118 | + } |
|
119 | 119 | } |
@@ -37,25 +37,25 @@ |
||
37 | 37 | public function get_privacy_message() { |
38 | 38 | |
39 | 39 | $content = '<div class="wp-suggested-text">' . |
40 | - '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' . |
|
41 | - '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' . |
|
42 | - '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' . |
|
43 | - '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' . |
|
44 | - '<ul>' . |
|
45 | - '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' . |
|
46 | - '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' . |
|
47 | - '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' . |
|
48 | - '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
49 | - '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' . |
|
50 | - '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
51 | - '</ul>' . |
|
52 | - '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' . |
|
53 | - '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' . |
|
54 | - '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' . |
|
55 | - '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' . |
|
56 | - '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' . |
|
57 | - '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' . |
|
58 | - '</div>'; |
|
40 | + '<h2>' . __( 'Invoices and checkout', 'invoicing' ) . '</h2>' . |
|
41 | + '<p class="privacy-policy-tutorial">' . __( 'Example privacy texts.', 'invoicing' ) . '</p>' . |
|
42 | + '<p>' . __( 'We collect information about you during the checkout process on our site. This information may include, but is not limited to, your name, email address, phone number, address, IP and any other details that might be requested from you for the purpose of processing your payment and retaining your invoice details for legal reasons.', 'invoicing' ) . '</p>' . |
|
43 | + '<p>' . __( 'Handling this data also allows us to:', 'invoicing' ) . '</p>' . |
|
44 | + '<ul>' . |
|
45 | + '<li>' . __( '- Send you important account/invoice/service information.', 'invoicing' ) . '</li>' . |
|
46 | + '<li>' . __( '- Estimate taxes based on your location.', 'invoicing' ) . '</li>' . |
|
47 | + '<li>' . __( '- Respond to your queries or complaints.', 'invoicing' ) . '</li>' . |
|
48 | + '<li>' . __( '- Process payments and to prevent fraudulent transactions. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
49 | + '<li>' . __( '- Retain historical payment and invoice history. We do this on the basis of legal obligations.', 'invoicing' ) . '</li>' . |
|
50 | + '<li>' . __( '- Set up and administer your account, provide technical and/or customer support, and to verify your identity. We do this on the basis of our legitimate business interests.', 'invoicing' ) . '</li>' . |
|
51 | + '</ul>' . |
|
52 | + '<p>' . __( 'In addition to collecting information at checkout we may also use and store your contact details when manually creating invoices for require payments relating to prior contractual agreements or agreed terms.', 'invoicing' ) . '</p>' . |
|
53 | + '<h2>' . __( 'What we share with others', 'invoicing' ) . '</h2>' . |
|
54 | + '<p>' . __( 'We share information with third parties who help us provide our payment and invoicing services to you; for example --', 'invoicing' ) . '</p>' . |
|
55 | + '<p class="privacy-policy-tutorial">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'invoicing' ) . '</p>' . |
|
56 | + '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'invoicing' ) . '</p>' . |
|
57 | + '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'invoicing' ) . '</p>' . |
|
58 | + '</div>'; |
|
59 | 59 | |
60 | 60 | return apply_filters( 'wpinv_privacy_policy_content', $content ); |
61 | 61 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | class OxidInstaller extends BaseInstaller |
7 | 7 | { |
8 | - const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
8 | + const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
9 | 9 | |
10 | 10 | protected $locations = array( |
11 | 11 | 'module' => 'modules/{$name}/', |
@@ -13,47 +13,47 @@ discard block |
||
13 | 13 | 'out' => 'out/{$name}/', |
14 | 14 | ); |
15 | 15 | |
16 | - /** |
|
17 | - * getInstallPath |
|
18 | - * |
|
19 | - * @param PackageInterface $package |
|
20 | - * @param string $frameworkType |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | - { |
|
25 | - $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | - $type = $this->package->getType(); |
|
27 | - if ($type === 'oxid-module') { |
|
28 | - $this->prepareVendorDirectory($installPath); |
|
29 | - } |
|
30 | - return $installPath; |
|
31 | - } |
|
16 | + /** |
|
17 | + * getInstallPath |
|
18 | + * |
|
19 | + * @param PackageInterface $package |
|
20 | + * @param string $frameworkType |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | + { |
|
25 | + $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | + $type = $this->package->getType(); |
|
27 | + if ($type === 'oxid-module') { |
|
28 | + $this->prepareVendorDirectory($installPath); |
|
29 | + } |
|
30 | + return $installPath; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * prepareVendorDirectory |
|
35 | - * |
|
36 | - * Makes sure there is a vendormetadata.php file inside |
|
37 | - * the vendor folder if there is a vendor folder. |
|
38 | - * |
|
39 | - * @param string $installPath |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - protected function prepareVendorDirectory($installPath) |
|
43 | - { |
|
44 | - $matches = ''; |
|
45 | - $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | - if (!$hasVendorDirectory) { |
|
47 | - return; |
|
48 | - } |
|
33 | + /** |
|
34 | + * prepareVendorDirectory |
|
35 | + * |
|
36 | + * Makes sure there is a vendormetadata.php file inside |
|
37 | + * the vendor folder if there is a vendor folder. |
|
38 | + * |
|
39 | + * @param string $installPath |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + protected function prepareVendorDirectory($installPath) |
|
43 | + { |
|
44 | + $matches = ''; |
|
45 | + $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | + if (!$hasVendorDirectory) { |
|
47 | + return; |
|
48 | + } |
|
49 | 49 | |
50 | - $vendorDirectory = $matches['vendor']; |
|
51 | - $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | - if (!file_exists($vendorPath)) { |
|
53 | - mkdir($vendorPath, 0755, true); |
|
54 | - } |
|
50 | + $vendorDirectory = $matches['vendor']; |
|
51 | + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | + if (!file_exists($vendorPath)) { |
|
53 | + mkdir($vendorPath, 0755, true); |
|
54 | + } |
|
55 | 55 | |
56 | - $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | - touch($vendorMetaDataPath); |
|
58 | - } |
|
56 | + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | + touch($vendorMetaDataPath); |
|
58 | + } |
|
59 | 59 | } |
@@ -14,51 +14,51 @@ |
||
14 | 14 | */ |
15 | 15 | class GetPaid_Payment_Exception extends Exception { |
16 | 16 | |
17 | - /** |
|
18 | - * Sanitized error code. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $error_code; |
|
17 | + /** |
|
18 | + * Sanitized error code. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $error_code; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Error extra data. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $error_data; |
|
24 | + /** |
|
25 | + * Error extra data. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $error_data; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Setup exception. |
|
33 | - * |
|
34 | - * @param string $code Machine-readable error code, e.g `getpaid-discount-error`. |
|
35 | - * @param string $message User-friendly translated error message, e.g. 'Discount is invalid'. |
|
36 | - * @param int $http_status_code Proper HTTP status code to respond with, e.g. 400. |
|
37 | - * @param array $data Extra error data. |
|
38 | - */ |
|
39 | - public function __construct( $code, $message, $http_status_code = 400, $data = array() ) { |
|
40 | - $this->error_code = $code; |
|
41 | - $this->error_data = array_merge( array( 'status' => $http_status_code ), $data ); |
|
31 | + /** |
|
32 | + * Setup exception. |
|
33 | + * |
|
34 | + * @param string $code Machine-readable error code, e.g `getpaid-discount-error`. |
|
35 | + * @param string $message User-friendly translated error message, e.g. 'Discount is invalid'. |
|
36 | + * @param int $http_status_code Proper HTTP status code to respond with, e.g. 400. |
|
37 | + * @param array $data Extra error data. |
|
38 | + */ |
|
39 | + public function __construct( $code, $message, $http_status_code = 400, $data = array() ) { |
|
40 | + $this->error_code = $code; |
|
41 | + $this->error_data = array_merge( array( 'status' => $http_status_code ), $data ); |
|
42 | 42 | |
43 | - parent::__construct( $message, $http_status_code ); |
|
44 | - } |
|
43 | + parent::__construct( $message, $http_status_code ); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Returns the error code. |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function getErrorCode() { |
|
52 | - return $this->error_code; |
|
53 | - } |
|
46 | + /** |
|
47 | + * Returns the error code. |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function getErrorCode() { |
|
52 | + return $this->error_code; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Returns error data. |
|
57 | - * |
|
58 | - * @return array |
|
59 | - */ |
|
60 | - public function getErrorData() { |
|
61 | - return $this->error_data; |
|
62 | - } |
|
55 | + /** |
|
56 | + * Returns error data. |
|
57 | + * |
|
58 | + * @return array |
|
59 | + */ |
|
60 | + public function getErrorData() { |
|
61 | + return $this->error_data; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; // Exit if accessed directly |
|
10 | + exit; // Exit if accessed directly |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | class GetPaid_Meta_Box_Payment_Form { |
17 | 17 | |
18 | 18 | /** |
19 | - * Output the metabox. |
|
20 | - * |
|
21 | - * @param WP_Post $post |
|
22 | - */ |
|
19 | + * Output the metabox. |
|
20 | + * |
|
21 | + * @param WP_Post $post |
|
22 | + */ |
|
23 | 23 | public static function output( $post ) { |
24 | 24 | ?> |
25 | 25 | <style> |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | - * Save meta box data. |
|
106 | - * |
|
107 | - * @param int $post_id |
|
108 | - */ |
|
109 | - public static function save( $post_id ) { |
|
105 | + * Save meta box data. |
|
106 | + * |
|
107 | + * @param int $post_id |
|
108 | + */ |
|
109 | + public static function save( $post_id ) { |
|
110 | 110 | |
111 | 111 | // Prepare the form. |
112 | 112 | $form = new GetPaid_Payment_Form( $post_id ); |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | - * Converts an array fo form items to objects. |
|
141 | - * |
|
142 | - * @param array $items |
|
143 | - */ |
|
144 | - public static function item_to_objects( $items ) { |
|
140 | + * Converts an array fo form items to objects. |
|
141 | + * |
|
142 | + * @param array $items |
|
143 | + */ |
|
144 | + public static function item_to_objects( $items ) { |
|
145 | 145 | |
146 | 146 | $objects = array(); |
147 | 147 |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @deprecated |
247 | 247 | */ |
248 | 248 | function wpinv_get_payment_key( $invoice = 0 ) { |
249 | - $invoice = new WPInv_Invoice( $invoice ); |
|
249 | + $invoice = new WPInv_Invoice( $invoice ); |
|
250 | 250 | return $invoice->get_key(); |
251 | 251 | } |
252 | 252 | |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @deprecated |
425 | 425 | */ |
426 | 426 | function wpinv_get_checkout_session() { |
427 | - return false; |
|
427 | + return false; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -1273,5 +1273,5 @@ discard block |
||
1273 | 1273 | * @deprecated |
1274 | 1274 | */ |
1275 | 1275 | function wpinv_get_subscription( $invoice ) { |
1276 | - return wpinv_get_invoice_subscription( $invoice ); |
|
1276 | + return wpinv_get_invoice_subscription( $invoice ); |
|
1277 | 1277 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
9 | - exit; // Exit if accessed directly |
|
9 | + exit; // Exit if accessed directly |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | class GetPaid_Meta_Box_Invoice_Subscription { |
16 | 16 | |
17 | 17 | /** |
18 | - * Output the subscription metabox. |
|
19 | - * |
|
20 | - * @param WP_Post $post |
|
21 | - */ |
|
18 | + * Output the subscription metabox. |
|
19 | + * |
|
20 | + * @param WP_Post $post |
|
21 | + */ |
|
22 | 22 | public static function output( $post ) { |
23 | 23 | |
24 | 24 | // Fetch the invoice. |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | - * Output the subscription invoices. |
|
38 | - * |
|
39 | - * @param WP_Post $post |
|
40 | - */ |
|
37 | + * Output the subscription invoices. |
|
38 | + * |
|
39 | + * @param WP_Post $post |
|
40 | + */ |
|
41 | 41 | public static function output_invoices( $post ) { |
42 | 42 | |
43 | 43 | // Fetch the invoice. |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | - * Outputs related subscriptions. |
|
57 | - * |
|
58 | - * @param WP_Post $post |
|
59 | - */ |
|
56 | + * Outputs related subscriptions. |
|
57 | + * |
|
58 | + * @param WP_Post $post |
|
59 | + */ |
|
60 | 60 | public static function output_related( $post ) { |
61 | 61 | |
62 | 62 | // Fetch the invoice. |
@@ -16,165 +16,165 @@ |
||
16 | 16 | */ |
17 | 17 | class GetPaid_MaxMind_Geolocation { |
18 | 18 | |
19 | - /** |
|
20 | - * The service responsible for interacting with the MaxMind database. |
|
21 | - * |
|
22 | - * @var GetPaid_MaxMind_Database_Service |
|
23 | - */ |
|
24 | - private $database_service; |
|
25 | - |
|
26 | - /** |
|
27 | - * Initialize the integration. |
|
28 | - */ |
|
29 | - public function __construct() { |
|
30 | - |
|
31 | - /** |
|
32 | - * Supports overriding the database service to be used. |
|
33 | - * |
|
34 | - * @since 1.0.19 |
|
35 | - * @return mixed|null The geolocation database service. |
|
36 | - */ |
|
37 | - $this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null ); |
|
38 | - if ( null === $this->database_service ) { |
|
39 | - $this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() ); |
|
40 | - } |
|
41 | - |
|
42 | - // Bind to the scheduled updater action. |
|
43 | - add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) ); |
|
44 | - |
|
45 | - // Bind to the geolocation filter for MaxMind database lookups. |
|
46 | - add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 ); |
|
47 | - |
|
48 | - // Handle maxmind key updates. |
|
49 | - add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) ); |
|
50 | - |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Get database service. |
|
55 | - * |
|
56 | - * @return GetPaid_MaxMind_Database_Service|null |
|
57 | - */ |
|
58 | - public function get_database_service() { |
|
59 | - return $this->database_service; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Checks to make sure that the license key is valid. |
|
64 | - * |
|
65 | - * @param string $license_key The new license key. |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function handle_key_updates( $license_key ) { |
|
69 | - |
|
70 | - // Trim whitespaces and strip slashes. |
|
71 | - $license_key = trim( $license_key ); |
|
72 | - |
|
73 | - // Abort if the license key is empty or unchanged. |
|
74 | - if ( empty( $license_key ) ) { |
|
75 | - return $license_key; |
|
76 | - } |
|
77 | - |
|
78 | - // Abort if a database exists and the license key is unchaged. |
|
79 | - if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) { |
|
80 | - return $license_key; |
|
81 | - } |
|
82 | - |
|
83 | - // Check the license key by attempting to download the Geolocation database. |
|
84 | - $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
85 | - if ( is_wp_error( $tmp_database_path ) ) { |
|
86 | - getpaid_admin()->show_error( $tmp_database_path->get_error_message() ); |
|
87 | - return $license_key; |
|
88 | - } |
|
89 | - |
|
90 | - $this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path ); |
|
91 | - |
|
92 | - return $license_key; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Updates the database used for geolocation queries. |
|
97 | - * |
|
98 | - * @param string $tmp_database_path Temporary database path. |
|
99 | - */ |
|
100 | - public function update_database( $tmp_database_path = null ) { |
|
101 | - |
|
102 | - // Allow us to easily interact with the filesystem. |
|
103 | - require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
104 | - WP_Filesystem(); |
|
105 | - global $wp_filesystem; |
|
106 | - |
|
107 | - // Remove any existing archives to comply with the MaxMind TOS. |
|
108 | - $target_database_path = $this->database_service->get_database_path(); |
|
109 | - |
|
110 | - // If there's no database path, we can't store the database. |
|
111 | - if ( empty( $target_database_path ) ) { |
|
112 | - return; |
|
113 | - } |
|
114 | - |
|
115 | - if ( $wp_filesystem->exists( $target_database_path ) ) { |
|
116 | - $wp_filesystem->delete( $target_database_path ); |
|
117 | - } |
|
118 | - |
|
119 | - // We can't download a database if there's no license key configured. |
|
120 | - $license_key = wpinv_get_option( 'maxmind_license_key' ); |
|
121 | - if ( empty( $license_key ) ) { |
|
122 | - return; |
|
123 | - } |
|
124 | - |
|
125 | - if ( empty( $tmp_database_path ) ) { |
|
126 | - $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
127 | - } |
|
128 | - |
|
129 | - if ( is_wp_error( $tmp_database_path ) ) { |
|
130 | - wpinv_error_log( $tmp_database_path->get_error_message() ); |
|
131 | - return; |
|
132 | - } |
|
133 | - |
|
134 | - // Move the new database into position. |
|
135 | - $wp_filesystem->move( $tmp_database_path, $target_database_path, true ); |
|
136 | - $wp_filesystem->delete( dirname( $tmp_database_path ) ); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Performs a geolocation lookup against the MaxMind database for the given IP address. |
|
141 | - * |
|
142 | - * @param array $data Geolocation data. |
|
143 | - * @param string $ip_address The IP address to geolocate. |
|
144 | - * @return array Geolocation including country code, state, city and postcode based on an IP address. |
|
145 | - */ |
|
146 | - public function get_geolocation( $data, $ip_address ) { |
|
147 | - |
|
148 | - if ( ! empty( $data['country'] ) || empty( $ip_address ) ) { |
|
149 | - return $data; |
|
150 | - } |
|
151 | - |
|
152 | - $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address ); |
|
153 | - |
|
154 | - return array( |
|
155 | - 'country' => $country_code, |
|
156 | - 'state' => '', |
|
157 | - 'city' => '', |
|
158 | - 'postcode' => '', |
|
159 | - ); |
|
160 | - |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Fetches the prefix for the MaxMind database file. |
|
165 | - * |
|
166 | - * @return string |
|
167 | - */ |
|
168 | - private function get_database_prefix() { |
|
169 | - |
|
170 | - $prefix = get_option( 'wpinv_maxmind_database_prefix' ); |
|
171 | - |
|
172 | - if ( empty( $prefix ) ) { |
|
173 | - $prefix = md5( uniqid( 'wpinv' ) ); |
|
174 | - update_option( 'wpinv_maxmind_database_prefix', $prefix ); |
|
175 | - } |
|
176 | - |
|
177 | - return $prefix; |
|
178 | - } |
|
19 | + /** |
|
20 | + * The service responsible for interacting with the MaxMind database. |
|
21 | + * |
|
22 | + * @var GetPaid_MaxMind_Database_Service |
|
23 | + */ |
|
24 | + private $database_service; |
|
25 | + |
|
26 | + /** |
|
27 | + * Initialize the integration. |
|
28 | + */ |
|
29 | + public function __construct() { |
|
30 | + |
|
31 | + /** |
|
32 | + * Supports overriding the database service to be used. |
|
33 | + * |
|
34 | + * @since 1.0.19 |
|
35 | + * @return mixed|null The geolocation database service. |
|
36 | + */ |
|
37 | + $this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null ); |
|
38 | + if ( null === $this->database_service ) { |
|
39 | + $this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() ); |
|
40 | + } |
|
41 | + |
|
42 | + // Bind to the scheduled updater action. |
|
43 | + add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) ); |
|
44 | + |
|
45 | + // Bind to the geolocation filter for MaxMind database lookups. |
|
46 | + add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 ); |
|
47 | + |
|
48 | + // Handle maxmind key updates. |
|
49 | + add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) ); |
|
50 | + |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Get database service. |
|
55 | + * |
|
56 | + * @return GetPaid_MaxMind_Database_Service|null |
|
57 | + */ |
|
58 | + public function get_database_service() { |
|
59 | + return $this->database_service; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Checks to make sure that the license key is valid. |
|
64 | + * |
|
65 | + * @param string $license_key The new license key. |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function handle_key_updates( $license_key ) { |
|
69 | + |
|
70 | + // Trim whitespaces and strip slashes. |
|
71 | + $license_key = trim( $license_key ); |
|
72 | + |
|
73 | + // Abort if the license key is empty or unchanged. |
|
74 | + if ( empty( $license_key ) ) { |
|
75 | + return $license_key; |
|
76 | + } |
|
77 | + |
|
78 | + // Abort if a database exists and the license key is unchaged. |
|
79 | + if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) { |
|
80 | + return $license_key; |
|
81 | + } |
|
82 | + |
|
83 | + // Check the license key by attempting to download the Geolocation database. |
|
84 | + $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
85 | + if ( is_wp_error( $tmp_database_path ) ) { |
|
86 | + getpaid_admin()->show_error( $tmp_database_path->get_error_message() ); |
|
87 | + return $license_key; |
|
88 | + } |
|
89 | + |
|
90 | + $this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path ); |
|
91 | + |
|
92 | + return $license_key; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Updates the database used for geolocation queries. |
|
97 | + * |
|
98 | + * @param string $tmp_database_path Temporary database path. |
|
99 | + */ |
|
100 | + public function update_database( $tmp_database_path = null ) { |
|
101 | + |
|
102 | + // Allow us to easily interact with the filesystem. |
|
103 | + require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
104 | + WP_Filesystem(); |
|
105 | + global $wp_filesystem; |
|
106 | + |
|
107 | + // Remove any existing archives to comply with the MaxMind TOS. |
|
108 | + $target_database_path = $this->database_service->get_database_path(); |
|
109 | + |
|
110 | + // If there's no database path, we can't store the database. |
|
111 | + if ( empty( $target_database_path ) ) { |
|
112 | + return; |
|
113 | + } |
|
114 | + |
|
115 | + if ( $wp_filesystem->exists( $target_database_path ) ) { |
|
116 | + $wp_filesystem->delete( $target_database_path ); |
|
117 | + } |
|
118 | + |
|
119 | + // We can't download a database if there's no license key configured. |
|
120 | + $license_key = wpinv_get_option( 'maxmind_license_key' ); |
|
121 | + if ( empty( $license_key ) ) { |
|
122 | + return; |
|
123 | + } |
|
124 | + |
|
125 | + if ( empty( $tmp_database_path ) ) { |
|
126 | + $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
127 | + } |
|
128 | + |
|
129 | + if ( is_wp_error( $tmp_database_path ) ) { |
|
130 | + wpinv_error_log( $tmp_database_path->get_error_message() ); |
|
131 | + return; |
|
132 | + } |
|
133 | + |
|
134 | + // Move the new database into position. |
|
135 | + $wp_filesystem->move( $tmp_database_path, $target_database_path, true ); |
|
136 | + $wp_filesystem->delete( dirname( $tmp_database_path ) ); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Performs a geolocation lookup against the MaxMind database for the given IP address. |
|
141 | + * |
|
142 | + * @param array $data Geolocation data. |
|
143 | + * @param string $ip_address The IP address to geolocate. |
|
144 | + * @return array Geolocation including country code, state, city and postcode based on an IP address. |
|
145 | + */ |
|
146 | + public function get_geolocation( $data, $ip_address ) { |
|
147 | + |
|
148 | + if ( ! empty( $data['country'] ) || empty( $ip_address ) ) { |
|
149 | + return $data; |
|
150 | + } |
|
151 | + |
|
152 | + $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address ); |
|
153 | + |
|
154 | + return array( |
|
155 | + 'country' => $country_code, |
|
156 | + 'state' => '', |
|
157 | + 'city' => '', |
|
158 | + 'postcode' => '', |
|
159 | + ); |
|
160 | + |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Fetches the prefix for the MaxMind database file. |
|
165 | + * |
|
166 | + * @return string |
|
167 | + */ |
|
168 | + private function get_database_prefix() { |
|
169 | + |
|
170 | + $prefix = get_option( 'wpinv_maxmind_database_prefix' ); |
|
171 | + |
|
172 | + if ( empty( $prefix ) ) { |
|
173 | + $prefix = md5( uniqid( 'wpinv' ) ); |
|
174 | + update_option( 'wpinv_maxmind_database_prefix', $prefix ); |
|
175 | + } |
|
176 | + |
|
177 | + return $prefix; |
|
178 | + } |
|
179 | 179 | |
180 | 180 | } |