Passed
Push — master ( 039fc1...a932b5 )
by Brian
05:54
created
vendor/ayecode/wp-ayecode-ui/includes/inc/bs5-js.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -993,8 +993,8 @@
 block discarded – undo
993 993
     aui_flip_color_scheme_on_scroll();
994 994
 
995 995
 	<?php
996
-	// FSE tweaks.
997
-	if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?>
996
+    // FSE tweaks.
997
+    if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?>
998 998
     function aui_fse_set_data_scroll() {
999 999
         console.log('init scroll');
1000 1000
         let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas");
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-alert.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,87 +11,87 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Alert {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 * 
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get($args = array()){
22
-		global $aui_bs5;
23
-		$defaults = array(
24
-			'type'       => 'info',
25
-			'class'      => '',
26
-			'icon' => '',
27
-			'heading'    => '',
28
-			'content'    => '',
29
-			'footer'     => '',
30
-			'dismissible'=> false,
31
-			'data'       => '',
32
-		);
33
-
34
-		/**
35
-		 * Parse incoming $args into an array and merge it with $defaults
36
-		 */
37
-		$args   = wp_parse_args( $args, $defaults );
38
-		$output = '';
39
-		if ( ! empty( $args['content'] ) ) {
40
-			$type = sanitize_html_class( $args['type'] );
41
-			if($type=='error'){$type='danger';}
42
-			$icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : '';
43
-
44
-			// set default icon
45
-			if(!$icon && $args['icon']!==false && $type){
46
-				if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';}
47
-				elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';}
48
-				elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';}
49
-				elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';}
50
-			}
51
-
52
-			$data = '';
53
-			$class = !empty($args['class']) ? esc_attr($args['class']) : '';
54
-			if($args['dismissible']){$class .= " alert-dismissible fade show";}
55
-
56
-			// open
57
-			$output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>';
58
-
59
-			// heading
60
-			if ( ! empty( $args['heading'] ) ) {
61
-				$output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>';
62
-			}
63
-
64
-			// icon
65
-			if ( ! empty( $icon) ) {
66
-				$output .= $icon." ";
67
-			}
68
-
69
-			// content
70
-			$output .= $args['content'];
71
-
72
-			// dismissible
73
-			if($args['dismissible']){
74
-
75
-				if ( $aui_bs5 ) {
76
-					$output .= '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
77
-				}else{
78
-					$output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">';
79
-					$output .= '<span aria-hidden="true">&times;</span>';
80
-					$output .= '</button>';
81
-				}
82
-			}
83
-
84
-			// footer
85
-			if ( ! empty( $args['footer'] ) ) {
86
-				$output .= '<hr>';
87
-				$output .= '<p class="mb-0">' . $args['footer'] . '</p>';
88
-			}
89
-
90
-			// close
91
-			$output .= '</div>';
92
-		}
93
-
94
-		return $output;
95
-	}
14
+    /**
15
+     * Build the component.
16
+     * 
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get($args = array()){
22
+        global $aui_bs5;
23
+        $defaults = array(
24
+            'type'       => 'info',
25
+            'class'      => '',
26
+            'icon' => '',
27
+            'heading'    => '',
28
+            'content'    => '',
29
+            'footer'     => '',
30
+            'dismissible'=> false,
31
+            'data'       => '',
32
+        );
33
+
34
+        /**
35
+         * Parse incoming $args into an array and merge it with $defaults
36
+         */
37
+        $args   = wp_parse_args( $args, $defaults );
38
+        $output = '';
39
+        if ( ! empty( $args['content'] ) ) {
40
+            $type = sanitize_html_class( $args['type'] );
41
+            if($type=='error'){$type='danger';}
42
+            $icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : '';
43
+
44
+            // set default icon
45
+            if(!$icon && $args['icon']!==false && $type){
46
+                if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';}
47
+                elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';}
48
+                elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';}
49
+                elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';}
50
+            }
51
+
52
+            $data = '';
53
+            $class = !empty($args['class']) ? esc_attr($args['class']) : '';
54
+            if($args['dismissible']){$class .= " alert-dismissible fade show";}
55
+
56
+            // open
57
+            $output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>';
58
+
59
+            // heading
60
+            if ( ! empty( $args['heading'] ) ) {
61
+                $output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>';
62
+            }
63
+
64
+            // icon
65
+            if ( ! empty( $icon) ) {
66
+                $output .= $icon." ";
67
+            }
68
+
69
+            // content
70
+            $output .= $args['content'];
71
+
72
+            // dismissible
73
+            if($args['dismissible']){
74
+
75
+                if ( $aui_bs5 ) {
76
+                    $output .= '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
77
+                }else{
78
+                    $output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">';
79
+                    $output .= '<span aria-hidden="true">&times;</span>';
80
+                    $output .= '</button>';
81
+                }
82
+            }
83
+
84
+            // footer
85
+            if ( ! empty( $args['footer'] ) ) {
86
+                $output .= '<hr>';
87
+                $output .= '<p class="mb-0">' . $args['footer'] . '</p>';
88
+            }
89
+
90
+            // close
91
+            $output .= '</div>';
92
+        }
93
+
94
+        return $output;
95
+    }
96 96
 
97 97
 }
