Passed
Pull Request — master (#191)
by
unknown
03:10
created
vendor/ayecode/wp-super-duper/hello-world.php 2 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -3,22 +3,22 @@  discard block
 block discarded – undo
3 3
 class SD_Hello_World extends WP_Super_Duper {
4 4
 
5 5
 
6
-	public $arguments;
7
-
8
-	/**
9
-	 * Sets up the widgets name etc
10
-	 */
11
-	public function __construct() {
12
-
13
-		$options = array(
14
-			'textdomain'     => 'super-duper',
15
-			// textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
-			'block-icon'     => 'admin-site',
17
-			// Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
-			'block-category' => 'widgets',
19
-			// the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
20
-			'block-keywords' => "['hello','world']",
21
-			// used in the block search, MAX 3
6
+    public $arguments;
7
+
8
+    /**
9
+     * Sets up the widgets name etc
10
+     */
11
+    public function __construct() {
12
+
13
+        $options = array(
14
+            'textdomain'     => 'super-duper',
15
+            // textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
+            'block-icon'     => 'admin-site',
17
+            // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
+            'block-category' => 'widgets',
19
+            // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
20
+            'block-keywords' => "['hello','world']",
21
+            // used in the block search, MAX 3
22 22
 //			'block-output'   => array( // the block visual output elements as an array
23 23
 //				'element::p' => array(
24 24
 //					'title'   => __( 'Placeholder', 'hello-world' ),
@@ -26,83 +26,83 @@  discard block
 block discarded – undo
26 26
 //					'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
27 27
 //				)
28 28
 //			),
29
-			'block-output'   => array( // the block visual output elements as an array
30
-				array(
31
-					'element' => 'p',
32
-					'title'   => __( 'Placeholder', 'hello-world' ),
33
-					'class'   => '[%className%]',
34
-					'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
35
-				)
36
-			),
37
-			'class_name'     => __CLASS__,
38
-			// The calling class name
39
-			'base_id'        => 'hello_world',
40
-			// this is used as the widget id and the shortcode id.
41
-			'name'           => __( 'Hello World', 'hello-world' ),
42
-			// the name of the widget/block
43
-			'widget_ops'     => array(
44
-				'classname'   => 'hello-world-class',
45
-				// widget class
46
-				'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ),
47
-				// widget description
48
-			),
49
-			'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
50
-				'after_text' => array( // this is the input name=''
51
-					'title'       => __( 'Text after hello:', 'hello-world' ),
52
-					// input title
53
-					'desc'        => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ),
54
-					// input description
55
-					'type'        => 'text',
56
-					// the type of input, test, select, checkbox etc.
57
-					'placeholder' => 'World',
58
-					// the input placeholder text.
59
-					'desc_tip'    => true,
60
-					// if the input should show the widget description text as a tooltip.
61
-					'default'     => 'World',
62
-					// the input default value.
63
-					'advanced'    => false
64
-					// not yet implemented
65
-				),
66
-			)
67
-		);
68
-
69
-		parent::__construct( $options );
70
-	}
71
-
72
-
73
-	/**
74
-	 * This is the output function for the widget, shortcode and block (front end).
75
-	 *
76
-	 * @param array $args The arguments values.
77
-	 * @param array $widget_args The widget arguments when used.
78
-	 * @param string $content The shortcode content argument
79
-	 *
80
-	 * @return string
81
-	 */
82
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
83
-
84
-		/**
85
-		 * @var string $after_text
86
-		 * @var string $another_input This is added by filter below.
87
-		 */
88
-		extract( $args, EXTR_SKIP );
89
-
90
-		/*
29
+            'block-output'   => array( // the block visual output elements as an array
30
+                array(
31
+                    'element' => 'p',
32
+                    'title'   => __( 'Placeholder', 'hello-world' ),
33
+                    'class'   => '[%className%]',
34
+                    'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
35
+                )
36
+            ),
37
+            'class_name'     => __CLASS__,
38
+            // The calling class name
39
+            'base_id'        => 'hello_world',
40
+            // this is used as the widget id and the shortcode id.
41
+            'name'           => __( 'Hello World', 'hello-world' ),
42
+            // the name of the widget/block
43
+            'widget_ops'     => array(
44
+                'classname'   => 'hello-world-class',
45
+                // widget class
46
+                'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ),
47
+                // widget description
48
+            ),
49
+            'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
50
+                'after_text' => array( // this is the input name=''
51
+                    'title'       => __( 'Text after hello:', 'hello-world' ),
52
+                    // input title
53
+                    'desc'        => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ),
54
+                    // input description
55
+                    'type'        => 'text',
56
+                    // the type of input, test, select, checkbox etc.
57
+                    'placeholder' => 'World',
58
+                    // the input placeholder text.
59
+                    'desc_tip'    => true,
60
+                    // if the input should show the widget description text as a tooltip.
61
+                    'default'     => 'World',
62
+                    // the input default value.
63
+                    'advanced'    => false
64
+                    // not yet implemented
65
+                ),
66
+            )
67
+        );
68
+
69
+        parent::__construct( $options );
70
+    }
71
+
72
+
73
+    /**
74
+     * This is the output function for the widget, shortcode and block (front end).
75
+     *
76
+     * @param array $args The arguments values.
77
+     * @param array $widget_args The widget arguments when used.
78
+     * @param string $content The shortcode content argument
79
+     *
80
+     * @return string
81
+     */
82
+    public function output( $args = array(), $widget_args = array(), $content = '' ) {
83
+
84
+        /**
85
+         * @var string $after_text
86
+         * @var string $another_input This is added by filter below.
87
+         */
88
+        extract( $args, EXTR_SKIP );
89
+
90
+        /*
91 91
 		 * This value is added by filter so might not exist if filter is removed so we check.
92 92
 		 */
93
-		if ( ! $another_input ) {
94
-			$another_input = '';
95
-		}
93
+        if ( ! $another_input ) {
94
+            $another_input = '';
95
+        }
96 96
 
97
-		return "Hello: " . $after_text . "" . $another_input;
97
+        return "Hello: " . $after_text . "" . $another_input;
98 98
 
99
-	}
99
+    }
100 100
 
101 101
 }
102 102
 
103 103
 // register it.
104 104
 add_action( 'widgets_init', function () {
105
-	register_widget( 'SD_Hello_World' );
105
+    register_widget( 'SD_Hello_World' );
106 106
 } );
107 107
 
108 108
 
@@ -115,26 +115,26 @@  discard block
 block discarded – undo
115 115
  */
116 116
 function _my_extra_arguments( $options ) {
117 117
 
118
-	/*
118
+    /*
119 119
 	 * Add a new input option.
120 120
 	 */
121
-	$options['arguments']['another_input'] = array(
122
-		'name'        => 'another_input', // this is the input name=''
123
-		'title'       => __( 'Another input:', 'hello-world' ), // input title
124
-		'desc'        => __( 'This is an input added via filter.', 'hello-world' ), // input description
125
-		'type'        => 'text', // the type of input, test, select, checkbox etc.
126
-		'placeholder' => 'Placeholder text', // the input placeholder text.
127
-		'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
128
-		'default'     => '', // the input default value.
129
-		'advanced'    => false // not yet implemented
130
-	);
131
-
132
-	/*
121
+    $options['arguments']['another_input'] = array(
122
+        'name'        => 'another_input', // this is the input name=''
123
+        'title'       => __( 'Another input:', 'hello-world' ), // input title
124
+        'desc'        => __( 'This is an input added via filter.', 'hello-world' ), // input description
125
+        'type'        => 'text', // the type of input, test, select, checkbox etc.
126
+        'placeholder' => 'Placeholder text', // the input placeholder text.
127
+        'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
128
+        'default'     => '', // the input default value.
129
+        'advanced'    => false // not yet implemented
130
+    );
131
+
132
+    /*
133 133
 	 * Output the new option in the block output also.
134 134
 	 */
135
-	$options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
135
+    $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
136 136
 
137
-	return $options;
137
+    return $options;
138 138
 }
139 139
 
140 140
 //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' );
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 			'block-output'   => array( // the block visual output elements as an array
30 30
 				array(
31 31
 					'element' => 'p',
32
-					'title'   => __( 'Placeholder', 'hello-world' ),
32
+					'title'   => __('Placeholder', 'hello-world'),
33 33
 					'class'   => '[%className%]',
34 34
 					'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
35 35
 				)
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 			// The calling class name
39 39
 			'base_id'        => 'hello_world',
40 40
 			// this is used as the widget id and the shortcode id.
41
-			'name'           => __( 'Hello World', 'hello-world' ),
41
+			'name'           => __('Hello World', 'hello-world'),
42 42
 			// the name of the widget/block
43 43
 			'widget_ops'     => array(
44 44
 				'classname'   => 'hello-world-class',
45 45
 				// widget class
46
-				'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ),
46
+				'description' => esc_html__('This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world'),
47 47
 				// widget description
48 48
 			),
49 49
 			'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
50 50
 				'after_text' => array( // this is the input name=''
51
-					'title'       => __( 'Text after hello:', 'hello-world' ),
51
+					'title'       => __('Text after hello:', 'hello-world'),
52 52
 					// input title
53
-					'desc'        => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ),
53
+					'desc'        => __('This is the text that will appear after `Hello:`.', 'hello-world'),
54 54
 					// input description
55 55
 					'type'        => 'text',
56 56
 					// the type of input, test, select, checkbox etc.
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 			)
67 67
 		);
68 68
 
69
-		parent::__construct( $options );
69
+		parent::__construct($options);
70 70
 	}
71 71
 
72 72
 
@@ -79,18 +79,18 @@  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
 		/**
85 85
 		 * @var string $after_text
86 86
 		 * @var string $another_input This is added by filter below.
87 87
 		 */
88
-		extract( $args, EXTR_SKIP );
88
+		extract($args, EXTR_SKIP);
89 89
 
90 90
 		/*
91 91
 		 * This value is added by filter so might not exist if filter is removed so we check.
92 92
 		 */
93
-		if ( ! $another_input ) {
93
+		if (!$another_input) {
94 94
 			$another_input = '';
95 95
 		}
96 96
 
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 }
102 102
 
103 103
 // register it.
104
-add_action( 'widgets_init', function () {
105
-	register_widget( 'SD_Hello_World' );
104
+add_action('widgets_init', function() {
105
+	register_widget('SD_Hello_World');
106 106
 } );
107 107
 
108 108
 
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
  *
114 114
  * @return mixed
115 115
  */
116
-function _my_extra_arguments( $options ) {
116
+function _my_extra_arguments($options) {
117 117
 
118 118
 	/*
119 119
 	 * Add a new input option.
120 120
 	 */
121 121
 	$options['arguments']['another_input'] = array(
122 122
 		'name'        => 'another_input', // this is the input name=''
123
-		'title'       => __( 'Another input:', 'hello-world' ), // input title
124
-		'desc'        => __( 'This is an input added via filter.', 'hello-world' ), // input description
123
+		'title'       => __('Another input:', 'hello-world'), // input title
124
+		'desc'        => __('This is an input added via filter.', 'hello-world'), // input description
125 125
 		'type'        => 'text', // the type of input, test, select, checkbox etc.
126 126
 		'placeholder' => 'Placeholder text', // the input placeholder text.
127 127
 		'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	/*
133 133
 	 * Output the new option in the block output also.
134 134
 	 */
135
-	$options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
135
+	$options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]"; ;
136 136
 
137 137
 	return $options;
138 138
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/sd-plugin.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@
 block discarded – undo
15 15
  */
16 16
 
17 17
 if ( ! defined( 'ABSPATH' ) ) {
18
-	exit;
18
+    exit;
19 19
 }
20 20
 
21 21
 if ( ! class_exists( 'WP_Super_Duper' ) ) {
22
-	// include the class if needed
23
-	include_once( dirname( __FILE__ ) . "/wp-super-duper.php" );
22
+    // include the class if needed
23
+    include_once( dirname( __FILE__ ) . "/wp-super-duper.php" );
24 24
 }
25 25
 
26 26
 /*
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@
 block discarded – undo
14 14
  * Tested up to: 5.0.0
15 15
  */
16 16
 
17
-if ( ! defined( 'ABSPATH' ) ) {
17
+if (!defined('ABSPATH')) {
18 18
 	exit;
19 19
 }
20 20
 
21
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
21
+if (!class_exists('WP_Super_Duper')) {
22 22
 	// include the class if needed
23
-	include_once( dirname( __FILE__ ) . "/wp-super-duper.php" );
23
+	include_once(dirname(__FILE__) . "/wp-super-duper.php");
24 24
 }
25 25
 
26 26
 /*
27 27
  * Hello world example.
28 28
  */
29
-include_once( dirname( __FILE__ ) . "/hello-world.php" );
29
+include_once(dirname(__FILE__) . "/hello-world.php");
30 30
 
31 31
 /*
32 32
  * Map example.
33 33
  */
34
-include_once( dirname( __FILE__ ) . "/map.php" );
34
+include_once(dirname(__FILE__) . "/map.php");
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/map.php 3 patches
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -3,241 +3,241 @@
 block discarded – undo
3 3
 class SD_Map extends WP_Super_Duper {
4 4
 
5 5
 
6
-	public $arguments;
7
-
8
-	/**
9
-	 * Sets up the widgets name etc
10
-	 */
11
-	public function __construct() {
12
-
13
-		$options = array(
14
-			'textdomain'     => 'super-duper',
15
-			// textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
-			'block-icon'     => 'admin-site',
17
-			// Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
-			'block-category' => 'widgets',
19
-			// the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
20
-			'block-keywords' => "['map','super','google']",
21
-			// used in the block search, MAX 3
22
-			'block-output'   => array( // the block visual output elements as an array
23
-				array(
24
-					'element' => 'p',
25
-					'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ','super-duper'),
26
-					//'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"',
27
-					'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
28
-				),
29
-				array(
30
-					'element' => 'a',
31
-					'content' => __('API KEY for Google Maps','super-duper'),
32
-					'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
33
-					'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/',
34
-				),
35
-				array(
36
-					'element' => 'img',
37
-					'class'   => '[%className%]',
38
-					//'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
39
-					'element_require' => '[%type%]=="image"',
40
-					'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]"
41
-				),
42
-				array(
43
-					'element' => 'div',
44
-					'class'   => 'sd-map-iframe-cover',
45
-					'style'   => '{overflow:"hidden", position:"relative"}',
46
-					array(
47
-						'element' => 'iframe',
48
-						'title'   => __( 'Placeholderx', 'super-duper' ),
49
-						'class'   => '[%className%]',
50
-						'width'   => '[%width%]',
51
-						'height'  => '[%height%]',
52
-						'frameborder' => '0',
53
-						'allowfullscreen' => 'true',
54
-						'style' => '{border:0}',
55
-						'element_require' => '[%type%]!="image"',
56
-						'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]"
57
-					),
58
-				),
59
-				array(
60
-					'element' => 'style',
61
-					'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__("Click here, Settings are in the block settings sidebar","super-duper").'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center;  color: #fff; font-size: 20px; font-weight: bold;}',
62
-					'element_require' => '[%type%]!="image"',
63
-				),
64
-			),
65
-			'class_name'     => __CLASS__,
66
-			// The calling class name
67
-			'base_id'        => 'sd_map',
68
-			// this is used as the widget id and the shortcode id.
69
-			'name'           => __( 'Map', 'super-duper' ),
70
-			// the name of the widget/block
71
-			'widget_ops'     => array(
72
-				'classname'   => 'sd-map-class',
73
-				// widget class
74
-				'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ),
75
-				// widget description
76
-			),
77
-			'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
78
-				'type'  => array(
79
-					'title' => __('Map Type:', 'geodirectory'),
80
-					'desc' => __('Select the map type to use.', 'geodirectory'),
81
-					'type' => 'select',
82
-					'options'   =>  array(
83
-						"image" => __('Static Image', 'geodirectory'),
84
-						"place" => __('Place', 'geodirectory'),
6
+    public $arguments;
7
+
8
+    /**
9
+     * Sets up the widgets name etc
10
+     */
11
+    public function __construct() {
12
+
13
+        $options = array(
14
+            'textdomain'     => 'super-duper',
15
+            // textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
+            'block-icon'     => 'admin-site',
17
+            // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
+            'block-category' => 'widgets',
19
+            // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
20
+            'block-keywords' => "['map','super','google']",
21
+            // used in the block search, MAX 3
22
+            'block-output'   => array( // the block visual output elements as an array
23
+                array(
24
+                    'element' => 'p',
25
+                    'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ','super-duper'),
26
+                    //'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"',
27
+                    'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
28
+                ),
29
+                array(
30
+                    'element' => 'a',
31
+                    'content' => __('API KEY for Google Maps','super-duper'),
32
+                    'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
33
+                    'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/',
34
+                ),
35
+                array(
36
+                    'element' => 'img',
37
+                    'class'   => '[%className%]',
38
+                    //'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
39
+                    'element_require' => '[%type%]=="image"',
40
+                    'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]"
41
+                ),
42
+                array(
43
+                    'element' => 'div',
44
+                    'class'   => 'sd-map-iframe-cover',
45
+                    'style'   => '{overflow:"hidden", position:"relative"}',
46
+                    array(
47
+                        'element' => 'iframe',
48
+                        'title'   => __( 'Placeholderx', 'super-duper' ),
49
+                        'class'   => '[%className%]',
50
+                        'width'   => '[%width%]',
51
+                        'height'  => '[%height%]',
52
+                        'frameborder' => '0',
53
+                        'allowfullscreen' => 'true',
54
+                        'style' => '{border:0}',
55
+                        'element_require' => '[%type%]!="image"',
56
+                        'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]"
57
+                    ),
58
+                ),
59
+                array(
60
+                    'element' => 'style',
61
+                    'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__("Click here, Settings are in the block settings sidebar","super-duper").'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center;  color: #fff; font-size: 20px; font-weight: bold;}',
62
+                    'element_require' => '[%type%]!="image"',
63
+                ),
64
+            ),
65
+            'class_name'     => __CLASS__,
66
+            // The calling class name
67
+            'base_id'        => 'sd_map',
68
+            // this is used as the widget id and the shortcode id.
69
+            'name'           => __( 'Map', 'super-duper' ),
70
+            // the name of the widget/block
71
+            'widget_ops'     => array(
72
+                'classname'   => 'sd-map-class',
73
+                // widget class
74
+                'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ),
75
+                // widget description
76
+            ),
77
+            'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
78
+                'type'  => array(
79
+                    'title' => __('Map Type:', 'geodirectory'),
80
+                    'desc' => __('Select the map type to use.', 'geodirectory'),
81
+                    'type' => 'select',
82
+                    'options'   =>  array(
83
+                        "image" => __('Static Image', 'geodirectory'),
84
+                        "place" => __('Place', 'geodirectory'),
85 85
 //						"directions" => __('Directions', 'geodirectory'),
86 86
 //						"search" => __('Search', 'geodirectory'),
87 87
 //						"view" => __('View', 'geodirectory'),
88 88
 //						"streetview" => __('Streetview', 'geodirectory'),
89
-					),
90
-					'default'  => 'image',
91
-					'desc_tip' => true,
92
-					'advanced' => false
93
-				),
94
-				'location'            => array(
95
-					'type'        => 'text',
96
-					'title'       => __( 'Location:', 'geodirectory' ),
97
-					'desc'        => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory' ),
98
-					'placeholder' => 'Place, city, zip code or GPS',
99
-					'desc_tip'    => true,
100
-					'default'     => 'Ireland',
101
-					'advanced'    => false
102
-				),
103
-				'static_width'            => array(
104
-					'type'        => 'number',
105
-					'title'       => __( 'Width:', 'geodirectory' ),
106
-					'desc'        => __( 'This is the width of the map, for static maps you can only use px values.', 'geodirectory' ),
107
-					'placeholder' => '600',
108
-					'desc_tip'    => true,
109
-					'default'     => '600',
110
-					'custom_attributes' => array(
111
-						'max'         => '2000',
112
-						'min'         => '100',
113
-					),
114
-					'element_require' => '[%type%]=="image"',
115
-					'advanced'    => false
116
-				),
117
-				'static_height'           => array(
118
-					'type'        => 'number',
119
-					'title'       => __( 'Height:', 'geodirectory' ),
120
-					'desc'        => __( 'This is the height of the map, for static maps you can only use px values.', 'geodirectory' ),
121
-					'placeholder' => '400',
122
-					'desc_tip'    => true,
123
-					'default'     => '400',
124
-					'custom_attributes' => array(
125
-						'max'         => '2000',
126
-						'min'         => '100',
127
-						'required'         => 'required',
128
-					),
129
-					'element_require' => '[%type%]=="image"',
130
-					'advanced'    => false
131
-				),
132
-				'width'            => array(
133
-					'type'        => 'text',
134
-					'title'       => __( 'Width:', 'geodirectory' ),
135
-					'desc'        => __( 'This is the width of the map, you can use % or px here.', 'geodirectory' ),
136
-					'placeholder' => '100%',
137
-					'desc_tip'    => true,
138
-					'default'     => '100%',
139
-					'element_require' => '[%type%]!="image"',
140
-					'advanced'    => false
141
-				),
142
-				'height'           => array(
143
-					'type'        => 'text',
144
-					'title'       => __( 'Height:', 'geodirectory' ),
145
-					'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ),
146
-					'placeholder' => '425px',
147
-					'desc_tip'    => true,
148
-					'default'     => '425px',
149
-					'element_require' => '[%type%]!="image"',
150
-					'advanced'    => false
151
-				),
152
-				'maptype'          => array(
153
-					'type'     => 'select',
154
-					'title'    => __( 'Mapview:', 'geodirectory' ),
155
-					'desc'     => __( 'This is the type of map view that will be used by default.', 'geodirectory' ),
156
-					'options'  => array(
157
-						"roadmap"   => __( 'Road Map', 'geodirectory' ),
158
-						"satellite" => __( 'Satellite Map', 'geodirectory' ),
89
+                    ),
90
+                    'default'  => 'image',
91
+                    'desc_tip' => true,
92
+                    'advanced' => false
93
+                ),
94
+                'location'            => array(
95
+                    'type'        => 'text',
96
+                    'title'       => __( 'Location:', 'geodirectory' ),
97
+                    'desc'        => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory' ),
98
+                    'placeholder' => 'Place, city, zip code or GPS',
99
+                    'desc_tip'    => true,
100
+                    'default'     => 'Ireland',
101
+                    'advanced'    => false
102
+                ),
103
+                'static_width'            => array(
104
+                    'type'        => 'number',
105
+                    'title'       => __( 'Width:', 'geodirectory' ),
106
+                    'desc'        => __( 'This is the width of the map, for static maps you can only use px values.', 'geodirectory' ),
107
+                    'placeholder' => '600',
108
+                    'desc_tip'    => true,
109
+                    'default'     => '600',
110
+                    'custom_attributes' => array(
111
+                        'max'         => '2000',
112
+                        'min'         => '100',
113
+                    ),
114
+                    'element_require' => '[%type%]=="image"',
115
+                    'advanced'    => false
116
+                ),
117
+                'static_height'           => array(
118
+                    'type'        => 'number',
119
+                    'title'       => __( 'Height:', 'geodirectory' ),
120
+                    'desc'        => __( 'This is the height of the map, for static maps you can only use px values.', 'geodirectory' ),
121
+                    'placeholder' => '400',
122
+                    'desc_tip'    => true,
123
+                    'default'     => '400',
124
+                    'custom_attributes' => array(
125
+                        'max'         => '2000',
126
+                        'min'         => '100',
127
+                        'required'         => 'required',
128
+                    ),
129
+                    'element_require' => '[%type%]=="image"',
130
+                    'advanced'    => false
131
+                ),
132
+                'width'            => array(
133
+                    'type'        => 'text',
134
+                    'title'       => __( 'Width:', 'geodirectory' ),
135
+                    'desc'        => __( 'This is the width of the map, you can use % or px here.', 'geodirectory' ),
136
+                    'placeholder' => '100%',
137
+                    'desc_tip'    => true,
138
+                    'default'     => '100%',
139
+                    'element_require' => '[%type%]!="image"',
140
+                    'advanced'    => false
141
+                ),
142
+                'height'           => array(
143
+                    'type'        => 'text',
144
+                    'title'       => __( 'Height:', 'geodirectory' ),
145
+                    'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ),
146
+                    'placeholder' => '425px',
147
+                    'desc_tip'    => true,
148
+                    'default'     => '425px',
149
+                    'element_require' => '[%type%]!="image"',
150
+                    'advanced'    => false
151
+                ),
152
+                'maptype'          => array(
153
+                    'type'     => 'select',
154
+                    'title'    => __( 'Mapview:', 'geodirectory' ),
155
+                    'desc'     => __( 'This is the type of map view that will be used by default.', 'geodirectory' ),
156
+                    'options'  => array(
157
+                        "roadmap"   => __( 'Road Map', 'geodirectory' ),
158
+                        "satellite" => __( 'Satellite Map', 'geodirectory' ),
159 159
 //						"hybrid"    => __( 'Hybrid Map', 'geodirectory' ),
160 160
 //						"terrain"   => __( 'Terrain Map', 'geodirectory' ),
161
-					),
162
-					'desc_tip' => true,
163
-					'default'  => 'roadmap',
164
-					'advanced' => true
165
-				),
166
-				'zoom'             => array(
167
-					'type'        => 'select',
168
-					'title'       => __( 'Zoom level:', 'geodirectory' ),
169
-					'desc'        => __( 'This is the zoom level of the map, `auto` is recommended.', 'geodirectory' ),
170
-					'options'     => range( 1, 19 ),
171
-					'placeholder' => '',
172
-					'desc_tip'    => true,
173
-					'default'     => '7',
174
-					'advanced'    => true
175
-				),
176
-				'api_key'           => array(
177
-					'type'        => 'text',
178
-					'title'       => __( 'Api Key:', 'geodirectory' ),
179
-					'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ),
180
-					'placeholder' => '',
181
-					'desc_tip'    => true,
182
-					'default'     => '',
183
-					'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1',
184
-					'advanced'    => false
185
-				),
186
-			)
187
-		);
188
-
189
-		parent::__construct( $options );
190
-	}
191
-
192
-
193
-	/**
194
-	 * This is the output function for the widget, shortcode and block (front end).
195
-	 *
196
-	 * @param array $args The arguments values.
197
-	 * @param array $widget_args The widget arguments when used.
198
-	 * @param string $content The shortcode content argument
199
-	 *
200
-	 * @return string
201
-	 */
202
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
203
-
204
-		// options
205
-		$defaults = array(
206
-			'type'      => 'image', // image, place
207
-			'location' => 'Ireland',
208
-			'static_width' => '600',
209
-			'static_height' => '400',
210
-			'width'=> '100%',
211
-			'height'=> '425px',
212
-			'maptype'     => 'roadmap',
213
-			'zoom'     => '7',
214
-			'api_key'     => 'AIzaSyBK3ZcmK0ljxl5agNyJNQh_G24Thq1btuE',
215
-		);
216
-
217
-		/**
218
-		 * Parse incoming $args into an array and merge it with $defaults
219
-		 */
220
-		$args = wp_parse_args($args, $defaults );
221
-
222
-		$output = '';
223
-
224
-
225
-		// check if we have a global API key
226
-		$args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key'];
227
-
228
-		if($args['type']=='image'){
229
-			$output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />";
230
-		}else{
231
-			$output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> ";
232
-		}
233
-
234
-		return $output;
235
-
236
-	}
161
+                    ),
162
+                    'desc_tip' => true,
163
+                    'default'  => 'roadmap',
164
+                    'advanced' => true
165
+                ),
166
+                'zoom'             => array(
167
+                    'type'        => 'select',
168
+                    'title'       => __( 'Zoom level:', 'geodirectory' ),
169
+                    'desc'        => __( 'This is the zoom level of the map, `auto` is recommended.', 'geodirectory' ),
170
+                    'options'     => range( 1, 19 ),
171
+                    'placeholder' => '',
172
+                    'desc_tip'    => true,
173
+                    'default'     => '7',
174
+                    'advanced'    => true
175
+                ),
176
+                'api_key'           => array(
177
+                    'type'        => 'text',
178
+                    'title'       => __( 'Api Key:', 'geodirectory' ),
179
+                    'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ),
180
+                    'placeholder' => '',
181
+                    'desc_tip'    => true,
182
+                    'default'     => '',
183
+                    'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1',
184
+                    'advanced'    => false
185
+                ),
186
+            )
187
+        );
188
+
189
+        parent::__construct( $options );
190
+    }
191
+
192
+
193
+    /**
194
+     * This is the output function for the widget, shortcode and block (front end).
195
+     *
196
+     * @param array $args The arguments values.
197
+     * @param array $widget_args The widget arguments when used.
198
+     * @param string $content The shortcode content argument
199
+     *
200
+     * @return string
201
+     */
202
+    public function output( $args = array(), $widget_args = array(), $content = '' ) {
203
+
204
+        // options
205
+        $defaults = array(
206
+            'type'      => 'image', // image, place
207
+            'location' => 'Ireland',
208
+            'static_width' => '600',
209
+            'static_height' => '400',
210
+            'width'=> '100%',
211
+            'height'=> '425px',
212
+            'maptype'     => 'roadmap',
213
+            'zoom'     => '7',
214
+            'api_key'     => 'AIzaSyBK3ZcmK0ljxl5agNyJNQh_G24Thq1btuE',
215
+        );
216
+
217
+        /**
218
+         * Parse incoming $args into an array and merge it with $defaults
219
+         */
220
+        $args = wp_parse_args($args, $defaults );
221
+
222
+        $output = '';
223
+
224
+
225
+        // check if we have a global API key
226
+        $args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key'];
227
+
228
+        if($args['type']=='image'){
229
+            $output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />";
230
+        }else{
231
+            $output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> ";
232
+        }
233
+
234
+        return $output;
235
+
236
+    }
237 237
 
238 238
 }
239 239
 
240 240
 // register it.
241 241
 add_action( 'widgets_init', function () {
242
-	register_widget( 'SD_Map' );
242
+    register_widget( 'SD_Map' );
243 243
 } );
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 			'block-output'   => array( // the block visual output elements as an array
23 23
 				array(
24 24
 					'element' => 'p',
25
-					'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ','super-duper'),
25
+					'content' => __('A Google API key is required to use this block, we recommend installing our plugin which makes it easy and sets it globally, or you can set a key in the block settings sidebar: ', 'super-duper'),
26 26
 					//'element_require' => '"1"=='.get_option( 'rgmk_google_map_api_key', '"0"') ? '"0"' : '"1"',
27
-					'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
27
+					'element_require' => get_option('rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
28 28
 				),
29 29
 				array(
30 30
 					'element' => 'a',
31
-					'content' => __('API KEY for Google Maps','super-duper'),
32
-					'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
31
+					'content' => __('API KEY for Google Maps', 'super-duper'),
32
+					'element_require' => get_option('rgmk_google_map_api_key', false) ? '1==0' : '1==1 && [%api_key%]==""',
33 33
 					'href' => 'https://wordpress.org/plugins/api-key-for-google-maps/',
34 34
 				),
35 35
 				array(
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 					'class'   => '[%className%]',
38 38
 					//'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
39 39
 					'element_require' => '[%type%]=="image"',
40
-					'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=".get_option( 'rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]"
40
+					'src'     => get_option('rgmk_google_map_api_key', false) ? "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=" . get_option('rgmk_google_map_api_key') : "https://maps.googleapis.com/maps/api/staticmap?center=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&size=[%static_width%]x[%static_height%]&key=[%api_key%]"
41 41
 				),
42 42
 				array(
43 43
 					'element' => 'div',
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 					'style'   => '{overflow:"hidden", position:"relative"}',
46 46
 					array(
47 47
 						'element' => 'iframe',
48
-						'title'   => __( 'Placeholderx', 'super-duper' ),
48
+						'title'   => __('Placeholderx', 'super-duper'),
49 49
 						'class'   => '[%className%]',
50 50
 						'width'   => '[%width%]',
51 51
 						'height'  => '[%height%]',
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 						'allowfullscreen' => 'true',
54 54
 						'style' => '{border:0}',
55 55
 						'element_require' => '[%type%]!="image"',
56
-						'src'     => get_option( 'rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=".get_option( 'rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]"
56
+						'src'     => get_option('rgmk_google_map_api_key', false) ? "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=" . get_option('rgmk_google_map_api_key') : "https://www.google.com/maps/embed/v1/[%type%]?q=[%location%]&maptype=[%maptype%]&zoom=[%zoom%]&key=[%api_key%]"
57 57
 					),
58 58
 				),
59 59
 				array(
60 60
 					'element' => 'style',
61
-					'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "'.__("Click here, Settings are in the block settings sidebar","super-duper").'";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center;  color: #fff; font-size: 20px; font-weight: bold;}',
61
+					'content' => '.sd-map-iframe-cover:hover:before {background: #4a4a4a88; content: "' . __("Click here, Settings are in the block settings sidebar", "super-duper") . '";} .sd-map-iframe-cover:before{cursor: pointer; content: ""; width: 100%; height: 100%; position: absolute; top: 0; bottom: 0;padding-top: 33%; text-align: center;  color: #fff; font-size: 20px; font-weight: bold;}',
62 62
 					'element_require' => '[%type%]!="image"',
63 63
 				),
64 64
 			),
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 			// The calling class name
67 67
 			'base_id'        => 'sd_map',
68 68
 			// this is used as the widget id and the shortcode id.
69
-			'name'           => __( 'Map', 'super-duper' ),
69
+			'name'           => __('Map', 'super-duper'),
70 70
 			// the name of the widget/block
71 71
 			'widget_ops'     => array(
72 72
 				'classname'   => 'sd-map-class',
73 73
 				// widget class
74
-				'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ),
74
+				'description' => esc_html__('This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world'),
75 75
 				// widget description
76 76
 			),
77 77
 			'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 				),
94 94
 				'location'            => array(
95 95
 					'type'        => 'text',
96
-					'title'       => __( 'Location:', 'geodirectory' ),
97
-					'desc'        => __( 'Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory' ),
96
+					'title'       => __('Location:', 'geodirectory'),
97
+					'desc'        => __('Enter the location to show on the map, place, city, zip code or GPS.', 'geodirectory'),
98 98
 					'placeholder' => 'Place, city, zip code or GPS',
99 99
 					'desc_tip'    => true,
100 100
 					'default'     => 'Ireland',
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 				),
103 103
 				'static_width'            => array(
104 104
 					'type'        => 'number',
105
-					'title'       => __( 'Width:', 'geodirectory' ),
106
-					'desc'        => __( 'This is the width of the map, for static maps you can only use px values.', 'geodirectory' ),
105
+					'title'       => __('Width:', 'geodirectory'),
106
+					'desc'        => __('This is the width of the map, for static maps you can only use px values.', 'geodirectory'),
107 107
 					'placeholder' => '600',
108 108
 					'desc_tip'    => true,
109 109
 					'default'     => '600',
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 				),
117 117
 				'static_height'           => array(
118 118
 					'type'        => 'number',
119
-					'title'       => __( 'Height:', 'geodirectory' ),
120
-					'desc'        => __( 'This is the height of the map, for static maps you can only use px values.', 'geodirectory' ),
119
+					'title'       => __('Height:', 'geodirectory'),
120
+					'desc'        => __('This is the height of the map, for static maps you can only use px values.', 'geodirectory'),
121 121
 					'placeholder' => '400',
122 122
 					'desc_tip'    => true,
123 123
 					'default'     => '400',
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 				),
132 132
 				'width'            => array(
133 133
 					'type'        => 'text',
134
-					'title'       => __( 'Width:', 'geodirectory' ),
135
-					'desc'        => __( 'This is the width of the map, you can use % or px here.', 'geodirectory' ),
134
+					'title'       => __('Width:', 'geodirectory'),
135
+					'desc'        => __('This is the width of the map, you can use % or px here.', 'geodirectory'),
136 136
 					'placeholder' => '100%',
137 137
 					'desc_tip'    => true,
138 138
 					'default'     => '100%',
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 				),
142 142
 				'height'           => array(
143 143
 					'type'        => 'text',
144
-					'title'       => __( 'Height:', 'geodirectory' ),
145
-					'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ),
144
+					'title'       => __('Height:', 'geodirectory'),
145
+					'desc'        => __('This is the height of the map, you can use %, px or vh here.', 'geodirectory'),
146 146
 					'placeholder' => '425px',
147 147
 					'desc_tip'    => true,
148 148
 					'default'     => '425px',
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
 				),
152 152
 				'maptype'          => array(
153 153
 					'type'     => 'select',
154
-					'title'    => __( 'Mapview:', 'geodirectory' ),
155
-					'desc'     => __( 'This is the type of map view that will be used by default.', 'geodirectory' ),
154
+					'title'    => __('Mapview:', 'geodirectory'),
155
+					'desc'     => __('This is the type of map view that will be used by default.', 'geodirectory'),
156 156
 					'options'  => array(
157
-						"roadmap"   => __( 'Road Map', 'geodirectory' ),
158
-						"satellite" => __( 'Satellite Map', 'geodirectory' ),
157
+						"roadmap"   => __('Road Map', 'geodirectory'),
158
+						"satellite" => __('Satellite Map', 'geodirectory'),
159 159
 //						"hybrid"    => __( 'Hybrid Map', 'geodirectory' ),
160 160
 //						"terrain"   => __( 'Terrain Map', 'geodirectory' ),
161 161
 					),
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 				),
166 166
 				'zoom'             => array(
167 167
 					'type'        => 'select',
168
-					'title'       => __( 'Zoom level:', 'geodirectory' ),
169
-					'desc'        => __( 'This is the zoom level of the map, `auto` is recommended.', 'geodirectory' ),
170
-					'options'     => range( 1, 19 ),
168
+					'title'       => __('Zoom level:', 'geodirectory'),
169
+					'desc'        => __('This is the zoom level of the map, `auto` is recommended.', 'geodirectory'),
170
+					'options'     => range(1, 19),
171 171
 					'placeholder' => '',
172 172
 					'desc_tip'    => true,
173 173
 					'default'     => '7',
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
 				),
176 176
 				'api_key'           => array(
177 177
 					'type'        => 'text',
178
-					'title'       => __( 'Api Key:', 'geodirectory' ),
179
-					'desc'        => __( 'This is the height of the map, you can use %, px or vh here.', 'geodirectory' ),
178
+					'title'       => __('Api Key:', 'geodirectory'),
179
+					'desc'        => __('This is the height of the map, you can use %, px or vh here.', 'geodirectory'),
180 180
 					'placeholder' => '',
181 181
 					'desc_tip'    => true,
182 182
 					'default'     => '',
183
-					'element_require' => get_option( 'rgmk_google_map_api_key', false) ? '1==0' : '1==1',
183
+					'element_require' => get_option('rgmk_google_map_api_key', false) ? '1==0' : '1==1',
184 184
 					'advanced'    => false
185 185
 				),
186 186
 			)
187 187
 		);
188 188
 
189
-		parent::__construct( $options );
189
+		parent::__construct($options);
190 190
 	}
191 191
 
192 192
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return string
201 201
 	 */
202
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
202
+	public function output($args = array(), $widget_args = array(), $content = '') {
203 203
 
204 204
 		// options
205 205
 		$defaults = array(
@@ -217,18 +217,18 @@  discard block
 block discarded – undo
217 217
 		/**
218 218
 		 * Parse incoming $args into an array and merge it with $defaults
219 219
 		 */
220
-		$args = wp_parse_args($args, $defaults );
220
+		$args = wp_parse_args($args, $defaults);
221 221
 
222 222
 		$output = '';
223 223
 
224 224
 
225 225
 		// check if we have a global API key
226
-		$args['api_key'] = get_option( 'rgmk_google_map_api_key', false ) ? get_option( 'rgmk_google_map_api_key' ) : $args['api_key'];
226
+		$args['api_key'] = get_option('rgmk_google_map_api_key', false) ? get_option('rgmk_google_map_api_key') : $args['api_key'];
227 227
 
228
-		if($args['type']=='image'){
229
-			$output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />";
230
-		}else{
231
-			$output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> ";
228
+		if ($args['type'] == 'image') {
229
+			$output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=" . esc_attr($args['location']) . "&maptype=" . esc_attr($args['maptype']) . "&zoom=" . esc_attr($args['zoom']) . "&size=" . esc_attr($args['static_width']) . "x" . esc_attr($args['static_height']) . "&key=" . esc_attr($args['api_key']) . "' />";
230
+		} else {
231
+			$output .= "<iframe width='" . esc_attr($args['width']) . "' height='" . esc_attr($args['height']) . "' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/" . esc_attr($args['type']) . "?q=" . esc_attr($args['location']) . "&maptype=" . esc_attr($args['maptype']) . "&zoom=" . esc_attr($args['zoom']) . "&key=" . esc_attr($args['api_key']) . "' ></iframe> ";
232 232
 		}
233 233
 
234 234
 		return $output;
@@ -238,6 +238,6 @@  discard block
 block discarded – undo
238 238
 }
239 239
 
240 240
 // register it.
241
-add_action( 'widgets_init', function () {
242
-	register_widget( 'SD_Map' );
241
+add_action('widgets_init', function() {
242
+	register_widget('SD_Map');
243 243
 } );
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,7 +227,7 @@
 block discarded – undo
227 227
 
228 228
 		if($args['type']=='image'){
229 229
 			$output .= "<img src='https://maps.googleapis.com/maps/api/staticmap?center=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&size=".esc_attr($args['static_width'])."x".esc_attr($args['static_height'])."&key=".esc_attr($args['api_key'])."' />";
230
-		}else{
230
+		} else{
231 231
 			$output .= "<iframe width='".esc_attr($args['width'])."' height='".esc_attr($args['height'])."' frameborder='0' allowfullscreen style='border:0;' src='https://www.google.com/maps/embed/v1/".esc_attr($args['type'])."?q=".esc_attr($args['location'])."&maptype=".esc_attr($args['maptype'])."&zoom=".esc_attr($args['zoom'])."&key=".esc_attr($args['api_key'])."' ></iframe> ";
232 232
 		}
233 233
 
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +703 added lines, -703 removed lines patch added patch discarded remove patch
@@ -7,91 +7,91 @@  discard block
 block discarded – undo
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
-if ( !is_admin() ) {
15
-    add_filter( 'template_include', 'wpinv_template', 10, 1 );
16
-    add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' );
17
-    add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' );
18
-    add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' );
14
+if (!is_admin()) {
15
+    add_filter('template_include', 'wpinv_template', 10, 1);
16
+    add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar');
17
+    add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions');
18
+    add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions');
19 19
 }
20 20
 
21 21
 function wpinv_template_path() {
22
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
22
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
23 23
 }
24 24
 
25
-function wpinv_display_invoice_top_bar( $invoice ) {
26
-    if ( empty( $invoice ) ) {
25
+function wpinv_display_invoice_top_bar($invoice) {
26
+    if (empty($invoice)) {
27 27
         return;
28 28
     }
29 29
     ?>
30 30
     <div class="row wpinv-top-bar no-print">
31 31
         <div class="container">
32 32
             <div class="col-xs-6">
33
-                <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?>
33
+                <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?>
34 34
             </div>
35 35
             <div class="col-xs-6 text-right">
36
-                <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?>
36
+                <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?>
37 37
             </div>
38 38
         </div>
39 39
     </div>
40 40
     <?php
41 41
 }
42 42
 
43
-function wpinv_invoice_display_left_actions( $invoice ) {
44
-    if ( empty( $invoice ) ) {
43
+function wpinv_invoice_display_left_actions($invoice) {
44
+    if (empty($invoice)) {
45 45
         return; // Exit if invoice is not set.
46 46
     }
47 47
     
48
-    if ( $invoice->post_type == 'wpi_invoice' ) {
49
-        if ( $invoice->needs_payment() ) {
50
-            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php
48
+    if ($invoice->post_type == 'wpi_invoice') {
49
+        if ($invoice->needs_payment()) {
50
+            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php
51 51
         }
52 52
     }
53 53
     do_action('wpinv_invoice_display_left_actions', $invoice);
54 54
 }
55 55
 
56
-function wpinv_invoice_display_right_actions( $invoice ) {
57
-    if ( empty( $invoice ) ) {
56
+function wpinv_invoice_display_right_actions($invoice) {
57
+    if (empty($invoice)) {
58 58
         return; // Exit if invoice is not set.
59 59
     }
60 60
 
61
-    if ( $invoice->post_type == 'wpi_invoice' ) { ?>
62
-        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a>
63
-        <?php if ( is_user_logged_in() ) { ?>
64
-        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a>
61
+    if ($invoice->post_type == 'wpi_invoice') { ?>
62
+        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a>
63
+        <?php if (is_user_logged_in()) { ?>
64
+        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a>
65 65
         <?php }
66 66
     }
67 67
     do_action('wpinv_invoice_display_right_actions', $invoice);
68 68
 }
69 69
 
70
-function wpinv_before_invoice_content( $content ) {
70
+function wpinv_before_invoice_content($content) {
71 71
     global $post;
72 72
 
73
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
73
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
74 74
         ob_start();
75
-        do_action( 'wpinv_before_invoice_content', $post->ID );
75
+        do_action('wpinv_before_invoice_content', $post->ID);
76 76
         $content = ob_get_clean() . $content;
77 77
     }
78 78
 
79 79
     return $content;
80 80
 }
81
-add_filter( 'the_content', 'wpinv_before_invoice_content' );
81
+add_filter('the_content', 'wpinv_before_invoice_content');
82 82
 
83
-function wpinv_after_invoice_content( $content ) {
83
+function wpinv_after_invoice_content($content) {
84 84
     global $post;
85 85
 
86
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
86
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
87 87
         ob_start();
88
-        do_action( 'wpinv_after_invoice_content', $post->ID );
88
+        do_action('wpinv_after_invoice_content', $post->ID);
89 89
         $content .= ob_get_clean();
90 90
     }
91 91
 
92 92
     return $content;
93 93
 }
94
-add_filter( 'the_content', 'wpinv_after_invoice_content' );
94
+add_filter('the_content', 'wpinv_after_invoice_content');
95 95
 
96 96
 function wpinv_get_templates_dir() {
97 97
     return WPINV_PLUGIN_DIR . 'templates';
@@ -101,105 +101,105 @@  discard block
 block discarded – undo
101 101
     return WPINV_PLUGIN_URL . 'templates';
102 102
 }
103 103
 
104
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105
-    if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
104
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
105
+    if (!empty($args) && is_array($args)) {
106
+		extract($args);
107 107
 	}
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
109
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
110 110
 	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
111
+	$located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path);
112 112
 
113
-	if ( ! file_exists( $located ) ) {
114
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
113
+	if (!file_exists($located)) {
114
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
115 115
 		return;
116 116
 	}
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
119 119
 
120
-	include( $located );
120
+	include($located);
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
123 123
 }
124 124
 
125
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
125
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
126 126
 	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
127
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
128 128
 	return ob_get_clean();
129 129
 }
130 130
 
131
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
132
-    if ( ! $template_path ) {
131
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
132
+    if (!$template_path) {
133 133
         $template_path = wpinv_template_path();
134 134
     }
135 135
 
136
-    if ( ! $default_path ) {
136
+    if (!$default_path) {
137 137
         $default_path = WPINV_PLUGIN_DIR . 'templates/';
138 138
     }
139 139
 
140 140
     // Look within passed path within the theme - this is priority.
141 141
     $template = locate_template(
142 142
         array(
143
-            trailingslashit( $template_path ) . $template_name,
143
+            trailingslashit($template_path) . $template_name,
144 144
             $template_name
145 145
         )
146 146
     );
147 147
 
148 148
     // Get default templates/
149
-    if ( !$template && $default_path ) {
150
-        $template = trailingslashit( $default_path ) . $template_name;
149
+    if (!$template && $default_path) {
150
+        $template = trailingslashit($default_path) . $template_name;
151 151
     }
152 152
 
153 153
     // Return what we found.
154
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path );
154
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path);
155 155
 }
156 156
 
157
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
157
+function wpinv_get_template_part($slug, $name = null, $load = true) {
158
+	do_action('get_template_part_' . $slug, $slug, $name);
159 159
 
160 160
 	// Setup possible parts
161 161
 	$templates = array();
162
-	if ( isset( $name ) )
162
+	if (isset($name))
163 163
 		$templates[] = $slug . '-' . $name . '.php';
164 164
 	$templates[] = $slug . '.php';
165 165
 
166 166
 	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
167
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
168 168
 
169 169
 	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
170
+	return wpinv_locate_tmpl($templates, $load, false);
171 171
 }
172 172
 
173
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
173
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
174 174
 	// No file found yet
175 175
 	$located = false;
176 176
 
177 177
 	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
178
+	foreach ((array)$template_names as $template_name) {
179 179
 
180 180
 		// Continue if template is empty
181
-		if ( empty( $template_name ) )
181
+		if (empty($template_name))
182 182
 			continue;
183 183
 
184 184
 		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
185
+		$template_name = ltrim($template_name, '/');
186 186
 
187 187
 		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
188
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
190
+			if (file_exists($template_path . $template_name)) {
191 191
 				$located = $template_path . $template_name;
192 192
 				break;
193 193
 			}
194 194
 		}
195 195
 
196
-		if( !empty( $located ) ) {
196
+		if (!empty($located)) {
197 197
 			break;
198 198
 		}
199 199
 	}
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+	if ((true == $load) && !empty($located))
202
+		load_template($located, $require_once);
203 203
 
204 204
 	return $located;
205 205
 }
@@ -208,149 +208,149 @@  discard block
 block discarded – undo
208 208
 	$template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210 210
 	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
211
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
212
+		10 => trailingslashit(get_template_directory()) . $template_dir,
213 213
 		100 => wpinv_get_templates_dir()
214 214
 	);
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
217 217
 
218 218
 	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
219
+	ksort($file_paths, SORT_NUMERIC);
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+	return array_map('trailingslashit', $file_paths);
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230 230
 	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
231
+	$pages[] = wpinv_get_option('success_page');
232
+	$pages[] = wpinv_get_option('failure_page');
233
+	$pages[] = wpinv_get_option('invoice_history_page');
234
+	$pages[] = wpinv_get_option('invoice_subscription_page');
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
236
+	if (!wpinv_is_checkout() && !is_page($pages)) {
237 237
 		return;
238 238
 	}
239 239
 
240 240
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
242
+add_action('wp_head', 'wpinv_checkout_meta_tags');
243 243
 
244
-function wpinv_add_body_classes( $class ) {
244
+function wpinv_add_body_classes($class) {
245 245
 	$classes = (array)$class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
247
+	if (wpinv_is_checkout()) {
248 248
 		$classes[] = 'wpinv-checkout';
249 249
 		$classes[] = 'wpinv-page';
250 250
 	}
251 251
 
252
-	if( wpinv_is_success_page() ) {
252
+	if (wpinv_is_success_page()) {
253 253
 		$classes[] = 'wpinv-success';
254 254
 		$classes[] = 'wpinv-page';
255 255
 	}
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
257
+	if (wpinv_is_failed_transaction_page()) {
258 258
 		$classes[] = 'wpinv-failed-transaction';
259 259
 		$classes[] = 'wpinv-page';
260 260
 	}
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
262
+	if (wpinv_is_invoice_history_page()) {
263 263
 		$classes[] = 'wpinv-history';
264 264
 		$classes[] = 'wpinv-page';
265 265
 	}
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
267
+	if (wpinv_is_subscriptions_history_page()) {
268 268
 		$classes[] = 'wpinv-subscription';
269 269
 		$classes[] = 'wpinv-page';
270 270
 	}
271 271
 
272
-	if( wpinv_is_test_mode() ) {
272
+	if (wpinv_is_test_mode()) {
273 273
 		$classes[] = 'wpinv-test-mode';
274 274
 		$classes[] = 'wpinv-page';
275 275
 	}
276 276
 
277
-	return array_unique( $classes );
277
+	return array_unique($classes);
278 278
 }
279
-add_filter( 'body_class', 'wpinv_add_body_classes' );
279
+add_filter('body_class', 'wpinv_add_body_classes');
280 280
 
281
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
282
-    $args = array( 'nopaging' => true );
281
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
282
+    $args = array('nopaging' => true);
283 283
 
284
-    if ( ! empty( $status ) )
284
+    if (!empty($status))
285 285
         $args['post_status'] = $status;
286 286
 
287
-    $discounts = wpinv_get_discounts( $args );
287
+    $discounts = wpinv_get_discounts($args);
288 288
     $options   = array();
289 289
 
290
-    if ( $discounts ) {
291
-        foreach ( $discounts as $discount ) {
292
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
290
+    if ($discounts) {
291
+        foreach ($discounts as $discount) {
292
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
293 293
         }
294 294
     } else {
295
-        $options[0] = __( 'No discounts found', 'invoicing' );
295
+        $options[0] = __('No discounts found', 'invoicing');
296 296
     }
297 297
 
298
-    $output = wpinv_html_select( array(
298
+    $output = wpinv_html_select(array(
299 299
         'name'             => $name,
300 300
         'selected'         => $selected,
301 301
         'options'          => $options,
302 302
         'show_option_all'  => false,
303 303
         'show_option_none' => false,
304
-    ) );
304
+    ));
305 305
 
306 306
     return $output;
307 307
 }
308 308
 
309
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
310
-    $current     = date( 'Y' );
311
-    $start_year  = $current - absint( $years_before );
312
-    $end_year    = $current + absint( $years_after );
313
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
309
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
310
+    $current     = date('Y');
311
+    $start_year  = $current - absint($years_before);
312
+    $end_year    = $current + absint($years_after);
313
+    $selected    = empty($selected) ? date('Y') : $selected;
314 314
     $options     = array();
315 315
 
316
-    while ( $start_year <= $end_year ) {
317
-        $options[ absint( $start_year ) ] = $start_year;
316
+    while ($start_year <= $end_year) {
317
+        $options[absint($start_year)] = $start_year;
318 318
         $start_year++;
319 319
     }
320 320
 
321
-    $output = wpinv_html_select( array(
321
+    $output = wpinv_html_select(array(
322 322
         'name'             => $name,
323 323
         'selected'         => $selected,
324 324
         'options'          => $options,
325 325
         'show_option_all'  => false,
326 326
         'show_option_none' => false
327
-    ) );
327
+    ));
328 328
 
329 329
     return $output;
330 330
 }
331 331
 
332
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
332
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
333 333
     $month   = 1;
334 334
     $options = array();
335
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
335
+    $selected = empty($selected) ? date('n') : $selected;
336 336
 
337
-    while ( $month <= 12 ) {
338
-        $options[ absint( $month ) ] = wpinv_month_num_to_name( $month );
337
+    while ($month <= 12) {
338
+        $options[absint($month)] = wpinv_month_num_to_name($month);
339 339
         $month++;
340 340
     }
341 341
 
342
-    $output = wpinv_html_select( array(
342
+    $output = wpinv_html_select(array(
343 343
         'name'             => $name,
344 344
         'selected'         => $selected,
345 345
         'options'          => $options,
346 346
         'show_option_all'  => false,
347 347
         'show_option_none' => false
348
-    ) );
348
+    ));
349 349
 
350 350
     return $output;
351 351
 }
352 352
 
353
-function wpinv_html_select( $args = array() ) {
353
+function wpinv_html_select($args = array()) {
354 354
     $defaults = array(
355 355
         'options'          => array(),
356 356
         'name'             => null,
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
         'selected'         => 0,
360 360
         'placeholder'      => null,
361 361
         'multiple'         => false,
362
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
363
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
362
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
363
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
364 364
         'data'             => array(),
365 365
         'onchange'         => null,
366 366
         'required'         => false,
@@ -368,74 +368,74 @@  discard block
 block discarded – undo
368 368
         'readonly'         => false,
369 369
     );
370 370
 
371
-    $args = wp_parse_args( $args, $defaults );
371
+    $args = wp_parse_args($args, $defaults);
372 372
 
373 373
     $data_elements = '';
374
-    foreach ( $args['data'] as $key => $value ) {
375
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
374
+    foreach ($args['data'] as $key => $value) {
375
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
376 376
     }
377 377
 
378
-    if( $args['multiple'] ) {
378
+    if ($args['multiple']) {
379 379
         $multiple = ' MULTIPLE';
380 380
     } else {
381 381
         $multiple = '';
382 382
     }
383 383
 
384
-    if( $args['placeholder'] ) {
384
+    if ($args['placeholder']) {
385 385
         $placeholder = $args['placeholder'];
386 386
     } else {
387 387
         $placeholder = '';
388 388
     }
389 389
     
390 390
     $options = '';
391
-    if( !empty( $args['onchange'] ) ) {
392
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
391
+    if (!empty($args['onchange'])) {
392
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
393 393
     }
394 394
     
395
-    if( !empty( $args['required'] ) ) {
395
+    if (!empty($args['required'])) {
396 396
         $options .= ' required="required"';
397 397
     }
398 398
     
399
-    if( !empty( $args['disabled'] ) ) {
399
+    if (!empty($args['disabled'])) {
400 400
         $options .= ' disabled';
401 401
     }
402 402
     
403
-    if( !empty( $args['readonly'] ) ) {
403
+    if (!empty($args['readonly'])) {
404 404
         $options .= ' readonly';
405 405
     }
406 406
 
407
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
408
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
407
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
408
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
409 409
 
410
-    if ( $args['show_option_all'] ) {
411
-        if( $args['multiple'] ) {
412
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
410
+    if ($args['show_option_all']) {
411
+        if ($args['multiple']) {
412
+            $selected = selected(true, in_array(0, $args['selected']), false);
413 413
         } else {
414
-            $selected = selected( $args['selected'], 0, false );
414
+            $selected = selected($args['selected'], 0, false);
415 415
         }
416
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
416
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
417 417
     }
418 418
 
419
-    if ( !empty( $args['options'] ) ) {
419
+    if (!empty($args['options'])) {
420 420
 
421
-        if ( $args['show_option_none'] ) {
422
-            if( $args['multiple'] ) {
423
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
421
+        if ($args['show_option_none']) {
422
+            if ($args['multiple']) {
423
+                $selected = selected(true, in_array("", $args['selected']), false);
424 424
             } else {
425
-                $selected = selected( $args['selected'] === "", true, false );
425
+                $selected = selected($args['selected'] === "", true, false);
426 426
             }
427
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
427
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
428 428
         }
429 429
 
430
-        foreach( $args['options'] as $key => $option ) {
430
+        foreach ($args['options'] as $key => $option) {
431 431
 
432
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
433
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
432
+            if ($args['multiple'] && is_array($args['selected'])) {
433
+                $selected = selected(true, (bool)in_array($key, $args['selected']), false);
434 434
             } else {
435
-                $selected = selected( $args['selected'], $key, false );
435
+                $selected = selected($args['selected'], $key, false);
436 436
             }
437 437
 
438
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
438
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
439 439
         }
440 440
     }
441 441
 
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
     return $output;
445 445
 }
446 446
 
447
-function wpinv_item_dropdown( $args = array() ) {
447
+function wpinv_item_dropdown($args = array()) {
448 448
     $defaults = array(
449 449
         'name'              => 'wpi_item',
450 450
         'id'                => 'wpi_item',
@@ -452,14 +452,14 @@  discard block
 block discarded – undo
452 452
         'multiple'          => false,
453 453
         'selected'          => 0,
454 454
         'number'            => 100,
455
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
456
-        'data'              => array( 'search-type' => 'item' ),
455
+        'placeholder'       => __('Choose a item', 'invoicing'),
456
+        'data'              => array('search-type' => 'item'),
457 457
         'show_option_all'   => false,
458 458
         'show_option_none'  => false,
459 459
         'show_recurring'    => false,
460 460
     );
461 461
 
462
-    $args = wp_parse_args( $args, $defaults );
462
+    $args = wp_parse_args($args, $defaults);
463 463
 
464 464
     $item_args = array(
465 465
         'post_type'      => 'wpi_item',
@@ -468,44 +468,44 @@  discard block
 block discarded – undo
468 468
         'posts_per_page' => $args['number']
469 469
     );
470 470
     
471
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
471
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
472 472
 
473
-    $items      = get_posts( $item_args );
473
+    $items      = get_posts($item_args);
474 474
     $options    = array();
475
-    if ( $items ) {
476
-        foreach ( $items as $item ) {
477
-            $title = esc_html( $item->post_title );
475
+    if ($items) {
476
+        foreach ($items as $item) {
477
+            $title = esc_html($item->post_title);
478 478
             
479
-            if ( !empty( $args['show_recurring'] ) ) {
480
-                $title .= wpinv_get_item_suffix( $item->ID, false );
479
+            if (!empty($args['show_recurring'])) {
480
+                $title .= wpinv_get_item_suffix($item->ID, false);
481 481
             }
482 482
             
483
-            $options[ absint( $item->ID ) ] = $title;
483
+            $options[absint($item->ID)] = $title;
484 484
         }
485 485
     }
486 486
 
487 487
     // This ensures that any selected items are included in the drop down
488
-    if( is_array( $args['selected'] ) ) {
489
-        foreach( $args['selected'] as $item ) {
490
-            if( ! in_array( $item, $options ) ) {
491
-                $title = get_the_title( $item );
492
-                if ( !empty( $args['show_recurring'] ) ) {
493
-                    $title .= wpinv_get_item_suffix( $item, false );
488
+    if (is_array($args['selected'])) {
489
+        foreach ($args['selected'] as $item) {
490
+            if (!in_array($item, $options)) {
491
+                $title = get_the_title($item);
492
+                if (!empty($args['show_recurring'])) {
493
+                    $title .= wpinv_get_item_suffix($item, false);
494 494
                 }
495 495
                 $options[$item] = $title;
496 496
             }
497 497
         }
498
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
499
-        if ( ! in_array( $args['selected'], $options ) ) {
500
-            $title = get_the_title( $args['selected'] );
501
-            if ( !empty( $args['show_recurring'] ) ) {
502
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
498
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
499
+        if (!in_array($args['selected'], $options)) {
500
+            $title = get_the_title($args['selected']);
501
+            if (!empty($args['show_recurring'])) {
502
+                $title .= wpinv_get_item_suffix($args['selected'], false);
503 503
             }
504
-            $options[$args['selected']] = get_the_title( $args['selected'] );
504
+            $options[$args['selected']] = get_the_title($args['selected']);
505 505
         }
506 506
     }
507 507
 
508
-    $output = wpinv_html_select( array(
508
+    $output = wpinv_html_select(array(
509 509
         'name'             => $args['name'],
510 510
         'selected'         => $args['selected'],
511 511
         'id'               => $args['id'],
@@ -516,12 +516,12 @@  discard block
 block discarded – undo
516 516
         'show_option_all'  => $args['show_option_all'],
517 517
         'show_option_none' => $args['show_option_none'],
518 518
         'data'             => $args['data'],
519
-    ) );
519
+    ));
520 520
 
521 521
     return $output;
522 522
 }
523 523
 
524
-function wpinv_html_checkbox( $args = array() ) {
524
+function wpinv_html_checkbox($args = array()) {
525 525
     $defaults = array(
526 526
         'name'     => null,
527 527
         'current'  => null,
@@ -532,38 +532,38 @@  discard block
 block discarded – undo
532 532
         )
533 533
     );
534 534
 
535
-    $args = wp_parse_args( $args, $defaults );
535
+    $args = wp_parse_args($args, $defaults);
536 536
 
537
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
537
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
538 538
     $options = '';
539
-    if ( ! empty( $args['options']['disabled'] ) ) {
539
+    if (!empty($args['options']['disabled'])) {
540 540
         $options .= ' disabled="disabled"';
541
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
541
+    } elseif (!empty($args['options']['readonly'])) {
542 542
         $options .= ' readonly';
543 543
     }
544 544
 
545
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
545
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
546 546
 
547 547
     return $output;
548 548
 }
549 549
 
550
-function wpinv_html_text( $args = array() ) {
550
+function wpinv_html_text($args = array()) {
551 551
     // Backwards compatibility
552
-    if ( func_num_args() > 1 ) {
552
+    if (func_num_args() > 1) {
553 553
         $args = func_get_args();
554 554
 
555 555
         $name  = $args[0];
556
-        $value = isset( $args[1] ) ? $args[1] : '';
557
-        $label = isset( $args[2] ) ? $args[2] : '';
558
-        $desc  = isset( $args[3] ) ? $args[3] : '';
556
+        $value = isset($args[1]) ? $args[1] : '';
557
+        $label = isset($args[2]) ? $args[2] : '';
558
+        $desc  = isset($args[3]) ? $args[3] : '';
559 559
     }
560 560
 
561 561
     $defaults = array(
562 562
         'id'           => '',
563
-        'name'         => isset( $name )  ? $name  : 'text',
564
-        'value'        => isset( $value ) ? $value : null,
565
-        'label'        => isset( $label ) ? $label : null,
566
-        'desc'         => isset( $desc )  ? $desc  : null,
563
+        'name'         => isset($name) ? $name : 'text',
564
+        'value'        => isset($value) ? $value : null,
565
+        'label'        => isset($label) ? $label : null,
566
+        'desc'         => isset($desc) ? $desc : null,
567 567
         'placeholder'  => '',
568 568
         'class'        => 'regular-text',
569 569
         'disabled'     => false,
@@ -573,51 +573,51 @@  discard block
 block discarded – undo
573 573
         'data'         => false
574 574
     );
575 575
 
576
-    $args = wp_parse_args( $args, $defaults );
576
+    $args = wp_parse_args($args, $defaults);
577 577
 
578
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
578
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
579 579
     $options = '';
580
-    if( $args['required'] ) {
580
+    if ($args['required']) {
581 581
         $options .= ' required="required"';
582 582
     }
583
-    if( $args['readonly'] ) {
583
+    if ($args['readonly']) {
584 584
         $options .= ' readonly';
585 585
     }
586
-    if( $args['readonly'] ) {
586
+    if ($args['readonly']) {
587 587
         $options .= ' readonly';
588 588
     }
589 589
 
590 590
     $data = '';
591
-    if ( !empty( $args['data'] ) ) {
592
-        foreach ( $args['data'] as $key => $value ) {
593
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
591
+    if (!empty($args['data'])) {
592
+        foreach ($args['data'] as $key => $value) {
593
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
594 594
         }
595 595
     }
596 596
 
597
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
598
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
599
-    if ( ! empty( $args['desc'] ) ) {
600
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
597
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
598
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
599
+    if (!empty($args['desc'])) {
600
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
601 601
     }
602 602
 
603
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
603
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
604 604
 
605 605
     $output .= '</span>';
606 606
 
607 607
     return $output;
608 608
 }
609 609
 
610
-function wpinv_html_date_field( $args = array() ) {
611
-    if( empty( $args['class'] ) ) {
610
+function wpinv_html_date_field($args = array()) {
611
+    if (empty($args['class'])) {
612 612
         $args['class'] = 'wpiDatepicker';
613
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
613
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
614 614
         $args['class'] .= ' wpiDatepicker';
615 615
     }
616 616
 
617
-    return wpinv_html_text( $args );
617
+    return wpinv_html_text($args);
618 618
 }
619 619
 
620
-function wpinv_html_textarea( $args = array() ) {
620
+function wpinv_html_textarea($args = array()) {
621 621
     $defaults = array(
622 622
         'name'        => 'textarea',
623 623
         'value'       => null,
@@ -627,31 +627,31 @@  discard block
 block discarded – undo
627 627
         'disabled'    => false
628 628
     );
629 629
 
630
-    $args = wp_parse_args( $args, $defaults );
630
+    $args = wp_parse_args($args, $defaults);
631 631
 
632
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
632
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
633 633
     $disabled = '';
634
-    if( $args['disabled'] ) {
634
+    if ($args['disabled']) {
635 635
         $disabled = ' disabled="disabled"';
636 636
     }
637 637
 
638
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
639
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
640
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
638
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
639
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
640
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
641 641
 
642
-    if ( ! empty( $args['desc'] ) ) {
643
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
642
+    if (!empty($args['desc'])) {
643
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
644 644
     }
645 645
     $output .= '</span>';
646 646
 
647 647
     return $output;
648 648
 }
649 649
 
650
-function wpinv_html_ajax_user_search( $args = array() ) {
650
+function wpinv_html_ajax_user_search($args = array()) {
651 651
     $defaults = array(
652 652
         'name'        => 'user_id',
653 653
         'value'       => null,
654
-        'placeholder' => __( 'Enter username', 'invoicing' ),
654
+        'placeholder' => __('Enter username', 'invoicing'),
655 655
         'label'       => null,
656 656
         'desc'        => null,
657 657
         'class'       => '',
@@ -660,13 +660,13 @@  discard block
 block discarded – undo
660 660
         'data'        => false
661 661
     );
662 662
 
663
-    $args = wp_parse_args( $args, $defaults );
663
+    $args = wp_parse_args($args, $defaults);
664 664
 
665 665
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
666 666
 
667 667
     $output  = '<span class="wpinv_user_search_wrap">';
668
-        $output .= wpinv_html_text( $args );
669
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
668
+        $output .= wpinv_html_text($args);
669
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
670 670
     $output .= '</span>';
671 671
 
672 672
     return $output;
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 function wpinv_ip_geolocation() {
676 676
     global $wpinv_euvat;
677 677
     
678
-    $ip         = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : '';    
678
+    $ip         = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : '';    
679 679
     $content    = '';
680 680
     $iso        = '';
681 681
     $country    = '';
@@ -686,69 +686,69 @@  discard block
 block discarded – undo
686 686
     $credit     = '';
687 687
     $address    = '';
688 688
     
689
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) {
689
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) {
690 690
         try {
691 691
             $iso        = $geoip2_city->country->isoCode;
692 692
             $country    = $geoip2_city->country->name;
693
-            $region     = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
693
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
694 694
             $city       = $geoip2_city->city->name;
695 695
             $longitude  = $geoip2_city->location->longitude;
696 696
             $latitude   = $geoip2_city->location->latitude;
697
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
698
-        } catch( Exception $e ) { }
697
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
698
+        } catch (Exception $e) { }
699 699
     }
700 700
     
701
-    if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) {
701
+    if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) {
702 702
         try {
703
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
703
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
704 704
             
705
-            if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) {
705
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
706 706
                 $iso        = $load_xml->geoplugin_countryCode;
707 707
                 $country    = $load_xml->geoplugin_countryName;
708
-                $region     = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
709
-                $city       = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
708
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
709
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
710 710
                 $longitude  = $load_xml->geoplugin_longitude;
711 711
                 $latitude   = $load_xml->geoplugin_latitude;
712 712
                 $credit     = $load_xml->geoplugin_credit;
713
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
713
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
714 714
             }
715
-        } catch( Exception $e ) { }
715
+        } catch (Exception $e) { }
716 716
     }
717 717
     
718
-    if ( $iso && $longitude && $latitude ) {
719
-        if ( $city ) {
718
+    if ($iso && $longitude && $latitude) {
719
+        if ($city) {
720 720
             $address .= $city . ', ';
721 721
         }
722 722
         
723
-        if ( $region ) {
723
+        if ($region) {
724 724
             $address .= $region . ', ';
725 725
         }
726 726
         
727 727
         $address .= $country . ' (' . $iso . ')';
728
-        $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>';
729
-        $content .= '<p>'. $credit . '</p>';
728
+        $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>';
729
+        $content .= '<p>' . $credit . '</p>';
730 730
     } else {
731
-        $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>';
731
+        $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>';
732 732
     }
733 733
     ?>
734 734
 <!DOCTYPE html>
735
-<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
735
+<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
736 736
 <body>
737
-    <?php if ( $latitude && $latitude ) { ?>
737
+    <?php if ($latitude && $latitude) { ?>
738 738
     <div id="map"></div>
739 739
         <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
740 740
         <script type="text/javascript">
741 741
         var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
742 742
             osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
743 743
             osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
744
-            latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>);
744
+            latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
745 745
 
746 746
         var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]});
747 747
 
748 748
         var marker = new L.Marker(latlng);
749 749
         map.addLayer(marker);
750 750
 
751
-        marker.bindPopup("<p><?php esc_attr_e( $address );?></p>");
751
+        marker.bindPopup("<p><?php esc_attr_e($address); ?></p>");
752 752
     </script>
753 753
     <?php } ?>
754 754
     <div style="height:100px"><?php echo $content; ?></div>
@@ -756,18 +756,18 @@  discard block
 block discarded – undo
756 756
 <?php
757 757
     exit;
758 758
 }
759
-add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
760
-add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
759
+add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
760
+add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
761 761
 
762 762
 // Set up the template for the invoice.
763
-function wpinv_template( $template ) {
763
+function wpinv_template($template) {
764 764
     global $post, $wp_query;
765 765
     
766
-    if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) {
767
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
768
-            $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false );
766
+    if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) {
767
+        if (wpinv_user_can_view_invoice($post->ID)) {
768
+            $template = wpinv_get_template_part('wpinv-invoice-print', false, false);
769 769
         } else {
770
-            $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false );
770
+            $template = wpinv_get_template_part('wpinv-invalid-access', false, false);
771 771
         }
772 772
     }
773 773
 
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 
777 777
 function wpinv_get_business_address() {
778 778
     $business_address   = wpinv_store_address();
779
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
779
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
780 780
     
781 781
     /*
782 782
     $default_country    = wpinv_get_default_country();
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
     
801 801
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
802 802
     
803
-    return apply_filters( 'wpinv_get_business_address', $business_address );
803
+    return apply_filters('wpinv_get_business_address', $business_address);
804 804
 }
805 805
 
806 806
 function wpinv_display_from_address() {
@@ -810,192 +810,192 @@  discard block
 block discarded – undo
810 810
     if (empty($from_name)) {
811 811
         $from_name = wpinv_get_business_name();
812 812
     }
813
-    ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div>
813
+    ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div>
814 814
     <div class="wrapper col-xs-10">
815
-        <div class="name"><?php echo esc_html( $from_name ); ?></div>
816
-        <?php if ( $address = wpinv_get_business_address() ) { ?>
817
-        <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div>
815
+        <div class="name"><?php echo esc_html($from_name); ?></div>
816
+        <?php if ($address = wpinv_get_business_address()) { ?>
817
+        <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div>
818 818
         <?php } ?>
819
-        <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
820
-        <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div>
819
+        <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
820
+        <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div>
821 821
         <?php } ?>
822 822
     </div>
823 823
     <?php
824 824
 }
825 825
 
826
-function wpinv_watermark( $id = 0 ) {
827
-    $output = wpinv_get_watermark( $id );
826
+function wpinv_watermark($id = 0) {
827
+    $output = wpinv_get_watermark($id);
828 828
     
829
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
829
+    return apply_filters('wpinv_get_watermark', $output, $id);
830 830
 }
831 831
 
832
-function wpinv_get_watermark( $id ) {
833
-    if ( !$id > 0 ) {
832
+function wpinv_get_watermark($id) {
833
+    if (!$id > 0) {
834 834
         return NULL;
835 835
     }
836
-    $invoice = wpinv_get_invoice( $id );
836
+    $invoice = wpinv_get_invoice($id);
837 837
     
838
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
839
-        if ( $invoice->is_paid() ) {
840
-            return __( 'Paid', 'invoicing' );
838
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
839
+        if ($invoice->is_paid()) {
840
+            return __('Paid', 'invoicing');
841 841
         }
842
-        if ( $invoice->is_refunded() ) {
843
-            return __( 'Refunded', 'invoicing' );
842
+        if ($invoice->is_refunded()) {
843
+            return __('Refunded', 'invoicing');
844 844
         }
845
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
846
-            return __( 'Cancelled', 'invoicing' );
845
+        if ($invoice->has_status(array('wpi-cancelled'))) {
846
+            return __('Cancelled', 'invoicing');
847 847
         }
848 848
     }
849 849
     
850 850
     return NULL;
851 851
 }
852 852
 
853
-function wpinv_display_invoice_details( $invoice ) {
853
+function wpinv_display_invoice_details($invoice) {
854 854
     global $wpinv_euvat;
855 855
     
856 856
     $invoice_id = $invoice->ID;
857 857
     $vat_name   = $wpinv_euvat->get_vat_name();
858 858
     $use_taxes  = wpinv_use_taxes();
859 859
     
860
-    $invoice_status = wpinv_get_invoice_status( $invoice_id );
860
+    $invoice_status = wpinv_get_invoice_status($invoice_id);
861 861
     ?>
862 862
     <table class="table table-bordered table-sm">
863
-        <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
863
+        <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?>
864 864
             <tr class="wpi-row-number">
865
-                <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th>
866
-                <td><?php echo esc_html( $invoice_number ); ?></td>
865
+                <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th>
866
+                <td><?php echo esc_html($invoice_number); ?></td>
867 867
             </tr>
868 868
         <?php } ?>
869 869
         <tr class="wpi-row-status">
870
-            <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th>
871
-            <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td>
870
+            <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th>
871
+            <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td>
872 872
         </tr>
873
-        <?php if ( $invoice->is_renewal() ) { ?>
873
+        <?php if ($invoice->is_renewal()) { ?>
874 874
         <tr class="wpi-row-parent">
875
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th>
876
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
875
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th>
876
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
877 877
         </tr>
878 878
         <?php } ?>
879
-        <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
879
+        <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
880 880
             <tr class="wpi-row-gateway">
881
-                <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th>
881
+                <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th>
882 882
                 <td><?php echo $gateway_name; ?></td>
883 883
             </tr>
884 884
         <?php } ?>
885
-        <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?>
885
+        <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?>
886 886
             <tr class="wpi-row-date">
887
-                <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th>
887
+                <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th>
888 888
                 <td><?php echo $invoice_date; ?></td>
889 889
             </tr>
890 890
         <?php } ?>
891
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?>
891
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?>
892 892
             <tr class="wpi-row-date">
893
-                <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th>
893
+                <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th>
894 894
                 <td><?php echo $due_date; ?></td>
895 895
             </tr>
896 896
         <?php } ?>
897
-        <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?>
898
-        <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
897
+        <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?>
898
+        <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
899 899
             <tr class="wpi-row-ovatno">
900
-                <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
900
+                <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
901 901
                 <td><?php echo $owner_vat_number; ?></td>
902 902
             </tr>
903 903
         <?php } ?>
904
-        <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?>
905
-        <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?>
904
+        <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?>
905
+        <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?>
906 906
             <tr class="wpi-row-uvatno">
907
-                <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
907
+                <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
908 908
                 <td><?php echo $user_vat_number; ?></td>
909 909
             </tr>
910 910
         <?php } ?>
911 911
         <tr class="table-active tr-total wpi-row-total">
912
-            <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th>
913
-            <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td>
912
+            <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th>
913
+            <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td>
914 914
         </tr>
915 915
     </table>
916 916
 <?php
917 917
 }
918 918
 
919
-function wpinv_display_to_address( $invoice_id = 0 ) {
920
-    $invoice = wpinv_get_invoice( $invoice_id );
919
+function wpinv_display_to_address($invoice_id = 0) {
920
+    $invoice = wpinv_get_invoice($invoice_id);
921 921
     
922
-    if ( empty( $invoice ) ) {
922
+    if (empty($invoice)) {
923 923
         return NULL;
924 924
     }
925 925
     
926 926
     $billing_details = $invoice->get_user_info();
927
-    $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>';
927
+    $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>';
928 928
     $output .= '<div class="wrapper col-xs-10">';
929 929
     
930 930
     ob_start();
931
-    do_action( 'wpinv_display_to_address_top', $invoice );
931
+    do_action('wpinv_display_to_address_top', $invoice);
932 932
     $output .= ob_get_clean();
933 933
     
934
-    $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>';
935
-    if ( $company = $billing_details['company'] ) {
936
-        $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>';
934
+    $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>';
935
+    if ($company = $billing_details['company']) {
936
+        $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>';
937 937
     }
938 938
     $address_row = '';
939
-    if ( $address = $billing_details['address'] ) {
940
-        $address_row .= wpautop( wp_kses_post( $address ) );
939
+    if ($address = $billing_details['address']) {
940
+        $address_row .= wpautop(wp_kses_post($address));
941 941
     }
942 942
     
943 943
     $address_fields = array();
944
-    if ( !empty( $billing_details['city'] ) ) {
944
+    if (!empty($billing_details['city'])) {
945 945
         $address_fields[] = $billing_details['city'];
946 946
     }
947 947
     
948
-    $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : '';
949
-    if ( !empty( $billing_details['state'] ) ) {
950
-        $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country );
948
+    $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : '';
949
+    if (!empty($billing_details['state'])) {
950
+        $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country);
951 951
     }
952 952
 
953
-    if ( !empty( $billing_country ) ) {
954
-        $address_fields[] = wpinv_country_name( $billing_country );
953
+    if (!empty($billing_country)) {
954
+        $address_fields[] = wpinv_country_name($billing_country);
955 955
     }
956 956
 
957
-    if ( !empty( $address_fields ) ) {
958
-        $address_fields = implode( ", ", $address_fields );
957
+    if (!empty($address_fields)) {
958
+        $address_fields = implode(", ", $address_fields);
959 959
         
960
-        if ( !empty( $billing_details['zip'] ) ) {
960
+        if (!empty($billing_details['zip'])) {
961 961
             $address_fields .= ' ' . $billing_details['zip'];
962 962
         }
963 963
 
964
-        $address_row .= wpautop( wp_kses_post( $address_fields ) );
964
+        $address_row .= wpautop(wp_kses_post($address_fields));
965 965
     }
966 966
     
967
-    if ( $address_row ) {
967
+    if ($address_row) {
968 968
         $output .= '<div class="address">' . $address_row . '</div>';
969 969
     }
970 970
 
971
-    if ( $phone = $invoice->get_phone() ) {
972
-        $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>';
971
+    if ($phone = $invoice->get_phone()) {
972
+        $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>';
973 973
     }
974
-    if ( $email = $invoice->get_email() ) {
975
-        $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>';
974
+    if ($email = $invoice->get_email()) {
975
+        $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>';
976 976
     }
977 977
 
978 978
     ob_start();
979
-    do_action( 'wpinv_display_to_address_bottom', $invoice );
979
+    do_action('wpinv_display_to_address_bottom', $invoice);
980 980
     $output .= ob_get_clean();
981 981
     
982 982
     $output .= '</div>';
983
-    $output = apply_filters( 'wpinv_display_to_address', $output, $invoice );
983
+    $output = apply_filters('wpinv_display_to_address', $output, $invoice);
984 984
 
985 985
     echo $output;
986 986
 }
987 987
 
988
-function wpinv_display_line_items( $invoice_id = 0 ) {
988
+function wpinv_display_line_items($invoice_id = 0) {
989 989
     global $wpinv_euvat, $ajax_cart_details;
990
-    $invoice            = wpinv_get_invoice( $invoice_id );
990
+    $invoice            = wpinv_get_invoice($invoice_id);
991 991
     $quantities_enabled = wpinv_item_quantities_enabled();
992 992
     $use_taxes          = wpinv_use_taxes();
993
-    if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
993
+    if (!$use_taxes && (float)$invoice->get_tax() > 0) {
994 994
         $use_taxes = true;
995 995
     }
996 996
     $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
997
-    $tax_label           = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
998
-    $tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
997
+    $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
998
+    $tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
999 999
 
1000 1000
     $cart_details       = $invoice->get_cart_details();
1001 1001
     $ajax_cart_details  = $cart_details;
@@ -1004,66 +1004,66 @@  discard block
 block discarded – undo
1004 1004
     <table class="table table-sm table-bordered table-responsive">
1005 1005
         <thead>
1006 1006
             <tr>
1007
-                <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th>
1008
-                <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th>
1007
+                <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th>
1008
+                <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th>
1009 1009
                 <?php if ($quantities_enabled) { ?>
1010
-                    <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th>
1010
+                    <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th>
1011 1011
                 <?php } ?>
1012 1012
                 <?php if ($use_taxes && !$zero_tax) { ?>
1013 1013
                     <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th>
1014 1014
                 <?php } ?>
1015
-                <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th>
1015
+                <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th>
1016 1016
             </tr>
1017 1017
         </thead>
1018 1018
         <tbody>
1019 1019
         <?php 
1020
-            if ( !empty( $cart_details ) ) {
1021
-                do_action( 'wpinv_display_line_items_start', $invoice );
1020
+            if (!empty($cart_details)) {
1021
+                do_action('wpinv_display_line_items_start', $invoice);
1022 1022
 
1023 1023
                 $count = 0;
1024 1024
                 $cols  = 3;
1025
-                foreach ( $cart_details as $key => $cart_item ) {
1026
-                    $item_id    = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : '';
1027
-                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0;
1028
-                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0;
1029
-                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
1025
+                foreach ($cart_details as $key => $cart_item) {
1026
+                    $item_id    = !empty($cart_item['id']) ? absint($cart_item['id']) : '';
1027
+                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0;
1028
+                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0;
1029
+                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
1030 1030
 
1031
-                    $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1031
+                    $item       = $item_id ? new WPInv_Item($item_id) : NULL;
1032 1032
                     $summary    = '';
1033 1033
                     $cols       = 3;
1034
-                    if ( !empty($item) ) {
1034
+                    if (!empty($item)) {
1035 1035
                         $item_name  = $item->get_name();
1036 1036
                         $summary    = $item->get_summary();
1037 1037
                     }
1038
-                    $item_name  = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1038
+                    $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1039 1039
 
1040
-                    $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice );
1040
+                    $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice);
1041 1041
 
1042 1042
                     $item_tax       = '';
1043 1043
                     $tax_rate       = '';
1044
-                    if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1045
-                        $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1046
-                        $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1047
-                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1044
+                    if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1045
+                        $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1046
+                        $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1047
+                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : '';
1048 1048
                         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : '';
1049 1049
                     }
1050 1050
 
1051 1051
                     $line_item_tax = $item_tax . $tax_rate;
1052 1052
 
1053
-                    if ( $line_item_tax === '' ) {
1053
+                    if ($line_item_tax === '') {
1054 1054
                         $line_item_tax = 0; // Zero tax
1055 1055
                     }
1056 1056
 
1057
-                    $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols );
1057
+                    $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols);
1058 1058
 
1059
-                    $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">';
1060
-                        $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item );
1061
-                        if ( $summary !== '' ) {
1062
-                            $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>';
1059
+                    $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">';
1060
+                        $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item);
1061
+                        if ($summary !== '') {
1062
+                            $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>';
1063 1063
                         }
1064 1064
                         $line_item .= '</td>';
1065 1065
 
1066
-                        $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>';
1066
+                        $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>';
1067 1067
                         if ($quantities_enabled) {
1068 1068
                             $cols++;
1069 1069
                             $line_item .= '<td class="qty">' . $quantity . '</td>';
@@ -1072,55 +1072,55 @@  discard block
 block discarded – undo
1072 1072
                             $cols++;
1073 1073
                             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1074 1074
                         }
1075
-                        $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>';
1075
+                        $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>';
1076 1076
                     $line_item .= '</tr>';
1077 1077
 
1078
-                    echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols );
1078
+                    echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols);
1079 1079
 
1080 1080
                     $count++;
1081 1081
                 }
1082 1082
 
1083
-                do_action( 'wpinv_display_before_subtotal', $invoice, $cols );
1083
+                do_action('wpinv_display_before_subtotal', $invoice, $cols);
1084 1084
                 ?>
1085 1085
                 <tr class="row-sub-total row_odd">
1086
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1087
-                    <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1086
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1087
+                    <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1088 1088
                 </tr>
1089 1089
                 <?php
1090
-                do_action( 'wpinv_display_after_subtotal', $invoice, $cols );
1090
+                do_action('wpinv_display_after_subtotal', $invoice, $cols);
1091 1091
                 
1092
-                if ( wpinv_discount( $invoice_id, false ) > 0 ) {
1093
-                    do_action( 'wpinv_display_before_discount', $invoice, $cols );
1092
+                if (wpinv_discount($invoice_id, false) > 0) {
1093
+                    do_action('wpinv_display_before_discount', $invoice, $cols);
1094 1094
                     ?>
1095 1095
                         <tr class="row-discount">
1096
-                            <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td>
1097
-                            <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1096
+                            <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td>
1097
+                            <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1098 1098
                         </tr>
1099 1099
                     <?php
1100
-                    do_action( 'wpinv_display_after_discount', $invoice, $cols );
1100
+                    do_action('wpinv_display_after_discount', $invoice, $cols);
1101 1101
                 }
1102 1102
 
1103
-                if ( $use_taxes ) {
1104
-                    do_action( 'wpinv_display_before_tax', $invoice, $cols );
1103
+                if ($use_taxes) {
1104
+                    do_action('wpinv_display_before_tax', $invoice, $cols);
1105 1105
                     ?>
1106 1106
                     <tr class="row-tax">
1107
-                        <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td>
1108
-                        <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1107
+                        <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td>
1108
+                        <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1109 1109
                     </tr>
1110 1110
                     <?php
1111
-                    do_action( 'wpinv_display_after_tax', $invoice, $cols );
1111
+                    do_action('wpinv_display_after_tax', $invoice, $cols);
1112 1112
                 }
1113 1113
 
1114
-                do_action( 'wpinv_display_before_total', $invoice, $cols );
1114
+                do_action('wpinv_display_before_total', $invoice, $cols);
1115 1115
                 ?>
1116 1116
                 <tr class="table-active row-total">
1117
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1118
-                    <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1117
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1118
+                    <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1119 1119
                 </tr>
1120 1120
                 <?php
1121
-                do_action( 'wpinv_display_after_total', $invoice, $cols );
1121
+                do_action('wpinv_display_after_total', $invoice, $cols);
1122 1122
 
1123
-                do_action( 'wpinv_display_line_end', $invoice, $cols );
1123
+                do_action('wpinv_display_line_end', $invoice, $cols);
1124 1124
             }
1125 1125
         ?>
1126 1126
         </tbody>
@@ -1129,35 +1129,35 @@  discard block
 block discarded – undo
1129 1129
     echo ob_get_clean();
1130 1130
 }
1131 1131
 
1132
-function wpinv_display_invoice_totals( $invoice_id = 0 ) {
1132
+function wpinv_display_invoice_totals($invoice_id = 0) {
1133 1133
     $use_taxes = wpinv_use_taxes();
1134 1134
 
1135
-    do_action( 'wpinv_before_display_totals_table', $invoice_id ); 
1135
+    do_action('wpinv_before_display_totals_table', $invoice_id); 
1136 1136
     ?>
1137 1137
     <table class="table table-sm table-bordered table-responsive">
1138 1138
         <tbody>
1139
-            <?php do_action( 'wpinv_before_display_totals' ); ?>
1139
+            <?php do_action('wpinv_before_display_totals'); ?>
1140 1140
             <tr class="row-sub-total">
1141
-                <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td>
1142
-                <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1141
+                <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td>
1142
+                <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1143 1143
             </tr>
1144
-            <?php do_action( 'wpinv_after_display_totals' ); ?>
1145
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
1144
+            <?php do_action('wpinv_after_display_totals'); ?>
1145
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
1146 1146
                 <tr class="row-discount">
1147
-                    <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td>
1148
-                    <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1147
+                    <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td>
1148
+                    <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1149 1149
                 </tr>
1150
-            <?php do_action( 'wpinv_after_display_discount' ); ?>
1150
+            <?php do_action('wpinv_after_display_discount'); ?>
1151 1151
             <?php } ?>
1152
-            <?php if ( $use_taxes ) { ?>
1152
+            <?php if ($use_taxes) { ?>
1153 1153
             <tr class="row-tax">
1154
-                <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td>
1155
-                <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1154
+                <td class="rate"><?php _e('Tax', 'invoicing'); ?></td>
1155
+                <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1156 1156
             </tr>
1157
-            <?php do_action( 'wpinv_after_display_tax' ); ?>
1157
+            <?php do_action('wpinv_after_display_tax'); ?>
1158 1158
             <?php } ?>
1159
-            <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?>
1160
-                <?php foreach ( $fees as $fee ) { ?>
1159
+            <?php if ($fees = wpinv_get_fees($invoice_id)) { ?>
1160
+                <?php foreach ($fees as $fee) { ?>
1161 1161
                     <tr class="row-fee">
1162 1162
                         <td class="rate"><?php echo $fee['label']; ?></td>
1163 1163
                         <td class="total"><?php echo $fee['amount_display']; ?></td>
@@ -1165,82 +1165,82 @@  discard block
 block discarded – undo
1165 1165
                 <?php } ?>
1166 1166
             <?php } ?>
1167 1167
             <tr class="table-active row-total">
1168
-                <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td>
1169
-                <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1168
+                <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td>
1169
+                <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1170 1170
             </tr>
1171
-            <?php do_action( 'wpinv_after_totals' ); ?>
1171
+            <?php do_action('wpinv_after_totals'); ?>
1172 1172
         </tbody>
1173 1173
 
1174 1174
     </table>
1175 1175
 
1176
-    <?php do_action( 'wpinv_after_totals_table' );
1176
+    <?php do_action('wpinv_after_totals_table');
1177 1177
 }
1178 1178
 
1179
-function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) {
1180
-    $invoice = wpinv_get_invoice( $invoice_id );
1179
+function wpinv_display_payments_info($invoice_id = 0, $echo = true) {
1180
+    $invoice = wpinv_get_invoice($invoice_id);
1181 1181
 
1182 1182
     ob_start();
1183
-    do_action( 'wpinv_before_display_payments_info', $invoice_id );
1184
-    if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) {
1183
+    do_action('wpinv_before_display_payments_info', $invoice_id);
1184
+    if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) {
1185 1185
         ?>
1186 1186
         <div class="wpi-payment-info">
1187
-            <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p>
1188
-            <?php if ( $gateway_title ) { ?>
1189
-            <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p>
1187
+            <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p>
1188
+            <?php if ($gateway_title) { ?>
1189
+            <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p>
1190 1190
             <?php } ?>
1191 1191
         </div>
1192 1192
         <?php
1193 1193
     }
1194
-    do_action( 'wpinv_after_display_payments_info', $invoice_id );
1194
+    do_action('wpinv_after_display_payments_info', $invoice_id);
1195 1195
     $outout = ob_get_clean();
1196 1196
 
1197
-    if ( $echo ) {
1197
+    if ($echo) {
1198 1198
         echo $outout;
1199 1199
     } else {
1200 1200
         return $outout;
1201 1201
     }
1202 1202
 }
1203 1203
 
1204
-function wpinv_display_style( $invoice ) {
1205
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION );
1204
+function wpinv_display_style($invoice) {
1205
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION);
1206 1206
 
1207
-    wp_print_styles( 'open-sans' );
1208
-    wp_print_styles( 'wpinv-single-style' );
1207
+    wp_print_styles('open-sans');
1208
+    wp_print_styles('wpinv-single-style');
1209 1209
 
1210 1210
     $custom_css = wpinv_get_option('template_custom_css');
1211
-    if(isset($custom_css) && !empty($custom_css)){
1212
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1213
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1211
+    if (isset($custom_css) && !empty($custom_css)) {
1212
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1213
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1214 1214
         echo '<style type="text/css">';
1215 1215
         echo $custom_css;
1216 1216
         echo '</style>';
1217 1217
     }
1218 1218
 }
1219
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1220
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1219
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1220
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1221 1221
 
1222 1222
 function wpinv_checkout_billing_details() {
1223 1223
     $invoice_id = (int)wpinv_get_invoice_cart_id();
1224 1224
     if (empty($invoice_id)) {
1225
-        wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ );
1225
+        wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__);
1226 1226
         return null;
1227 1227
     }
1228 1228
 
1229
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
1229
+    $invoice = wpinv_get_invoice_cart($invoice_id);
1230 1230
     if (empty($invoice)) {
1231
-        wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ );
1231
+        wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__);
1232 1232
         return null;
1233 1233
     }
1234 1234
     $user_id        = $invoice->get_user_id();
1235 1235
     $user_info      = $invoice->get_user_info();
1236
-    $address_info   = wpinv_get_user_address( $user_id );
1236
+    $address_info   = wpinv_get_user_address($user_id);
1237 1237
 
1238
-    if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) {
1238
+    if (empty($user_info['first_name']) && !empty($user_info['first_name'])) {
1239 1239
         $user_info['first_name'] = $user_info['first_name'];
1240 1240
         $user_info['last_name'] = $user_info['last_name'];
1241 1241
     }
1242 1242
 
1243
-    if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) {
1243
+    if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) {
1244 1244
         $user_info['country']   = $address_info['country'];
1245 1245
         $user_info['state']     = $address_info['state'];
1246 1246
         $user_info['city']      = $address_info['city'];
@@ -1256,98 +1256,98 @@  discard block
 block discarded – undo
1256 1256
         'address'
1257 1257
     );
1258 1258
 
1259
-    foreach ( $address_fields as $field ) {
1260
-        if ( empty( $user_info[$field] ) ) {
1259
+    foreach ($address_fields as $field) {
1260
+        if (empty($user_info[$field])) {
1261 1261
             $user_info[$field] = $address_info[$field];
1262 1262
         }
1263 1263
     }
1264 1264
 
1265
-    return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice );
1265
+    return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice);
1266 1266
 }
1267 1267
 
1268 1268
 function wpinv_admin_get_line_items($invoice = array()) {
1269 1269
     $item_quantities    = wpinv_item_quantities_enabled();
1270 1270
     $use_taxes          = wpinv_use_taxes();
1271 1271
 
1272
-    if ( empty( $invoice ) ) {
1272
+    if (empty($invoice)) {
1273 1273
         return NULL;
1274 1274
     }
1275 1275
 
1276 1276
     $cart_items = $invoice->get_cart_details();
1277
-    if ( empty( $cart_items ) ) {
1277
+    if (empty($cart_items)) {
1278 1278
         return NULL;
1279 1279
     }
1280 1280
     ob_start();
1281 1281
 
1282
-    do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice );
1282
+    do_action('wpinv_admin_before_line_items', $cart_items, $invoice);
1283 1283
 
1284 1284
     $count = 0;
1285
-    foreach ( $cart_items as $key => $cart_item ) {
1285
+    foreach ($cart_items as $key => $cart_item) {
1286 1286
         $item_id    = $cart_item['id'];
1287
-        $wpi_item   = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL;
1287
+        $wpi_item   = $item_id > 0 ? new WPInv_Item($item_id) : NULL;
1288 1288
 
1289 1289
         if (empty($wpi_item)) {
1290 1290
             continue;
1291 1291
         }
1292 1292
 
1293
-        $item_price     = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() );
1294
-        $quantity       = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1295
-        $item_subtotal  = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() );
1293
+        $item_price     = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency());
1294
+        $quantity       = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1295
+        $item_subtotal  = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency());
1296 1296
         $can_remove     = true;
1297 1297
 
1298
-        $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice );
1298
+        $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice);
1299 1299
 
1300 1300
         $item_tax       = '';
1301 1301
         $tax_rate       = '';
1302
-        if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1303
-            $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1304
-            $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1305
-            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1302
+        if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1303
+            $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1304
+            $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1305
+            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : '';
1306 1306
             $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
1307 1307
         }
1308 1308
         $line_item_tax = $item_tax . $tax_rate;
1309 1309
 
1310
-        if ( $line_item_tax === '' ) {
1310
+        if ($line_item_tax === '') {
1311 1311
             $line_item_tax = 0; // Zero tax
1312 1312
         }
1313 1313
 
1314
-        $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">';
1314
+        $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">';
1315 1315
             $line_item .= '<td class="id">' . $item_id . '</td>';
1316
-            $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item );
1317
-            if ( $summary !== '' ) {
1318
-                $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
1316
+            $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item);
1317
+            if ($summary !== '') {
1318
+                $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
1319 1319
             }
1320 1320
             $line_item .= '</td>';
1321 1321
             $line_item .= '<td class="price">' . $item_price . '</td>';
1322 1322
             
1323
-            if ( $item_quantities ) {
1324
-                if ( count( $cart_items ) == 1 && $quantity <= 1 ) {
1323
+            if ($item_quantities) {
1324
+                if (count($cart_items) == 1 && $quantity <= 1) {
1325 1325
                     $can_remove = false;
1326 1326
                 }
1327 1327
                 $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
1328 1328
             } else {
1329
-                if ( count( $cart_items ) == 1 ) {
1329
+                if (count($cart_items) == 1) {
1330 1330
                     $can_remove = false;
1331 1331
                 }
1332 1332
             }
1333 1333
             $line_item .= '<td class="total">' . $item_subtotal . '</td>';
1334 1334
             
1335
-            if ( $use_taxes ) {
1335
+            if ($use_taxes) {
1336 1336
                 $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1337 1337
             }
1338 1338
             $line_item .= '<td class="action">';
1339
-            if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) {
1339
+            if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) {
1340 1340
                 $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
1341 1341
             }
1342 1342
             $line_item .= '</td>';
1343 1343
         $line_item .= '</tr>';
1344 1344
 
1345
-        echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice );
1345
+        echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice);
1346 1346
 
1347 1347
         $count++;
1348 1348
     } 
1349 1349
 
1350
-    do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice );
1350
+    do_action('wpinv_admin_after_line_items', $cart_items, $invoice);
1351 1351
 
1352 1352
     return ob_get_clean();
1353 1353
 }
@@ -1358,35 +1358,35 @@  discard block
 block discarded – undo
1358 1358
     // Set current invoice id.
1359 1359
     $wpi_checkout_id = wpinv_get_invoice_cart_id();
1360 1360
 
1361
-    $form_action  = esc_url( wpinv_get_checkout_uri() );
1361
+    $form_action = esc_url(wpinv_get_checkout_uri());
1362 1362
 
1363 1363
     ob_start();
1364 1364
         echo '<div id="wpinv_checkout_wrap">';
1365 1365
 
1366
-        if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) {
1366
+        if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) {
1367 1367
             ?>
1368 1368
             <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive">
1369
-                <?php do_action( 'wpinv_before_checkout_form' ); ?>
1369
+                <?php do_action('wpinv_before_checkout_form'); ?>
1370 1370
                 <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST">
1371 1371
                     <?php
1372
-                    do_action( 'wpinv_checkout_form_top' );
1373
-                    do_action( 'wpinv_checkout_billing_info' );
1374
-                    do_action( 'wpinv_checkout_cart' );
1375
-                    do_action( 'wpinv_payment_mode_select'  );
1376
-                    do_action( 'wpinv_checkout_form_bottom' )
1372
+                    do_action('wpinv_checkout_form_top');
1373
+                    do_action('wpinv_checkout_billing_info');
1374
+                    do_action('wpinv_checkout_cart');
1375
+                    do_action('wpinv_payment_mode_select');
1376
+                    do_action('wpinv_checkout_form_bottom')
1377 1377
                     ?>
1378 1378
                 </form>
1379
-                <?php do_action( 'wpinv_after_purchase_form' ); ?>
1379
+                <?php do_action('wpinv_after_purchase_form'); ?>
1380 1380
             </div><!--end #wpinv_checkout_form_wrap-->
1381 1381
         <?php
1382 1382
         } else {
1383
-            do_action( 'wpinv_cart_empty' );
1383
+            do_action('wpinv_cart_empty');
1384 1384
         }
1385 1385
         echo '</div><!--end #wpinv_checkout_wrap-->';
1386 1386
     return ob_get_clean();
1387 1387
 }
1388 1388
 
1389
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1389
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1390 1390
     global $ajax_cart_details;
1391 1391
     $ajax_cart_details = $cart_details;
1392 1392
     /*
@@ -1401,25 +1401,25 @@  discard block
 block discarded – undo
1401 1401
     }
1402 1402
     */
1403 1403
     ob_start();
1404
-    do_action( 'wpinv_before_checkout_cart' );
1404
+    do_action('wpinv_before_checkout_cart');
1405 1405
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1406 1406
         echo '<div id="wpinv_checkout_cart_wrap">';
1407
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1407
+            wpinv_get_template_part('wpinv-checkout-cart');
1408 1408
         echo '</div>';
1409 1409
     echo '</div>';
1410
-    do_action( 'wpinv_after_checkout_cart' );
1410
+    do_action('wpinv_after_checkout_cart');
1411 1411
     $content = ob_get_clean();
1412 1412
     
1413
-    if ( $echo ) {
1413
+    if ($echo) {
1414 1414
         echo $content;
1415 1415
     } else {
1416 1416
         return $content;
1417 1417
     }
1418 1418
 }
1419
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1419
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1420 1420
 
1421 1421
 function wpinv_empty_cart_message() {
1422
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1422
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1423 1423
 }
1424 1424
 
1425 1425
 /**
@@ -1431,91 +1431,91 @@  discard block
 block discarded – undo
1431 1431
 function wpinv_empty_checkout_cart() {
1432 1432
 	echo wpinv_empty_cart_message();
1433 1433
 }
1434
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1434
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1435 1435
 
1436 1436
 function wpinv_save_cart_button() {
1437
-    if ( wpinv_is_cart_saving_disabled() )
1437
+    if (wpinv_is_cart_saving_disabled())
1438 1438
         return;
1439 1439
 ?>
1440
-    <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a>
1440
+    <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url(add_query_arg('wpi_action', 'save_cart')); ?>"><?php _e('Save Cart', 'invoicing'); ?></a>
1441 1441
 <?php
1442 1442
 }
1443 1443
 
1444 1444
 function wpinv_update_cart_button() {
1445
-    if ( !wpinv_item_quantities_enabled() )
1445
+    if (!wpinv_item_quantities_enabled())
1446 1446
         return;
1447 1447
 ?>
1448
-    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1448
+    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/>
1449 1449
     <input type="hidden" name="wpi_action" value="update_cart"/>
1450 1450
 <?php
1451 1451
 }
1452 1452
 
1453 1453
 function wpinv_checkout_cart_columns() {
1454 1454
     $default = 3;
1455
-    if ( wpinv_item_quantities_enabled() ) {
1455
+    if (wpinv_item_quantities_enabled()) {
1456 1456
         $default++;
1457 1457
     }
1458 1458
     
1459
-    if ( wpinv_use_taxes() ) {
1459
+    if (wpinv_use_taxes()) {
1460 1460
         $default++;
1461 1461
     }
1462 1462
 
1463
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1463
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1464 1464
 }
1465 1465
 
1466 1466
 function wpinv_display_cart_messages() {
1467 1467
     global $wpi_session;
1468 1468
 
1469
-    $messages = $wpi_session->get( 'wpinv_cart_messages' );
1469
+    $messages = $wpi_session->get('wpinv_cart_messages');
1470 1470
 
1471
-    if ( $messages ) {
1472
-        foreach ( $messages as $message_id => $message ) {
1471
+    if ($messages) {
1472
+        foreach ($messages as $message_id => $message) {
1473 1473
             // Try and detect what type of message this is
1474
-            if ( strpos( strtolower( $message ), 'error' ) ) {
1474
+            if (strpos(strtolower($message), 'error')) {
1475 1475
                 $type = 'error';
1476
-            } elseif ( strpos( strtolower( $message ), 'success' ) ) {
1476
+            } elseif (strpos(strtolower($message), 'success')) {
1477 1477
                 $type = 'success';
1478 1478
             } else {
1479 1479
                 $type = 'info';
1480 1480
             }
1481 1481
 
1482
-            $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) );
1482
+            $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type));
1483 1483
 
1484
-            echo '<div class="' . implode( ' ', $classes ) . '">';
1484
+            echo '<div class="' . implode(' ', $classes) . '">';
1485 1485
                 // Loop message codes and display messages
1486 1486
                     echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>';
1487 1487
             echo '</div>';
1488 1488
         }
1489 1489
 
1490 1490
         // Remove all of the cart saving messages
1491
-        $wpi_session->set( 'wpinv_cart_messages', null );
1491
+        $wpi_session->set('wpinv_cart_messages', null);
1492 1492
     }
1493 1493
 }
1494
-add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' );
1494
+add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages');
1495 1495
 
1496 1496
 function wpinv_discount_field() {
1497
-    if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) {
1497
+    if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) {
1498 1498
         return; // Only show before a payment method has been selected if ajax is disabled
1499 1499
     }
1500 1500
 
1501
-    if ( !wpinv_is_checkout() ) {
1501
+    if (!wpinv_is_checkout()) {
1502 1502
         return;
1503 1503
     }
1504 1504
 
1505
-    if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) {
1505
+    if (wpinv_has_active_discounts() && wpinv_get_cart_total()) {
1506 1506
     ?>
1507 1507
     <div id="wpinv-discount-field" class="panel panel-default">
1508 1508
         <div class="panel-body">
1509 1509
             <p>
1510
-                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label>
1511
-                <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span>
1510
+                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label>
1511
+                <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span>
1512 1512
             </p>
1513 1513
             <div class="form-group row">
1514 1514
                 <div class="col-sm-4">
1515
-                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/>
1515
+                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/>
1516 1516
                 </div>
1517 1517
                 <div class="col-sm-3">
1518
-                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button>
1518
+                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button>
1519 1519
                 </div>
1520 1520
                 <div style="clear:both"></div>
1521 1521
                 <div class="col-sm-12 wpinv-discount-msg">
@@ -1528,10 +1528,10 @@  discard block
 block discarded – undo
1528 1528
 <?php
1529 1529
     }
1530 1530
 }
1531
-add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 );
1531
+add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10);
1532 1532
 
1533 1533
 function wpinv_agree_to_terms_js() {
1534
-    if ( wpinv_get_option( 'show_agree_to_terms', false ) ) {
1534
+    if (wpinv_get_option('show_agree_to_terms', false)) {
1535 1535
 ?>
1536 1536
 <script type="text/javascript">
1537 1537
     jQuery(document).ready(function($){
@@ -1546,126 +1546,126 @@  discard block
 block discarded – undo
1546 1546
 <?php
1547 1547
     }
1548 1548
 }
1549
-add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' );
1549
+add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js');
1550 1550
 
1551 1551
 function wpinv_payment_mode_select() {
1552
-    $gateways = wpinv_get_enabled_payment_gateways( true );
1553
-    $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
1552
+    $gateways = wpinv_get_enabled_payment_gateways(true);
1553
+    $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
1554 1554
     $page_URL = wpinv_get_current_page_url();
1555
-    $invoice = wpinv_get_invoice( 0, true );
1555
+    $invoice = wpinv_get_invoice(0, true);
1556 1556
 
1557 1557
     do_action('wpinv_payment_mode_top');
1558 1558
     $invoice_id = (int)$invoice->ID;
1559
-    $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1559
+    $chosen_gateway = wpinv_get_chosen_gateway($invoice_id);
1560 1560
     ?>
1561
-    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>>
1562
-            <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?>
1561
+    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>>
1562
+            <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?>
1563 1563
             <div id="wpinv-payment-mode-wrap" class="panel panel-default">
1564
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div>
1564
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div>
1565 1565
                 <div class="panel-body list-group wpi-payment_methods">
1566 1566
                     <?php
1567
-                    do_action( 'wpinv_payment_mode_before_gateways' );
1567
+                    do_action('wpinv_payment_mode_before_gateways');
1568 1568
 
1569
-                    if ( !empty( $gateways ) ) {
1570
-                        foreach ( $gateways as $gateway_id => $gateway ) {
1571
-                            $checked = checked( $gateway_id, $chosen_gateway, false );
1572
-                            $button_label = wpinv_get_gateway_button_label( $gateway_id );
1573
-                            $description = wpinv_get_gateway_description( $gateway_id );
1569
+                    if (!empty($gateways)) {
1570
+                        foreach ($gateways as $gateway_id => $gateway) {
1571
+                            $checked = checked($gateway_id, $chosen_gateway, false);
1572
+                            $button_label = wpinv_get_gateway_button_label($gateway_id);
1573
+                            $description = wpinv_get_gateway_description($gateway_id);
1574 1574
                             ?>
1575 1575
                             <div class="list-group-item">
1576 1576
                                 <div class="radio">
1577
-                                    <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label>
1577
+                                    <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway['checkout_label']); ?></label>
1578 1578
                                 </div>
1579
-                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert">
1580
-                                    <?php if ( !empty( $description ) ) { ?>
1581
-                                        <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div>
1579
+                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert">
1580
+                                    <?php if (!empty($description)) { ?>
1581
+                                        <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div>
1582 1582
                                     <?php } ?>
1583
-                                    <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?>
1583
+                                    <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?>
1584 1584
                                 </div>
1585 1585
                             </div>
1586 1586
                             <?php
1587 1587
                         }
1588 1588
                     } else {
1589
-                        echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>';
1589
+                        echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>';
1590 1590
                     }
1591 1591
 
1592
-                    do_action( 'wpinv_payment_mode_after_gateways' );
1592
+                    do_action('wpinv_payment_mode_after_gateways');
1593 1593
                     ?>
1594 1594
                 </div>
1595 1595
             </div>
1596
-            <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?>
1596
+            <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?>
1597 1597
     </div>
1598 1598
     <?php
1599 1599
     do_action('wpinv_payment_mode_bottom');
1600 1600
 }
1601
-add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' );
1601
+add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select');
1602 1602
 
1603 1603
 function wpinv_checkout_billing_info() {
1604
-    if ( wpinv_is_checkout() ) {
1604
+    if (wpinv_is_checkout()) {
1605 1605
         $logged_in          = is_user_logged_in();
1606 1606
         $billing_details    = wpinv_checkout_billing_details();
1607
-        $selected_country   = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country();
1607
+        $selected_country   = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country();
1608 1608
         ?>
1609 1609
         <div id="wpinv-fields" class="clearfix">
1610 1610
             <div id="wpi-billing" class="wpi-billing clearfix panel panel-default">
1611
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div>
1611
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div>
1612 1612
                 <div id="wpinv-fields-box" class="panel-body">
1613
-                    <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?>
1613
+                    <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?>
1614 1614
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1615
-                        <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1615
+                        <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1616 1616
                         <?php
1617
-                        echo wpinv_html_text( array(
1617
+                        echo wpinv_html_text(array(
1618 1618
                                 'id'            => 'wpinv_first_name',
1619 1619
                                 'name'          => 'wpinv_first_name',
1620 1620
                                 'value'         => $billing_details['first_name'],
1621 1621
                                 'class'         => 'wpi-input form-control',
1622
-                                'placeholder'   => __( 'First name', 'invoicing' ),
1623
-                                'required'      => (bool)wpinv_get_option( 'fname_mandatory' ),
1624
-                            ) );
1622
+                                'placeholder'   => __('First name', 'invoicing'),
1623
+                                'required'      => (bool)wpinv_get_option('fname_mandatory'),
1624
+                            ));
1625 1625
                         ?>
1626 1626
                     </p>
1627 1627
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1628
-                        <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1628
+                        <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1629 1629
                         <?php
1630
-                        echo wpinv_html_text( array(
1630
+                        echo wpinv_html_text(array(
1631 1631
                                 'id'            => 'wpinv_last_name',
1632 1632
                                 'name'          => 'wpinv_last_name',
1633 1633
                                 'value'         => $billing_details['last_name'],
1634 1634
                                 'class'         => 'wpi-input form-control',
1635
-                                'placeholder'   => __( 'Last name', 'invoicing' ),
1636
-                                'required'      => (bool)wpinv_get_option( 'lname_mandatory' ),
1637
-                            ) );
1635
+                                'placeholder'   => __('Last name', 'invoicing'),
1636
+                                'required'      => (bool)wpinv_get_option('lname_mandatory'),
1637
+                            ));
1638 1638
                         ?>
1639 1639
                     </p>
1640 1640
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1641
-                        <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1641
+                        <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1642 1642
                         <?php
1643
-                        echo wpinv_html_text( array(
1643
+                        echo wpinv_html_text(array(
1644 1644
                                 'id'            => 'wpinv_address',
1645 1645
                                 'name'          => 'wpinv_address',
1646 1646
                                 'value'         => $billing_details['address'],
1647 1647
                                 'class'         => 'wpi-input form-control',
1648
-                                'placeholder'   => __( 'Address', 'invoicing' ),
1649
-                                'required'      => (bool)wpinv_get_option( 'address_mandatory' ),
1650
-                            ) );
1648
+                                'placeholder'   => __('Address', 'invoicing'),
1649
+                                'required'      => (bool)wpinv_get_option('address_mandatory'),
1650
+                            ));
1651 1651
                         ?>
1652 1652
                     </p>
1653 1653
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1654
-                        <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1654
+                        <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1655 1655
                         <?php
1656
-                        echo wpinv_html_text( array(
1656
+                        echo wpinv_html_text(array(
1657 1657
                                 'id'            => 'wpinv_city',
1658 1658
                                 'name'          => 'wpinv_city',
1659 1659
                                 'value'         => $billing_details['city'],
1660 1660
                                 'class'         => 'wpi-input form-control',
1661
-                                'placeholder'   => __( 'City', 'invoicing' ),
1662
-                                'required'      => (bool)wpinv_get_option( 'city_mandatory' ),
1663
-                            ) );
1661
+                                'placeholder'   => __('City', 'invoicing'),
1662
+                                'required'      => (bool)wpinv_get_option('city_mandatory'),
1663
+                            ));
1664 1664
                         ?>
1665 1665
                     </p>
1666 1666
                     <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf">
1667
-                        <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1668
-                        <?php echo wpinv_html_select( array(
1667
+                        <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1668
+                        <?php echo wpinv_html_select(array(
1669 1669
                             'options'          => wpinv_get_country_list(),
1670 1670
                             'name'             => 'wpinv_country',
1671 1671
                             'id'               => 'wpinv_country',
@@ -1673,16 +1673,16 @@  discard block
 block discarded – undo
1673 1673
                             'show_option_all'  => false,
1674 1674
                             'show_option_none' => false,
1675 1675
                             'class'            => 'wpi-input form-control',
1676
-                            'placeholder'      => __( 'Choose a country', 'invoicing' ),
1677
-                            'required'         => (bool)wpinv_get_option( 'country_mandatory' ),
1678
-                        ) ); ?>
1676
+                            'placeholder'      => __('Choose a country', 'invoicing'),
1677
+                            'required'         => (bool)wpinv_get_option('country_mandatory'),
1678
+                        )); ?>
1679 1679
                     </p>
1680 1680
                     <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll">
1681
-                        <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1681
+                        <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1682 1682
                         <?php
1683
-                        $states = wpinv_get_country_states( $selected_country );
1684
-                        if( !empty( $states ) ) {
1685
-                            echo wpinv_html_select( array(
1683
+                        $states = wpinv_get_country_states($selected_country);
1684
+                        if (!empty($states)) {
1685
+                            echo wpinv_html_select(array(
1686 1686
                                 'options'          => $states,
1687 1687
                                 'name'             => 'wpinv_state',
1688 1688
                                 'id'               => 'wpinv_state',
@@ -1690,61 +1690,61 @@  discard block
 block discarded – undo
1690 1690
                                 'show_option_all'  => false,
1691 1691
                                 'show_option_none' => false,
1692 1692
                                 'class'            => 'wpi-input form-control',
1693
-                                'placeholder'      => __( 'Choose a state', 'invoicing' ),
1694
-                                'required'         => (bool)wpinv_get_option( 'state_mandatory' ),
1695
-                            ) );
1693
+                                'placeholder'      => __('Choose a state', 'invoicing'),
1694
+                                'required'         => (bool)wpinv_get_option('state_mandatory'),
1695
+                            ));
1696 1696
                         } else {
1697
-                            echo wpinv_html_text( array(
1697
+                            echo wpinv_html_text(array(
1698 1698
                                 'name'          => 'wpinv_state',
1699 1699
                                 'value'         => $billing_details['state'],
1700 1700
                                 'id'            => 'wpinv_state',
1701 1701
                                 'class'         => 'wpi-input form-control',
1702
-                                'placeholder'   => __( 'State / Province', 'invoicing' ),
1703
-                                'required'      => (bool)wpinv_get_option( 'state_mandatory' ),
1704
-                            ) );
1702
+                                'placeholder'   => __('State / Province', 'invoicing'),
1703
+                                'required'      => (bool)wpinv_get_option('state_mandatory'),
1704
+                            ));
1705 1705
                         }
1706 1706
                         ?>
1707 1707
                     </p>
1708 1708
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1709
-                        <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1709
+                        <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1710 1710
                         <?php
1711
-                        echo wpinv_html_text( array(
1711
+                        echo wpinv_html_text(array(
1712 1712
                                 'name'          => 'wpinv_zip',
1713 1713
                                 'value'         => $billing_details['zip'],
1714 1714
                                 'id'            => 'wpinv_zip',
1715 1715
                                 'class'         => 'wpi-input form-control',
1716
-                                'placeholder'   => __( 'ZIP / Postcode', 'invoicing' ),
1717
-                                'required'      => (bool)wpinv_get_option( 'zip_mandatory' ),
1718
-                            ) );
1716
+                                'placeholder'   => __('ZIP / Postcode', 'invoicing'),
1717
+                                'required'      => (bool)wpinv_get_option('zip_mandatory'),
1718
+                            ));
1719 1719
                         ?>
1720 1720
                     </p>
1721 1721
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1722
-                        <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1722
+                        <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1723 1723
                         <?php
1724
-                        echo wpinv_html_text( array(
1724
+                        echo wpinv_html_text(array(
1725 1725
                                 'id'            => 'wpinv_phone',
1726 1726
                                 'name'          => 'wpinv_phone',
1727 1727
                                 'value'         => $billing_details['phone'],
1728 1728
                                 'class'         => 'wpi-input form-control',
1729
-                                'placeholder'   => __( 'Phone', 'invoicing' ),
1730
-                                'required'      => (bool)wpinv_get_option( 'phone_mandatory' ),
1731
-                            ) );
1729
+                                'placeholder'   => __('Phone', 'invoicing'),
1730
+                                'required'      => (bool)wpinv_get_option('phone_mandatory'),
1731
+                            ));
1732 1732
                         ?>
1733 1733
                     </p>
1734
-                    <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?>
1734
+                    <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?>
1735 1735
                     <div class="clearfix"></div>
1736 1736
                 </div>
1737 1737
             </div>
1738
-            <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?>
1738
+            <?php do_action('wpinv_after_billing_fields', $billing_details); ?>
1739 1739
         </div>
1740 1740
         <?php
1741 1741
     }
1742 1742
 }
1743
-add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' );
1743
+add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info');
1744 1744
 
1745 1745
 function wpinv_checkout_hidden_fields() {
1746 1746
 ?>
1747
-    <?php if ( is_user_logged_in() ) { ?>
1747
+    <?php if (is_user_logged_in()) { ?>
1748 1748
     <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/>
1749 1749
     <?php } ?>
1750 1750
     <input type="hidden" name="wpi_action" value="payment" />
@@ -1754,9 +1754,9 @@  discard block
 block discarded – undo
1754 1754
 function wpinv_checkout_button_purchase() {
1755 1755
     ob_start();
1756 1756
 ?>
1757
-    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/>
1757
+    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/>
1758 1758
 <?php
1759
-    return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() );
1759
+    return apply_filters('wpinv_checkout_button_purchase', ob_get_clean());
1760 1760
 }
1761 1761
 
1762 1762
 function wpinv_checkout_total() {
@@ -1765,116 +1765,116 @@  discard block
 block discarded – undo
1765 1765
 <div id="wpinv_checkout_total" class="panel panel-info">
1766 1766
     <div class="panel-body">
1767 1767
     <?php
1768
-    do_action( 'wpinv_purchase_form_before_checkout_total' );
1768
+    do_action('wpinv_purchase_form_before_checkout_total');
1769 1769
     ?>
1770
-    <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span>
1770
+    <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span>
1771 1771
     <?php
1772
-    do_action( 'wpinv_purchase_form_after_checkout_total' );
1772
+    do_action('wpinv_purchase_form_after_checkout_total');
1773 1773
     ?>
1774 1774
     </div>
1775 1775
 </div>
1776 1776
 <?php
1777 1777
 }
1778
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 );
1778
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998);
1779 1779
 
1780 1780
 function wpinv_checkout_accept_tandc() {
1781
-    $page = wpinv_get_option( 'tandc_page' );
1781
+    $page = wpinv_get_option('tandc_page');
1782 1782
     ?>
1783 1783
     <div id="wpinv_checkout_tandc" class="panel panel-success">
1784 1784
         <div class="panel-body">
1785 1785
             <?php echo wpinv_get_policy_text(); ?>
1786 1786
             <?php
1787
-            if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){
1788
-                $terms_link = esc_url( get_permalink( $page ) );
1787
+            if (isset($page) && (int)$page > 0 && apply_filters('wpinv_checkout_show_terms', true)) {
1788
+                $terms_link = esc_url(get_permalink($page));
1789 1789
                 ?>
1790 1790
                 <label class="">
1791
-                    <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I&rsquo;ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms &amp; conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span>
1791
+                    <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I&rsquo;ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms &amp; conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span>
1792 1792
                 </label>
1793 1793
             <?php } ?>
1794 1794
         </div>
1795 1795
     </div>
1796 1796
     <?php
1797 1797
 }
1798
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 );
1798
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995);
1799 1799
 
1800 1800
 function wpinv_checkout_submit() {
1801 1801
 ?>
1802 1802
 <div id="wpinv_purchase_submit" class="panel panel-success">
1803 1803
     <div class="panel-body text-center">
1804 1804
     <?php
1805
-    do_action( 'wpinv_purchase_form_before_submit' );
1805
+    do_action('wpinv_purchase_form_before_submit');
1806 1806
     wpinv_checkout_hidden_fields();
1807 1807
     echo wpinv_checkout_button_purchase();
1808
-    do_action( 'wpinv_purchase_form_after_submit' );
1808
+    do_action('wpinv_purchase_form_after_submit');
1809 1809
     ?>
1810 1810
     </div>
1811 1811
 </div>
1812 1812
 <?php
1813 1813
 }
1814
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 );
1814
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999);
1815 1815
 
1816
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1817
-    $invoice = wpinv_get_invoice( $invoice_id );
1816
+function wpinv_receipt_billing_address($invoice_id = 0) {
1817
+    $invoice = wpinv_get_invoice($invoice_id);
1818 1818
 
1819
-    if ( empty( $invoice ) ) {
1819
+    if (empty($invoice)) {
1820 1820
         return NULL;
1821 1821
     }
1822 1822
 
1823 1823
     $billing_details = $invoice->get_user_info();
1824 1824
     $address_row = '';
1825
-    if ( $address = $billing_details['address'] ) {
1826
-        $address_row .= wpautop( wp_kses_post( $address ) );
1825
+    if ($address = $billing_details['address']) {
1826
+        $address_row .= wpautop(wp_kses_post($address));
1827 1827
     }
1828 1828
 
1829 1829
     $address_fields = array();
1830
-    if ( !empty( $billing_details['city'] ) ) {
1830
+    if (!empty($billing_details['city'])) {
1831 1831
         $address_fields[] = $billing_details['city'];
1832 1832
     }
1833 1833
 
1834
-    $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : '';
1835
-    if ( !empty( $billing_details['state'] ) ) {
1836
-        $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country );
1834
+    $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : '';
1835
+    if (!empty($billing_details['state'])) {
1836
+        $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country);
1837 1837
     }
1838 1838
 
1839
-    if ( !empty( $billing_country ) ) {
1840
-        $address_fields[] = wpinv_country_name( $billing_country );
1839
+    if (!empty($billing_country)) {
1840
+        $address_fields[] = wpinv_country_name($billing_country);
1841 1841
     }
1842 1842
 
1843
-    if ( !empty( $address_fields ) ) {
1844
-        $address_fields = implode( ", ", $address_fields );
1843
+    if (!empty($address_fields)) {
1844
+        $address_fields = implode(", ", $address_fields);
1845 1845
 
1846
-        if ( !empty( $billing_details['zip'] ) ) {
1846
+        if (!empty($billing_details['zip'])) {
1847 1847
             $address_fields .= ' ' . $billing_details['zip'];
1848 1848
         }
1849 1849
 
1850
-        $address_row .= wpautop( wp_kses_post( $address_fields ) );
1850
+        $address_row .= wpautop(wp_kses_post($address_fields));
1851 1851
     }
1852 1852
     ob_start();
1853 1853
     ?>
1854 1854
     <table class="table table-bordered table-sm wpi-billing-details">
1855 1855
         <tbody>
1856 1856
             <tr class="wpi-receipt-name">
1857
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1858
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1857
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1858
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1859 1859
             </tr>
1860 1860
             <tr class="wpi-receipt-email">
1861
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1862
-                <td><?php echo $billing_details['email'] ;?></td>
1861
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1862
+                <td><?php echo $billing_details['email']; ?></td>
1863 1863
             </tr>
1864
-            <?php if ( $billing_details['company'] ) { ?>
1864
+            <?php if ($billing_details['company']) { ?>
1865 1865
             <tr class="wpi-receipt-company">
1866
-                <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th>
1867
-                <td><?php echo esc_html( $billing_details['company'] ) ;?></td>
1866
+                <th class="text-left"><?php _e('Company', 'invoicing'); ?></th>
1867
+                <td><?php echo esc_html($billing_details['company']); ?></td>
1868 1868
             </tr>
1869 1869
             <?php } ?>
1870 1870
             <tr class="wpi-receipt-address">
1871
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1872
-                <td><?php echo $address_row ;?></td>
1871
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1872
+                <td><?php echo $address_row; ?></td>
1873 1873
             </tr>
1874
-            <?php if ( $billing_details['phone'] ) { ?>
1874
+            <?php if ($billing_details['phone']) { ?>
1875 1875
             <tr class="wpi-receipt-phone">
1876
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1877
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1876
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1877
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1878 1878
             </tr>
1879 1879
             <?php } ?>
1880 1880
         </tbody>
@@ -1882,74 +1882,74 @@  discard block
 block discarded – undo
1882 1882
     <?php
1883 1883
     $output = ob_get_clean();
1884 1884
     
1885
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1885
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1886 1886
 
1887 1887
     echo $output;
1888 1888
 }
1889 1889
 
1890
-function wpinv_filter_success_page_content( $content ) {
1891
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1892
-        if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) {
1893
-            $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content );
1890
+function wpinv_filter_success_page_content($content) {
1891
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1892
+        if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) {
1893
+            $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content);
1894 1894
         }
1895 1895
     }
1896 1896
 
1897 1897
     return $content;
1898 1898
 }
1899
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1899
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1900 1900
 
1901
-function wpinv_receipt_actions( $invoice ) {
1902
-    if ( !empty( $invoice ) ) {
1901
+function wpinv_receipt_actions($invoice) {
1902
+    if (!empty($invoice)) {
1903 1903
         $actions = array();
1904 1904
 
1905
-        if ( wpinv_user_can_view_invoice( $invoice->ID ) ) {
1906
-            $actions['print']   = array(
1907
-                'url'  => $invoice->get_view_url( true ),
1908
-                'name' => __( 'Print Invoice', 'invoicing' ),
1905
+        if (wpinv_user_can_view_invoice($invoice->ID)) {
1906
+            $actions['print'] = array(
1907
+                'url'  => $invoice->get_view_url(true),
1908
+                'name' => __('Print Invoice', 'invoicing'),
1909 1909
                 'class' => 'btn-primary',
1910 1910
             );
1911 1911
         }
1912 1912
 
1913
-        if ( is_user_logged_in() ) {
1913
+        if (is_user_logged_in()) {
1914 1914
             $actions['history'] = array(
1915 1915
                 'url'  => wpinv_get_history_page_uri(),
1916
-                'name' => __( 'Invoice History', 'invoicing' ),
1916
+                'name' => __('Invoice History', 'invoicing'),
1917 1917
                 'class' => 'btn-warning',
1918 1918
             );
1919 1919
         }
1920 1920
 
1921
-        $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice );
1921
+        $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice);
1922 1922
 
1923
-        if ( !empty( $actions ) ) {
1923
+        if (!empty($actions)) {
1924 1924
         ?>
1925 1925
         <div class="wpinv-receipt-actions text-right">
1926
-            <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?>
1927
-            <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a>
1926
+            <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?>
1927
+            <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a>
1928 1928
             <?php } ?>
1929 1929
         </div>
1930 1930
         <?php
1931 1931
         }
1932 1932
     }
1933 1933
 }
1934
-add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 );
1934
+add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1);
1935 1935
 
1936
-function wpinv_invoice_link( $invoice_id ) {
1937
-    $invoice = wpinv_get_invoice( $invoice_id );
1936
+function wpinv_invoice_link($invoice_id) {
1937
+    $invoice = wpinv_get_invoice($invoice_id);
1938 1938
 
1939
-    if ( empty( $invoice ) ) {
1939
+    if (empty($invoice)) {
1940 1940
         return NULL;
1941 1941
     }
1942 1942
 
1943
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1943
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1944 1944
 
1945
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1945
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1946 1946
 }
1947 1947
 
1948
-function wpinv_invoice_subscription_details( $invoice ) {
1949
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1950
-        $subscription = wpinv_get_subscription( $invoice, true );
1948
+function wpinv_invoice_subscription_details($invoice) {
1949
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1950
+        $subscription = wpinv_get_subscription($invoice, true);
1951 1951
 
1952
-        if ( empty( $subscription ) ) {
1952
+        if (empty($subscription)) {
1953 1953
             return;
1954 1954
         }
1955 1955
 
@@ -1960,15 +1960,15 @@  discard block
 block discarded – undo
1960 1960
         $payments = $subscription->get_child_payments();
1961 1961
         ?>
1962 1962
         <div class="wpinv-subscriptions-details">
1963
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1963
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1964 1964
             <table class="table">
1965 1965
                 <thead>
1966 1966
                     <tr>
1967
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1968
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1969
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1970
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1971
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1967
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1968
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1969
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1970
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1971
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1972 1972
                     </tr>
1973 1973
                 </thead>
1974 1974
                 <tbody>
@@ -1982,29 +1982,29 @@  discard block
 block discarded – undo
1982 1982
                 </tbody>
1983 1983
             </table>
1984 1984
         </div>
1985
-        <?php if ( !empty( $payments ) ) { ?>
1985
+        <?php if (!empty($payments)) { ?>
1986 1986
         <div class="wpinv-renewal-payments">
1987
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1987
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1988 1988
             <table class="table">
1989 1989
                 <thead>
1990 1990
                     <tr>
1991 1991
                         <th>#</th>
1992
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
1993
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
1994
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
1992
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
1993
+                        <th><?php _e('Date', 'invoicing'); ?></th>
1994
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
1995 1995
                     </tr>
1996 1996
                 </thead>
1997 1997
                 <tbody>
1998 1998
                     <?php
1999 1999
                         $i = 1;
2000
-                        foreach ( $payments as $payment ) {
2000
+                        foreach ($payments as $payment) {
2001 2001
                             $invoice_id = $payment->ID;
2002 2002
                     ?>
2003 2003
                     <tr>
2004
-                        <th scope="row"><?php echo $i;?></th>
2005
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
2006
-                        <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td>
2007
-                        <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td>
2004
+                        <th scope="row"><?php echo $i; ?></th>
2005
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
2006
+                        <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td>
2007
+                        <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td>
2008 2008
                     </tr>
2009 2009
                     <?php $i++; } ?>
2010 2010
                 </tbody>
@@ -2015,52 +2015,52 @@  discard block
 block discarded – undo
2015 2015
     }
2016 2016
 }
2017 2017
 
2018
-function wpinv_cart_total_label( $label, $invoice ) {
2019
-    if ( empty( $invoice ) ) {
2018
+function wpinv_cart_total_label($label, $invoice) {
2019
+    if (empty($invoice)) {
2020 2020
         return $label;
2021 2021
     }
2022 2022
 
2023 2023
     $prefix_label = '';
2024
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
2025
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
2026
-    } else if ( $invoice->is_renewal() ) {
2027
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
2024
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
2025
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
2026
+    } else if ($invoice->is_renewal()) {
2027
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
2028 2028
     }
2029 2029
 
2030
-    if ( $prefix_label != '' ) {
2031
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2030
+    if ($prefix_label != '') {
2031
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2032 2032
     }
2033 2033
 
2034 2034
     return $label;
2035 2035
 }
2036
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2037
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2038
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2036
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2037
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2038
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2039 2039
 
2040
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 );
2040
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1);
2041 2041
 
2042
-function wpinv_invoice_print_description( $invoice ) {
2043
-    if ( empty( $invoice ) ) {
2042
+function wpinv_invoice_print_description($invoice) {
2043
+    if (empty($invoice)) {
2044 2044
         return NULL;
2045 2045
     }
2046
-    if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) {
2046
+    if ($description = wpinv_get_invoice_description($invoice->ID)) {
2047 2047
         ?>
2048 2048
         <div class="row wpinv-lower">
2049 2049
             <div class="col-sm-12 wpinv-description">
2050
-                <?php echo wpautop( $description ); ?>
2050
+                <?php echo wpautop($description); ?>
2051 2051
             </div>
2052 2052
         </div>
2053 2053
         <?php
2054 2054
     }
2055 2055
 }
2056
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 );
2056
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1);
2057 2057
 
2058
-function wpinv_invoice_print_payment_info( $invoice ) {
2059
-    if ( empty( $invoice ) ) {
2058
+function wpinv_invoice_print_payment_info($invoice) {
2059
+    if (empty($invoice)) {
2060 2060
         return NULL;
2061 2061
     }
2062 2062
 
2063
-    if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) {
2063
+    if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) {
2064 2064
         ?>
2065 2065
         <div class="row wpinv-payments">
2066 2066
             <div class="col-sm-12">
@@ -2072,43 +2072,43 @@  discard block
 block discarded – undo
2072 2072
 }
2073 2073
 // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 );
2074 2074
 
2075
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
2076
-    if ( empty( $note ) ) {
2075
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
2076
+    if (empty($note)) {
2077 2077
         return NULL;
2078 2078
     }
2079 2079
 
2080
-    if ( is_int( $note ) ) {
2081
-        $note = get_comment( $note );
2080
+    if (is_int($note)) {
2081
+        $note = get_comment($note);
2082 2082
     }
2083 2083
 
2084
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
2084
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
2085 2085
         return NULL;
2086 2086
     }
2087 2087
 
2088
-    $note_classes   = array( 'note' );
2089
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
2088
+    $note_classes   = array('note');
2089
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
2090 2090
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
2091
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
2092
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
2091
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
2092
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
2093 2093
 
2094 2094
     ob_start();
2095 2095
     ?>
2096
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>">
2096
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>">
2097 2097
         <div class="note_content">
2098
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
2098
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
2099 2099
         </div>
2100 2100
         <p class="meta">
2101
-            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr>&nbsp;&nbsp;
2102
-            <?php if ( $note->comment_author !== 'System' || current_user_can( 'manage_options' ) ) { ?>
2103
-                <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
2101
+            <abbr class="exact-date" title="<?php echo $note->comment_date; ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr>&nbsp;&nbsp;
2102
+            <?php if ($note->comment_author !== 'System' || current_user_can('manage_options')) { ?>
2103
+                <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
2104 2104
             <?php } ?>
2105 2105
         </p>
2106 2106
     </li>
2107 2107
     <?php
2108 2108
     $note_content = ob_get_clean();
2109
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
2109
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
2110 2110
 
2111
-    if ( $echo ) {
2111
+    if ($echo) {
2112 2112
         echo $note_content;
2113 2113
     } else {
2114 2114
         return $note_content;
@@ -2118,43 +2118,43 @@  discard block
 block discarded – undo
2118 2118
 function wpinv_invalid_invoice_content() {
2119 2119
     global $post;
2120 2120
 
2121
-    $invoice = wpinv_get_invoice( $post->ID );
2121
+    $invoice = wpinv_get_invoice($post->ID);
2122 2122
 
2123
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' );
2124
-    if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
2125
-        if ( is_user_logged_in() ) {
2126
-            if ( wpinv_require_login_to_checkout() ) {
2127
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2128
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
2123
+    $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing');
2124
+    if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
2125
+        if (is_user_logged_in()) {
2126
+            if (wpinv_require_login_to_checkout()) {
2127
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2128
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
2129 2129
                 }
2130 2130
             }
2131 2131
         } else {
2132
-            if ( wpinv_require_login_to_checkout() ) {
2133
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2134
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
2132
+            if (wpinv_require_login_to_checkout()) {
2133
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2134
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
2135 2135
                 }
2136 2136
             }
2137 2137
         }
2138 2138
     } else {
2139
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
2139
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
2140 2140
     }
2141 2141
     ?>
2142 2142
     <div class="row wpinv-row-invalid">
2143 2143
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
2144
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
2144
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
2145 2145
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
2146 2146
         </div>
2147 2147
     </div>
2148 2148
     <?php
2149 2149
 }
2150
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
2150
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
2151 2151
 
2152
-add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2153
-function wpinv_force_company_name_field(){
2152
+add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2153
+function wpinv_force_company_name_field() {
2154 2154
     $invoice = wpinv_get_invoice_cart();
2155
-    $user_id = wpinv_get_user_id( $invoice->ID );
2156
-    $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
2157
-    if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) {
2155
+    $user_id = wpinv_get_user_id($invoice->ID);
2156
+    $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
2157
+    if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) {
2158 2158
         ?>
2159 2159
         <p class="wpi-cart-field wpi-col2 wpi-colf">
2160 2160
             <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
@@ -2179,21 +2179,21 @@  discard block
 block discarded – undo
2179 2179
  * @return string
2180 2180
  */
2181 2181
 function wpinv_get_policy_text() {
2182
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
2182
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
2183 2183
 
2184
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
2184
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
2185 2185
 
2186
-    if(!$privacy_page_id){
2187
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
2186
+    if (!$privacy_page_id) {
2187
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
2188 2188
     }
2189 2189
 
2190
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
2190
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
2191 2191
 
2192 2192
     $find_replace = array(
2193 2193
         '[wpinv_privacy_policy]' => $privacy_link,
2194 2194
     );
2195 2195
 
2196
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
2196
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
2197 2197
 
2198 2198
     return wp_kses_post(wpautop($privacy_text));
2199 2199
 }
2200 2200
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
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 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -31,31 +31,31 @@  discard block
 block discarded – undo
31 31
     }
32 32
     
33 33
     public function define_constants() {
34
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
35
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
34
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
35
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
36 36
     }
37 37
     
38 38
     private function actions() {
39 39
         /* Internationalize the text strings used. */
40
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
40
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
41 41
         
42 42
         /* Perform actions on admin initialization. */
43
-        add_action( 'admin_init', array( &$this, 'admin_init') );
44
-        add_action( 'init', array( &$this, 'init' ), 3 );
45
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
46
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
43
+        add_action('admin_init', array(&$this, 'admin_init'));
44
+        add_action('init', array(&$this, 'init'), 3);
45
+        add_action('init', array('WPInv_Shortcodes', 'init'));
46
+        add_action('init', array(&$this, 'wpinv_actions'));
47 47
         
48
-        if ( class_exists( 'BuddyPress' ) ) {
49
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
48
+        if (class_exists('BuddyPress')) {
49
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
50 50
         }
51 51
 
52
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
52
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
53 53
         
54
-        if ( is_admin() ) {
55
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
56
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
54
+        if (is_admin()) {
55
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
56
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
57 57
         } else {
58
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
58
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
59 59
         }
60 60
         
61 61
         /**
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
          *
66 66
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
67 67
          */
68
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
68
+        do_action_ref_array('wpinv_actions', array(&$this));
69 69
 
70
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
70
+        add_action('admin_init', array(&$this, 'activation_redirect'));
71 71
     }
72 72
     
73 73
     public function plugins_loaded() {
74 74
         /* Internationalize the text strings used. */
75 75
         $this->load_textdomain();
76 76
 
77
-        do_action( 'wpinv_loaded' );
77
+        do_action('wpinv_loaded');
78 78
     }
79 79
     
80 80
     /**
@@ -82,211 +82,211 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @since 1.0
84 84
      */
85
-    public function load_textdomain( $locale = NULL ) {
86
-        if ( empty( $locale ) ) {
87
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
85
+    public function load_textdomain($locale = NULL) {
86
+        if (empty($locale)) {
87
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
88 88
         }
89 89
 
90
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
90
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
91 91
         
92
-        unload_textdomain( 'invoicing' );
93
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
94
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
92
+        unload_textdomain('invoicing');
93
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
94
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
95 95
         
96 96
         /**
97 97
          * Define language constants.
98 98
          */
99
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
99
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
100 100
     }
101 101
         
102 102
     public function includes() {
103 103
         global $wpinv_options;
104 104
         
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
106 106
         $wpinv_options = wpinv_get_settings();
107 107
         
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
121
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
129
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
130
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
131
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
132
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
133
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
134
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
135
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
136
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
137
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php' );
138
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
139
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
121
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
129
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
130
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
131
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
132
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
133
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
134
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
135
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
136
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
137
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstract-wpinv-privacy.php');
138
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
139
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
140 140
 
141
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
142
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
141
+        if (!class_exists('WPInv_EUVat')) {
142
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
143 143
         }
144 144
         
145
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
146
-        if ( !empty( $gateways ) ) {
147
-            foreach ( $gateways as $gateway ) {
148
-                if ( $gateway == 'manual' ) {
145
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
146
+        if (!empty($gateways)) {
147
+            foreach ($gateways as $gateway) {
148
+                if ($gateway == 'manual') {
149 149
                     continue;
150 150
                 }
151 151
                 
152 152
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
153 153
                 
154
-                if ( file_exists( $gateway_file ) ) {
155
-                    require_once( $gateway_file );
154
+                if (file_exists($gateway_file)) {
155
+                    require_once($gateway_file);
156 156
                 }
157 157
             }
158 158
         }
159
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
159
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
160 160
         
161
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
162
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
163
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
164
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
161
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
162
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
163
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
164
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
165 165
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
166
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
167
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
168
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
169
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
170
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
171
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
172
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
166
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
167
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
168
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
169
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
170
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
171
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
172
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
173 173
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
174 174
             // load the user class only on the users.php page
175 175
             global $pagenow;
176
-            if($pagenow=='users.php'){
176
+            if ($pagenow == 'users.php') {
177 177
                 new WPInv_Admin_Users();
178 178
             }
179 179
         }
180 180
         
181 181
         // include css inliner
182
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
183
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
182
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
183
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
184 184
         }
185 185
         
186
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
186
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
187 187
     }
188 188
     
189 189
     public function init() {
190 190
     }
191 191
     
192 192
     public function admin_init() {
193
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
193
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
194 194
         }
195 195
         
196
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
196
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
197 197
     }
198 198
 
199 199
     public function activation_redirect() {
200 200
         // Bail if no activation redirect
201
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
201
+        if (!get_transient('_wpinv_activation_redirect')) {
202 202
             return;
203 203
         }
204 204
 
205 205
         // Delete the redirect transient
206
-        delete_transient( '_wpinv_activation_redirect' );
206
+        delete_transient('_wpinv_activation_redirect');
207 207
 
208 208
         // Bail if activating from network, or bulk
209
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
209
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
210 210
             return;
211 211
         }
212 212
 
213
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
213
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
214 214
         exit;
215 215
     }
216 216
     
217 217
     public function enqueue_scripts() {
218
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
218
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
219 219
         
220
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
221
-        wp_enqueue_style( 'wpinv_front_style' );
220
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
221
+        wp_enqueue_style('wpinv_front_style');
222 222
                
223 223
         // Register scripts
224
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
225
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
224
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
225
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
226 226
 
227 227
         $localize                         = array();
228
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
229
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
228
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
229
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
230 230
         $localize['currency_symbol']      = wpinv_currency_symbol();
231 231
         $localize['currency_pos']         = wpinv_currency_position();
232 232
         $localize['thousand_sep']         = wpinv_thousands_separator();
233 233
         $localize['decimal_sep']          = wpinv_decimal_separator();
234 234
         $localize['decimals']             = wpinv_decimals();
235
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
235
+        $localize['txtComplete']          = __('Complete', 'invoicing');
236 236
         
237
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
237
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
238 238
         
239
-        wp_enqueue_script( 'jquery-blockui' );
239
+        wp_enqueue_script('jquery-blockui');
240 240
         $autofill_api = wpinv_get_option('address_autofill_api');
241 241
         $autofill_active = wpinv_get_option('address_autofill_active');
242
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
243
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
244
-                wp_dequeue_script( 'google-maps-api' );
242
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
243
+            if (wp_script_is('google-maps-api', 'enqueued')) {
244
+                wp_dequeue_script('google-maps-api');
245 245
             }
246
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
247
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
246
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
247
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
248 248
         }
249
-        wp_enqueue_script( 'wpinv-front-script' );
250
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
249
+        wp_enqueue_script('wpinv-front-script');
250
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
251 251
     }
252 252
 
253 253
     public function admin_enqueue_scripts() {
254 254
         global $post, $pagenow;
255 255
         
256 256
         $post_type  = wpinv_admin_post_type();
257
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
258
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
257
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
258
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
259 259
 
260 260
         $jquery_ui_css = false;
261
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
261
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
262 262
             $jquery_ui_css = true;
263
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
263
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
264 264
             $jquery_ui_css = true;
265 265
         }
266
-        if ( $jquery_ui_css ) {
267
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
268
-            wp_enqueue_style( 'jquery-ui-css' );
266
+        if ($jquery_ui_css) {
267
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
268
+            wp_enqueue_style('jquery-ui-css');
269 269
         }
270 270
 
271
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
272
-        wp_enqueue_style( 'wpinv_meta_box_style' );
271
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
272
+        wp_enqueue_style('wpinv_meta_box_style');
273 273
         
274
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
275
-        wp_enqueue_style( 'wpinv_admin_style' );
274
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
275
+        wp_enqueue_style('wpinv_admin_style');
276 276
 
277
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
278
-        if ( $page == 'wpinv-subscriptions' ) {
279
-            wp_enqueue_script( 'jquery-ui-datepicker' );
277
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
278
+        if ($page == 'wpinv-subscriptions') {
279
+            wp_enqueue_script('jquery-ui-datepicker');
280 280
         }
281 281
         
282
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
283
-            wp_enqueue_script( 'jquery-ui-datepicker' );
282
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
283
+            wp_enqueue_script('jquery-ui-datepicker');
284 284
         }
285 285
 
286
-        wp_enqueue_style( 'wp-color-picker' );
287
-        wp_enqueue_script( 'wp-color-picker' );
286
+        wp_enqueue_style('wp-color-picker');
287
+        wp_enqueue_script('wp-color-picker');
288 288
         
289
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
289
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
290 290
 
291 291
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
292 292
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
             }
298 298
         }
299 299
 
300
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
301
-        wp_enqueue_script( 'wpinv-admin-script' );
300
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
301
+        wp_enqueue_script('wpinv-admin-script');
302 302
         
303 303
         $localize                               = array();
304
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
305
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
306
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
307
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
308
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
309
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
310
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
304
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
305
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
306
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
307
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
308
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
309
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
310
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
311 311
         $localize['tax']                        = wpinv_tax_amount();
312 312
         $localize['discount']                   = wpinv_discount_amount();
313 313
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -315,69 +315,69 @@  discard block
 block discarded – undo
315 315
         $localize['thousand_sep']               = wpinv_thousands_separator();
316 316
         $localize['decimal_sep']                = wpinv_decimal_separator();
317 317
         $localize['decimals']                   = wpinv_decimals();
318
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
319
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
320
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
321
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
322
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
323
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
324
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
325
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
326
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
327
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
328
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
329
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
330
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
331
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
318
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
319
+        $localize['status_publish']             = wpinv_status_nicename('publish');
320
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
321
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
322
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
323
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
324
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
325
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
326
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
327
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
328
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
329
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
330
+        $localize['action_edit']                = __('Edit', 'invoicing');
331
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
332 332
 
333
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
333
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
334 334
 
335
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
335
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
336 336
 
337
-        if ( $page == 'wpinv-subscriptions' ) {
338
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
339
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
337
+        if ($page == 'wpinv-subscriptions') {
338
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions' . $suffix . '.js', array('wpinv-admin-script'), WPINV_VERSION);
339
+            wp_enqueue_script('wpinv-sub-admin-script');
340 340
         }
341 341
     }
342 342
     
343
-    public function admin_body_class( $classes ) {
343
+    public function admin_body_class($classes) {
344 344
         global $pagenow, $post, $current_screen;
345 345
         
346
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) {
346
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) {
347 347
             $classes .= ' wpinv-cpt';
348 348
         }
349 349
         
350
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
350
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
351 351
 
352
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
353
-        if ( $add_class ) {
354
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
352
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
353
+        if ($add_class) {
354
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
355 355
         }
356 356
         
357 357
         $settings_class = array();
358
-        if ( $page == 'wpinv-settings' ) {
359
-            if ( !empty( $_REQUEST['tab'] ) ) {
360
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
358
+        if ($page == 'wpinv-settings') {
359
+            if (!empty($_REQUEST['tab'])) {
360
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
361 361
             }
362 362
             
363
-            if ( !empty( $_REQUEST['section'] ) ) {
364
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
363
+            if (!empty($_REQUEST['section'])) {
364
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
365 365
             }
366 366
             
367
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
367
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
368 368
         }
369 369
         
370
-        if ( !empty( $settings_class ) ) {
371
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
370
+        if (!empty($settings_class)) {
371
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
372 372
         }
373 373
         
374 374
         $post_type = wpinv_admin_post_type();
375 375
 
376
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
376
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
377 377
             return $classes .= ' wpinv';
378 378
         }
379 379
         
380
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
380
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
381 381
             $classes .= ' wpi-editable-n';
382 382
         }
383 383
 
@@ -389,20 +389,20 @@  discard block
 block discarded – undo
389 389
     }
390 390
     
391 391
     public function wpinv_actions() {
392
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
393
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
392
+        if (isset($_REQUEST['wpi_action'])) {
393
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
394 394
         }
395 395
     }
396 396
     
397
-    public function pre_get_posts( $wp_query ) {
398
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
399
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
397
+    public function pre_get_posts($wp_query) {
398
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
399
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
400 400
         }
401 401
         
402 402
         return $wp_query;
403 403
     }
404 404
     
405 405
     public function bp_invoicing_init() {
406
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
406
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
407 407
     }
408 408
 }
409 409
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-invoice-functions.php 1 patch
Spacing   +751 added lines, -751 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@  discard block
 block discarded – undo
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 14
 function wpinv_get_invoice_cart_id() {
15 15
     $wpinv_checkout = wpinv_get_checkout_session();
16 16
     
17
-    if ( !empty( $wpinv_checkout['invoice_id'] ) ) {
17
+    if (!empty($wpinv_checkout['invoice_id'])) {
18 18
         return $wpinv_checkout['invoice_id'];
19 19
     }
20 20
     
21 21
     return NULL;
22 22
 }
23 23
 
24
-function wpinv_insert_invoice( $invoice_data = array(), $wp_error = false ) {
25
-    if ( empty( $invoice_data ) ) {
24
+function wpinv_insert_invoice($invoice_data = array(), $wp_error = false) {
25
+    if (empty($invoice_data)) {
26 26
         return false;
27 27
     }
28 28
     
29
-    if ( !( !empty( $invoice_data['cart_details'] ) && is_array( $invoice_data['cart_details'] ) ) ) {
30
-        return $wp_error ? new WP_Error( 'wpinv_invalid_items', __( 'Invoice must have atleast on item.', 'invoicing' ) ) : 0;
29
+    if (!(!empty($invoice_data['cart_details']) && is_array($invoice_data['cart_details']))) {
30
+        return $wp_error ? new WP_Error('wpinv_invalid_items', __('Invoice must have atleast on item.', 'invoicing')) : 0;
31 31
     }
32 32
     
33
-    if ( empty( $invoice_data['user_id'] ) ) {
33
+    if (empty($invoice_data['user_id'])) {
34 34
         $invoice_data['user_id'] = get_current_user_id();
35 35
     }
36 36
     
37
-    $invoice_data['invoice_id'] = !empty( $invoice_data['invoice_id'] ) ? (int)$invoice_data['invoice_id'] : 0;
37
+    $invoice_data['invoice_id'] = !empty($invoice_data['invoice_id']) ? (int)$invoice_data['invoice_id'] : 0;
38 38
     
39
-    if ( empty( $invoice_data['status'] ) ) {
39
+    if (empty($invoice_data['status'])) {
40 40
         $invoice_data['status'] = 'wpi-pending';
41 41
     }
42 42
     
43
-    if ( empty( $invoice_data['ip'] ) ) {
43
+    if (empty($invoice_data['ip'])) {
44 44
         $invoice_data['ip'] = wpinv_get_ip();
45 45
     }
46 46
 
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
         'status'        => $invoice_data['status'],
52 52
     );
53 53
 
54
-    $invoice = wpinv_create_invoice( $default_args, $invoice_data, true );
55
-    if ( is_wp_error( $invoice ) ) {
54
+    $invoice = wpinv_create_invoice($default_args, $invoice_data, true);
55
+    if (is_wp_error($invoice)) {
56 56
         return $wp_error ? $invoice : 0;
57 57
     }
58 58
     
59
-    if ( empty( $invoice_data['invoice_id'] ) ) {
59
+    if (empty($invoice_data['invoice_id'])) {
60 60
         //$invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) );
61 61
     }
62 62
     
@@ -79,24 +79,24 @@  discard block
 block discarded – undo
79 79
         'discount'              => array(),
80 80
     );
81 81
 
82
-    if ( $user_id = (int)$invoice->get_user_id() ) {
83
-        if ( $user_address = wpinv_get_user_address( $user_id ) ) {
84
-            $default_user_info = wp_parse_args( $user_address, $default_user_info );
82
+    if ($user_id = (int)$invoice->get_user_id()) {
83
+        if ($user_address = wpinv_get_user_address($user_id)) {
84
+            $default_user_info = wp_parse_args($user_address, $default_user_info);
85 85
         }
86 86
     }
87 87
     
88
-    if ( empty( $invoice_data['user_info'] ) ) {
88
+    if (empty($invoice_data['user_info'])) {
89 89
         $invoice_data['user_info'] = array();
90 90
     }
91 91
     
92
-    $user_info = wp_parse_args( $invoice_data['user_info'], $default_user_info );
92
+    $user_info = wp_parse_args($invoice_data['user_info'], $default_user_info);
93 93
     
94
-    if ( empty( $user_info['first_name'] ) ) {
94
+    if (empty($user_info['first_name'])) {
95 95
         $user_info['first_name'] = $default_user_info['first_name'];
96 96
         $user_info['last_name'] = $default_user_info['last_name'];
97 97
     }
98 98
     
99
-    if ( empty( $user_info['country'] ) ) {
99
+    if (empty($user_info['country'])) {
100 100
         $user_info['country'] = $default_user_info['country'];
101 101
         $user_info['state'] = $default_user_info['state'];
102 102
         $user_info['city'] = $default_user_info['city'];
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
         $user_info['phone'] = $default_user_info['phone'];
106 106
     }
107 107
     
108
-    if ( !empty( $user_info['discount'] ) && !is_array( $user_info['discount'] ) ) {
108
+    if (!empty($user_info['discount']) && !is_array($user_info['discount'])) {
109 109
         $user_info['discount'] = (array)$user_info['discount'];
110 110
     }
111 111
 
112 112
     // Payment details
113 113
     $payment_details = array();
114
-    if ( !empty( $invoice_data['payment_details'] ) ) {
114
+    if (!empty($invoice_data['payment_details'])) {
115 115
         $default_payment_details = array(
116 116
             'gateway'           => 'manual',
117 117
             'gateway_title'     => '',
@@ -119,56 +119,56 @@  discard block
 block discarded – undo
119 119
             'transaction_id'    => '',
120 120
         );
121 121
         
122
-        $payment_details = wp_parse_args( $invoice_data['payment_details'], $default_payment_details );
122
+        $payment_details = wp_parse_args($invoice_data['payment_details'], $default_payment_details);
123 123
         
124
-        if ( empty( $payment_details['gateway'] ) ) {
124
+        if (empty($payment_details['gateway'])) {
125 125
             $payment_details['gateway'] = 'manual';
126 126
         }
127 127
         
128
-        if ( empty( $payment_details['currency'] ) ) {
128
+        if (empty($payment_details['currency'])) {
129 129
             $payment_details['currency'] = wpinv_get_default_country();
130 130
         }
131 131
         
132
-        if ( empty( $payment_details['gateway_title'] ) ) {
133
-            $payment_details['gateway_title'] = wpinv_get_gateway_checkout_label( $payment_details['gateway'] );
132
+        if (empty($payment_details['gateway_title'])) {
133
+            $payment_details['gateway_title'] = wpinv_get_gateway_checkout_label($payment_details['gateway']);
134 134
         }
135 135
     }
136 136
     
137
-    $invoice->set( 'status', ( !empty( $invoice_data['status'] ) ? $invoice_data['status'] : 'wpi-pending' ) );
138
-    
139
-    if ( !empty( $payment_details ) ) {
140
-        $invoice->set( 'currency', $payment_details['currency'] );
141
-        $invoice->set( 'gateway', $payment_details['gateway'] );
142
-        $invoice->set( 'gateway_title', $payment_details['gateway_title'] );
143
-        $invoice->set( 'transaction_id', $payment_details['transaction_id'] );
144
-    }
145
-    
146
-    $invoice->set( 'user_info', $user_info );
147
-    $invoice->set( 'first_name', $user_info['first_name'] );
148
-    $invoice->set( 'last_name', $user_info['last_name'] );
149
-    $invoice->set( 'address', $user_info['address'] );
150
-    $invoice->set( 'company', $user_info['company'] );
151
-    $invoice->set( 'vat_number', $user_info['vat_number'] );
152
-    $invoice->set( 'phone', $user_info['phone'] );
153
-    $invoice->set( 'city', $user_info['city'] );
154
-    $invoice->set( 'country', $user_info['country'] );
155
-    $invoice->set( 'state', $user_info['state'] );
156
-    $invoice->set( 'zip', $user_info['zip'] );
157
-    $invoice->set( 'discounts', $user_info['discount'] );
158
-    $invoice->set( 'ip', ( !empty( $invoice_data['ip'] ) ? $invoice_data['ip'] : wpinv_get_ip() ) );
159
-    $invoice->set( 'mode', ( wpinv_is_test_mode() ? 'test' : 'live' ) );
160
-    $invoice->set( 'parent_invoice', ( !empty( $invoice_data['parent'] ) ? absint( $invoice_data['parent'] ) : '' ) );
161
-    
162
-    if ( !empty( $invoice_data['cart_details'] ) && is_array( $invoice_data['cart_details'] ) ) {
163
-        foreach ( $invoice_data['cart_details'] as $key => $item ) {
164
-            $item_id        = !empty( $item['id'] ) ? $item['id'] : 0;
165
-            $quantity       = !empty( $item['quantity'] ) ? $item['quantity'] : 1;
166
-            $name           = !empty( $item['name'] ) ? $item['name'] : '';
167
-            $item_price     = isset( $item['item_price'] ) ? $item['item_price'] : '';
137
+    $invoice->set('status', (!empty($invoice_data['status']) ? $invoice_data['status'] : 'wpi-pending'));
138
+    
139
+    if (!empty($payment_details)) {
140
+        $invoice->set('currency', $payment_details['currency']);
141
+        $invoice->set('gateway', $payment_details['gateway']);
142
+        $invoice->set('gateway_title', $payment_details['gateway_title']);
143
+        $invoice->set('transaction_id', $payment_details['transaction_id']);
144
+    }
145
+    
146
+    $invoice->set('user_info', $user_info);
147
+    $invoice->set('first_name', $user_info['first_name']);
148
+    $invoice->set('last_name', $user_info['last_name']);
149
+    $invoice->set('address', $user_info['address']);
150
+    $invoice->set('company', $user_info['company']);
151
+    $invoice->set('vat_number', $user_info['vat_number']);
152
+    $invoice->set('phone', $user_info['phone']);
153
+    $invoice->set('city', $user_info['city']);
154
+    $invoice->set('country', $user_info['country']);
155
+    $invoice->set('state', $user_info['state']);
156
+    $invoice->set('zip', $user_info['zip']);
157
+    $invoice->set('discounts', $user_info['discount']);
158
+    $invoice->set('ip', (!empty($invoice_data['ip']) ? $invoice_data['ip'] : wpinv_get_ip()));
159
+    $invoice->set('mode', (wpinv_is_test_mode() ? 'test' : 'live'));
160
+    $invoice->set('parent_invoice', (!empty($invoice_data['parent']) ? absint($invoice_data['parent']) : ''));
161
+    
162
+    if (!empty($invoice_data['cart_details']) && is_array($invoice_data['cart_details'])) {
163
+        foreach ($invoice_data['cart_details'] as $key => $item) {
164
+            $item_id        = !empty($item['id']) ? $item['id'] : 0;
165
+            $quantity       = !empty($item['quantity']) ? $item['quantity'] : 1;
166
+            $name           = !empty($item['name']) ? $item['name'] : '';
167
+            $item_price     = isset($item['item_price']) ? $item['item_price'] : '';
168 168
             
169
-            $post_item  = new WPInv_Item( $item_id );
170
-            if ( !empty( $post_item ) ) {
171
-                $name       = !empty( $name ) ? $name : $post_item->get_name();
169
+            $post_item = new WPInv_Item($item_id);
170
+            if (!empty($post_item)) {
171
+                $name       = !empty($name) ? $name : $post_item->get_name();
172 172
                 $item_price = $item_price !== '' ? $item_price : $post_item->get_price();
173 173
             } else {
174 174
                 continue;
@@ -178,253 +178,253 @@  discard block
 block discarded – undo
178 178
                 'name'          => $name,
179 179
                 'quantity'      => $quantity,
180 180
                 'item_price'    => $item_price,
181
-                'custom_price'  => isset( $item['custom_price'] ) ? $item['custom_price'] : '',
182
-                'tax'           => !empty( $item['tax'] ) ? $item['tax'] : 0.00,
183
-                'discount'      => isset( $item['discount'] ) ? $item['discount'] : 0,
184
-                'meta'          => isset( $item['meta'] ) ? $item['meta'] : array(),
185
-                'fees'          => isset( $item['fees'] ) ? $item['fees'] : array(),
181
+                'custom_price'  => isset($item['custom_price']) ? $item['custom_price'] : '',
182
+                'tax'           => !empty($item['tax']) ? $item['tax'] : 0.00,
183
+                'discount'      => isset($item['discount']) ? $item['discount'] : 0,
184
+                'meta'          => isset($item['meta']) ? $item['meta'] : array(),
185
+                'fees'          => isset($item['fees']) ? $item['fees'] : array(),
186 186
             );
187 187
 
188
-            $invoice->add_item( $item_id, $args );
188
+            $invoice->add_item($item_id, $args);
189 189
         }
190 190
     }
191 191
 
192
-    $invoice->increase_tax( wpinv_get_cart_fee_tax() );
192
+    $invoice->increase_tax(wpinv_get_cart_fee_tax());
193 193
 
194
-    if ( isset( $invoice_data['post_date'] ) ) {
195
-        $invoice->set( 'date', $invoice_data['post_date'] );
194
+    if (isset($invoice_data['post_date'])) {
195
+        $invoice->set('date', $invoice_data['post_date']);
196 196
     }
197 197
     
198 198
     // Invoice due date
199
-    if ( isset( $invoice_data['due_date'] ) ) {
200
-        $invoice->set( 'due_date', $invoice_data['due_date'] );
199
+    if (isset($invoice_data['due_date'])) {
200
+        $invoice->set('due_date', $invoice_data['due_date']);
201 201
     }
202 202
     
203 203
     $invoice->save();
204 204
     
205 205
     // Add notes
206
-    if ( !empty( $invoice_data['private_note'] ) ) {
207
-        $invoice->add_note( $invoice_data['private_note'] );
206
+    if (!empty($invoice_data['private_note'])) {
207
+        $invoice->add_note($invoice_data['private_note']);
208 208
     }
209
-    if ( !empty( $invoice_data['user_note'] ) ) {
210
-        $invoice->add_note( $invoice_data['user_note'], true );
209
+    if (!empty($invoice_data['user_note'])) {
210
+        $invoice->add_note($invoice_data['user_note'], true);
211 211
     }
212 212
     
213
-    do_action( 'wpinv_insert_invoice', $invoice->ID, $invoice_data );
213
+    do_action('wpinv_insert_invoice', $invoice->ID, $invoice_data);
214 214
 
215
-    if ( ! empty( $invoice->ID ) ) {
215
+    if (!empty($invoice->ID)) {
216 216
         global $wpi_userID, $wpinv_ip_address_country;
217 217
         
218 218
         $checkout_session = wpinv_get_checkout_session();
219 219
         
220 220
         $data_session                   = array();
221 221
         $data_session['invoice_id']     = $invoice->ID;
222
-        $data_session['cart_discounts'] = $invoice->get_discounts( true );
222
+        $data_session['cart_discounts'] = $invoice->get_discounts(true);
223 223
         
224
-        wpinv_set_checkout_session( $data_session );
224
+        wpinv_set_checkout_session($data_session);
225 225
         
226 226
         $wpi_userID         = (int)$invoice->get_user_id();
227 227
         
228
-        $_POST['country']   = !empty( $invoice->country ) ? $invoice->country : wpinv_get_default_country();
228
+        $_POST['country']   = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
229 229
         $_POST['state']     = $invoice->state;
230 230
 
231
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
232
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
231
+        $invoice->set('country', sanitize_text_field($_POST['country']));
232
+        $invoice->set('state', sanitize_text_field($_POST['state']));
233 233
         
234 234
         $wpinv_ip_address_country = $invoice->country;
235 235
         
236
-        $invoice = $invoice->recalculate_totals( true );
236
+        $invoice = $invoice->recalculate_totals(true);
237 237
         
238
-        wpinv_set_checkout_session( $checkout_session );
238
+        wpinv_set_checkout_session($checkout_session);
239 239
                     
240 240
         return $invoice;
241 241
     }
242 242
     
243
-    if ( $wp_error ) {
244
-        if ( is_wp_error( $invoice ) ) {
243
+    if ($wp_error) {
244
+        if (is_wp_error($invoice)) {
245 245
             return $invoice;
246 246
         } else {
247
-            return new WP_Error( 'wpinv_insert_invoice_error', __( 'Error in insert invoice.', 'invoicing' ) );
247
+            return new WP_Error('wpinv_insert_invoice_error', __('Error in insert invoice.', 'invoicing'));
248 248
         }
249 249
     } else {
250 250
         return 0;
251 251
     }
252 252
 }
253 253
 
254
-function wpinv_update_invoice( $invoice_data = array(), $wp_error = false ) {
255
-    $invoice_ID = !empty( $invoice_data['ID'] ) ? absint( $invoice_data['ID'] ) : NULL;
254
+function wpinv_update_invoice($invoice_data = array(), $wp_error = false) {
255
+    $invoice_ID = !empty($invoice_data['ID']) ? absint($invoice_data['ID']) : NULL;
256 256
 
257
-    if ( !$invoice_ID ) {
258
-        if ( $wp_error ) {
259
-            return new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) );
257
+    if (!$invoice_ID) {
258
+        if ($wp_error) {
259
+            return new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing'));
260 260
         }
261 261
         return 0;
262 262
     }
263 263
 
264
-    $invoice = wpinv_get_invoice( $invoice_ID );
264
+    $invoice = wpinv_get_invoice($invoice_ID);
265 265
 
266
-    $recurring_item = $invoice->is_recurring() ? $invoice->get_recurring( true ) : NULL;
266
+    $recurring_item = $invoice->is_recurring() ? $invoice->get_recurring(true) : NULL;
267 267
 
268
-    if ( empty( $invoice->ID ) ) {
269
-        if ( $wp_error ) {
270
-            return new WP_Error( 'invalid_invoice', __( 'Invalid invoice.', 'invoicing' ) );
268
+    if (empty($invoice->ID)) {
269
+        if ($wp_error) {
270
+            return new WP_Error('invalid_invoice', __('Invalid invoice.', 'invoicing'));
271 271
         }
272 272
         return 0;
273 273
     }
274 274
 
275
-    if ( !$invoice->has_status( array( 'wpi-pending' ) ) ) {
276
-        if ( $wp_error ) {
277
-            return new WP_Error( 'invalid_invoice_status', __( 'Only invoice with pending payment is allowed to update.', 'invoicing' ) );
275
+    if (!$invoice->has_status(array('wpi-pending'))) {
276
+        if ($wp_error) {
277
+            return new WP_Error('invalid_invoice_status', __('Only invoice with pending payment is allowed to update.', 'invoicing'));
278 278
         }
279 279
         return 0;
280 280
     }
281 281
 
282 282
     // Invoice status
283
-    if ( !empty( $invoice_data['status'] ) ) {
284
-        $invoice->set( 'status', $invoice_data['status'] );
283
+    if (!empty($invoice_data['status'])) {
284
+        $invoice->set('status', $invoice_data['status']);
285 285
     }
286 286
 
287 287
     // Invoice date
288
-    if ( !empty( $invoice_data['post_date'] ) ) {
289
-        $invoice->set( 'date', $invoice_data['post_date'] );
288
+    if (!empty($invoice_data['post_date'])) {
289
+        $invoice->set('date', $invoice_data['post_date']);
290 290
     }
291 291
 
292 292
     // Invoice due date
293
-    if ( isset( $invoice_data['due_date'] ) ) {
294
-        $invoice->set( 'due_date', $invoice_data['due_date'] );
293
+    if (isset($invoice_data['due_date'])) {
294
+        $invoice->set('due_date', $invoice_data['due_date']);
295 295
     }
296 296
 
297 297
     // Invoice IP address
298
-    if ( !empty( $invoice_data['ip'] ) ) {
299
-        $invoice->set( 'ip', $invoice_data['ip'] );
298
+    if (!empty($invoice_data['ip'])) {
299
+        $invoice->set('ip', $invoice_data['ip']);
300 300
     }
301 301
     
302 302
     // User info
303
-    if ( !empty( $invoice_data['user_info'] ) && is_array( $invoice_data['user_info'] ) ) {
304
-        $user_info = wp_parse_args( $invoice_data['user_info'], $invoice->user_info );
303
+    if (!empty($invoice_data['user_info']) && is_array($invoice_data['user_info'])) {
304
+        $user_info = wp_parse_args($invoice_data['user_info'], $invoice->user_info);
305 305
 
306
-        if ( $discounts = $invoice->get_discounts() ) {
306
+        if ($discounts = $invoice->get_discounts()) {
307 307
             $set_discount = $discounts;
308 308
         } else {
309 309
             $set_discount = '';
310 310
         }
311 311
 
312 312
         // Manage discount
313
-        if ( !empty( $invoice_data['user_info']['discount'] ) ) {
313
+        if (!empty($invoice_data['user_info']['discount'])) {
314 314
             // Remove discount
315
-            if ( $invoice_data['user_info']['discount'] == 'none' ) {
315
+            if ($invoice_data['user_info']['discount'] == 'none') {
316 316
                 $set_discount = '';
317 317
             } else {
318 318
                 $set_discount = $invoice_data['user_info']['discount'];
319 319
             }
320 320
 
321
-            $invoice->set( 'discounts', $set_discount );
321
+            $invoice->set('discounts', $set_discount);
322 322
         }
323 323
 
324 324
         $user_info['discount'] = $set_discount;
325 325
 
326
-        $invoice->set( 'user_info', $user_info );
326
+        $invoice->set('user_info', $user_info);
327 327
     }
328 328
 
329
-    if ( !empty( $invoice_data['cart_details'] ) && is_array( $invoice_data['cart_details'] ) && $cart_details = $invoice_data['cart_details'] ) {
330
-        $remove_items = !empty( $cart_details['remove_items'] ) && is_array( $cart_details['remove_items'] ) ? $cart_details['remove_items'] : array();
329
+    if (!empty($invoice_data['cart_details']) && is_array($invoice_data['cart_details']) && $cart_details = $invoice_data['cart_details']) {
330
+        $remove_items = !empty($cart_details['remove_items']) && is_array($cart_details['remove_items']) ? $cart_details['remove_items'] : array();
331 331
 
332
-        if ( !empty( $remove_items[0]['id'] ) ) {
333
-            foreach ( $remove_items as $item ) {
334
-                $item_id        = !empty( $item['id'] ) ? $item['id'] : 0;
335
-                $quantity       = !empty( $item['quantity'] ) ? $item['quantity'] : 1;
336
-                if ( empty( $item_id ) ) {
332
+        if (!empty($remove_items[0]['id'])) {
333
+            foreach ($remove_items as $item) {
334
+                $item_id        = !empty($item['id']) ? $item['id'] : 0;
335
+                $quantity       = !empty($item['quantity']) ? $item['quantity'] : 1;
336
+                if (empty($item_id)) {
337 337
                     continue;
338 338
                 }
339 339
 
340
-                foreach ( $invoice->cart_details as $cart_index => $cart_item ) {
341
-                    if ( $item_id == $cart_item['id'] ) {
340
+                foreach ($invoice->cart_details as $cart_index => $cart_item) {
341
+                    if ($item_id == $cart_item['id']) {
342 342
                         $args = array(
343 343
                             'id'         => $item_id,
344 344
                             'quantity'   => $quantity,
345 345
                             'cart_index' => $cart_index
346 346
                         );
347 347
 
348
-                        $invoice->remove_item( $item_id, $args );
348
+                        $invoice->remove_item($item_id, $args);
349 349
                         break;
350 350
                     }
351 351
                 }
352 352
             }
353 353
         }
354 354
 
355
-        $add_items = !empty( $cart_details['add_items'] ) && is_array( $cart_details['add_items'] ) ? $cart_details['add_items'] : array();
355
+        $add_items = !empty($cart_details['add_items']) && is_array($cart_details['add_items']) ? $cart_details['add_items'] : array();
356 356
 
357
-        if ( !empty( $add_items[0]['id'] ) ) {
358
-            foreach ( $add_items as $item ) {
359
-                $item_id        = !empty( $item['id'] ) ? $item['id'] : 0;
360
-                $post_item      = new WPInv_Item( $item_id );
361
-                if ( empty( $post_item ) ) {
357
+        if (!empty($add_items[0]['id'])) {
358
+            foreach ($add_items as $item) {
359
+                $item_id        = !empty($item['id']) ? $item['id'] : 0;
360
+                $post_item      = new WPInv_Item($item_id);
361
+                if (empty($post_item)) {
362 362
                     continue;
363 363
                 }
364 364
 
365 365
                 $valid_item = true;
366
-                if ( !empty( $recurring_item ) ) {
367
-                    if ( $recurring_item->ID != $item_id ) {
366
+                if (!empty($recurring_item)) {
367
+                    if ($recurring_item->ID != $item_id) {
368 368
                         $valid_item = false;
369 369
                     }
370
-                } else if ( wpinv_is_recurring_item( $item_id ) ) {
370
+                } else if (wpinv_is_recurring_item($item_id)) {
371 371
                     $valid_item = false;
372 372
                 }
373 373
                 
374
-                if ( !$valid_item ) {
375
-                    if ( $wp_error ) {
376
-                        return new WP_Error( 'invalid_invoice_item', __( 'You can not add item because recurring item must be paid individually!', 'invoicing' ) );
374
+                if (!$valid_item) {
375
+                    if ($wp_error) {
376
+                        return new WP_Error('invalid_invoice_item', __('You can not add item because recurring item must be paid individually!', 'invoicing'));
377 377
                     }
378 378
                     return 0;
379 379
                 }
380 380
 
381
-                $quantity       = !empty( $item['quantity'] ) ? $item['quantity'] : 1;
382
-                $name           = !empty( $item['name'] ) ? $item['name'] : $post_item->get_name();
383
-                $item_price     = isset( $item['item_price'] ) ? $item['item_price'] : $post_item->get_price();
381
+                $quantity       = !empty($item['quantity']) ? $item['quantity'] : 1;
382
+                $name           = !empty($item['name']) ? $item['name'] : $post_item->get_name();
383
+                $item_price     = isset($item['item_price']) ? $item['item_price'] : $post_item->get_price();
384 384
 
385 385
                 $args = array(
386 386
                     'name'          => $name,
387 387
                     'quantity'      => $quantity,
388 388
                     'item_price'    => $item_price,
389
-                    'custom_price'  => isset( $item['custom_price'] ) ? $item['custom_price'] : '',
390
-                    'tax'           => !empty( $item['tax'] ) ? $item['tax'] : 0,
391
-                    'discount'      => isset( $item['discount'] ) ? $item['discount'] : 0,
392
-                    'meta'          => isset( $item['meta'] ) ? $item['meta'] : array(),
393
-                    'fees'          => isset( $item['fees'] ) ? $item['fees'] : array(),
389
+                    'custom_price'  => isset($item['custom_price']) ? $item['custom_price'] : '',
390
+                    'tax'           => !empty($item['tax']) ? $item['tax'] : 0,
391
+                    'discount'      => isset($item['discount']) ? $item['discount'] : 0,
392
+                    'meta'          => isset($item['meta']) ? $item['meta'] : array(),
393
+                    'fees'          => isset($item['fees']) ? $item['fees'] : array(),
394 394
                 );
395 395
 
396
-                $invoice->add_item( $item_id, $args );
396
+                $invoice->add_item($item_id, $args);
397 397
             }
398 398
         }
399 399
     }
400 400
     
401 401
     // Payment details
402
-    if ( !empty( $invoice_data['payment_details'] ) && $payment_details = $invoice_data['payment_details'] ) {
403
-        if ( !empty( $payment_details['gateway'] ) ) {
404
-            $invoice->set( 'gateway', $payment_details['gateway'] );
402
+    if (!empty($invoice_data['payment_details']) && $payment_details = $invoice_data['payment_details']) {
403
+        if (!empty($payment_details['gateway'])) {
404
+            $invoice->set('gateway', $payment_details['gateway']);
405 405
         }
406 406
 
407
-        if ( !empty( $payment_details['transaction_id'] ) ) {
408
-            $invoice->set( 'transaction_id', $payment_details['transaction_id'] );
407
+        if (!empty($payment_details['transaction_id'])) {
408
+            $invoice->set('transaction_id', $payment_details['transaction_id']);
409 409
         }
410 410
     }
411 411
 
412
-    do_action( 'wpinv_pre_update_invoice', $invoice->ID, $invoice_data );
412
+    do_action('wpinv_pre_update_invoice', $invoice->ID, $invoice_data);
413 413
 
414 414
     // Parent invoice
415
-    if ( !empty( $invoice_data['parent'] ) ) {
416
-        $invoice->set( 'parent_invoice', $invoice_data['parent'] );
415
+    if (!empty($invoice_data['parent'])) {
416
+        $invoice->set('parent_invoice', $invoice_data['parent']);
417 417
     }
418 418
 
419 419
     // Save invoice data.
420 420
     $invoice->save();
421 421
     
422
-    if ( empty( $invoice->ID ) || is_wp_error( $invoice ) ) {
423
-        if ( $wp_error ) {
424
-            if ( is_wp_error( $invoice ) ) {
422
+    if (empty($invoice->ID) || is_wp_error($invoice)) {
423
+        if ($wp_error) {
424
+            if (is_wp_error($invoice)) {
425 425
                 return $invoice;
426 426
             } else {
427
-                return new WP_Error( 'wpinv_update_invoice_error', __( 'Error in update invoice.', 'invoicing' ) );
427
+                return new WP_Error('wpinv_update_invoice_error', __('Error in update invoice.', 'invoicing'));
428 428
             }
429 429
         } else {
430 430
             return 0;
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
     }
433 433
 
434 434
     // Add private note
435
-    if ( !empty( $invoice_data['private_note'] ) ) {
436
-        $invoice->add_note( $invoice_data['private_note'] );
435
+    if (!empty($invoice_data['private_note'])) {
436
+        $invoice->add_note($invoice_data['private_note']);
437 437
     }
438 438
 
439 439
     // Add user note
440
-    if ( !empty( $invoice_data['user_note'] ) ) {
441
-        $invoice->add_note( $invoice_data['user_note'], true );
440
+    if (!empty($invoice_data['user_note'])) {
441
+        $invoice->add_note($invoice_data['user_note'], true);
442 442
     }
443 443
 
444 444
     global $wpi_userID, $wpinv_ip_address_country;
@@ -447,450 +447,450 @@  discard block
 block discarded – undo
447 447
 
448 448
     $data_session                   = array();
449 449
     $data_session['invoice_id']     = $invoice->ID;
450
-    $data_session['cart_discounts'] = $invoice->get_discounts( true );
450
+    $data_session['cart_discounts'] = $invoice->get_discounts(true);
451 451
 
452
-    wpinv_set_checkout_session( $data_session );
452
+    wpinv_set_checkout_session($data_session);
453 453
 
454 454
     $wpi_userID         = (int)$invoice->get_user_id();
455 455
 
456
-    $_POST['country']   = !empty( $invoice->country ) ? $invoice->country : wpinv_get_default_country();
456
+    $_POST['country']   = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
457 457
     $_POST['state']     = $invoice->state;
458 458
 
459
-    $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
460
-    $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
459
+    $invoice->set('country', sanitize_text_field($_POST['country']));
460
+    $invoice->set('state', sanitize_text_field($_POST['state']));
461 461
 
462 462
     $wpinv_ip_address_country = $invoice->country;
463 463
 
464
-    $invoice = $invoice->recalculate_totals( true );
464
+    $invoice = $invoice->recalculate_totals(true);
465 465
 
466
-    do_action( 'wpinv_post_update_invoice', $invoice->ID, $invoice_data );
466
+    do_action('wpinv_post_update_invoice', $invoice->ID, $invoice_data);
467 467
 
468
-    wpinv_set_checkout_session( $checkout_session );
468
+    wpinv_set_checkout_session($checkout_session);
469 469
 
470 470
     return $invoice;
471 471
 }
472 472
 
473
-function wpinv_get_invoice( $invoice_id = 0, $cart = false ) {
474
-    if ( $cart && empty( $invoice_id ) ) {
473
+function wpinv_get_invoice($invoice_id = 0, $cart = false) {
474
+    if ($cart && empty($invoice_id)) {
475 475
         $invoice_id = (int)wpinv_get_invoice_cart_id();
476 476
     }
477 477
 
478
-    $invoice = new WPInv_Invoice( $invoice_id );
478
+    $invoice = new WPInv_Invoice($invoice_id);
479 479
 
480
-    if ( ! empty( $invoice ) && ! empty( $invoice->ID ) ) {
480
+    if (!empty($invoice) && !empty($invoice->ID)) {
481 481
         return $invoice;
482 482
     }
483 483
     
484 484
     return NULL;
485 485
 }
486 486
 
487
-function wpinv_get_invoice_cart( $invoice_id = 0 ) {
488
-    return wpinv_get_invoice( $invoice_id, true );
487
+function wpinv_get_invoice_cart($invoice_id = 0) {
488
+    return wpinv_get_invoice($invoice_id, true);
489 489
 }
490 490
 
491
-function wpinv_get_invoice_description( $invoice_id = 0 ) {
492
-    $invoice = new WPInv_Invoice( $invoice_id );
491
+function wpinv_get_invoice_description($invoice_id = 0) {
492
+    $invoice = new WPInv_Invoice($invoice_id);
493 493
     return $invoice->get_description();
494 494
 }
495 495
 
496
-function wpinv_get_invoice_currency_code( $invoice_id = 0 ) {
497
-    $invoice = new WPInv_Invoice( $invoice_id );
496
+function wpinv_get_invoice_currency_code($invoice_id = 0) {
497
+    $invoice = new WPInv_Invoice($invoice_id);
498 498
     return $invoice->get_currency();
499 499
 }
500 500
 
501
-function wpinv_get_payment_user_email( $invoice_id ) {
502
-    $invoice = new WPInv_Invoice( $invoice_id );
501
+function wpinv_get_payment_user_email($invoice_id) {
502
+    $invoice = new WPInv_Invoice($invoice_id);
503 503
     return $invoice->get_email();
504 504
 }
505 505
 
506
-function wpinv_get_user_id( $invoice_id ) {
507
-    $invoice = new WPInv_Invoice( $invoice_id );
506
+function wpinv_get_user_id($invoice_id) {
507
+    $invoice = new WPInv_Invoice($invoice_id);
508 508
     return $invoice->get_user_id();
509 509
 }
510 510
 
511
-function wpinv_get_invoice_status( $invoice_id, $return_label = false ) {
512
-    $invoice = new WPInv_Invoice( $invoice_id );
511
+function wpinv_get_invoice_status($invoice_id, $return_label = false) {
512
+    $invoice = new WPInv_Invoice($invoice_id);
513 513
     
514
-    return $invoice->get_status( $return_label );
514
+    return $invoice->get_status($return_label);
515 515
 }
516 516
 
517
-function wpinv_get_payment_gateway( $invoice_id, $return_label = false ) {
518
-    $invoice = new WPInv_Invoice( $invoice_id );
517
+function wpinv_get_payment_gateway($invoice_id, $return_label = false) {
518
+    $invoice = new WPInv_Invoice($invoice_id);
519 519
     
520
-    return $invoice->get_gateway( $return_label );
520
+    return $invoice->get_gateway($return_label);
521 521
 }
522 522
 
523
-function wpinv_get_payment_gateway_name( $invoice_id ) {
524
-    $invoice = new WPInv_Invoice( $invoice_id );
523
+function wpinv_get_payment_gateway_name($invoice_id) {
524
+    $invoice = new WPInv_Invoice($invoice_id);
525 525
     
526 526
     return $invoice->get_gateway_title();
527 527
 }
528 528
 
529
-function wpinv_get_payment_transaction_id( $invoice_id ) {
530
-    $invoice = new WPInv_Invoice( $invoice_id );
529
+function wpinv_get_payment_transaction_id($invoice_id) {
530
+    $invoice = new WPInv_Invoice($invoice_id);
531 531
     
532 532
     return $invoice->get_transaction_id();
533 533
 }
534 534
 
535
-function wpinv_get_id_by_transaction_id( $key ) {
535
+function wpinv_get_id_by_transaction_id($key) {
536 536
     global $wpdb;
537 537
 
538
-    $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
538
+    $invoice_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = %s LIMIT 1", $key));
539 539
 
540
-    if ( $invoice_id != NULL )
540
+    if ($invoice_id != NULL)
541 541
         return $invoice_id;
542 542
 
543 543
     return 0;
544 544
 }
545 545
 
546
-function wpinv_get_invoice_meta( $invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true ) {
547
-    $invoice = new WPInv_Invoice( $invoice_id );
546
+function wpinv_get_invoice_meta($invoice_id = 0, $meta_key = '_wpinv_payment_meta', $single = true) {
547
+    $invoice = new WPInv_Invoice($invoice_id);
548 548
 
549
-    return $invoice->get_meta( $meta_key, $single );
549
+    return $invoice->get_meta($meta_key, $single);
550 550
 }
551 551
 
552
-function wpinv_update_invoice_meta( $invoice_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
553
-    $invoice = new WPInv_Invoice( $invoice_id );
552
+function wpinv_update_invoice_meta($invoice_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
553
+    $invoice = new WPInv_Invoice($invoice_id);
554 554
     
555
-    return $invoice->update_meta( $meta_key, $meta_value, $prev_value );
555
+    return $invoice->update_meta($meta_key, $meta_value, $prev_value);
556 556
 }
557 557
 
558
-function wpinv_get_items( $invoice_id = 0 ) {
559
-    $invoice            = wpinv_get_invoice( $invoice_id );
558
+function wpinv_get_items($invoice_id = 0) {
559
+    $invoice            = wpinv_get_invoice($invoice_id);
560 560
     
561 561
     $items              = $invoice->get_items();
562 562
     $invoice_currency   = $invoice->get_currency();
563 563
 
564
-    if ( !empty( $items ) && is_array( $items ) ) {
565
-        foreach ( $items as $key => $item ) {
564
+    if (!empty($items) && is_array($items)) {
565
+        foreach ($items as $key => $item) {
566 566
             $items[$key]['currency'] = $invoice_currency;
567 567
 
568
-            if ( !isset( $cart_item['subtotal'] ) ) {
568
+            if (!isset($cart_item['subtotal'])) {
569 569
                 $items[$key]['subtotal'] = $items[$key]['amount'] * 1;
570 570
             }
571 571
         }
572 572
     }
573 573
 
574
-    return apply_filters( 'wpinv_get_items', $items, $invoice_id );
574
+    return apply_filters('wpinv_get_items', $items, $invoice_id);
575 575
 }
576 576
 
577
-function wpinv_get_fees( $invoice_id = 0 ) {
578
-    $invoice           = wpinv_get_invoice( $invoice_id );
577
+function wpinv_get_fees($invoice_id = 0) {
578
+    $invoice           = wpinv_get_invoice($invoice_id);
579 579
     $fees              = $invoice->get_fees();
580 580
 
581
-    return apply_filters( 'wpinv_get_fees', $fees, $invoice_id );
581
+    return apply_filters('wpinv_get_fees', $fees, $invoice_id);
582 582
 }
583 583
 
584
-function wpinv_get_invoice_ip( $invoice_id ) {
585
-    $invoice = new WPInv_Invoice( $invoice_id );
584
+function wpinv_get_invoice_ip($invoice_id) {
585
+    $invoice = new WPInv_Invoice($invoice_id);
586 586
     return $invoice->get_ip();
587 587
 }
588 588
 
589
-function wpinv_get_invoice_user_info( $invoice_id ) {
590
-    $invoice = new WPInv_Invoice( $invoice_id );
589
+function wpinv_get_invoice_user_info($invoice_id) {
590
+    $invoice = new WPInv_Invoice($invoice_id);
591 591
     return $invoice->get_user_info();
592 592
 }
593 593
 
594
-function wpinv_subtotal( $invoice_id = 0, $currency = false ) {
595
-    $invoice = new WPInv_Invoice( $invoice_id );
594
+function wpinv_subtotal($invoice_id = 0, $currency = false) {
595
+    $invoice = new WPInv_Invoice($invoice_id);
596 596
 
597
-    return $invoice->get_subtotal( $currency );
597
+    return $invoice->get_subtotal($currency);
598 598
 }
599 599
 
600
-function wpinv_tax( $invoice_id = 0, $currency = false ) {
601
-    $invoice = new WPInv_Invoice( $invoice_id );
600
+function wpinv_tax($invoice_id = 0, $currency = false) {
601
+    $invoice = new WPInv_Invoice($invoice_id);
602 602
 
603
-    return $invoice->get_tax( $currency );
603
+    return $invoice->get_tax($currency);
604 604
 }
605 605
 
606
-function wpinv_discount( $invoice_id = 0, $currency = false, $dash = false ) {
607
-    $invoice = wpinv_get_invoice( $invoice_id );
606
+function wpinv_discount($invoice_id = 0, $currency = false, $dash = false) {
607
+    $invoice = wpinv_get_invoice($invoice_id);
608 608
 
609
-    return $invoice->get_discount( $currency, $dash );
609
+    return $invoice->get_discount($currency, $dash);
610 610
 }
611 611
 
612
-function wpinv_discount_code( $invoice_id = 0 ) {
613
-    $invoice = new WPInv_Invoice( $invoice_id );
612
+function wpinv_discount_code($invoice_id = 0) {
613
+    $invoice = new WPInv_Invoice($invoice_id);
614 614
 
615 615
     return $invoice->get_discount_code();
616 616
 }
617 617
 
618
-function wpinv_payment_total( $invoice_id = 0, $currency = false ) {
619
-    $invoice = new WPInv_Invoice( $invoice_id );
618
+function wpinv_payment_total($invoice_id = 0, $currency = false) {
619
+    $invoice = new WPInv_Invoice($invoice_id);
620 620
 
621
-    return $invoice->get_total( $currency );
621
+    return $invoice->get_total($currency);
622 622
 }
623 623
 
624
-function wpinv_get_date_created( $invoice_id = 0, $format = '' ) {
625
-    $invoice = new WPInv_Invoice( $invoice_id );
624
+function wpinv_get_date_created($invoice_id = 0, $format = '') {
625
+    $invoice = new WPInv_Invoice($invoice_id);
626 626
 
627
-    $format         = !empty( $format ) ? $format : get_option( 'date_format' );
627
+    $format         = !empty($format) ? $format : get_option('date_format');
628 628
     $date_created   = $invoice->get_created_date();
629
-    $date_created   = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( $format, strtotime( $date_created ) ) : '';
629
+    $date_created   = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n($format, strtotime($date_created)) : '';
630 630
 
631 631
     return $date_created;
632 632
 }
633 633
 
634
-function wpinv_get_invoice_date( $invoice_id = 0, $format = '', $default = true ) {
635
-    $invoice = new WPInv_Invoice( $invoice_id );
634
+function wpinv_get_invoice_date($invoice_id = 0, $format = '', $default = true) {
635
+    $invoice = new WPInv_Invoice($invoice_id);
636 636
     
637
-    $format         = !empty( $format ) ? $format : get_option( 'date_format' );
637
+    $format         = !empty($format) ? $format : get_option('date_format');
638 638
     $date_completed = $invoice->get_completed_date();
639
-    $invoice_date   = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( $format, strtotime( $date_completed ) ) : '';
640
-    if ( $invoice_date == '' && $default ) {
641
-        $invoice_date   = wpinv_get_date_created( $invoice_id, $format );
639
+    $invoice_date   = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n($format, strtotime($date_completed)) : '';
640
+    if ($invoice_date == '' && $default) {
641
+        $invoice_date = wpinv_get_date_created($invoice_id, $format);
642 642
     }
643 643
 
644 644
     return $invoice_date;
645 645
 }
646 646
 
647
-function wpinv_get_invoice_vat_number( $invoice_id = 0 ) {
648
-    $invoice = new WPInv_Invoice( $invoice_id );
647
+function wpinv_get_invoice_vat_number($invoice_id = 0) {
648
+    $invoice = new WPInv_Invoice($invoice_id);
649 649
     
650 650
     return $invoice->vat_number;
651 651
 }
652 652
 
653
-function wpinv_insert_payment_note( $invoice_id = 0, $note = '', $user_type = false, $added_by_user = false, $system = false ) {
654
-    $invoice = new WPInv_Invoice( $invoice_id );
653
+function wpinv_insert_payment_note($invoice_id = 0, $note = '', $user_type = false, $added_by_user = false, $system = false) {
654
+    $invoice = new WPInv_Invoice($invoice_id);
655 655
 
656
-    return $invoice->add_note( $note, $user_type, $added_by_user, $system );
656
+    return $invoice->add_note($note, $user_type, $added_by_user, $system);
657 657
 }
658 658
 
659
-function wpinv_get_invoice_notes( $invoice_id = 0, $type = '' ) {
659
+function wpinv_get_invoice_notes($invoice_id = 0, $type = '') {
660 660
     global $invoicing;
661 661
     
662
-    if ( empty( $invoice_id ) ) {
662
+    if (empty($invoice_id)) {
663 663
         return NULL;
664 664
     }
665 665
     
666
-    $notes = $invoicing->notes->get_invoice_notes( $invoice_id, $type );
666
+    $notes = $invoicing->notes->get_invoice_notes($invoice_id, $type);
667 667
     
668
-    return apply_filters( 'wpinv_invoice_notes', $notes, $invoice_id, $type );
668
+    return apply_filters('wpinv_invoice_notes', $notes, $invoice_id, $type);
669 669
 }
670 670
 
671
-function wpinv_get_payment_key( $invoice_id = 0 ) {
672
-	$invoice = new WPInv_Invoice( $invoice_id );
671
+function wpinv_get_payment_key($invoice_id = 0) {
672
+	$invoice = new WPInv_Invoice($invoice_id);
673 673
     return $invoice->get_key();
674 674
 }
675 675
 
676
-function wpinv_get_invoice_number( $invoice_id = 0 ) {
677
-    $invoice = new WPInv_Invoice( $invoice_id );
676
+function wpinv_get_invoice_number($invoice_id = 0) {
677
+    $invoice = new WPInv_Invoice($invoice_id);
678 678
     return $invoice->get_number();
679 679
 }
680 680
 
681
-function wpinv_get_cart_discountable_subtotal( $code_id ) {
681
+function wpinv_get_cart_discountable_subtotal($code_id) {
682 682
     $cart_items = wpinv_get_cart_content_details();
683 683
     $items      = array();
684 684
 
685
-    $excluded_items = wpinv_get_discount_excluded_items( $code_id );
685
+    $excluded_items = wpinv_get_discount_excluded_items($code_id);
686 686
 
687
-    if( $cart_items ) {
687
+    if ($cart_items) {
688 688
 
689
-        foreach( $cart_items as $item ) {
689
+        foreach ($cart_items as $item) {
690 690
 
691
-            if( ! in_array( $item['id'], $excluded_items ) ) {
692
-                $items[] =  $item;
691
+            if (!in_array($item['id'], $excluded_items)) {
692
+                $items[] = $item;
693 693
             }
694 694
         }
695 695
     }
696 696
 
697
-    $subtotal = wpinv_get_cart_items_subtotal( $items );
697
+    $subtotal = wpinv_get_cart_items_subtotal($items);
698 698
 
699
-    return apply_filters( 'wpinv_get_cart_discountable_subtotal', $subtotal );
699
+    return apply_filters('wpinv_get_cart_discountable_subtotal', $subtotal);
700 700
 }
701 701
 
702
-function wpinv_get_cart_items_subtotal( $items ) {
702
+function wpinv_get_cart_items_subtotal($items) {
703 703
     $subtotal = 0.00;
704 704
 
705
-    if ( is_array( $items ) && ! empty( $items ) ) {
706
-        $prices = wp_list_pluck( $items, 'subtotal' );
705
+    if (is_array($items) && !empty($items)) {
706
+        $prices = wp_list_pluck($items, 'subtotal');
707 707
 
708
-        if( is_array( $prices ) ) {
709
-            $subtotal = array_sum( $prices );
708
+        if (is_array($prices)) {
709
+            $subtotal = array_sum($prices);
710 710
         } else {
711 711
             $subtotal = 0.00;
712 712
         }
713 713
 
714
-        if( $subtotal < 0 ) {
714
+        if ($subtotal < 0) {
715 715
             $subtotal = 0.00;
716 716
         }
717 717
     }
718 718
 
719
-    return apply_filters( 'wpinv_get_cart_items_subtotal', $subtotal );
719
+    return apply_filters('wpinv_get_cart_items_subtotal', $subtotal);
720 720
 }
721 721
 
722
-function wpinv_get_cart_subtotal( $items = array() ) {
723
-    $items    = !empty( $items ) ? $items : wpinv_get_cart_content_details();
724
-    $subtotal = wpinv_get_cart_items_subtotal( $items );
722
+function wpinv_get_cart_subtotal($items = array()) {
723
+    $items    = !empty($items) ? $items : wpinv_get_cart_content_details();
724
+    $subtotal = wpinv_get_cart_items_subtotal($items);
725 725
 
726
-    return apply_filters( 'wpinv_get_cart_subtotal', $subtotal );
726
+    return apply_filters('wpinv_get_cart_subtotal', $subtotal);
727 727
 }
728 728
 
729
-function wpinv_cart_subtotal( $items = array() ) {
730
-    $price = wpinv_price( wpinv_format_amount( wpinv_get_cart_subtotal( $items ) ) );
729
+function wpinv_cart_subtotal($items = array()) {
730
+    $price = wpinv_price(wpinv_format_amount(wpinv_get_cart_subtotal($items)));
731 731
 
732 732
     return $price;
733 733
 }
734 734
 
735
-function wpinv_get_cart_total( $items = array(), $discounts = false, $invoice = array() ) {
736
-    $subtotal  = (float)wpinv_get_cart_subtotal( $items );
737
-    $discounts = (float)wpinv_get_cart_discounted_amount( $items );
738
-    $cart_tax  = (float)wpinv_get_cart_tax( $items );
735
+function wpinv_get_cart_total($items = array(), $discounts = false, $invoice = array()) {
736
+    $subtotal  = (float)wpinv_get_cart_subtotal($items);
737
+    $discounts = (float)wpinv_get_cart_discounted_amount($items);
738
+    $cart_tax  = (float)wpinv_get_cart_tax($items);
739 739
     $fees      = (float)wpinv_get_cart_fee_total();
740
-    if ( !empty( $invoice ) && $invoice->is_free_trial() ) {
740
+    if (!empty($invoice) && $invoice->is_free_trial()) {
741 741
         $total = 0;
742 742
     } else {
743
-        $total     = $subtotal - $discounts + $cart_tax + $fees;
743
+        $total = $subtotal - $discounts + $cart_tax + $fees;
744 744
     }
745 745
 
746
-    if ( $total < 0 ) {
746
+    if ($total < 0) {
747 747
         $total = 0.00;
748 748
     }
749 749
     
750
-    $total = (float)apply_filters( 'wpinv_get_cart_total', $total, $items );
750
+    $total = (float)apply_filters('wpinv_get_cart_total', $total, $items);
751 751
 
752
-    return wpinv_sanitize_amount( $total );
752
+    return wpinv_sanitize_amount($total);
753 753
 }
754 754
 
755
-function wpinv_cart_total( $cart_items = array(), $echo = true, $invoice = array() ) {
755
+function wpinv_cart_total($cart_items = array(), $echo = true, $invoice = array()) {
756 756
     global $cart_total;
757
-    $total = wpinv_price( wpinv_format_amount( wpinv_get_cart_total( $cart_items, NULL, $invoice ) ) );
758
-    $total = apply_filters( 'wpinv_cart_total', $total, $cart_items, $invoice );
757
+    $total = wpinv_price(wpinv_format_amount(wpinv_get_cart_total($cart_items, NULL, $invoice)));
758
+    $total = apply_filters('wpinv_cart_total', $total, $cart_items, $invoice);
759 759
     
760 760
     $cart_total = $total;
761 761
 
762
-    if ( !$echo ) {
762
+    if (!$echo) {
763 763
         return $total;
764 764
     }
765 765
 
766 766
     echo $total;
767 767
 }
768 768
 
769
-function wpinv_get_cart_tax( $items = array() ) {
769
+function wpinv_get_cart_tax($items = array()) {
770 770
     $cart_tax = 0;
771
-    $items    = !empty( $items ) ? $items : wpinv_get_cart_content_details();
771
+    $items    = !empty($items) ? $items : wpinv_get_cart_content_details();
772 772
 
773
-    if ( $items ) {
774
-        $taxes = wp_list_pluck( $items, 'tax' );
773
+    if ($items) {
774
+        $taxes = wp_list_pluck($items, 'tax');
775 775
 
776
-        if( is_array( $taxes ) ) {
777
-            $cart_tax = array_sum( $taxes );
776
+        if (is_array($taxes)) {
777
+            $cart_tax = array_sum($taxes);
778 778
         }
779 779
     }
780 780
 
781 781
     $cart_tax += wpinv_get_cart_fee_tax();
782 782
 
783
-    return apply_filters( 'wpinv_get_cart_tax', wpinv_sanitize_amount( $cart_tax ) );
783
+    return apply_filters('wpinv_get_cart_tax', wpinv_sanitize_amount($cart_tax));
784 784
 }
785 785
 
786
-function wpinv_cart_tax( $items = array(), $echo = false ) {
787
-    $cart_tax = wpinv_get_cart_tax( $items );
788
-    $cart_tax = wpinv_price( wpinv_format_amount( $cart_tax ) );
786
+function wpinv_cart_tax($items = array(), $echo = false) {
787
+    $cart_tax = wpinv_get_cart_tax($items);
788
+    $cart_tax = wpinv_price(wpinv_format_amount($cart_tax));
789 789
 
790
-    $tax = apply_filters( 'wpinv_cart_tax', $cart_tax, $items );
790
+    $tax = apply_filters('wpinv_cart_tax', $cart_tax, $items);
791 791
 
792
-    if ( !$echo ) {
792
+    if (!$echo) {
793 793
         return $tax;
794 794
     }
795 795
 
796 796
     echo $tax;
797 797
 }
798 798
 
799
-function wpinv_get_cart_discount_code( $items = array() ) {
799
+function wpinv_get_cart_discount_code($items = array()) {
800 800
     $invoice = wpinv_get_invoice_cart();
801
-    $cart_discount_code = !empty( $invoice ) ? $invoice->get_discount_code() : '';
801
+    $cart_discount_code = !empty($invoice) ? $invoice->get_discount_code() : '';
802 802
     
803
-    return apply_filters( 'wpinv_get_cart_discount_code', $cart_discount_code );
803
+    return apply_filters('wpinv_get_cart_discount_code', $cart_discount_code);
804 804
 }
805 805
 
806
-function wpinv_cart_discount_code( $items = array(), $echo = false ) {
807
-    $cart_discount_code = wpinv_get_cart_discount_code( $items );
806
+function wpinv_cart_discount_code($items = array(), $echo = false) {
807
+    $cart_discount_code = wpinv_get_cart_discount_code($items);
808 808
 
809
-    if ( $cart_discount_code != '' ) {
809
+    if ($cart_discount_code != '') {
810 810
         $cart_discount_code = ' (' . $cart_discount_code . ')';
811 811
     }
812 812
     
813
-    $discount_code = apply_filters( 'wpinv_cart_discount_code', $cart_discount_code, $items );
813
+    $discount_code = apply_filters('wpinv_cart_discount_code', $cart_discount_code, $items);
814 814
 
815
-    if ( !$echo ) {
815
+    if (!$echo) {
816 816
         return $discount_code;
817 817
     }
818 818
 
819 819
     echo $discount_code;
820 820
 }
821 821
 
822
-function wpinv_get_cart_discount( $items = array() ) {
822
+function wpinv_get_cart_discount($items = array()) {
823 823
     $invoice = wpinv_get_invoice_cart();
824
-    $cart_discount = !empty( $invoice ) ? $invoice->get_discount() : 0;
824
+    $cart_discount = !empty($invoice) ? $invoice->get_discount() : 0;
825 825
     
826
-    return apply_filters( 'wpinv_get_cart_discount', wpinv_sanitize_amount( $cart_discount ), $items );
826
+    return apply_filters('wpinv_get_cart_discount', wpinv_sanitize_amount($cart_discount), $items);
827 827
 }
828 828
 
829
-function wpinv_cart_discount( $items = array(), $echo = false ) {
830
-    $cart_discount = wpinv_get_cart_discount( $items );
831
-    $cart_discount = wpinv_price( wpinv_format_amount( $cart_discount ) );
829
+function wpinv_cart_discount($items = array(), $echo = false) {
830
+    $cart_discount = wpinv_get_cart_discount($items);
831
+    $cart_discount = wpinv_price(wpinv_format_amount($cart_discount));
832 832
 
833
-    $discount = apply_filters( 'wpinv_cart_discount', $cart_discount, $items );
833
+    $discount = apply_filters('wpinv_cart_discount', $cart_discount, $items);
834 834
 
835
-    if ( !$echo ) {
835
+    if (!$echo) {
836 836
         return $discount;
837 837
     }
838 838
 
839 839
     echo $discount;
840 840
 }
841 841
 
842
-function wpinv_get_cart_fees( $type = 'all', $item_id = 0 ) {
843
-    $item = new WPInv_Item( $item_id );
842
+function wpinv_get_cart_fees($type = 'all', $item_id = 0) {
843
+    $item = new WPInv_Item($item_id);
844 844
     
845
-    return $item->get_fees( $type, $item_id );
845
+    return $item->get_fees($type, $item_id);
846 846
 }
847 847
 
848 848
 function wpinv_get_cart_fee_total() {
849
-    $total  = 0;
849
+    $total = 0;
850 850
     $fees = wpinv_get_cart_fees();
851 851
     
852
-    if ( $fees ) {
853
-        foreach ( $fees as $fee_id => $fee ) {
852
+    if ($fees) {
853
+        foreach ($fees as $fee_id => $fee) {
854 854
             $total += $fee['amount'];
855 855
         }
856 856
     }
857 857
 
858
-    return apply_filters( 'wpinv_get_cart_fee_total', $total );
858
+    return apply_filters('wpinv_get_cart_fee_total', $total);
859 859
 }
860 860
 
861 861
 function wpinv_get_cart_fee_tax() {
862 862
     $tax  = 0;
863 863
     $fees = wpinv_get_cart_fees();
864 864
 
865
-    if ( $fees ) {
866
-        foreach ( $fees as $fee_id => $fee ) {
867
-            if( ! empty( $fee['no_tax'] ) ) {
865
+    if ($fees) {
866
+        foreach ($fees as $fee_id => $fee) {
867
+            if (!empty($fee['no_tax'])) {
868 868
                 continue;
869 869
             }
870 870
 
871
-            $tax += wpinv_calculate_tax( $fee['amount'] );
871
+            $tax += wpinv_calculate_tax($fee['amount']);
872 872
         }
873 873
     }
874 874
 
875
-    return apply_filters( 'wpinv_get_cart_fee_tax', $tax );
875
+    return apply_filters('wpinv_get_cart_fee_tax', $tax);
876 876
 }
877 877
 
878 878
 function wpinv_cart_has_recurring_item() {
879 879
     $cart_items = wpinv_get_cart_contents();
880 880
     
881
-    if ( empty( $cart_items ) ) {
881
+    if (empty($cart_items)) {
882 882
         return false;
883 883
     }
884 884
     
885 885
     $has_subscription = false;
886
-    foreach( $cart_items as $cart_item ) {
887
-        if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
886
+    foreach ($cart_items as $cart_item) {
887
+        if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
888 888
             $has_subscription = true;
889 889
             break;
890 890
         }
891 891
     }
892 892
     
893
-    return apply_filters( 'wpinv_cart_has_recurring_item', $has_subscription, $cart_items );
893
+    return apply_filters('wpinv_cart_has_recurring_item', $has_subscription, $cart_items);
894 894
 }
895 895
 
896 896
 function wpinv_cart_has_free_trial() {
@@ -898,97 +898,97 @@  discard block
 block discarded – undo
898 898
     
899 899
     $free_trial = false;
900 900
     
901
-    if ( !empty( $invoice ) && $invoice->is_free_trial() ) {
901
+    if (!empty($invoice) && $invoice->is_free_trial()) {
902 902
         $free_trial = true;
903 903
     }
904 904
     
905
-    return apply_filters( 'wpinv_cart_has_free_trial', $free_trial, $invoice );
905
+    return apply_filters('wpinv_cart_has_free_trial', $free_trial, $invoice);
906 906
 }
907 907
 
908 908
 function wpinv_get_cart_contents() {
909 909
     $cart_details = wpinv_get_cart_details();
910 910
     
911
-    return apply_filters( 'wpinv_get_cart_contents', $cart_details );
911
+    return apply_filters('wpinv_get_cart_contents', $cart_details);
912 912
 }
913 913
 
914 914
 function wpinv_get_cart_content_details() {
915 915
     global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpinv_is_last_cart_item, $wpinv_flat_discount_total;
916 916
     $cart_items = wpinv_get_cart_contents();
917 917
     
918
-    if ( empty( $cart_items ) ) {
918
+    if (empty($cart_items)) {
919 919
         return false;
920 920
     }
921 921
     $invoice = wpinv_get_invoice_cart();
922
-	if ( empty( $invoice ) ) {
922
+	if (empty($invoice)) {
923 923
         return false;
924 924
     }
925 925
 
926 926
     $details = array();
927
-    $length  = count( $cart_items ) - 1;
927
+    $length  = count($cart_items) - 1;
928 928
     
929
-    if ( empty( $_POST['country'] ) ) {
929
+    if (empty($_POST['country'])) {
930 930
         $_POST['country'] = $invoice->country;
931 931
     }
932
-    if ( !isset( $_POST['state'] ) ) {
932
+    if (!isset($_POST['state'])) {
933 933
         $_POST['state'] = $invoice->state;
934 934
     }
935 935
 
936
-    foreach( $cart_items as $key => $item ) {
937
-        $item_id            = isset( $item['id'] ) ? sanitize_text_field( $item['id'] ) : '';
938
-        if ( empty( $item_id ) ) {
936
+    foreach ($cart_items as $key => $item) {
937
+        $item_id = isset($item['id']) ? sanitize_text_field($item['id']) : '';
938
+        if (empty($item_id)) {
939 939
             continue;
940 940
         }
941 941
         
942 942
         $wpi_current_id         = $invoice->ID;
943 943
         $wpi_item_id            = $item_id;
944 944
         
945
-        if ( isset( $item['custom_price'] ) && $item['custom_price'] !== '' ) {
945
+        if (isset($item['custom_price']) && $item['custom_price'] !== '') {
946 946
             $item_price = $item['custom_price'];
947 947
         } else {
948
-            if ( isset( $item['item_price'] ) && $item['item_price'] !== '' && $item['item_price'] !== false ) {
948
+            if (isset($item['item_price']) && $item['item_price'] !== '' && $item['item_price'] !== false) {
949 949
                 $item_price = $item['item_price'];
950 950
             } else {
951
-                $item_price = wpinv_get_item_price( $item_id );
951
+                $item_price = wpinv_get_item_price($item_id);
952 952
             }
953 953
         }
954
-        $discount           = wpinv_get_cart_item_discount_amount( $item );
955
-        $discount           = apply_filters( 'wpinv_get_cart_content_details_item_discount_amount', $discount, $item );
956
-        $quantity           = wpinv_get_cart_item_quantity( $item );
957
-        $fees               = wpinv_get_cart_fees( 'fee', $item_id );
954
+        $discount           = wpinv_get_cart_item_discount_amount($item);
955
+        $discount           = apply_filters('wpinv_get_cart_content_details_item_discount_amount', $discount, $item);
956
+        $quantity           = wpinv_get_cart_item_quantity($item);
957
+        $fees               = wpinv_get_cart_fees('fee', $item_id);
958 958
         
959 959
         $subtotal           = $item_price * $quantity;
960
-        $tax_rate           = wpinv_get_tax_rate( $_POST['country'], $_POST['state'], $wpi_item_id );
961
-        $tax_class          = $wpinv_euvat->get_item_class( $item_id );
962
-        $tax                = wpinv_get_cart_item_tax( $item_id, $subtotal - $discount );
960
+        $tax_rate           = wpinv_get_tax_rate($_POST['country'], $_POST['state'], $wpi_item_id);
961
+        $tax_class          = $wpinv_euvat->get_item_class($item_id);
962
+        $tax                = wpinv_get_cart_item_tax($item_id, $subtotal - $discount);
963 963
         
964
-        if ( wpinv_prices_include_tax() ) {
965
-            $subtotal -= wpinv_round_amount( $tax );
964
+        if (wpinv_prices_include_tax()) {
965
+            $subtotal -= wpinv_round_amount($tax);
966 966
         }
967 967
         
968
-        $total              = $subtotal - $discount + $tax;
968
+        $total = $subtotal - $discount + $tax;
969 969
         
970 970
         // Do not allow totals to go negatve
971
-        if( $total < 0 ) {
971
+        if ($total < 0) {
972 972
             $total = 0;
973 973
         }
974 974
         
975
-        $details[ $key ]  = array(
975
+        $details[$key] = array(
976 976
             'id'                => $item_id,
977
-            'name'              => !empty($item['name']) ? $item['name'] : get_the_title( $item_id ),
978
-            'item_price'        => wpinv_round_amount( $item_price ),
979
-            'custom_price'      => isset( $item['custom_price'] ) ? $item['custom_price'] : '',
977
+            'name'              => !empty($item['name']) ? $item['name'] : get_the_title($item_id),
978
+            'item_price'        => wpinv_round_amount($item_price),
979
+            'custom_price'      => isset($item['custom_price']) ? $item['custom_price'] : '',
980 980
             'quantity'          => $quantity,
981
-            'discount'          => wpinv_round_amount( $discount ),
982
-            'subtotal'          => wpinv_round_amount( $subtotal ),
983
-            'tax'               => wpinv_round_amount( $tax ),
984
-            'price'             => wpinv_round_amount( $total ),
981
+            'discount'          => wpinv_round_amount($discount),
982
+            'subtotal'          => wpinv_round_amount($subtotal),
983
+            'tax'               => wpinv_round_amount($tax),
984
+            'price'             => wpinv_round_amount($total),
985 985
             'vat_rates_class'   => $tax_class,
986 986
             'vat_rate'          => $tax_rate,
987
-            'meta'              => isset( $item['meta'] ) ? $item['meta'] : array(),
987
+            'meta'              => isset($item['meta']) ? $item['meta'] : array(),
988 988
             'fees'              => $fees,
989 989
         );
990 990
         
991
-        if ( $wpinv_is_last_cart_item ) {
991
+        if ($wpinv_is_last_cart_item) {
992 992
             $wpinv_is_last_cart_item   = false;
993 993
             $wpinv_flat_discount_total = 0.00;
994 994
         }
@@ -997,67 +997,67 @@  discard block
 block discarded – undo
997 997
     return $details;
998 998
 }
999 999
 
1000
-function wpinv_get_cart_details( $invoice_id = 0 ) {
1000
+function wpinv_get_cart_details($invoice_id = 0) {
1001 1001
     global $ajax_cart_details;
1002 1002
 
1003
-    $invoice      = wpinv_get_invoice_cart( $invoice_id );
1003
+    $invoice      = wpinv_get_invoice_cart($invoice_id);
1004 1004
     $cart_details = $ajax_cart_details;
1005
-    if ( empty( $cart_details ) && ! empty( $invoice->cart_details ) ) {
1005
+    if (empty($cart_details) && !empty($invoice->cart_details)) {
1006 1006
         $cart_details = $invoice->cart_details;
1007 1007
     }
1008 1008
 
1009
-    if ( ! empty( $cart_details ) && is_array( $cart_details ) ) {
1010
-        $invoice_currency = ! empty( $invoice->currency ) ? $invoice->currency : wpinv_get_default_country();
1009
+    if (!empty($cart_details) && is_array($cart_details)) {
1010
+        $invoice_currency = !empty($invoice->currency) ? $invoice->currency : wpinv_get_default_country();
1011 1011
 
1012
-        foreach ( $cart_details as $key => $cart_item ) {
1013
-            $cart_details[ $key ]['currency'] = $invoice_currency;
1012
+        foreach ($cart_details as $key => $cart_item) {
1013
+            $cart_details[$key]['currency'] = $invoice_currency;
1014 1014
 
1015
-            if ( ! isset( $cart_item['subtotal'] ) ) {
1016
-                $cart_details[ $key ]['subtotal'] = $cart_item['price'];
1015
+            if (!isset($cart_item['subtotal'])) {
1016
+                $cart_details[$key]['subtotal'] = $cart_item['price'];
1017 1017
             }
1018 1018
         }
1019 1019
     }
1020 1020
 
1021
-    return apply_filters( 'wpinv_get_cart_details', $cart_details, $invoice_id );
1021
+    return apply_filters('wpinv_get_cart_details', $cart_details, $invoice_id);
1022 1022
 }
1023 1023
 
1024
-function wpinv_record_status_change( $invoice_id, $new_status, $old_status ) {
1025
-    if ( 'wpi_invoice' != get_post_type( $invoice_id ) ) {
1024
+function wpinv_record_status_change($invoice_id, $new_status, $old_status) {
1025
+    if ('wpi_invoice' != get_post_type($invoice_id)) {
1026 1026
         return;
1027 1027
     }
1028 1028
 
1029
-    if ( ( $old_status == 'wpi-pending' && $new_status == 'draft' ) || ( $old_status == 'draft' && $new_status == 'wpi-pending' ) ) {
1029
+    if (($old_status == 'wpi-pending' && $new_status == 'draft') || ($old_status == 'draft' && $new_status == 'wpi-pending')) {
1030 1030
         return;
1031 1031
     }
1032 1032
 
1033
-    $invoice    = wpinv_get_invoice( $invoice_id );
1033
+    $invoice    = wpinv_get_invoice($invoice_id);
1034 1034
     
1035
-    $old_status = wpinv_status_nicename( $old_status );
1036
-    $new_status = wpinv_status_nicename( $new_status );
1035
+    $old_status = wpinv_status_nicename($old_status);
1036
+    $new_status = wpinv_status_nicename($new_status);
1037 1037
 
1038
-    $status_change = sprintf( __( 'Invoice status changed from %s to %s', 'invoicing' ), $old_status, $new_status );
1038
+    $status_change = sprintf(__('Invoice status changed from %s to %s', 'invoicing'), $old_status, $new_status);
1039 1039
     
1040 1040
     // Add note
1041
-    return $invoice->add_note( $status_change, false, false, true );
1041
+    return $invoice->add_note($status_change, false, false, true);
1042 1042
 }
1043
-add_action( 'wpinv_update_status', 'wpinv_record_status_change', 100, 3 );
1043
+add_action('wpinv_update_status', 'wpinv_record_status_change', 100, 3);
1044 1044
 
1045
-function wpinv_complete_payment( $invoice_id, $new_status, $old_status ) {
1045
+function wpinv_complete_payment($invoice_id, $new_status, $old_status) {
1046 1046
     global $wpi_has_free_trial;
1047 1047
     
1048 1048
     $wpi_has_free_trial = false;
1049 1049
     
1050
-    if ( $old_status == 'publish' ) {
1050
+    if ($old_status == 'publish') {
1051 1051
         return; // Make sure that payments are only paid once
1052 1052
     }
1053 1053
 
1054 1054
     // Make sure the payment completion is only processed when new status is paid
1055
-    if ( $new_status != 'publish' ) {
1055
+    if ($new_status != 'publish') {
1056 1056
         return;
1057 1057
     }
1058 1058
 
1059
-    $invoice = new WPInv_Invoice( $invoice_id );
1060
-    if ( empty( $invoice ) ) {
1059
+    $invoice = new WPInv_Invoice($invoice_id);
1060
+    if (empty($invoice)) {
1061 1061
         return;
1062 1062
     }
1063 1063
 
@@ -1065,58 +1065,58 @@  discard block
 block discarded – undo
1065 1065
     $completed_date = $invoice->completed_date;
1066 1066
     $cart_details   = $invoice->cart_details;
1067 1067
 
1068
-    do_action( 'wpinv_pre_complete_payment', $invoice_id );
1068
+    do_action('wpinv_pre_complete_payment', $invoice_id);
1069 1069
 
1070
-    if ( is_array( $cart_details ) ) {
1070
+    if (is_array($cart_details)) {
1071 1071
         // Increase purchase count and earnings
1072
-        foreach ( $cart_details as $cart_index => $item ) {
1072
+        foreach ($cart_details as $cart_index => $item) {
1073 1073
             // Ensure these actions only run once, ever
1074
-            if ( empty( $completed_date ) ) {
1075
-                do_action( 'wpinv_complete_item_payment', $item['id'], $invoice_id, $item, $cart_index );
1074
+            if (empty($completed_date)) {
1075
+                do_action('wpinv_complete_item_payment', $item['id'], $invoice_id, $item, $cart_index);
1076 1076
             }
1077 1077
         }
1078 1078
     }
1079 1079
     
1080 1080
     // Check for discount codes and increment their use counts
1081
-    if ( $discounts = $invoice->get_discounts( true ) ) {
1082
-        if( ! empty( $discounts ) ) {
1083
-            foreach( $discounts as $code ) {
1084
-                wpinv_increase_discount_usage( $code );
1081
+    if ($discounts = $invoice->get_discounts(true)) {
1082
+        if (!empty($discounts)) {
1083
+            foreach ($discounts as $code) {
1084
+                wpinv_increase_discount_usage($code);
1085 1085
             }
1086 1086
         }
1087 1087
     }
1088 1088
     
1089 1089
     // Ensure this action only runs once ever
1090
-    if( empty( $completed_date ) ) {
1090
+    if (empty($completed_date)) {
1091 1091
         // Save the completed date
1092
-        $invoice->set( 'completed_date', current_time( 'mysql', 0 ) );
1092
+        $invoice->set('completed_date', current_time('mysql', 0));
1093 1093
         $invoice->save();
1094 1094
 
1095
-        do_action( 'wpinv_complete_payment', $invoice_id );
1095
+        do_action('wpinv_complete_payment', $invoice_id);
1096 1096
     }
1097 1097
 
1098 1098
     // Empty the shopping cart
1099 1099
     wpinv_empty_cart();
1100 1100
 }
1101
-add_action( 'wpinv_update_status', 'wpinv_complete_payment', 100, 3 );
1101
+add_action('wpinv_update_status', 'wpinv_complete_payment', 100, 3);
1102 1102
 
1103
-function wpinv_update_payment_status( $invoice_id, $new_status = 'publish' ) {    
1104
-    $invoice = !empty( $invoice_id ) && is_object( $invoice_id ) ? $invoice_id : wpinv_get_invoice( (int)$invoice_id );
1103
+function wpinv_update_payment_status($invoice_id, $new_status = 'publish') {    
1104
+    $invoice = !empty($invoice_id) && is_object($invoice_id) ? $invoice_id : wpinv_get_invoice((int)$invoice_id);
1105 1105
     
1106
-    if ( empty( $invoice ) ) {
1106
+    if (empty($invoice)) {
1107 1107
         return false;
1108 1108
     }
1109 1109
     
1110
-    return $invoice->update_status( $new_status );
1110
+    return $invoice->update_status($new_status);
1111 1111
 }
1112 1112
 
1113
-function wpinv_cart_has_fees( $type = 'all' ) {
1113
+function wpinv_cart_has_fees($type = 'all') {
1114 1114
     return false;
1115 1115
 }
1116 1116
 
1117 1117
 function wpinv_validate_checkout_fields() {    
1118 1118
     // Check if there is $_POST
1119
-    if ( empty( $_POST ) ) {
1119
+    if (empty($_POST)) {
1120 1120
         return false;
1121 1121
     }
1122 1122
     
@@ -1128,11 +1128,11 @@  discard block
 block discarded – undo
1128 1128
     );
1129 1129
     
1130 1130
     // Validate agree to terms
1131
-    $page = wpinv_get_option( 'tandc_page' );
1132
-    if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){
1131
+    $page = wpinv_get_option('tandc_page');
1132
+    if (isset($page) && (int)$page > 0 && apply_filters('wpinv_checkout_show_terms', true)) {
1133 1133
         // Validate agree to terms
1134
-        if ( ! isset( $_POST['wpi_terms'] ) || !$_POST['wpi_terms'] ) {
1135
-            wpinv_set_error( 'accept_terms', apply_filters( 'wpinv_accept_terms_error_text', __( 'You must accept terms and conditions', 'invoicing' ) ) );
1134
+        if (!isset($_POST['wpi_terms']) || !$_POST['wpi_terms']) {
1135
+            wpinv_set_error('accept_terms', apply_filters('wpinv_accept_terms_error_text', __('You must accept terms and conditions', 'invoicing')));
1136 1136
         }
1137 1137
     }
1138 1138
     
@@ -1148,26 +1148,26 @@  discard block
 block discarded – undo
1148 1148
     
1149 1149
     $invoice = wpinv_get_invoice_cart();
1150 1150
     $has_subscription = $invoice->is_recurring();
1151
-    if ( empty( $invoice ) ) {
1152
-        wpinv_set_error( 'invalid_invoice', __( 'Your cart is empty.', 'invoicing' ) );
1151
+    if (empty($invoice)) {
1152
+        wpinv_set_error('invalid_invoice', __('Your cart is empty.', 'invoicing'));
1153 1153
         return $gateway;
1154 1154
     }
1155 1155
 
1156 1156
     // Check if a gateway value is present
1157
-    if ( !empty( $_REQUEST['wpi-gateway'] ) ) {
1158
-        $gateway = sanitize_text_field( $_REQUEST['wpi-gateway'] );
1157
+    if (!empty($_REQUEST['wpi-gateway'])) {
1158
+        $gateway = sanitize_text_field($_REQUEST['wpi-gateway']);
1159 1159
 
1160
-        if ( $invoice->is_free() ) {
1160
+        if ($invoice->is_free()) {
1161 1161
             $gateway = 'manual';
1162
-        } elseif ( !wpinv_is_gateway_active( $gateway ) ) {
1163
-            wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled', 'invoicing' ) );
1164
-        } elseif ( $has_subscription && !wpinv_gateway_support_subscription( $gateway ) ) {
1165
-            wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway doesnot support subscription payment', 'invoicing' ) );
1162
+        } elseif (!wpinv_is_gateway_active($gateway)) {
1163
+            wpinv_set_error('invalid_gateway', __('The selected payment gateway is not enabled', 'invoicing'));
1164
+        } elseif ($has_subscription && !wpinv_gateway_support_subscription($gateway)) {
1165
+            wpinv_set_error('invalid_gateway', __('The selected payment gateway doesnot support subscription payment', 'invoicing'));
1166 1166
         }
1167 1167
     }
1168 1168
 
1169
-    if ( $has_subscription && count( wpinv_get_cart_contents() ) > 1 ) {
1170
-        wpinv_set_error( 'subscription_invalid', __( 'Only one subscription may be purchased through payment per checkout.', 'invoicing' ) );
1169
+    if ($has_subscription && count(wpinv_get_cart_contents()) > 1) {
1170
+        wpinv_set_error('subscription_invalid', __('Only one subscription may be purchased through payment per checkout.', 'invoicing'));
1171 1171
     }
1172 1172
 
1173 1173
     return $gateway;
@@ -1181,10 +1181,10 @@  discard block
 block discarded – undo
1181 1181
     
1182 1182
     $error = false;
1183 1183
     // If we have discounts, loop through them
1184
-    if ( ! empty( $discounts ) ) {
1185
-        foreach ( $discounts as $discount ) {
1184
+    if (!empty($discounts)) {
1185
+        foreach ($discounts as $discount) {
1186 1186
             // Check if valid
1187
-            if (  !wpinv_is_discount_valid( $discount, (int)$wpi_cart->get_user_id() ) ) {
1187
+            if (!wpinv_is_discount_valid($discount, (int)$wpi_cart->get_user_id())) {
1188 1188
                 // Discount is not valid
1189 1189
                 $error = true;
1190 1190
             }
@@ -1194,20 +1194,20 @@  discard block
 block discarded – undo
1194 1194
         return NULL;
1195 1195
     }
1196 1196
 
1197
-    if ( $error && !wpinv_get_errors() ) {
1198
-        wpinv_set_error( 'invalid_discount', __( 'Discount code you entered is invalid', 'invoicing' ) );
1197
+    if ($error && !wpinv_get_errors()) {
1198
+        wpinv_set_error('invalid_discount', __('Discount code you entered is invalid', 'invoicing'));
1199 1199
     }
1200 1200
 
1201
-    return implode( ',', $discounts );
1201
+    return implode(',', $discounts);
1202 1202
 }
1203 1203
 
1204 1204
 function wpinv_checkout_validate_cc() {
1205 1205
     $card_data = wpinv_checkout_get_cc_info();
1206 1206
 
1207 1207
     // Validate the card zip
1208
-    if ( !empty( $card_data['wpinv_zip'] ) ) {
1209
-        if ( !wpinv_checkout_validate_cc_zip( $card_data['wpinv_zip'], $card_data['wpinv_country'] ) ) {
1210
-            wpinv_set_error( 'invalid_cc_zip', __( 'The zip / postcode you entered for your billing address is invalid', 'invoicing' ) );
1208
+    if (!empty($card_data['wpinv_zip'])) {
1209
+        if (!wpinv_checkout_validate_cc_zip($card_data['wpinv_zip'], $card_data['wpinv_country'])) {
1210
+            wpinv_set_error('invalid_cc_zip', __('The zip / postcode you entered for your billing address is invalid', 'invoicing'));
1211 1211
         }
1212 1212
     }
1213 1213
 
@@ -1217,28 +1217,28 @@  discard block
 block discarded – undo
1217 1217
 
1218 1218
 function wpinv_checkout_get_cc_info() {
1219 1219
 	$cc_info = array();
1220
-	$cc_info['card_name']      = isset( $_POST['card_name'] )       ? sanitize_text_field( $_POST['card_name'] )       : '';
1221
-	$cc_info['card_number']    = isset( $_POST['card_number'] )     ? sanitize_text_field( $_POST['card_number'] )     : '';
1222
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] )        ? sanitize_text_field( $_POST['card_cvc'] )        : '';
1223
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] )  ? sanitize_text_field( $_POST['card_exp_month'] )  : '';
1224
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] )   ? sanitize_text_field( $_POST['card_exp_year'] )   : '';
1225
-	$cc_info['card_address']   = isset( $_POST['wpinv_address'] )  ? sanitize_text_field( $_POST['wpinv_address'] ) : '';
1226
-	$cc_info['card_city']      = isset( $_POST['wpinv_city'] )     ? sanitize_text_field( $_POST['wpinv_city'] )    : '';
1227
-	$cc_info['card_state']     = isset( $_POST['wpinv_state'] )    ? sanitize_text_field( $_POST['wpinv_state'] )   : '';
1228
-	$cc_info['card_country']   = isset( $_POST['wpinv_country'] )  ? sanitize_text_field( $_POST['wpinv_country'] ) : '';
1229
-	$cc_info['card_zip']       = isset( $_POST['wpinv_zip'] )      ? sanitize_text_field( $_POST['wpinv_zip'] )     : '';
1220
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
1221
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
1222
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
1223
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
1224
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
1225
+	$cc_info['card_address']   = isset($_POST['wpinv_address']) ? sanitize_text_field($_POST['wpinv_address']) : '';
1226
+	$cc_info['card_city']      = isset($_POST['wpinv_city']) ? sanitize_text_field($_POST['wpinv_city']) : '';
1227
+	$cc_info['card_state']     = isset($_POST['wpinv_state']) ? sanitize_text_field($_POST['wpinv_state']) : '';
1228
+	$cc_info['card_country']   = isset($_POST['wpinv_country']) ? sanitize_text_field($_POST['wpinv_country']) : '';
1229
+	$cc_info['card_zip']       = isset($_POST['wpinv_zip']) ? sanitize_text_field($_POST['wpinv_zip']) : '';
1230 1230
 
1231 1231
 	// Return cc info
1232 1232
 	return $cc_info;
1233 1233
 }
1234 1234
 
1235
-function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) {
1235
+function wpinv_checkout_validate_cc_zip($zip = 0, $country_code = '') {
1236 1236
     $ret = false;
1237 1237
 
1238
-    if ( empty( $zip ) || empty( $country_code ) )
1238
+    if (empty($zip) || empty($country_code))
1239 1239
         return $ret;
1240 1240
 
1241
-    $country_code = strtoupper( $country_code );
1241
+    $country_code = strtoupper($country_code);
1242 1242
 
1243 1243
     $zip_regex = array(
1244 1244
         "AD" => "AD\d{3}",
@@ -1398,17 +1398,17 @@  discard block
 block discarded – undo
1398 1398
         "ZM" => "\d{5}"
1399 1399
     );
1400 1400
 
1401
-    if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) )
1401
+    if (!isset ($zip_regex[$country_code]) || preg_match("/" . $zip_regex[$country_code] . "/i", $zip))
1402 1402
         $ret = true;
1403 1403
 
1404
-    return apply_filters( 'wpinv_is_zip_valid', $ret, $zip, $country_code );
1404
+    return apply_filters('wpinv_is_zip_valid', $ret, $zip, $country_code);
1405 1405
 }
1406 1406
 
1407 1407
 function wpinv_checkout_validate_agree_to_terms() {
1408 1408
     // Validate agree to terms
1409
-    if ( ! isset( $_POST['wpi_agree_to_terms'] ) || $_POST['wpi_agree_to_terms'] != 1 ) {
1409
+    if (!isset($_POST['wpi_agree_to_terms']) || $_POST['wpi_agree_to_terms'] != 1) {
1410 1410
         // User did not agree
1411
-        wpinv_set_error( 'agree_to_terms', apply_filters( 'wpinv_agree_to_terms_text', __( 'You must agree to the terms of use', 'invoicing' ) ) );
1411
+        wpinv_set_error('agree_to_terms', apply_filters('wpinv_agree_to_terms_text', __('You must agree to the terms of use', 'invoicing')));
1412 1412
     }
1413 1413
 }
1414 1414
 
@@ -1420,40 +1420,40 @@  discard block
 block discarded – undo
1420 1420
     );
1421 1421
     
1422 1422
     // Verify there is a user_ID
1423
-    if ( $user_ID == (int)$wpi_cart->get_user_id() ) {
1423
+    if ($user_ID == (int)$wpi_cart->get_user_id()) {
1424 1424
         // Get the logged in user data
1425
-        $user_data = get_userdata( $user_ID );
1426
-        $required_fields  = wpinv_checkout_required_fields();
1425
+        $user_data = get_userdata($user_ID);
1426
+        $required_fields = wpinv_checkout_required_fields();
1427 1427
 
1428 1428
         // Loop through required fields and show error messages
1429
-         if ( !empty( $required_fields ) ) {
1430
-            foreach ( $required_fields as $field_name => $value ) {
1431
-                if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) {
1432
-                    wpinv_set_error( $value['error_id'], $value['error_message'] );
1429
+         if (!empty($required_fields)) {
1430
+            foreach ($required_fields as $field_name => $value) {
1431
+                if (in_array($value, $required_fields) && empty($_POST['wpinv_' . $field_name])) {
1432
+                    wpinv_set_error($value['error_id'], $value['error_message']);
1433 1433
                 }
1434 1434
             }
1435 1435
         }
1436 1436
 
1437 1437
         // Verify data
1438
-        if ( $user_data ) {
1438
+        if ($user_data) {
1439 1439
             // Collected logged in user data
1440 1440
             $valid_user_data = array(
1441 1441
                 'user_id'     => $user_ID,
1442
-                'email'       => isset( $_POST['wpinv_email'] ) ? sanitize_email( $_POST['wpinv_email'] ) : $user_data->user_email,
1443
-                'first_name'  => isset( $_POST['wpinv_first_name'] ) && ! empty( $_POST['wpinv_first_name'] ) ? sanitize_text_field( $_POST['wpinv_first_name'] ) : $user_data->first_name,
1444
-                'last_name'   => isset( $_POST['wpinv_last_name'] ) && ! empty( $_POST['wpinv_last_name']  ) ? sanitize_text_field( $_POST['wpinv_last_name']  ) : $user_data->last_name,
1442
+                'email'       => isset($_POST['wpinv_email']) ? sanitize_email($_POST['wpinv_email']) : $user_data->user_email,
1443
+                'first_name'  => isset($_POST['wpinv_first_name']) && !empty($_POST['wpinv_first_name']) ? sanitize_text_field($_POST['wpinv_first_name']) : $user_data->first_name,
1444
+                'last_name'   => isset($_POST['wpinv_last_name']) && !empty($_POST['wpinv_last_name']) ? sanitize_text_field($_POST['wpinv_last_name']) : $user_data->last_name,
1445 1445
             );
1446 1446
 
1447
-            if ( !empty( $_POST[ 'wpinv_email' ] ) && !is_email( $_POST[ 'wpinv_email' ] ) ) {
1448
-                wpinv_set_error( 'invalid_email', __( 'Please enter a valid email address', 'invoicing' ) );
1447
+            if (!empty($_POST['wpinv_email']) && !is_email($_POST['wpinv_email'])) {
1448
+                wpinv_set_error('invalid_email', __('Please enter a valid email address', 'invoicing'));
1449 1449
             }
1450 1450
         } else {
1451 1451
             // Set invalid user error
1452
-            wpinv_set_error( 'invalid_user', __( 'The user billing information is invalid', 'invoicing' ) );
1452
+            wpinv_set_error('invalid_user', __('The user billing information is invalid', 'invoicing'));
1453 1453
         }
1454 1454
     } else {
1455 1455
         // Set invalid user error
1456
-        wpinv_set_error( 'invalid_user_id', __( 'The invalid invoice user id', 'invoicing' ) );
1456
+        wpinv_set_error('invalid_user_id', __('The invalid invoice user id', 'invoicing'));
1457 1457
     }
1458 1458
 
1459 1459
     // Return user data
@@ -1465,30 +1465,30 @@  discard block
 block discarded – undo
1465 1465
 
1466 1466
     $data = array();
1467 1467
     
1468
-    if ( is_user_logged_in() ) {
1469
-        if ( !wpinv_require_login_to_checkout() || ( wpinv_require_login_to_checkout() && (int)$wpi_cart->get_user_id() === (int)get_current_user_id() ) ) {
1468
+    if (is_user_logged_in()) {
1469
+        if (!wpinv_require_login_to_checkout() || (wpinv_require_login_to_checkout() && (int)$wpi_cart->get_user_id() === (int)get_current_user_id())) {
1470 1470
             $data['user_id'] = (int)get_current_user_id();
1471 1471
         } else {
1472
-            wpinv_set_error( 'logged_in_only', __( 'You are not allowed to pay for this invoice', 'invoicing' ) );
1472
+            wpinv_set_error('logged_in_only', __('You are not allowed to pay for this invoice', 'invoicing'));
1473 1473
         }
1474 1474
     } else {
1475 1475
         // If guest checkout allowed
1476
-        if ( !wpinv_require_login_to_checkout() ) {
1476
+        if (!wpinv_require_login_to_checkout()) {
1477 1477
             $data['user_id'] = 0;
1478 1478
         } else {
1479
-            wpinv_set_error( 'logged_in_only', __( 'You must be logged in to pay for this invoice', 'invoicing' ) );
1479
+            wpinv_set_error('logged_in_only', __('You must be logged in to pay for this invoice', 'invoicing'));
1480 1480
         }
1481 1481
     }
1482 1482
 
1483 1483
     return $data;
1484 1484
 }
1485 1485
 
1486
-function wpinv_checkout_form_get_user( $valid_data = array() ) {
1486
+function wpinv_checkout_form_get_user($valid_data = array()) {
1487 1487
     // Initialize user
1488 1488
     $user    = false;
1489
-    $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
1489
+    $is_ajax = defined('DOING_AJAX') && DOING_AJAX;
1490 1490
 
1491
-    if ( empty( $valid_data['current_user'] ) ) {
1491
+    if (empty($valid_data['current_user'])) {
1492 1492
         $user = false;
1493 1493
     } else {
1494 1494
         // Set the valid invoice user
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
     }
1497 1497
 
1498 1498
     // Verify invoice have an user
1499
-    if ( false === $user || empty( $user ) ) {
1499
+    if (false === $user || empty($user)) {
1500 1500
         return false;
1501 1501
     }
1502 1502
 
@@ -1513,11 +1513,11 @@  discard block
 block discarded – undo
1513 1513
         'zip',
1514 1514
     );
1515 1515
     
1516
-    foreach ( $address_fields as $field ) {
1517
-        $user[$field]  = !empty( $_POST['wpinv_' . $field] ) ? sanitize_text_field( $_POST['wpinv_' . $field] ) : false;
1516
+    foreach ($address_fields as $field) {
1517
+        $user[$field] = !empty($_POST['wpinv_' . $field]) ? sanitize_text_field($_POST['wpinv_' . $field]) : false;
1518 1518
         
1519
-        if ( !empty( $user['user_id'] ) && !empty( $valid_data['current_user']['user_id'] ) && $valid_data['current_user']['user_id'] == $user['user_id'] ) {
1520
-            update_user_meta( $user['user_id'], '_wpinv_' . $field, $user[$field] );
1519
+        if (!empty($user['user_id']) && !empty($valid_data['current_user']['user_id']) && $valid_data['current_user']['user_id'] == $user['user_id']) {
1520
+            update_user_meta($user['user_id'], '_wpinv_' . $field, $user[$field]);
1521 1521
         }
1522 1522
     }
1523 1523
 
@@ -1525,28 +1525,28 @@  discard block
 block discarded – undo
1525 1525
     return $user;
1526 1526
 }
1527 1527
 
1528
-function wpinv_set_checkout_session( $invoice_data = array() ) {
1528
+function wpinv_set_checkout_session($invoice_data = array()) {
1529 1529
     global $wpi_session;
1530 1530
     
1531
-    return $wpi_session->set( 'wpinv_checkout', $invoice_data );
1531
+    return $wpi_session->set('wpinv_checkout', $invoice_data);
1532 1532
 }
1533 1533
 
1534 1534
 function wpinv_get_checkout_session() {
1535 1535
 	global $wpi_session;
1536 1536
     
1537
-    return $wpi_session->get( 'wpinv_checkout' );
1537
+    return $wpi_session->get('wpinv_checkout');
1538 1538
 }
1539 1539
 
1540 1540
 function wpinv_empty_cart() {
1541 1541
     global $wpi_session;
1542 1542
 
1543 1543
     // Remove cart contents
1544
-    $wpi_session->set( 'wpinv_checkout', NULL );
1544
+    $wpi_session->set('wpinv_checkout', NULL);
1545 1545
 
1546 1546
     // Remove all cart fees
1547
-    $wpi_session->set( 'wpi_cart_fees', NULL );
1547
+    $wpi_session->set('wpi_cart_fees', NULL);
1548 1548
 
1549
-    do_action( 'wpinv_empty_cart' );
1549
+    do_action('wpinv_empty_cart');
1550 1550
 }
1551 1551
 
1552 1552
 function wpinv_process_checkout() {
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
     wpinv_clear_errors();
1556 1556
     
1557 1557
     $invoice = wpinv_get_invoice_cart();
1558
-    if ( empty( $invoice ) ) {
1558
+    if (empty($invoice)) {
1559 1559
         return false;
1560 1560
     }
1561 1561
     
@@ -1563,42 +1563,42 @@  discard block
 block discarded – undo
1563 1563
     
1564 1564
     $wpi_checkout_id = $invoice->ID;
1565 1565
     
1566
-    do_action( 'wpinv_pre_process_checkout' );
1566
+    do_action('wpinv_pre_process_checkout');
1567 1567
     
1568
-    if ( !wpinv_get_cart_contents() ) { // Make sure the cart isn't empty
1568
+    if (!wpinv_get_cart_contents()) { // Make sure the cart isn't empty
1569 1569
         $valid_data = false;
1570
-        wpinv_set_error( 'empty_cart', __( 'Your cart is empty', 'invoicing' ) );
1570
+        wpinv_set_error('empty_cart', __('Your cart is empty', 'invoicing'));
1571 1571
     } else {
1572 1572
         // Validate the form $_POST data
1573 1573
         $valid_data = wpinv_validate_checkout_fields();
1574 1574
         
1575 1575
         // Allow themes and plugins to hook to errors
1576
-        do_action( 'wpinv_checkout_error_checks', $valid_data, $_POST );
1576
+        do_action('wpinv_checkout_error_checks', $valid_data, $_POST);
1577 1577
     }
1578 1578
     
1579
-    $is_ajax    = defined( 'DOING_AJAX' ) && DOING_AJAX;
1579
+    $is_ajax = defined('DOING_AJAX') && DOING_AJAX;
1580 1580
     
1581 1581
     // Validate the user
1582
-    $user = wpinv_checkout_form_get_user( $valid_data );
1582
+    $user = wpinv_checkout_form_get_user($valid_data);
1583 1583
 
1584 1584
     // Let extensions validate fields after user is logged in if user has used login/registration form
1585
-    do_action( 'wpinv_checkout_user_error_checks', $user, $valid_data, $_POST );
1585
+    do_action('wpinv_checkout_user_error_checks', $user, $valid_data, $_POST);
1586 1586
     
1587
-    if ( false === $valid_data || wpinv_get_errors() || ! $user ) {
1588
-        if ( $is_ajax ) {
1589
-            do_action( 'wpinv_ajax_checkout_errors' );
1587
+    if (false === $valid_data || wpinv_get_errors() || !$user) {
1588
+        if ($is_ajax) {
1589
+            do_action('wpinv_ajax_checkout_errors');
1590 1590
             die();
1591 1591
         } else {
1592 1592
             return false;
1593 1593
         }
1594 1594
     }
1595 1595
 
1596
-    if ( $is_ajax ) {
1596
+    if ($is_ajax) {
1597 1597
         // Save address fields.
1598
-        $address_fields = array( 'first_name', 'last_name', 'phone', 'address', 'city', 'country', 'state', 'zip', 'company' );
1599
-        foreach ( $address_fields as $field ) {
1600
-            if ( isset( $user[$field] ) ) {
1601
-                $invoice->set( $field, $user[$field] );
1598
+        $address_fields = array('first_name', 'last_name', 'phone', 'address', 'city', 'country', 'state', 'zip', 'company');
1599
+        foreach ($address_fields as $field) {
1600
+            if (isset($user[$field])) {
1601
+                $invoice->set($field, $user[$field]);
1602 1602
             }
1603 1603
             
1604 1604
             $invoice->save();
@@ -1606,15 +1606,15 @@  discard block
 block discarded – undo
1606 1606
 
1607 1607
         $response['success']            = true;
1608 1608
         $response['data']['subtotal']   = $invoice->get_subtotal();
1609
-        $response['data']['subtotalf']  = $invoice->get_subtotal( true );
1609
+        $response['data']['subtotalf']  = $invoice->get_subtotal(true);
1610 1610
         $response['data']['discount']   = $invoice->get_discount();
1611
-        $response['data']['discountf']  = $invoice->get_discount( true );
1611
+        $response['data']['discountf']  = $invoice->get_discount(true);
1612 1612
         $response['data']['tax']        = $invoice->get_tax();
1613
-        $response['data']['taxf']       = $invoice->get_tax( true );
1613
+        $response['data']['taxf']       = $invoice->get_tax(true);
1614 1614
         $response['data']['total']      = $invoice->get_total();
1615
-        $response['data']['totalf']     = $invoice->get_total( true );
1615
+        $response['data']['totalf']     = $invoice->get_total(true);
1616 1616
         
1617
-        wp_send_json( $response );
1617
+        wp_send_json($response);
1618 1618
     }
1619 1619
     
1620 1620
     $user_info = array(
@@ -1636,42 +1636,42 @@  discard block
 block discarded – undo
1636 1636
     
1637 1637
     // Setup invoice information
1638 1638
     $invoice_data = array(
1639
-        'invoice_id'        => !empty( $invoice ) ? $invoice->ID : 0,
1639
+        'invoice_id'        => !empty($invoice) ? $invoice->ID : 0,
1640 1640
         'items'             => $cart_items,
1641 1641
         'cart_discounts'    => $discounts,
1642
-        'fees'              => wpinv_get_cart_fees(),        // Any arbitrary fees that have been added to the cart
1643
-        'subtotal'          => wpinv_get_cart_subtotal( $cart_items ),    // Amount before taxes and discounts
1644
-        'discount'          => wpinv_get_cart_items_discount_amount( $cart_items, $discounts ), // Discounted amount
1645
-        'tax'               => wpinv_get_cart_tax( $cart_items ),               // Taxed amount
1646
-        'price'             => wpinv_get_cart_total( $cart_items, $discounts ),    // Amount after taxes
1642
+        'fees'              => wpinv_get_cart_fees(), // Any arbitrary fees that have been added to the cart
1643
+        'subtotal'          => wpinv_get_cart_subtotal($cart_items), // Amount before taxes and discounts
1644
+        'discount'          => wpinv_get_cart_items_discount_amount($cart_items, $discounts), // Discounted amount
1645
+        'tax'               => wpinv_get_cart_tax($cart_items), // Taxed amount
1646
+        'price'             => wpinv_get_cart_total($cart_items, $discounts), // Amount after taxes
1647 1647
         'invoice_key'       => $invoice->get_key() ? $invoice->get_key() : $invoice->generate_key(),
1648 1648
         'user_email'        => $user['email'],
1649
-        'date'              => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
1650
-        'user_info'         => stripslashes_deep( $user_info ),
1649
+        'date'              => date('Y-m-d H:i:s', current_time('timestamp')),
1650
+        'user_info'         => stripslashes_deep($user_info),
1651 1651
         'post_data'         => $_POST,
1652 1652
         'cart_details'      => $cart_items,
1653 1653
         'gateway'           => $valid_data['gateway'],
1654 1654
         'card_info'         => $valid_data['cc_info']
1655 1655
     );
1656 1656
     
1657
-    $vat_info   = $wpinv_euvat->current_vat_data();
1658
-    if ( is_array( $vat_info ) ) {
1657
+    $vat_info = $wpinv_euvat->current_vat_data();
1658
+    if (is_array($vat_info)) {
1659 1659
         $invoice_data['user_info']['vat_number']        = $vat_info['number'];
1660 1660
         $invoice_data['user_info']['vat_rate']          = wpinv_get_tax_rate($invoice_data['user_info']['country'], $invoice_data['user_info']['state']);
1661
-        $invoice_data['user_info']['adddress_confirmed']    = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false;
1661
+        $invoice_data['user_info']['adddress_confirmed'] = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false;
1662 1662
 
1663 1663
         // Add the VAT rate to each item in the cart
1664
-        foreach( $invoice_data['cart_details'] as $key => $item_data) {
1664
+        foreach ($invoice_data['cart_details'] as $key => $item_data) {
1665 1665
             $rate = wpinv_get_tax_rate($invoice_data['user_info']['country'], $invoice_data['user_info']['state'], $item_data['id']);
1666
-            $invoice_data['cart_details'][$key]['vat_rate'] = wpinv_round_amount( $rate, 4 );
1666
+            $invoice_data['cart_details'][$key]['vat_rate'] = wpinv_round_amount($rate, 4);
1667 1667
         }
1668 1668
     }
1669 1669
     
1670 1670
     // Save vat fields.
1671
-    $address_fields = array( 'vat_number', 'vat_rate', 'adddress_confirmed' );
1672
-    foreach ( $address_fields as $field ) {
1673
-        if ( isset( $invoice_data['user_info'][$field] ) ) {
1674
-            $invoice->set( $field, $invoice_data['user_info'][$field] );
1671
+    $address_fields = array('vat_number', 'vat_rate', 'adddress_confirmed');
1672
+    foreach ($address_fields as $field) {
1673
+        if (isset($invoice_data['user_info'][$field])) {
1674
+            $invoice->set($field, $invoice_data['user_info'][$field]);
1675 1675
         }
1676 1676
         
1677 1677
         $invoice->save();
@@ -1681,55 +1681,55 @@  discard block
 block discarded – undo
1681 1681
     $valid_data['user'] = $user;
1682 1682
     
1683 1683
     // Allow themes and plugins to hook before the gateway
1684
-    do_action( 'wpinv_checkout_before_gateway', $_POST, $user_info, $valid_data );
1684
+    do_action('wpinv_checkout_before_gateway', $_POST, $user_info, $valid_data);
1685 1685
     
1686 1686
     // If the total amount in the cart is 0, send to the manual gateway. This emulates a free invoice
1687
-    if ( !$invoice_data['price'] ) {
1687
+    if (!$invoice_data['price']) {
1688 1688
         // Revert to manual
1689 1689
         $invoice_data['gateway'] = 'manual';
1690 1690
         $_POST['wpi-gateway'] = 'manual';
1691 1691
     }
1692 1692
     
1693 1693
     // Allow the invoice data to be modified before it is sent to the gateway
1694
-    $invoice_data = apply_filters( 'wpinv_data_before_gateway', $invoice_data, $valid_data );
1694
+    $invoice_data = apply_filters('wpinv_data_before_gateway', $invoice_data, $valid_data);
1695 1695
     
1696
-    if ( $invoice_data['price'] && $invoice_data['gateway'] == 'manual' ) {
1696
+    if ($invoice_data['price'] && $invoice_data['gateway'] == 'manual') {
1697 1697
         $mode = 'test';
1698 1698
     } else {
1699
-        $mode = wpinv_is_test_mode( $invoice_data['gateway'] ) ? 'test' : 'live';
1699
+        $mode = wpinv_is_test_mode($invoice_data['gateway']) ? 'test' : 'live';
1700 1700
     }
1701 1701
     
1702 1702
     // Setup the data we're storing in the purchase session
1703 1703
     $session_data = $invoice_data;
1704 1704
     // Make sure credit card numbers are never stored in sessions
1705
-    if ( !empty( $session_data['card_info']['card_number'] ) ) {
1706
-        unset( $session_data['card_info']['card_number'] );
1705
+    if (!empty($session_data['card_info']['card_number'])) {
1706
+        unset($session_data['card_info']['card_number']);
1707 1707
     }
1708 1708
     
1709 1709
     // Used for showing item links to non logged-in users after purchase, and for other plugins needing purchase data.
1710
-    wpinv_set_checkout_session( $invoice_data );
1710
+    wpinv_set_checkout_session($invoice_data);
1711 1711
     
1712 1712
     // Set gateway
1713
-    $invoice->update_meta( '_wpinv_gateway', $invoice_data['gateway'] );
1714
-    $invoice->update_meta( '_wpinv_mode', $mode );
1715
-    $invoice->update_meta( '_wpinv_checkout', date_i18n( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) );
1713
+    $invoice->update_meta('_wpinv_gateway', $invoice_data['gateway']);
1714
+    $invoice->update_meta('_wpinv_mode', $mode);
1715
+    $invoice->update_meta('_wpinv_checkout', date_i18n('Y-m-d H:i:s', current_time('timestamp')));
1716 1716
     
1717
-    do_action( 'wpinv_checkout_before_send_to_gateway', $invoice, $invoice_data );
1717
+    do_action('wpinv_checkout_before_send_to_gateway', $invoice, $invoice_data);
1718 1718
 
1719 1719
     // Send info to the gateway for payment processing
1720
-    wpinv_send_to_gateway( $invoice_data['gateway'], $invoice_data );
1720
+    wpinv_send_to_gateway($invoice_data['gateway'], $invoice_data);
1721 1721
     die();
1722 1722
 }
1723
-add_action( 'wpinv_payment', 'wpinv_process_checkout' );
1723
+add_action('wpinv_payment', 'wpinv_process_checkout');
1724 1724
 
1725
-function wpinv_get_invoices( $args ) {
1726
-    $args = wp_parse_args( $args, array(
1727
-        'status'   => array_keys( wpinv_get_invoice_statuses() ),
1725
+function wpinv_get_invoices($args) {
1726
+    $args = wp_parse_args($args, array(
1727
+        'status'   => array_keys(wpinv_get_invoice_statuses()),
1728 1728
         'type'     => 'wpi_invoice',
1729 1729
         'parent'   => null,
1730 1730
         'user'     => null,
1731 1731
         'email'    => '',
1732
-        'limit'    => get_option( 'posts_per_page' ),
1732
+        'limit'    => get_option('posts_per_page'),
1733 1733
         'offset'   => null,
1734 1734
         'page'     => 1,
1735 1735
         'exclude'  => array(),
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
         'order'    => 'DESC',
1738 1738
         'return'   => 'objects',
1739 1739
         'paginate' => false,
1740
-    ) );
1740
+    ));
1741 1741
     
1742 1742
     // Handle some BW compatibility arg names where wp_query args differ in naming.
1743 1743
     $map_legacy = array(
@@ -1750,18 +1750,18 @@  discard block
 block discarded – undo
1750 1750
         'paged'          => 'page',
1751 1751
     );
1752 1752
 
1753
-    foreach ( $map_legacy as $from => $to ) {
1754
-        if ( isset( $args[ $from ] ) ) {
1755
-            $args[ $to ] = $args[ $from ];
1753
+    foreach ($map_legacy as $from => $to) {
1754
+        if (isset($args[$from])) {
1755
+            $args[$to] = $args[$from];
1756 1756
         }
1757 1757
     }
1758 1758
 
1759
-    if ( get_query_var( 'paged' ) )
1759
+    if (get_query_var('paged'))
1760 1760
         $args['page'] = get_query_var('paged');
1761
-    else if ( get_query_var( 'page' ) )
1762
-        $args['page'] = get_query_var( 'page' );
1763
-    else if ( !empty( $args[ 'page' ] ) )
1764
-        $args['page'] = $args[ 'page' ];
1761
+    else if (get_query_var('page'))
1762
+        $args['page'] = get_query_var('page');
1763
+    else if (!empty($args['page']))
1764
+        $args['page'] = $args['page'];
1765 1765
     else
1766 1766
         $args['page'] = 1;
1767 1767
 
@@ -1774,49 +1774,49 @@  discard block
 block discarded – undo
1774 1774
         'post_status'    => $args['status'],
1775 1775
         'posts_per_page' => $args['limit'],
1776 1776
         'meta_query'     => array(),
1777
-        'date_query'     => !empty( $args['date_query'] ) ? $args['date_query'] : array(),
1777
+        'date_query'     => !empty($args['date_query']) ? $args['date_query'] : array(),
1778 1778
         'fields'         => 'ids',
1779 1779
         'orderby'        => $args['orderby'],
1780 1780
         'order'          => $args['order'],
1781 1781
     );
1782 1782
     
1783
-    if ( !empty( $args['user'] ) ) {
1784
-        $wp_query_args['author'] = absint( $args['user'] );
1783
+    if (!empty($args['user'])) {
1784
+        $wp_query_args['author'] = absint($args['user']);
1785 1785
     }
1786 1786
 
1787
-    if ( ! is_null( $args['parent'] ) ) {
1788
-        $wp_query_args['post_parent'] = absint( $args['parent'] );
1787
+    if (!is_null($args['parent'])) {
1788
+        $wp_query_args['post_parent'] = absint($args['parent']);
1789 1789
     }
1790 1790
 
1791
-    if ( ! is_null( $args['offset'] ) ) {
1792
-        $wp_query_args['offset'] = absint( $args['offset'] );
1791
+    if (!is_null($args['offset'])) {
1792
+        $wp_query_args['offset'] = absint($args['offset']);
1793 1793
     } else {
1794
-        $wp_query_args['paged'] = absint( $args['page'] );
1794
+        $wp_query_args['paged'] = absint($args['page']);
1795 1795
     }
1796 1796
 
1797
-    if ( ! empty( $args['exclude'] ) ) {
1798
-        $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
1797
+    if (!empty($args['exclude'])) {
1798
+        $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']);
1799 1799
     }
1800 1800
 
1801
-    if ( ! $args['paginate' ] ) {
1801
+    if (!$args['paginate']) {
1802 1802
         $wp_query_args['no_found_rows'] = true;
1803 1803
     }
1804 1804
 
1805 1805
     $wp_query_args = apply_filters('wpinv_get_invoices_args', $wp_query_args, $args);
1806 1806
 
1807 1807
     // Get results.
1808
-    $invoices = new WP_Query( $wp_query_args );
1808
+    $invoices = new WP_Query($wp_query_args);
1809 1809
 
1810
-    if ( 'objects' === $args['return'] ) {
1811
-        $return = array_map( 'wpinv_get_invoice', $invoices->posts );
1812
-    } elseif ( 'self' === $args['return'] ) {
1810
+    if ('objects' === $args['return']) {
1811
+        $return = array_map('wpinv_get_invoice', $invoices->posts);
1812
+    } elseif ('self' === $args['return']) {
1813 1813
         return $invoices;
1814 1814
     } else {
1815 1815
         $return = $invoices->posts;
1816 1816
     }
1817 1817
 
1818
-    if ( $args['paginate' ] ) {
1819
-        return (object) array(
1818
+    if ($args['paginate']) {
1819
+        return (object)array(
1820 1820
             'invoices'      => $return,
1821 1821
             'total'         => $invoices->found_posts,
1822 1822
             'max_num_pages' => $invoices->max_num_pages,
@@ -1828,22 +1828,22 @@  discard block
 block discarded – undo
1828 1828
 
1829 1829
 function wpinv_get_user_invoices_columns() {
1830 1830
     $columns = array(
1831
-            'invoice-number'  => array( 'title' => __( 'ID', 'invoicing' ), 'class' => 'text-left' ),
1832
-            'created-date'    => array( 'title' => __( 'Created Date', 'invoicing' ), 'class' => 'text-left' ),
1833
-            'payment-date'    => array( 'title' => __( 'Payment Date', 'invoicing' ), 'class' => 'text-left' ),
1834
-            'invoice-status'  => array( 'title' => __( 'Status', 'invoicing' ), 'class' => 'text-center' ),
1835
-            'invoice-total'   => array( 'title' => __( 'Total', 'invoicing' ), 'class' => 'text-right' ),
1836
-            'invoice-actions' => array( 'title' => '&nbsp;', 'class' => 'text-center' ),
1831
+            'invoice-number'  => array('title' => __('ID', 'invoicing'), 'class' => 'text-left'),
1832
+            'created-date'    => array('title' => __('Created Date', 'invoicing'), 'class' => 'text-left'),
1833
+            'payment-date'    => array('title' => __('Payment Date', 'invoicing'), 'class' => 'text-left'),
1834
+            'invoice-status'  => array('title' => __('Status', 'invoicing'), 'class' => 'text-center'),
1835
+            'invoice-total'   => array('title' => __('Total', 'invoicing'), 'class' => 'text-right'),
1836
+            'invoice-actions' => array('title' => '&nbsp;', 'class' => 'text-center'),
1837 1837
         );
1838 1838
 
1839
-    return apply_filters( 'wpinv_user_invoices_columns', $columns );
1839
+    return apply_filters('wpinv_user_invoices_columns', $columns);
1840 1840
 }
1841 1841
 
1842
-function wpinv_payment_receipt( $atts, $content = null ) {
1842
+function wpinv_payment_receipt($atts, $content = null) {
1843 1843
     global $wpinv_receipt_args;
1844 1844
 
1845
-    $wpinv_receipt_args = shortcode_atts( array(
1846
-        'error'           => __( 'Sorry, trouble retrieving payment receipt.', 'invoicing' ),
1845
+    $wpinv_receipt_args = shortcode_atts(array(
1846
+        'error'           => __('Sorry, trouble retrieving payment receipt.', 'invoicing'),
1847 1847
         'price'           => true,
1848 1848
         'discount'        => true,
1849 1849
         'items'           => true,
@@ -1852,195 +1852,195 @@  discard block
 block discarded – undo
1852 1852
         'invoice_key'     => false,
1853 1853
         'payment_method'  => true,
1854 1854
         'invoice_id'      => true
1855
-    ), $atts, 'wpinv_receipt' );
1855
+    ), $atts, 'wpinv_receipt');
1856 1856
 
1857 1857
     $session = wpinv_get_checkout_session();
1858
-    if ( isset( $_GET['invoice_key'] ) ) {
1859
-        $invoice_key = urldecode( $_GET['invoice_key'] );
1860
-    } else if ( $session && isset( $session['invoice_key'] ) ) {
1858
+    if (isset($_GET['invoice_key'])) {
1859
+        $invoice_key = urldecode($_GET['invoice_key']);
1860
+    } else if ($session && isset($session['invoice_key'])) {
1861 1861
         $invoice_key = $session['invoice_key'];
1862
-    } elseif ( isset( $wpinv_receipt_args['invoice_key'] ) && $wpinv_receipt_args['invoice_key'] ) {
1862
+    } elseif (isset($wpinv_receipt_args['invoice_key']) && $wpinv_receipt_args['invoice_key']) {
1863 1863
         $invoice_key = $wpinv_receipt_args['invoice_key'];
1864
-    } else if ( isset( $_GET['invoice-id'] ) ) {
1865
-        $invoice_key = wpinv_get_payment_key( (int)$_GET['invoice-id'] );
1864
+    } else if (isset($_GET['invoice-id'])) {
1865
+        $invoice_key = wpinv_get_payment_key((int)$_GET['invoice-id']);
1866 1866
     }
1867 1867
 
1868 1868
     // No key found
1869
-    if ( ! isset( $invoice_key ) ) {
1869
+    if (!isset($invoice_key)) {
1870 1870
         return '<p class="alert alert-error">' . $wpinv_receipt_args['error'] . '</p>';
1871 1871
     }
1872 1872
 
1873
-    $invoice_id    = wpinv_get_invoice_id_by_key( $invoice_key );
1874
-    $user_can_view = wpinv_can_view_receipt( $invoice_key );
1875
-    if ( $user_can_view && isset( $_GET['invoice-id'] ) ) {
1873
+    $invoice_id    = wpinv_get_invoice_id_by_key($invoice_key);
1874
+    $user_can_view = wpinv_can_view_receipt($invoice_key);
1875
+    if ($user_can_view && isset($_GET['invoice-id'])) {
1876 1876
         $invoice_id     = (int)$_GET['invoice-id'];
1877
-        $user_can_view  = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? true : false;
1877
+        $user_can_view  = $invoice_key == wpinv_get_payment_key((int)$_GET['invoice-id']) ? true : false;
1878 1878
     }
1879 1879
 
1880 1880
     // Key was provided, but user is logged out. Offer them the ability to login and view the receipt
1881
-    if ( ! $user_can_view && ! empty( $invoice_key ) && ! is_user_logged_in() ) {
1881
+    if (!$user_can_view && !empty($invoice_key) && !is_user_logged_in()) {
1882 1882
         // login redirect
1883
-        return '<p class="alert alert-error">' . __( 'You are not allowed to access this section', 'invoicing' ) . '</p>';
1883
+        return '<p class="alert alert-error">' . __('You are not allowed to access this section', 'invoicing') . '</p>';
1884 1884
     }
1885 1885
 
1886
-    if ( ! apply_filters( 'wpinv_user_can_view_receipt', $user_can_view, $wpinv_receipt_args ) ) {
1886
+    if (!apply_filters('wpinv_user_can_view_receipt', $user_can_view, $wpinv_receipt_args)) {
1887 1887
         return '<p class="alert alert-error">' . $wpinv_receipt_args['error'] . '</p>';
1888 1888
     }
1889 1889
 
1890 1890
     ob_start();
1891 1891
 
1892
-    wpinv_get_template_part( 'wpinv-invoice-receipt' );
1892
+    wpinv_get_template_part('wpinv-invoice-receipt');
1893 1893
 
1894 1894
     $display = ob_get_clean();
1895 1895
 
1896 1896
     return $display;
1897 1897
 }
1898 1898
 
1899
-function wpinv_get_invoice_id_by_key( $key ) {
1899
+function wpinv_get_invoice_id_by_key($key) {
1900 1900
 	global $wpdb;
1901 1901
 
1902
-	$invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) );
1902
+	$invoice_id = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key));
1903 1903
 
1904
-	if ( $invoice_id != NULL )
1904
+	if ($invoice_id != NULL)
1905 1905
 		return $invoice_id;
1906 1906
 
1907 1907
 	return 0;
1908 1908
 }
1909 1909
 
1910
-function wpinv_can_view_receipt( $invoice_key = '' ) {
1910
+function wpinv_can_view_receipt($invoice_key = '') {
1911 1911
 	$return = false;
1912 1912
 
1913
-	if ( empty( $invoice_key ) ) {
1913
+	if (empty($invoice_key)) {
1914 1914
 		return $return;
1915 1915
 	}
1916 1916
 
1917 1917
 	global $wpinv_receipt_args;
1918 1918
 
1919
-	$wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key );
1920
-	if ( isset( $_GET['invoice-id'] ) ) {
1921
-		$wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0;
1919
+	$wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key($invoice_key);
1920
+	if (isset($_GET['invoice-id'])) {
1921
+		$wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key((int)$_GET['invoice-id']) ? (int)$_GET['invoice-id'] : 0;
1922 1922
 	}
1923 1923
 
1924
-	if ( empty( $wpinv_receipt_args['id'] ) ) {
1924
+	if (empty($wpinv_receipt_args['id'])) {
1925 1925
 		return $return;
1926 1926
 	}
1927 1927
 
1928
-	$invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] );
1929
-	if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) {
1928
+	$invoice = wpinv_get_invoice($wpinv_receipt_args['id']);
1929
+	if (!(!empty($invoice->ID) && $invoice->get_key() === $invoice_key)) {
1930 1930
 		return $return;
1931 1931
 	}
1932 1932
 
1933
-	if ( is_user_logged_in() ) {
1934
-		if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) {
1933
+	if (is_user_logged_in()) {
1934
+		if ((int)$invoice->get_user_id() === (int)get_current_user_id()) {
1935 1935
 			$return = true;
1936 1936
 		}
1937 1937
 	}
1938 1938
 
1939 1939
 	$session = wpinv_get_checkout_session();
1940
-	if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) {
1941
-		$check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key'];
1940
+	if (isset($_GET['invoice_key']) || ($session && isset($session['invoice_key']))) {
1941
+		$check_key = isset($_GET['invoice_key']) ? $_GET['invoice_key'] : $session['invoice_key'];
1942 1942
 
1943
-		if ( wpinv_require_login_to_checkout() ) {
1943
+		if (wpinv_require_login_to_checkout()) {
1944 1944
 			$return = $return && $check_key === $invoice_key;
1945 1945
 		} else {
1946 1946
 			$return = $check_key === $invoice_key;
1947 1947
 		}
1948 1948
 	}
1949 1949
 
1950
-	return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key );
1950
+	return (bool)apply_filters('wpinv_can_view_receipt', $return, $invoice_key);
1951 1951
 }
1952 1952
 
1953 1953
 function wpinv_pay_for_invoice() {
1954 1954
     global $wpinv_euvat;
1955 1955
     
1956
-    if ( isset( $_GET['invoice_key'] ) ) {
1956
+    if (isset($_GET['invoice_key'])) {
1957 1957
         $checkout_uri   = wpinv_get_checkout_uri();
1958
-        $invoice_key    = sanitize_text_field( $_GET['invoice_key'] );
1958
+        $invoice_key    = sanitize_text_field($_GET['invoice_key']);
1959 1959
         
1960
-        if ( empty( $invoice_key ) ) {
1961
-            wpinv_set_error( 'invalid_invoice', __( 'Invoice not found', 'invoicing' ) );
1962
-            wp_redirect( $checkout_uri );
1960
+        if (empty($invoice_key)) {
1961
+            wpinv_set_error('invalid_invoice', __('Invoice not found', 'invoicing'));
1962
+            wp_redirect($checkout_uri);
1963 1963
             wpinv_die();
1964 1964
         }
1965 1965
         
1966
-        do_action( 'wpinv_check_pay_for_invoice', $invoice_key );
1966
+        do_action('wpinv_check_pay_for_invoice', $invoice_key);
1967 1967
 
1968
-        $invoice_id    = wpinv_get_invoice_id_by_key( $invoice_key );
1969
-        $user_can_view = wpinv_can_view_receipt( $invoice_key );
1970
-        if ( $user_can_view && isset( $_GET['invoice-id'] ) ) {
1968
+        $invoice_id    = wpinv_get_invoice_id_by_key($invoice_key);
1969
+        $user_can_view = wpinv_can_view_receipt($invoice_key);
1970
+        if ($user_can_view && isset($_GET['invoice-id'])) {
1971 1971
             $invoice_id     = (int)$_GET['invoice-id'];
1972
-            $user_can_view  = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? true : false;
1972
+            $user_can_view  = $invoice_key == wpinv_get_payment_key((int)$_GET['invoice-id']) ? true : false;
1973 1973
         }
1974 1974
         
1975
-        if ( $invoice_id && $user_can_view && ( $invoice = wpinv_get_invoice( $invoice_id ) ) ) {
1976
-            if ( $invoice->needs_payment() ) {
1975
+        if ($invoice_id && $user_can_view && ($invoice = wpinv_get_invoice($invoice_id))) {
1976
+            if ($invoice->needs_payment()) {
1977 1977
                 $data                   = array();
1978 1978
                 $data['invoice_id']     = $invoice_id;
1979
-                $data['cart_discounts'] = $invoice->get_discounts( true );
1979
+                $data['cart_discounts'] = $invoice->get_discounts(true);
1980 1980
                 
1981
-                wpinv_set_checkout_session( $data );
1981
+                wpinv_set_checkout_session($data);
1982 1982
                 
1983
-                if ( wpinv_get_option( 'vat_ip_country_default' ) ) {
1983
+                if (wpinv_get_option('vat_ip_country_default')) {
1984 1984
                     $_POST['country']   = $wpinv_euvat->get_country_by_ip();
1985 1985
                     $_POST['state']     = $_POST['country'] == $invoice->country ? $invoice->state : '';
1986 1986
                     
1987
-                    wpinv_recalculate_tax( true );
1987
+                    wpinv_recalculate_tax(true);
1988 1988
                 }
1989 1989
                 
1990 1990
             } else {
1991 1991
                 $checkout_uri = $invoice->get_view_url();
1992 1992
             }
1993 1993
         } else {
1994
-            wpinv_set_error( 'invalid_invoice', __( 'You are not allowed to view this invoice', 'invoicing' ) );
1994
+            wpinv_set_error('invalid_invoice', __('You are not allowed to view this invoice', 'invoicing'));
1995 1995
             
1996
-            $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url( get_permalink() );
1996
+            $checkout_uri = is_user_logged_in() ? wpinv_get_history_page_uri() : wp_login_url(get_permalink());
1997 1997
         }
1998 1998
         
1999
-        wp_redirect( $checkout_uri );
1999
+        wp_redirect($checkout_uri);
2000 2000
         wpinv_die();
2001 2001
     }
2002 2002
 }
2003
-add_action( 'wpinv_pay_for_invoice', 'wpinv_pay_for_invoice' );
2003
+add_action('wpinv_pay_for_invoice', 'wpinv_pay_for_invoice');
2004 2004
 
2005
-function wpinv_handle_pay_via_invoice_link( $invoice_key ) {
2006
-    if ( !empty( $invoice_key ) && !empty( $_REQUEST['_wpipay'] ) && !is_user_logged_in() && $invoice_id = wpinv_get_invoice_id_by_key( $invoice_key ) ) {
2007
-        if ( $invoice = wpinv_get_invoice( $invoice_id ) ) {
2005
+function wpinv_handle_pay_via_invoice_link($invoice_key) {
2006
+    if (!empty($invoice_key) && !empty($_REQUEST['_wpipay']) && !is_user_logged_in() && $invoice_id = wpinv_get_invoice_id_by_key($invoice_key)) {
2007
+        if ($invoice = wpinv_get_invoice($invoice_id)) {
2008 2008
             $user_id = $invoice->get_user_id();
2009
-            $secret = sanitize_text_field( $_GET['_wpipay'] );
2009
+            $secret = sanitize_text_field($_GET['_wpipay']);
2010 2010
             
2011
-            if ( $secret === md5( $user_id . '::' . $invoice->get_email() . '::' . $invoice_key ) ) { // valid invoice link
2012
-                $redirect_to = remove_query_arg( '_wpipay', get_permalink() );
2011
+            if ($secret === md5($user_id . '::' . $invoice->get_email() . '::' . $invoice_key)) { // valid invoice link
2012
+                $redirect_to = remove_query_arg('_wpipay', get_permalink());
2013 2013
                 
2014
-                wpinv_guest_redirect( $redirect_to, $user_id );
2014
+                wpinv_guest_redirect($redirect_to, $user_id);
2015 2015
                 wpinv_die();
2016 2016
             }
2017 2017
         }
2018 2018
     }
2019 2019
 }
2020
-add_action( 'wpinv_check_pay_for_invoice', 'wpinv_handle_pay_via_invoice_link' );
2020
+add_action('wpinv_check_pay_for_invoice', 'wpinv_handle_pay_via_invoice_link');
2021 2021
 
2022
-function wpinv_set_payment_transaction_id( $invoice_id = 0, $transaction_id = '' ) {
2023
-    $invoice_id = is_object( $invoice_id ) && !empty( $invoice_id->ID ) ? $invoice_id : $invoice_id;
2022
+function wpinv_set_payment_transaction_id($invoice_id = 0, $transaction_id = '') {
2023
+    $invoice_id = is_object($invoice_id) && !empty($invoice_id->ID) ? $invoice_id : $invoice_id;
2024 2024
     
2025
-    if ( empty( $invoice_id ) && $invoice_id > 0 ) {
2025
+    if (empty($invoice_id) && $invoice_id > 0) {
2026 2026
         return false;
2027 2027
     }
2028 2028
     
2029
-    if ( empty( $transaction_id ) ) {
2029
+    if (empty($transaction_id)) {
2030 2030
         $transaction_id = $invoice_id;
2031 2031
     }
2032 2032
 
2033
-    $transaction_id = apply_filters( 'wpinv_set_payment_transaction_id', $transaction_id, $invoice_id );
2033
+    $transaction_id = apply_filters('wpinv_set_payment_transaction_id', $transaction_id, $invoice_id);
2034 2034
     
2035
-    return wpinv_update_invoice_meta( $invoice_id, '_wpinv_transaction_id', $transaction_id );
2035
+    return wpinv_update_invoice_meta($invoice_id, '_wpinv_transaction_id', $transaction_id);
2036 2036
 }
2037 2037
 
2038
-function wpinv_invoice_status_label( $status, $status_display = '' ) {
2039
-    if ( empty( $status_display ) ) {
2040
-        $status_display = wpinv_status_nicename( $status );
2038
+function wpinv_invoice_status_label($status, $status_display = '') {
2039
+    if (empty($status_display)) {
2040
+        $status_display = wpinv_status_nicename($status);
2041 2041
     }
2042 2042
     
2043
-    switch ( $status ) {
2043
+    switch ($status) {
2044 2044
         case 'publish' :
2045 2045
         case 'wpi-renewal' :
2046 2046
             $class = 'label-success';
@@ -2065,257 +2065,257 @@  discard block
 block discarded – undo
2065 2065
     
2066 2066
     $label = '<span class="label label-inv-' . $status . ' ' . $class . '">' . $status_display . '</span>';
2067 2067
     
2068
-    return apply_filters( 'wpinv_invoice_status_label', $label, $status, $status_display );
2068
+    return apply_filters('wpinv_invoice_status_label', $label, $status, $status_display);
2069 2069
 }
2070 2070
 
2071
-function wpinv_format_invoice_number( $number, $type = '' ) {
2072
-    $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type );
2073
-    if ( null !== $check ) {
2071
+function wpinv_format_invoice_number($number, $type = '') {
2072
+    $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type);
2073
+    if (null !== $check) {
2074 2074
         return $check;
2075 2075
     }
2076 2076
 
2077
-    if ( !empty( $number ) && !is_numeric( $number ) ) {
2077
+    if (!empty($number) && !is_numeric($number)) {
2078 2078
         return $number;
2079 2079
     }
2080 2080
 
2081
-    $padd  = wpinv_get_option( 'invoice_number_padd' );
2082
-    $prefix  = wpinv_get_option( 'invoice_number_prefix' );
2083
-    $postfix = wpinv_get_option( 'invoice_number_postfix' );
2081
+    $padd = wpinv_get_option('invoice_number_padd');
2082
+    $prefix  = wpinv_get_option('invoice_number_prefix');
2083
+    $postfix = wpinv_get_option('invoice_number_postfix');
2084 2084
     
2085
-    $padd = absint( $padd );
2086
-    $formatted_number = absint( $number );
2085
+    $padd = absint($padd);
2086
+    $formatted_number = absint($number);
2087 2087
     
2088
-    if ( $padd > 0 ) {
2089
-        $formatted_number = zeroise( $formatted_number, $padd );
2088
+    if ($padd > 0) {
2089
+        $formatted_number = zeroise($formatted_number, $padd);
2090 2090
     }    
2091 2091
 
2092 2092
     $formatted_number = $prefix . $formatted_number . $postfix;
2093 2093
 
2094
-    return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd );
2094
+    return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd);
2095 2095
 }
2096 2096
 
2097
-function wpinv_get_next_invoice_number( $type = '' ) {
2098
-    $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type );
2099
-    if ( null !== $check ) {
2097
+function wpinv_get_next_invoice_number($type = '') {
2098
+    $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type);
2099
+    if (null !== $check) {
2100 2100
         return $check;
2101 2101
     }
2102 2102
     
2103
-    if ( !wpinv_sequential_number_active() ) {
2103
+    if (!wpinv_sequential_number_active()) {
2104 2104
         return false;
2105 2105
     }
2106 2106
 
2107
-    $number = $last_number = get_option( 'wpinv_last_invoice_number', 0 );
2108
-    $start  = wpinv_get_option( 'invoice_sequence_start', 1 );
2109
-    if ( !absint( $start ) > 0 ) {
2107
+    $number = $last_number = get_option('wpinv_last_invoice_number', 0);
2108
+    $start  = wpinv_get_option('invoice_sequence_start', 1);
2109
+    if (!absint($start) > 0) {
2110 2110
         $start = 1;
2111 2111
     }
2112 2112
     $increment_number = true;
2113 2113
     $save_number = false;
2114 2114
 
2115
-    if ( !empty( $number ) && !is_numeric( $number ) && $number == wpinv_format_invoice_number( $number ) ) {
2116
-        $number = wpinv_clean_invoice_number( $number );
2115
+    if (!empty($number) && !is_numeric($number) && $number == wpinv_format_invoice_number($number)) {
2116
+        $number = wpinv_clean_invoice_number($number);
2117 2117
     }
2118 2118
 
2119
-    if ( empty( $number ) ) {
2120
-        if ( !( $last_number === 0 || $last_number === '0' ) ) {
2121
-            $last_invoice = wpinv_get_invoices( array( 'limit' => 1, 'order' => 'DESC', 'orderby' => 'ID', 'return' => 'posts', 'fields' => 'ids', 'status' => array_keys( wpinv_get_invoice_statuses( true, true ) ) ) );
2119
+    if (empty($number)) {
2120
+        if (!($last_number === 0 || $last_number === '0')) {
2121
+            $last_invoice = wpinv_get_invoices(array('limit' => 1, 'order' => 'DESC', 'orderby' => 'ID', 'return' => 'posts', 'fields' => 'ids', 'status' => array_keys(wpinv_get_invoice_statuses(true, true))));
2122 2122
 
2123
-            if ( !empty( $last_invoice[0] ) && $invoice_number = wpinv_get_invoice_number( $last_invoice[0] ) ) {
2124
-                if ( is_numeric( $invoice_number ) ) {
2123
+            if (!empty($last_invoice[0]) && $invoice_number = wpinv_get_invoice_number($last_invoice[0])) {
2124
+                if (is_numeric($invoice_number)) {
2125 2125
                     $number = $invoice_number;
2126 2126
                 } else {
2127
-                    $number = wpinv_clean_invoice_number( $invoice_number );
2127
+                    $number = wpinv_clean_invoice_number($invoice_number);
2128 2128
                 }
2129 2129
             }
2130 2130
 
2131
-            if ( empty( $number ) ) {
2131
+            if (empty($number)) {
2132 2132
                 $increment_number = false;
2133 2133
                 $number = $start;
2134
-                $save_number = ( $number - 1 );
2134
+                $save_number = ($number - 1);
2135 2135
             } else {
2136 2136
                 $save_number = $number;
2137 2137
             }
2138 2138
         }
2139 2139
     }
2140 2140
 
2141
-    if ( $start > $number ) {
2141
+    if ($start > $number) {
2142 2142
         $increment_number = false;
2143 2143
         $number = $start;
2144
-        $save_number = ( $number - 1 );
2144
+        $save_number = ($number - 1);
2145 2145
     }
2146 2146
 
2147
-    if ( $save_number !== false ) {
2148
-        update_option( 'wpinv_last_invoice_number', $save_number );
2147
+    if ($save_number !== false) {
2148
+        update_option('wpinv_last_invoice_number', $save_number);
2149 2149
     }
2150 2150
     
2151
-    $increment_number = apply_filters( 'wpinv_increment_payment_number', $increment_number, $number );
2151
+    $increment_number = apply_filters('wpinv_increment_payment_number', $increment_number, $number);
2152 2152
 
2153
-    if ( $increment_number ) {
2153
+    if ($increment_number) {
2154 2154
         $number++;
2155 2155
     }
2156 2156
 
2157
-    return apply_filters( 'wpinv_get_next_invoice_number', $number );
2157
+    return apply_filters('wpinv_get_next_invoice_number', $number);
2158 2158
 }
2159 2159
 
2160
-function wpinv_clean_invoice_number( $number, $type = '' ) {
2161
-    $check = apply_filters( 'wpinv_pre_clean_invoice_number', null, $number, $type );
2162
-    if ( null !== $check ) {
2160
+function wpinv_clean_invoice_number($number, $type = '') {
2161
+    $check = apply_filters('wpinv_pre_clean_invoice_number', null, $number, $type);
2162
+    if (null !== $check) {
2163 2163
         return $check;
2164 2164
     }
2165 2165
     
2166
-    $prefix  = wpinv_get_option( 'invoice_number_prefix' );
2167
-    $postfix = wpinv_get_option( 'invoice_number_postfix' );
2166
+    $prefix  = wpinv_get_option('invoice_number_prefix');
2167
+    $postfix = wpinv_get_option('invoice_number_postfix');
2168 2168
 
2169
-    $number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
2169
+    $number = preg_replace('/' . $prefix . '/', '', $number, 1);
2170 2170
 
2171
-    $length      = strlen( $number );
2172
-    $postfix_pos = strrpos( $number, $postfix );
2171
+    $length      = strlen($number);
2172
+    $postfix_pos = strrpos($number, $postfix);
2173 2173
     
2174
-    if ( false !== $postfix_pos ) {
2175
-        $number      = substr_replace( $number, '', $postfix_pos, $length );
2174
+    if (false !== $postfix_pos) {
2175
+        $number = substr_replace($number, '', $postfix_pos, $length);
2176 2176
     }
2177 2177
 
2178
-    $number = intval( $number );
2178
+    $number = intval($number);
2179 2179
 
2180
-    return apply_filters( 'wpinv_clean_invoice_number', $number, $prefix, $postfix );
2180
+    return apply_filters('wpinv_clean_invoice_number', $number, $prefix, $postfix);
2181 2181
 }
2182 2182
 
2183
-function wpinv_save_number_post_saved( $post_ID, $post, $update ) {
2183
+function wpinv_save_number_post_saved($post_ID, $post, $update) {
2184 2184
     global $wpdb;
2185 2185
 
2186
-    if ( !$update && !get_post_meta( $post_ID, '_wpinv_number', true ) ) {
2187
-        wpinv_update_invoice_number( $post_ID, $post->post_status != 'auto-draft', $post->post_type );
2186
+    if (!$update && !get_post_meta($post_ID, '_wpinv_number', true)) {
2187
+        wpinv_update_invoice_number($post_ID, $post->post_status != 'auto-draft', $post->post_type);
2188 2188
     }
2189 2189
 
2190
-    if ( !$update ) {
2191
-        $wpdb->update( $wpdb->posts, array( 'post_name' => wpinv_generate_post_name( $post_ID ) ), array( 'ID' => $post_ID ) );
2192
-        clean_post_cache( $post_ID );
2190
+    if (!$update) {
2191
+        $wpdb->update($wpdb->posts, array('post_name' => wpinv_generate_post_name($post_ID)), array('ID' => $post_ID));
2192
+        clean_post_cache($post_ID);
2193 2193
     }
2194 2194
 }
2195
-add_action( 'save_post_wpi_invoice', 'wpinv_save_number_post_saved', 1, 3 );
2195
+add_action('save_post_wpi_invoice', 'wpinv_save_number_post_saved', 1, 3);
2196 2196
 
2197
-function wpinv_save_number_post_updated( $post_ID, $post_after, $post_before ) {
2198
-    if ( !empty( $post_after->post_type ) && $post_after->post_type == 'wpi_invoice' && $post_before->post_status == 'auto-draft' && $post_after->post_status != $post_before->post_status ) {
2199
-        wpinv_update_invoice_number( $post_ID, true, $post_after->post_type );
2197
+function wpinv_save_number_post_updated($post_ID, $post_after, $post_before) {
2198
+    if (!empty($post_after->post_type) && $post_after->post_type == 'wpi_invoice' && $post_before->post_status == 'auto-draft' && $post_after->post_status != $post_before->post_status) {
2199
+        wpinv_update_invoice_number($post_ID, true, $post_after->post_type);
2200 2200
     }
2201 2201
 }
2202
-add_action( 'post_updated', 'wpinv_save_number_post_updated', 1, 3 );
2202
+add_action('post_updated', 'wpinv_save_number_post_updated', 1, 3);
2203 2203
 
2204
-function wpinv_update_invoice_number( $post_ID, $save_sequential = false, $type = '' ) {
2204
+function wpinv_update_invoice_number($post_ID, $save_sequential = false, $type = '') {
2205 2205
     global $wpdb;
2206 2206
     
2207
-    $check = apply_filters( 'wpinv_pre_update_invoice_number', null, $post_ID, $save_sequential, $type );
2208
-    if ( null !== $check ) {
2207
+    $check = apply_filters('wpinv_pre_update_invoice_number', null, $post_ID, $save_sequential, $type);
2208
+    if (null !== $check) {
2209 2209
         return $check;
2210 2210
     }
2211 2211
 
2212
-    if ( wpinv_sequential_number_active() ) {
2212
+    if (wpinv_sequential_number_active()) {
2213 2213
         $number = wpinv_get_next_invoice_number();
2214 2214
 
2215
-        if ( $save_sequential ) {
2216
-            update_option( 'wpinv_last_invoice_number', $number );
2215
+        if ($save_sequential) {
2216
+            update_option('wpinv_last_invoice_number', $number);
2217 2217
         }
2218 2218
     } else {
2219 2219
         $number = $post_ID;
2220 2220
     }
2221 2221
 
2222
-    $number = wpinv_format_invoice_number( $number );
2222
+    $number = wpinv_format_invoice_number($number);
2223 2223
 
2224
-    update_post_meta( $post_ID, '_wpinv_number', $number );
2224
+    update_post_meta($post_ID, '_wpinv_number', $number);
2225 2225
 
2226
-    $wpdb->update( $wpdb->posts, array( 'post_title' => $number ), array( 'ID' => $post_ID ) );
2226
+    $wpdb->update($wpdb->posts, array('post_title' => $number), array('ID' => $post_ID));
2227 2227
 
2228
-    clean_post_cache( $post_ID );
2228
+    clean_post_cache($post_ID);
2229 2229
 
2230 2230
     return $number;
2231 2231
 }
2232 2232
 
2233
-function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) {
2234
-    return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type );
2233
+function wpinv_post_name_prefix($post_type = 'wpi_invoice') {
2234
+    return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type);
2235 2235
 }
2236 2236
 
2237
-function wpinv_generate_post_name( $post_ID ) {
2238
-    $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) );
2239
-    $post_name = sanitize_title( $prefix . $post_ID );
2237
+function wpinv_generate_post_name($post_ID) {
2238
+    $prefix = wpinv_post_name_prefix(get_post_type($post_ID));
2239
+    $post_name = sanitize_title($prefix . $post_ID);
2240 2240
 
2241
-    return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix );
2241
+    return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix);
2242 2242
 }
2243 2243
 
2244
-function wpinv_is_invoice_viewed( $invoice_id ) {
2245
-    if ( empty( $invoice_id ) ) {
2244
+function wpinv_is_invoice_viewed($invoice_id) {
2245
+    if (empty($invoice_id)) {
2246 2246
         return false;
2247 2247
     }
2248 2248
 
2249
-    $viewed_meta = get_post_meta( $invoice_id, '_wpinv_is_viewed', true );
2249
+    $viewed_meta = get_post_meta($invoice_id, '_wpinv_is_viewed', true);
2250 2250
 
2251
-    if ( isset($viewed_meta) && 1 == $viewed_meta ) {
2251
+    if (isset($viewed_meta) && 1 == $viewed_meta) {
2252 2252
         $is_viewed = true;
2253 2253
     } else {
2254 2254
         $is_viewed = false;
2255 2255
     }
2256 2256
 
2257
-    return apply_filters( 'wpinv_is_invoice_viewed', $is_viewed, $invoice_id );
2257
+    return apply_filters('wpinv_is_invoice_viewed', $is_viewed, $invoice_id);
2258 2258
 }
2259 2259
 
2260 2260
 function wpinv_mark_invoice_viewed() {
2261 2261
 
2262
-    if ( isset( $_GET['invoice_key'] ) ) {
2262
+    if (isset($_GET['invoice_key'])) {
2263 2263
         $invoice_key = urldecode($_GET['invoice_key']);
2264 2264
 
2265 2265
         $invoice_id = wpinv_get_invoice_id_by_key($invoice_key);
2266 2266
         $invoice = new WPInv_Invoice($invoice_id);
2267 2267
 
2268
-        if(!$invoice_id){
2268
+        if (!$invoice_id) {
2269 2269
             return;
2270 2270
         }
2271 2271
 
2272
-        if( is_user_logged_in()){
2272
+        if (is_user_logged_in()) {
2273 2273
             $current_user = wp_get_current_user();
2274
-            if(!current_user_can('administrator') && $current_user->user_email == $invoice->get_email()){
2275
-                update_post_meta($invoice_id,'_wpinv_is_viewed', 1);
2274
+            if (!current_user_can('administrator') && $current_user->user_email == $invoice->get_email()) {
2275
+                update_post_meta($invoice_id, '_wpinv_is_viewed', 1);
2276 2276
             }
2277 2277
         } else {
2278
-            update_post_meta($invoice_id,'_wpinv_is_viewed', 1);
2278
+            update_post_meta($invoice_id, '_wpinv_is_viewed', 1);
2279 2279
         }
2280 2280
     }
2281 2281
 
2282 2282
 }
2283
-add_action( 'init', 'wpinv_mark_invoice_viewed' );
2283
+add_action('init', 'wpinv_mark_invoice_viewed');
2284 2284
 
2285
-function wpinv_get_subscription( $invoice, $by_parent = false ) {
2286
-    if ( empty( $invoice ) ) {
2285
+function wpinv_get_subscription($invoice, $by_parent = false) {
2286
+    if (empty($invoice)) {
2287 2287
         return false;
2288 2288
     }
2289 2289
     
2290
-    if ( ! is_object( $invoice ) && is_scalar( $invoice ) ) {
2291
-        $invoice = wpinv_get_invoice( $invoice );
2290
+    if (!is_object($invoice) && is_scalar($invoice)) {
2291
+        $invoice = wpinv_get_invoice($invoice);
2292 2292
     }
2293 2293
     
2294
-    if ( !( is_object( $invoice ) && ! empty( $invoice->ID ) && $invoice->is_recurring() ) ) {
2294
+    if (!(is_object($invoice) && !empty($invoice->ID) && $invoice->is_recurring())) {
2295 2295
         return false;
2296 2296
     }
2297 2297
     
2298
-    $invoice_id = ! $by_parent && ! empty( $invoice->parent_invoice ) ? $invoice->parent_invoice : $invoice->ID;
2298
+    $invoice_id = !$by_parent && !empty($invoice->parent_invoice) ? $invoice->parent_invoice : $invoice->ID;
2299 2299
     
2300 2300
     $subs_db    = new WPInv_Subscriptions_DB;
2301
-    $subs       = $subs_db->get_subscriptions( array( 'parent_payment_id' => $invoice_id, 'number' => 1 ) );
2301
+    $subs       = $subs_db->get_subscriptions(array('parent_payment_id' => $invoice_id, 'number' => 1));
2302 2302
     
2303
-    if ( ! empty( $subs ) ) {
2304
-        return reset( $subs );
2303
+    if (!empty($subs)) {
2304
+        return reset($subs);
2305 2305
     }
2306 2306
     
2307 2307
     return false;
2308 2308
 }
2309 2309
 
2310
-function wpinv_filter_posts_clauses( $clauses, $wp_query ) {
2310
+function wpinv_filter_posts_clauses($clauses, $wp_query) {
2311 2311
     global $wpdb;
2312 2312
 
2313
-    if ( ! empty( $wp_query->query_vars['orderby'] ) && $wp_query->query_vars['orderby'] == 'invoice_date' ) {
2314
-        if ( !empty( $clauses['join'] ) ) {
2313
+    if (!empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'invoice_date') {
2314
+        if (!empty($clauses['join'])) {
2315 2315
             $clauses['join'] .= " ";
2316 2316
         }
2317 2317
 
2318
-        if ( !empty( $clauses['fields'] ) ) {
2318
+        if (!empty($clauses['fields'])) {
2319 2319
             $clauses['fields'] .= ", ";
2320 2320
         }
2321 2321
 
@@ -2326,4 +2326,4 @@  discard block
 block discarded – undo
2326 2326
 
2327 2327
     return $clauses;
2328 2328
 }
2329
-add_filter( 'posts_clauses', 'wpinv_filter_posts_clauses', 10, 2 );
2330 2329
\ No newline at end of file
2330
+add_filter('posts_clauses', 'wpinv_filter_posts_clauses', 10, 2);
2331 2331
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/class-wpinv-users.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
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 14
 class WPInv_Admin_Users {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Admin_Users ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Admin_Users)) {
19 19
             self::$instance = new WPInv_Admin_Users;
20 20
         }
21 21
 
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
     }
24 24
     
25 25
     public function __construct() {
26
-        add_filter( 'manage_users_columns', array( $this, 'wpinv_add_user_column') );
27
-        add_filter( 'manage_users_custom_column', array( $this, 'wpinv_user_column_content') , 10, 3 );
26
+        add_filter('manage_users_columns', array($this, 'wpinv_add_user_column'));
27
+        add_filter('manage_users_custom_column', array($this, 'wpinv_user_column_content'), 10, 3);
28 28
     }
29 29
 
30 30
     /**
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @return mixed
36 36
      */
37
-    public function wpinv_add_user_column( $column ) {
38
-        $column['wpinvoicing'] = __('Invoicing','invoicing');
37
+    public function wpinv_add_user_column($column) {
38
+        $column['wpinvoicing'] = __('Invoicing', 'invoicing');
39 39
         return $column;
40 40
     }
41 41
 
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return string
50 50
      */
51
-    function wpinv_user_column_content( $val, $column_name, $user_id ) {
51
+    function wpinv_user_column_content($val, $column_name, $user_id) {
52 52
         switch ($column_name) {
53 53
             case 'wpinvoicing' :
54
-                return $this->get_user_invoices( $user_id );
54
+                return $this->get_user_invoices($user_id);
55 55
                 break;
56 56
             default:
57 57
         }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return string
67 67
      */
68
-    public function get_user_invoices($user_id){
68
+    public function get_user_invoices($user_id) {
69 69
         $output = '';
70 70
         $wp_query_args = array(
71 71
             'post_type'      => 'wpi_invoice',
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 
78 78
         $wp_query_args = apply_filters('wpinv_get_user_invoices_args', $wp_query_args, $user_id);
79 79
 
80
-        $invoices = new WP_Query( $wp_query_args );
81
-        $count = absint( $invoices->found_posts );
80
+        $invoices = new WP_Query($wp_query_args);
81
+        $count = absint($invoices->found_posts);
82 82
 
83
-        if(empty($count)){
84
-            $output .= __('No Invoice(s)','invoicing');
85
-        }else{
86
-            $link_url = admin_url( "edit.php?post_type=wpi_invoice&author=".absint($user_id) );
87
-            $link_text = sprintf( __('Invoices ( %d )', 'invoicing'), $count );
83
+        if (empty($count)) {
84
+            $output .= __('No Invoice(s)', 'invoicing');
85
+        } else {
86
+            $link_url = admin_url("edit.php?post_type=wpi_invoice&author=" . absint($user_id));
87
+            $link_text = sprintf(__('Invoices ( %d )', 'invoicing'), $count);
88 88
             $output .= "<a href='$link_url' >$link_text</a>";
89 89
         }
90 90
 
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +83 added lines, -83 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,94 +13,94 @@  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, 'remove_admin_submenus' ), 10 );
18
-        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, 'remove_admin_submenus'), 10);
18
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
19 19
     }
20 20
 
21 21
     public function admin_menu() {
22 22
         global $menu;
23 23
 
24
-        if ( !(current_user_can( 'manage_invoicing' ) || current_user_can( 'manage_options' )) ) {
24
+        if (!(current_user_can('manage_invoicing') || current_user_can('manage_options'))) {
25 25
             return;
26 26
         }
27 27
 
28
-        $capability = apply_filters( 'invoicing_capability', 'manage_invoicing' );
28
+        $capability = apply_filters('invoicing_capability', 'manage_invoicing');
29 29
 
30
-        if ( current_user_can( 'manage_options' ) ) {
31
-            $menu[] = array( '', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv' );
30
+        if (current_user_can('manage_options')) {
31
+            $menu[] = array('', 'read', 'separator-wpinv', '', 'wp-menu-separator wpinv');
32 32
         }
33 33
 
34
-        $wpi_invoice = get_post_type_object( 'wpi_invoice' );
34
+        $wpi_invoice = get_post_type_object('wpi_invoice');
35 35
 
36
-        add_menu_page( __( 'Invoicing', 'invoicing' ), __( 'Invoicing', 'invoicing' ), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460' );
36
+        add_menu_page(__('Invoicing', 'invoicing'), __('Invoicing', 'invoicing'), $capability, 'wpinv', null, $wpi_invoice->menu_icon, '54.123460');
37 37
 
38
-        add_submenu_page( 'wpinv', __( 'Invoice Settings', 'invoicing' ), __( 'Settings', 'invoicing' ), $capability, 'wpinv-settings', array( $this, 'options_page' ));
38
+        add_submenu_page('wpinv', __('Invoice Settings', 'invoicing'), __('Settings', 'invoicing'), $capability, 'wpinv-settings', array($this, 'options_page'));
39 39
     }
40 40
 
41 41
     function options_page() {
42
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
42
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
43 43
 
44
-        if ( $page !== 'wpinv-settings' ) {
44
+        if ($page !== 'wpinv-settings') {
45 45
             return;
46 46
         }
47 47
 
48 48
         $settings_tabs = wpinv_get_settings_tabs();
49 49
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
50
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
51
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
50
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
51
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
52 52
         $key           = 'main';
53 53
 
54
-        if ( is_array( $sections ) ) {
55
-            $key = key( $sections );
54
+        if (is_array($sections)) {
55
+            $key = key($sections);
56 56
         }
57 57
 
58
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
59
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
58
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
59
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
60 60
         ob_start();
61 61
         ?>
62 62
         <div class="wrap">
63 63
             <h1 class="nav-tab-wrapper">
64 64
                 <?php
65
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
66
-                    $tab_url = add_query_arg( array(
65
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
66
+                    $tab_url = add_query_arg(array(
67 67
                         'settings-updated' => false,
68 68
                         'tab' => $tab_id,
69
-                    ) );
69
+                    ));
70 70
 
71 71
                     // Remove the section from the tabs so we always end up at the main section
72
-                    $tab_url = remove_query_arg( 'section', $tab_url );
73
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
72
+                    $tab_url = remove_query_arg('section', $tab_url);
73
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
74 74
 
75 75
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
76 76
 
77
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
78
-                    echo esc_html( $tab_name );
77
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
78
+                    echo esc_html($tab_name);
79 79
                     echo '</a>';
80 80
                 }
81 81
                 ?>
82 82
             </h1>
83 83
             <?php
84
-            $number_of_sections = count( $sections );
84
+            $number_of_sections = count($sections);
85 85
             $number = 0;
86
-            if ( $number_of_sections > 1 ) {
86
+            if ($number_of_sections > 1) {
87 87
                 echo '<div><ul class="subsubsub">';
88
-                foreach( $sections as $section_id => $section_name ) {
88
+                foreach ($sections as $section_id => $section_name) {
89 89
                     echo '<li>';
90 90
                     $number++;
91
-                    $tab_url = add_query_arg( array(
91
+                    $tab_url = add_query_arg(array(
92 92
                         'settings-updated' => false,
93 93
                         'tab' => $active_tab,
94 94
                         'section' => $section_id
95
-                    ) );
96
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
95
+                    ));
96
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
97 97
                     $class = '';
98
-                    if ( $section == $section_id ) {
98
+                    if ($section == $section_id) {
99 99
                         $class = 'current';
100 100
                     }
101
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
101
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
102 102
 
103
-                    if ( $number != $number_of_sections ) {
103
+                    if ($number != $number_of_sections) {
104 104
                         echo ' | ';
105 105
                     }
106 106
                     echo '</li>';
@@ -112,19 +112,19 @@  discard block
 block discarded – undo
112 112
                 <form method="post" action="options.php">
113 113
                     <table class="form-table">
114 114
                         <?php
115
-                        settings_fields( 'wpinv_settings' );
115
+                        settings_fields('wpinv_settings');
116 116
 
117
-                        if ( 'main' === $section ) {
118
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
117
+                        if ('main' === $section) {
118
+                            do_action('wpinv_settings_tab_top', $active_tab);
119 119
                         }
120 120
 
121
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
122
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
123
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
121
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
122
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
123
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
124 124
 
125 125
                         // For backwards compatibility
126
-                        if ( 'main' === $section ) {
127
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
126
+                        if ('main' === $section) {
127
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
128 128
                         }
129 129
                         ?>
130 130
                     </table>
@@ -138,52 +138,52 @@  discard block
 block discarded – undo
138 138
     }
139 139
 
140 140
     public function remove_admin_submenus() {
141
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
141
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
142 142
     }
143 143
 
144
-    public function add_nav_menu_meta_boxes(){
145
-        add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
144
+    public function add_nav_menu_meta_boxes() {
145
+        add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low');
146 146
     }
147 147
 
148
-    public function nav_menu_links(){
148
+    public function nav_menu_links() {
149 149
         $endpoints = $this->get_menu_items();
150 150
         ?>
151 151
         <div id="invoicing-endpoints" class="posttypediv">
152
-        <?php if(!empty($endpoints['pages'])){ ?>
152
+        <?php if (!empty($endpoints['pages'])) { ?>
153 153
             <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
154 154
                 <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
155 155
                     <?php
156 156
                     $walker = new Walker_Nav_Menu_Checklist(array());
157
-                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
157
+                    echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object)array('walker' => $walker));
158 158
                     ?>
159 159
                 </ul>
160 160
             </div>
161 161
         <?php } ?>
162 162
         <p class="button-controls">
163 163
         <span class="list-controls">
164
-            <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>
164
+            <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>
165 165
         </span>
166 166
             <span class="add-to-menu">
167
-            <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">
167
+            <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">
168 168
             <span class="spinner"></span>
169 169
         </span>
170 170
         </p>
171 171
         <?php
172 172
     }
173 173
 
174
-    public function get_menu_items(){
174
+    public function get_menu_items() {
175 175
         $items = array();
176 176
 
177
-        $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' );
178
-        if($wpinv_history_page_id > 0){
177
+        $wpinv_history_page_id = (int)wpinv_get_option('invoice_history_page');
178
+        if ($wpinv_history_page_id > 0) {
179 179
             $item = new stdClass();
180 180
             $item->object_id = $wpinv_history_page_id;
181 181
             $item->db_id = 0;
182
-            $item->object =  'page';
182
+            $item->object = 'page';
183 183
             $item->menu_item_parent = 0;
184 184
             $item->type = 'post_type';
185
-            $item->title = __('Invoice History Page','invoicing');
186
-            $item->url = get_permalink( $wpinv_history_page_id );
185
+            $item->title = __('Invoice History Page', 'invoicing');
186
+            $item->url = get_permalink($wpinv_history_page_id);
187 187
             $item->target = '';
188 188
             $item->attr_title = '';
189 189
             $item->classes = array('wpinv-menu-item');
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
             $items['pages'][] = $item;
193 193
         }
194 194
 
195
-        $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' );
196
-        if($wpinv_sub_history_page_id > 0){
195
+        $wpinv_sub_history_page_id = (int)wpinv_get_option('invoice_subscription_page');
196
+        if ($wpinv_sub_history_page_id > 0) {
197 197
             $item = new stdClass();
198 198
             $item->object_id = $wpinv_sub_history_page_id;
199 199
             $item->db_id = 0;
200
-            $item->object =  'page';
200
+            $item->object = 'page';
201 201
             $item->menu_item_parent = 0;
202 202
             $item->type = 'post_type';
203
-            $item->title = __('Invoice Subscriptions Page','invoicing');
204
-            $item->url = get_permalink( $wpinv_sub_history_page_id );
203
+            $item->title = __('Invoice Subscriptions Page', 'invoicing');
204
+            $item->url = get_permalink($wpinv_sub_history_page_id);
205 205
             $item->target = '';
206 206
             $item->attr_title = '';
207 207
             $item->classes = array('wpinv-menu-item');
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
             $items['pages'][] = $item;
211 211
         }
212 212
 
213
-        $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' );
214
-        if($wpinv_checkout_page_id > 0){
213
+        $wpinv_checkout_page_id = (int)wpinv_get_option('checkout_page');
214
+        if ($wpinv_checkout_page_id > 0) {
215 215
             $item = new stdClass();
216 216
             $item->object_id = $wpinv_checkout_page_id;
217 217
             $item->db_id = 0;
218
-            $item->object =  'page';
218
+            $item->object = 'page';
219 219
             $item->menu_item_parent = 0;
220 220
             $item->type = 'post_type';
221
-            $item->title = __('Checkout Page','invoicing');
222
-            $item->url = get_permalink( $wpinv_checkout_page_id );
221
+            $item->title = __('Checkout Page', 'invoicing');
222
+            $item->url = get_permalink($wpinv_checkout_page_id);
223 223
             $item->target = '';
224 224
             $item->attr_title = '';
225 225
             $item->classes = array('wpinv-menu-item');
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
             $items['pages'][] = $item;
229 229
         }
230 230
 
231
-        $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' );
232
-        if($wpinv_tandc_page_id > 0){
231
+        $wpinv_tandc_page_id = (int)wpinv_get_option('tandc_page');
232
+        if ($wpinv_tandc_page_id > 0) {
233 233
             $item = new stdClass();
234 234
             $item->object_id = $wpinv_tandc_page_id;
235 235
             $item->db_id = 0;
236
-            $item->object =  'page';
236
+            $item->object = 'page';
237 237
             $item->menu_item_parent = 0;
238 238
             $item->type = 'post_type';
239
-            $item->title = __('Terms & Conditions','invoicing');
240
-            $item->url = get_permalink( $wpinv_tandc_page_id );
239
+            $item->title = __('Terms & Conditions', 'invoicing');
240
+            $item->url = get_permalink($wpinv_tandc_page_id);
241 241
             $item->target = '';
242 242
             $item->attr_title = '';
243 243
             $item->classes = array('wpinv-menu-item');
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
             $items['pages'][] = $item;
247 247
         }
248 248
 
249
-        $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' );
250
-        if($wpinv_success_page_id > 0){
249
+        $wpinv_success_page_id = (int)wpinv_get_option('success_page');
250
+        if ($wpinv_success_page_id > 0) {
251 251
             $item = new stdClass();
252 252
             $item->object_id = $wpinv_success_page_id;
253 253
             $item->db_id = 0;
254
-            $item->object =  'page';
254
+            $item->object = 'page';
255 255
             $item->menu_item_parent = 0;
256 256
             $item->type = 'post_type';
257
-            $item->title = __('Success Page','invoicing');
258
-            $item->url = get_permalink( $wpinv_success_page_id );
257
+            $item->title = __('Success Page', 'invoicing');
258
+            $item->url = get_permalink($wpinv_success_page_id);
259 259
             $item->target = '';
260 260
             $item->attr_title = '';
261 261
             $item->classes = array('wpinv-menu-item');
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
             $items['pages'][] = $item;
265 265
         }
266 266
 
267
-        $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' );
268
-        if($wpinv_failure_page_id > 0){
267
+        $wpinv_failure_page_id = (int)wpinv_get_option('failure_page');
268
+        if ($wpinv_failure_page_id > 0) {
269 269
             $item = new stdClass();
270 270
             $item->object_id = $wpinv_failure_page_id;
271 271
             $item->db_id = 0;
272
-            $item->object =  'page';
272
+            $item->object = 'page';
273 273
             $item->menu_item_parent = 0;
274 274
             $item->type = 'post_type';
275
-            $item->title = __('Failed Transaction Page','invoicing');
276
-            $item->url = get_permalink( $wpinv_failure_page_id );
275
+            $item->title = __('Failed Transaction Page', 'invoicing');
276
+            $item->url = get_permalink($wpinv_failure_page_id);
277 277
             $item->target = '';
278 278
             $item->attr_title = '';
279 279
             $item->classes = array('wpinv-menu-item');
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
             $items['pages'][] = $item;
283 283
         }
284 284
 
285
-        return apply_filters( 'wpinv_menu_items', $items );
285
+        return apply_filters('wpinv_menu_items', $items);
286 286
     }
287 287
 
288 288
 }
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' );
8
-function wpinv_discount_columns( $existing_columns ) {
7
+add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns');
8
+function wpinv_discount_columns($existing_columns) {
9 9
     $columns                = array();
10 10
     $columns['cb']          = $existing_columns['cb'];
11
-    $columns['name']        = __( 'Name', 'invoicing' );
12
-    $columns['code']        = __( 'Code', 'invoicing' );
13
-    $columns['amount']      = __( 'Amount', 'invoicing' );
14
-    $columns['usage']       = __( 'Usage / Limit', 'invoicing' );
15
-    $columns['start_date']  = __( 'Start Date', 'invoicing' );
16
-    $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' );
17
-    $columns['status']      = __( 'Status', 'invoicing' );
11
+    $columns['name']        = __('Name', 'invoicing');
12
+    $columns['code']        = __('Code', 'invoicing');
13
+    $columns['amount']      = __('Amount', 'invoicing');
14
+    $columns['usage']       = __('Usage / Limit', 'invoicing');
15
+    $columns['start_date']  = __('Start Date', 'invoicing');
16
+    $columns['expiry_date'] = __('Expiry Date', 'invoicing');
17
+    $columns['status']      = __('Status', 'invoicing');
18 18
 
19 19
     return $columns;
20 20
 }
21 21
 
22
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
23
-function wpinv_discount_custom_column( $column ) {
22
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
23
+function wpinv_discount_custom_column($column) {
24 24
     global $post;
25 25
     
26 26
     $discount = $post;
27 27
 
28
-    switch ( $column ) {
28
+    switch ($column) {
29 29
         case 'name' :
30
-            echo get_the_title( $discount->ID );
30
+            echo get_the_title($discount->ID);
31 31
         break;
32 32
         case 'code' :
33
-            echo wpinv_get_discount_code( $discount->ID );
33
+            echo wpinv_get_discount_code($discount->ID);
34 34
         break;
35 35
         case 'amount' :
36
-            echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
36
+            echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
37 37
         break;
38 38
         case 'usage_limit' :
39
-            echo wpinv_get_discount_uses( $discount->ID );
39
+            echo wpinv_get_discount_uses($discount->ID);
40 40
         break;
41 41
         case 'usage' :
42
-            $usage = wpinv_get_discount_uses( $discount->ID ) . ' / ';
43
-            if ( wpinv_get_discount_max_uses( $discount->ID ) ) {
44
-                $usage .= wpinv_get_discount_max_uses( $discount->ID );
42
+            $usage = wpinv_get_discount_uses($discount->ID) . ' / ';
43
+            if (wpinv_get_discount_max_uses($discount->ID)) {
44
+                $usage .= wpinv_get_discount_max_uses($discount->ID);
45 45
             } else {
46 46
                 $usage .= ' &infin;';
47 47
             }
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
             echo $usage;
50 50
         break;
51 51
         case 'start_date' :
52
-            if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) {
53
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) );
52
+            if ($start_date = wpinv_get_discount_start_date($discount->ID)) {
53
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date));
54 54
             } else {
55 55
                 $value = '-';
56 56
             }
@@ -58,163 +58,163 @@  discard block
 block discarded – undo
58 58
             echo $value;
59 59
         break;
60 60
         case 'expiry_date' :
61
-            if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) {
62
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) );
61
+            if ($expiration = wpinv_get_discount_expiration($discount->ID)) {
62
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration));
63 63
             } else {
64
-                $value = __( 'Never', 'invoicing' );
64
+                $value = __('Never', 'invoicing');
65 65
             }
66 66
                 
67 67
             echo $value;
68 68
         break;
69 69
         break;
70 70
         case 'description' :
71
-            echo wp_kses_post( $post->post_excerpt );
71
+            echo wp_kses_post($post->post_excerpt);
72 72
         break;
73 73
         case 'status' :
74
-            $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status;
74
+            $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status;
75 75
             
76
-            echo wpinv_discount_status( $status );
76
+            echo wpinv_discount_status($status);
77 77
         break;
78 78
     }
79 79
 }
80 80
 
81
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
82
-function wpinv_post_row_actions( $actions, $post ) {
83
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
81
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
82
+function wpinv_post_row_actions($actions, $post) {
83
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
84 84
     
85
-    if ( $post_type == 'wpi_invoice' ) {
85
+    if ($post_type == 'wpi_invoice') {
86 86
         $actions = array();
87 87
     }
88 88
     
89
-    if ( $post_type == 'wpi_discount' ) {
90
-        $actions = wpinv_discount_row_actions( $post, $actions );
89
+    if ($post_type == 'wpi_discount') {
90
+        $actions = wpinv_discount_row_actions($post, $actions);
91 91
     }
92 92
     
93 93
     return $actions;
94 94
 }
95 95
 
96
-function wpinv_discount_row_actions( $discount, $row_actions ) {
97
-    $row_actions  = array();
98
-    $edit_link = get_edit_post_link( $discount->ID );
99
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
96
+function wpinv_discount_row_actions($discount, $row_actions) {
97
+    $row_actions = array();
98
+    $edit_link = get_edit_post_link($discount->ID);
99
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
100 100
 
101
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
102
-        $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>';
103
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
104
-        $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>';
101
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
102
+        $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>';
103
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
104
+        $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>';
105 105
     }
106 106
 
107
-    if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) {
108
-        if ( isset( $row_actions['delete'] ) ) {
109
-            unset( $row_actions['delete'] ); // Don't delete used discounts.
107
+    if (wpinv_get_discount_uses($discount->ID) > 0) {
108
+        if (isset($row_actions['delete'])) {
109
+            unset($row_actions['delete']); // Don't delete used discounts.
110 110
         }
111 111
     } else {
112
-        $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>';
112
+        $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>';
113 113
     }
114 114
     
115 115
 
116
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
116
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
117 117
 
118 118
     return $row_actions;
119 119
 }
120 120
 
121
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
122
-function wpinv_table_primary_column( $default, $screen_id ) {
123
-    if ( 'edit-wpi_invoice' === $screen_id ) {
121
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
122
+function wpinv_table_primary_column($default, $screen_id) {
123
+    if ('edit-wpi_invoice' === $screen_id) {
124 124
         return 'name';
125 125
     }
126 126
     
127 127
     return $default;
128 128
 }
129 129
 
130
-function wpinv_discount_bulk_actions( $actions, $display = false ) {    
131
-    if ( !$display ) {
130
+function wpinv_discount_bulk_actions($actions, $display = false) {    
131
+    if (!$display) {
132 132
         return array();
133 133
     }
134 134
     
135 135
     $actions = array(
136
-        'activate'   => __( 'Activate', 'invoicing' ),
137
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
138
-        'delete'     => __( 'Delete', 'invoicing' ),
136
+        'activate'   => __('Activate', 'invoicing'),
137
+        'deactivate' => __('Deactivate', 'invoicing'),
138
+        'delete'     => __('Delete', 'invoicing'),
139 139
     );
140 140
     $two = '';
141 141
     $which = 'top';
142 142
     echo '</div><div class="alignleft actions bulkactions">';
143
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
144
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
145
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
143
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
144
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
145
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
146 146
 
147
-    foreach ( $actions as $name => $title ) {
147
+    foreach ($actions as $name => $title) {
148 148
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
149 149
 
150 150
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
151 151
     }
152 152
     echo "</select>";
153 153
 
154
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
154
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
155 155
     
156 156
     echo '</div><div class="alignleft actions">';
157 157
 }
158
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
158
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
159 159
 
160
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
161
-    if ( $post_type == 'wpi_discount' ) {
160
+function wpinv_disable_months_dropdown($disable, $post_type) {
161
+    if ($post_type == 'wpi_discount') {
162 162
         $disable = true;
163 163
     }
164 164
     
165 165
     return $disable;
166 166
 }
167
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
167
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
168 168
 
169 169
 function wpinv_restrict_manage_posts() {
170 170
     global $typenow;
171 171
 
172
-    if( 'wpi_discount' == $typenow ) {
172
+    if ('wpi_discount' == $typenow) {
173 173
         wpinv_discount_filters();
174 174
     }
175 175
 }
176
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
176
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
177 177
 
178 178
 function wpinv_discount_filters() {
179
-    echo wpinv_discount_bulk_actions( array(), true );
179
+    echo wpinv_discount_bulk_actions(array(), true);
180 180
     
181 181
     ?>
182 182
     <select name="discount_type" id="dropdown_wpinv_discount_type">
183
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
183
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
184 184
         <?php
185 185
             $types = wpinv_get_discount_types();
186 186
 
187
-            foreach ( $types as $name => $type ) {
188
-                echo '<option value="' . esc_attr( $name ) . '"';
187
+            foreach ($types as $name => $type) {
188
+                echo '<option value="' . esc_attr($name) . '"';
189 189
 
190
-                if ( isset( $_GET['discount_type'] ) )
191
-                    selected( $name, $_GET['discount_type'] );
190
+                if (isset($_GET['discount_type']))
191
+                    selected($name, $_GET['discount_type']);
192 192
 
193
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
193
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
194 194
             }
195 195
         ?>
196 196
     </select>
197 197
     <?php
198 198
 }
199 199
 
200
-function wpinv_request( $vars ) {
200
+function wpinv_request($vars) {
201 201
     global $typenow, $wp_query, $wp_post_statuses;
202 202
 
203
-    if ( 'wpi_invoice' === $typenow ) {
204
-        if ( !isset( $vars['post_status'] ) ) {
203
+    if ('wpi_invoice' === $typenow) {
204
+        if (!isset($vars['post_status'])) {
205 205
             $post_statuses = wpinv_get_invoice_statuses();
206 206
 
207
-            foreach ( $post_statuses as $status => $value ) {
208
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
209
-                    unset( $post_statuses[ $status ] );
207
+            foreach ($post_statuses as $status => $value) {
208
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
209
+                    unset($post_statuses[$status]);
210 210
                 }
211 211
             }
212 212
 
213
-            $vars['post_status'] = array_keys( $post_statuses );
213
+            $vars['post_status'] = array_keys($post_statuses);
214 214
         }
215 215
         
216
-        if ( isset( $vars['orderby'] ) ) {
217
-            if ( 'amount' == $vars['orderby'] ) {
216
+        if (isset($vars['orderby'])) {
217
+            if ('amount' == $vars['orderby']) {
218 218
                 $vars = array_merge(
219 219
                     $vars,
220 220
                     array(
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                         'orderby'  => 'meta_value_num'
223 223
                     )
224 224
                 );
225
-            } else if ( 'customer' == $vars['orderby'] ) {
225
+            } else if ('customer' == $vars['orderby']) {
226 226
                 $vars = array_merge(
227 227
                     $vars,
228 228
                     array(
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
                         'orderby'  => 'meta_value'
231 231
                     )
232 232
                 );
233
-            } else if ( 'number' == $vars['orderby'] ) {
233
+            } else if ('number' == $vars['orderby']) {
234 234
                 $vars = array_merge(
235 235
                     $vars,
236 236
                     array(
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                         'orderby'  => 'meta_value'
239 239
                     )
240 240
                 );
241
-            } else if ( 'payment_date' == $vars['orderby'] ) {
241
+            } else if ('payment_date' == $vars['orderby']) {
242 242
                 $vars = array_merge(
243 243
                     $vars,
244 244
                     array(
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
                 );
249 249
             }
250 250
         }
251
-    } else if ( 'wpi_item' == $typenow ) {
251
+    } else if ('wpi_item' == $typenow) {
252 252
         // Check if 'orderby' is set to "price"
253
-        if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
253
+        if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
254 254
             $vars = array_merge(
255 255
                 $vars,
256 256
                 array(
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         }
262 262
 
263 263
         // Check if "orderby" is set to "vat_rule"
264
-        if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) {
264
+        if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) {
265 265
             $vars = array_merge(
266 266
                 $vars,
267 267
                 array(
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
         }
273 273
 
274 274
         // Check if "orderby" is set to "vat_class"
275
-        if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) {
275
+        if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) {
276 276
             $vars = array_merge(
277 277
                 $vars,
278 278
                 array(
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         }
284 284
         
285 285
         // Check if "orderby" is set to "type"
286
-        if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) {
286
+        if (isset($vars['orderby']) && 'type' == $vars['orderby']) {
287 287
             $vars = array_merge(
288 288
                 $vars,
289 289
                 array(
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
         }
295 295
         
296 296
         // Check if "orderby" is set to "recurring"
297
-        if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) {
297
+        if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) {
298 298
             $vars = array_merge(
299 299
                 $vars,
300 300
                 array(
@@ -304,104 +304,104 @@  discard block
 block discarded – undo
304 304
             );
305 305
         }
306 306
 
307
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
307
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
308 308
         // Filter vat rule type
309
-        if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) {
309
+        if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') {
310 310
             $meta_query[] = array(
311 311
                     'key'   => '_wpinv_vat_rule',
312
-                    'value' => sanitize_text_field( $_GET['vat_rule'] ),
312
+                    'value' => sanitize_text_field($_GET['vat_rule']),
313 313
                     'compare' => '='
314 314
                 );
315 315
         }
316 316
         
317 317
         // Filter vat class
318
-        if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) {
318
+        if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') {
319 319
             $meta_query[] = array(
320 320
                     'key'   => '_wpinv_vat_class',
321
-                    'value' => sanitize_text_field( $_GET['vat_class'] ),
321
+                    'value' => sanitize_text_field($_GET['vat_class']),
322 322
                     'compare' => '='
323 323
                 );
324 324
         }
325 325
         
326 326
         // Filter item type
327
-        if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) {
327
+        if (isset($_GET['type']) && $_GET['type'] !== '') {
328 328
             $meta_query[] = array(
329 329
                     'key'   => '_wpinv_type',
330
-                    'value' => sanitize_text_field( $_GET['type'] ),
330
+                    'value' => sanitize_text_field($_GET['type']),
331 331
                     'compare' => '='
332 332
                 );
333 333
         }
334 334
         
335
-        if ( !empty( $meta_query ) ) {
335
+        if (!empty($meta_query)) {
336 336
             $vars['meta_query'] = $meta_query;
337 337
         }
338
-    } else if ( 'wpi_discount' == $typenow ) {
339
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
338
+    } else if ('wpi_discount' == $typenow) {
339
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
340 340
         // Filter vat rule type
341
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
341
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
342 342
             $meta_query[] = array(
343 343
                     'key'   => '_wpi_discount_type',
344
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
344
+                    'value' => sanitize_text_field($_GET['discount_type']),
345 345
                     'compare' => '='
346 346
                 );
347 347
         }
348 348
         
349
-        if ( !empty( $meta_query ) ) {
349
+        if (!empty($meta_query)) {
350 350
             $vars['meta_query'] = $meta_query;
351 351
         }
352 352
     }
353 353
 
354 354
     return $vars;
355 355
 }
356
-add_filter( 'request', 'wpinv_request' );
356
+add_filter('request', 'wpinv_request');
357 357
 
358
-function wpinv_item_type_class( $classes, $class, $post_id ) {
358
+function wpinv_item_type_class($classes, $class, $post_id) {
359 359
     global $pagenow, $typenow;
360 360
 
361
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
362
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
363
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
361
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
362
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
363
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
364 364
         }
365 365
         
366
-        if ( !wpinv_item_is_editable( $post_id ) ) {
366
+        if (!wpinv_item_is_editable($post_id)) {
367 367
             $classes[] = 'wpi-editable-n';
368 368
         }
369 369
     }
370 370
     return $classes;
371 371
 }
372
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
372
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
373 373
 
374 374
 function wpinv_check_quick_edit() {
375 375
     global $pagenow, $current_screen, $wpinv_item_screen;
376 376
 
377
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
378
-        if ( empty( $wpinv_item_screen ) ) {
379
-            if ( $current_screen->post_type == 'wpi_item' ) {
377
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
378
+        if (empty($wpinv_item_screen)) {
379
+            if ($current_screen->post_type == 'wpi_item') {
380 380
                 $wpinv_item_screen = 'y';
381 381
             } else {
382 382
                 $wpinv_item_screen = 'n';
383 383
             }
384 384
         }
385 385
 
386
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
387
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
388
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
386
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
387
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
388
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
389 389
         }
390 390
     }
391 391
 }
392
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
392
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
393 393
 
394
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
395
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
396
-        unset( $actions['inline hide-if-no-js'] );
394
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
395
+    if (isset($actions['inline hide-if-no-js'])) {
396
+        unset($actions['inline hide-if-no-js']);
397 397
     }
398 398
     
399
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
400
-        if ( isset( $actions['trash'] ) ) {
401
-            unset( $actions['trash'] );
399
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
400
+        if (isset($actions['trash'])) {
401
+            unset($actions['trash']);
402 402
         }
403
-        if ( isset( $actions['delete'] ) ) {
404
-            unset( $actions['delete'] );
403
+        if (isset($actions['delete'])) {
404
+            unset($actions['delete']);
405 405
         }
406 406
     }
407 407
 
@@ -418,19 +418,19 @@  discard block
 block discarded – undo
418 418
  * @param int $post_parent (default: 0) Parent for the new page
419 419
  * @return int page ID
420 420
  */
421
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
421
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
422 422
     global $wpdb;
423 423
 
424
-    $option_value = wpinv_get_option( $option );
424
+    $option_value = wpinv_get_option($option);
425 425
 
426
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
427
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
426
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
427
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
428 428
             // Valid page is already in place
429 429
             return $page_object->ID;
430 430
         }
431 431
     }
432 432
 
433
-    if(!empty($post_parent)){
433
+    if (!empty($post_parent)) {
434 434
         $page = get_page_by_path($post_parent);
435 435
         if ($page) {
436 436
             $post_parent = $page->ID;
@@ -439,40 +439,40 @@  discard block
 block discarded – undo
439 439
         }
440 440
     }
441 441
 
442
-    if ( strlen( $page_content ) > 0 ) {
442
+    if (strlen($page_content) > 0) {
443 443
         // Search for an existing page with the specified page content (typically a shortcode)
444
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
444
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
445 445
     } else {
446 446
         // Search for an existing page with the specified page slug
447
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
447
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
448 448
     }
449 449
 
450
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
450
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
451 451
 
452
-    if ( $valid_page_found ) {
453
-        if ( $option ) {
454
-            wpinv_update_option( $option, $valid_page_found );
452
+    if ($valid_page_found) {
453
+        if ($option) {
454
+            wpinv_update_option($option, $valid_page_found);
455 455
         }
456 456
         return $valid_page_found;
457 457
     }
458 458
 
459 459
     // Search for a matching valid trashed page
460
-    if ( strlen( $page_content ) > 0 ) {
460
+    if (strlen($page_content) > 0) {
461 461
         // Search for an existing page with the specified page content (typically a shortcode)
462
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
462
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
463 463
     } else {
464 464
         // Search for an existing page with the specified page slug
465
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
465
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
466 466
     }
467 467
 
468
-    if ( $trashed_page_found ) {
468
+    if ($trashed_page_found) {
469 469
         $page_id   = $trashed_page_found;
470 470
         $page_data = array(
471 471
             'ID'             => $page_id,
472 472
             'post_status'    => 'publish',
473 473
             'post_parent'    => $post_parent,
474 474
         );
475
-        wp_update_post( $page_data );
475
+        wp_update_post($page_data);
476 476
     } else {
477 477
         $page_data = array(
478 478
             'post_status'    => 'publish',
@@ -484,11 +484,11 @@  discard block
 block discarded – undo
484 484
             'post_parent'    => $post_parent,
485 485
             'comment_status' => 'closed',
486 486
         );
487
-        $page_id = wp_insert_post( $page_data );
487
+        $page_id = wp_insert_post($page_data);
488 488
     }
489 489
 
490
-    if ( $option ) {
491
-        wpinv_update_option( $option, (int)$page_id );
490
+    if ($option) {
491
+        wpinv_update_option($option, (int)$page_id);
492 492
     }
493 493
 
494 494
     return $page_id;
Please login to merge, or discard this patch.