@@ -38,29 +38,29 @@ discard block |
||
38 | 38 | 'advanced' => false |
39 | 39 | ), |
40 | 40 | 'buy_items' => array( |
41 | - 'title' => __( 'Items to buy', 'invoicing' ), |
|
42 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
43 | - 'type' => 'text', |
|
44 | - 'desc_tip' => true, |
|
45 | - 'default' => '', |
|
46 | - 'placeholder' => __('Items to buy','invoicing'), |
|
47 | - 'advanced' => false |
|
41 | + 'title' => __( 'Items to buy', 'invoicing' ), |
|
42 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
43 | + 'type' => 'text', |
|
44 | + 'desc_tip' => true, |
|
45 | + 'default' => '', |
|
46 | + 'placeholder' => __('Items to buy','invoicing'), |
|
47 | + 'advanced' => false |
|
48 | 48 | ), |
49 | 49 | 'button_label' => array( |
50 | - 'title' => __( 'Button Label', 'invoicing' ), |
|
51 | - 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
52 | - 'type' => 'text', |
|
53 | - 'desc_tip' => true, |
|
54 | - 'default' => __( 'Buy Now', 'invoicing' ), |
|
55 | - 'advanced' => false |
|
50 | + 'title' => __( 'Button Label', 'invoicing' ), |
|
51 | + 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
52 | + 'type' => 'text', |
|
53 | + 'desc_tip' => true, |
|
54 | + 'default' => __( 'Buy Now', 'invoicing' ), |
|
55 | + 'advanced' => false |
|
56 | 56 | ), |
57 | 57 | 'post_id' => array( |
58 | - 'title' => __( 'Post ID', 'invoicing' ), |
|
59 | - 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
60 | - 'type' => 'number', |
|
61 | - 'desc_tip' => true, |
|
62 | - 'default' => '', |
|
63 | - 'advanced' => true |
|
58 | + 'title' => __( 'Post ID', 'invoicing' ), |
|
59 | + 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
60 | + 'type' => 'number', |
|
61 | + 'desc_tip' => true, |
|
62 | + 'default' => '', |
|
63 | + 'advanced' => true |
|
64 | 64 | ), |
65 | 65 | ) |
66 | 66 | |
@@ -70,43 +70,43 @@ discard block |
||
70 | 70 | parent::__construct( $options ); |
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * The Super block output function. |
|
75 | - * |
|
76 | - * @param array $args |
|
77 | - * @param array $widget_args |
|
78 | - * @param string $content |
|
79 | - * |
|
80 | - * @return string |
|
81 | - */ |
|
73 | + /** |
|
74 | + * The Super block output function. |
|
75 | + * |
|
76 | + * @param array $args |
|
77 | + * @param array $widget_args |
|
78 | + * @param string $content |
|
79 | + * |
|
80 | + * @return string |
|
81 | + */ |
|
82 | 82 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
83 | 83 | |
84 | - $defaults = array( |
|
85 | - 'buy_items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
|
86 | - 'button_label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
87 | - 'post_id' => '', // any related post_id |
|
88 | - ); |
|
84 | + $defaults = array( |
|
85 | + 'buy_items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
|
86 | + 'button_label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
87 | + 'post_id' => '', // any related post_id |
|
88 | + ); |
|
89 | 89 | |
90 | - /** |
|
91 | - * Parse incoming $args into an array and merge it with $defaults |
|
92 | - */ |
|
93 | - $args = wp_parse_args( $args, $defaults ); |
|
90 | + /** |
|
91 | + * Parse incoming $args into an array and merge it with $defaults |
|
92 | + */ |
|
93 | + $args = wp_parse_args( $args, $defaults ); |
|
94 | 94 | |
95 | - $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
|
95 | + $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
|
96 | 96 | |
97 | - if ( empty( $args['buy_items'] ) ) { |
|
98 | - $html .= __( 'No items selected', 'invoicing' ); |
|
99 | - } else { |
|
100 | - $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0; |
|
101 | - $label = isset( $args['button_label'] ) ? sanitize_text_field( $args['button_label'] ) : __( 'Buy Now', 'invoicing' ); |
|
102 | - $items = esc_attr( $args['buy_items'] ); |
|
103 | - $html .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>"; |
|
104 | - } |
|
97 | + if ( empty( $args['buy_items'] ) ) { |
|
98 | + $html .= __( 'No items selected', 'invoicing' ); |
|
99 | + } else { |
|
100 | + $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0; |
|
101 | + $label = isset( $args['button_label'] ) ? sanitize_text_field( $args['button_label'] ) : __( 'Buy Now', 'invoicing' ); |
|
102 | + $items = esc_attr( $args['buy_items'] ); |
|
103 | + $html .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>"; |
|
104 | + } |
|
105 | 105 | |
106 | - $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
107 | - $html .= '</div>'; |
|
106 | + $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
107 | + $html .= '</div>'; |
|
108 | 108 | |
109 | - return $html; |
|
109 | + return $html; |
|
110 | 110 | |
111 | 111 | } |
112 | 112 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -23,40 +23,40 @@ discard block |
||
23 | 23 | 'block-keywords'=> "['invoicing','buy', 'buy item']", |
24 | 24 | 'class_name' => __CLASS__, |
25 | 25 | 'base_id' => 'wpinv_buy', |
26 | - 'name' => __('Invoicing > Buy Item Button','invoicing'), |
|
26 | + 'name' => __('Invoicing > Buy Item Button', 'invoicing'), |
|
27 | 27 | 'widget_ops' => array( |
28 | 28 | 'classname' => 'wpinv-buy-item-class wpi-g', |
29 | - 'description' => esc_html__('Displays buy invoicing item button.','invoicing'), |
|
29 | + 'description' => esc_html__('Displays buy invoicing item button.', 'invoicing'), |
|
30 | 30 | ), |
31 | 31 | 'arguments' => array( |
32 | 32 | 'title' => array( |
33 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
34 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
33 | + 'title' => __('Widget title', 'invoicing'), |
|
34 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
35 | 35 | 'type' => 'text', |
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
38 | 38 | 'advanced' => false |
39 | 39 | ), |
40 | 40 | 'buy_items' => array( |
41 | - 'title' => __( 'Items to buy', 'invoicing' ), |
|
42 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
|
41 | + 'title' => __('Items to buy', 'invoicing'), |
|
42 | + 'desc' => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing'), |
|
43 | 43 | 'type' => 'text', |
44 | 44 | 'desc_tip' => true, |
45 | 45 | 'default' => '', |
46 | - 'placeholder' => __('Items to buy','invoicing'), |
|
46 | + 'placeholder' => __('Items to buy', 'invoicing'), |
|
47 | 47 | 'advanced' => false |
48 | 48 | ), |
49 | 49 | 'button_label' => array( |
50 | - 'title' => __( 'Button Label', 'invoicing' ), |
|
51 | - 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
|
50 | + 'title' => __('Button Label', 'invoicing'), |
|
51 | + 'desc' => __('Enter button label. Default "Buy Now".', 'invoicing'), |
|
52 | 52 | 'type' => 'text', |
53 | 53 | 'desc_tip' => true, |
54 | - 'default' => __( 'Buy Now', 'invoicing' ), |
|
54 | + 'default' => __('Buy Now', 'invoicing'), |
|
55 | 55 | 'advanced' => false |
56 | 56 | ), |
57 | 57 | 'post_id' => array( |
58 | - 'title' => __( 'Post ID', 'invoicing' ), |
|
59 | - 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
|
58 | + 'title' => __('Post ID', 'invoicing'), |
|
59 | + 'desc' => __('Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing'), |
|
60 | 60 | 'type' => 'number', |
61 | 61 | 'desc_tip' => true, |
62 | 62 | 'default' => '', |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ); |
68 | 68 | |
69 | 69 | |
70 | - parent::__construct( $options ); |
|
70 | + parent::__construct($options); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,31 +79,31 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
82 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
83 | 83 | |
84 | 84 | $defaults = array( |
85 | 85 | 'buy_items' => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity |
86 | - 'button_label' => __( 'Buy Now', 'invoicing' ), // the button title |
|
86 | + 'button_label' => __('Buy Now', 'invoicing'), // the button title |
|
87 | 87 | 'post_id' => '', // any related post_id |
88 | 88 | ); |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Parse incoming $args into an array and merge it with $defaults |
92 | 92 | */ |
93 | - $args = wp_parse_args( $args, $defaults ); |
|
93 | + $args = wp_parse_args($args, $defaults); |
|
94 | 94 | |
95 | 95 | $html = '<div class="wpi-buy-button-wrapper wpi-g">'; |
96 | 96 | |
97 | - if ( empty( $args['buy_items'] ) ) { |
|
98 | - $html .= __( 'No items selected', 'invoicing' ); |
|
97 | + if (empty($args['buy_items'])) { |
|
98 | + $html .= __('No items selected', 'invoicing'); |
|
99 | 99 | } else { |
100 | - $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0; |
|
101 | - $label = isset( $args['button_label'] ) ? sanitize_text_field( $args['button_label'] ) : __( 'Buy Now', 'invoicing' ); |
|
102 | - $items = esc_attr( $args['buy_items'] ); |
|
100 | + $post_id = isset($args['post_id']) && is_numeric($args['post_id']) ? sanitize_text_field($args['post_id']) : 0; |
|
101 | + $label = isset($args['button_label']) ? sanitize_text_field($args['button_label']) : __('Buy Now', 'invoicing'); |
|
102 | + $items = esc_attr($args['buy_items']); |
|
103 | 103 | $html .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>"; |
104 | 104 | } |
105 | 105 | |
106 | - $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false ); |
|
106 | + $html .= wp_nonce_field('wpinv_buy_items', 'wpinv_buy_nonce', true, false); |
|
107 | 107 | $html .= '</div>'; |
108 | 108 | |
109 | 109 | return $html; |
@@ -7,38 +7,38 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | -add_action( 'init', 'wpinv_register_post_types', 1 ); |
|
14 | +add_action('init', 'wpinv_register_post_types', 1); |
|
15 | 15 | function wpinv_register_post_types() { |
16 | 16 | |
17 | 17 | $labels = array( |
18 | - 'name' => _x( 'Invoices', 'post type general name', 'invoicing' ), |
|
19 | - 'singular_name' => _x( 'Invoice', 'post type singular name', 'invoicing' ), |
|
20 | - 'menu_name' => _x( 'Invoices', 'admin menu', 'invoicing' ), |
|
21 | - 'name_admin_bar' => _x( 'Invoice', 'add new on admin bar', 'invoicing' ), |
|
22 | - 'add_new' => _x( 'Add New', 'book', 'invoicing' ), |
|
23 | - 'add_new_item' => __( 'Add New Invoice', 'invoicing' ), |
|
24 | - 'new_item' => __( 'New Invoice', 'invoicing' ), |
|
25 | - 'edit_item' => __( 'Edit Invoice', 'invoicing' ), |
|
26 | - 'view_item' => __( 'View Invoice', 'invoicing' ), |
|
27 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
28 | - 'search_items' => __( 'Search Invoices', 'invoicing' ), |
|
29 | - 'parent_item_colon' => __( 'Parent Invoices:', 'invoicing' ), |
|
30 | - 'not_found' => __( 'No invoices found.', 'invoicing' ), |
|
31 | - 'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' ) |
|
18 | + 'name' => _x('Invoices', 'post type general name', 'invoicing'), |
|
19 | + 'singular_name' => _x('Invoice', 'post type singular name', 'invoicing'), |
|
20 | + 'menu_name' => _x('Invoices', 'admin menu', 'invoicing'), |
|
21 | + 'name_admin_bar' => _x('Invoice', 'add new on admin bar', 'invoicing'), |
|
22 | + 'add_new' => _x('Add New', 'book', 'invoicing'), |
|
23 | + 'add_new_item' => __('Add New Invoice', 'invoicing'), |
|
24 | + 'new_item' => __('New Invoice', 'invoicing'), |
|
25 | + 'edit_item' => __('Edit Invoice', 'invoicing'), |
|
26 | + 'view_item' => __('View Invoice', 'invoicing'), |
|
27 | + 'all_items' => __('Invoices', 'invoicing'), |
|
28 | + 'search_items' => __('Search Invoices', 'invoicing'), |
|
29 | + 'parent_item_colon' => __('Parent Invoices:', 'invoicing'), |
|
30 | + 'not_found' => __('No invoices found.', 'invoicing'), |
|
31 | + 'not_found_in_trash' => __('No invoices found in trash.', 'invoicing') |
|
32 | 32 | ); |
33 | - $labels = apply_filters( 'wpinv_labels', $labels ); |
|
33 | + $labels = apply_filters('wpinv_labels', $labels); |
|
34 | 34 | |
35 | 35 | $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico'; |
36 | - $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon ); |
|
36 | + $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon); |
|
37 | 37 | |
38 | 38 | $cap_type = 'wpi_invoice'; |
39 | 39 | $args = array( |
40 | 40 | 'labels' => $labels, |
41 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
41 | + 'description' => __('This is where invoices are stored.', 'invoicing'), |
|
42 | 42 | 'public' => true, |
43 | 43 | 'can_export' => true, |
44 | 44 | '_builtin' => false, |
@@ -71,42 +71,42 @@ discard block |
||
71 | 71 | 'has_archive' => false, |
72 | 72 | 'hierarchical' => false, |
73 | 73 | 'menu_position' => null, |
74 | - 'supports' => array( 'title', 'author' ), |
|
74 | + 'supports' => array('title', 'author'), |
|
75 | 75 | 'menu_icon' => 'dashicons-media-spreadsheet', |
76 | 76 | ); |
77 | 77 | |
78 | - $args = apply_filters( 'wpinv_register_post_type_invoice', $args ); |
|
78 | + $args = apply_filters('wpinv_register_post_type_invoice', $args); |
|
79 | 79 | |
80 | - register_post_type( 'wpi_invoice', $args ); |
|
80 | + register_post_type('wpi_invoice', $args); |
|
81 | 81 | |
82 | 82 | $items_labels = array( |
83 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
84 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
85 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
86 | - 'add_new' => _x( 'Add New', 'wpi_item', 'invoicing' ), |
|
87 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
88 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
89 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
90 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
91 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
92 | - 'search_items' => __( 'Search Items', 'invoicing' ), |
|
83 | + 'name' => _x('Items', 'post type general name', 'invoicing'), |
|
84 | + 'singular_name' => _x('Item', 'post type singular name', 'invoicing'), |
|
85 | + 'menu_name' => _x('Items', 'admin menu', 'invoicing'), |
|
86 | + 'add_new' => _x('Add New', 'wpi_item', 'invoicing'), |
|
87 | + 'add_new_item' => __('Add New Item', 'invoicing'), |
|
88 | + 'new_item' => __('New Item', 'invoicing'), |
|
89 | + 'edit_item' => __('Edit Item', 'invoicing'), |
|
90 | + 'view_item' => __('View Item', 'invoicing'), |
|
91 | + 'all_items' => __('Items', 'invoicing'), |
|
92 | + 'search_items' => __('Search Items', 'invoicing'), |
|
93 | 93 | 'parent_item_colon' => '', |
94 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
95 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
94 | + 'not_found' => __('No items found.', 'invoicing'), |
|
95 | + 'not_found_in_trash' => __('No items found in trash.', 'invoicing') |
|
96 | 96 | ); |
97 | - $items_labels = apply_filters( 'wpinv_items_labels', $items_labels ); |
|
97 | + $items_labels = apply_filters('wpinv_items_labels', $items_labels); |
|
98 | 98 | |
99 | 99 | $cap_type = 'wpi_item'; |
100 | 100 | $invoice_item_args = array( |
101 | 101 | 'labels' => $items_labels, |
102 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
102 | + 'description' => __('This is where you can add new invoice items.', 'invoicing'), |
|
103 | 103 | 'public' => false, |
104 | 104 | 'has_archive' => false, |
105 | 105 | '_builtin' => false, |
106 | 106 | 'show_ui' => true, |
107 | 107 | 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
108 | 108 | 'show_in_nav_menus' => false, |
109 | - 'supports' => array( 'title', 'excerpt' ), |
|
109 | + 'supports' => array('title', 'excerpt'), |
|
110 | 110 | 'register_meta_box_cb' => 'wpinv_register_item_meta_boxes', |
111 | 111 | 'rewrite' => false, |
112 | 112 | 'query_var' => false, |
@@ -133,33 +133,33 @@ discard block |
||
133 | 133 | ), |
134 | 134 | 'can_export' => true, |
135 | 135 | ); |
136 | - $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args ); |
|
136 | + $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args); |
|
137 | 137 | |
138 | - register_post_type( 'wpi_item', $invoice_item_args ); |
|
138 | + register_post_type('wpi_item', $invoice_item_args); |
|
139 | 139 | |
140 | 140 | $labels = array( |
141 | - 'name' => _x( 'Discounts', 'post type general name', 'invoicing' ), |
|
142 | - 'singular_name' => _x( 'Discount', 'post type singular name', 'invoicing' ), |
|
143 | - 'menu_name' => _x( 'Discounts', 'admin menu', 'invoicing' ), |
|
144 | - 'name_admin_bar' => _x( 'Discount', 'add new on admin bar', 'invoicing' ), |
|
145 | - 'add_new' => _x( 'Add New', 'book', 'invoicing' ), |
|
146 | - 'add_new_item' => __( 'Add New Discount', 'invoicing' ), |
|
147 | - 'new_item' => __( 'New Discount', 'invoicing' ), |
|
148 | - 'edit_item' => __( 'Edit Discount', 'invoicing' ), |
|
149 | - 'view_item' => __( 'View Discount', 'invoicing' ), |
|
150 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
151 | - 'search_items' => __( 'Search Discounts', 'invoicing' ), |
|
152 | - 'parent_item_colon' => __( 'Parent Discounts:', 'invoicing' ), |
|
153 | - 'not_found' => __( 'No discounts found.', 'invoicing' ), |
|
154 | - 'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' ) |
|
141 | + 'name' => _x('Discounts', 'post type general name', 'invoicing'), |
|
142 | + 'singular_name' => _x('Discount', 'post type singular name', 'invoicing'), |
|
143 | + 'menu_name' => _x('Discounts', 'admin menu', 'invoicing'), |
|
144 | + 'name_admin_bar' => _x('Discount', 'add new on admin bar', 'invoicing'), |
|
145 | + 'add_new' => _x('Add New', 'book', 'invoicing'), |
|
146 | + 'add_new_item' => __('Add New Discount', 'invoicing'), |
|
147 | + 'new_item' => __('New Discount', 'invoicing'), |
|
148 | + 'edit_item' => __('Edit Discount', 'invoicing'), |
|
149 | + 'view_item' => __('View Discount', 'invoicing'), |
|
150 | + 'all_items' => __('Discounts', 'invoicing'), |
|
151 | + 'search_items' => __('Search Discounts', 'invoicing'), |
|
152 | + 'parent_item_colon' => __('Parent Discounts:', 'invoicing'), |
|
153 | + 'not_found' => __('No discounts found.', 'invoicing'), |
|
154 | + 'not_found_in_trash' => __('No discounts found in trash.', 'invoicing') |
|
155 | 155 | ); |
156 | - $labels = apply_filters( 'wpinv_discounts_labels', $labels ); |
|
156 | + $labels = apply_filters('wpinv_discounts_labels', $labels); |
|
157 | 157 | |
158 | 158 | $cap_type = 'wpi_discount'; |
159 | 159 | |
160 | 160 | $args = array( |
161 | 161 | 'labels' => $labels, |
162 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
162 | + 'description' => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'), |
|
163 | 163 | 'public' => false, |
164 | 164 | 'can_export' => true, |
165 | 165 | '_builtin' => false, |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | ), |
191 | 191 | 'has_archive' => false, |
192 | 192 | 'hierarchical' => false, |
193 | - 'supports' => array( 'title', 'excerpt' ), |
|
193 | + 'supports' => array('title', 'excerpt'), |
|
194 | 194 | 'register_meta_box_cb' => 'wpinv_register_discount_meta_boxes', |
195 | 195 | 'show_in_nav_menus' => false, |
196 | 196 | 'show_in_admin_bar' => true, |
@@ -198,106 +198,106 @@ discard block |
||
198 | 198 | 'menu_position' => null, |
199 | 199 | ); |
200 | 200 | |
201 | - $args = apply_filters( 'wpinv_register_post_type_discount', $args ); |
|
201 | + $args = apply_filters('wpinv_register_post_type_discount', $args); |
|
202 | 202 | |
203 | - register_post_type( 'wpi_discount', $args ); |
|
203 | + register_post_type('wpi_discount', $args); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | function wpinv_get_default_labels() { |
207 | 207 | $defaults = array( |
208 | - 'singular' => __( 'Invoice', 'invoicing' ), |
|
209 | - 'plural' => __( 'Invoices', 'invoicing' ) |
|
208 | + 'singular' => __('Invoice', 'invoicing'), |
|
209 | + 'plural' => __('Invoices', 'invoicing') |
|
210 | 210 | ); |
211 | 211 | |
212 | - return apply_filters( 'wpinv_default_invoices_name', $defaults ); |
|
212 | + return apply_filters('wpinv_default_invoices_name', $defaults); |
|
213 | 213 | } |
214 | 214 | |
215 | -function wpinv_get_label_singular( $lowercase = false ) { |
|
215 | +function wpinv_get_label_singular($lowercase = false) { |
|
216 | 216 | $defaults = wpinv_get_default_labels(); |
217 | 217 | |
218 | - return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
218 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
219 | 219 | } |
220 | 220 | |
221 | -function wpinv_get_label_plural( $lowercase = false ) { |
|
221 | +function wpinv_get_label_plural($lowercase = false) { |
|
222 | 222 | $defaults = wpinv_get_default_labels(); |
223 | 223 | |
224 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
224 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
225 | 225 | } |
226 | 226 | |
227 | -function wpinv_change_default_title( $title ) { |
|
228 | - if ( !is_admin() ) { |
|
227 | +function wpinv_change_default_title($title) { |
|
228 | + if (!is_admin()) { |
|
229 | 229 | $label = wpinv_get_label_singular(); |
230 | - $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
|
230 | + $title = sprintf(__('Enter %s name here', 'invoicing'), $label); |
|
231 | 231 | return $title; |
232 | 232 | } |
233 | 233 | |
234 | 234 | $screen = get_current_screen(); |
235 | 235 | |
236 | - if ( 'wpi_invoice' == $screen->post_type ) { |
|
236 | + if ('wpi_invoice' == $screen->post_type) { |
|
237 | 237 | $label = wpinv_get_label_singular(); |
238 | - $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label ); |
|
238 | + $title = sprintf(__('Enter %s name here', 'invoicing'), $label); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | return $title; |
242 | 242 | } |
243 | -add_filter( 'enter_title_here', 'wpinv_change_default_title' ); |
|
243 | +add_filter('enter_title_here', 'wpinv_change_default_title'); |
|
244 | 244 | |
245 | 245 | function wpinv_register_post_status() { |
246 | - register_post_status( 'wpi-pending', array( |
|
247 | - 'label' => _x( 'Pending', 'Invoice status', 'invoicing' ), |
|
246 | + register_post_status('wpi-pending', array( |
|
247 | + 'label' => _x('Pending', 'Invoice status', 'invoicing'), |
|
248 | 248 | 'public' => true, |
249 | 249 | 'exclude_from_search' => true, |
250 | 250 | 'show_in_admin_all_list' => true, |
251 | 251 | 'show_in_admin_status_list' => true, |
252 | - 'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing' ) |
|
253 | - ) ); |
|
254 | - register_post_status( 'wpi-processing', array( |
|
255 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
252 | + 'label_count' => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing') |
|
253 | + )); |
|
254 | + register_post_status('wpi-processing', array( |
|
255 | + 'label' => _x('Processing', 'Invoice status', 'invoicing'), |
|
256 | 256 | 'public' => true, |
257 | 257 | 'exclude_from_search' => true, |
258 | 258 | 'show_in_admin_all_list' => true, |
259 | 259 | 'show_in_admin_status_list' => true, |
260 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
261 | - ) ); |
|
262 | - register_post_status( 'wpi-onhold', array( |
|
263 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
260 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing') |
|
261 | + )); |
|
262 | + register_post_status('wpi-onhold', array( |
|
263 | + 'label' => _x('On Hold', 'Invoice status', 'invoicing'), |
|
264 | 264 | 'public' => true, |
265 | 265 | 'exclude_from_search' => true, |
266 | 266 | 'show_in_admin_all_list' => true, |
267 | 267 | 'show_in_admin_status_list' => true, |
268 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
269 | - ) ); |
|
270 | - register_post_status( 'wpi-cancelled', array( |
|
271 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
268 | + 'label_count' => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing') |
|
269 | + )); |
|
270 | + register_post_status('wpi-cancelled', array( |
|
271 | + 'label' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
272 | 272 | 'public' => true, |
273 | 273 | 'exclude_from_search' => true, |
274 | 274 | 'show_in_admin_all_list' => true, |
275 | 275 | 'show_in_admin_status_list' => true, |
276 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
277 | - ) ); |
|
278 | - register_post_status( 'wpi-refunded', array( |
|
279 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
276 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing') |
|
277 | + )); |
|
278 | + register_post_status('wpi-refunded', array( |
|
279 | + 'label' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
280 | 280 | 'public' => true, |
281 | 281 | 'exclude_from_search' => true, |
282 | 282 | 'show_in_admin_all_list' => true, |
283 | 283 | 'show_in_admin_status_list' => true, |
284 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
285 | - ) ); |
|
286 | - register_post_status( 'wpi-failed', array( |
|
287 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
284 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing') |
|
285 | + )); |
|
286 | + register_post_status('wpi-failed', array( |
|
287 | + 'label' => _x('Failed', 'Invoice status', 'invoicing'), |
|
288 | 288 | 'public' => true, |
289 | 289 | 'exclude_from_search' => true, |
290 | 290 | 'show_in_admin_all_list' => true, |
291 | 291 | 'show_in_admin_status_list' => true, |
292 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
293 | - ) ); |
|
294 | - register_post_status( 'wpi-renewal', array( |
|
295 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
292 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing') |
|
293 | + )); |
|
294 | + register_post_status('wpi-renewal', array( |
|
295 | + 'label' => _x('Renewal', 'Invoice status', 'invoicing'), |
|
296 | 296 | 'public' => true, |
297 | 297 | 'exclude_from_search' => true, |
298 | 298 | 'show_in_admin_all_list' => true, |
299 | 299 | 'show_in_admin_status_list' => true, |
300 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
301 | - ) ); |
|
300 | + 'label_count' => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing') |
|
301 | + )); |
|
302 | 302 | } |
303 | -add_action( 'init', 'wpinv_register_post_status', 10 ); |
|
303 | +add_action('init', 'wpinv_register_post_status', 10); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Setup menus in WP admin. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WC_Admin_Menus Class. |
@@ -13,40 +13,40 @@ discard block |
||
13 | 13 | * Hook in tabs. |
14 | 14 | */ |
15 | 15 | public function __construct() { |
16 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
17 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 99 ); |
|
18 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
19 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
16 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
17 | + add_action('admin_menu', array($this, 'add_addons_menu'), 99); |
|
18 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
19 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function admin_menu() { |
23 | 23 | global $menu, $submenu; |
24 | 24 | |
25 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
25 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
26 | 26 | return; |
27 | 27 | } |
28 | 28 | |
29 | - $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() ); |
|
29 | + $capability = apply_filters('invoicing_capability', wpinv_get_capability()); |
|
30 | 30 | |
31 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
32 | - $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' ); |
|
31 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
32 | + $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv'); |
|
33 | 33 | |
34 | 34 | // Allow users with 'manage_invocing' capability to create new invoices |
35 | - $submenu['post-new.php?post_type=wpi_invoice'][] = array( '', '', 'post-new.php?post_type=wpi_invoice', '' ); |
|
36 | - $submenu['post-new.php?post_type=wpi_item'][] = array( '', '', 'post-new.php?post_type=wpi_item', '' ); |
|
37 | - $submenu['post-new.php?post_type=wpi_discount'][] = array( '', '', 'post-new.php?post_type=wpi_discount', '' ); |
|
35 | + $submenu['post-new.php?post_type=wpi_invoice'][] = array('', '', 'post-new.php?post_type=wpi_invoice', ''); |
|
36 | + $submenu['post-new.php?post_type=wpi_item'][] = array('', '', 'post-new.php?post_type=wpi_item', ''); |
|
37 | + $submenu['post-new.php?post_type=wpi_discount'][] = array('', '', 'post-new.php?post_type=wpi_discount', ''); |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | - $wpi_invoice = get_post_type_object( 'wpi_invoice' ); |
|
41 | + $wpi_invoice = get_post_type_object('wpi_invoice'); |
|
42 | 42 | |
43 | - add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' ); |
|
43 | + add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460'); |
|
44 | 44 | |
45 | - add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', array( $this, 'options_page' )); |
|
45 | + add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', array($this, 'options_page')); |
|
46 | 46 | } |
47 | 47 | |
48 | - public function add_addons_menu(){ |
|
49 | - if ( !apply_filters( 'wpi_show_addons_page', true ) ) { |
|
48 | + public function add_addons_menu() { |
|
49 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | |
@@ -56,78 +56,78 @@ discard block |
||
56 | 56 | __('Extensions', 'invoicing'), |
57 | 57 | 'manage_options', |
58 | 58 | 'wpi-addons', |
59 | - array( $this, 'addons_page' ) |
|
59 | + array($this, 'addons_page') |
|
60 | 60 | ); |
61 | 61 | } |
62 | 62 | |
63 | - public function addons_page(){ |
|
63 | + public function addons_page() { |
|
64 | 64 | $addon_obj = new WPInv_Admin_Addons(); |
65 | 65 | $addon_obj->output(); |
66 | 66 | } |
67 | 67 | |
68 | 68 | function options_page() { |
69 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
69 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
70 | 70 | |
71 | - if ( $page !== 'wpinv-settings' ) { |
|
71 | + if ($page !== 'wpinv-settings') { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $settings_tabs = wpinv_get_settings_tabs(); |
76 | 76 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
77 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
78 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
77 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
78 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
79 | 79 | $key = 'main'; |
80 | 80 | |
81 | - if ( is_array( $sections ) ) { |
|
82 | - $key = key( $sections ); |
|
81 | + if (is_array($sections)) { |
|
82 | + $key = key($sections); |
|
83 | 83 | } |
84 | 84 | |
85 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
86 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
85 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
86 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
87 | 87 | ob_start(); |
88 | 88 | ?> |
89 | 89 | <div class="wrap"> |
90 | 90 | <h1 class="nav-tab-wrapper"> |
91 | 91 | <?php |
92 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
93 | - $tab_url = add_query_arg( array( |
|
92 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
93 | + $tab_url = add_query_arg(array( |
|
94 | 94 | 'settings-updated' => false, |
95 | 95 | 'tab' => $tab_id, |
96 | - ) ); |
|
96 | + )); |
|
97 | 97 | |
98 | 98 | // Remove the section from the tabs so we always end up at the main section |
99 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
100 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
99 | + $tab_url = remove_query_arg('section', $tab_url); |
|
100 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
101 | 101 | |
102 | 102 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
103 | 103 | |
104 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
105 | - echo esc_html( $tab_name ); |
|
104 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
105 | + echo esc_html($tab_name); |
|
106 | 106 | echo '</a>'; |
107 | 107 | } |
108 | 108 | ?> |
109 | 109 | </h1> |
110 | 110 | <?php |
111 | - $number_of_sections = count( $sections ); |
|
111 | + $number_of_sections = count($sections); |
|
112 | 112 | $number = 0; |
113 | - if ( $number_of_sections > 1 ) { |
|
113 | + if ($number_of_sections > 1) { |
|
114 | 114 | echo '<div><ul class="subsubsub">'; |
115 | - foreach( $sections as $section_id => $section_name ) { |
|
115 | + foreach ($sections as $section_id => $section_name) { |
|
116 | 116 | echo '<li>'; |
117 | 117 | $number++; |
118 | - $tab_url = add_query_arg( array( |
|
118 | + $tab_url = add_query_arg(array( |
|
119 | 119 | 'settings-updated' => false, |
120 | 120 | 'tab' => $active_tab, |
121 | 121 | 'section' => $section_id |
122 | - ) ); |
|
123 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
122 | + )); |
|
123 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
124 | 124 | $class = ''; |
125 | - if ( $section == $section_id ) { |
|
125 | + if ($section == $section_id) { |
|
126 | 126 | $class = 'current'; |
127 | 127 | } |
128 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
128 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
129 | 129 | |
130 | - if ( $number != $number_of_sections ) { |
|
130 | + if ($number != $number_of_sections) { |
|
131 | 131 | echo ' | '; |
132 | 132 | } |
133 | 133 | echo '</li>'; |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | <form method="post" action="options.php"> |
140 | 140 | <table class="form-table"> |
141 | 141 | <?php |
142 | - settings_fields( 'wpinv_settings' ); |
|
142 | + settings_fields('wpinv_settings'); |
|
143 | 143 | |
144 | - if ( 'main' === $section ) { |
|
145 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
144 | + if ('main' === $section) { |
|
145 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
146 | 146 | } |
147 | 147 | |
148 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
149 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
150 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
148 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
149 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
150 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
151 | 151 | |
152 | 152 | // For backwards compatibility |
153 | - if ( 'main' === $section ) { |
|
154 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
153 | + if ('main' === $section) { |
|
154 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
155 | 155 | } |
156 | 156 | ?> |
157 | 157 | </table> |
@@ -165,18 +165,18 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | public function remove_admin_submenus() { |
168 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
168 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
169 | 169 | } |
170 | 170 | |
171 | - public function add_nav_menu_meta_boxes(){ |
|
172 | - add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' ); |
|
171 | + public function add_nav_menu_meta_boxes() { |
|
172 | + add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low'); |
|
173 | 173 | } |
174 | 174 | |
175 | - public function nav_menu_links(){ |
|
175 | + public function nav_menu_links() { |
|
176 | 176 | $endpoints = $this->get_menu_items(); |
177 | 177 | ?> |
178 | 178 | <div id="invoicing-endpoints" class="posttypediv"> |
179 | - <?php if(!empty($endpoints['pages'])){ ?> |
|
179 | + <?php if (!empty($endpoints['pages'])) { ?> |
|
180 | 180 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
181 | 181 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
182 | 182 | <?php |
@@ -188,29 +188,29 @@ discard block |
||
188 | 188 | <?php } ?> |
189 | 189 | <p class="button-controls"> |
190 | 190 | <span class="list-controls"> |
191 | - <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a> |
|
191 | + <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a> |
|
192 | 192 | </span> |
193 | 193 | <span class="add-to-menu"> |
194 | - <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
194 | + <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints"> |
|
195 | 195 | <span class="spinner"></span> |
196 | 196 | </span> |
197 | 197 | </p> |
198 | 198 | <?php |
199 | 199 | } |
200 | 200 | |
201 | - public function get_menu_items(){ |
|
201 | + public function get_menu_items() { |
|
202 | 202 | $items = array(); |
203 | 203 | |
204 | - $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' ); |
|
205 | - if($wpinv_history_page_id > 0){ |
|
204 | + $wpinv_history_page_id = (int) wpinv_get_option('invoice_history_page'); |
|
205 | + if ($wpinv_history_page_id > 0) { |
|
206 | 206 | $item = new stdClass(); |
207 | 207 | $item->object_id = $wpinv_history_page_id; |
208 | 208 | $item->db_id = 0; |
209 | - $item->object = 'page'; |
|
209 | + $item->object = 'page'; |
|
210 | 210 | $item->menu_item_parent = 0; |
211 | 211 | $item->type = 'post_type'; |
212 | - $item->title = __('Invoice History Page','invoicing'); |
|
213 | - $item->url = get_permalink( $wpinv_history_page_id ); |
|
212 | + $item->title = __('Invoice History Page', 'invoicing'); |
|
213 | + $item->url = get_permalink($wpinv_history_page_id); |
|
214 | 214 | $item->target = ''; |
215 | 215 | $item->attr_title = ''; |
216 | 216 | $item->classes = array('wpinv-menu-item'); |
@@ -219,16 +219,16 @@ discard block |
||
219 | 219 | $items['pages'][] = $item; |
220 | 220 | } |
221 | 221 | |
222 | - $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' ); |
|
223 | - if($wpinv_sub_history_page_id > 0){ |
|
222 | + $wpinv_sub_history_page_id = (int) wpinv_get_option('invoice_subscription_page'); |
|
223 | + if ($wpinv_sub_history_page_id > 0) { |
|
224 | 224 | $item = new stdClass(); |
225 | 225 | $item->object_id = $wpinv_sub_history_page_id; |
226 | 226 | $item->db_id = 0; |
227 | - $item->object = 'page'; |
|
227 | + $item->object = 'page'; |
|
228 | 228 | $item->menu_item_parent = 0; |
229 | 229 | $item->type = 'post_type'; |
230 | - $item->title = __('Invoice Subscriptions Page','invoicing'); |
|
231 | - $item->url = get_permalink( $wpinv_sub_history_page_id ); |
|
230 | + $item->title = __('Invoice Subscriptions Page', 'invoicing'); |
|
231 | + $item->url = get_permalink($wpinv_sub_history_page_id); |
|
232 | 232 | $item->target = ''; |
233 | 233 | $item->attr_title = ''; |
234 | 234 | $item->classes = array('wpinv-menu-item'); |
@@ -237,16 +237,16 @@ discard block |
||
237 | 237 | $items['pages'][] = $item; |
238 | 238 | } |
239 | 239 | |
240 | - $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' ); |
|
241 | - if($wpinv_checkout_page_id > 0){ |
|
240 | + $wpinv_checkout_page_id = (int) wpinv_get_option('checkout_page'); |
|
241 | + if ($wpinv_checkout_page_id > 0) { |
|
242 | 242 | $item = new stdClass(); |
243 | 243 | $item->object_id = $wpinv_checkout_page_id; |
244 | 244 | $item->db_id = 0; |
245 | - $item->object = 'page'; |
|
245 | + $item->object = 'page'; |
|
246 | 246 | $item->menu_item_parent = 0; |
247 | 247 | $item->type = 'post_type'; |
248 | - $item->title = __('Checkout Page','invoicing'); |
|
249 | - $item->url = get_permalink( $wpinv_checkout_page_id ); |
|
248 | + $item->title = __('Checkout Page', 'invoicing'); |
|
249 | + $item->url = get_permalink($wpinv_checkout_page_id); |
|
250 | 250 | $item->target = ''; |
251 | 251 | $item->attr_title = ''; |
252 | 252 | $item->classes = array('wpinv-menu-item'); |
@@ -255,16 +255,16 @@ discard block |
||
255 | 255 | $items['pages'][] = $item; |
256 | 256 | } |
257 | 257 | |
258 | - $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' ); |
|
259 | - if($wpinv_tandc_page_id > 0){ |
|
258 | + $wpinv_tandc_page_id = (int) wpinv_get_option('tandc_page'); |
|
259 | + if ($wpinv_tandc_page_id > 0) { |
|
260 | 260 | $item = new stdClass(); |
261 | 261 | $item->object_id = $wpinv_tandc_page_id; |
262 | 262 | $item->db_id = 0; |
263 | - $item->object = 'page'; |
|
263 | + $item->object = 'page'; |
|
264 | 264 | $item->menu_item_parent = 0; |
265 | 265 | $item->type = 'post_type'; |
266 | - $item->title = __('Terms & Conditions','invoicing'); |
|
267 | - $item->url = get_permalink( $wpinv_tandc_page_id ); |
|
266 | + $item->title = __('Terms & Conditions', 'invoicing'); |
|
267 | + $item->url = get_permalink($wpinv_tandc_page_id); |
|
268 | 268 | $item->target = ''; |
269 | 269 | $item->attr_title = ''; |
270 | 270 | $item->classes = array('wpinv-menu-item'); |
@@ -273,16 +273,16 @@ discard block |
||
273 | 273 | $items['pages'][] = $item; |
274 | 274 | } |
275 | 275 | |
276 | - $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' ); |
|
277 | - if($wpinv_success_page_id > 0){ |
|
276 | + $wpinv_success_page_id = (int) wpinv_get_option('success_page'); |
|
277 | + if ($wpinv_success_page_id > 0) { |
|
278 | 278 | $item = new stdClass(); |
279 | 279 | $item->object_id = $wpinv_success_page_id; |
280 | 280 | $item->db_id = 0; |
281 | - $item->object = 'page'; |
|
281 | + $item->object = 'page'; |
|
282 | 282 | $item->menu_item_parent = 0; |
283 | 283 | $item->type = 'post_type'; |
284 | - $item->title = __('Success Page','invoicing'); |
|
285 | - $item->url = get_permalink( $wpinv_success_page_id ); |
|
284 | + $item->title = __('Success Page', 'invoicing'); |
|
285 | + $item->url = get_permalink($wpinv_success_page_id); |
|
286 | 286 | $item->target = ''; |
287 | 287 | $item->attr_title = ''; |
288 | 288 | $item->classes = array('wpinv-menu-item'); |
@@ -291,16 +291,16 @@ discard block |
||
291 | 291 | $items['pages'][] = $item; |
292 | 292 | } |
293 | 293 | |
294 | - $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' ); |
|
295 | - if($wpinv_failure_page_id > 0){ |
|
294 | + $wpinv_failure_page_id = (int) wpinv_get_option('failure_page'); |
|
295 | + if ($wpinv_failure_page_id > 0) { |
|
296 | 296 | $item = new stdClass(); |
297 | 297 | $item->object_id = $wpinv_failure_page_id; |
298 | 298 | $item->db_id = 0; |
299 | - $item->object = 'page'; |
|
299 | + $item->object = 'page'; |
|
300 | 300 | $item->menu_item_parent = 0; |
301 | 301 | $item->type = 'post_type'; |
302 | - $item->title = __('Failed Transaction Page','invoicing'); |
|
303 | - $item->url = get_permalink( $wpinv_failure_page_id ); |
|
302 | + $item->title = __('Failed Transaction Page', 'invoicing'); |
|
303 | + $item->url = get_permalink($wpinv_failure_page_id); |
|
304 | 304 | $item->target = ''; |
305 | 305 | $item->attr_title = ''; |
306 | 306 | $item->classes = array('wpinv-menu-item'); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | $items['pages'][] = $item; |
310 | 310 | } |
311 | 311 | |
312 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
312 | + return apply_filters('wpinv_menu_items', $items); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | 5 | function wpinv_subscription_init() { |
6 | 6 | return WPInv_Subscriptions::instance(); |
7 | 7 | } |
8 | -add_action( 'plugins_loaded', 'wpinv_subscription_init', 100 ); |
|
8 | +add_action('plugins_loaded', 'wpinv_subscription_init', 100); |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * WPInv_Subscriptions Class. |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * Main WPInv_Subscriptions Instance |
21 | 21 | */ |
22 | 22 | public static function instance() { |
23 | - if ( ! isset( self::$instance ) ) { |
|
23 | + if (!isset(self::$instance)) { |
|
24 | 24 | self::$instance = new WPInv_Subscriptions; |
25 | 25 | |
26 | 26 | self::$instance->init(); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @since 1.0.0 |
36 | 36 | */ |
37 | - private function __construct(){ |
|
37 | + private function __construct() { |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | private function setup_constants() { |
64 | 64 | |
65 | 65 | // Make sure CAL_GREGORIAN is defined. |
66 | - if ( ! defined( 'CAL_GREGORIAN' ) ) { |
|
67 | - define( 'CAL_GREGORIAN', 1 ); |
|
66 | + if (!defined('CAL_GREGORIAN')) { |
|
67 | + define('CAL_GREGORIAN', 1); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private function actions() { |
78 | 78 | |
79 | - add_action( 'admin_menu', array( $this, 'wpinv_subscriptions_list' ), 10 ); |
|
80 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
81 | - add_action( 'init', array( $this, 'wpinv_post_actions' ) ); |
|
82 | - add_action( 'init', array( $this, 'wpinv_get_actions' ) ); |
|
83 | - add_action( 'wpinv_cancel_subscription', array( $this, 'wpinv_process_cancellation' ) ); |
|
84 | - add_action( 'wpinv_checkout_before_send_to_gateway', array( $this, 'wpinv_checkout_add_subscription' ), -999, 2 ); |
|
85 | - add_action( 'wpinv_subscriptions_front_notices', array( $this, 'notices' ) ); |
|
79 | + add_action('admin_menu', array($this, 'wpinv_subscriptions_list'), 10); |
|
80 | + add_action('admin_notices', array($this, 'notices')); |
|
81 | + add_action('init', array($this, 'wpinv_post_actions')); |
|
82 | + add_action('init', array($this, 'wpinv_get_actions')); |
|
83 | + add_action('wpinv_cancel_subscription', array($this, 'wpinv_process_cancellation')); |
|
84 | + add_action('wpinv_checkout_before_send_to_gateway', array($this, 'wpinv_checkout_add_subscription'), -999, 2); |
|
85 | + add_action('wpinv_subscriptions_front_notices', array($this, 'notices')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | public function wpinv_subscriptions_list() { |
105 | 105 | add_submenu_page( |
106 | 106 | 'wpinv', |
107 | - __( 'Subscriptions', 'invoicing' ), |
|
108 | - __( 'Subscriptions', 'invoicing' ), |
|
107 | + __('Subscriptions', 'invoicing'), |
|
108 | + __('Subscriptions', 'invoicing'), |
|
109 | 109 | wpinv_get_capability(), |
110 | 110 | 'wpinv-subscriptions', |
111 | 111 | 'wpinv_subscriptions_page' |
@@ -114,37 +114,37 @@ discard block |
||
114 | 114 | |
115 | 115 | public function notices() { |
116 | 116 | |
117 | - if( empty( $_GET['wpinv-message'] ) ) { |
|
117 | + if (empty($_GET['wpinv-message'])) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | 121 | $type = 'updated'; |
122 | 122 | $message = ''; |
123 | 123 | |
124 | - switch( strtolower( $_GET['wpinv-message'] ) ) { |
|
124 | + switch (strtolower($_GET['wpinv-message'])) { |
|
125 | 125 | |
126 | 126 | case 'updated' : |
127 | 127 | |
128 | - $message = __( 'Subscription updated successfully.', 'invoicing' ); |
|
128 | + $message = __('Subscription updated successfully.', 'invoicing'); |
|
129 | 129 | |
130 | 130 | break; |
131 | 131 | |
132 | 132 | case 'deleted' : |
133 | 133 | |
134 | - $message = __( 'Subscription deleted successfully.', 'invoicing' ); |
|
134 | + $message = __('Subscription deleted successfully.', 'invoicing'); |
|
135 | 135 | |
136 | 136 | break; |
137 | 137 | |
138 | 138 | case 'cancelled' : |
139 | 139 | |
140 | - $message = __( 'Subscription cancelled successfully.', 'invoicing' ); |
|
140 | + $message = __('Subscription cancelled successfully.', 'invoicing'); |
|
141 | 141 | |
142 | 142 | break; |
143 | 143 | |
144 | 144 | } |
145 | 145 | |
146 | - if ( ! empty( $message ) ) { |
|
147 | - echo '<div class="' . esc_attr( $type ) . '"><p>' . $message . '</p></div>'; |
|
146 | + if (!empty($message)) { |
|
147 | + echo '<div class="' . esc_attr($type) . '"><p>' . $message . '</p></div>'; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @return void |
158 | 158 | */ |
159 | 159 | function wpinv_get_actions() { |
160 | - if ( isset( $_GET['wpinv_action'] ) ) { |
|
161 | - do_action( 'wpinv_' . $_GET['wpinv_action'], $_GET ); |
|
160 | + if (isset($_GET['wpinv_action'])) { |
|
161 | + do_action('wpinv_' . $_GET['wpinv_action'], $_GET); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @return void |
171 | 171 | */ |
172 | 172 | function wpinv_post_actions() { |
173 | - if ( isset( $_POST['wpinv_action'] ) ) { |
|
174 | - do_action( 'wpinv_' . $_POST['wpinv_action'], $_POST ); |
|
173 | + if (isset($_POST['wpinv_action'])) { |
|
174 | + do_action('wpinv_' . $_POST['wpinv_action'], $_POST); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
@@ -182,24 +182,24 @@ discard block |
||
182 | 182 | * @param int $frequency_count The frequency of the period. |
183 | 183 | * @return mixed|string|void |
184 | 184 | */ |
185 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) { |
|
185 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
186 | 186 | $frequency = ''; |
187 | 187 | //Format period details |
188 | - switch ( $period ) { |
|
188 | + switch ($period) { |
|
189 | 189 | case 'day' : |
190 | - $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
190 | + $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count); |
|
191 | 191 | break; |
192 | 192 | case 'week' : |
193 | - $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
193 | + $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count); |
|
194 | 194 | break; |
195 | 195 | case 'month' : |
196 | - $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
196 | + $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count); |
|
197 | 197 | break; |
198 | 198 | case 'year' : |
199 | - $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
199 | + $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count); |
|
200 | 200 | break; |
201 | 201 | default : |
202 | - $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count ); |
|
202 | + $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count); |
|
203 | 203 | break; |
204 | 204 | } |
205 | 205 | |
@@ -214,50 +214,50 @@ discard block |
||
214 | 214 | * @since 1.0.0 |
215 | 215 | * @return void |
216 | 216 | */ |
217 | - public function wpinv_process_cancellation( $data ) { |
|
217 | + public function wpinv_process_cancellation($data) { |
|
218 | 218 | |
219 | 219 | |
220 | - if( empty( $data['sub_id'] ) ) { |
|
220 | + if (empty($data['sub_id'])) { |
|
221 | 221 | return; |
222 | 222 | } |
223 | 223 | |
224 | - if( ! is_user_logged_in() ) { |
|
224 | + if (!is_user_logged_in()) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - if( ! wp_verify_nonce( $data['_wpnonce'], 'wpinv-recurring-cancel' ) ) { |
|
229 | - wp_die( __( 'Error', 'invoicing' ), __( 'Nonce verification failed', 'invoicing' ), array( 'response' => 403 ) ); |
|
228 | + if (!wp_verify_nonce($data['_wpnonce'], 'wpinv-recurring-cancel')) { |
|
229 | + wp_die(__('Error', 'invoicing'), __('Nonce verification failed', 'invoicing'), array('response' => 403)); |
|
230 | 230 | } |
231 | 231 | |
232 | - $data['sub_id'] = absint( $data['sub_id'] ); |
|
233 | - $subscription = new WPInv_Subscription( $data['sub_id'] ); |
|
232 | + $data['sub_id'] = absint($data['sub_id']); |
|
233 | + $subscription = new WPInv_Subscription($data['sub_id']); |
|
234 | 234 | |
235 | - if( ! $subscription->can_cancel() ) { |
|
236 | - wp_die( __( 'Error', 'invoicing' ), __( 'This subscription cannot be cancelled', 'invoicing' ), array( 'response' => 403 ) ); |
|
235 | + if (!$subscription->can_cancel()) { |
|
236 | + wp_die(__('Error', 'invoicing'), __('This subscription cannot be cancelled', 'invoicing'), array('response' => 403)); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | try { |
240 | 240 | |
241 | - do_action( 'wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true ); |
|
241 | + do_action('wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true); |
|
242 | 242 | |
243 | 243 | $subscription->cancel(); |
244 | 244 | |
245 | - if( is_admin() ) { |
|
245 | + if (is_admin()) { |
|
246 | 246 | |
247 | - wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id ) ); |
|
247 | + wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id)); |
|
248 | 248 | exit; |
249 | 249 | |
250 | 250 | } else { |
251 | 251 | |
252 | - $redirect = remove_query_arg( array( '_wpnonce', 'wpinv_action', 'sub_id' ), add_query_arg( array( 'wpinv-message' => 'cancelled' ) ) ); |
|
253 | - $redirect = apply_filters( 'wpinv_recurring_cancellation_redirect', $redirect, $subscription ); |
|
254 | - wp_safe_redirect( $redirect ); |
|
252 | + $redirect = remove_query_arg(array('_wpnonce', 'wpinv_action', 'sub_id'), add_query_arg(array('wpinv-message' => 'cancelled'))); |
|
253 | + $redirect = apply_filters('wpinv_recurring_cancellation_redirect', $redirect, $subscription); |
|
254 | + wp_safe_redirect($redirect); |
|
255 | 255 | exit; |
256 | 256 | |
257 | 257 | } |
258 | 258 | |
259 | - } catch ( Exception $e ) { |
|
260 | - wp_die( __( 'Error', 'invoicing' ), $e->getMessage(), array( 'response' => 403 ) ); |
|
259 | + } catch (Exception $e) { |
|
260 | + wp_die(__('Error', 'invoicing'), $e->getMessage(), array('response' => 403)); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | } |
@@ -269,35 +269,35 @@ discard block |
||
269 | 269 | * @since 1.0.0 |
270 | 270 | * @return void |
271 | 271 | */ |
272 | - public function wpinv_checkout_add_subscription( $invoice, $invoice_data ) { |
|
273 | - if ( ! ( ! empty( $invoice->ID ) && $invoice->is_recurring() ) ) { |
|
272 | + public function wpinv_checkout_add_subscription($invoice, $invoice_data) { |
|
273 | + if (!(!empty($invoice->ID) && $invoice->is_recurring())) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | - $item = $invoice->get_recurring( true ); |
|
278 | - if ( empty( $item ) ) { |
|
277 | + $item = $invoice->get_recurring(true); |
|
278 | + if (empty($item)) { |
|
279 | 279 | return; |
280 | 280 | } |
281 | 281 | |
282 | - $invoice_date = $invoice->get_invoice_date( false ); |
|
282 | + $invoice_date = $invoice->get_invoice_date(false); |
|
283 | 283 | $status = 'pending'; |
284 | 284 | |
285 | - $period = $item->get_recurring_period( true ); |
|
285 | + $period = $item->get_recurring_period(true); |
|
286 | 286 | $interval = $item->get_recurring_interval(); |
287 | - $bill_times = (int)$item->get_recurring_limit(); |
|
287 | + $bill_times = (int) $item->get_recurring_limit(); |
|
288 | 288 | $add_period = $interval . ' ' . $period; |
289 | 289 | $trial_period = ''; |
290 | 290 | |
291 | - if ( $invoice->is_free_trial() ) { |
|
291 | + if ($invoice->is_free_trial()) { |
|
292 | 292 | $status = 'trialling'; |
293 | - $trial_period = $item->get_trial_period( true ); |
|
293 | + $trial_period = $item->get_trial_period(true); |
|
294 | 294 | $free_interval = $item->get_trial_interval(); |
295 | 295 | $trial_period = $free_interval . ' ' . $trial_period; |
296 | 296 | |
297 | 297 | $add_period = $trial_period; |
298 | 298 | } |
299 | 299 | |
300 | - $expiration = date_i18n( 'Y-m-d H:i:s', strtotime( '+' . $add_period . ' 23:59:59', strtotime( $invoice_date ) ) ); |
|
300 | + $expiration = date_i18n('Y-m-d H:i:s', strtotime('+' . $add_period . ' 23:59:59', strtotime($invoice_date))); |
|
301 | 301 | |
302 | 302 | $args = array( |
303 | 303 | 'product_id' => $item->ID, |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | 'frequency' => $interval, |
308 | 308 | 'period' => $period, |
309 | 309 | 'initial_amount' => $invoice->get_total(), |
310 | - 'recurring_amount' => $invoice->get_recurring_details( 'total' ), |
|
310 | + 'recurring_amount' => $invoice->get_recurring_details('total'), |
|
311 | 311 | 'bill_times' => $bill_times, |
312 | 312 | 'created' => $invoice_date, |
313 | 313 | 'expiration' => $expiration, |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | 'transaction_id' => '', |
317 | 317 | ); |
318 | 318 | |
319 | - $subscription = wpinv_get_subscription( $invoice ); |
|
319 | + $subscription = wpinv_get_subscription($invoice); |
|
320 | 320 | |
321 | - if ( empty( $subscription ) ) { |
|
321 | + if (empty($subscription)) { |
|
322 | 322 | $subscription = new WPInv_Subscription(); |
323 | - $subscription->create( $args ); |
|
323 | + $subscription->create($args); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return $subscription; |