98 98
\ No newline at end of file
Please login to merge, or discard this patch.
wp-ayecode-ui/includes/components/class-aui-component-pagination.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,112 +11,112 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Pagination {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get( $args = array() ) {
22
-		global $wp_query, $aui_bs5;
23
-
24
-		$defaults = array(
25
-			'class'              => '',
26
-			'mid_size'           => 2,
27
-			'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
-			'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
-			'screen_reader_text' => __( 'Posts navigation','aui' ),
30
-			'before_paging'      => '',
31
-			'after_paging'       => '',
32
-			'type'               => 'array',
33
-			'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
-			'links'              => array(), // an array of links if using custom links, this includes the a tag.
35
-			'rounded_style'      => false,
36
-			'custom_next_text'   => '', // Custom next page text
37
-			'custom_prev_text'   => '', // Custom prev page text
38
-		);
39
-
40
-		/**
41
-		 * Parse incoming $args into an array and merge it with $defaults
42
-		 */
43
-		$args = wp_parse_args( $args, $defaults );
44
-
45
-		$output = '';
46
-
47
-		// Don't print empty markup if there's only one page.
48
-		if ( $args['total'] > 1 ) {
49
-			// Set up paginated links.
50
-			$links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
51
-
52
-			$class = !empty($args['class']) ? $args['class'] : '';
53
-
54
-			$custom_prev_link = '';
55
-			$custom_next_link = '';
56
-
57
-			// make the output bootstrap ready
58
-			$links_html = "<ul class='pagination m-0 p-0 $class'>";
59
-			if ( ! empty( $links ) ) {
60
-				foreach ( $links as $link ) {
61
-					$_link = $link;
62
-
63
-					if ( $aui_bs5 ) {
64
-						$link_class = $args['rounded_style'] ? 'page-link badge rounded-pill border-0 mx-1 fs-base text-dark link-primary' : 'page-link';
65
-						$link_class_active = $args['rounded_style'] ? ' current active fw-bold badge rounded-pill' : ' current active';
66
-						$links_html .= "<li class='page-item mx-0'>";
67
-						$link = str_replace( array( "page-numbers", " current" ), array( $link_class, $link_class_active ), $link );
68
-						$link = str_replace( 'text-dark link-primary current', 'current', $link );
69
-						$links_html .=  $link;
70
-						$links_html .= "</li>";
71
-					} else {
72
-						$active = strpos( $link, 'current' ) !== false ? 'active' : '';
73
-						$links_html .= "<li class='page-item $active'>";
74
-						$links_html .= str_replace( "page-numbers", "page-link", $link );
75
-						$links_html .= "</li>";
76
-					}
77
-
78
-					if ( strpos( $_link, 'next page-numbers' ) || strpos( $_link, 'prev page-numbers' ) ) {
79
-						$link = str_replace( array( "page-numbers", " current" ), array( 'btn btn-outline-primary rounded' . ( $args['rounded_style'] ? '-pill' : '' ) . ' mx-1 fs-base text-dark link-primary', ' current active fw-bold badge rounded-pill' ), $_link );
80
-						$link = str_replace( 'text-dark link-primary current', 'current', $link );
81
-
82
-						if ( strpos( $_link, 'next page-numbers' ) && ! empty( $args['custom_next_text'] ) ) {
83
-							$custom_next_link = str_replace( $args['next_text'], $args['custom_next_text'], $link );
84
-						} else if ( strpos( $_link, 'prev page-numbers' ) && ! empty( $args['custom_prev_text'] ) ) {
85
-							$custom_prev_link = str_replace( $args['prev_text'], $args['custom_prev_text'], $link );
86
-						}
87
-					}
88
-				}
89
-			}
90
-			$links_html .= "</ul>";
91
-
92
-			if ( $links ) {
93
-				$output .= '<section class="px-0 py-2 w-100">';
94
-				$output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
95
-				$output .= '</section>';
96
-			}
97
-
98
-			$output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
99
-			$output = str_replace( "nav-links", "aui-nav-links", $output );
100
-		}
101
-
102
-		if ( $output ) {
103
-			if ( $custom_next_link || $custom_prev_link ) {
104
-				$total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
105
-				$current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
106
-
107
-				$output = '<div class="row d-flex align-items-center justify-content-between"><div class="col text-start">' . $custom_prev_link . '</div><div class="col text-center d-none d-md-block">' . $output . '</div><div class="col text-center d-md-none">' . $current . '/' . $args['total'] . '</div><div class="col text-end">' . $custom_next_link . '</div></div>';
108
-			}
109
-
110
-			if ( ! empty( $args['before_paging'] ) ) {
111
-				$output = $args['before_paging'] . $output;
112
-			}
113
-
114
-			if ( ! empty( $args['after_paging'] ) ) {
115
-				$output = $output . $args['after_paging'];
116
-			}
117
-		}
118
-
119
-		return $output;
120
-	}
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get( $args = array() ) {
22
+        global $wp_query, $aui_bs5;
23
+
24
+        $defaults = array(
25
+            'class'              => '',
26
+            'mid_size'           => 2,
27
+            'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
+            'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
+            'screen_reader_text' => __( 'Posts navigation','aui' ),
30
+            'before_paging'      => '',
31
+            'after_paging'       => '',
32
+            'type'               => 'array',
33
+            'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
+            'links'              => array(), // an array of links if using custom links, this includes the a tag.
35
+            'rounded_style'      => false,
36
+            'custom_next_text'   => '', // Custom next page text
37
+            'custom_prev_text'   => '', // Custom prev page text
38
+        );
39
+
40
+        /**
41
+         * Parse incoming $args into an array and merge it with $defaults
42
+         */
43
+        $args = wp_parse_args( $args, $defaults );
44
+
45
+        $output = '';
46
+
47
+        // Don't print empty markup if there's only one page.
48
+        if ( $args['total'] > 1 ) {
49
+            // Set up paginated links.
50
+            $links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
51
+
52
+            $class = !empty($args['class']) ? $args['class'] : '';
53
+
54
+            $custom_prev_link = '';
55
+            $custom_next_link = '';
56
+
57
+            // make the output bootstrap ready
58
+            $links_html = "<ul class='pagination m-0 p-0 $class'>";
59
+            if ( ! empty( $links ) ) {
60
+                foreach ( $links as $link ) {
61
+                    $_link = $link;
62
+
63
+                    if ( $aui_bs5 ) {
64
+                        $link_class = $args['rounded_style'] ? 'page-link badge rounded-pill border-0 mx-1 fs-base text-dark link-primary' : 'page-link';
65
+                        $link_class_active = $args['rounded_style'] ? ' current active fw-bold badge rounded-pill' : ' current active';
66
+                        $links_html .= "<li class='page-item mx-0'>";
67
+                        $link = str_replace( array( "page-numbers", " current" ), array( $link_class, $link_class_active ), $link );
68
+                        $link = str_replace( 'text-dark link-primary current', 'current', $link );
69
+                        $links_html .=  $link;
70
+                        $links_html .= "</li>";
71
+                    } else {
72
+                        $active = strpos( $link, 'current' ) !== false ? 'active' : '';
73
+                        $links_html .= "<li class='page-item $active'>";
74
+                        $links_html .= str_replace( "page-numbers", "page-link", $link );
75
+                        $links_html .= "</li>";
76
+                    }
77
+
78
+                    if ( strpos( $_link, 'next page-numbers' ) || strpos( $_link, 'prev page-numbers' ) ) {
79
+                        $link = str_replace( array( "page-numbers", " current" ), array( 'btn btn-outline-primary rounded' . ( $args['rounded_style'] ? '-pill' : '' ) . ' mx-1 fs-base text-dark link-primary', ' current active fw-bold badge rounded-pill' ), $_link );
80
+                        $link = str_replace( 'text-dark link-primary current', 'current', $link );
81
+
82
+                        if ( strpos( $_link, 'next page-numbers' ) && ! empty( $args['custom_next_text'] ) ) {
83
+                            $custom_next_link = str_replace( $args['next_text'], $args['custom_next_text'], $link );
84
+                        } else if ( strpos( $_link, 'prev page-numbers' ) && ! empty( $args['custom_prev_text'] ) ) {
85
+                            $custom_prev_link = str_replace( $args['prev_text'], $args['custom_prev_text'], $link );
86
+                        }
87
+                    }
88
+                }
89
+            }
90
+            $links_html .= "</ul>";
91
+
92
+            if ( $links ) {
93
+                $output .= '<section class="px-0 py-2 w-100">';
94
+                $output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
95
+                $output .= '</section>';
96
+            }
97
+
98
+            $output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
99
+            $output = str_replace( "nav-links", "aui-nav-links", $output );
100
+        }
101
+
102
+        if ( $output ) {
103
+            if ( $custom_next_link || $custom_prev_link ) {
104
+                $total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
105
+                $current = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
106
+
107
+                $output = '<div class="row d-flex align-items-center justify-content-between"><div class="col text-start">' . $custom_prev_link . '</div><div class="col text-center d-none d-md-block">' . $output . '</div><div class="col text-center d-md-none">' . $current . '/' . $args['total'] . '</div><div class="col text-end">' . $custom_next_link . '</div></div>';
108
+            }
109
+
110
+            if ( ! empty( $args['before_paging'] ) ) {
111
+                $output = $args['before_paging'] . $output;
112
+            }
113
+
114
+            if ( ! empty( $args['after_paging'] ) ) {
115
+                $output = $output . $args['after_paging'];
116
+            }
117
+        }
118
+
119
+        return $output;
120
+    }
121 121
 
122 122
 }
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-helper.php 1 patch
Indentation   +467 added lines, -467 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,470 +11,470 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Helper {
13 13
 
14
-	/**
15
-	 * A component helper for generating a input name.
16
-	 *
17
-	 * @param $text
18
-	 * @param $multiple bool If the name is set to be multiple but no brackets found then we add some.
19
-	 *
20
-	 * @return string
21
-	 */
22
-	public static function name( $text, $multiple = false ) {
23
-		$output = '';
24
-
25
-		if ( $text ) {
26
-			$is_multiple = strpos( $text, '[' ) === false && $multiple ? '[]' : '';
27
-			$output      = ' name="' . esc_attr( $text ) . $is_multiple . '" ';
28
-		}
29
-
30
-		return $output;
31
-	}
32
-
33
-	/**
34
-	 * A component helper for generating a item id.
35
-	 *
36
-	 * @param $text string The text to be used as the value.
37
-	 *
38
-	 * @return string The sanitized item.
39
-	 */
40
-	public static function id( $text ) {
41
-		$output = '';
42
-
43
-		if ( $text ) {
44
-			$output = ' id="' . sanitize_html_class( $text ) . '" ';
45
-		}
46
-
47
-		return $output;
48
-	}
49
-
50
-	/**
51
-	 * A component helper for generating a item title.
52
-	 *
53
-	 * @param $text string The text to be used as the value.
54
-	 *
55
-	 * @return string The sanitized item.
56
-	 */
57
-	public static function title( $text ) {
58
-		$output = '';
59
-
60
-		if ( $text ) {
61
-			$output = ' title="' . esc_attr( $text ) . '" ';
62
-		}
63
-
64
-		return $output;
65
-	}
66
-
67
-	/**
68
-	 * A component helper for generating a item value.
69
-	 *
70
-	 * @param $text string The text to be used as the value.
71
-	 *
72
-	 * @return string The sanitized item.
73
-	 */
74
-	public static function value( $text ) {
75
-		$output = '';
76
-
77
-		if ( $text !== null && $text !== false ) {
78
-			$output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" ';
79
-		}
80
-
81
-		return $output;
82
-	}
83
-
84
-	/**
85
-	 * A component helper for generating a item class attribute.
86
-	 *
87
-	 * @param $text string The text to be used as the value.
88
-	 *
89
-	 * @return string The sanitized item.
90
-	 */
91
-	public static function class_attr( $text ) {
92
-		$output = '';
93
-
94
-		if ( $text ) {
95
-			$classes = self::esc_classes( $text );
96
-			if ( ! empty( $classes ) ) {
97
-				$output = ' class="' . $classes . '" ';
98
-			}
99
-		}
100
-
101
-		return $output;
102
-	}
103
-
104
-	/**
105
-	 * Escape a string of classes.
106
-	 *
107
-	 * @param $text
108
-	 *
109
-	 * @return string
110
-	 */
111
-	public static function esc_classes( $text ) {
112
-		$output = '';
113
-
114
-		if ( $text ) {
115
-			$classes = explode( " ", $text );
116
-			$classes = array_map( "trim", $classes );
117
-			$classes = array_map( "sanitize_html_class", $classes );
118
-			if ( ! empty( $classes ) ) {
119
-				$output = implode( " ", $classes );
120
-			}
121
-		}
122
-
123
-		return $output;
124
-
125
-	}
126
-
127
-	/**
128
-	 * @param $args
129
-	 *
130
-	 * @return string
131
-	 */
132
-	public static function data_attributes( $args ) {
133
-		$output = '';
134
-
135
-		if ( ! empty( $args ) ) {
136
-
137
-			foreach ( $args as $key => $val ) {
138
-				if ( substr( $key, 0, 5 ) === "data-" ) {
139
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
140
-				}
141
-			}
142
-		}
143
-
144
-		return $output;
145
-	}
146
-
147
-	/**
148
-	 * @param $args
149
-	 *
150
-	 * @return string
151
-	 */
152
-	public static function aria_attributes( $args ) {
153
-		$output = '';
154
-
155
-		if ( ! empty( $args ) ) {
156
-
157
-			foreach ( $args as $key => $val ) {
158
-				if ( substr( $key, 0, 5 ) === "aria-" ) {
159
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
160
-				}
161
-			}
162
-		}
163
-
164
-		return $output;
165
-	}
166
-
167
-	/**
168
-	 * Build a font awesome icon from a class.
169
-	 *
170
-	 * @param $class
171
-	 * @param bool $space_after
172
-	 * @param array $extra_attributes An array of extra attributes.
173
-	 *
174
-	 * @return string
175
-	 */
176
-	public static function icon( $class, $space_after = false, $extra_attributes = array() ) {
177
-		$output = '';
178
-
179
-		if ( $class ) {
180
-			$classes = self::esc_classes( $class );
181
-			if ( ! empty( $classes ) ) {
182
-				$output = '<i class="' . $classes . '" ';
183
-				// extra attributes
184
-				if ( ! empty( $extra_attributes ) ) {
185
-					$output .= AUI_Component_Helper::extra_attributes( $extra_attributes );
186
-				}
187
-				$output .= '></i>';
188
-				if ( $space_after ) {
189
-					$output .= " ";
190
-				}
191
-			}
192
-		}
193
-
194
-		return $output;
195
-	}
196
-
197
-	/**
198
-	 * @param $args
199
-	 *
200
-	 * @return string
201
-	 */
202
-	public static function extra_attributes( $args ) {
203
-		$output = '';
204
-
205
-		if ( ! empty( $args ) ) {
206
-
207
-			if ( is_array( $args ) ) {
208
-				foreach ( $args as $key => $val ) {
209
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
210
-				}
211
-			} else {
212
-				$output .= ' ' . $args . ' ';
213
-			}
214
-
215
-		}
216
-
217
-		return $output;
218
-	}
219
-
220
-	/**
221
-	 * @param $args
222
-	 *
223
-	 * @return string
224
-	 */
225
-	public static function help_text( $text ) {
226
-		$output = '';
227
-
228
-		if ( $text ) {
229
-			$output .= '<small class="form-text text-muted d-block">' . wp_kses_post( $text ) . '</small>';
230
-		}
231
-
232
-
233
-		return $output;
234
-	}
235
-
236
-	/**
237
-	 * Replace element require context with JS.
238
-	 *
239
-	 * @param $input
240
-	 *
241
-	 * @return string|void
242
-	 */
243
-	public static function element_require( $input ) {
244
-
245
-		$input = str_replace( "'", '"', $input );// we only want double quotes
246
-
247
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
248
-			"jQuery(form).find('[data-argument=\"",
249
-			"\"]').find('input,select,textarea').val()",
250
-			"\"]').find('input:checked').val()",
251
-		), $input ) );
252
-
253
-		if ( $output ) {
254
-			$output = ' data-element-require="' . $output . '" ';
255
-		}
256
-
257
-		return $output;
258
-	}
259
-
260
-	/**
261
-	 * Navigates through an array, object, or scalar, and removes slashes from the values.
262
-	 *
263
-	 * @since 0.1.41
264
-	 *
265
-	 * @param mixed $value The value to be stripped.
266
-	 * @param array $input Input Field.
267
-	 *
268
-	 * @return mixed Stripped value.
269
-	 */
270
-	public static function sanitize_html_field( $value, $input = array() ) {
271
-		$original = $value;
272
-
273
-		if ( is_array( $value ) ) {
274
-			foreach ( $value as $index => $item ) {
275
-				$value[ $index ] = self::_sanitize_html_field( $value, $input );
276
-			}
277
-		} elseif ( is_object( $value ) ) {
278
-			$object_vars = get_object_vars( $value );
279
-
280
-			foreach ( $object_vars as $property_name => $property_value ) {
281
-				$value->$property_name = self::_sanitize_html_field( $property_value, $input );
282
-			}
283
-		} else {
284
-			$value = self::_sanitize_html_field( $value, $input );
285
-		}
286
-
287
-		/**
288
-		 * Filters content and keeps only allowable HTML elements.
289
-		 *
290
-		 * @since 0.1.41
291
-		 *
292
-		 * @param string|array $value Content to filter through kses.
293
-		 * @param string|array $value Original content without filter.
294
-		 * @param array $input Input Field.
295
-		 */
296
-		return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input );
297
-	}
298
-
299
-	/**
300
-	 * Filters content and keeps only allowable HTML elements.
301
-	 *
302
-	 * This function makes sure that only the allowed HTML element names, attribute
303
-	 * names and attribute values plus only sane HTML entities will occur in
304
-	 * $string. You have to remove any slashes from PHP's magic quotes before you
305
-	 * call this function.
306
-	 *
307
-	 * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
308
-	 * 'irc', 'gopher', 'nntp', 'feed', 'telnet, 'mms', 'rtsp' and 'svn'. This
309
-	 * covers all common link protocols, except for 'javascript' which should not
310
-	 * be allowed for untrusted users.
311
-	 *
312
-	 * @since 0.1.41
313
-	 *
314
-	 * @param string|array $value Content to filter through kses.
315
-	 * @param array $input Input Field.
316
-	 *
317
-	 * @return string Filtered content with only allowed HTML elements.
318
-	 */
319
-	public static function _sanitize_html_field( $value, $input = array() ) {
320
-		if ( $value === '' ) {
321
-			return $value;
322
-		}
323
-
324
-		$allowed_html = self::kses_allowed_html( 'post', $input );
325
-
326
-		if ( ! is_array( $allowed_html ) ) {
327
-			$allowed_html = wp_kses_allowed_html( 'post' );
328
-		}
329
-
330
-		$filtered = trim( wp_unslash( $value ) );
331
-		$filtered = wp_kses( $filtered, $allowed_html );
332
-		$filtered = balanceTags( $filtered ); // Balances tags
333
-
334
-		return $filtered;
335
-	}
336
-
337
-	/**
338
-	 * Returns an array of allowed HTML tags and attributes for a given context.
339
-	 *
340
-	 * @since 0.1.41
341
-	 *
342
-	 * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
343
-	 *                              'strip', 'data', 'entities', or the name of a field filter such as
344
-	 *                              'pre_user_description'.
345
-	 * @param array $input Input.
346
-	 *
347
-	 * @return array Array of allowed HTML tags and their allowed attributes.
348
-	 */
349
-	public static function kses_allowed_html( $context = 'post', $input = array() ) {
350
-		$allowed_html = wp_kses_allowed_html( $context );
351
-
352
-		if ( is_array( $allowed_html ) ) {
353
-			// <iframe>
354
-			if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) {
355
-				$allowed_html['iframe'] = array(
356
-					'class'           => true,
357
-					'id'              => true,
358
-					'src'             => true,
359
-					'width'           => true,
360
-					'height'          => true,
361
-					'frameborder'     => true,
362
-					'marginwidth'     => true,
363
-					'marginheight'    => true,
364
-					'scrolling'       => true,
365
-					'style'           => true,
366
-					'title'           => true,
367
-					'allow'           => true,
368
-					'allowfullscreen' => true,
369
-					'data-*'          => true,
370
-				);
371
-			}
372
-		}
373
-
374
-		/**
375
-		 * Filters the allowed html tags.
376
-		 *
377
-		 * @since 0.1.41
378
-		 *
379
-		 * @param array[]|string $allowed_html Allowed html tags.
380
-		 * @param @param string|array $context The context for which to retrieve tags.
381
-		 * @param array $input Input field.
382
-		 */
383
-		return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input );
384
-	}
385
-
386
-	public static function get_column_class( $label_number = 2, $type = 'label' ) {
387
-
388
-		$class = '';
389
-
390
-		// set default if empty
391
-		if( $label_number === '' ){
392
-			$label_number = 2;
393
-		}
394
-
395
-		if ( $label_number && $label_number < 12 && $label_number > 0 ) {
396
-			if ( $type == 'label' ) {
397
-				$class = 'col-sm-' . absint( $label_number );
398
-			} elseif ( $type == 'input' ) {
399
-				$class = 'col-sm-' . ( 12 - absint( $label_number ) );
400
-			}
401
-		}
402
-
403
-		return $class;
404
-	}
405
-
406
-	/**
407
-	 * Sanitizes a multiline string from user input or from the database.
408
-	 *
409
-	 * Emulate the WP native sanitize_textarea_field function in a %%variable%% safe way.
410
-	 *
411
-	 * @see   https://core.trac.wordpress.org/browser/trunk/src/wp-includes/formatting.php for the original
412
-	 *
413
-	 * @since 0.1.66
414
-	 *
415
-	 * @param string $str String to sanitize.
416
-	 * @return string Sanitized string.
417
-	 */
418
-	public static function sanitize_textarea_field( $str ) {
419
-		$filtered = self::_sanitize_text_fields( $str, true );
420
-
421
-		/**
422
-		 * Filters a sanitized textarea field string.
423
-		 *
424
-		 * @see https://core.trac.wordpress.org/browser/trunk/src/wp-includes/formatting.php
425
-		 *
426
-		 * @param string $filtered The sanitized string.
427
-		 * @param string $str      The string prior to being sanitized.
428
-		 */
429
-		return apply_filters( 'sanitize_textarea_field', $filtered, $str );
430
-	}
431
-
432
-	/**
433
-	 * Internal helper function to sanitize a string from user input or from the db.
434
-	 *
435
-	 * @since 0.1.66
436
-	 * @access private
437
-	 *
438
-	 * @param string $str           String to sanitize.
439
-	 * @param bool   $keep_newlines Optional. Whether to keep newlines. Default: false.
440
-	 * @return string Sanitized string.
441
-	 */
442
-	public static function _sanitize_text_fields( $str, $keep_newlines = false ) {
443
-		if ( is_object( $str ) || is_array( $str ) ) {
444
-			return '';
445
-		}
446
-
447
-		$str = (string) $str;
448
-
449
-		$filtered = wp_check_invalid_utf8( $str );
450
-
451
-		if ( strpos( $filtered, '<' ) !== false ) {
452
-			$filtered = wp_pre_kses_less_than( $filtered );
453
-			// This will strip extra whitespace for us.
454
-			$filtered = wp_strip_all_tags( $filtered, false );
455
-
456
-			// Use HTML entities in a special case to make sure no later
457
-			// newline stripping stage could lead to a functional tag.
458
-			$filtered = str_replace( "<\n", "&lt;\n", $filtered );
459
-		}
460
-
461
-		if ( ! $keep_newlines ) {
462
-			$filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
463
-		}
464
-		$filtered = trim( $filtered );
465
-
466
-		$found = false;
467
-		while ( preg_match( '`[^%](%[a-f0-9]{2})`i', $filtered, $match ) ) {
468
-			$filtered = str_replace( $match[1], '', $filtered );
469
-			$found = true;
470
-		}
471
-		unset( $match );
472
-
473
-		if ( $found ) {
474
-			// Strip out the whitespace that may now exist after removing the octets.
475
-			$filtered = trim( preg_replace( '` +`', ' ', $filtered ) );
476
-		}
477
-
478
-		return $filtered;
479
-	}
14
+    /**
15
+     * A component helper for generating a input name.
16
+     *
17
+     * @param $text
18
+     * @param $multiple bool If the name is set to be multiple but no brackets found then we add some.
19
+     *
20
+     * @return string
21
+     */
22
+    public static function name( $text, $multiple = false ) {
23
+        $output = '';
24
+
25
+        if ( $text ) {
26
+            $is_multiple = strpos( $text, '[' ) === false && $multiple ? '[]' : '';
27
+            $output      = ' name="' . esc_attr( $text ) . $is_multiple . '" ';
28
+        }
29
+
30
+        return $output;
31
+    }
32
+
33
+    /**
34
+     * A component helper for generating a item id.
35
+     *
36
+     * @param $text string The text to be used as the value.
37
+     *
38
+     * @return string The sanitized item.
39
+     */
40
+    public static function id( $text ) {
41
+        $output = '';
42
+
43
+        if ( $text ) {
44
+            $output = ' id="' . sanitize_html_class( $text ) . '" ';
45
+        }
46
+
47
+        return $output;
48
+    }
49
+
50
+    /**
51
+     * A component helper for generating a item title.
52
+     *
53
+     * @param $text string The text to be used as the value.
54
+     *
55
+     * @return string The sanitized item.
56
+     */
57
+    public static function title( $text ) {
58
+        $output = '';
59
+
60
+        if ( $text ) {
61
+            $output = ' title="' . esc_attr( $text ) . '" ';
62
+        }
63
+
64
+        return $output;
65
+    }
66
+
67
+    /**
68
+     * A component helper for generating a item value.
69
+     *
70
+     * @param $text string The text to be used as the value.
71
+     *
72
+     * @return string The sanitized item.
73
+     */
74
+    public static function value( $text ) {
75
+        $output = '';
76
+
77
+        if ( $text !== null && $text !== false ) {
78
+            $output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" ';
79
+        }
80
+
81
+        return $output;
82
+    }
83
+
84
+    /**
85
+     * A component helper for generating a item class attribute.
86
+     *
87
+     * @param $text string The text to be used as the value.
88
+     *
89
+     * @return string The sanitized item.
90
+     */
91
+    public static function class_attr( $text ) {
92
+        $output = '';
93
+
94
+        if ( $text ) {
95
+            $classes = self::esc_classes( $text );
96
+            if ( ! empty( $classes ) ) {
97
+                $output = ' class="' . $classes . '" ';
98
+            }
99
+        }
100
+
101
+        return $output;
102
+    }
103
+
104
+    /**
105
+     * Escape a string of classes.
106
+     *
107
+     * @param $text
108
+     *
109
+     * @return string
110
+     */
111
+    public static function esc_classes( $text ) {
112
+        $output = '';
113
+
114
+        if ( $text ) {
115
+            $classes = explode( " ", $text );
116
+            $classes = array_map( "trim", $classes );
117
+            $classes = array_map( "sanitize_html_class", $classes );
118
+            if ( ! empty( $classes ) ) {
119
+                $output = implode( " ", $classes );
120
+            }
121
+        }
122
+
123
+        return $output;
124
+
125
+    }
126
+
127
+    /**
128
+     * @param $args
129
+     *
130
+     * @return string
131
+     */
132
+    public static function data_attributes( $args ) {
133
+        $output = '';
134
+
135
+        if ( ! empty( $args ) ) {
136
+
137
+            foreach ( $args as $key => $val ) {
138
+                if ( substr( $key, 0, 5 ) === "data-" ) {
139
+                    $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
140
+                }
141
+            }
142
+        }
143
+
144
+        return $output;
145
+    }
146
+
147
+    /**
148
+     * @param $args
149
+     *
150
+     * @return string
151
+     */
152
+    public static function aria_attributes( $args ) {
153
+        $output = '';
154
+
155
+        if ( ! empty( $args ) ) {
156
+
157
+            foreach ( $args as $key => $val ) {
158
+                if ( substr( $key, 0, 5 ) === "aria-" ) {
159
+                    $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
160
+                }
161
+            }
162
+        }
163
+
164
+        return $output;
165
+    }
166
+
167
+    /**
168
+     * Build a font awesome icon from a class.
169
+     *
170
+     * @param $class
171
+     * @param bool $space_after
172
+     * @param array $extra_attributes An array of extra attributes.
173
+     *
174
+     * @return string
175
+     */
176
+    public static function icon( $class, $space_after = false, $extra_attributes = array() ) {
177
+        $output = '';
178
+
179
+        if ( $class ) {
180
+            $classes = self::esc_classes( $class );
181
+            if ( ! empty( $classes ) ) {
182
+                $output = '<i class="' . $classes . '" ';
183
+                // extra attributes
184
+                if ( ! empty( $extra_attributes ) ) {
185
+                    $output .= AUI_Component_Helper::extra_attributes( $extra_attributes );
186
+                }
187
+                $output .= '></i>';
188
+                if ( $space_after ) {
189
+                    $output .= " ";
190
+                }
191
+            }
192
+        }
193
+
194
+        return $output;
195
+    }
196
+
197
+    /**
198
+     * @param $args
199
+     *
200
+     * @return string
201
+     */
202
+    public static function extra_attributes( $args ) {
203
+        $output = '';
204
+
205
+        if ( ! empty( $args ) ) {
206
+
207
+            if ( is_array( $args ) ) {
208
+                foreach ( $args as $key => $val ) {
209
+                    $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
210
+                }
211
+            } else {
212
+                $output .= ' ' . $args . ' ';
213
+            }
214
+
215
+        }
216
+
217
+        return $output;
218
+    }
219
+
220
+    /**
221
+     * @param $args
222
+     *
223
+     * @return string
224
+     */
225
+    public static function help_text( $text ) {
226
+        $output = '';
227
+
228
+        if ( $text ) {
229
+            $output .= '<small class="form-text text-muted d-block">' . wp_kses_post( $text ) . '</small>';
230
+        }
231
+
232
+
233
+        return $output;
234
+    }
235
+
236
+    /**
237
+     * Replace element require context with JS.
238
+     *
239
+     * @param $input
240
+     *
241
+     * @return string|void
242
+     */
243
+    public static function element_require( $input ) {
244
+
245
+        $input = str_replace( "'", '"', $input );// we only want double quotes
246
+
247
+        $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
248
+            "jQuery(form).find('[data-argument=\"",
249
+            "\"]').find('input,select,textarea').val()",
250
+            "\"]').find('input:checked').val()",
251
+        ), $input ) );
252
+
253
+        if ( $output ) {
254
+            $output = ' data-element-require="' . $output . '" ';
255
+        }
256
+
257
+        return $output;
258
+    }
259
+
260
+    /**
261
+     * Navigates through an array, object, or scalar, and removes slashes from the values.
262
+     *
263
+     * @since 0.1.41
264
+     *
265
+     * @param mixed $value The value to be stripped.
266
+     * @param array $input Input Field.
267
+     *
268
+     * @return mixed Stripped value.
269
+     */
270
+    public static function sanitize_html_field( $value, $input = array() ) {
271
+        $original = $value;
272
+
273
+        if ( is_array( $value ) ) {
274
+            foreach ( $value as $index => $item ) {
275
+                $value[ $index ] = self::_sanitize_html_field( $value, $input );
276
+            }
277
+        } elseif ( is_object( $value ) ) {
278
+            $object_vars = get_object_vars( $value );
279
+
280
+            foreach ( $object_vars as $property_name => $property_value ) {
281
+                $value->$property_name = self::_sanitize_html_field( $property_value, $input );
282
+            }
283
+        } else {
284
+            $value = self::_sanitize_html_field( $value, $input );
285
+        }
286
+
287
+        /**
288
+         * Filters content and keeps only allowable HTML elements.
289
+         *
290
+         * @since 0.1.41
291
+         *
292
+         * @param string|array $value Content to filter through kses.
293
+         * @param string|array $value Original content without filter.
294
+         * @param array $input Input Field.
295
+         */
296
+        return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input );
297
+    }
298
+
299
+    /**
300
+     * Filters content and keeps only allowable HTML elements.
301
+     *
302
+     * This function makes sure that only the allowed HTML element names, attribute
303
+     * names and attribute values plus only sane HTML entities will occur in
304
+     * $string. You have to remove any slashes from PHP's magic quotes before you
305
+     * call this function.
306
+     *
307
+     * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
308
+     * 'irc', 'gopher', 'nntp', 'feed', 'telnet, 'mms', 'rtsp' and 'svn'. This
309
+     * covers all common link protocols, except for 'javascript' which should not
310
+     * be allowed for untrusted users.
311
+     *
312
+     * @since 0.1.41
313
+     *
314
+     * @param string|array $value Content to filter through kses.
315
+     * @param array $input Input Field.
316
+     *
317
+     * @return string Filtered content with only allowed HTML elements.
318
+     */
319
+    public static function _sanitize_html_field( $value, $input = array() ) {
320
+        if ( $value === '' ) {
321
+            return $value;
322
+        }
323
+
324
+        $allowed_html = self::kses_allowed_html( 'post', $input );
325
+
326
+        if ( ! is_array( $allowed_html ) ) {
327
+            $allowed_html = wp_kses_allowed_html( 'post' );
328
+        }
329
+
330
+        $filtered = trim( wp_unslash( $value ) );
331
+        $filtered = wp_kses( $filtered, $allowed_html );
332
+        $filtered = balanceTags( $filtered ); // Balances tags
333
+
334
+        return $filtered;
335
+    }
336
+
337
+    /**
338
+     * Returns an array of allowed HTML tags and attributes for a given context.
339
+     *
340
+     * @since 0.1.41
341
+     *
342
+     * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
343
+     *                              'strip', 'data', 'entities', or the name of a field filter such as
344
+     *                              'pre_user_description'.
345
+     * @param array $input Input.
346
+     *
347
+     * @return array Array of allowed HTML tags and their allowed attributes.
348
+     */
349
+    public static function kses_allowed_html( $context = 'post', $input = array() ) {
350
+        $allowed_html = wp_kses_allowed_html( $context );
351
+
352
+        if ( is_array( $allowed_html ) ) {
353
+            // <iframe>
354
+            if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) {
355
+                $allowed_html['iframe'] = array(
356
+                    'class'           => true,
357
+                    'id'              => true,
358
+                    'src'             => true,
359
+                    'width'           => true,
360
+                    'height'          => true,
361
+                    'frameborder'     => true,
362
+                    'marginwidth'     => true,
363
+                    'marginheight'    => true,
364
+                    'scrolling'       => true,
365
+                    'style'           => true,
366
+                    'title'           => true,
367
+                    'allow'           => true,
368
+                    'allowfullscreen' => true,
369
+                    'data-*'          => true,
370
+                );
371
+            }
372
+        }
373
+
374
+        /**
375
+         * Filters the allowed html tags.
376
+         *
377
+         * @since 0.1.41
378
+         *
379
+         * @param array[]|string $allowed_html Allowed html tags.
380
+         * @param @param string|array $context The context for which to retrieve tags.
381
+         * @param array $input Input field.
382
+         */
383
+        return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input );
384
+    }
385
+
386
+    public static function get_column_class( $label_number = 2, $type = 'label' ) {
387
+
388
+        $class = '';
389
+
390
+        // set default if empty
391
+        if( $label_number === '' ){
392
+            $label_number = 2;
393
+        }
394
+
395
+        if ( $label_number && $label_number < 12 && $label_number > 0 ) {
396
+            if ( $type == 'label' ) {
397
+                $class = 'col-sm-' . absint( $label_number );
398
+            } elseif ( $type == 'input' ) {
399
+                $class = 'col-sm-' . ( 12 - absint( $label_number ) );
400
+            }
401
+        }
402
+
403
+        return $class;
404
+    }
405
+
406
+    /**
407
+     * Sanitizes a multiline string from user input or from the database.
408
+     *
409
+     * Emulate the WP native sanitize_textarea_field function in a %%variable%% safe way.
410
+     *
411
+     * @see   https://core.trac.wordpress.org/browser/trunk/src/wp-includes/formatting.php for the original
412
+     *
413
+     * @since 0.1.66
414
+     *
415
+     * @param string $str String to sanitize.
416
+     * @return string Sanitized string.
417
+     */
418
+    public static function sanitize_textarea_field( $str ) {
419
+        $filtered = self::_sanitize_text_fields( $str, true );
420
+
421
+        /**
422
+         * Filters a sanitized textarea field string.
423
+         *
424
+         * @see https://core.trac.wordpress.org/browser/trunk/src/wp-includes/formatting.php
425
+         *
426
+         * @param string $filtered The sanitized string.
427
+         * @param string $str      The string prior to being sanitized.
428
+         */
429
+        return apply_filters( 'sanitize_textarea_field', $filtered, $str );
430
+    }
431
+
432
+    /**
433
+     * Internal helper function to sanitize a string from user input or from the db.
434
+     *
435
+     * @since 0.1.66
436
+     * @access private
437
+     *
438
+     * @param string $str           String to sanitize.
439
+     * @param bool   $keep_newlines Optional. Whether to keep newlines. Default: false.
440
+     * @return string Sanitized string.
441
+     */
442
+    public static function _sanitize_text_fields( $str, $keep_newlines = false ) {
443
+        if ( is_object( $str ) || is_array( $str ) ) {
444
+            return '';
445
+        }
446
+
447
+        $str = (string) $str;
448
+
449
+        $filtered = wp_check_invalid_utf8( $str );
450
+
451
+        if ( strpos( $filtered, '<' ) !== false ) {
452
+            $filtered = wp_pre_kses_less_than( $filtered );
453
+            // This will strip extra whitespace for us.
454
+            $filtered = wp_strip_all_tags( $filtered, false );
455
+
456
+            // Use HTML entities in a special case to make sure no later
457
+            // newline stripping stage could lead to a functional tag.
458
+            $filtered = str_replace( "<\n", "&lt;\n", $filtered );
459
+        }
460
+
461
+        if ( ! $keep_newlines ) {
462
+            $filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
463
+        }
464
+        $filtered = trim( $filtered );
465
+
466
+        $found = false;
467
+        while ( preg_match( '`[^%](%[a-f0-9]{2})`i', $filtered, $match ) ) {
468
+            $filtered = str_replace( $match[1], '', $filtered );
469
+            $found = true;
470
+        }
471
+        unset( $match );
472
+
473
+        if ( $found ) {
474
+            // Strip out the whitespace that may now exist after removing the octets.
475
+            $filtered = trim( preg_replace( '` +`', ' ', $filtered ) );
476
+        }
477
+
478
+        return $filtered;
479
+    }
480 480
 }
481 481
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/example-plugin.php 1 patch
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -16,222 +16,222 @@
 block discarded – undo
16 16
 
17 17
 // If this file is called directly, abort.
18 18
 if ( ! defined( 'WPINC' ) ) {
19
-	die;
19
+    die;
20 20
 }
21 21
 
22 22
 class AyeCode_UI_Plugin {
23 23
 
24
-	/**
25
-	 * AUI Plugin constructor.
26
-	 *
27
-	 * @since 1.0.0
28
-	 */
29
-	public function __construct() {
30
-
31
-		// load AUI
32
-		require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' );
33
-
34
-		// Maybe show example page
35
-		add_action( 'template_redirect', array( $this,'maybe_show_examples' ) );
36
-	}
37
-
38
-	public function maybe_show_examples(){
39
-		if ( current_user_can( 'manage_options' ) && isset( $_REQUEST['preview-aui'] ) ) {
40
-			echo "<head>";
41
-			wp_head();
42
-			echo "</head>";
43
-			echo "<body class='bsui'>";
44
-			echo $this->get_examples();
45
-			wp_footer();
46
-			echo "</body>";
47
-			exit;
48
-		}
49
-	}
50
-
51
-	public function get_examples(){
52
-		$output = '';
53
-
54
-		// open form
55
-		$output .= "<form class='p-5 m-5 border rounded bg-white'>";
56
-
57
-		$output .= aui()->input(
58
-			array(
59
-				'type'             => 'datepicker',
60
-				'id'               => 'date_example_sm',
61
-				'size'             => 'sm',
62
-				'name'             => 'date_example_sm',
63
-				'label'            => 'Date Input Label (small)',
64
-				'help_text'        => 'help text',
65
-				'label_type'       => 'top',
66
-				'placeholder'      => 'YYYY-MM-DD 00:00',
67
-				'value'            => '',
68
-				'extra_attributes' => array(
69
-					'data-enable-time' => 'true',
70
-					'data-time_24hr'   => 'true',
71
-					'data-allow-input' => 'true',
72
-				),
73
-			)
74
-		);
75
-
76
-		$output .= aui()->input(
77
-			array(
78
-				'type'             => 'datepicker',
79
-				'id'               => 'date_example',
80
-				//'size'             => 'smx',
81
-				'name'             => 'date_example',
82
-				'label'            => 'Date Input Label',
83
-				'help_text'        => 'help text',
84
-				'label_type'       => 'top',
85
-				'placeholder'      => 'YYYY-MM-DD 00:00',
86
-				'value'            => '',
87
-				'extra_attributes' => array(
88
-					'data-enable-time' => 'true',
89
-					'data-time_24hr'   => 'true',
90
-					'data-allow-input' => 'true',
91
-				),
92
-			)
93
-		);
94
-
95
-		$output .= aui()->input(
96
-			array(
97
-				'type'             => 'datepicker',
98
-				'id'               => 'date_example_lg',
99
-				'size'             => 'lg',
100
-				'name'             => 'date_example_lg',
101
-				'label'            => 'Date Input Label (large)',
102
-				'help_text'        => 'help text',
103
-				'label_type'       => 'top',
104
-				'placeholder'      => 'YYYY-MM-DD 00:00',
105
-				'value'            => '',
106
-				'extra_attributes' => array(
107
-					'data-enable-time' => 'true',
108
-					'data-time_24hr'   => 'true',
109
-					//'data-allow-input' => 'true',
110
-				),
111
-			)
112
-		);
113
-
114
-		// input example
115
-		$output .= aui()->input(
116
-			array(
117
-				'type'  =>  'text',
118
-				'id'    =>  'text-example',
119
-				'size'             => 'sm',
120
-				//'clear_icon'    => true,
121
-				'name'    =>  'text-example',
122
-				'placeholder'   => 'text placeholder',
123
-				'title'   => 'Text input example',
124
-				'value' =>  '',
125
-				'required'  => false,
126
-				'help_text' => 'help text',
127
-				'label' => 'Text input example label',
128
-				'label_type' => 'top'
129
-			)
130
-		);
131
-
132
-		$output .= aui()->input(
133
-			array(
134
-				'type'  =>  'search',
135
-				'id'    =>  'text-example',
136
-				'size'             => 'sm',
137
-				//'clear_icon'    => true,
138
-				'name'    =>  'text-example',
139
-				'placeholder'   => 'text placeholder',
140
-				'title'   => 'Text input example',
141
-				'value' =>  '',
142
-				'required'  => false,
143
-				'help_text' => 'help text',
144
-				'label' => 'Text input example label',
145
-				'label_type' => 'top'
146
-			)
147
-		);
148
-
149
-		// input example
150
-		$output .= aui()->input(
151
-			array(
152
-				'type'  =>  'url',
153
-				'id'    =>  'text-example2',
154
-				'name'    =>  'text-example',
155
-				'placeholder'   => 'url placeholder',
156
-				'title'   => 'Text input example',
157
-				'value' =>  '',
158
-				'required'  => false,
159
-				'help_text' => 'help text',
160
-				'label' => 'Text input example label'
161
-			)
162
-		);
163
-
164
-		// checkbox example
165
-		$output .= aui()->input(
166
-			array(
167
-				'type'  =>  'checkbox',
168
-				'id'    =>  'checkbox-example',
169
-				'name'    =>  'checkbox-example',
170
-				'placeholder'   => 'checkbox-example',
171
-				'title'   => 'Checkbox example',
172
-				'value' =>  '1',
173
-				'checked'   => true,
174
-				'required'  => false,
175
-				'help_text' => 'help text',
176
-				'label' => 'Checkbox checked'
177
-			)
178
-		);
179
-
180
-		// checkbox example
181
-		$output .= aui()->input(
182
-			array(
183
-				'type'  =>  'checkbox',
184
-				'id'    =>  'checkbox-example2',
185
-				'name'    =>  'checkbox-example2',
186
-				'placeholder'   => 'checkbox-example',
187
-				'title'   => 'Checkbox example',
188
-				'value' =>  '1',
189
-				'checked'   => false,
190
-				'required'  => false,
191
-				'help_text' => 'help text',
192
-				'label' => 'Checkbox un-checked'
193
-			)
194
-		);
195
-
196
-		// switch example
197
-		$output .= aui()->input(
198
-			array(
199
-				'type'  =>  'checkbox',
200
-				'id'    =>  'switch-example',
201
-				'name'    =>  'switch-example',
202
-				'placeholder'   => 'checkbox-example',
203
-				'title'   => 'Switch example',
204
-				'value' =>  '1',
205
-				'checked'   => true,
206
-				'switch'    => true,
207
-				'required'  => false,
208
-				'help_text' => 'help text',
209
-				'label' => 'Switch on'
210
-			)
211
-		);
212
-
213
-		// switch example
214
-		$output .= aui()->input(
215
-			array(
216
-				'type'  =>  'checkbox',
217
-				'id'    =>  'switch-example2',
218
-				'name'    =>  'switch-example2',
219
-				'placeholder'   => 'checkbox-example',
220
-				'title'   => 'Switch example',
221
-				'value' =>  '1',
222
-				'checked'   => false,
223
-				'switch'    => true,
224
-				'required'  => false,
225
-				'help_text' => 'help text',
226
-				'label' => 'Switch off'
227
-			)
228
-		);
229
-
230
-		// close form
231
-		$output .= "</form>";
232
-
233
-		return $output;
234
-	}
24
+    /**
25
+     * AUI Plugin constructor.
26
+     *
27
+     * @since 1.0.0
28
+     */
29
+    public function __construct() {
30
+
31
+        // load AUI
32
+        require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' );
33
+
34
+        // Maybe show example page
35
+        add_action( 'template_redirect', array( $this,'maybe_show_examples' ) );
36
+    }
37
+
38
+    public function maybe_show_examples(){
39
+        if ( current_user_can( 'manage_options' ) && isset( $_REQUEST['preview-aui'] ) ) {
40
+            echo "<head>";
41
+            wp_head();
42
+            echo "</head>";
43
+            echo "<body class='bsui'>";
44
+            echo $this->get_examples();
45
+            wp_footer();
46
+            echo "</body>";
47
+            exit;
48
+        }
49
+    }
50
+
51
+    public function get_examples(){
52
+        $output = '';
53
+
54
+        // open form
55
+        $output .= "<form class='p-5 m-5 border rounded bg-white'>";
56
+
57
+        $output .= aui()->input(
58
+            array(
59
+                'type'             => 'datepicker',
60
+                'id'               => 'date_example_sm',
61
+                'size'             => 'sm',
62
+                'name'             => 'date_example_sm',
63
+                'label'            => 'Date Input Label (small)',
64
+                'help_text'        => 'help text',
65
+                'label_type'       => 'top',
66
+                'placeholder'      => 'YYYY-MM-DD 00:00',
67
+                'value'            => '',
68
+                'extra_attributes' => array(
69
+                    'data-enable-time' => 'true',
70
+                    'data-time_24hr'   => 'true',
71
+                    'data-allow-input' => 'true',
72
+                ),
73
+            )
74
+        );
75
+
76
+        $output .= aui()->input(
77
+            array(
78
+                'type'             => 'datepicker',
79
+                'id'               => 'date_example',
80
+                //'size'             => 'smx',
81
+                'name'             => 'date_example',
82
+                'label'            => 'Date Input Label',
83
+                'help_text'        => 'help text',
84
+                'label_type'       => 'top',
85
+                'placeholder'      => 'YYYY-MM-DD 00:00',
86
+                'value'            => '',
87
+                'extra_attributes' => array(
88
+                    'data-enable-time' => 'true',
89
+                    'data-time_24hr'   => 'true',
90
+                    'data-allow-input' => 'true',
91
+                ),
92
+            )
93
+        );
94
+
95
+        $output .= aui()->input(
96
+            array(
97
+                'type'             => 'datepicker',
98
+                'id'               => 'date_example_lg',
99
+                'size'             => 'lg',
100
+                'name'             => 'date_example_lg',
101
+                'label'            => 'Date Input Label (large)',
102
+                'help_text'        => 'help text',
103
+                'label_type'       => 'top',
104
+                'placeholder'      => 'YYYY-MM-DD 00:00',
105
+                'value'            => '',
106
+                'extra_attributes' => array(
107
+                    'data-enable-time' => 'true',
108
+                    'data-time_24hr'   => 'true',
109
+                    //'data-allow-input' => 'true',
110
+                ),
111
+            )
112
+        );
113
+
114
+        // input example
115
+        $output .= aui()->input(
116
+            array(
117
+                'type'  =>  'text',
118
+                'id'    =>  'text-example',
119
+                'size'             => 'sm',
120
+                //'clear_icon'    => true,
121
+                'name'    =>  'text-example',
122
+                'placeholder'   => 'text placeholder',
123
+                'title'   => 'Text input example',
124
+                'value' =>  '',
125
+                'required'  => false,
126
+                'help_text' => 'help text',
127
+                'label' => 'Text input example label',
128
+                'label_type' => 'top'
129
+            )
130
+        );
131
+
132
+        $output .= aui()->input(
133
+            array(
134
+                'type'  =>  'search',
135
+                'id'    =>  'text-example',
136
+                'size'             => 'sm',
137
+                //'clear_icon'    => true,
138
+                'name'    =>  'text-example',
139
+                'placeholder'   => 'text placeholder',
140
+                'title'   => 'Text input example',
141
+                'value' =>  '',
142
+                'required'  => false,
143
+                'help_text' => 'help text',
144
+                'label' => 'Text input example label',
145
+                'label_type' => 'top'
146
+            )
147
+        );
148
+
149
+        // input example
150
+        $output .= aui()->input(
151
+            array(
152
+                'type'  =>  'url',
153
+                'id'    =>  'text-example2',
154
+                'name'    =>  'text-example',
155
+                'placeholder'   => 'url placeholder',
156
+                'title'   => 'Text input example',
157
+                'value' =>  '',
158
+                'required'  => false,
159
+                'help_text' => 'help text',
160
+                'label' => 'Text input example label'
161
+            )
162
+        );
163
+
164
+        // checkbox example
165
+        $output .= aui()->input(
166
+            array(
167
+                'type'  =>  'checkbox',
168
+                'id'    =>  'checkbox-example',
169
+                'name'    =>  'checkbox-example',
170
+                'placeholder'   => 'checkbox-example',
171
+                'title'   => 'Checkbox example',
172
+                'value' =>  '1',
173
+                'checked'   => true,
174
+                'required'  => false,
175
+                'help_text' => 'help text',
176
+                'label' => 'Checkbox checked'
177
+            )
178
+        );
179
+
180
+        // checkbox example
181
+        $output .= aui()->input(
182
+            array(
183
+                'type'  =>  'checkbox',
184
+                'id'    =>  'checkbox-example2',
185
+                'name'    =>  'checkbox-example2',
186
+                'placeholder'   => 'checkbox-example',
187
+                'title'   => 'Checkbox example',
188
+                'value' =>  '1',
189
+                'checked'   => false,
190
+                'required'  => false,
191
+                'help_text' => 'help text',
192
+                'label' => 'Checkbox un-checked'
193
+            )
194
+        );
195
+
196
+        // switch example
197
+        $output .= aui()->input(
198
+            array(
199
+                'type'  =>  'checkbox',
200
+                'id'    =>  'switch-example',
201
+                'name'    =>  'switch-example',
202
+                'placeholder'   => 'checkbox-example',
203
+                'title'   => 'Switch example',
204
+                'value' =>  '1',
205
+                'checked'   => true,
206
+                'switch'    => true,
207
+                'required'  => false,
208
+                'help_text' => 'help text',
209
+                'label' => 'Switch on'
210
+            )
211
+        );
212
+
213
+        // switch example
214
+        $output .= aui()->input(
215
+            array(
216
+                'type'  =>  'checkbox',
217
+                'id'    =>  'switch-example2',
218
+                'name'    =>  'switch-example2',
219
+                'placeholder'   => 'checkbox-example',
220
+                'title'   => 'Switch example',
221
+                'value' =>  '1',
222
+                'checked'   => false,
223
+                'switch'    => true,
224
+                'required'  => false,
225
+                'help_text' => 'help text',
226
+                'label' => 'Switch off'
227
+            )
228
+        );
229
+
230
+        // close form
231
+        $output .= "</form>";
232
+
233
+        return $output;
234
+    }
235 235
 }
236 236
 
237 237
 new AyeCode_UI_Plugin();
238 238
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/inc/bs4-js.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -993,8 +993,8 @@
 block discarded – undo
993 993
     aui_flip_color_scheme_on_scroll();
994 994
 
995 995
 	<?php
996
-	// FSE tweaks.
997
-	if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?>
996
+    // FSE tweaks.
997
+    if(!empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template'){ ?>
998 998
     function aui_fse_set_data_scroll() {
999 999
         console.log('init scroll');
1000 1000
         let Iframe = document.getElementsByClassName("edit-site-visual-editor__editor-canvas");
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 1 patch
Indentation   +791 added lines, -791 removed lines patch added patch discarded remove patch
@@ -13,741 +13,741 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( wpinv_get_default_payment_form() === $post->ID ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] = sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID,
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-			$actions['reset'] = sprintf(
131
-				'<a href="%1$s" style="color: #800">%2$s</a>',
132
-				esc_url(
133
-					wp_nonce_url(
134
-						add_query_arg(
135
-							array(
136
-								'getpaid-admin-action' => 'reset_form_stats',
137
-								'form_id'              => $post->ID,
138
-							)
139
-						),
140
-						'getpaid-nonce',
141
-						'getpaid-nonce'
142
-					)
143
-				),
144
-				esc_html( __( 'Reset Stats', 'invoicing' ) )
145
-			);
146
-		}
147
-
148
-		// Link to item payment form.
149
-		if ( 'wpi_item' == $post->post_type ) {
150
-
151
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ), true ) ) {
152
-
153
-				$actions['buy'] = sprintf(
154
-					'<a href="%1$s">%2$s</a>',
155
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
156
-					esc_html( __( 'Buy', 'invoicing' ) )
157
-				);
158
-
159
-			}
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0  => '',
68
+            1  => __( 'Discount updated.', 'invoicing' ),
69
+            2  => __( 'Custom field updated.', 'invoicing' ),
70
+            3  => __( 'Custom field deleted.', 'invoicing' ),
71
+            4  => __( 'Discount updated.', 'invoicing' ),
72
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6  => __( 'Discount updated.', 'invoicing' ),
74
+            7  => __( 'Discount saved.', 'invoicing' ),
75
+            8  => __( 'Discount submitted.', 'invoicing' ),
76
+            9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10 => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0  => '',
82
+            1  => __( 'Payment Form updated.', 'invoicing' ),
83
+            2  => __( 'Custom field updated.', 'invoicing' ),
84
+            3  => __( 'Custom field deleted.', 'invoicing' ),
85
+            4  => __( 'Payment Form updated.', 'invoicing' ),
86
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6  => __( 'Payment Form updated.', 'invoicing' ),
88
+            7  => __( 'Payment Form saved.', 'invoicing' ),
89
+            8  => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( wpinv_get_default_payment_form() === $post->ID ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] = sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID,
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+            $actions['reset'] = sprintf(
131
+                '<a href="%1$s" style="color: #800">%2$s</a>',
132
+                esc_url(
133
+                    wp_nonce_url(
134
+                        add_query_arg(
135
+                            array(
136
+                                'getpaid-admin-action' => 'reset_form_stats',
137
+                                'form_id'              => $post->ID,
138
+                            )
139
+                        ),
140
+                        'getpaid-nonce',
141
+                        'getpaid-nonce'
142
+                    )
143
+                ),
144
+                esc_html( __( 'Reset Stats', 'invoicing' ) )
145
+            );
146
+        }
147
+
148
+        // Link to item payment form.
149
+        if ( 'wpi_item' == $post->post_type ) {
150
+
151
+            if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ), true ) ) {
152
+
153
+                $actions['buy'] = sprintf(
154
+                    '<a href="%1$s">%2$s</a>',
155
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
156
+                    esc_html( __( 'Buy', 'invoicing' ) )
157
+                );
158
+
159
+            }
160 160
 }
161 161
 
162
-		return $actions;
163
-	}
162
+        return $actions;
163
+    }
164 164
 
165
-	/**
165
+    /**
166 166
      * Remove bulk edit option from admin side quote listing
167 167
      *
168 168
      * @since    1.0.0
169 169
      * @param array $actions post actions
170
-	 * @param WP_Post $post
170
+     * @param WP_Post $post
171 171
      * @return array $actions actions without edit option
172 172
      */
173 173
     public static function filter_invoice_row_actions( $actions, $post ) {
174 174
 
175 175
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
176 176
 
177
-			$actions = array();
178
-			$invoice = new WPInv_Invoice( $post );
179
-
180
-			$actions['edit'] = sprintf(
181
-				'<a href="%1$s">%2$s</a>',
182
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
183
-				esc_html( __( 'Edit', 'invoicing' ) )
184
-			);
185
-
186
-			if ( ! $invoice->is_draft() ) {
187
-
188
-				$actions['view'] = sprintf(
189
-					'<a href="%1$s">%2$s</a>',
190
-					esc_url( $invoice->get_view_url() ),
191
-					sprintf(
192
-						// translators: %s is the invoice type
193
-						esc_html__( 'View %s', 'invoicing' ),
194
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
195
-					)
196
-				);
197
-
198
-				$actions['send'] = sprintf(
199
-					'<a href="%1$s">%2$s</a>',
200
-					esc_url(
201
-						wp_nonce_url(
202
-							add_query_arg(
203
-								array(
204
-									'getpaid-admin-action' => 'send_invoice',
205
-									'invoice_id'           => $invoice->get_id(),
206
-								)
207
-							),
208
-							'getpaid-nonce',
209
-							'getpaid-nonce'
210
-						)
211
-					),
212
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
213
-				);
214
-
215
-			}
216
-
217
-			$actions['duplicate'] = sprintf(
218
-				'<a href="%1$s">%2$s</a>',
219
-				esc_url(
220
-					wp_nonce_url(
221
-						add_query_arg(
222
-							array(
223
-								'getpaid-admin-action' => 'duplicate_invoice',
224
-								'invoice_id'           => $post->ID,
225
-							)
226
-						),
227
-						'getpaid-nonce',
228
-						'getpaid-nonce'
229
-					)
230
-				),
231
-				esc_html( __( 'Duplicate', 'invoicing' ) )
232
-			);
177
+            $actions = array();
178
+            $invoice = new WPInv_Invoice( $post );
179
+
180
+            $actions['edit'] = sprintf(
181
+                '<a href="%1$s">%2$s</a>',
182
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
183
+                esc_html( __( 'Edit', 'invoicing' ) )
184
+            );
185
+
186
+            if ( ! $invoice->is_draft() ) {
187
+
188
+                $actions['view'] = sprintf(
189
+                    '<a href="%1$s">%2$s</a>',
190
+                    esc_url( $invoice->get_view_url() ),
191
+                    sprintf(
192
+                        // translators: %s is the invoice type
193
+                        esc_html__( 'View %s', 'invoicing' ),
194
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
195
+                    )
196
+                );
197
+
198
+                $actions['send'] = sprintf(
199
+                    '<a href="%1$s">%2$s</a>',
200
+                    esc_url(
201
+                        wp_nonce_url(
202
+                            add_query_arg(
203
+                                array(
204
+                                    'getpaid-admin-action' => 'send_invoice',
205
+                                    'invoice_id'           => $invoice->get_id(),
206
+                                )
207
+                            ),
208
+                            'getpaid-nonce',
209
+                            'getpaid-nonce'
210
+                        )
211
+                    ),
212
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
213
+                );
214
+
215
+            }
216
+
217
+            $actions['duplicate'] = sprintf(
218
+                '<a href="%1$s">%2$s</a>',
219
+                esc_url(
220
+                    wp_nonce_url(
221
+                        add_query_arg(
222
+                            array(
223
+                                'getpaid-admin-action' => 'duplicate_invoice',
224
+                                'invoice_id'           => $post->ID,
225
+                            )
226
+                        ),
227
+                        'getpaid-nonce',
228
+                        'getpaid-nonce'
229
+                    )
230
+                ),
231
+                esc_html( __( 'Duplicate', 'invoicing' ) )
232
+            );
233 233
 
234 234
         }
235 235
 
236 236
         return $actions;
237
-	}
238
-
239
-	/**
240
-	 * Returns an array of invoice table columns.
241
-	 */
242
-	public static function invoice_columns( $columns ) {
243
-
244
-		$columns = array(
245
-			'cb'           => $columns['cb'],
246
-			'number'       => __( 'Invoice', 'invoicing' ),
247
-			'customer'     => __( 'Customer', 'invoicing' ),
248
-			'invoice_date' => __( 'Created', 'invoicing' ),
249
-			'payment_date' => __( 'Completed', 'invoicing' ),
250
-			'amount'       => __( 'Amount', 'invoicing' ),
251
-			'recurring'    => __( 'Recurring', 'invoicing' ),
252
-			'status'       => __( 'Status', 'invoicing' ),
253
-		);
254
-
255
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
256
-	}
257
-
258
-	/**
259
-	 * Displays invoice table columns.
260
-	 */
261
-	public static function display_invoice_columns( $column_name, $post_id ) {
262
-
263
-		$invoice = new WPInv_Invoice( $post_id );
264
-
265
-		switch ( $column_name ) {
266
-
267
-			case 'invoice_date':
268
-				$date_time = esc_attr( $invoice->get_created_date() );
269
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
270
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
271
-				break;
272
-
273
-			case 'payment_date':
274
-				if ( $invoice->is_paid() ) {
275
-					$date_time = esc_attr( $invoice->get_completed_date() );
276
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
277
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
278
-				} else {
279
-					echo '&mdash;';
280
-				}
281
-
282
-				break;
283
-
284
-			case 'amount':
285
-				$amount = $invoice->get_total();
286
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
287
-
288
-				if ( $invoice->is_refunded() ) {
289
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
290
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
291
-				} else {
292
-
293
-					$discount = $invoice->get_total_discount();
294
-
295
-					if ( ! empty( $discount ) ) {
296
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
297
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
298
-					} else {
299
-						echo wp_kses_post( $formated_amount );
300
-					}
301
-				}
302
-
303
-				break;
304
-
305
-			case 'status':
306
-				$status       = esc_html( $invoice->get_status() );
307
-				$status_label = esc_html( $invoice->get_status_nicename() );
308
-
309
-				// If it is paid, show the gateway title.
310
-				if ( $invoice->is_paid() ) {
311
-					$gateway = esc_html( $invoice->get_gateway_title() );
312
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
313
-
314
-					echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
315
-				} else {
316
-					echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
317
-				}
318
-
319
-				// If it is not paid, display the overdue and view status.
320
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
321
-
322
-					// Invoice view status.
323
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
324
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
325
-					} else {
326
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
327
-					}
328
-
329
-					// Display the overview status.
330
-					if ( wpinv_get_option( 'overdue_active' ) ) {
331
-						$due_date = $invoice->get_due_date();
332
-						$fomatted = getpaid_format_date( $due_date );
333
-
334
-						if ( ! empty( $fomatted ) ) {
335
-							$date = wp_sprintf(
336
-								// translators: %s is the due date.
337
-								__( 'Due %s', 'invoicing' ),
338
-								$fomatted
339
-							);
340
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
341
-						}
342
-					}
343
-				}
344
-
345
-				break;
346
-
347
-			case 'recurring':
348
-				if ( $invoice->is_recurring() ) {
349
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
350
-				} else {
351
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
352
-				}
353
-				break;
354
-
355
-			case 'number':
356
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
357
-				$invoice_number  = esc_html( $invoice->get_number() );
358
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
359
-
360
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
361
-
362
-				do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
363
-				break;
364
-
365
-			case 'customer':
366
-				$customer_name = $invoice->get_user_full_name();
367
-
368
-				if ( empty( $customer_name ) ) {
369
-					$customer_name = $invoice->get_email();
370
-				}
371
-
372
-				if ( ! empty( $customer_name ) ) {
373
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
374
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
375
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
376
-				} else {
377
-					echo '<div>&mdash;</div>';
378
-				}
379
-
380
-				break;
381
-
382
-		}
383
-
384
-	}
385
-
386
-	/**
387
-	 * Displays invoice bulk actions.
388
-	 */
389
-	public static function invoice_bulk_actions( $actions ) {
390
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
391
-		return $actions;
392
-	}
393
-
394
-	/**
395
-	 * Processes invoice bulk actions.
396
-	 */
397
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
398
-
399
-		if ( 'resend-invoice' === $action ) {
400
-			foreach ( $post_ids as $post_id ) {
401
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
402
-			}
403
-		}
404
-
405
-		return $redirect_url;
406
-
407
-	}
408
-
409
-	/**
410
-	 * Returns an array of payment forms table columns.
411
-	 */
412
-	public static function payment_form_columns( $columns ) {
413
-
414
-		$columns = array(
415
-			'cb'        => $columns['cb'],
416
-			'title'     => __( 'Name', 'invoicing' ),
417
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
418
-			'earnings'  => __( 'Revenue', 'invoicing' ),
419
-			'refunds'   => __( 'Refunded', 'invoicing' ),
420
-			'items'     => __( 'Items', 'invoicing' ),
421
-			'date'      => __( 'Date', 'invoicing' ),
422
-		);
423
-
424
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
425
-
426
-	}
427
-
428
-	/**
429
-	 * Displays payment form table columns.
430
-	 */
431
-	public static function display_payment_form_columns( $column_name, $post_id ) {
432
-
433
-		// Retrieve the payment form.
434
-		$form = new GetPaid_Payment_Form( $post_id );
435
-
436
-		switch ( $column_name ) {
437
-
438
-			case 'earnings':
439
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
440
-				break;
441
-
442
-			case 'refunds':
443
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
444
-				break;
445
-
446
-			case 'refunds':
447
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
448
-				break;
449
-
450
-			case 'shortcode':
451
-				if ( $form->is_default() ) {
452
-					echo '&mdash;';
453
-				} else {
454
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
455
-				}
456
-
457
-				break;
237
+    }
238
+
239
+    /**
240
+     * Returns an array of invoice table columns.
241
+     */
242
+    public static function invoice_columns( $columns ) {
243
+
244
+        $columns = array(
245
+            'cb'           => $columns['cb'],
246
+            'number'       => __( 'Invoice', 'invoicing' ),
247
+            'customer'     => __( 'Customer', 'invoicing' ),
248
+            'invoice_date' => __( 'Created', 'invoicing' ),
249
+            'payment_date' => __( 'Completed', 'invoicing' ),
250
+            'amount'       => __( 'Amount', 'invoicing' ),
251
+            'recurring'    => __( 'Recurring', 'invoicing' ),
252
+            'status'       => __( 'Status', 'invoicing' ),
253
+        );
254
+
255
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
256
+    }
257
+
258
+    /**
259
+     * Displays invoice table columns.
260
+     */
261
+    public static function display_invoice_columns( $column_name, $post_id ) {
262
+
263
+        $invoice = new WPInv_Invoice( $post_id );
264
+
265
+        switch ( $column_name ) {
266
+
267
+            case 'invoice_date':
268
+                $date_time = esc_attr( $invoice->get_created_date() );
269
+                $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
270
+                echo wp_kses_post( "<span title='$date_time'>$date</span>" );
271
+                break;
272
+
273
+            case 'payment_date':
274
+                if ( $invoice->is_paid() ) {
275
+                    $date_time = esc_attr( $invoice->get_completed_date() );
276
+                    $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
277
+                    echo wp_kses_post( "<span title='$date_time'>$date</span>" );
278
+                } else {
279
+                    echo '&mdash;';
280
+                }
281
+
282
+                break;
283
+
284
+            case 'amount':
285
+                $amount = $invoice->get_total();
286
+                $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
287
+
288
+                if ( $invoice->is_refunded() ) {
289
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
290
+                    echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
291
+                } else {
292
+
293
+                    $discount = $invoice->get_total_discount();
294
+
295
+                    if ( ! empty( $discount ) ) {
296
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
297
+                        echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
298
+                    } else {
299
+                        echo wp_kses_post( $formated_amount );
300
+                    }
301
+                }
302
+
303
+                break;
304
+
305
+            case 'status':
306
+                $status       = esc_html( $invoice->get_status() );
307
+                $status_label = esc_html( $invoice->get_status_nicename() );
308
+
309
+                // If it is paid, show the gateway title.
310
+                if ( $invoice->is_paid() ) {
311
+                    $gateway = esc_html( $invoice->get_gateway_title() );
312
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
313
+
314
+                    echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
315
+                } else {
316
+                    echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
317
+                }
318
+
319
+                // If it is not paid, display the overdue and view status.
320
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
321
+
322
+                    // Invoice view status.
323
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
324
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
325
+                    } else {
326
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
327
+                    }
328
+
329
+                    // Display the overview status.
330
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
331
+                        $due_date = $invoice->get_due_date();
332
+                        $fomatted = getpaid_format_date( $due_date );
333
+
334
+                        if ( ! empty( $fomatted ) ) {
335
+                            $date = wp_sprintf(
336
+                                // translators: %s is the due date.
337
+                                __( 'Due %s', 'invoicing' ),
338
+                                $fomatted
339
+                            );
340
+                            echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
341
+                        }
342
+                    }
343
+                }
344
+
345
+                break;
346
+
347
+            case 'recurring':
348
+                if ( $invoice->is_recurring() ) {
349
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
350
+                } else {
351
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
352
+                }
353
+                break;
354
+
355
+            case 'number':
356
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
357
+                $invoice_number  = esc_html( $invoice->get_number() );
358
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
359
+
360
+                echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
361
+
362
+                do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
363
+                break;
364
+
365
+            case 'customer':
366
+                $customer_name = $invoice->get_user_full_name();
367
+
368
+                if ( empty( $customer_name ) ) {
369
+                    $customer_name = $invoice->get_email();
370
+                }
371
+
372
+                if ( ! empty( $customer_name ) ) {
373
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
374
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
375
+                    echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
376
+                } else {
377
+                    echo '<div>&mdash;</div>';
378
+                }
379
+
380
+                break;
458 381
 
459
-			case 'items':
460
-				$items = $form->get_items();
461
-
462
-				if ( $form->is_default() || empty( $items ) ) {
463
-					echo '&mdash;';
464
-					return;
465
-				}
466
-
467
-				$_items = array();
468
-
469
-				foreach ( $items as $item ) {
470
-					$url = $item->get_edit_url();
471
-
472
-					if ( empty( $url ) ) {
473
-						$_items[] = esc_html( $item->get_name() );
474
-					} else {
475
-						$_items[] = sprintf(
476
-							'<a href="%s">%s</a>',
477
-							esc_url( $url ),
478
-							esc_html( $item->get_name() )
479
-						);
480
-					}
382
+        }
383
+
384
+    }
385
+
386
+    /**
387
+     * Displays invoice bulk actions.
388
+     */
389
+    public static function invoice_bulk_actions( $actions ) {
390
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
391
+        return $actions;
392
+    }
393
+
394
+    /**
395
+     * Processes invoice bulk actions.
396
+     */
397
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
398
+
399
+        if ( 'resend-invoice' === $action ) {
400
+            foreach ( $post_ids as $post_id ) {
401
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
402
+            }
403
+        }
404
+
405
+        return $redirect_url;
406
+
407
+    }
408
+
409
+    /**
410
+     * Returns an array of payment forms table columns.
411
+     */
412
+    public static function payment_form_columns( $columns ) {
413
+
414
+        $columns = array(
415
+            'cb'        => $columns['cb'],
416
+            'title'     => __( 'Name', 'invoicing' ),
417
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
418
+            'earnings'  => __( 'Revenue', 'invoicing' ),
419
+            'refunds'   => __( 'Refunded', 'invoicing' ),
420
+            'items'     => __( 'Items', 'invoicing' ),
421
+            'date'      => __( 'Date', 'invoicing' ),
422
+        );
423
+
424
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
425
+
426
+    }
427
+
428
+    /**
429
+     * Displays payment form table columns.
430
+     */
431
+    public static function display_payment_form_columns( $column_name, $post_id ) {
432
+
433
+        // Retrieve the payment form.
434
+        $form = new GetPaid_Payment_Form( $post_id );
435
+
436
+        switch ( $column_name ) {
437
+
438
+            case 'earnings':
439
+                echo wp_kses_post( wpinv_price( $form->get_earned() ) );
440
+                break;
441
+
442
+            case 'refunds':
443
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
444
+                break;
445
+
446
+            case 'refunds':
447
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
448
+                break;
449
+
450
+            case 'shortcode':
451
+                if ( $form->is_default() ) {
452
+                    echo '&mdash;';
453
+                } else {
454
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
455
+                }
456
+
457
+                break;
458
+
459
+            case 'items':
460
+                $items = $form->get_items();
461
+
462
+                if ( $form->is_default() || empty( $items ) ) {
463
+                    echo '&mdash;';
464
+                    return;
465
+                }
466
+
467
+                $_items = array();
468
+
469
+                foreach ( $items as $item ) {
470
+                    $url = $item->get_edit_url();
471
+
472
+                    if ( empty( $url ) ) {
473
+                        $_items[] = esc_html( $item->get_name() );
474
+                    } else {
475
+                        $_items[] = sprintf(
476
+                            '<a href="%s">%s</a>',
477
+                            esc_url( $url ),
478
+                            esc_html( $item->get_name() )
479
+                        );
480
+                    }
481 481
 }
482 482
 
483
-				echo wp_kses_post( implode( '<br>', $_items ) );
483
+                echo wp_kses_post( implode( '<br>', $_items ) );
484
+
485
+                break;
486
+
487
+        }
488
+
489
+    }
490
+
491
+    /**
492
+     * Filters post states.
493
+     */
494
+    public static function filter_payment_form_state( $post_states, $post ) {
495
+
496
+        if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
497
+            $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
498
+        }
499
+
500
+        return $post_states;
501
+
502
+    }
503
+
504
+    /**
505
+     * Returns an array of coupon table columns.
506
+     */
507
+    public static function discount_columns( $columns ) {
508
+
509
+        $columns = array(
510
+            'cb'          => $columns['cb'],
511
+            'title'       => __( 'Name', 'invoicing' ),
512
+            'code'        => __( 'Code', 'invoicing' ),
513
+            'amount'      => __( 'Amount', 'invoicing' ),
514
+            'usage'       => __( 'Usage / Limit', 'invoicing' ),
515
+            'start_date'  => __( 'Start Date', 'invoicing' ),
516
+            'expiry_date' => __( 'Expiry Date', 'invoicing' ),
517
+        );
518
+
519
+        return apply_filters( 'wpi_discount_table_columns', $columns );
520
+    }
484 521
 
485
-				break;
522
+    /**
523
+     * Filters post states.
524
+     */
525
+    public static function filter_discount_state( $post_states, $post ) {
486 526
 
487
-		}
527
+        if ( 'wpi_discount' === $post->post_type ) {
488 528
 
489
-	}
529
+            $discount = new WPInv_Discount( $post );
490 530
 
491
-	/**
492
-	 * Filters post states.
493
-	 */
494
-	public static function filter_payment_form_state( $post_states, $post ) {
531
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
495 532
 
496
-		if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
497
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
498
-		}
533
+            if ( 'publish' !== $status ) {
534
+                return array(
535
+                    'discount_status' => wpinv_discount_status( $status ),
536
+                );
537
+            }
538
+
539
+            return array();
540
+
541
+        }
542
+
543
+        return $post_states;
499 544
 
500
-		return $post_states;
545
+    }
501 546
 
502
-	}
547
+    /**
548
+     * Returns an array of items table columns.
549
+     */
550
+    public static function item_columns( $columns ) {
551
+
552
+        $columns = array(
553
+            'cb'        => $columns['cb'],
554
+            'title'     => __( 'Name', 'invoicing' ),
555
+            'price'     => __( 'Price', 'invoicing' ),
556
+            'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
557
+            'vat_class' => __( 'Tax Class', 'invoicing' ),
558
+            'type'      => __( 'Type', 'invoicing' ),
559
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
560
+        );
561
+
562
+        if ( ! wpinv_use_taxes() ) {
563
+            unset( $columns['vat_rule'] );
564
+            unset( $columns['vat_class'] );
565
+        }
503 566
 
504
-	/**
505
-	 * Returns an array of coupon table columns.
506
-	 */
507
-	public static function discount_columns( $columns ) {
567
+        return apply_filters( 'wpi_item_table_columns', $columns );
568
+    }
508 569
 
509
-		$columns = array(
510
-			'cb'          => $columns['cb'],
511
-			'title'       => __( 'Name', 'invoicing' ),
512
-			'code'        => __( 'Code', 'invoicing' ),
513
-			'amount'      => __( 'Amount', 'invoicing' ),
514
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
515
-			'start_date'  => __( 'Start Date', 'invoicing' ),
516
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
517
-		);
570
+    /**
571
+     * Returns an array of sortable items table columns.
572
+     */
573
+    public static function sortable_item_columns( $columns ) {
574
+
575
+        return array_merge(
576
+            $columns,
577
+            array(
578
+                'price'     => 'price',
579
+                'vat_rule'  => 'vat_rule',
580
+                'vat_class' => 'vat_class',
581
+                'type'      => 'type',
582
+            )
583
+        );
518 584
 
519
-		return apply_filters( 'wpi_discount_table_columns', $columns );
520
-	}
585
+    }
521 586
 
522
-	/**
523
-	 * Filters post states.
524
-	 */
525
-	public static function filter_discount_state( $post_states, $post ) {
587
+    /**
588
+     * Displays items table columns.
589
+     */
590
+    public static function display_item_columns( $column_name, $post_id ) {
526 591
 
527
-		if ( 'wpi_discount' === $post->post_type ) {
592
+        $item = new WPInv_Item( $post_id );
528 593
 
529
-			$discount = new WPInv_Discount( $post );
594
+        switch ( $column_name ) {
530 595
 
531
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
596
+            case 'price':
597
+                if ( ! $item->is_recurring() ) {
598
+                    echo wp_kses_post( $item->get_the_price() );
599
+                    break;
600
+                }
532 601
 
533
-			if ( 'publish' !== $status ) {
534
-				return array(
535
-					'discount_status' => wpinv_discount_status( $status ),
536
-				);
537
-			}
602
+                $price = wp_sprintf(
603
+                    __( '%1$s / %2$s', 'invoicing' ),
604
+                    $item->get_the_price(),
605
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
606
+                );
538 607
 
539
-			return array();
608
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
609
+                    echo wp_kses_post( $price );
610
+                    break;
611
+                }
540 612
 
541
-		}
613
+                echo wp_kses_post( $item->get_the_initial_price() );
542 614
 
543
-		return $post_states;
615
+                echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
616
+                break;
544 617
 
545
-	}
618
+            case 'vat_rule':
619
+                echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
620
+                break;
546 621
 
547
-	/**
548
-	 * Returns an array of items table columns.
549
-	 */
550
-	public static function item_columns( $columns ) {
622
+            case 'vat_class':
623
+                echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
624
+                break;
551 625
 
552
-		$columns = array(
553
-			'cb'        => $columns['cb'],
554
-			'title'     => __( 'Name', 'invoicing' ),
555
-			'price'     => __( 'Price', 'invoicing' ),
556
-			'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
557
-			'vat_class' => __( 'Tax Class', 'invoicing' ),
558
-			'type'      => __( 'Type', 'invoicing' ),
559
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
560
-		);
626
+            case 'shortcode':
627
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
628
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
629
+                } else {
630
+                    echo '&mdash;';
631
+                }
561 632
 
562
-		if ( ! wpinv_use_taxes() ) {
563
-			unset( $columns['vat_rule'] );
564
-			unset( $columns['vat_class'] );
565
-		}
633
+                break;
566 634
 
567
-		return apply_filters( 'wpi_item_table_columns', $columns );
568
-	}
635
+            case 'type':
636
+                echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
637
+                break;
569 638
 
570
-	/**
571
-	 * Returns an array of sortable items table columns.
572
-	 */
573
-	public static function sortable_item_columns( $columns ) {
574
-
575
-		return array_merge(
576
-			$columns,
577
-			array(
578
-				'price'     => 'price',
579
-				'vat_rule'  => 'vat_rule',
580
-				'vat_class' => 'vat_class',
581
-				'type'      => 'type',
582
-			)
583
-		);
584
-
585
-	}
586
-
587
-	/**
588
-	 * Displays items table columns.
589
-	 */
590
-	public static function display_item_columns( $column_name, $post_id ) {
591
-
592
-		$item = new WPInv_Item( $post_id );
593
-
594
-		switch ( $column_name ) {
595
-
596
-			case 'price':
597
-				if ( ! $item->is_recurring() ) {
598
-					echo wp_kses_post( $item->get_the_price() );
599
-					break;
600
-				}
601
-
602
-				$price = wp_sprintf(
603
-					__( '%1$s / %2$s', 'invoicing' ),
604
-					$item->get_the_price(),
605
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
606
-				);
607
-
608
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
609
-					echo wp_kses_post( $price );
610
-					break;
611
-				}
612
-
613
-				echo wp_kses_post( $item->get_the_initial_price() );
614
-
615
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
616
-				break;
617
-
618
-			case 'vat_rule':
619
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
620
-				break;
621
-
622
-			case 'vat_class':
623
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
624
-				break;
625
-
626
-			case 'shortcode':
627
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
628
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
629
-				} else {
630
-					echo '&mdash;';
631
-				}
632
-
633
-				break;
634
-
635
-			case 'type':
636
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
637
-				break;
638
-
639
-		}
640
-
641
-	}
642
-
643
-	/**
644
-	 * Lets users filter items using taxes.
645
-	 */
646
-	public static function add_item_filters( $post_type ) {
647
-
648
-		// Abort if we're not dealing with items.
649
-		if ( 'wpi_item' !== $post_type ) {
650
-			return;
651
-		}
652
-
653
-		// Filter by vat rules.
654
-		if ( wpinv_use_taxes() ) {
655
-
656
-			// Sanitize selected vat rule.
657
-			$vat_rule   = '';
658
-			$vat_rules  = getpaid_get_tax_rules();
659
-			if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
660
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
661
-			}
662
-
663
-			// Filter by VAT rule.
664
-			wpinv_html_select(
665
-				array(
666
-					'options'          => array_merge(
667
-						array(
668
-							'' => __( 'All Tax Rules', 'invoicing' ),
669
-						),
670
-						$vat_rules
671
-					),
672
-					'name'             => 'vat_rule',
673
-					'id'               => 'vat_rule',
674
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
675
-					'show_option_all'  => false,
676
-					'show_option_none' => false,
677
-				)
678
-			);
679
-
680
-			// Filter by VAT class.
681
-
682
-			// Sanitize selected vat rule.
683
-			$vat_class   = '';
684
-			$vat_classes = getpaid_get_tax_classes();
685
-			if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
686
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
687
-			}
688
-
689
-			wpinv_html_select(
690
-				array(
691
-					'options'          => array_merge(
692
-						array(
693
-							'' => __( 'All Tax Classes', 'invoicing' ),
694
-						),
695
-						$vat_classes
696
-					),
697
-					'name'             => 'vat_class',
698
-					'id'               => 'vat_class',
699
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
700
-					'show_option_all'  => false,
701
-					'show_option_none' => false,
702
-				)
703
-			);
704
-
705
-		}
706
-
707
-		// Filter by item type.
708
-		$type   = '';
709
-		if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
710
-			$type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
711
-		}
712
-
713
-		wpinv_html_select(
714
-			array(
715
-				'options'          => array_merge(
716
-					array(
717
-						'' => __( 'All item types', 'invoicing' ),
718
-					),
719
-					wpinv_get_item_types()
720
-				),
721
-				'name'             => 'type',
722
-				'id'               => 'type',
723
-				'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
724
-				'show_option_all'  => false,
725
-				'show_option_none' => false,
726
-			)
727
-		);
728
-
729
-	}
730
-
731
-	/**
732
-	 * Filters the item query.
733
-	 */
734
-	public static function filter_item_query( $query ) {
735
-
736
-		// modify the query only if it admin and main query.
737
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
738
-			return $query;
739
-		}
740
-
741
-		// we want to modify the query for our items.
742
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
743
-			return $query;
744
-		}
745
-
746
-		if ( empty( $query->query_vars['meta_query'] ) ) {
747
-			$query->query_vars['meta_query'] = array();
748
-		}
749
-
750
-		// Filter vat rule type
639
+        }
640
+
641
+    }
642
+
643
+    /**
644
+     * Lets users filter items using taxes.
645
+     */
646
+    public static function add_item_filters( $post_type ) {
647
+
648
+        // Abort if we're not dealing with items.
649
+        if ( 'wpi_item' !== $post_type ) {
650
+            return;
651
+        }
652
+
653
+        // Filter by vat rules.
654
+        if ( wpinv_use_taxes() ) {
655
+
656
+            // Sanitize selected vat rule.
657
+            $vat_rule   = '';
658
+            $vat_rules  = getpaid_get_tax_rules();
659
+            if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
660
+                $vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
661
+            }
662
+
663
+            // Filter by VAT rule.
664
+            wpinv_html_select(
665
+                array(
666
+                    'options'          => array_merge(
667
+                        array(
668
+                            '' => __( 'All Tax Rules', 'invoicing' ),
669
+                        ),
670
+                        $vat_rules
671
+                    ),
672
+                    'name'             => 'vat_rule',
673
+                    'id'               => 'vat_rule',
674
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
675
+                    'show_option_all'  => false,
676
+                    'show_option_none' => false,
677
+                )
678
+            );
679
+
680
+            // Filter by VAT class.
681
+
682
+            // Sanitize selected vat rule.
683
+            $vat_class   = '';
684
+            $vat_classes = getpaid_get_tax_classes();
685
+            if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
686
+                $vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
687
+            }
688
+
689
+            wpinv_html_select(
690
+                array(
691
+                    'options'          => array_merge(
692
+                        array(
693
+                            '' => __( 'All Tax Classes', 'invoicing' ),
694
+                        ),
695
+                        $vat_classes
696
+                    ),
697
+                    'name'             => 'vat_class',
698
+                    'id'               => 'vat_class',
699
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
700
+                    'show_option_all'  => false,
701
+                    'show_option_none' => false,
702
+                )
703
+            );
704
+
705
+        }
706
+
707
+        // Filter by item type.
708
+        $type   = '';
709
+        if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
710
+            $type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
711
+        }
712
+
713
+        wpinv_html_select(
714
+            array(
715
+                'options'          => array_merge(
716
+                    array(
717
+                        '' => __( 'All item types', 'invoicing' ),
718
+                    ),
719
+                    wpinv_get_item_types()
720
+                ),
721
+                'name'             => 'type',
722
+                'id'               => 'type',
723
+                'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
724
+                'show_option_all'  => false,
725
+                'show_option_none' => false,
726
+            )
727
+        );
728
+
729
+    }
730
+
731
+    /**
732
+     * Filters the item query.
733
+     */
734
+    public static function filter_item_query( $query ) {
735
+
736
+        // modify the query only if it admin and main query.
737
+        if ( ! ( is_admin() && $query->is_main_query() ) ) {
738
+            return $query;
739
+        }
740
+
741
+        // we want to modify the query for our items.
742
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
743
+            return $query;
744
+        }
745
+
746
+        if ( empty( $query->query_vars['meta_query'] ) ) {
747
+            $query->query_vars['meta_query'] = array();
748
+        }
749
+
750
+        // Filter vat rule type
751 751
         if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
752 752
             $query->query_vars['meta_query'][] = array(
753 753
                 'key'     => '_wpinv_vat_rule',
@@ -772,97 +772,97 @@  discard block
 block discarded – undo
772 772
                 'value'   => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
773 773
                 'compare' => '=',
774 774
             );
775
-		}
776
-
777
-	}
778
-
779
-	/**
780
-	 * Reorders items.
781
-	 */
782
-	public static function reorder_items( $vars ) {
783
-		global $typenow;
784
-
785
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
786
-			return $vars;
787
-		}
788
-
789
-		// By item type.
790
-		if ( 'type' === $vars['orderby'] ) {
791
-			return array_merge(
792
-				$vars,
793
-				array(
794
-					'meta_key' => '_wpinv_type',
795
-					'orderby'  => 'meta_value',
796
-				)
797
-			);
798
-		}
799
-
800
-		// By vat class.
801
-		if ( 'vat_class' === $vars['orderby'] ) {
802
-			return array_merge(
803
-				$vars,
804
-				array(
805
-					'meta_key' => '_wpinv_vat_class',
806
-					'orderby'  => 'meta_value',
807
-				)
808
-			);
809
-		}
810
-
811
-		// By vat rule.
812
-		if ( 'vat_rule' === $vars['orderby'] ) {
813
-			return array_merge(
814
-				$vars,
815
-				array(
816
-					'meta_key' => '_wpinv_vat_rule',
817
-					'orderby'  => 'meta_value',
818
-				)
819
-			);
820
-		}
821
-
822
-		// By price.
823
-		if ( 'price' === $vars['orderby'] ) {
824
-			return array_merge(
825
-				$vars,
826
-				array(
827
-					'meta_key' => '_wpinv_price',
828
-					'orderby'  => 'meta_value_num',
829
-				)
830
-			);
831
-		}
832
-
833
-		return $vars;
834
-
835
-	}
836
-
837
-	/**
838
-	 * Fired when deleting a post.
839
-	 */
840
-	public static function delete_post( $post_id ) {
841
-
842
-		switch ( get_post_type( $post_id ) ) {
843
-
844
-			case 'wpi_item':
845
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
846
-				break;
847
-
848
-			case 'wpi_payment_form':
849
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
850
-				break;
851
-
852
-			case 'wpi_discount':
853
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
854
-				break;
855
-
856
-			case 'wpi_invoice':
857
-				$invoice = new WPInv_Invoice( $post_id );
858
-				do_action( 'getpaid_before_delete_invoice', $invoice );
859
-				$invoice->get_data_store()->delete_items( $invoice );
860
-				$invoice->get_data_store()->delete_special_fields( $invoice );
861
-				break;
862
-		}
863
-	}
864
-
865
-	/**
775
+        }
776
+
777
+    }
778
+
779
+    /**
780
+     * Reorders items.
781
+     */
782
+    public static function reorder_items( $vars ) {
783
+        global $typenow;
784
+
785
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
786
+            return $vars;
787
+        }
788
+
789
+        // By item type.
790
+        if ( 'type' === $vars['orderby'] ) {
791
+            return array_merge(
792
+                $vars,
793
+                array(
794
+                    'meta_key' => '_wpinv_type',
795
+                    'orderby'  => 'meta_value',
796
+                )
797
+            );
798
+        }
799
+
800
+        // By vat class.
801
+        if ( 'vat_class' === $vars['orderby'] ) {
802
+            return array_merge(
803
+                $vars,
804
+                array(
805
+                    'meta_key' => '_wpinv_vat_class',
806
+                    'orderby'  => 'meta_value',
807
+                )
808
+            );
809
+        }
810
+
811
+        // By vat rule.
812
+        if ( 'vat_rule' === $vars['orderby'] ) {
813
+            return array_merge(
814
+                $vars,
815
+                array(
816
+                    'meta_key' => '_wpinv_vat_rule',
817
+                    'orderby'  => 'meta_value',
818
+                )
819
+            );
820
+        }
821
+
822
+        // By price.
823
+        if ( 'price' === $vars['orderby'] ) {
824
+            return array_merge(
825
+                $vars,
826
+                array(
827
+                    'meta_key' => '_wpinv_price',
828
+                    'orderby'  => 'meta_value_num',
829
+                )
830
+            );
831
+        }
832
+
833
+        return $vars;
834
+
835
+    }
836
+
837
+    /**
838
+     * Fired when deleting a post.
839
+     */
840
+    public static function delete_post( $post_id ) {
841
+
842
+        switch ( get_post_type( $post_id ) ) {
843
+
844
+            case 'wpi_item':
845
+                do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
846
+                break;
847
+
848
+            case 'wpi_payment_form':
849
+                do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
850
+                break;
851
+
852
+            case 'wpi_discount':
853
+                do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
854
+                break;
855
+
856
+            case 'wpi_invoice':
857
+                $invoice = new WPInv_Invoice( $post_id );
858
+                do_action( 'getpaid_before_delete_invoice', $invoice );
859
+                $invoice->get_data_store()->delete_items( $invoice );
860
+                $invoice->get_data_store()->delete_special_fields( $invoice );
861
+                break;
862
+        }
863
+    }
864
+
865
+    /**
866 866
      * Add a post display state for special GetPaid pages in the page list table.
867 867
      *
868 868
      * @param array   $post_states An array of post display states.
@@ -876,21 +876,21 @@  discard block
 block discarded – undo
876 876
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
877 877
         }
878 878
 
879
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
879
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
880 880
 
881
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
882
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
883
-					__( 'GetPaid %s History Page', 'invoicing' ),
884
-					$label
885
-				);
886
-			}
881
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
882
+                $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
883
+                    __( 'GetPaid %s History Page', 'invoicing' ),
884
+                    $label
885
+                );
886
+            }
887 887
 }
888 888
 
889
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
889
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
890 890
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
891 891
         }
892 892
 
893
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
893
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
894 894
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
895 895
         }
896 896
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Indentation   +620 added lines, -620 removed lines patch added patch discarded remove patch
@@ -14,93 +14,93 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
29
-
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29
+
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct() {
38
+     * Class constructor.
39
+     */
40
+    public function __construct() {
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect' ) );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
67
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
68
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
69 69
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
76
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
77
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
78
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
79
-		do_action( 'getpaid_init_admin_hooks', $this );
80
-
81
-		// Setup/welcome
82
-		if ( ! empty( $_GET['page'] ) ) {
83
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
84
-				case 'gp-setup':
85
-					include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
86
-					break;
87
-			}
88
-		}
89
-
90
-    }
91
-
92
-    /**
93
-	 * Register admin scripts
94
-	 *
95
-	 */
96
-	public function enqeue_scripts() {
70
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
75
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
76
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
77
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
78
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
79
+        do_action( 'getpaid_init_admin_hooks', $this );
80
+
81
+        // Setup/welcome
82
+        if ( ! empty( $_GET['page'] ) ) {
83
+            switch ( sanitize_text_field( $_GET['page'] ) ) {
84
+                case 'gp-setup':
85
+                    include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
86
+                    break;
87
+            }
88
+        }
89
+
90
+    }
91
+
92
+    /**
93
+     * Register admin scripts
94
+     *
95
+     */
96
+    public function enqeue_scripts() {
97 97
         global $current_screen, $pagenow;
98 98
 
99
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
100
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
100
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
101 101
 
102 102
         if ( ! empty( $current_screen->post_type ) ) {
103
-			$page = $current_screen->post_type;
103
+            $page = $current_screen->post_type;
104 104
         }
105 105
 
106 106
         // General styles.
@@ -121,53 +121,53 @@  discard block
 block discarded – undo
121 121
         }
122 122
 
123 123
         // Payment form scripts.
124
-		if ( 'wpi_payment_form' == $page && $editing ) {
124
+        if ( 'wpi_payment_form' == $page && $editing ) {
125 125
             $this->load_payment_form_scripts();
126 126
         }
127 127
 
128
-		if ( $page == 'wpinv-subscriptions' ) {
129
-			wp_enqueue_script( 'postbox' );
130
-		}
128
+        if ( $page == 'wpinv-subscriptions' ) {
129
+            wp_enqueue_script( 'postbox' );
130
+        }
131 131
 
132 132
     }
133 133
 
