@@ -15,332 +15,332 @@ |
||
15 | 15 | class GetPaid_Post_Types { |
16 | 16 | |
17 | 17 | /** |
18 | - * Hook in methods. |
|
19 | - */ |
|
20 | - public static function init() { |
|
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 static function init() { |
|
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 | - // Fires before registering post types. |
|
37 | - do_action( 'getpaid_register_post_types' ); |
|
36 | + // Fires before registering post types. |
|
37 | + do_action( 'getpaid_register_post_types' ); |
|
38 | 38 | |
39 | - // Register item post type. |
|
40 | - register_post_type( |
|
41 | - 'wpi_item', |
|
42 | - apply_filters( |
|
43 | - 'wpinv_register_post_type_invoice_item', |
|
44 | - array( |
|
45 | - 'labels' => array( |
|
46 | - 'name' => __( 'Items', 'invoicing' ), |
|
47 | - 'singular_name' => __( 'Item', 'invoicing' ), |
|
48 | - 'all_items' => __( 'All Items', 'invoicing' ), |
|
49 | - 'menu_name' => _x( 'Items', 'Admin menu name', 'invoicing' ), |
|
50 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
51 | - 'add_new_item' => __( 'Add new item', 'invoicing' ), |
|
52 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
53 | - 'edit_item' => __( 'Edit item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New item', 'invoicing' ), |
|
55 | - 'view_item' => __( 'View item', 'invoicing' ), |
|
56 | - 'view_items' => __( 'View items', 'invoicing' ), |
|
57 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
58 | - 'not_found' => __( 'No Items found', 'invoicing' ), |
|
59 | - 'not_found_in_trash' => __( 'No Items found in trash', 'invoicing' ), |
|
60 | - 'parent' => __( 'Parent item', 'invoicing' ), |
|
61 | - 'featured_image' => __( 'item image', 'invoicing' ), |
|
62 | - 'set_featured_image' => __( 'Set item image', 'invoicing' ), |
|
63 | - 'remove_featured_image' => __( 'Remove item image', 'invoicing' ), |
|
64 | - 'use_featured_image' => __( 'Use as item image', 'invoicing' ), |
|
65 | - 'insert_into_item' => __( 'Insert into item', 'invoicing' ), |
|
66 | - 'uploaded_to_this_item' => __( 'Uploaded to this item', 'invoicing' ), |
|
67 | - 'filter_items_list' => __( 'Filter items', 'invoicing' ), |
|
68 | - 'items_list_navigation' => __( 'Items navigation', 'invoicing' ), |
|
69 | - 'items_list' => __( 'Items list', 'invoicing' ), |
|
70 | - ), |
|
71 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
72 | - 'public' => false, |
|
73 | - 'has_archive' => false, |
|
74 | - '_builtin' => false, |
|
75 | - 'show_ui' => true, |
|
76 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
77 | - 'show_in_nav_menus' => false, |
|
78 | - 'supports' => array( 'title', 'excerpt' ), |
|
79 | - 'register_meta_box_cb' => 'wpinv_register_item_meta_boxes', |
|
80 | - 'rewrite' => false, |
|
81 | - 'query_var' => false, |
|
82 | - 'capability_type' => 'wpi_item', |
|
83 | - 'map_meta_cap' => true, |
|
84 | - 'show_in_admin_bar' => true, |
|
85 | - 'can_export' => true, |
|
86 | - ) |
|
87 | - ) |
|
88 | - ); |
|
39 | + // Register item post type. |
|
40 | + register_post_type( |
|
41 | + 'wpi_item', |
|
42 | + apply_filters( |
|
43 | + 'wpinv_register_post_type_invoice_item', |
|
44 | + array( |
|
45 | + 'labels' => array( |
|
46 | + 'name' => __( 'Items', 'invoicing' ), |
|
47 | + 'singular_name' => __( 'Item', 'invoicing' ), |
|
48 | + 'all_items' => __( 'All Items', 'invoicing' ), |
|
49 | + 'menu_name' => _x( 'Items', 'Admin menu name', 'invoicing' ), |
|
50 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
51 | + 'add_new_item' => __( 'Add new item', 'invoicing' ), |
|
52 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
53 | + 'edit_item' => __( 'Edit item', 'invoicing' ), |
|
54 | + 'new_item' => __( 'New item', 'invoicing' ), |
|
55 | + 'view_item' => __( 'View item', 'invoicing' ), |
|
56 | + 'view_items' => __( 'View items', 'invoicing' ), |
|
57 | + 'search_items' => __( 'Search items', 'invoicing' ), |
|
58 | + 'not_found' => __( 'No Items found', 'invoicing' ), |
|
59 | + 'not_found_in_trash' => __( 'No Items found in trash', 'invoicing' ), |
|
60 | + 'parent' => __( 'Parent item', 'invoicing' ), |
|
61 | + 'featured_image' => __( 'item image', 'invoicing' ), |
|
62 | + 'set_featured_image' => __( 'Set item image', 'invoicing' ), |
|
63 | + 'remove_featured_image' => __( 'Remove item image', 'invoicing' ), |
|
64 | + 'use_featured_image' => __( 'Use as item image', 'invoicing' ), |
|
65 | + 'insert_into_item' => __( 'Insert into item', 'invoicing' ), |
|
66 | + 'uploaded_to_this_item' => __( 'Uploaded to this item', 'invoicing' ), |
|
67 | + 'filter_items_list' => __( 'Filter items', 'invoicing' ), |
|
68 | + 'items_list_navigation' => __( 'Items navigation', 'invoicing' ), |
|
69 | + 'items_list' => __( 'Items list', 'invoicing' ), |
|
70 | + ), |
|
71 | + 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
72 | + 'public' => false, |
|
73 | + 'has_archive' => false, |
|
74 | + '_builtin' => false, |
|
75 | + 'show_ui' => true, |
|
76 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
77 | + 'show_in_nav_menus' => false, |
|
78 | + 'supports' => array( 'title', 'excerpt' ), |
|
79 | + 'register_meta_box_cb' => 'wpinv_register_item_meta_boxes', |
|
80 | + 'rewrite' => false, |
|
81 | + 'query_var' => false, |
|
82 | + 'capability_type' => 'wpi_item', |
|
83 | + 'map_meta_cap' => true, |
|
84 | + 'show_in_admin_bar' => true, |
|
85 | + 'can_export' => true, |
|
86 | + ) |
|
87 | + ) |
|
88 | + ); |
|
89 | 89 | |
90 | - // Register payment form post type. |
|
91 | - register_post_type( |
|
92 | - 'wpi_payment_form', |
|
93 | - apply_filters( |
|
94 | - 'wpinv_register_post_type_payment_form', |
|
95 | - array( |
|
96 | - 'labels' => array( |
|
97 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
98 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
99 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
100 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
101 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
102 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
103 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
104 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
105 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
106 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
107 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
108 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
109 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
110 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
111 | - ), |
|
112 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
113 | - 'public' => false, |
|
114 | - 'show_ui' => true, |
|
115 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true, |
|
116 | - 'show_in_nav_menus' => false, |
|
117 | - 'query_var' => false, |
|
118 | - 'rewrite' => true, |
|
119 | - 'map_meta_cap' => true, |
|
120 | - 'has_archive' => false, |
|
121 | - 'hierarchical' => false, |
|
122 | - 'menu_position' => null, |
|
123 | - 'supports' => array( 'title' ), |
|
124 | - 'menu_icon' => 'dashicons-media-form', |
|
125 | - ) |
|
126 | - ) |
|
127 | - ); |
|
90 | + // Register payment form post type. |
|
91 | + register_post_type( |
|
92 | + 'wpi_payment_form', |
|
93 | + apply_filters( |
|
94 | + 'wpinv_register_post_type_payment_form', |
|
95 | + array( |
|
96 | + 'labels' => array( |
|
97 | + 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
98 | + 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
99 | + 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
100 | + 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
101 | + 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
102 | + 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
103 | + 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
104 | + 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
105 | + 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
106 | + 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
107 | + 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
108 | + 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
109 | + 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
110 | + 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
111 | + ), |
|
112 | + 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
113 | + 'public' => false, |
|
114 | + 'show_ui' => true, |
|
115 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : true, |
|
116 | + 'show_in_nav_menus' => false, |
|
117 | + 'query_var' => false, |
|
118 | + 'rewrite' => true, |
|
119 | + 'map_meta_cap' => true, |
|
120 | + 'has_archive' => false, |
|
121 | + 'hierarchical' => false, |
|
122 | + 'menu_position' => null, |
|
123 | + 'supports' => array( 'title' ), |
|
124 | + 'menu_icon' => 'dashicons-media-form', |
|
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' => __( 'All 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' => true, |
|
171 | - 'query_var' => false, |
|
172 | - 'capability_type' => 'wpi_invoice', |
|
173 | - 'map_meta_cap' => true, |
|
174 | - 'show_in_admin_bar' => true, |
|
175 | - 'can_export' => true, |
|
176 | - 'hierarchical' => false, |
|
177 | - 'menu_position' => null, |
|
178 | - 'menu_icon' => 'dashicons-media-spreadsheet', |
|
179 | - ) |
|
180 | - ) |
|
181 | - ); |
|
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' => __( 'All 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' => true, |
|
171 | + 'query_var' => false, |
|
172 | + 'capability_type' => 'wpi_invoice', |
|
173 | + 'map_meta_cap' => true, |
|
174 | + 'show_in_admin_bar' => true, |
|
175 | + 'can_export' => true, |
|
176 | + 'hierarchical' => false, |
|
177 | + 'menu_position' => null, |
|
178 | + 'menu_icon' => 'dashicons-media-spreadsheet', |
|
179 | + ) |
|
180 | + ) |
|
181 | + ); |
|
182 | 182 | |
183 | - // Register discount post type. |
|
184 | - register_post_type( |
|
185 | - 'wpi_discount', |
|
186 | - apply_filters( |
|
187 | - 'wpinv_register_post_type_discount', |
|
188 | - array( |
|
189 | - 'labels' => array( |
|
190 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
191 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
192 | - 'all_items' => __( 'All Discounts', 'invoicing' ), |
|
193 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
194 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
195 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
196 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
197 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
198 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
199 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
200 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
201 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
202 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
203 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
204 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
205 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
206 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
207 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
208 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
209 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
210 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
211 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
212 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
213 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
214 | - ), |
|
215 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
216 | - 'public' => false, |
|
217 | - 'can_export' => true, |
|
218 | - '_builtin' => false, |
|
219 | - 'publicly_queryable' => false, |
|
220 | - 'exclude_from_search'=> true, |
|
221 | - 'show_ui' => true, |
|
222 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
223 | - 'query_var' => false, |
|
224 | - 'rewrite' => false, |
|
225 | - 'capability_type' => 'wpi_discount', |
|
226 | - 'map_meta_cap' => true, |
|
227 | - 'has_archive' => false, |
|
228 | - 'hierarchical' => false, |
|
229 | - 'supports' => array( 'title', 'excerpt' ), |
|
230 | - 'register_meta_box_cb' => 'wpinv_register_discount_meta_boxes', |
|
231 | - 'show_in_nav_menus' => false, |
|
232 | - 'show_in_admin_bar' => true, |
|
233 | - 'menu_position' => null, |
|
234 | - ) |
|
235 | - ) |
|
236 | - ); |
|
183 | + // Register discount post type. |
|
184 | + register_post_type( |
|
185 | + 'wpi_discount', |
|
186 | + apply_filters( |
|
187 | + 'wpinv_register_post_type_discount', |
|
188 | + array( |
|
189 | + 'labels' => array( |
|
190 | + 'name' => __( 'Discounts', 'invoicing' ), |
|
191 | + 'singular_name' => __( 'Discount', 'invoicing' ), |
|
192 | + 'all_items' => __( 'All Discounts', 'invoicing' ), |
|
193 | + 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
194 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
195 | + 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
196 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
197 | + 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
198 | + 'new_item' => __( 'New discount', 'invoicing' ), |
|
199 | + 'view_item' => __( 'View discount', 'invoicing' ), |
|
200 | + 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
201 | + 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
202 | + 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
203 | + 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
204 | + 'parent' => __( 'Parent discount', 'invoicing' ), |
|
205 | + 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
206 | + 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
207 | + 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
208 | + 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
209 | + 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
210 | + 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
211 | + 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
212 | + 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
213 | + 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
214 | + ), |
|
215 | + 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
216 | + 'public' => false, |
|
217 | + 'can_export' => true, |
|
218 | + '_builtin' => false, |
|
219 | + 'publicly_queryable' => false, |
|
220 | + 'exclude_from_search'=> true, |
|
221 | + 'show_ui' => true, |
|
222 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
223 | + 'query_var' => false, |
|
224 | + 'rewrite' => false, |
|
225 | + 'capability_type' => 'wpi_discount', |
|
226 | + 'map_meta_cap' => true, |
|
227 | + 'has_archive' => false, |
|
228 | + 'hierarchical' => false, |
|
229 | + 'supports' => array( 'title', 'excerpt' ), |
|
230 | + 'register_meta_box_cb' => 'wpinv_register_discount_meta_boxes', |
|
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 | } |
346 | 346 | GetPaid_Post_Types::init(); |
@@ -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_Resend_Invoice { |
16 | 16 | |
17 | 17 | /** |
18 | - * Output the metabox. |
|
19 | - * |
|
20 | - * @param WP_Post $post |
|
21 | - */ |
|
18 | + * Output the metabox. |
|
19 | + * |
|
20 | + * @param WP_Post $post |
|
21 | + */ |
|
22 | 22 | public static function output( $post ) { |
23 | 23 | |
24 | 24 | // Fetch the invoice. |
@@ -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 metabox. |
|
19 | - * |
|
20 | - * @param WP_Post $post |
|
21 | - */ |
|
18 | + * Output the metabox. |
|
19 | + * |
|
20 | + * @param WP_Post $post |
|
21 | + */ |
|
22 | 22 | public static function output( $post ) { |
23 | 23 | |
24 | 24 | //Fetch the invoice. |
@@ -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 | <div id="wpinv-form-builder" class="bsui"> |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | - * Save meta box data. |
|
86 | - * |
|
87 | - * @param int $post_id |
|
88 | - */ |
|
89 | - public static function save( $post_id ) { |
|
85 | + * Save meta box data. |
|
86 | + * |
|
87 | + * @param int $post_id |
|
88 | + */ |
|
89 | + public static function save( $post_id ) { |
|
90 | 90 | |
91 | 91 | // Prepare the form. |
92 | 92 | $form = new GetPaid_Payment_Form( $post_id ); |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Discount_Details { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the discount. |
@@ -368,34 +368,34 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
371 | - * Save meta box data. |
|
372 | - * |
|
373 | - * @param int $post_id |
|
374 | - */ |
|
375 | - public static function save( $post_id ) { |
|
371 | + * Save meta box data. |
|
372 | + * |
|
373 | + * @param int $post_id |
|
374 | + */ |
|
375 | + public static function save( $post_id ) { |
|
376 | 376 | |
377 | 377 | // Prepare the discount. |
378 | 378 | $discount = new WPInv_Discount( $post_id ); |
379 | 379 | |
380 | 380 | // Load new data. |
381 | 381 | $discount->set_props( |
382 | - array( |
|
383 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null, |
|
384 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null, |
|
385 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
386 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
387 | - 'is_single_use' => isset( $_POST['wpinv_discount_single_use'] ), |
|
382 | + array( |
|
383 | + 'code' => isset( $_POST['wpinv_discount_code'] ) ? $_POST['wpinv_discount_code'] : null, |
|
384 | + 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? $_POST['wpinv_discount_amount'] : null, |
|
385 | + 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
386 | + 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
387 | + 'is_single_use' => isset( $_POST['wpinv_discount_single_use'] ), |
|
388 | 388 | 'type' => isset( $_POST['wpinv_discount_type'] ) ? $_POST['wpinv_discount_type'] : null, |
389 | - 'is_recurring' => isset( $_POST['wpinv_discount_recurring'] ), |
|
390 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : null, |
|
391 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : null, |
|
392 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null, |
|
393 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null, |
|
394 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null, |
|
395 | - ) |
|
389 | + 'is_recurring' => isset( $_POST['wpinv_discount_recurring'] ), |
|
390 | + 'items' => isset( $_POST['wpinv_discount_items'] ) ? $_POST['wpinv_discount_items'] : null, |
|
391 | + 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? $_POST['wpinv_discount_excluded_items'] : null, |
|
392 | + 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? $_POST['wpinv_discount_max_uses'] : null, |
|
393 | + 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? $_POST['wpinv_discount_min_total'] : null, |
|
394 | + 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? $_POST['wpinv_discount_max_total'] : null, |
|
395 | + ) |
|
396 | 396 | ); |
397 | 397 | |
398 | - $discount->save(); |
|
399 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
400 | - } |
|
398 | + $discount->save(); |
|
399 | + do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
400 | + } |
|
401 | 401 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Item_Details { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the item. |
@@ -289,35 +289,35 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
292 | - * Save meta box data. |
|
293 | - * |
|
294 | - * @param int $post_id |
|
295 | - */ |
|
296 | - public static function save( $post_id ) { |
|
292 | + * Save meta box data. |
|
293 | + * |
|
294 | + * @param int $post_id |
|
295 | + */ |
|
296 | + public static function save( $post_id ) { |
|
297 | 297 | |
298 | 298 | // Prepare the item. |
299 | 299 | $item = new WPInv_Item( $post_id ); |
300 | 300 | |
301 | 301 | // Load new data. |
302 | 302 | $item->set_props( |
303 | - array( |
|
304 | - 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
305 | - 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
306 | - 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
307 | - 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
308 | - 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
303 | + array( |
|
304 | + 'price' => isset( $_POST['wpinv_item_price'] ) ? (float) $_POST['wpinv_item_price'] : null, |
|
305 | + 'vat_rule' => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null, |
|
306 | + 'vat_class' => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null, |
|
307 | + 'type' => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null, |
|
308 | + 'is_dynamic_pricing' => isset( $_POST['wpinv_name_your_price'] ), |
|
309 | 309 | 'minimum_price' => isset( $_POST['wpinv_minimum_price'] ) ? (float) $_POST['wpinv_minimum_price'] : null, |
310 | - 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
311 | - 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
312 | - 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
313 | - 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
314 | - 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
315 | - 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
316 | - 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
317 | - ) |
|
310 | + 'is_recurring' => isset( $_POST['wpinv_is_recurring'] ), |
|
311 | + 'recurring_period' => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null, |
|
312 | + 'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : null, |
|
313 | + 'recurring_limit' => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null, |
|
314 | + 'is_free_trial' => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null, |
|
315 | + 'trial_period' => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null, |
|
316 | + 'trial_interval' => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null, |
|
317 | + ) |
|
318 | 318 | ); |
319 | 319 | |
320 | - $item->save(); |
|
321 | - do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
322 | - } |
|
320 | + $item->save(); |
|
321 | + do_action( 'getpaid_item_metabox_save', $post_id, $item ); |
|
322 | + } |
|
323 | 323 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | class GetPaid_Meta_Box_Invoice_Address { |
18 | 18 | |
19 | 19 | /** |
20 | - * Output the metabox. |
|
21 | - * |
|
22 | - * @param WP_Post $post |
|
23 | - */ |
|
20 | + * Output the metabox. |
|
21 | + * |
|
22 | + * @param WP_Post $post |
|
23 | + */ |
|
24 | 24 | public static function output( $post ) { |
25 | 25 | |
26 | 26 | // Prepare the invoice. |
@@ -300,18 +300,18 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
303 | - * Save meta box data. |
|
304 | - * |
|
305 | - * @param int $post_id |
|
306 | - */ |
|
307 | - public static function save( $post_id ) { |
|
303 | + * Save meta box data. |
|
304 | + * |
|
305 | + * @param int $post_id |
|
306 | + */ |
|
307 | + public static function save( $post_id ) { |
|
308 | 308 | |
309 | 309 | // Prepare the invoice. |
310 | 310 | $invoice = new WPInv_Invoice( $post_id ); |
311 | 311 | |
312 | 312 | // Load new data. |
313 | 313 | $invoice->set_props( |
314 | - array( |
|
314 | + array( |
|
315 | 315 | 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
316 | 316 | 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
317 | 317 | 'disable_taxes' => isset( $_POST['disable_taxes'] ), |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
333 | 333 | 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
334 | 334 | 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
335 | - ) |
|
335 | + ) |
|
336 | 336 | ); |
337 | 337 | |
338 | 338 | // Recalculate totals. |
@@ -362,6 +362,6 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | // Fires after an invoice is saved. |
365 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
366 | - } |
|
365 | + do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
366 | + } |
|
367 | 367 | } |
@@ -13,259 +13,259 @@ |
||
13 | 13 | class GetPaid_Post_Types_Admin { |
14 | 14 | |
15 | 15 | /** |
16 | - * Hook in methods. |
|
17 | - */ |
|
18 | - public static function init() { |
|
19 | - |
|
20 | - // Init metaboxes. |
|
21 | - GetPaid_Metaboxes::init(); |
|
22 | - |
|
23 | - // Filter the post updated messages. |
|
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | - |
|
26 | - // Filter post actions. |
|
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - |
|
29 | - // Table columns. |
|
30 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
31 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
32 | - |
|
33 | - // Deleting posts. |
|
34 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * Post updated messages. |
|
39 | - */ |
|
40 | - public static function post_updated_messages( $messages ) { |
|
41 | - global $post; |
|
42 | - |
|
43 | - $messages['wpi_discount'] = array( |
|
44 | - 0 => '', |
|
45 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
46 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
47 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
48 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
49 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
50 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
51 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
52 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
53 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
54 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
55 | - ); |
|
56 | - |
|
57 | - $messages['wpi_payment_form'] = array( |
|
58 | - 0 => '', |
|
59 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
60 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
61 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
62 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
63 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
64 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
65 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
66 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
67 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
68 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
69 | - ); |
|
70 | - |
|
71 | - return $messages; |
|
72 | - |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Post row actions. |
|
77 | - */ |
|
78 | - public static function post_row_actions( $actions, $post ) { |
|
79 | - |
|
80 | - $post = get_post( $post ); |
|
81 | - |
|
82 | - // We do not want to edit the default payment form. |
|
83 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
84 | - unset( $actions['trash'] ); |
|
85 | - unset( $actions['inline hide-if-no-js'] ); |
|
86 | - } |
|
87 | - |
|
88 | - return $actions; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Returns an array of invoice table columns. |
|
93 | - */ |
|
94 | - public static function invoice_columns( $columns ) { |
|
95 | - |
|
96 | - $columns = array( |
|
97 | - 'cb' => $columns['cb'], |
|
98 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
99 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
100 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
101 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
102 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
103 | - 'status' => __( 'Status', 'invoicing' ), |
|
104 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
105 | - ); |
|
106 | - |
|
107 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Displays invoice table columns. |
|
112 | - */ |
|
113 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
114 | - |
|
115 | - $invoice = new WPInv_Invoice( $post_id ); |
|
116 | - |
|
117 | - switch ( $column_name ) { |
|
118 | - |
|
119 | - case 'invoice_date' : |
|
120 | - $date_time = sanitize_text_field( $invoice->get_created_date() ); |
|
121 | - $date = mysql2date( get_option( 'date_format' ), $date_time ); |
|
122 | - echo "<span title='$date_time'>$date</span>"; |
|
123 | - break; |
|
124 | - |
|
125 | - case 'amount' : |
|
126 | - |
|
127 | - $amount = $invoice->get_total(); |
|
128 | - $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
129 | - |
|
130 | - if ( $invoice->is_refunded() ) { |
|
131 | - $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
132 | - echo "<del>$formated_amount</del><ins>$refunded_amount</ins>"; |
|
133 | - } else { |
|
134 | - |
|
135 | - $discount = $invoice->get_total_discount(); |
|
136 | - |
|
137 | - if ( ! empty( $discount ) ) { |
|
138 | - $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
139 | - echo "<del>$new_amount</del><ins>$formated_amount</ins>"; |
|
140 | - } else { |
|
141 | - echo $formated_amount; |
|
142 | - } |
|
143 | - |
|
144 | - } |
|
145 | - |
|
146 | - break; |
|
147 | - |
|
148 | - case 'status' : |
|
149 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
150 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
151 | - |
|
152 | - // If it is paid, show the gateway title. |
|
153 | - if ( $invoice->is_paid() ) { |
|
154 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
155 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
16 | + * Hook in methods. |
|
17 | + */ |
|
18 | + public static function init() { |
|
156 | 19 | |
157 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
158 | - } else { |
|
159 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
160 | - } |
|
20 | + // Init metaboxes. |
|
21 | + GetPaid_Metaboxes::init(); |
|
161 | 22 | |
162 | - // If it is not paid, display the overdue and view status. |
|
163 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
23 | + // Filter the post updated messages. |
|
24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
164 | 25 | |
165 | - // Invoice view status. |
|
166 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
167 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
168 | - } else { |
|
169 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
170 | - } |
|
26 | + // Filter post actions. |
|
27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
171 | 28 | |
172 | - // Display the overview status. |
|
173 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
174 | - $due_date = $invoice->get_due_date(); |
|
29 | + // Table columns. |
|
30 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
31 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
175 | 32 | |
176 | - if ( ! empty( $due_date ) ) { |
|
177 | - $date = mysql2date( get_option( 'date_format' ), $due_date ); |
|
178 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $date ); |
|
179 | - echo "<p class='description' style='color: #888;' title='$due_date'>$date</p>"; |
|
180 | - } |
|
181 | - } |
|
33 | + // Deleting posts. |
|
34 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
35 | + } |
|
182 | 36 | |
183 | - } |
|
37 | + /** |
|
38 | + * Post updated messages. |
|
39 | + */ |
|
40 | + public static function post_updated_messages( $messages ) { |
|
41 | + global $post; |
|
42 | + |
|
43 | + $messages['wpi_discount'] = array( |
|
44 | + 0 => '', |
|
45 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
46 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
47 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
48 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
49 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
50 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
51 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
52 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
53 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
54 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
55 | + ); |
|
56 | + |
|
57 | + $messages['wpi_payment_form'] = array( |
|
58 | + 0 => '', |
|
59 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
60 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
61 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
62 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
63 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
64 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
65 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
66 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
67 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
68 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
69 | + ); |
|
70 | + |
|
71 | + return $messages; |
|
72 | + |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Post row actions. |
|
77 | + */ |
|
78 | + public static function post_row_actions( $actions, $post ) { |
|
79 | + |
|
80 | + $post = get_post( $post ); |
|
81 | + |
|
82 | + // We do not want to edit the default payment form. |
|
83 | + if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
84 | + unset( $actions['trash'] ); |
|
85 | + unset( $actions['inline hide-if-no-js'] ); |
|
86 | + } |
|
87 | + |
|
88 | + return $actions; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Returns an array of invoice table columns. |
|
93 | + */ |
|
94 | + public static function invoice_columns( $columns ) { |
|
95 | + |
|
96 | + $columns = array( |
|
97 | + 'cb' => $columns['cb'], |
|
98 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
99 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
100 | + 'invoice_date' => __( 'Date', 'invoicing' ), |
|
101 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
102 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
103 | + 'status' => __( 'Status', 'invoicing' ), |
|
104 | + 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
105 | + ); |
|
106 | + |
|
107 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Displays invoice table columns. |
|
112 | + */ |
|
113 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
114 | + |
|
115 | + $invoice = new WPInv_Invoice( $post_id ); |
|
116 | + |
|
117 | + switch ( $column_name ) { |
|
118 | + |
|
119 | + case 'invoice_date' : |
|
120 | + $date_time = sanitize_text_field( $invoice->get_created_date() ); |
|
121 | + $date = mysql2date( get_option( 'date_format' ), $date_time ); |
|
122 | + echo "<span title='$date_time'>$date</span>"; |
|
123 | + break; |
|
124 | + |
|
125 | + case 'amount' : |
|
126 | + |
|
127 | + $amount = $invoice->get_total(); |
|
128 | + $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
129 | + |
|
130 | + if ( $invoice->is_refunded() ) { |
|
131 | + $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
132 | + echo "<del>$formated_amount</del><ins>$refunded_amount</ins>"; |
|
133 | + } else { |
|
184 | 134 | |
185 | - break; |
|
135 | + $discount = $invoice->get_total_discount(); |
|
186 | 136 | |
187 | - case 'recurring': |
|
137 | + if ( ! empty( $discount ) ) { |
|
138 | + $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
139 | + echo "<del>$new_amount</del><ins>$formated_amount</ins>"; |
|
140 | + } else { |
|
141 | + echo $formated_amount; |
|
142 | + } |
|
188 | 143 | |
189 | - if ( $invoice->is_recurring() ) { |
|
190 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
191 | - } else { |
|
192 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
193 | - } |
|
194 | - break; |
|
144 | + } |
|
195 | 145 | |
196 | - case 'number' : |
|
146 | + break; |
|
197 | 147 | |
198 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
199 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
200 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
148 | + case 'status' : |
|
149 | + $status = sanitize_text_field( $invoice->get_status() ); |
|
150 | + $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
201 | 151 | |
202 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
152 | + // If it is paid, show the gateway title. |
|
153 | + if ( $invoice->is_paid() ) { |
|
154 | + $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
155 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
203 | 156 | |
204 | - break; |
|
157 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
158 | + } else { |
|
159 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
160 | + } |
|
205 | 161 | |
206 | - case 'customer' : |
|
162 | + // If it is not paid, display the overdue and view status. |
|
163 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
164 | + |
|
165 | + // Invoice view status. |
|
166 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
167 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
168 | + } else { |
|
169 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
170 | + } |
|
171 | + |
|
172 | + // Display the overview status. |
|
173 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
174 | + $due_date = $invoice->get_due_date(); |
|
175 | + |
|
176 | + if ( ! empty( $due_date ) ) { |
|
177 | + $date = mysql2date( get_option( 'date_format' ), $due_date ); |
|
178 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $date ); |
|
179 | + echo "<p class='description' style='color: #888;' title='$due_date'>$date</p>"; |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + } |
|
184 | + |
|
185 | + break; |
|
186 | + |
|
187 | + case 'recurring': |
|
188 | + |
|
189 | + if ( $invoice->is_recurring() ) { |
|
190 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
191 | + } else { |
|
192 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
193 | + } |
|
194 | + break; |
|
195 | + |
|
196 | + case 'number' : |
|
197 | + |
|
198 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
199 | + $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
200 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
201 | + |
|
202 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
203 | + |
|
204 | + break; |
|
205 | + |
|
206 | + case 'customer' : |
|
207 | 207 | |
208 | - $customer_name = $invoice->get_user_full_name(); |
|
208 | + $customer_name = $invoice->get_user_full_name(); |
|
209 | 209 | |
210 | - if ( empty( $customer_name ) ) { |
|
211 | - $customer_name = $invoice->get_email(); |
|
212 | - } |
|
210 | + if ( empty( $customer_name ) ) { |
|
211 | + $customer_name = $invoice->get_email(); |
|
212 | + } |
|
213 | 213 | |
214 | - if ( ! empty( $customer_name ) ) { |
|
215 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
216 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
217 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
218 | - } else { |
|
219 | - echo '<div>—</div>'; |
|
220 | - } |
|
221 | - |
|
222 | - break; |
|
223 | - |
|
224 | - case 'wpi_actions' : |
|
225 | - |
|
226 | - if ( ! $invoice->is_draft() ) { |
|
227 | - $url = esc_url( $invoice->get_view_url() ); |
|
228 | - $print = esc_attr__( 'Print invoice', 'invoicing' ); |
|
229 | - echo " <a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>"; |
|
230 | - } |
|
231 | - |
|
232 | - if ( $invoice->get_email() ) { |
|
233 | - $url = esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $invoice->get_id() ) ) ); |
|
234 | - $send = esc_attr__( 'Send invoice to customer', 'invoicing' ); |
|
235 | - echo " <a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>"; |
|
236 | - } |
|
214 | + if ( ! empty( $customer_name ) ) { |
|
215 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
216 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
217 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
218 | + } else { |
|
219 | + echo '<div>—</div>'; |
|
220 | + } |
|
221 | + |
|
222 | + break; |
|
223 | + |
|
224 | + case 'wpi_actions' : |
|
225 | + |
|
226 | + if ( ! $invoice->is_draft() ) { |
|
227 | + $url = esc_url( $invoice->get_view_url() ); |
|
228 | + $print = esc_attr__( 'Print invoice', 'invoicing' ); |
|
229 | + echo " <a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>"; |
|
230 | + } |
|
231 | + |
|
232 | + if ( $invoice->get_email() ) { |
|
233 | + $url = esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $invoice->get_id() ) ) ); |
|
234 | + $send = esc_attr__( 'Send invoice to customer', 'invoicing' ); |
|
235 | + echo " <a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>"; |
|
236 | + } |
|
237 | 237 | |
238 | - break; |
|
239 | - } |
|
240 | - |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Fired when deleting a post. |
|
245 | - */ |
|
246 | - public static function delete_post( $post_id ) { |
|
247 | - |
|
248 | - switch ( get_post_type( $post_id ) ) { |
|
249 | - |
|
250 | - case 'wpi_item' : |
|
251 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
252 | - break; |
|
253 | - |
|
254 | - case 'wpi_payment_form' : |
|
255 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
256 | - break; |
|
257 | - |
|
258 | - case 'wpi_discount' : |
|
259 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
260 | - break; |
|
261 | - |
|
262 | - case 'wpi_invoice' : |
|
263 | - $invoice = new WPInv_Invoice( $post_id ); |
|
264 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
265 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
266 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
267 | - break; |
|
268 | - } |
|
269 | - } |
|
238 | + break; |
|
239 | + } |
|
240 | + |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Fired when deleting a post. |
|
245 | + */ |
|
246 | + public static function delete_post( $post_id ) { |
|
247 | + |
|
248 | + switch ( get_post_type( $post_id ) ) { |
|
249 | + |
|
250 | + case 'wpi_item' : |
|
251 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
252 | + break; |
|
253 | + |
|
254 | + case 'wpi_payment_form' : |
|
255 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
256 | + break; |
|
257 | + |
|
258 | + case 'wpi_discount' : |
|
259 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
260 | + break; |
|
261 | + |
|
262 | + case 'wpi_invoice' : |
|
263 | + $invoice = new WPInv_Invoice( $post_id ); |
|
264 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
265 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
266 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
267 | + break; |
|
268 | + } |
|
269 | + } |
|
270 | 270 | |
271 | 271 | } |
@@ -12,181 +12,181 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Metaboxes { |
14 | 14 | |
15 | - /** |
|
16 | - * Only save metaboxes once. |
|
17 | - * |
|
18 | - * @var boolean |
|
19 | - */ |
|
20 | - private static $saved_meta_boxes = false; |
|
21 | - |
|
22 | 15 | /** |
23 | - * Hook in methods. |
|
24 | - */ |
|
25 | - public static function init() { |
|
26 | - |
|
27 | - // Register metaboxes. |
|
28 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 15, 2 ); |
|
29 | - |
|
30 | - // Remove metaboxes. |
|
31 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
16 | + * Only save metaboxes once. |
|
17 | + * |
|
18 | + * @var boolean |
|
19 | + */ |
|
20 | + private static $saved_meta_boxes = false; |
|
32 | 21 | |
33 | - // Rename metaboxes. |
|
34 | - add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
35 | - |
|
36 | - // Save metaboxes. |
|
37 | - add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
38 | - } |
|
22 | + /** |
|
23 | + * Hook in methods. |
|
24 | + */ |
|
25 | + public static function init() { |
|
39 | 26 | |
40 | - /** |
|
41 | - * Register core metaboxes. |
|
42 | - */ |
|
43 | - public static function add_meta_boxes( $post_type, $post ) { |
|
44 | - global $wpinv_euvat; |
|
27 | + // Register metaboxes. |
|
28 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 15, 2 ); |
|
45 | 29 | |
46 | - // For invoices... |
|
47 | - if ( $post_type == 'wpi_invoice' ) { |
|
48 | - $invoice = new WPInv_Invoice( $post ); |
|
30 | + // Remove metaboxes. |
|
31 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 ); |
|
49 | 32 | |
50 | - // Resend invoice. |
|
51 | - if ( ! $invoice->is_draft() ) { |
|
52 | - add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'high' ); |
|
53 | - } |
|
33 | + // Rename metaboxes. |
|
34 | + add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 ); |
|
54 | 35 | |
55 | - // Subscriptions. |
|
56 | - if ( $invoice->is_recurring() ) { |
|
57 | - add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high' ); |
|
58 | - } |
|
36 | + // Save metaboxes. |
|
37 | + add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 ); |
|
38 | + } |
|
59 | 39 | |
60 | - // Invoice details. |
|
61 | - add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
40 | + /** |
|
41 | + * Register core metaboxes. |
|
42 | + */ |
|
43 | + public static function add_meta_boxes( $post_type, $post ) { |
|
44 | + global $wpinv_euvat; |
|
45 | + |
|
46 | + // For invoices... |
|
47 | + if ( $post_type == 'wpi_invoice' ) { |
|
48 | + $invoice = new WPInv_Invoice( $post ); |
|
49 | + |
|
50 | + // Resend invoice. |
|
51 | + if ( ! $invoice->is_draft() ) { |
|
52 | + add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'high' ); |
|
53 | + } |
|
54 | + |
|
55 | + // Subscriptions. |
|
56 | + if ( $invoice->is_recurring() ) { |
|
57 | + add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high' ); |
|
58 | + } |
|
59 | + |
|
60 | + // Invoice details. |
|
61 | + add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' ); |
|
62 | 62 | |
63 | - // Payment details. |
|
64 | - add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' ); |
|
63 | + // Payment details. |
|
64 | + add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' ); |
|
65 | 65 | |
66 | - // Billing details. |
|
67 | - add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' ); |
|
66 | + // Billing details. |
|
67 | + add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' ); |
|
68 | 68 | |
69 | - // Invoice items. |
|
70 | - add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
69 | + // Invoice items. |
|
70 | + add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' ); |
|
71 | 71 | |
72 | - // Invoice notes. |
|
73 | - add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
72 | + // Invoice notes. |
|
73 | + add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
|
74 | 74 | |
75 | - // Payment form information. |
|
76 | - if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) { |
|
77 | - add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' ); |
|
78 | - } |
|
79 | - } |
|
75 | + // Payment form information. |
|
76 | + if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) { |
|
77 | + add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' ); |
|
78 | + } |
|
79 | + } |
|
80 | 80 | |
81 | - // For payment forms. |
|
82 | - if ( $post_type == 'wpi_payment_form' ) { |
|
81 | + // For payment forms. |
|
82 | + if ( $post_type == 'wpi_payment_form' ) { |
|
83 | 83 | |
84 | - // Design payment form. |
|
85 | - add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
84 | + // Design payment form. |
|
85 | + add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' ); |
|
86 | 86 | |
87 | - // Payment form information. |
|
88 | - add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
87 | + // Payment form information. |
|
88 | + add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' ); |
|
89 | 89 | |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | - // For invoice items. |
|
93 | - if ( $post_type == 'wpi_item' ) { |
|
92 | + // For invoice items. |
|
93 | + if ( $post_type == 'wpi_item' ) { |
|
94 | 94 | |
95 | - // Item details. |
|
96 | - add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
95 | + // Item details. |
|
96 | + add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' ); |
|
97 | 97 | |
98 | - // If taxes are enabled, register the tax metabox. |
|
99 | - if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) { |
|
100 | - add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
101 | - } |
|
98 | + // If taxes are enabled, register the tax metabox. |
|
99 | + if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) { |
|
100 | + add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' ); |
|
101 | + } |
|
102 | 102 | |
103 | - // Item info. |
|
104 | - add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
103 | + // Item info. |
|
104 | + add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' ); |
|
105 | 105 | |
106 | - } |
|
106 | + } |
|
107 | 107 | |
108 | - // For invoice discounts. |
|
109 | - if ( $post_type == 'wpi_discount' ) { |
|
110 | - add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
111 | - } |
|
108 | + // For invoice discounts. |
|
109 | + if ( $post_type == 'wpi_discount' ) { |
|
110 | + add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' ); |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - } |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Remove some metaboxes. |
|
118 | - */ |
|
119 | - public static function remove_meta_boxes() { |
|
120 | - remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
121 | - } |
|
116 | + /** |
|
117 | + * Remove some metaboxes. |
|
118 | + */ |
|
119 | + public static function remove_meta_boxes() { |
|
120 | + remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' ); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Rename other metaboxes. |
|
125 | - */ |
|
126 | - public static function rename_meta_boxes() { |
|
123 | + /** |
|
124 | + * Rename other metaboxes. |
|
125 | + */ |
|
126 | + public static function rename_meta_boxes() { |
|
127 | 127 | |
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Check if we're saving, then trigger an action based on the post type. |
|
132 | - * |
|
133 | - * @param int $post_id Post ID. |
|
134 | - * @param object $post Post object. |
|
135 | - */ |
|
136 | - public static function save_meta_boxes( $post_id, $post ) { |
|
137 | - $post_id = absint( $post_id ); |
|
138 | - |
|
139 | - // Do not save for ajax requests. |
|
140 | - if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
141 | - return; |
|
142 | - } |
|
143 | - |
|
144 | - // $post_id and $post are required |
|
145 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
146 | - return; |
|
147 | - } |
|
148 | - |
|
149 | - // Dont' save meta boxes for revisions or autosaves. |
|
150 | - if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
151 | - return; |
|
152 | - } |
|
153 | - |
|
154 | - // Check the nonce. |
|
155 | - if ( empty( $_POST['getpaid_meta_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['getpaid_meta_nonce'] ), 'getpaid_meta_nonce' ) ) { |
|
156 | - return; |
|
157 | - } |
|
158 | - |
|
159 | - // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
160 | - if ( empty( $_POST['post_ID'] ) || absint( $_POST['post_ID'] ) !== $post_id ) { |
|
161 | - return; |
|
162 | - } |
|
163 | - |
|
164 | - // Check user has permission to edit. |
|
165 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
166 | - return; |
|
167 | - } |
|
168 | - |
|
169 | - // Ensure this is our post type. |
|
170 | - $post_types_map = array( |
|
171 | - 'wpi_invoice' => 'GetPaid_Meta_Box_Invoice_Address', |
|
172 | - 'wpi_quote' => 'GetPaid_Meta_Box_Invoice_Address', |
|
173 | - 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
174 | - 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
175 | - 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
176 | - ); |
|
177 | - |
|
178 | - // Is this our post type? |
|
179 | - if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
180 | - return; |
|
181 | - } |
|
182 | - |
|
183 | - // We need this save event to run once to avoid potential endless loops. |
|
184 | - self::$saved_meta_boxes = true; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Check if we're saving, then trigger an action based on the post type. |
|
132 | + * |
|
133 | + * @param int $post_id Post ID. |
|
134 | + * @param object $post Post object. |
|
135 | + */ |
|
136 | + public static function save_meta_boxes( $post_id, $post ) { |
|
137 | + $post_id = absint( $post_id ); |
|
138 | + |
|
139 | + // Do not save for ajax requests. |
|
140 | + if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) { |
|
141 | + return; |
|
142 | + } |
|
143 | + |
|
144 | + // $post_id and $post are required |
|
145 | + if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
146 | + return; |
|
147 | + } |
|
148 | + |
|
149 | + // Dont' save meta boxes for revisions or autosaves. |
|
150 | + if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
151 | + return; |
|
152 | + } |
|
153 | + |
|
154 | + // Check the nonce. |
|
155 | + if ( empty( $_POST['getpaid_meta_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['getpaid_meta_nonce'] ), 'getpaid_meta_nonce' ) ) { |
|
156 | + return; |
|
157 | + } |
|
158 | + |
|
159 | + // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
|
160 | + if ( empty( $_POST['post_ID'] ) || absint( $_POST['post_ID'] ) !== $post_id ) { |
|
161 | + return; |
|
162 | + } |
|
163 | + |
|
164 | + // Check user has permission to edit. |
|
165 | + if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
166 | + return; |
|
167 | + } |
|
168 | + |
|
169 | + // Ensure this is our post type. |
|
170 | + $post_types_map = array( |
|
171 | + 'wpi_invoice' => 'GetPaid_Meta_Box_Invoice_Address', |
|
172 | + 'wpi_quote' => 'GetPaid_Meta_Box_Invoice_Address', |
|
173 | + 'wpi_item' => 'GetPaid_Meta_Box_Item_Details', |
|
174 | + 'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form', |
|
175 | + 'wpi_discount' => 'GetPaid_Meta_Box_Discount_Details', |
|
176 | + ); |
|
177 | + |
|
178 | + // Is this our post type? |
|
179 | + if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) { |
|
180 | + return; |
|
181 | + } |
|
182 | + |
|
183 | + // We need this save event to run once to avoid potential endless loops. |
|
184 | + self::$saved_meta_boxes = true; |
|
185 | 185 | |
186 | - // Save the post. |
|
187 | - $class = $post_types_map[ $post->post_type ]; |
|
188 | - $class::save( $post_id, $_POST, $post ); |
|
186 | + // Save the post. |
|
187 | + $class = $post_types_map[ $post->post_type ]; |
|
188 | + $class::save( $post_id, $_POST, $post ); |
|
189 | 189 | |
190 | - } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | } |