@@ -15,331 +15,331 @@ |
||
15 | 15 | class GetPaid_Post_Types { |
16 | 16 | |
17 | 17 | /** |
18 | - * Hook in methods. |
|
19 | - */ |
|
20 | - public function __construct() { |
|
21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | - } |
|
18 | + * Hook in methods. |
|
19 | + */ |
|
20 | + public function __construct() { |
|
21 | + add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | + add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | + add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | + add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Register core post types. |
|
29 | - */ |
|
30 | - public static function register_post_types() { |
|
27 | + /** |
|
28 | + * Register core post types. |
|
29 | + */ |
|
30 | + public static function register_post_types() { |
|
31 | 31 | |
32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | - return; |
|
34 | - } |
|
32 | + if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | + return; |
|
34 | + } |
|
35 | 35 | |
36 | - $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
36 | + $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
37 | 37 | |
38 | - // Fires before registering post types. |
|
39 | - do_action( 'getpaid_register_post_types' ); |
|
38 | + // Fires before registering post types. |
|
39 | + do_action( 'getpaid_register_post_types' ); |
|
40 | 40 | |
41 | - // Register item post type. |
|
42 | - register_post_type( |
|
43 | - 'wpi_item', |
|
44 | - apply_filters( |
|
45 | - 'wpinv_register_post_type_invoice_item', |
|
46 | - array( |
|
47 | - 'labels' => array( |
|
48 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | - 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | - 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | - 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
62 | - ), |
|
63 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | - 'public' => false, |
|
65 | - 'has_archive' => false, |
|
66 | - '_builtin' => false, |
|
67 | - 'show_ui' => true, |
|
68 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
69 | - 'show_in_nav_menus' => false, |
|
70 | - 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | - 'rewrite' => false, |
|
72 | - 'query_var' => false, |
|
73 | - 'map_meta_cap' => true, |
|
74 | - 'show_in_admin_bar' => true, |
|
75 | - 'can_export' => true, |
|
76 | - ) |
|
77 | - ) |
|
78 | - ); |
|
41 | + // Register item post type. |
|
42 | + register_post_type( |
|
43 | + 'wpi_item', |
|
44 | + apply_filters( |
|
45 | + 'wpinv_register_post_type_invoice_item', |
|
46 | + array( |
|
47 | + 'labels' => array( |
|
48 | + 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | + 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | + 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | + 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | + 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | + 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | + 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | + 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | + 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | + 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | + 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | + 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | + 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | + 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
62 | + ), |
|
63 | + 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | + 'public' => false, |
|
65 | + 'has_archive' => false, |
|
66 | + '_builtin' => false, |
|
67 | + 'show_ui' => true, |
|
68 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
69 | + 'show_in_nav_menus' => false, |
|
70 | + 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | + 'rewrite' => false, |
|
72 | + 'query_var' => false, |
|
73 | + 'map_meta_cap' => true, |
|
74 | + 'show_in_admin_bar' => true, |
|
75 | + 'can_export' => true, |
|
76 | + ) |
|
77 | + ) |
|
78 | + ); |
|
79 | 79 | |
80 | - // Register payment form post type. |
|
81 | - register_post_type( |
|
82 | - 'wpi_payment_form', |
|
83 | - apply_filters( |
|
84 | - 'wpinv_register_post_type_payment_form', |
|
85 | - array( |
|
86 | - 'labels' => array( |
|
87 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
101 | - ), |
|
102 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | - 'public' => false, |
|
104 | - 'show_ui' => true, |
|
105 | - 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
106 | - 'show_in_nav_menus' => false, |
|
107 | - 'query_var' => false, |
|
108 | - 'rewrite' => true, |
|
109 | - 'map_meta_cap' => true, |
|
110 | - 'has_archive' => false, |
|
111 | - 'hierarchical' => false, |
|
112 | - 'menu_position' => null, |
|
113 | - 'supports' => array( 'title' ), |
|
114 | - 'menu_icon' => 'dashicons-media-form', |
|
115 | - 'capabilities' => array( |
|
116 | - 'edit_post' => $capabilities, |
|
117 | - 'read_post' => $capabilities, |
|
118 | - 'delete_post' => $capabilities, |
|
119 | - 'edit_posts' => 'update_core', |
|
120 | - 'edit_others_posts' => 'update_core', |
|
121 | - 'delete_posts' => 'update_core', |
|
122 | - 'publish_posts' => 'update_core', |
|
123 | - 'read_private_posts' => 'update_core' |
|
124 | - ), |
|
125 | - ) |
|
126 | - ) |
|
127 | - ); |
|
80 | + // Register payment form post type. |
|
81 | + register_post_type( |
|
82 | + 'wpi_payment_form', |
|
83 | + apply_filters( |
|
84 | + 'wpinv_register_post_type_payment_form', |
|
85 | + array( |
|
86 | + 'labels' => array( |
|
87 | + 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | + 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | + 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | + 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | + 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | + 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | + 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | + 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | + 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | + 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | + 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | + 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | + 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | + 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
101 | + ), |
|
102 | + 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | + 'public' => false, |
|
104 | + 'show_ui' => true, |
|
105 | + 'show_in_menu' => $capabilities ? 'wpinv' : false, |
|
106 | + 'show_in_nav_menus' => false, |
|
107 | + 'query_var' => false, |
|
108 | + 'rewrite' => true, |
|
109 | + 'map_meta_cap' => true, |
|
110 | + 'has_archive' => false, |
|
111 | + 'hierarchical' => false, |
|
112 | + 'menu_position' => null, |
|
113 | + 'supports' => array( 'title' ), |
|
114 | + 'menu_icon' => 'dashicons-media-form', |
|
115 | + 'capabilities' => array( |
|
116 | + 'edit_post' => $capabilities, |
|
117 | + 'read_post' => $capabilities, |
|
118 | + 'delete_post' => $capabilities, |
|
119 | + 'edit_posts' => 'update_core', |
|
120 | + 'edit_others_posts' => 'update_core', |
|
121 | + 'delete_posts' => 'update_core', |
|
122 | + 'publish_posts' => 'update_core', |
|
123 | + 'read_private_posts' => 'update_core' |
|
124 | + ), |
|
125 | + ) |
|
126 | + ) |
|
127 | + ); |
|
128 | 128 | |
129 | - // Register invoice post type. |
|
130 | - register_post_type( |
|
131 | - 'wpi_invoice', |
|
132 | - apply_filters( |
|
133 | - 'wpinv_register_post_type_invoice', |
|
134 | - array( |
|
135 | - 'labels' => array( |
|
136 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
139 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
160 | - ), |
|
161 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
162 | - 'public' => true, |
|
163 | - 'has_archive' => false, |
|
164 | - 'publicly_queryable' => true, |
|
165 | - 'exclude_from_search' => true, |
|
166 | - 'show_ui' => true, |
|
167 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
168 | - 'show_in_nav_menus' => false, |
|
169 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
170 | - 'rewrite' => array( |
|
171 | - 'slug' => 'invoice', |
|
172 | - 'with_front' => false, |
|
173 | - ), |
|
174 | - 'query_var' => false, |
|
175 | - 'map_meta_cap' => true, |
|
176 | - 'show_in_admin_bar' => true, |
|
177 | - 'can_export' => true, |
|
178 | - 'hierarchical' => false, |
|
179 | - 'menu_position' => null, |
|
180 | - 'menu_icon' => 'dashicons-media-spreadsheet', |
|
181 | - ) |
|
182 | - ) |
|
183 | - ); |
|
129 | + // Register invoice post type. |
|
130 | + register_post_type( |
|
131 | + 'wpi_invoice', |
|
132 | + apply_filters( |
|
133 | + 'wpinv_register_post_type_invoice', |
|
134 | + array( |
|
135 | + 'labels' => array( |
|
136 | + 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | + 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | + 'all_items' => __( 'Invoices', 'invoicing' ), |
|
139 | + 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | + 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | + 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | + 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | + 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | + 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | + 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | + 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | + 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | + 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | + 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | + 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | + 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | + 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | + 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | + 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | + 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | + 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | + 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
160 | + ), |
|
161 | + 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
162 | + 'public' => true, |
|
163 | + 'has_archive' => false, |
|
164 | + 'publicly_queryable' => true, |
|
165 | + 'exclude_from_search' => true, |
|
166 | + 'show_ui' => true, |
|
167 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
168 | + 'show_in_nav_menus' => false, |
|
169 | + 'supports' => array( 'title', 'author', 'excerpt' ), |
|
170 | + 'rewrite' => array( |
|
171 | + 'slug' => 'invoice', |
|
172 | + 'with_front' => false, |
|
173 | + ), |
|
174 | + 'query_var' => false, |
|
175 | + 'map_meta_cap' => true, |
|
176 | + 'show_in_admin_bar' => true, |
|
177 | + 'can_export' => true, |
|
178 | + 'hierarchical' => false, |
|
179 | + 'menu_position' => null, |
|
180 | + 'menu_icon' => 'dashicons-media-spreadsheet', |
|
181 | + ) |
|
182 | + ) |
|
183 | + ); |
|
184 | 184 | |
185 | - // Register discount post type. |
|
186 | - register_post_type( |
|
187 | - 'wpi_discount', |
|
188 | - apply_filters( |
|
189 | - 'wpinv_register_post_type_discount', |
|
190 | - array( |
|
191 | - 'labels' => array( |
|
192 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
193 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
194 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
195 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
196 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
197 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
198 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
199 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
200 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
201 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
202 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
203 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
204 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
205 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
206 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
207 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
208 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
209 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
210 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
211 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
212 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
213 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
214 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
215 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
216 | - ), |
|
217 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
218 | - 'public' => false, |
|
219 | - 'can_export' => true, |
|
220 | - '_builtin' => false, |
|
221 | - 'publicly_queryable' => false, |
|
222 | - 'exclude_from_search'=> true, |
|
223 | - 'show_ui' => true, |
|
224 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
225 | - 'query_var' => false, |
|
226 | - 'rewrite' => false, |
|
227 | - 'map_meta_cap' => true, |
|
228 | - 'has_archive' => false, |
|
229 | - 'hierarchical' => false, |
|
230 | - 'supports' => array( 'title', 'excerpt' ), |
|
231 | - 'show_in_nav_menus' => false, |
|
232 | - 'show_in_admin_bar' => true, |
|
233 | - 'menu_position' => null, |
|
234 | - ) |
|
235 | - ) |
|
236 | - ); |
|
185 | + // Register discount post type. |
|
186 | + register_post_type( |
|
187 | + 'wpi_discount', |
|
188 | + apply_filters( |
|
189 | + 'wpinv_register_post_type_discount', |
|
190 | + array( |
|
191 | + 'labels' => array( |
|
192 | + 'name' => __( 'Discounts', 'invoicing' ), |
|
193 | + 'singular_name' => __( 'Discount', 'invoicing' ), |
|
194 | + 'all_items' => __( 'Discounts', 'invoicing' ), |
|
195 | + 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
196 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
197 | + 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
198 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
199 | + 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
200 | + 'new_item' => __( 'New discount', 'invoicing' ), |
|
201 | + 'view_item' => __( 'View discount', 'invoicing' ), |
|
202 | + 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
203 | + 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
204 | + 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
205 | + 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
206 | + 'parent' => __( 'Parent discount', 'invoicing' ), |
|
207 | + 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
208 | + 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
209 | + 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
210 | + 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
211 | + 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
212 | + 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
213 | + 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
214 | + 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
215 | + 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
216 | + ), |
|
217 | + 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
218 | + 'public' => false, |
|
219 | + 'can_export' => true, |
|
220 | + '_builtin' => false, |
|
221 | + 'publicly_queryable' => false, |
|
222 | + 'exclude_from_search'=> true, |
|
223 | + 'show_ui' => true, |
|
224 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
225 | + 'query_var' => false, |
|
226 | + 'rewrite' => false, |
|
227 | + 'map_meta_cap' => true, |
|
228 | + 'has_archive' => false, |
|
229 | + 'hierarchical' => false, |
|
230 | + 'supports' => array( 'title', 'excerpt' ), |
|
231 | + 'show_in_nav_menus' => false, |
|
232 | + 'show_in_admin_bar' => true, |
|
233 | + 'menu_position' => null, |
|
234 | + ) |
|
235 | + ) |
|
236 | + ); |
|
237 | 237 | |
238 | - do_action( 'getpaid_after_register_post_types' ); |
|
239 | - } |
|
238 | + do_action( 'getpaid_after_register_post_types' ); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Register our custom post statuses. |
|
243 | - */ |
|
244 | - public static function register_post_status() { |
|
241 | + /** |
|
242 | + * Register our custom post statuses. |
|
243 | + */ |
|
244 | + public static function register_post_status() { |
|
245 | 245 | |
246 | - $invoice_statuses = apply_filters( |
|
247 | - 'getpaid_register_invoice_post_statuses', |
|
248 | - array( |
|
246 | + $invoice_statuses = apply_filters( |
|
247 | + 'getpaid_register_invoice_post_statuses', |
|
248 | + array( |
|
249 | 249 | |
250 | - 'wpi-pending' => array( |
|
251 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
252 | - 'public' => true, |
|
253 | - 'exclude_from_search' => true, |
|
254 | - 'show_in_admin_all_list' => true, |
|
255 | - 'show_in_admin_status_list' => true, |
|
256 | - /* translators: %s: number of invoices */ |
|
257 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | - ), |
|
250 | + 'wpi-pending' => array( |
|
251 | + 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
252 | + 'public' => true, |
|
253 | + 'exclude_from_search' => true, |
|
254 | + 'show_in_admin_all_list' => true, |
|
255 | + 'show_in_admin_status_list' => true, |
|
256 | + /* translators: %s: number of invoices */ |
|
257 | + 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | + ), |
|
259 | 259 | |
260 | - 'wpi-processing' => array( |
|
261 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
262 | - 'public' => true, |
|
263 | - 'exclude_from_search' => true, |
|
264 | - 'show_in_admin_all_list' => true, |
|
265 | - 'show_in_admin_status_list' => true, |
|
266 | - /* translators: %s: number of invoices */ |
|
267 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | - ), |
|
260 | + 'wpi-processing' => array( |
|
261 | + 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
262 | + 'public' => true, |
|
263 | + 'exclude_from_search' => true, |
|
264 | + 'show_in_admin_all_list' => true, |
|
265 | + 'show_in_admin_status_list' => true, |
|
266 | + /* translators: %s: number of invoices */ |
|
267 | + 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | + ), |
|
269 | 269 | |
270 | - 'wpi-onhold' => array( |
|
271 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
272 | - 'public' => true, |
|
273 | - 'exclude_from_search' => true, |
|
274 | - 'show_in_admin_all_list' => true, |
|
275 | - 'show_in_admin_status_list' => true, |
|
276 | - /* translators: %s: number of invoices */ |
|
277 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | - ), |
|
270 | + 'wpi-onhold' => array( |
|
271 | + 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
272 | + 'public' => true, |
|
273 | + 'exclude_from_search' => true, |
|
274 | + 'show_in_admin_all_list' => true, |
|
275 | + 'show_in_admin_status_list' => true, |
|
276 | + /* translators: %s: number of invoices */ |
|
277 | + 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | + ), |
|
279 | 279 | |
280 | - 'wpi-cancelled' => array( |
|
281 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
282 | - 'public' => true, |
|
283 | - 'exclude_from_search' => true, |
|
284 | - 'show_in_admin_all_list' => true, |
|
285 | - 'show_in_admin_status_list' => true, |
|
286 | - /* translators: %s: number of invoices */ |
|
287 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | - ), |
|
280 | + 'wpi-cancelled' => array( |
|
281 | + 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
282 | + 'public' => true, |
|
283 | + 'exclude_from_search' => true, |
|
284 | + 'show_in_admin_all_list' => true, |
|
285 | + 'show_in_admin_status_list' => true, |
|
286 | + /* translators: %s: number of invoices */ |
|
287 | + 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | + ), |
|
289 | 289 | |
290 | - 'wpi-refunded' => array( |
|
291 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
292 | - 'public' => true, |
|
293 | - 'exclude_from_search' => true, |
|
294 | - 'show_in_admin_all_list' => true, |
|
295 | - 'show_in_admin_status_list' => true, |
|
296 | - /* translators: %s: number of invoices */ |
|
297 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | - ), |
|
290 | + 'wpi-refunded' => array( |
|
291 | + 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
292 | + 'public' => true, |
|
293 | + 'exclude_from_search' => true, |
|
294 | + 'show_in_admin_all_list' => true, |
|
295 | + 'show_in_admin_status_list' => true, |
|
296 | + /* translators: %s: number of invoices */ |
|
297 | + 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | + ), |
|
299 | 299 | |
300 | - 'wpi-failed' => array( |
|
301 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
302 | - 'public' => true, |
|
303 | - 'exclude_from_search' => true, |
|
304 | - 'show_in_admin_all_list' => true, |
|
305 | - 'show_in_admin_status_list' => true, |
|
306 | - /* translators: %s: number of invoices */ |
|
307 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | - ), |
|
300 | + 'wpi-failed' => array( |
|
301 | + 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
302 | + 'public' => true, |
|
303 | + 'exclude_from_search' => true, |
|
304 | + 'show_in_admin_all_list' => true, |
|
305 | + 'show_in_admin_status_list' => true, |
|
306 | + /* translators: %s: number of invoices */ |
|
307 | + 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | + ), |
|
309 | 309 | |
310 | - 'wpi-renewal' => array( |
|
311 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
312 | - 'public' => true, |
|
313 | - 'exclude_from_search' => true, |
|
314 | - 'show_in_admin_all_list' => true, |
|
315 | - 'show_in_admin_status_list' => true, |
|
316 | - /* translators: %s: number of invoices */ |
|
317 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
318 | - ) |
|
319 | - ) |
|
320 | - ); |
|
310 | + 'wpi-renewal' => array( |
|
311 | + 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
312 | + 'public' => true, |
|
313 | + 'exclude_from_search' => true, |
|
314 | + 'show_in_admin_all_list' => true, |
|
315 | + 'show_in_admin_status_list' => true, |
|
316 | + /* translators: %s: number of invoices */ |
|
317 | + 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
318 | + ) |
|
319 | + ) |
|
320 | + ); |
|
321 | 321 | |
322 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | - register_post_status( $invoice_statuse, $args ); |
|
324 | - } |
|
325 | - } |
|
322 | + foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | + register_post_status( $invoice_statuse, $args ); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | - /** |
|
328 | - * Flush rewrite rules. |
|
329 | - */ |
|
330 | - public static function flush_rewrite_rules() { |
|
331 | - flush_rewrite_rules(); |
|
332 | - } |
|
327 | + /** |
|
328 | + * Flush rewrite rules. |
|
329 | + */ |
|
330 | + public static function flush_rewrite_rules() { |
|
331 | + flush_rewrite_rules(); |
|
332 | + } |
|
333 | 333 | |
334 | - /** |
|
335 | - * Flush rules to prevent 404. |
|
336 | - * |
|
337 | - */ |
|
338 | - public static function maybe_flush_rewrite_rules() { |
|
339 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
341 | - self::flush_rewrite_rules(); |
|
342 | - } |
|
343 | - } |
|
334 | + /** |
|
335 | + * Flush rules to prevent 404. |
|
336 | + * |
|
337 | + */ |
|
338 | + public static function maybe_flush_rewrite_rules() { |
|
339 | + if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | + update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
341 | + self::flush_rewrite_rules(); |
|
342 | + } |
|
343 | + } |
|
344 | 344 | |
345 | 345 | } |
@@ -14,591 +14,591 @@ |
||
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 | - * @var array An array of payment gateways. |
|
40 | - */ |
|
41 | - public $gateways; |
|
42 | - |
|
43 | - /** |
|
44 | - * Class constructor. |
|
45 | - */ |
|
46 | - public function __construct() { |
|
47 | - $this->define_constants(); |
|
48 | - $this->includes(); |
|
49 | - $this->init_hooks(); |
|
50 | - $this->set_properties(); |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Sets a custom data property. |
|
55 | - * |
|
56 | - * @param string $prop The prop to set. |
|
57 | - * @param mixed $value The value to retrieve. |
|
58 | - */ |
|
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Gets a custom data property. |
|
65 | - * |
|
66 | - * @param string $prop The prop to set. |
|
67 | - * @return mixed The value. |
|
68 | - */ |
|
69 | - public function get( $prop ) { |
|
70 | - |
|
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
73 | - } |
|
74 | - |
|
75 | - return null; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Define class properties. |
|
80 | - */ |
|
81 | - public function set_properties() { |
|
82 | - |
|
83 | - // Sessions. |
|
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | - $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | - |
|
88 | - // Init other objects. |
|
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | - |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Define plugin constants. |
|
106 | - */ |
|
107 | - public function define_constants() { |
|
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | - $this->version = WPINV_VERSION; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Hook into actions and filters. |
|
115 | - * |
|
116 | - * @since 1.0.19 |
|
117 | - */ |
|
118 | - protected function init_hooks() { |
|
119 | - /* Internationalize the text strings used. */ |
|
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | - |
|
122 | - // Init the plugin after WordPress inits. |
|
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | - |
|
134 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
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 | + * @var array An array of payment gateways. |
|
40 | + */ |
|
41 | + public $gateways; |
|
42 | + |
|
43 | + /** |
|
44 | + * Class constructor. |
|
45 | + */ |
|
46 | + public function __construct() { |
|
47 | + $this->define_constants(); |
|
48 | + $this->includes(); |
|
49 | + $this->init_hooks(); |
|
50 | + $this->set_properties(); |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Sets a custom data property. |
|
55 | + * |
|
56 | + * @param string $prop The prop to set. |
|
57 | + * @param mixed $value The value to retrieve. |
|
58 | + */ |
|
59 | + public function set( $prop, $value ) { |
|
60 | + $this->data[ $prop ] = $value; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Gets a custom data property. |
|
65 | + * |
|
66 | + * @param string $prop The prop to set. |
|
67 | + * @return mixed The value. |
|
68 | + */ |
|
69 | + public function get( $prop ) { |
|
70 | + |
|
71 | + if ( isset( $this->data[ $prop ] ) ) { |
|
72 | + return $this->data[ $prop ]; |
|
73 | + } |
|
74 | + |
|
75 | + return null; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Define class properties. |
|
80 | + */ |
|
81 | + public function set_properties() { |
|
82 | + |
|
83 | + // Sessions. |
|
84 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | + $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
86 | + $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
|
87 | + |
|
88 | + // Init other objects. |
|
89 | + $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | + $this->set( 'notes', new WPInv_Notes() ); |
|
91 | + $this->set( 'api', new WPInv_API() ); |
|
92 | + $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | + $this->set( 'template', new GetPaid_Template() ); |
|
94 | + $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | + $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | + $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | + $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | + $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | + $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | + $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
101 | + |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Define plugin constants. |
|
106 | + */ |
|
107 | + public function define_constants() { |
|
108 | + define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | + define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
110 | + $this->version = WPINV_VERSION; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Hook into actions and filters. |
|
115 | + * |
|
116 | + * @since 1.0.19 |
|
117 | + */ |
|
118 | + protected function init_hooks() { |
|
119 | + /* Internationalize the text strings used. */ |
|
120 | + add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
121 | + |
|
122 | + // Init the plugin after WordPress inits. |
|
123 | + add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | + add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | + add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | + add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | + add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | + add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | + add_action( 'widgets_init', array( &$this, 'register_widgets' ) ); |
|
131 | + add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | + add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | + |
|
134 | + add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
135 | 135 | add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
136 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
137 | - |
|
138 | - // Fires after registering actions. |
|
139 | - do_action( 'wpinv_actions', $this ); |
|
140 | - do_action( 'getpaid_actions', $this ); |
|
141 | - |
|
142 | - } |
|
143 | - |
|
144 | - public function plugins_loaded() { |
|
145 | - /* Internationalize the text strings used. */ |
|
146 | - $this->load_textdomain(); |
|
147 | - |
|
148 | - do_action( 'wpinv_loaded' ); |
|
149 | - |
|
150 | - // Fix oxygen page builder conflict |
|
151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
152 | - wpinv_oxygen_fix_conflict(); |
|
153 | - } |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Load Localisation files. |
|
158 | - * |
|
159 | - * Note: the first-loaded translation file overrides any following ones if the same translation is present. |
|
160 | - * |
|
161 | - * Locales found in: |
|
162 | - * - WP_LANG_DIR/plugins/invoicing-LOCALE.mo |
|
163 | - * - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo |
|
164 | - * |
|
165 | - * @since 1.0.0 |
|
166 | - */ |
|
167 | - public function load_textdomain() { |
|
168 | - |
|
169 | - load_plugin_textdomain( |
|
170 | - 'invoicing', |
|
171 | - false, |
|
172 | - plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
173 | - ); |
|
174 | - |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Include required core files used in admin and on the frontend. |
|
179 | - */ |
|
180 | - public function includes() { |
|
181 | - |
|
182 | - // Start with the settings. |
|
183 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
184 | - |
|
185 | - // Packages/libraries. |
|
186 | - require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | - require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
188 | - |
|
189 | - // Load functions. |
|
190 | - require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | - require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | - require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | - require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | - require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
205 | - |
|
206 | - // Register autoloader. |
|
207 | - try { |
|
208 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | - } catch ( Exception $e ) { |
|
210 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
211 | - } |
|
212 | - |
|
213 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | - require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | - require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | - require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | - require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | - require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | - require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | - require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
234 | - |
|
235 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
236 | - GetPaid_Post_Types_Admin::init(); |
|
237 | - |
|
238 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
239 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
240 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
241 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
242 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
243 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
244 | - // load the user class only on the users.php page |
|
245 | - global $pagenow; |
|
246 | - if($pagenow=='users.php'){ |
|
247 | - new WPInv_Admin_Users(); |
|
248 | - } |
|
249 | - } |
|
250 | - |
|
251 | - // Register cli commands |
|
252 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
253 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
254 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
255 | - } |
|
256 | - |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Class autoloader |
|
261 | - * |
|
262 | - * @param string $class_name The name of the class to load. |
|
263 | - * @access public |
|
264 | - * @since 1.0.19 |
|
265 | - * @return void |
|
266 | - */ |
|
267 | - public function autoload( $class_name ) { |
|
268 | - |
|
269 | - // Normalize the class name... |
|
270 | - $class_name = strtolower( $class_name ); |
|
271 | - |
|
272 | - // ... and make sure it is our class. |
|
273 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
274 | - return; |
|
275 | - } |
|
276 | - |
|
277 | - // Next, prepare the file name from the class. |
|
278 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
279 | - |
|
280 | - // Base path of the classes. |
|
281 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
282 | - |
|
283 | - // And an array of possible locations in order of importance. |
|
284 | - $locations = array( |
|
285 | - "$plugin_path/includes", |
|
286 | - "$plugin_path/includes/data-stores", |
|
287 | - "$plugin_path/includes/gateways", |
|
288 | - "$plugin_path/includes/payments", |
|
289 | - "$plugin_path/includes/geolocation", |
|
290 | - "$plugin_path/includes/reports", |
|
291 | - "$plugin_path/includes/api", |
|
292 | - "$plugin_path/includes/admin", |
|
293 | - "$plugin_path/includes/admin/meta-boxes", |
|
294 | - ); |
|
295 | - |
|
296 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
297 | - |
|
298 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
299 | - include trailingslashit( $location ) . $file_name; |
|
300 | - break; |
|
301 | - } |
|
302 | - |
|
303 | - } |
|
304 | - |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * Inits hooks etc. |
|
309 | - */ |
|
310 | - public function init() { |
|
311 | - |
|
312 | - // Fires before getpaid inits. |
|
313 | - do_action( 'before_getpaid_init', $this ); |
|
314 | - |
|
315 | - // Maybe upgrade. |
|
316 | - $this->maybe_upgrade_database(); |
|
317 | - |
|
318 | - // Load default gateways. |
|
319 | - $gateways = apply_filters( |
|
320 | - 'getpaid_default_gateways', |
|
321 | - array( |
|
322 | - 'manual' => 'GetPaid_Manual_Gateway', |
|
323 | - 'paypal' => 'GetPaid_Paypal_Gateway', |
|
324 | - 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
325 | - 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
326 | - 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
327 | - ) |
|
328 | - ); |
|
329 | - |
|
330 | - foreach ( $gateways as $id => $class ) { |
|
331 | - $this->gateways[ $id ] = new $class(); |
|
332 | - } |
|
333 | - |
|
334 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
335 | - GetPaid_Installer::rename_gateways_label(); |
|
336 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
337 | - } |
|
338 | - |
|
339 | - // Fires after getpaid inits. |
|
340 | - do_action( 'getpaid_init', $this ); |
|
341 | - |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Checks if this is an IPN request and processes it. |
|
346 | - */ |
|
347 | - public function maybe_process_ipn() { |
|
348 | - |
|
349 | - // Ensure that this is an IPN request. |
|
350 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
351 | - return; |
|
352 | - } |
|
353 | - |
|
354 | - $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
355 | - |
|
356 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
357 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
358 | - exit; |
|
359 | - |
|
360 | - } |
|
361 | - |
|
362 | - public function enqueue_scripts() { |
|
363 | - |
|
364 | - // Fires before adding scripts. |
|
365 | - do_action( 'getpaid_enqueue_scripts' ); |
|
366 | - |
|
367 | - $localize = array(); |
|
368 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
369 | - $localize['thousands'] = wpinv_thousands_separator(); |
|
370 | - $localize['decimals'] = wpinv_decimal_separator(); |
|
371 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
372 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
373 | - $localize['UseTaxes'] = wpinv_use_taxes(); |
|
374 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
376 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
377 | - |
|
378 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
379 | - |
|
380 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
381 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
382 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
383 | - } |
|
384 | - |
|
385 | - public function wpinv_actions() { |
|
386 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
387 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
388 | - } |
|
389 | - } |
|
390 | - |
|
391 | - /** |
|
136 | + add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
137 | + |
|
138 | + // Fires after registering actions. |
|
139 | + do_action( 'wpinv_actions', $this ); |
|
140 | + do_action( 'getpaid_actions', $this ); |
|
141 | + |
|
142 | + } |
|
143 | + |
|
144 | + public function plugins_loaded() { |
|
145 | + /* Internationalize the text strings used. */ |
|
146 | + $this->load_textdomain(); |
|
147 | + |
|
148 | + do_action( 'wpinv_loaded' ); |
|
149 | + |
|
150 | + // Fix oxygen page builder conflict |
|
151 | + if ( function_exists( 'ct_css_output' ) ) { |
|
152 | + wpinv_oxygen_fix_conflict(); |
|
153 | + } |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Load Localisation files. |
|
158 | + * |
|
159 | + * Note: the first-loaded translation file overrides any following ones if the same translation is present. |
|
160 | + * |
|
161 | + * Locales found in: |
|
162 | + * - WP_LANG_DIR/plugins/invoicing-LOCALE.mo |
|
163 | + * - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo |
|
164 | + * |
|
165 | + * @since 1.0.0 |
|
166 | + */ |
|
167 | + public function load_textdomain() { |
|
168 | + |
|
169 | + load_plugin_textdomain( |
|
170 | + 'invoicing', |
|
171 | + false, |
|
172 | + plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
173 | + ); |
|
174 | + |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Include required core files used in admin and on the frontend. |
|
179 | + */ |
|
180 | + public function includes() { |
|
181 | + |
|
182 | + // Start with the settings. |
|
183 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' ); |
|
184 | + |
|
185 | + // Packages/libraries. |
|
186 | + require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' ); |
|
187 | + require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' ); |
|
188 | + |
|
189 | + // Load functions. |
|
190 | + require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' ); |
|
191 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' ); |
|
192 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' ); |
|
193 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' ); |
|
194 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' ); |
|
195 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' ); |
|
196 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' ); |
|
197 | + require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' ); |
|
198 | + require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' ); |
|
199 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' ); |
|
200 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' ); |
|
201 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' ); |
|
202 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' ); |
|
203 | + require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' ); |
|
204 | + require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' ); |
|
205 | + |
|
206 | + // Register autoloader. |
|
207 | + try { |
|
208 | + spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | + } catch ( Exception $e ) { |
|
210 | + wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
211 | + } |
|
212 | + |
|
213 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' ); |
|
214 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' ); |
|
215 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' ); |
|
216 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' ); |
|
217 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' ); |
|
218 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' ); |
|
219 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
|
220 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' ); |
|
221 | + require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' ); |
|
222 | + require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' ); |
|
223 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' ); |
|
224 | + require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' ); |
|
225 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' ); |
|
226 | + require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' ); |
|
227 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' ); |
|
228 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' ); |
|
229 | + require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' ); |
|
230 | + require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' ); |
|
231 | + require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' ); |
|
232 | + require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' ); |
|
233 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
234 | + |
|
235 | + if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
236 | + GetPaid_Post_Types_Admin::init(); |
|
237 | + |
|
238 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
239 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' ); |
|
240 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
241 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
242 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
243 | + require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' ); |
|
244 | + // load the user class only on the users.php page |
|
245 | + global $pagenow; |
|
246 | + if($pagenow=='users.php'){ |
|
247 | + new WPInv_Admin_Users(); |
|
248 | + } |
|
249 | + } |
|
250 | + |
|
251 | + // Register cli commands |
|
252 | + if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
253 | + require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' ); |
|
254 | + WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
255 | + } |
|
256 | + |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Class autoloader |
|
261 | + * |
|
262 | + * @param string $class_name The name of the class to load. |
|
263 | + * @access public |
|
264 | + * @since 1.0.19 |
|
265 | + * @return void |
|
266 | + */ |
|
267 | + public function autoload( $class_name ) { |
|
268 | + |
|
269 | + // Normalize the class name... |
|
270 | + $class_name = strtolower( $class_name ); |
|
271 | + |
|
272 | + // ... and make sure it is our class. |
|
273 | + if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
274 | + return; |
|
275 | + } |
|
276 | + |
|
277 | + // Next, prepare the file name from the class. |
|
278 | + $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
279 | + |
|
280 | + // Base path of the classes. |
|
281 | + $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
282 | + |
|
283 | + // And an array of possible locations in order of importance. |
|
284 | + $locations = array( |
|
285 | + "$plugin_path/includes", |
|
286 | + "$plugin_path/includes/data-stores", |
|
287 | + "$plugin_path/includes/gateways", |
|
288 | + "$plugin_path/includes/payments", |
|
289 | + "$plugin_path/includes/geolocation", |
|
290 | + "$plugin_path/includes/reports", |
|
291 | + "$plugin_path/includes/api", |
|
292 | + "$plugin_path/includes/admin", |
|
293 | + "$plugin_path/includes/admin/meta-boxes", |
|
294 | + ); |
|
295 | + |
|
296 | + foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
297 | + |
|
298 | + if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
299 | + include trailingslashit( $location ) . $file_name; |
|
300 | + break; |
|
301 | + } |
|
302 | + |
|
303 | + } |
|
304 | + |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * Inits hooks etc. |
|
309 | + */ |
|
310 | + public function init() { |
|
311 | + |
|
312 | + // Fires before getpaid inits. |
|
313 | + do_action( 'before_getpaid_init', $this ); |
|
314 | + |
|
315 | + // Maybe upgrade. |
|
316 | + $this->maybe_upgrade_database(); |
|
317 | + |
|
318 | + // Load default gateways. |
|
319 | + $gateways = apply_filters( |
|
320 | + 'getpaid_default_gateways', |
|
321 | + array( |
|
322 | + 'manual' => 'GetPaid_Manual_Gateway', |
|
323 | + 'paypal' => 'GetPaid_Paypal_Gateway', |
|
324 | + 'worldpay' => 'GetPaid_Worldpay_Gateway', |
|
325 | + 'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway', |
|
326 | + 'authorizenet' => 'GetPaid_Authorize_Net_Gateway', |
|
327 | + ) |
|
328 | + ); |
|
329 | + |
|
330 | + foreach ( $gateways as $id => $class ) { |
|
331 | + $this->gateways[ $id ] = new $class(); |
|
332 | + } |
|
333 | + |
|
334 | + if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
335 | + GetPaid_Installer::rename_gateways_label(); |
|
336 | + update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
337 | + } |
|
338 | + |
|
339 | + // Fires after getpaid inits. |
|
340 | + do_action( 'getpaid_init', $this ); |
|
341 | + |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Checks if this is an IPN request and processes it. |
|
346 | + */ |
|
347 | + public function maybe_process_ipn() { |
|
348 | + |
|
349 | + // Ensure that this is an IPN request. |
|
350 | + if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
351 | + return; |
|
352 | + } |
|
353 | + |
|
354 | + $gateway = wpinv_clean( $_GET['wpi-gateway'] ); |
|
355 | + |
|
356 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
357 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
358 | + exit; |
|
359 | + |
|
360 | + } |
|
361 | + |
|
362 | + public function enqueue_scripts() { |
|
363 | + |
|
364 | + // Fires before adding scripts. |
|
365 | + do_action( 'getpaid_enqueue_scripts' ); |
|
366 | + |
|
367 | + $localize = array(); |
|
368 | + $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
369 | + $localize['thousands'] = wpinv_thousands_separator(); |
|
370 | + $localize['decimals'] = wpinv_decimal_separator(); |
|
371 | + $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
372 | + $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
373 | + $localize['UseTaxes'] = wpinv_use_taxes(); |
|
374 | + $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | + $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
376 | + $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
377 | + |
|
378 | + $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
379 | + |
|
380 | + $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
381 | + wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
382 | + wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
383 | + } |
|
384 | + |
|
385 | + public function wpinv_actions() { |
|
386 | + if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
387 | + do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
388 | + } |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | 392 | * Fires an action after verifying that a user can fire them. |
393 | - * |
|
394 | - * Note: If the action is on an invoice, subscription etc, esure that the |
|
395 | - * current user owns the invoice/subscription. |
|
393 | + * |
|
394 | + * Note: If the action is on an invoice, subscription etc, esure that the |
|
395 | + * current user owns the invoice/subscription. |
|
396 | 396 | */ |
397 | 397 | public function maybe_do_authenticated_action() { |
398 | 398 | |
399 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
399 | + if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
400 | 400 | |
401 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
402 | - $data = wp_unslash( $_REQUEST ); |
|
403 | - if ( is_user_logged_in() ) { |
|
404 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
405 | - } |
|
401 | + $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
402 | + $data = wp_unslash( $_REQUEST ); |
|
403 | + if ( is_user_logged_in() ) { |
|
404 | + do_action( "getpaid_authenticated_action_$key", $data ); |
|
405 | + } |
|
406 | 406 | |
407 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
407 | + do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
408 | 408 | |
409 | - } |
|
409 | + } |
|
410 | 410 | |
411 | 411 | } |
412 | 412 | |
413 | - public function pre_get_posts( $wp_query ) { |
|
414 | - |
|
415 | - 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() ) { |
|
416 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
417 | - } |
|
418 | - |
|
419 | - return $wp_query; |
|
420 | - } |
|
421 | - |
|
422 | - /** |
|
423 | - * Register widgets |
|
424 | - * |
|
425 | - */ |
|
426 | - public function register_widgets() { |
|
427 | - |
|
428 | - // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
429 | - // So we disable our widgets when editing a page with UX Builder. |
|
430 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
431 | - return; |
|
432 | - } |
|
433 | - |
|
434 | - $widgets = apply_filters( |
|
435 | - 'getpaid_widget_classes', |
|
436 | - array( |
|
437 | - 'WPInv_Checkout_Widget', |
|
438 | - 'WPInv_History_Widget', |
|
439 | - 'WPInv_Receipt_Widget', |
|
440 | - 'WPInv_Subscriptions_Widget', |
|
441 | - 'WPInv_Buy_Item_Widget', |
|
442 | - 'WPInv_Messages_Widget', |
|
443 | - 'WPInv_GetPaid_Widget' |
|
444 | - ) |
|
445 | - ); |
|
446 | - |
|
447 | - foreach ( $widgets as $widget ) { |
|
448 | - register_widget( $widget ); |
|
449 | - } |
|
413 | + public function pre_get_posts( $wp_query ) { |
|
414 | + |
|
415 | + 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() ) { |
|
416 | + $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
417 | + } |
|
418 | + |
|
419 | + return $wp_query; |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Register widgets |
|
424 | + * |
|
425 | + */ |
|
426 | + public function register_widgets() { |
|
427 | + |
|
428 | + // Currently, UX Builder does not work particulaly well with SuperDuper. |
|
429 | + // So we disable our widgets when editing a page with UX Builder. |
|
430 | + if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
431 | + return; |
|
432 | + } |
|
433 | + |
|
434 | + $widgets = apply_filters( |
|
435 | + 'getpaid_widget_classes', |
|
436 | + array( |
|
437 | + 'WPInv_Checkout_Widget', |
|
438 | + 'WPInv_History_Widget', |
|
439 | + 'WPInv_Receipt_Widget', |
|
440 | + 'WPInv_Subscriptions_Widget', |
|
441 | + 'WPInv_Buy_Item_Widget', |
|
442 | + 'WPInv_Messages_Widget', |
|
443 | + 'WPInv_GetPaid_Widget' |
|
444 | + ) |
|
445 | + ); |
|
446 | + |
|
447 | + foreach ( $widgets as $widget ) { |
|
448 | + register_widget( $widget ); |
|
449 | + } |
|
450 | 450 | |
451 | - } |
|
451 | + } |
|
452 | 452 | |
453 | - /** |
|
454 | - * Upgrades the database. |
|
455 | - * |
|
456 | - * @since 2.0.2 |
|
457 | - */ |
|
458 | - public function maybe_upgrade_database() { |
|
453 | + /** |
|
454 | + * Upgrades the database. |
|
455 | + * |
|
456 | + * @since 2.0.2 |
|
457 | + */ |
|
458 | + public function maybe_upgrade_database() { |
|
459 | 459 | |
460 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
460 | + $wpi_version = get_option( 'wpinv_version', 0 ); |
|
461 | 461 | |
462 | - if ( $wpi_version == WPINV_VERSION ) { |
|
463 | - return; |
|
464 | - } |
|
462 | + if ( $wpi_version == WPINV_VERSION ) { |
|
463 | + return; |
|
464 | + } |
|
465 | 465 | |
466 | - $installer = new GetPaid_Installer(); |
|
466 | + $installer = new GetPaid_Installer(); |
|
467 | 467 | |
468 | - if ( empty( $wpi_version ) ) { |
|
469 | - return $installer->upgrade_db( 0 ); |
|
470 | - } |
|
468 | + if ( empty( $wpi_version ) ) { |
|
469 | + return $installer->upgrade_db( 0 ); |
|
470 | + } |
|
471 | 471 | |
472 | - $upgrades = array( |
|
473 | - '0.0.5' => '004', |
|
474 | - '1.0.3' => '102', |
|
475 | - '2.0.0' => '118', |
|
476 | - '2.0.8' => '207', |
|
477 | - ); |
|
472 | + $upgrades = array( |
|
473 | + '0.0.5' => '004', |
|
474 | + '1.0.3' => '102', |
|
475 | + '2.0.0' => '118', |
|
476 | + '2.0.8' => '207', |
|
477 | + ); |
|
478 | 478 | |
479 | - foreach ( $upgrades as $key => $method ) { |
|
479 | + foreach ( $upgrades as $key => $method ) { |
|
480 | 480 | |
481 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
482 | - return $installer->upgrade_db( $method ); |
|
483 | - } |
|
481 | + if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
482 | + return $installer->upgrade_db( $method ); |
|
483 | + } |
|
484 | 484 | |
485 | - } |
|
485 | + } |
|
486 | 486 | |
487 | - } |
|
487 | + } |
|
488 | 488 | |
489 | - /** |
|
490 | - * Flushes the permalinks if needed. |
|
491 | - * |
|
492 | - * @since 2.0.8 |
|
493 | - */ |
|
494 | - public function maybe_flush_permalinks() { |
|
489 | + /** |
|
490 | + * Flushes the permalinks if needed. |
|
491 | + * |
|
492 | + * @since 2.0.8 |
|
493 | + */ |
|
494 | + public function maybe_flush_permalinks() { |
|
495 | 495 | |
496 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
496 | + $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
497 | 497 | |
498 | - if ( ! empty( $flush ) ) { |
|
499 | - flush_rewrite_rules(); |
|
500 | - delete_option( 'wpinv_flush_permalinks' ); |
|
501 | - } |
|
498 | + if ( ! empty( $flush ) ) { |
|
499 | + flush_rewrite_rules(); |
|
500 | + delete_option( 'wpinv_flush_permalinks' ); |
|
501 | + } |
|
502 | 502 | |
503 | - } |
|
503 | + } |
|
504 | 504 | |
505 | - /** |
|
506 | - * Remove our pages from yoast sitemaps. |
|
507 | - * |
|
508 | - * @since 1.0.19 |
|
509 | - * @param int[] $excluded_posts_ids |
|
510 | - */ |
|
511 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
505 | + /** |
|
506 | + * Remove our pages from yoast sitemaps. |
|
507 | + * |
|
508 | + * @since 1.0.19 |
|
509 | + * @param int[] $excluded_posts_ids |
|
510 | + */ |
|
511 | + public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){ |
|
512 | 512 | |
513 | - // Ensure that we have an array. |
|
514 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
515 | - $excluded_posts_ids = array(); |
|
516 | - } |
|
513 | + // Ensure that we have an array. |
|
514 | + if ( ! is_array( $excluded_posts_ids ) ) { |
|
515 | + $excluded_posts_ids = array(); |
|
516 | + } |
|
517 | 517 | |
518 | - // Prepare our pages. |
|
519 | - $our_pages = array(); |
|
518 | + // Prepare our pages. |
|
519 | + $our_pages = array(); |
|
520 | 520 | |
521 | - // Checkout page. |
|
522 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
521 | + // Checkout page. |
|
522 | + $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
523 | 523 | |
524 | - // Success page. |
|
525 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
524 | + // Success page. |
|
525 | + $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
526 | 526 | |
527 | - // Failure page. |
|
528 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
527 | + // Failure page. |
|
528 | + $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
529 | 529 | |
530 | - // History page. |
|
531 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
530 | + // History page. |
|
531 | + $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
532 | 532 | |
533 | - // Subscriptions page. |
|
534 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
533 | + // Subscriptions page. |
|
534 | + $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
535 | 535 | |
536 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
536 | + $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
537 | 537 | |
538 | - $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
539 | - return array_unique( $excluded_posts_ids ); |
|
538 | + $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
|
539 | + return array_unique( $excluded_posts_ids ); |
|
540 | 540 | |
541 | - } |
|
541 | + } |
|
542 | 542 | |
543 | - /** |
|
544 | - * Displays additional footer code. |
|
545 | - * |
|
546 | - * @since 2.0.0 |
|
547 | - */ |
|
548 | - public function wp_footer() { |
|
549 | - wpinv_get_template( 'frontend-footer.php' ); |
|
550 | - } |
|
543 | + /** |
|
544 | + * Displays additional footer code. |
|
545 | + * |
|
546 | + * @since 2.0.0 |
|
547 | + */ |
|
548 | + public function wp_footer() { |
|
549 | + wpinv_get_template( 'frontend-footer.php' ); |
|
550 | + } |
|
551 | 551 | |
552 | - /** |
|
553 | - * Displays additional header code. |
|
554 | - * |
|
555 | - * @since 2.0.0 |
|
556 | - */ |
|
557 | - public function wp_head() { |
|
558 | - wpinv_get_template( 'frontend-head.php' ); |
|
559 | - } |
|
552 | + /** |
|
553 | + * Displays additional header code. |
|
554 | + * |
|
555 | + * @since 2.0.0 |
|
556 | + */ |
|
557 | + public function wp_head() { |
|
558 | + wpinv_get_template( 'frontend-head.php' ); |
|
559 | + } |
|
560 | 560 | |
561 | - /** |
|
562 | - * Custom query vars. |
|
563 | - * |
|
564 | - */ |
|
565 | - public function custom_query_vars( $vars ) { |
|
561 | + /** |
|
562 | + * Custom query vars. |
|
563 | + * |
|
564 | + */ |
|
565 | + public function custom_query_vars( $vars ) { |
|
566 | 566 | $vars[] = 'getpaid-ipn'; |
567 | 567 | return $vars; |
568 | - } |
|
568 | + } |
|
569 | 569 | |
570 | - /** |
|
571 | - * Add rewrite tags and rules. |
|
572 | - * |
|
573 | - */ |
|
574 | - public function add_rewrite_rule() { |
|
570 | + /** |
|
571 | + * Add rewrite tags and rules. |
|
572 | + * |
|
573 | + */ |
|
574 | + public function add_rewrite_rule() { |
|
575 | 575 | $tag = 'getpaid-ipn'; |
576 | 576 | add_rewrite_tag( "%$tag%", '([^&]+)' ); |
577 | 577 | add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' ); |
578 | - } |
|
578 | + } |
|
579 | 579 | |
580 | - /** |
|
581 | - * Processes non-query string ipns. |
|
582 | - * |
|
583 | - */ |
|
584 | - public function maybe_process_new_ipn( $query ) { |
|
580 | + /** |
|
581 | + * Processes non-query string ipns. |
|
582 | + * |
|
583 | + */ |
|
584 | + public function maybe_process_new_ipn( $query ) { |
|
585 | 585 | |
586 | 586 | if ( is_admin() || ! $query->is_main_query() ) { |
587 | 587 | return; |
588 | 588 | } |
589 | 589 | |
590 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
590 | + $gateway = get_query_var( 'getpaid-ipn' ); |
|
591 | 591 | |
592 | 592 | if ( ! empty( $gateway ) ){ |
593 | 593 | |
594 | - $gateway = sanitize_text_field( $gateway ); |
|
595 | - nocache_headers(); |
|
596 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
597 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
598 | - exit; |
|
594 | + $gateway = sanitize_text_field( $gateway ); |
|
595 | + nocache_headers(); |
|
596 | + do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
597 | + do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
598 | + exit; |
|
599 | 599 | |
600 | 600 | } |
601 | 601 | |
602 | - } |
|
602 | + } |
|
603 | 603 | |
604 | 604 | } |