134 134
     /**
135
-	 * Returns admin js translations.
136
-	 *
137
-	 */
138
-	protected function get_admin_i18() {
135
+     * Returns admin js translations.
136
+     *
137
+     */
138
+    protected function get_admin_i18() {
139 139
         global $post;
140 140
 
141
-		$date_range = array(
142
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
143
-		);
141
+        $date_range = array(
142
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
143
+        );
144 144
 
145
-		if ( $date_range['period'] == 'custom' ) {
145
+        if ( $date_range['period'] == 'custom' ) {
146 146
 
147
-			if ( isset( $_GET['from'] ) ) {
148
-				$date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
149
-			}
147
+            if ( isset( $_GET['from'] ) ) {
148
+                $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
149
+            }
150 150
 
151
-			if ( isset( $_GET['to'] ) ) {
152
-				$date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
153
-			}
151
+            if ( isset( $_GET['to'] ) ) {
152
+                $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
153
+            }
154 154
 }
155 155
 
156 156
         $i18n = array(
157 157
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
158 158
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
159
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
160
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
161
-			'rest_root'                 => esc_url_raw( rest_url() ),
162
-			'date_range'                => $date_range,
159
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
160
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
161
+            'rest_root'                 => esc_url_raw( rest_url() ),
162
+            'date_range'                => $date_range,
163 163
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
164 164
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
165 165
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
166 166
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
167 167
             'tax'                       => wpinv_tax_amount(),
168 168
             'discount'                  => 0,
169
-			'currency_symbol'           => wpinv_currency_symbol(),
170
-			'currency'                  => wpinv_get_currency(),
169
+            'currency_symbol'           => wpinv_currency_symbol(),
170
+            'currency'                  => wpinv_get_currency(),
171 171
             'currency_pos'              => wpinv_currency_position(),
172 172
             'thousand_sep'              => wpinv_thousands_separator(),
173 173
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -187,118 +187,118 @@  discard block
 block discarded – undo
187 187
             'item_description'          => __( 'Item Description', 'invoicing' ),
188 188
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
189 189
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
190
-			'searching'                 => __( 'Searching', 'invoicing' ),
191
-			'loading'                   => __( 'Loading...', 'invoicing' ),
192
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
193
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
194
-			'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
190
+            'searching'                 => __( 'Searching', 'invoicing' ),
191
+            'loading'                   => __( 'Loading...', 'invoicing' ),
192
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
193
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
194
+            'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
195 195
         );
196 196
 
197
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
197
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
198 198
 
199
-			$invoice              = new WPInv_Invoice( $post );
200
-			$i18n['save_invoice'] = sprintf(
201
-				__( 'Save %s', 'invoicing' ),
202
-				ucfirst( $invoice->get_invoice_quote_type() )
203
-			);
199
+            $invoice              = new WPInv_Invoice( $post );
200
+            $i18n['save_invoice'] = sprintf(
201
+                __( 'Save %s', 'invoicing' ),
202
+                ucfirst( $invoice->get_invoice_quote_type() )
203
+            );
204 204
 
205
-			$i18n['invoice_description'] = sprintf(
206
-				__( '%s Description', 'invoicing' ),
207
-				ucfirst( $invoice->get_invoice_quote_type() )
208
-			);
205
+            $i18n['invoice_description'] = sprintf(
206
+                __( '%s Description', 'invoicing' ),
207
+                ucfirst( $invoice->get_invoice_quote_type() )
208
+            );
209 209
 
210
-		}
211
-		return $i18n;
212
-	}
210
+        }
211
+        return $i18n;
212
+    }
213 213
 
214
-	/**
215
-	 * Change the admin footer text on GetPaid admin pages.
216
-	 *
217
-	 * @since  2.0.0
218
-	 * @param  string $footer_text
219
-	 * @return string
220
-	 */
221
-	public function admin_footer_text( $footer_text ) {
222
-		global $current_screen;
214
+    /**
215
+     * Change the admin footer text on GetPaid admin pages.
216
+     *
217
+     * @since  2.0.0
218
+     * @param  string $footer_text
219
+     * @return string
220
+     */
221
+    public function admin_footer_text( $footer_text ) {
222
+        global $current_screen;
223 223
 
224
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
224
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
225 225
 
226 226
         if ( ! empty( $current_screen->post_type ) ) {
227
-			$page = $current_screen->post_type;
227
+            $page = $current_screen->post_type;
228 228
         }
229 229
 
230 230
         // General styles.
231 231
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
232 232
 
233
-			// Change the footer text
234
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
233
+            // Change the footer text
234
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
235 235
 
236
-				$rating_url  = esc_url(
237
-					wp_nonce_url(
238
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
239
-						'getpaid-nonce',
240
-						'getpaid-nonce'
236
+                $rating_url  = esc_url(
237
+                    wp_nonce_url(
238
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
239
+                        'getpaid-nonce',
240
+                        'getpaid-nonce'
241 241
                     )
242
-				);
242
+                );
243 243
 
244
-				$footer_text = sprintf(
245
-					/* translators: %s: five stars */
246
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
247
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
248
-				);
244
+                $footer_text = sprintf(
245
+                    /* translators: %s: five stars */
246
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
247
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
248
+                );
249 249
 
250
-			} else {
250
+            } else {
251 251
 
252
-				$footer_text = sprintf(
253
-					/* translators: %s: GetPaid */
254
-					__( 'Thank you for using %s!', 'invoicing' ),
255
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
256
-				);
252
+                $footer_text = sprintf(
253
+                    /* translators: %s: GetPaid */
254
+                    __( 'Thank you for using %s!', 'invoicing' ),
255
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
256
+                );
257 257
 
258
-			}
258
+            }
259 259
 }
260 260
 
261
-		return $footer_text;
262
-	}
263
-
264
-	/**
265
-	 * Redirects to wp.org to rate the plugin.
266
-	 *
267
-	 * @since  2.0.0
268
-	 */
269
-	public function redirect_to_wordpress_rating_page() {
270
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
271
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
272
-		exit;
273
-	}
274
-
275
-    /**
276
-	 * Loads payment form js.
277
-	 *
278
-	 */
279
-	protected function load_payment_form_scripts() {
261
+        return $footer_text;
262
+    }
263
+
264
+    /**
265
+     * Redirects to wp.org to rate the plugin.
266
+     *
267
+     * @since  2.0.0
268
+     */
269
+    public function redirect_to_wordpress_rating_page() {
270
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
271
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
272
+        exit;
273
+    }
274
+
275
+    /**
276
+     * Loads payment form js.
277
+     *
278
+     */
279
+    protected function load_payment_form_scripts() {
280 280
         global $post;
281 281
 
282 282
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
283
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
284
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
283
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
284
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
285 285
 
286
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
287
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );
286
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
287
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );
288 288
 
289
-		wp_localize_script(
289
+        wp_localize_script(
290 290
             'wpinv-admin-payment-form-script',
291 291
             'wpinvPaymentFormAdmin',
292 292
             array(
293
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
294
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
295
-				'currency'      => wpinv_currency_symbol(),
296
-				'position'      => wpinv_currency_position(),
297
-				'decimals'      => (int) wpinv_decimals(),
298
-				'thousands_sep' => wpinv_thousands_separator(),
299
-				'decimals_sep'  => wpinv_decimal_separator(),
300
-				'form_items'    => gepaid_get_form_items( $post->ID ),
301
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
293
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
294
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
295
+                'currency'      => wpinv_currency_symbol(),
296
+                'position'      => wpinv_currency_position(),
297
+                'decimals'      => (int) wpinv_decimals(),
298
+                'thousands_sep' => wpinv_thousands_separator(),
299
+                'decimals_sep'  => wpinv_decimal_separator(),
300
+                'form_items'    => gepaid_get_form_items( $post->ID ),
301
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
302 302
             )
303 303
         );
304 304
 
@@ -307,19 +307,19 @@  discard block
 block discarded – undo
307 307
     }
308 308
 
309 309
     /**
310
-	 * Add our classes to admin pages.
310
+     * Add our classes to admin pages.
311 311
      *
312 312
      * @param string $classes
313 313
      * @return string
314
-	 *
315
-	 */
314
+     *
315
+     */
316 316
     public function admin_body_class( $classes ) {
317
-		global $pagenow, $post, $current_screen;
317
+        global $pagenow, $post, $current_screen;
318 318
 
319 319
         $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
320 320
 
321 321
         if ( ! empty( $current_screen->post_type ) ) {
322
-			$page = $current_screen->post_type;
322
+            $page = $current_screen->post_type;
323 323
         }
324 324
 
325 325
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -328,70 +328,70 @@  discard block
 block discarded – undo
328 328
 
329 329
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
330 330
             $classes .= ' wpinv-cpt wpinv';
331
-		}
331
+        }
332 332
 
333
-		if ( getpaid_is_invoice_post_type( $page ) ) {
333
+        if ( getpaid_is_invoice_post_type( $page ) ) {
334 334
             $classes .= ' getpaid-is-invoice-cpt';
335 335
         }
336 336
 
337
-		return $classes;
337
+        return $classes;
338 338
     }
339 339
 
340 340
     /**
341
-	 * Maybe show the AyeCode Connect Notice.
342
-	 */
343
-	public function init_ayecode_connect_helper() {
341
+     * Maybe show the AyeCode Connect Notice.
342
+     */
343
+    public function init_ayecode_connect_helper() {
344 344
 
345
-		// Register with the deactivation survey class.
346
-		AyeCode_Deactivation_Survey::instance(
345
+        // Register with the deactivation survey class.
346
+        AyeCode_Deactivation_Survey::instance(
347 347
             array(
348
-				'slug'              => 'invoicing',
349
-				'version'           => WPINV_VERSION,
350
-				'support_url'       => 'https://wpgetpaid.com/support/',
351
-				'documentation_url' => 'https://docs.wpgetpaid.com/',
352
-				'activated'         => (int) get_option( 'gepaid_installed_on' ),
348
+                'slug'              => 'invoicing',
349
+                'version'           => WPINV_VERSION,
350
+                'support_url'       => 'https://wpgetpaid.com/support/',
351
+                'documentation_url' => 'https://docs.wpgetpaid.com/',
352
+                'activated'         => (int) get_option( 'gepaid_installed_on' ),
353 353
             )
354 354
         );
355 355
 
356 356
         new AyeCode_Connect_Helper(
357 357
             array(
358
-				'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
359
-				'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
360
-				'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
361
-				'connect_button'    => __( 'Connect Site', 'invoicing' ),
362
-				'connecting_button' => __( 'Connecting...', 'invoicing' ),
363
-				'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
364
-				'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
358
+                'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
359
+                'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
360
+                'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
361
+                'connect_button'    => __( 'Connect Site', 'invoicing' ),
362
+                'connecting_button' => __( 'Connecting...', 'invoicing' ),
363
+                'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
364
+                'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
365 365
             ),
366 366
             array( 'wpi-addons' )
367 367
         );
368 368
 
369 369
     }
370 370
 
371
-	/**
372
-	 * Redirect users to settings on activation.
373
-	 *
374
-	 * @return void
375
-	 */
376
-	public function activation_redirect() {
371
+    /**
372
+     * Redirect users to settings on activation.
373
+     *
374
+     * @return void
375
+     */
376
+    public function activation_redirect() {
377 377
 
378
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
378
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
379 379
 
380
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
381
-			return;
382
-		}
380
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
381
+            return;
382
+        }
383 383
 
384
-		// Bail if activating from network, or bulk
385
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
386
-			return;
387
-		}
384
+        // Bail if activating from network, or bulk
385
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
386
+            return;
387
+        }
388 388
 
389
-	    update_option( 'wpinv_redirected_to_settings', 1 );
389
+        update_option( 'wpinv_redirected_to_settings', 1 );
390 390
 
391 391
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
392 392
         exit;
393 393
 
394
-	}
394
+    }
395 395
 
396 396
     /**
397 397
      * Fires an admin action after verifying that a user can fire them.
@@ -405,564 +405,564 @@  discard block
 block discarded – undo
405 405
 
406 406
     }
407 407
 
408
-	/**
408
+    /**
409 409
      * Duplicate invoice.
410
-	 *
411
-	 * @param array $args
410
+     *
411
+     * @param array $args
412 412
      */
413 413
     public function duplicate_invoice( $args ) {
414 414
 
415
-		if ( empty( $args['invoice_id'] ) ) {
416
-			return;
417
-		}
415
+        if ( empty( $args['invoice_id'] ) ) {
416
+            return;
417
+        }
418 418
 
419
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
419
+        $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
420 420
 
421
-		if ( ! $invoice->exists() ) {
422
-			return;
423
-		}
421
+        if ( ! $invoice->exists() ) {
422
+            return;
423
+        }
424 424
 
425
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
426
-		$new_invoice->save();
425
+        $new_invoice = getpaid_duplicate_invoice( $invoice );
426
+        $new_invoice->save();
427 427
 
428
-		if ( $new_invoice->exists() ) {
428
+        if ( $new_invoice->exists() ) {
429 429
 
430
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) );
430
+            getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) );
431 431
 
432
-			wp_safe_redirect(
433
-				add_query_arg(
434
-					array(
435
-						'action' => 'edit',
436
-						'post'   => $new_invoice->get_id(),
437
-					),
438
-					admin_url( 'post.php' )
439
-				)
440
-			);
441
-			exit;
432
+            wp_safe_redirect(
433
+                add_query_arg(
434
+                    array(
435
+                        'action' => 'edit',
436
+                        'post'   => $new_invoice->get_id(),
437
+                    ),
438
+                    admin_url( 'post.php' )
439
+                )
440
+            );
441
+            exit;
442 442
 
443
-		}
443
+        }
444 444
 
445
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) );
445
+        getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) );
446 446
 
447
-	}
447
+    }
448 448
 
449
-	/**
449
+    /**
450 450
      * Sends a payment reminder to a customer.
451
-	 *
452
-	 * @param array $args
451
+     *
452
+     * @param array $args
453 453
      */
454 454
     public function duplicate_payment_form( $args ) {
455 455
 
456
-		if ( empty( $args['form_id'] ) ) {
457
-			return;
458
-		}
459
-
460
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
456
+        if ( empty( $args['form_id'] ) ) {
457
+            return;
458
+        }
461 459
 
462
-		if ( ! $form->exists() ) {
463
-			return;
464
-		}
460
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
465 461
 
466
-		$new_form = new GetPaid_Payment_Form();
467
-		$new_form->set_author( $form->get_author( 'edit' ) );
468
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
469
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
470
-		$new_form->set_items( $form->get_items( 'edit' ) );
471
-		$new_form->save();
462
+        if ( ! $form->exists() ) {
463
+            return;
464
+        }
472 465
 
473
-		if ( $new_form->exists() ) {
474
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
475
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
476
-		} else {
477
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
478
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
479
-		}
466
+        $new_form = new GetPaid_Payment_Form();
467
+        $new_form->set_author( $form->get_author( 'edit' ) );
468
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
469
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
470
+        $new_form->set_items( $form->get_items( 'edit' ) );
471
+        $new_form->save();
472
+
473
+        if ( $new_form->exists() ) {
474
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
475
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
476
+        } else {
477
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
478
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
479
+        }
480 480
 
481
-		wp_redirect( $url );
482
-		exit;
483
-	}
481
+        wp_redirect( $url );
482
+        exit;
483
+    }
484 484
 
485
-	/**
485
+    /**
486 486
      * Resets form stats.
487
-	 *
488
-	 * @param array $args
487
+     *
488
+     * @param array $args
489 489
      */
490 490
     public function reset_form_stats( $args ) {
491 491
 
492
-		if ( empty( $args['form_id'] ) ) {
493
-			return;
494
-		}
492
+        if ( empty( $args['form_id'] ) ) {
493
+            return;
494
+        }
495 495
 
496
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
496
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
497 497
 
498
-		if ( ! $form->exists() ) {
499
-			return;
500
-		}
498
+        if ( ! $form->exists() ) {
499
+            return;
500
+        }
501 501
 
502
-		$form->set_earned( 0 );
503
-		$form->set_refunded( 0 );
504
-		$form->set_cancelled( 0 );
505
-		$form->set_failed( 0 );
506
-		$form->save();
502
+        $form->set_earned( 0 );
503
+        $form->set_refunded( 0 );
504
+        $form->set_cancelled( 0 );
505
+        $form->set_failed( 0 );
506
+        $form->save();
507 507
 
508
-		$this->show_success( __( 'Form stats reset successfully', 'invoicing' ) );
508
+        $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) );
509 509
 
510
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) );
511
-		exit;
512
-	}
510
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) );
511
+        exit;
512
+    }
513 513
 
514
-	/**
514
+    /**
515 515
      * Sends a payment reminder to a customer.
516
-	 *
517
-	 * @param array $args
516
+     *
517
+     * @param array $args
518 518
      */
519 519
     public function send_customer_invoice( $args ) {
520
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
521
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
522
-		exit;
523
-	}
520
+        getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
521
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
522
+        exit;
523
+    }
524 524
 
525
-	/**
525
+    /**
526 526
      * Sends a payment reminder to a customer.
527
-	 *
528
-	 * @param array $args
527
+     *
528
+     * @param array $args
529 529
      */
530 530
     public function send_customer_payment_reminder( $args ) {
531
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
531
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
532 532
 
533
-		if ( $sent ) {
534
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
535
-		} else {
536
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
537
-		}
533
+        if ( $sent ) {
534
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
535
+        } else {
536
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
537
+        }
538 538
 
539
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
540
-		exit;
541
-	}
539
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
540
+        exit;
541
+    }
542 542
 
543
-	/**
543
+    /**
544 544
      * Resets tax rates.
545
-	 *
545
+     *
546 546
      */
547 547
     public function admin_reset_tax_rates() {
548 548
 
549
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
550
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
551
-		exit;
549
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
550
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
551
+        exit;
552 552
 
553
-	}
553
+    }
554 554
 
555
-	/**
555
+    /**
556 556
      * Resets admin pages.
557
-	 *
557
+     *
558 558
      */
559 559
     public function admin_create_missing_pages() {
560
-		$installer = new GetPaid_Installer();
561
-		$installer->create_pages();
562
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
563
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
564
-		exit;
565
-	}
566
-
567
-	/**
568
-	 * Refreshes the permalinks.
569
-	 */
570
-	public function admin_refresh_permalinks() {
571
-		flush_rewrite_rules();
572
-		$this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) );
573
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
574
-		exit;
575
-	}
576
-
577
-	/**
560
+        $installer = new GetPaid_Installer();
561
+        $installer->create_pages();
562
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
563
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
564
+        exit;
565
+    }
566
+
567
+    /**
568
+     * Refreshes the permalinks.
569
+     */
570
+    public function admin_refresh_permalinks() {
571
+        flush_rewrite_rules();
572
+        $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) );
573
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
574
+        exit;
575
+    }
576
+
577
+    /**
578 578
      * Creates an missing admin tables.
579
-	 *
579
+     *
580 580
      */
581 581
     public function admin_create_missing_tables() {
582
-		global $wpdb;
583
-		$installer = new GetPaid_Installer();
582
+        global $wpdb;
583
+        $installer = new GetPaid_Installer();
584 584
 
585
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
586
-			$installer->create_subscriptions_table();
585
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
586
+            $installer->create_subscriptions_table();
587 587
 
588
-			if ( $wpdb->last_error !== '' ) {
589
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
590
-			}
591
-		}
588
+            if ( $wpdb->last_error !== '' ) {
589
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
590
+            }
591
+        }
592 592
 
593
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
594
-			$installer->create_invoices_table();
593
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
594
+            $installer->create_invoices_table();
595 595
 
596
-			if ( '' !== $wpdb->last_error ) {
597
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
598
-			}
599
-		}
596
+            if ( '' !== $wpdb->last_error ) {
597
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
598
+            }
599
+        }
600 600
 
601
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
602
-			$installer->create_invoice_items_table();
601
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
602
+            $installer->create_invoice_items_table();
603 603
 
604
-			if ( '' !== $wpdb->last_error ) {
605
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
606
-			}
607
-		}
604
+            if ( '' !== $wpdb->last_error ) {
605
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
606
+            }
607
+        }
608 608
 
609
-		if ( ! $this->has_notices() ) {
610
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
611
-		}
609
+        if ( ! $this->has_notices() ) {
610
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
611
+        }
612 612
 
613
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
614
-		exit;
615
-	}
613
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
614
+        exit;
615
+    }
616 616
 
617
-	/**
617
+    /**
618 618
      * Migrates old invoices to the new database tables.
619
-	 *
619
+     *
620 620
      */
621 621
     public function admin_migrate_old_invoices() {
622 622
 
623
-		// Migrate the invoices.
624
-		$installer = new GetPaid_Installer();
625
-		$installer->migrate_old_invoices();
623
+        // Migrate the invoices.
624
+        $installer = new GetPaid_Installer();
625
+        $installer->migrate_old_invoices();
626 626
 
627
-		// Show an admin message.
628
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
627
+        // Show an admin message.
628
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
629 629
 
630
-		// Redirect the admin.
631
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
632
-		exit;
630
+        // Redirect the admin.
631
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
632
+        exit;
633 633
 
634
-	}
634
+    }
635 635
 
636
-	/**
636
+    /**
637 637
      * Download customers.
638
-	 *
638
+     *
639 639
      */
640 640
     public function admin_download_customers() {
641
-		global $wpdb;
642
-
643
-		$output = fopen( 'php://output', 'w' );
644
-
645
-		if ( false === $output ) {
646
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
647
-		}
641
+        global $wpdb;
648 642
 
649
-		header( 'Content-Type:text/csv' );
650
-		header( 'Content-Disposition:attachment;filename=customers.csv' );
643
+        $output = fopen( 'php://output', 'w' );
651 644
 
652
-		$post_types = '';
645
+        if ( false === $output ) {
646
+            wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
647
+        }
653 648
 
654
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
655
-			$post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
656
-		}
649
+        header( 'Content-Type:text/csv' );
650
+        header( 'Content-Disposition:attachment;filename=customers.csv' );
657 651
 
