Passed
Push — master ( 607b2f...f897ad )
by Brian
04:05
created
includes/class-wpinv-privacy-exporters.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Personal data exporters.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WPInv_Privacy_Exporters Class.
@@ -17,38 +17,38 @@  discard block
 block discarded – undo
17 17
      * @param int    $page  Page.
18 18
      * @return array An array of invoice data in name value pairs
19 19
      */
20
-    public static function customer_invoice_data_exporter( $email_address, $page ) {
20
+    public static function customer_invoice_data_exporter($email_address, $page) {
21 21
         $done           = false;
22 22
         $page           = (int) $page;
23 23
         $data_to_export = array();
24 24
 
25
-        $user           = get_user_by( 'email', $email_address );
26
-        if ( ! $user instanceof WP_User ) {
25
+        $user           = get_user_by('email', $email_address);
26
+        if (!$user instanceof WP_User) {
27 27
             return array(
28 28
                 'data' => $data_to_export,
29 29
                 'done' => true,
30 30
             );
31 31
         }
32 32
 
33
-        $args    = array(
33
+        $args = array(
34 34
             'limit'    => 30,
35 35
             'page'     => $page,
36 36
             'user'     => $user->ID,
37 37
         );
38 38
 
39
-        $invoices = wpinv_get_invoices( $args );
39
+        $invoices = wpinv_get_invoices($args);
40 40
 
41
-        if ( 0 < count( $invoices ) ) {
42
-            foreach ( $invoices as $invoice ) {
41
+        if (0 < count($invoices)) {
42
+            foreach ($invoices as $invoice) {
43 43
                 $data_to_export[] = array(
44 44
                     'group_id'          => 'customer_invoices',
45
-                    'group_label'       => __( 'Invoicing Data', 'invoicing' ),
46
-                    'group_description' => __( 'Customer invoicing data.', 'invoicing' ),
45
+                    'group_label'       => __('Invoicing Data', 'invoicing'),
46
+                    'group_description' => __('Customer invoicing data.', 'invoicing'),
47 47
                     'item_id'           => "wpinv-{$invoice->ID}",
48
-                    'data'              => self::get_customer_invoice_data( $invoice ),
48
+                    'data'              => self::get_customer_invoice_data($invoice),
49 49
                 );
50 50
             }
51
-            $done = 30 > count( $invoices );
51
+            $done = 30 > count($invoices);
52 52
         } else {
53 53
             $done = true;
54 54
         }
@@ -66,59 +66,59 @@  discard block
 block discarded – undo
66 66
      * @param WPInv_Invoice $invoice invoice object.
67 67
      * @return array
68 68
      */
69
-    public static function get_customer_invoice_data( $invoice ) {
69
+    public static function get_customer_invoice_data($invoice) {
70 70
         $personal_data = array();
71 71
 
72 72
         $props_to_export = array(
73
-            'number'               => __( 'Invoice Number', 'invoicing' ),
74
-            'created_date'         => __( 'Invoice Date', 'invoicing' ),
75
-            'status'               => __( 'Invoice Status', 'invoicing' ),
76
-            'total'                => __( 'Invoice Total', 'invoicing' ),
77
-            'items'                => __( 'Invoice Items', 'invoicing' ),
78
-            'first_name'           => __( 'First Name', 'invoicing' ),
79
-            'last_name'            => __( 'Last Name', 'invoicing' ),
80
-            'email'                => __( 'Email Address', 'invoicing' ),
81
-            '_wpinv_company'       => __( 'Company', 'invoicing' ),
82
-            'phone'                => __( 'Phone Number', 'invoicing' ),
83
-            'address'              => __( 'Address', 'invoicing' ),
84
-            '_wpinv_city'          => __( 'City', 'invoicing' ),
85
-            '_wpinv_country'       => __( 'Country', 'invoicing' ),
86
-            '_wpinv_state'         => __( 'State', 'invoicing' ),
87
-            '_wpinv_zip'           => __( 'Zip Code', 'invoicing' ),
73
+            'number'               => __('Invoice Number', 'invoicing'),
74
+            'created_date'         => __('Invoice Date', 'invoicing'),
75
+            'status'               => __('Invoice Status', 'invoicing'),
76
+            'total'                => __('Invoice Total', 'invoicing'),
77
+            'items'                => __('Invoice Items', 'invoicing'),
78
+            'first_name'           => __('First Name', 'invoicing'),
79
+            'last_name'            => __('Last Name', 'invoicing'),
80
+            'email'                => __('Email Address', 'invoicing'),
81
+            '_wpinv_company'       => __('Company', 'invoicing'),
82
+            'phone'                => __('Phone Number', 'invoicing'),
83
+            'address'              => __('Address', 'invoicing'),
84
+            '_wpinv_city'          => __('City', 'invoicing'),
85
+            '_wpinv_country'       => __('Country', 'invoicing'),
86
+            '_wpinv_state'         => __('State', 'invoicing'),
87
+            '_wpinv_zip'           => __('Zip Code', 'invoicing'),
88 88
         );
89 89
 
90
-        $subscription = wpinv_get_subscription( $invoice );
90
+        $subscription = wpinv_get_subscription($invoice);
91 91
         $period = $initial_amt = $bill_times = $billed = $renewal_date = '';
92 92
 
93
-        if ( $invoice->is_recurring() && !empty( $subscription ) ) {
94
-            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period,$subscription->frequency );
95
-            $period = wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency;
96
-            $initial_amt = wpinv_price( wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) );
97
-            $bill_times = $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? 'Until Cancelled' : $subscription->bill_times );
98
-            $renewal_date = ! empty( $subscription->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration ) ) : __( 'N/A', 'invoicing' );
99
-
100
-            $props_to_export['period'] = __( 'Billing Cycle', 'invoicing' );
101
-            $props_to_export['initial_amount'] = __( 'Initial Amount', 'invoicing' );
102
-            $props_to_export['bill_times'] = __( 'Times Billed', 'invoicing' );
103
-            $props_to_export['renewal_date'] = __( 'Renewal Date', 'invoicing' );
93
+        if ($invoice->is_recurring() && !empty($subscription)) {
94
+            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
95
+            $period = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency;
96
+            $initial_amt = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id));
97
+            $bill_times = $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? 'Until Cancelled' : $subscription->bill_times);
98
+            $renewal_date = !empty($subscription->expiration) ? date_i18n(get_option('date_format'), strtotime($subscription->expiration)) : __('N/A', 'invoicing');
99
+
100
+            $props_to_export['period'] = __('Billing Cycle', 'invoicing');
101
+            $props_to_export['initial_amount'] = __('Initial Amount', 'invoicing');
102
+            $props_to_export['bill_times'] = __('Times Billed', 'invoicing');
103
+            $props_to_export['renewal_date'] = __('Renewal Date', 'invoicing');
104 104
         }
105 105
 
106
-        $props_to_export['ip'] = __( 'IP Address', 'invoicing' );
107
-        $props_to_export['view_url'] = __( 'Invoice Link', 'invoicing' );
106
+        $props_to_export['ip'] = __('IP Address', 'invoicing');
107
+        $props_to_export['view_url'] = __('Invoice Link', 'invoicing');
108 108
 
109
-        $props_to_export = apply_filters( 'wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription);
109
+        $props_to_export = apply_filters('wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription);
110 110
 
111
-        foreach ( $props_to_export as $prop => $name ) {
111
+        foreach ($props_to_export as $prop => $name) {
112 112
             $value = '';
113 113
 
114
-            switch ( $prop ) {
114
+            switch ($prop) {
115 115
                 case 'items':
116 116
                     $item_names = array();
117
-                    foreach ( $invoice->get_cart_details() as $key => $cart_item ) {
118
-                        $item_quantity  = $cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
117
+                    foreach ($invoice->get_cart_details() as $key => $cart_item) {
118
+                        $item_quantity = $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
119 119
                         $item_names[] = $cart_item['name'] . ' x ' . $item_quantity;
120 120
                     }
121
-                    $value = implode( ', ', $item_names );
121
+                    $value = implode(', ', $item_names);
122 122
                     break;
123 123
                 case 'status':
124 124
                     $value = $invoice->get_status(true);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                     $value = $renewal_date;
140 140
                     break;
141 141
                 default:
142
-                    if ( is_callable( array( $invoice, 'get_' . $prop ) ) ) {
142
+                    if (is_callable(array($invoice, 'get_' . $prop))) {
143 143
                         $value = $invoice->{"get_$prop"}();
144 144
                     } else {
145 145
                         $value = $invoice->get_meta($prop);
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
                     break;
148 148
             }
149 149
 
150
-            $value = apply_filters( 'wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice );
150
+            $value = apply_filters('wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice);
151 151
 
152
-            if ( $value ) {
152
+            if ($value) {
153 153
                 $personal_data[] = array(
154 154
                     'name'  => $name,
155 155
                     'value' => $value,
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
         }
160 160
 
161
-        $personal_data = apply_filters( 'wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice );
161
+        $personal_data = apply_filters('wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice);
162 162
 
163 163
         return $personal_data;
164 164
 
Please login to merge, or discard this patch.
widgets/buy-item.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -38,29 +38,29 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 
@@ -23,40 +23,40 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.