658
-		$post_types = rtrim( $post_types, ' OR' );
652
+        $post_types = '';
659 653
 
660
-		$customers = $wpdb->get_col( "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" );
654
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
655
+            $post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
656
+        }
661 657
 
662
-		$columns = array(
663
-			'name'       => __( 'Name', 'invoicing' ),
664
-			'email'      => __( 'Email', 'invoicing' ),
665
-			'country'    => __( 'Country', 'invoicing' ),
666
-			'state'      => __( 'State', 'invoicing' ),
667
-			'city'       => __( 'City', 'invoicing' ),
668
-			'zip'        => __( 'ZIP', 'invoicing' ),
669
-			'address'    => __( 'Address', 'invoicing' ),
670
-			'phone'      => __( 'Phone', 'invoicing' ),
671
-			'company'    => __( 'Company', 'invoicing' ),
672
-			'company_id' => __( 'Company ID', 'invoicing' ),
673
-			'invoices'   => __( 'Invoices', 'invoicing' ),
674
-			'total_raw'  => __( 'Total Spend', 'invoicing' ),
675
-			'signup'     => __( 'Date created', 'invoicing' ),
676
-		);
658
+        $post_types = rtrim( $post_types, ' OR' );
659
+
660
+        $customers = $wpdb->get_col( "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" );
661
+
662
+        $columns = array(
663
+            'name'       => __( 'Name', 'invoicing' ),
664
+            'email'      => __( 'Email', 'invoicing' ),
665
+            'country'    => __( 'Country', 'invoicing' ),
666
+            'state'      => __( 'State', 'invoicing' ),
667
+            'city'       => __( 'City', 'invoicing' ),
668
+            'zip'        => __( 'ZIP', 'invoicing' ),
669
+            'address'    => __( 'Address', 'invoicing' ),
670
+            'phone'      => __( 'Phone', 'invoicing' ),
671
+            'company'    => __( 'Company', 'invoicing' ),
672
+            'company_id' => __( 'Company ID', 'invoicing' ),
673
+            'invoices'   => __( 'Invoices', 'invoicing' ),
674
+            'total_raw'  => __( 'Total Spend', 'invoicing' ),
675
+            'signup'     => __( 'Date created', 'invoicing' ),
676
+        );
677 677
 
678
-		// Output the csv column headers.
679
-		fputcsv( $output, array_values( $columns ) );
678
+        // Output the csv column headers.
679
+        fputcsv( $output, array_values( $columns ) );
680 680
 
681
-		// Loop through
682
-		$table = new WPInv_Customers_Table();
683
-		foreach ( $customers as $customer_id ) {
681
+        // Loop through
682
+        $table = new WPInv_Customers_Table();
683
+        foreach ( $customers as $customer_id ) {
684 684
 
685
-			$user = get_user_by( 'id', $customer_id );
686
-			$row  = array();
687
-			if ( empty( $user ) ) {
688
-				continue;
689
-			}
685
+            $user = get_user_by( 'id', $customer_id );
686
+            $row  = array();
687
+            if ( empty( $user ) ) {
688
+                continue;
689
+            }
690 690
 
691
-			foreach ( array_keys( $columns ) as $column ) {
691
+            foreach ( array_keys( $columns ) as $column ) {
692 692
 
693
-				$method = 'column_' . $column;
693
+                $method = 'column_' . $column;
694 694
 
695
-				if ( 'name' == $column ) {
696
-					$value = esc_html( $user->display_name );
697
-				} elseif ( 'email' == $column ) {
698
-					$value = sanitize_email( $user->user_email );
699
-				} elseif ( is_callable( array( $table, $method ) ) ) {
700
-					$value = wp_strip_all_tags( $table->$method( $user ) );
701
-				}
695
+                if ( 'name' == $column ) {
696
+                    $value = esc_html( $user->display_name );
697
+                } elseif ( 'email' == $column ) {
698
+                    $value = sanitize_email( $user->user_email );
699
+                } elseif ( is_callable( array( $table, $method ) ) ) {
700
+                    $value = wp_strip_all_tags( $table->$method( $user ) );
701
+                }
702 702
 
703
-				if ( empty( $value ) ) {
704
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
705
-				}
703
+                if ( empty( $value ) ) {
704
+                    $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
705
+                }
706 706
 
707
-				$row[] = $value;
707
+                $row[] = $value;
708 708
 
709
-			}
709
+            }
710 710
 
711
-			fputcsv( $output, $row );
712
-		}
711
+            fputcsv( $output, $row );
712
+        }
713 713
 
714
-		fclose( $output );
715
-		exit;
714
+        fclose( $output );
715
+        exit;
716 716
 
717
-	}
717
+    }
718 718
 
719
-	/**
719
+    /**
720 720
      * Installs a plugin.
721
-	 *
722
-	 * @param array $data
721
+     *
722
+     * @param array $data
723 723
      */
724 724
     public function admin_install_plugin( $data ) {
725 725
 
726
-		if ( ! empty( $data['plugins'] ) ) {
727
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
728
-			wp_cache_flush();
726
+        if ( ! empty( $data['plugins'] ) ) {
727
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
728
+            wp_cache_flush();
729 729
 
730
-			foreach ( $data['plugins'] as $slug => $file ) {
731
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
732
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
733
-				$installed  = $upgrader->install( $plugin_zip );
730
+            foreach ( $data['plugins'] as $slug => $file ) {
731
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
732
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
733
+                $installed  = $upgrader->install( $plugin_zip );
734 734
 
735
-				if ( ! is_wp_error( $installed ) && $installed ) {
736
-					activate_plugin( $file, '', false, true );
737
-				} else {
738
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
739
-				}
735
+                if ( ! is_wp_error( $installed ) && $installed ) {
736
+                    activate_plugin( $file, '', false, true );
737
+                } else {
738
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
739
+                }
740 740
 }
741 741
 }
742 742
 
743
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
744
-		wp_safe_redirect( $redirect );
745
-		exit;
743
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
744
+        wp_safe_redirect( $redirect );
745
+        exit;
746 746
 
747
-	}
747
+    }
748 748
 
749
-	/**
749
+    /**
750 750
      * Connects a gateway.
751
-	 *
752
-	 * @param array $data
751
+     *
752
+     * @param array $data
753 753
      */
754 754
     public function admin_connect_gateway( $data ) {
755 755
 
756
-		if ( ! empty( $data['plugin'] ) ) {
756
+        if ( ! empty( $data['plugin'] ) ) {
757 757
 
758
-			$gateway     = sanitize_key( $data['plugin'] );
759
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
758
+            $gateway     = sanitize_key( $data['plugin'] );
759
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
760 760
 
761
-			if ( ! empty( $connect_url ) ) {
762
-				wp_redirect( $connect_url );
763
-				exit;
764
-			}
761
+            if ( ! empty( $connect_url ) ) {
762
+                wp_redirect( $connect_url );
763
+                exit;
764
+            }
765 765
 
766
-			if ( 'stripe' == $data['plugin'] ) {
767
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
768
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
769
-				wp_cache_flush();
766
+            if ( 'stripe' == $data['plugin'] ) {
767
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
768
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
769
+                wp_cache_flush();
770 770
 
771
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
772
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
773
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
774
-					$upgrader->install( $plugin_zip );
775
-				}
771
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
772
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
773
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
774
+                    $upgrader->install( $plugin_zip );
775
+                }
776 776
 
777
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
778
-			}
777
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
778
+            }
779 779
 
780
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
781
-			if ( ! empty( $connect_url ) ) {
782
-				wp_redirect( $connect_url );
783
-				exit;
784
-			}
780
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
781
+            if ( ! empty( $connect_url ) ) {
782
+                wp_redirect( $connect_url );
783
+                exit;
784
+            }
785 785
 }
786 786
 
787
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
788
-		wp_safe_redirect( $redirect );
789
-		exit;
787
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
788
+        wp_safe_redirect( $redirect );
789
+        exit;
790 790
 
791
-	}
791
+    }
792 792
 
793
-	/**
793
+    /**
794 794
      * Recalculates discounts.
795
-	 *
795
+     *
796 796
      */
797 797
     public function admin_recalculate_discounts() {
798
-		global $wpdb;
798
+        global $wpdb;
799 799
 
800
-		// Fetch all invoices that have discount codes.
801
-		$table    = $wpdb->prefix . 'getpaid_invoices';
802
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
800
+        // Fetch all invoices that have discount codes.
801
+        $table    = $wpdb->prefix . 'getpaid_invoices';
802
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
803 803
 
804
-		foreach ( $invoices as $invoice ) {
804
+        foreach ( $invoices as $invoice ) {
805 805
 
806
-			$invoice = new WPInv_Invoice( $invoice );
806
+            $invoice = new WPInv_Invoice( $invoice );
807 807
 
808
-			if ( ! $invoice->exists() ) {
809
-				continue;
810
-			}
808
+            if ( ! $invoice->exists() ) {
809
+                continue;
810
+            }
811 811
 
812
-			// Abort if the discount does not exist or does not apply here.
813
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
814
-			if ( ! $discount->exists() ) {
815
-				continue;
816
-			}
812
+            // Abort if the discount does not exist or does not apply here.
813
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
814
+            if ( ! $discount->exists() ) {
815
+                continue;
816
+            }
817 817
 
818
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
819
-			$invoice->recalculate_total();
818
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
819
+            $invoice->recalculate_total();
820 820
 
821
-			if ( $invoice->get_total_discount() > 0 ) {
822
-				$invoice->save();
823
-			}
821
+            if ( $invoice->get_total_discount() > 0 ) {
822
+                $invoice->save();
823
+            }
824 824
 }
825 825
 
826
-		// Show an admin message.
827
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
826
+        // Show an admin message.
827
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
828 828
 
829
-		// Redirect the admin.
830
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
831
-		exit;
829
+        // Redirect the admin.
830
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
831
+        exit;
832 832
 
833
-	}
833
+    }
834 834
 
835 835
     /**
836
-	 * Returns an array of admin notices.
837
-	 *
838
-	 * @since       1.0.19
836
+     * Returns an array of admin notices.
837
+     *
838
+     * @since       1.0.19
839 839
      * @return array
840
-	 */
841
-	public function get_notices() {
842
-		$notices = get_option( 'wpinv_admin_notices' );
840
+     */
841
+    public function get_notices() {
842
+        $notices = get_option( 'wpinv_admin_notices' );
843 843
         return is_array( $notices ) ? $notices : array();
844
-	}
844
+    }
845 845
 
846
-	/**
847
-	 * Checks if we have any admin notices.
848
-	 *
849
-	 * @since       2.0.4
846
+    /**
847
+     * Checks if we have any admin notices.
848
+     *
849
+     * @since       2.0.4
850 850
      * @return array
851
-	 */
852
-	public function has_notices() {
853
-		return count( $this->get_notices() ) > 0;
854
-	}
855
-
856
-	/**
857
-	 * Clears all admin notices
858
-	 *
859
-	 * @access      public
860
-	 * @since       1.0.19
861
-	 */
862
-	public function clear_notices() {
863
-		delete_option( 'wpinv_admin_notices' );
864
-	}
865
-
866
-	/**
867
-	 * Saves a new admin notice
868
-	 *
869
-	 * @access      public
870
-	 * @since       1.0.19
871
-	 */
872
-	public function save_notice( $type, $message ) {
873
-		$notices = $this->get_notices();
874
-
875
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
876
-			$notices[ $type ] = array();
877
-		}
878
-
879
-		$notices[ $type ][] = $message;
880
-
881
-		update_option( 'wpinv_admin_notices', $notices );
882
-	}
883
-
884
-	/**
885
-	 * Displays a success notice
886
-	 *
887
-	 * @param       string $msg The message to qeue.
888
-	 * @access      public
889
-	 * @since       1.0.19
890
-	 */
891
-	public function show_success( $msg ) {
892
-		$this->save_notice( 'success', $msg );
893
-	}
894
-
895
-	/**
896
-	 * Displays a error notice
897
-	 *
898
-	 * @access      public
899
-	 * @param       string $msg The message to qeue.
900
-	 * @since       1.0.19
901
-	 */
902
-	public function show_error( $msg ) {
903
-		$this->save_notice( 'error', $msg );
904
-	}
905
-
906
-	/**
907
-	 * Displays a warning notice
908
-	 *
909
-	 * @access      public
910
-	 * @param       string $msg The message to qeue.
911
-	 * @since       1.0.19
912
-	 */
913
-	public function show_warning( $msg ) {
914
-		$this->save_notice( 'warning', $msg );
915
-	}
916
-
917
-	/**
918
-	 * Displays a info notice
919
-	 *
920
-	 * @access      public
921
-	 * @param       string $msg The message to qeue.
922
-	 * @since       1.0.19
923
-	 */
924
-	public function show_info( $msg ) {
925
-		$this->save_notice( 'info', $msg );
926
-	}
927
-
928
-	/**
929
-	 * Show notices
930
-	 *
931
-	 * @access      public
932
-	 * @since       1.0.19
933
-	 */
934
-	public function show_notices() {
851
+     */
852
+    public function has_notices() {
853
+        return count( $this->get_notices() ) > 0;
854
+    }
855
+
856
+    /**
857
+     * Clears all admin notices
858
+     *
859
+     * @access      public
860
+     * @since       1.0.19
861
+     */
862
+    public function clear_notices() {
863
+        delete_option( 'wpinv_admin_notices' );
864
+    }
865
+
866
+    /**
867
+     * Saves a new admin notice
868
+     *
869
+     * @access      public
870
+     * @since       1.0.19
871
+     */
872
+    public function save_notice( $type, $message ) {
873
+        $notices = $this->get_notices();
874
+
875
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
876
+            $notices[ $type ] = array();
877
+        }
878
+
879
+        $notices[ $type ][] = $message;
880
+
881
+        update_option( 'wpinv_admin_notices', $notices );
882
+    }
883
+
884
+    /**
885
+     * Displays a success notice
886
+     *
887
+     * @param       string $msg The message to qeue.
888
+     * @access      public
889
+     * @since       1.0.19
890
+     */
891
+    public function show_success( $msg ) {
892
+        $this->save_notice( 'success', $msg );
893
+    }
894
+
895
+    /**
896
+     * Displays a error notice
897
+     *
898
+     * @access      public
899
+     * @param       string $msg The message to qeue.
900
+     * @since       1.0.19
901
+     */
902
+    public function show_error( $msg ) {
903
+        $this->save_notice( 'error', $msg );
904
+    }
905
+
906
+    /**
907
+     * Displays a warning notice
908
+     *
909
+     * @access      public
910
+     * @param       string $msg The message to qeue.
911
+     * @since       1.0.19
912
+     */
913
+    public function show_warning( $msg ) {
914
+        $this->save_notice( 'warning', $msg );
915
+    }
916
+
917
+    /**
918
+     * Displays a info notice
919
+     *
920
+     * @access      public
921
+     * @param       string $msg The message to qeue.
922
+     * @since       1.0.19
923
+     */
924
+    public function show_info( $msg ) {
925
+        $this->save_notice( 'info', $msg );
926
+    }
927
+
928
+    /**
929
+     * Show notices
930
+     *
931
+     * @access      public
932
+     * @since       1.0.19
933
+     */
934
+    public function show_notices() {
935 935
 
936 936
         $notices = $this->get_notices();
937 937
         $this->clear_notices();
938 938
 
939
-		foreach ( $notices as $type => $messages ) {
939
+        foreach ( $notices as $type => $messages ) {
940 940
 
941
-			if ( ! is_array( $messages ) ) {
942
-				continue;
943
-			}
941
+            if ( ! is_array( $messages ) ) {
942
+                continue;
943
+            }
944 944
 
945 945
             $type  = esc_attr( $type );
946
-			foreach ( $messages as $message ) {
947
-				echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
946
+            foreach ( $messages as $message ) {
947
+                echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
948 948
             }
949 949
 }
950 950
 
951
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
952
-
953
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
954
-				$url     = wp_nonce_url(
955
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
956
-					'getpaid-nonce',
957
-					'getpaid-nonce'
958
-				);
959
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
960
-				$message2 = __( 'Generate Pages', 'invoicing' );
961
-				echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
962
-				break;
963
-			}
951
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
952
+
953
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
954
+                $url     = wp_nonce_url(
955
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
956
+                    'getpaid-nonce',
957
+                    'getpaid-nonce'
958
+                );
959
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
960
+                $message2 = __( 'Generate Pages', 'invoicing' );
961
+                echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
962
+                break;
963
+            }
964 964
 }
965 965
 
966
-	}
966
+    }
967 967
 
968 968
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-checkout.php 1 patch
Indentation   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -12,184 +12,184 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Checkout {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Payment_Form_Submission
17
-	 */
18
-	protected $payment_form_submission;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 *
23
-	 * @param GetPaid_Payment_Form_Submission $submission
24
-	 */
25
-	public function __construct( $submission ) {
26
-		$this->payment_form_submission = $submission;
27
-	}
28
-
29
-	/**
30
-	 * Processes the checkout.
31
-	 *
32
-	 */
33
-	public function process_checkout() {
34
-
35
-		// Validate the submission.
36
-		$this->validate_submission();
37
-
38
-		// Prepare the invoice.
39
-		$items      = $this->get_submission_items();
40
-		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
42
-		$prepared   = $this->prepare_submission_data_for_saving();
43
-
44
-		$this->prepare_billing_info( $invoice );
45
-
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
47
-
48
-		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
50
-		$invoice->recalculate_total();
15
+    /**
16
+     * @var GetPaid_Payment_Form_Submission
17
+     */
18
+    protected $payment_form_submission;
19
+
20
+    /**
21
+     * Class constructor.
22
+     *
23
+     * @param GetPaid_Payment_Form_Submission $submission
24
+     */
25
+    public function __construct( $submission ) {
26
+        $this->payment_form_submission = $submission;
27
+    }
28
+
29
+    /**
30
+     * Processes the checkout.
31
+     *
32
+     */
33
+    public function process_checkout() {
34
+
35
+        // Validate the submission.
36
+        $this->validate_submission();
37
+
38
+        // Prepare the invoice.
39
+        $items      = $this->get_submission_items();
40
+        $invoice    = $this->get_submission_invoice();
41
+        $invoice    = $this->process_submission_invoice( $invoice, $items );
42
+        $prepared   = $this->prepare_submission_data_for_saving();
43
+
44
+        $this->prepare_billing_info( $invoice );
45
+
46
+        $shipping   = $this->prepare_shipping_info( $invoice );
47
+
48
+        // Save the invoice.
49
+        $invoice->set_is_viewed( true );
50
+        $invoice->recalculate_total();
51 51
         $invoice->save();
52 52
 
53
-		do_action( 'getpaid_checkout_invoice_updated', $invoice );
53
+        do_action( 'getpaid_checkout_invoice_updated', $invoice );
54 54
 
55
-		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
57
-	}
55
+        // Send to the gateway.
56
+        $this->post_process_submission( $invoice, $prepared, $shipping );
57
+    }
58 58
 
59
-	/**
60
-	 * Validates the submission.
61
-	 *
62
-	 */
63
-	protected function validate_submission() {
59
+    /**
60
+     * Validates the submission.
61
+     *
62
+     */
63
+    protected function validate_submission() {
64 64
 
65
-		$submission = $this->payment_form_submission;
66
-		$data       = $submission->get_data();
65
+        $submission = $this->payment_form_submission;
66
+        $data       = $submission->get_data();
67 67
 
68
-		// Do we have an error?
68
+        // Do we have an error?
69 69
         if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
70
+            wp_send_json_error( $submission->last_error );
71 71
         }
72 72
 
73
-		// We need a billing email.
73
+        // We need a billing email.
74 74
         if ( ! $submission->has_billing_email() ) {
75 75
             wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
76
-		}
76
+        }
77 77
 
78
-		// Non-recurring gateways should not be allowed to process recurring invoices.
79
-		if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
-		}
78
+        // Non-recurring gateways should not be allowed to process recurring invoices.
79
+        if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
+            wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
+        }
82 82
 
83
-		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wp_send_json_error( __( 'The selected payment gateway is not active', 'invoicing' ) );
86
-		}
83
+        // Ensure the gateway is active.
84
+        if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
+            wp_send_json_error( __( 'The selected payment gateway is not active', 'invoicing' ) );
86
+        }
87 87
 
88
-		// Clear any existing errors.
89
-		wpinv_clear_errors();
88
+        // Clear any existing errors.
89
+        wpinv_clear_errors();
90 90
 
91
-		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
91
+        // Allow themes and plugins to hook to errors
92
+        do_action( 'getpaid_checkout_error_checks', $submission );
93 93
 
94
-		// Do we have any errors?
94
+        // Do we have any errors?
95 95
         if ( wpinv_get_errors() ) {
96 96
             wp_send_json_error( getpaid_get_errors_html() );
97
-		}
97
+        }
98 98
 
99
-	}
99
+    }
100 100
 
101
-	/**
102
-	 * Retrieves submission items.
103
-	 *
104
-	 * @return GetPaid_Form_Item[]
105
-	 */
106
-	protected function get_submission_items() {
101
+    /**
102
+     * Retrieves submission items.
103
+     *
104
+     * @return GetPaid_Form_Item[]
105
+     */
106
+    protected function get_submission_items() {
107 107
 
108
-		$items = $this->payment_form_submission->get_items();
108
+        $items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111 111
         if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112 112
             wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
113
-		}
114
-
115
-		return $items;
116
-	}
117
-
118
-	/**
119
-	 * Retrieves submission invoice.
120
-	 *
121
-	 * @return WPInv_Invoice
122
-	 */
123
-	protected function get_submission_invoice() {
124
-		$submission = $this->payment_form_submission;
125
-
126
-		if ( ! $submission->has_invoice() ) {
127
-			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
129
-			return $invoice;
130 113
         }
131 114
 
132
-		$invoice = $submission->get_invoice();
115
+        return $items;
116
+    }
117
+
118
+    /**
119
+     * Retrieves submission invoice.
120
+     *
121
+     * @return WPInv_Invoice
122
+     */
123
+    protected function get_submission_invoice() {
124
+        $submission = $this->payment_form_submission;
133 125
 
134
-		// Make sure that it is neither paid or refunded.
135
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
-		}
126
+        if ( ! $submission->has_invoice() ) {
127
+            $invoice = new WPInv_Invoice();
128
+            $invoice->set_created_via( 'payment_form' );
129
+            return $invoice;
130
+        }
138 131
 
139
-		return $invoice;
140
-	}
132
+        $invoice = $submission->get_invoice();
141 133
 
142
-	/**
143
-	 * Processes the submission invoice.
144
-	 *
145
-	 * @param WPInv_Invoice $invoice
146
-	 * @param GetPaid_Form_Item[] $items
147
-	 * @return WPInv_Invoice
148
-	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
134
+        // Make sure that it is neither paid or refunded.
135
+        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
+            wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
+        }
150 138
 
151
-		$submission = $this->payment_form_submission;
139
+        return $invoice;
140
+    }
152 141
 
153
-		// Set-up the invoice details.
154
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
155
-		$invoice->set_user_id( $this->get_submission_customer() );
156
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
142
+    /**
143
+     * Processes the submission invoice.
144
+     *
145
+     * @param WPInv_Invoice $invoice
146
+     * @param GetPaid_Form_Item[] $items
147
+     * @return WPInv_Invoice
148
+     */
149
+    protected function process_submission_invoice( $invoice, $items ) {
150
+
151
+        $submission = $this->payment_form_submission;
152
+
153
+        // Set-up the invoice details.
154
+        $invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
155
+        $invoice->set_user_id( $this->get_submission_customer() );
156
+        $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
157 157
         $invoice->set_items( $items );
158 158
         $invoice->set_fees( $submission->get_fees() );
159 159
         $invoice->set_taxes( $submission->get_taxes() );
160
-		$invoice->set_discounts( $submission->get_discounts() );
161
-		$invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) );
162
-		$invoice->set_currency( $submission->get_currency() );
160
+        $invoice->set_discounts( $submission->get_discounts() );
161
+        $invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) );
162
+        $invoice->set_currency( $submission->get_currency() );
163 163
 
164
-		if ( $submission->has_shipping() ) {
165
-			$invoice->set_shipping( $submission->get_shipping() );
166
-		}
164
+        if ( $submission->has_shipping() ) {
165
+            $invoice->set_shipping( $submission->get_shipping() );
166
+        }
167 167
 
168
-		$address_confirmed = $submission->get_field( 'confirm-address' );
169
-		$invoice->set_address_confirmed( ! empty( $address_confirmed ) );
168
+        $address_confirmed = $submission->get_field( 'confirm-address' );
169
+        $invoice->set_address_confirmed( ! empty( $address_confirmed ) );
170 170
 
171
-		if ( $submission->has_discount_code() ) {
171
+        if ( $submission->has_discount_code() ) {
172 172
             $invoice->set_discount_code( $submission->get_discount_code() );
173
-		}
174
-
175
-		getpaid_maybe_add_default_address( $invoice );
176
-		return $invoice;
177
-	}
178
-
179
-	/**
180
-	 * Retrieves the submission's customer.
181
-	 *
182
-	 * @return int The customer id.
183
-	 */
184
-	protected function get_submission_customer() {
185
-		$submission = $this->payment_form_submission;
186
-
187
-		// If this is an existing invoice...
188
-		if ( $submission->has_invoice() ) {
189
-			return $submission->get_invoice()->get_user_id();
190
-		}
191
-
192
-		// (Maybe) create the user.
173
+        }
174
+
175
+        getpaid_maybe_add_default_address( $invoice );
176
+        return $invoice;
177
+    }
178
+
179
+    /**
180
+     * Retrieves the submission's customer.
181
+     *
182
+     * @return int The customer id.
183
+     */
184
+    protected function get_submission_customer() {
185
+        $submission = $this->payment_form_submission;
186
+
187
+        // If this is an existing invoice...
188
+        if ( $submission->has_invoice() ) {
189
+            return $submission->get_invoice()->get_user_id();
190
+        }
191
+
192
+        // (Maybe) create the user.
193 193
         $user = get_current_user_id();
194 194
 
195 195
         if ( empty( $user ) ) {
@@ -197,16 +197,16 @@  discard block
 block discarded – undo
197 197
         }
198 198
 
199 199
         if ( empty( $user ) ) {
200
-			$name = array( $submission->get_field( 'wpinv_first_name', 'billing' ), $submission->get_field( 'wpinv_last_name', 'billing' ) );
201
-			$name = implode( '', array_filter( $name ) );
200
+            $name = array( $submission->get_field( 'wpinv_first_name', 'billing' ), $submission->get_field( 'wpinv_last_name', 'billing' ) );
201
+            $name = implode( '', array_filter( $name ) );
202 202
             $user = wpinv_create_user( $submission->get_billing_email(), $name );
203 203
 
204
-			// (Maybe) send new user notification.
205
-			$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
206
-			if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
207
-				wp_send_new_user_notifications( $user, 'user' );
208
-			}
209
-		}
204
+            // (Maybe) send new user notification.
205
+            $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
206
+            if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
207
+                wp_send_new_user_notifications( $user, 'user' );
208
+            }
209
+        }
210 210
 
211 211
         if ( is_wp_error( $user ) ) {
212 212
             wp_send_json_error( $user->get_error_message() );
@@ -214,49 +214,49 @@  discard block
 block discarded – undo
214 214
 
215 215
         if ( is_numeric( $user ) ) {
216 216
             return $user;
217
-		}
217
+        }
218 218
 
219
-		return $user->ID;
219
+        return $user->ID;
220 220
 
221
-	}
221
+    }
222 222
 
223
-	/**
223
+    /**
224 224
      * Prepares submission data for saving to the database.
225 225
      *
226
-	 * @return array
226
+     * @return array
227 227
      */
228 228
     public function prepare_submission_data_for_saving() {
229 229
 
230
-		$submission = $this->payment_form_submission;
230
+        $submission = $this->payment_form_submission;
231 231
 
232
-		// Prepared submission details.
232
+        // Prepared submission details.
233 233
         $prepared = array(
234
-			'all'  => array(),
235
-			'meta' => array(),
236
-		);
234
+            'all'  => array(),
235
+            'meta' => array(),
236
+        );
237 237
 
238 238
         // Raw submission details.
239
-		$data     = $submission->get_data();
239
+        $data     = $submission->get_data();
240 240
 
241
-		// Loop through the submitted details.
241
+        // Loop through the submitted details.
242 242
         foreach ( $submission->get_payment_form()->get_elements() as $field ) {
243 243
 
244
-			// Skip premade fields.
244
+            // Skip premade fields.
245 245
             if ( ! empty( $field['premade'] ) ) {
246 246
                 continue;
247 247
             }
248 248
 
249
-			// Ensure address is provided.
250
-			if ( 'address' === $field['type'] ) {
249
+            // Ensure address is provided.
250
+            if ( 'address' === $field['type'] ) {
251 251
                 $address_type = isset( $field['address_type'] ) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing';
252 252
 
253
-				foreach ( $field['fields'] as $address_field ) {
253
+                foreach ( $field['fields'] as $address_field ) {
254 254
 
255
-					if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
256
-						wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
257
-					}
258
-			}
259
-		}
255
+                    if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
256
+                        wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
257
+                    }
258
+            }
259
+        }
260 260
 
261 261
             // If it is required and not set, abort.
262 262
             if ( ! $submission->is_required_field_set( $field ) ) {
@@ -266,31 +266,31 @@  discard block
 block discarded – undo
266 266
             // Handle misc fields.
267 267
             if ( isset( $data[ $field['id'] ] ) ) {
268 268
 
269
-				// Uploads.
270
-				if ( 'file_upload' === $field['type'] ) {
271
-					$max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] );
269
+                // Uploads.
270
+                if ( 'file_upload' === $field['type'] ) {
271
+                    $max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] );
272 272
 
273
-					if ( count( $data[ $field['id'] ] ) > $max_file_num ) {
274
-						wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) );
275
-					}
273
+                    if ( count( $data[ $field['id'] ] ) > $max_file_num ) {
274
+                        wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) );
275
+                    }
276 276
 
277
-					$value = array();
277
+                    $value = array();
278 278
 
279
-					foreach ( $data[ $field['id'] ] as $url => $name ) {
280
-						$value[] = sprintf(
281
-							'<a href="%s" target="_blank">%s</a>',
282
-							esc_url_raw( $url ),
283
-							esc_html( $name )
284
-						);
285
-					}
279
+                    foreach ( $data[ $field['id'] ] as $url => $name ) {
280
+                        $value[] = sprintf(
281
+                            '<a href="%s" target="_blank">%s</a>',
282
+                            esc_url_raw( $url ),
283
+                            esc_html( $name )
284
+                        );
285
+                    }
286 286
 
287
-					$value = implode( ' | ', $value );
287
+                    $value = implode( ' | ', $value );
288 288
 
289
-				} elseif ( 'checkbox' === $field['type'] ) {
290
-					$value = ! empty( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
291
-				} else {
292
-					$value = wp_kses_post( $data[ $field['id'] ] );
293
-				}
289
+                } elseif ( 'checkbox' === $field['type'] ) {
290
+                    $value = ! empty( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
291
+                } else {
292
+                    $value = wp_kses_post( $data[ $field['id'] ] );
293
+                }
294 294
 
295 295
                 $label = $field['id'];
296 296
 
@@ -298,192 +298,192 @@  discard block
 block discarded – undo
298 298
                     $label = $field['label'];
299 299
                 }
300 300
 
301
-				if ( ! empty( $field['add_meta'] ) ) {
302
-					$prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
303
-				}
304
-				$prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
301
+                if ( ! empty( $field['add_meta'] ) ) {
302
+                    $prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
303
+                }
304
+                $prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
305 305
 
306 306
             }
307
-		}
307
+        }
308 308
 
309
-		return $prepared;
309
+        return $prepared;
310 310
 
311
-	}
311
+    }
312 312
 
313
-	/**
313
+    /**
314 314
      * Retrieves address details.
315 315
      *
316
-	 * @return array
317
-	 * @param WPInv_Invoice $invoice
318
-	 * @param string $type
316
+     * @return array
317
+     * @param WPInv_Invoice $invoice
318
+     * @param string $type
319 319
      */
320 320
     public function prepare_address_details( $invoice, $type = 'billing' ) {
321 321
 
322
-		$data     = $this->payment_form_submission->get_data();
323
-		$type     = sanitize_key( $type );
324
-		$address  = array();
325
-		$prepared = array();
322
+        $data     = $this->payment_form_submission->get_data();
323
+        $type     = sanitize_key( $type );
324
+        $address  = array();
325
+        $prepared = array();
326 326
 
327
-		if ( ! empty( $data[ $type ] ) ) {
328
-			$address = $data[ $type ];
329
-		}
327
+        if ( ! empty( $data[ $type ] ) ) {
328
+            $address = $data[ $type ];
329
+        }
330 330
 
331
-		// Clean address details.
332
-		foreach ( $address as $key => $value ) {
333
-			$key             = sanitize_key( $key );
334
-			$key             = str_replace( 'wpinv_', '', $key );
335
-			$value           = wpinv_clean( $value );
336
-			$prepared[ $key ] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
337
-		}
331
+        // Clean address details.
332
+        foreach ( $address as $key => $value ) {
333
+            $key             = sanitize_key( $key );
334
+            $key             = str_replace( 'wpinv_', '', $key );
335
+            $value           = wpinv_clean( $value );
336
+            $prepared[ $key ] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
337
+        }
338 338
 
339
-		// Filter address details.
340
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
339
+        // Filter address details.
340
+        $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
341 341
 
342
-		// Remove non-whitelisted values.
343
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
342
+        // Remove non-whitelisted values.
343
+        return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
344 344
 
345
-	}
345
+    }
346 346
 
347
-	/**
347
+    /**
348 348
      * Prepares the billing details.
349 349
      *
350
-	 * @return array
351
-	 * @param WPInv_Invoice $invoice
350
+     * @return array
351
+     * @param WPInv_Invoice $invoice
352 352
      */
353 353
     protected function prepare_billing_info( &$invoice ) {
354 354
 
355
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
355
+        $billing_address = $this->prepare_address_details( $invoice, 'billing' );
356 356
 
357
-		// Update the invoice with the billing details.
358
-		$invoice->set_props( $billing_address );
357
+        // Update the invoice with the billing details.
358
+        $invoice->set_props( $billing_address );
359 359
 
360
-	}
360
+    }
361 361
 
362
-	/**
362
+    /**
363 363
      * Prepares the shipping details.
364 364
      *
365
-	 * @return array
366
-	 * @param WPInv_Invoice $invoice
365
+     * @return array
366
+     * @param WPInv_Invoice $invoice
367 367
      */
368 368
     protected function prepare_shipping_info( $invoice ) {
369 369
 
370
-		$data = $this->payment_form_submission->get_data();
370
+        $data = $this->payment_form_submission->get_data();
371 371
 
372
-		if ( empty( $data['same-shipping-address'] ) ) {
373
-			return $this->prepare_address_details( $invoice, 'shipping' );
374
-		}
372
+        if ( empty( $data['same-shipping-address'] ) ) {
373
+            return $this->prepare_address_details( $invoice, 'shipping' );
374
+        }
375 375
 
376
-		return $this->prepare_address_details( $invoice, 'billing' );
376
+        return $this->prepare_address_details( $invoice, 'billing' );
377 377
 
378
-	}
378
+    }
379 379
 
380
-	/**
381
-	 * Confirms the submission is valid and send users to the gateway.
382
-	 *
383
-	 * @param WPInv_Invoice $invoice
384
-	 * @param array $prepared_payment_form_data
385
-	 * @param array $shipping
386
-	 */
387
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
380
+    /**
381
+     * Confirms the submission is valid and send users to the gateway.
382
+     *
383
+     * @param WPInv_Invoice $invoice
384
+     * @param array $prepared_payment_form_data
385
+     * @param array $shipping
386
+     */
387
+    protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
388 388
 
389
-		// Ensure the invoice exists.
389
+        // Ensure the invoice exists.
390 390
         if ( ! $invoice->exists() ) {
391 391
             wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
392 392
         }
393 393
 
394
-		// Save payment form data.
395
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
394
+        // Save payment form data.
395
+        $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
396 396
         delete_post_meta( $invoice->get_id(), 'payment_form_data' );
397
-		delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
398
-		if ( ! empty( $prepared_payment_form_data ) ) {
397
+        delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
398
+        if ( ! empty( $prepared_payment_form_data ) ) {
399 399
 
400
-			if ( ! empty( $prepared_payment_form_data['all'] ) ) {
401
-				update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
402
-			}
400
+            if ( ! empty( $prepared_payment_form_data['all'] ) ) {
401
+                update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
402
+            }
403 403
 
404
-			if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
405
-				update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
406
-			}
407
-		}
404
+            if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
405
+                update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
406
+            }
407
+        }
408 408
 
409
-		// Save payment form data.
410
-		$shipping = apply_filters( 'getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission );
409
+        // Save payment form data.
410
+        $shipping = apply_filters( 'getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission );
411 411
         if ( ! empty( $shipping ) ) {
412 412
             update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
413
-		}
413
+        }
414 414
 
415
-		// Backwards compatibility.
415
+        // Backwards compatibility.
416 416
         add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
417 417
 
418
-		try {
419
-			$this->process_payment( $invoice );
420
-		} catch ( Exception $e ) {
421
-			wpinv_set_error( 'payment_error', $e->getMessage() );
422
-		}
418
+        try {
419
+            $this->process_payment( $invoice );
420
+        } catch ( Exception $e ) {
421
+            wpinv_set_error( 'payment_error', $e->getMessage() );
422
+        }
423 423
 
424 424
         // If we are here, there was an error.
425
-		wpinv_send_back_to_checkout( $invoice );
425
+        wpinv_send_back_to_checkout( $invoice );
426 426
 
427
-	}
427
+    }
428 428
 
429
-	/**
430
-	 * Processes the actual payment.
431
-	 *
432
-	 * @param WPInv_Invoice $invoice
433
-	 */
434
-	protected function process_payment( $invoice ) {
429
+    /**
430
+     * Processes the actual payment.
431
+     *
432
+     * @param WPInv_Invoice $invoice
433
+     */
434
+    protected function process_payment( $invoice ) {
435 435
 
436
-		// Clear any checkout errors.
437
-		wpinv_clear_errors();
436
+        // Clear any checkout errors.
437
+        wpinv_clear_errors();
438 438
 
439
-		// No need to send free invoices to the gateway.
440
-		if ( $invoice->is_free() ) {
441
-			$this->process_free_payment( $invoice );
442
-		}
439
+        // No need to send free invoices to the gateway.
440
+        if ( $invoice->is_free() ) {
441
+            $this->process_free_payment( $invoice );
442
+        }
443 443
 
444
-		$submission = $this->payment_form_submission;
444
+        $submission = $this->payment_form_submission;
445 445
 
446
-		// Fires before sending to the gateway.
447
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
446
+        // Fires before sending to the gateway.
447
+        do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
448 448
 
449
-		// Allow the sumission data to be modified before it is sent to the gateway.
450
-		$submission_data    = $submission->get_data();
451
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
452
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
449
+        // Allow the sumission data to be modified before it is sent to the gateway.
450
+        $submission_data    = $submission->get_data();
451
+        $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
452
+        $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
453 453
 
454
-		// Validate the currency.
455
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
456
-			wpinv_set_error( 'invalid_currency' );
457
-		}
454
+        // Validate the currency.
455
+        if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
456
+            wpinv_set_error( 'invalid_currency' );
457
+        }
458 458
 
459
-		// Check to see if we have any errors.
460
-		if ( wpinv_get_errors() ) {
461
-			wpinv_send_back_to_checkout( $invoice );
462
-		}
459
+        // Check to see if we have any errors.
460
+        if ( wpinv_get_errors() ) {
461
+            wpinv_send_back_to_checkout( $invoice );
462
+        }
463 463
 
464
-		// Send info to the gateway for payment processing
465
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
464
+        // Send info to the gateway for payment processing
465
+        do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
466 466
 
467
-		// Backwards compatibility.
468
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
467
+        // Backwards compatibility.
468
+        wpinv_send_to_gateway( $submission_gateway, $invoice );
469 469
 
470
-	}
470
+    }
471 471
 
472
-	/**
473
-	 * Marks the invoice as paid in case the checkout is free.
474
-	 *
475
-	 * @param WPInv_Invoice $invoice
476
-	 */
477
-	protected function process_free_payment( $invoice ) {
472
+    /**
473
+     * Marks the invoice as paid in case the checkout is free.
474
+     *
475
+     * @param WPInv_Invoice $invoice
476
+     */
477
+    protected function process_free_payment( $invoice ) {
478 478
 
479
-		$invoice->set_gateway( 'none' );
480
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
481
-		$invoice->mark_paid();
482
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
479
+        $invoice->set_gateway( 'none' );
480
+        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
481
+        $invoice->mark_paid();
482
+        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
483 483
 
484
-	}
484
+    }
485 485
 
486
-	/**
486
+    /**
487 487
      * Sends a redrect response to payment details.
488 488
      *
489 489
      */
Please login to merge, or discard this patch.