@@ -12,218 +12,218 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class GetPaid_Graph_Downloader { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var GetPaid_Reports_Report |
|
| 17 | - */ |
|
| 18 | - public $handler; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Class constructor. |
|
| 22 | - * |
|
| 23 | - */ |
|
| 24 | - public function __construct() { |
|
| 25 | - $this->handler = new GetPaid_Reports_Report(); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Prepares the datastore handler. |
|
| 30 | - * |
|
| 31 | - * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts |
|
| 32 | - */ |
|
| 33 | - public function prepare_handler( $graph ) { |
|
| 34 | - |
|
| 35 | - if ( empty( $this->handler->views[ $graph ] ) ) { |
|
| 36 | - wp_die( esc_html__( 'Invalid Graph', 'invoicing' ), 400 ); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - return new $this->handler->views[ $graph ]['class'](); |
|
| 40 | - |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Prepares the output stream. |
|
| 45 | - * |
|
| 46 | - * @return resource |
|
| 47 | - */ |
|
| 48 | - public function prepare_output() { |
|
| 49 | - |
|
| 50 | - $output = fopen( 'php://output', 'w' ); |
|
| 51 | - |
|
| 52 | - if ( false === $output ) { |
|
| 53 | - wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return $output; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Prepares the file type. |
|
| 61 | - * |
|
| 62 | - * @return string |
|
| 63 | - */ |
|
| 64 | - public function prepare_file_type( $graph ) { |
|
| 65 | - |
|
| 66 | - $file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] ); |
|
| 67 | - $file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) ); |
|
| 68 | - |
|
| 69 | - header( "Content-Type:application/$file_type" ); |
|
| 70 | - header( "Content-Disposition:attachment;filename=$file_name.$file_type" ); |
|
| 71 | - |
|
| 72 | - return $file_type; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Handles the actual download. |
|
| 77 | - * |
|
| 78 | - */ |
|
| 79 | - public function download( $graph ) { |
|
| 80 | - global $wpdb; |
|
| 81 | - |
|
| 82 | - $handler = $this->prepare_handler( $graph ); |
|
| 83 | - $stream = $this->prepare_output(); |
|
| 84 | - $stats = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) ); |
|
| 85 | - $headers = array( $handler->field, 'total', 'total_raw' ); |
|
| 86 | - $file_type = $this->prepare_file_type( $graph ); |
|
| 87 | - |
|
| 88 | - if ( 'csv' == $file_type ) { |
|
| 89 | - $this->download_csv( $stats, $stream, $headers ); |
|
| 90 | - } elseif ( 'xml' == $file_type ) { |
|
| 91 | - $this->download_xml( $stats, $stream, $headers ); |
|
| 92 | - } else { |
|
| 93 | - $this->download_json( $stats, $stream, $headers ); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - fclose( $stream ); |
|
| 97 | - exit; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Downloads graph as csv |
|
| 102 | - * |
|
| 103 | - * @param array $stats The stats being downloaded. |
|
| 104 | - * @param resource $stream The stream to output to. |
|
| 105 | - * @param array $headers The fields to stream. |
|
| 106 | - * @since 1.0.19 |
|
| 107 | - */ |
|
| 108 | - public function download_csv( $stats, $stream, $headers ) { |
|
| 109 | - |
|
| 110 | - // Output the csv column headers. |
|
| 111 | - fputcsv( $stream, $headers ); |
|
| 112 | - |
|
| 113 | - // Loop through |
|
| 114 | - foreach ( $stats as $stat ) { |
|
| 115 | - $row = array_values( $this->prepare_row( $stat, $headers ) ); |
|
| 116 | - $row = array_map( 'maybe_serialize', $row ); |
|
| 117 | - fputcsv( $stream, $row ); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Downloads graph as json |
|
| 124 | - * |
|
| 125 | - * @param array $stats The stats being downloaded. |
|
| 126 | - * @param resource $stream The stream to output to. |
|
| 127 | - * @param array $headers The fields to stream. |
|
| 128 | - * @since 1.0.19 |
|
| 129 | - */ |
|
| 130 | - public function download_json( $stats, $stream, $headers ) { |
|
| 131 | - |
|
| 132 | - $prepared = array(); |
|
| 133 | - |
|
| 134 | - // Loop through |
|
| 135 | - foreach ( $stats as $stat ) { |
|
| 136 | - $prepared[] = $this->prepare_row( $stat, $headers ); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - fwrite( $stream, wp_json_encode( $prepared ) ); |
|
| 140 | - |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Downloads graph as xml |
|
| 145 | - * |
|
| 146 | - * @param array $stats The stats being downloaded. |
|
| 147 | - * @param resource $stream The stream to output to. |
|
| 148 | - * @param array $headers The fields to stream. |
|
| 149 | - * @since 1.0.19 |
|
| 150 | - */ |
|
| 151 | - public function download_xml( $stats, $stream, $headers ) { |
|
| 152 | - |
|
| 153 | - $prepared = array(); |
|
| 154 | - |
|
| 155 | - // Loop through |
|
| 156 | - foreach ( $stats as $stat ) { |
|
| 157 | - $prepared[] = $this->prepare_row( $stat, $headers ); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - $xml = new SimpleXMLElement( '<?xml version="1.0"?><data></data>' ); |
|
| 161 | - $this->convert_array_xml( $prepared, $xml ); |
|
| 162 | - |
|
| 163 | - fwrite( $stream, $xml->asXML() ); |
|
| 164 | - |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Converts stats array to xml |
|
| 169 | - * |
|
| 170 | - * @access public |
|
| 171 | - * @since 1.0.19 |
|
| 172 | - */ |
|
| 173 | - public function convert_array_xml( $data, $xml ) { |
|
| 174 | - |
|
| 175 | - // Loop through |
|
| 176 | - foreach ( $data as $key => $value ) { |
|
| 177 | - |
|
| 178 | - $key = preg_replace( '/[^A-Za-z0-9_\-]/', '', $key ); |
|
| 179 | - |
|
| 180 | - if ( is_array( $value ) ) { |
|
| 181 | - |
|
| 182 | - if ( is_numeric( $key ) ) { |
|
| 183 | - $key = 'item' . $key; //dealing with <0/>..<n/> issues |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - $subnode = $xml->addChild( $key ); |
|
| 187 | - $this->convert_array_xml( $value, $subnode ); |
|
| 188 | - |
|
| 189 | - } else { |
|
| 190 | - $xml->addChild( $key, htmlspecialchars( $value ) ); |
|
| 191 | - } |
|
| 15 | + /** |
|
| 16 | + * @var GetPaid_Reports_Report |
|
| 17 | + */ |
|
| 18 | + public $handler; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Class constructor. |
|
| 22 | + * |
|
| 23 | + */ |
|
| 24 | + public function __construct() { |
|
| 25 | + $this->handler = new GetPaid_Reports_Report(); |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Prepares the datastore handler. |
|
| 30 | + * |
|
| 31 | + * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts |
|
| 32 | + */ |
|
| 33 | + public function prepare_handler( $graph ) { |
|
| 34 | + |
|
| 35 | + if ( empty( $this->handler->views[ $graph ] ) ) { |
|
| 36 | + wp_die( esc_html__( 'Invalid Graph', 'invoicing' ), 400 ); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + return new $this->handler->views[ $graph ]['class'](); |
|
| 40 | + |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Prepares the output stream. |
|
| 45 | + * |
|
| 46 | + * @return resource |
|
| 47 | + */ |
|
| 48 | + public function prepare_output() { |
|
| 49 | + |
|
| 50 | + $output = fopen( 'php://output', 'w' ); |
|
| 51 | + |
|
| 52 | + if ( false === $output ) { |
|
| 53 | + wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return $output; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Prepares the file type. |
|
| 61 | + * |
|
| 62 | + * @return string |
|
| 63 | + */ |
|
| 64 | + public function prepare_file_type( $graph ) { |
|
| 65 | + |
|
| 66 | + $file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] ); |
|
| 67 | + $file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) ); |
|
| 68 | + |
|
| 69 | + header( "Content-Type:application/$file_type" ); |
|
| 70 | + header( "Content-Disposition:attachment;filename=$file_name.$file_type" ); |
|
| 71 | + |
|
| 72 | + return $file_type; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Handles the actual download. |
|
| 77 | + * |
|
| 78 | + */ |
|
| 79 | + public function download( $graph ) { |
|
| 80 | + global $wpdb; |
|
| 81 | + |
|
| 82 | + $handler = $this->prepare_handler( $graph ); |
|
| 83 | + $stream = $this->prepare_output(); |
|
| 84 | + $stats = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) ); |
|
| 85 | + $headers = array( $handler->field, 'total', 'total_raw' ); |
|
| 86 | + $file_type = $this->prepare_file_type( $graph ); |
|
| 87 | + |
|
| 88 | + if ( 'csv' == $file_type ) { |
|
| 89 | + $this->download_csv( $stats, $stream, $headers ); |
|
| 90 | + } elseif ( 'xml' == $file_type ) { |
|
| 91 | + $this->download_xml( $stats, $stream, $headers ); |
|
| 92 | + } else { |
|
| 93 | + $this->download_json( $stats, $stream, $headers ); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + fclose( $stream ); |
|
| 97 | + exit; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Downloads graph as csv |
|
| 102 | + * |
|
| 103 | + * @param array $stats The stats being downloaded. |
|
| 104 | + * @param resource $stream The stream to output to. |
|
| 105 | + * @param array $headers The fields to stream. |
|
| 106 | + * @since 1.0.19 |
|
| 107 | + */ |
|
| 108 | + public function download_csv( $stats, $stream, $headers ) { |
|
| 109 | + |
|
| 110 | + // Output the csv column headers. |
|
| 111 | + fputcsv( $stream, $headers ); |
|
| 112 | + |
|
| 113 | + // Loop through |
|
| 114 | + foreach ( $stats as $stat ) { |
|
| 115 | + $row = array_values( $this->prepare_row( $stat, $headers ) ); |
|
| 116 | + $row = array_map( 'maybe_serialize', $row ); |
|
| 117 | + fputcsv( $stream, $row ); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Downloads graph as json |
|
| 124 | + * |
|
| 125 | + * @param array $stats The stats being downloaded. |
|
| 126 | + * @param resource $stream The stream to output to. |
|
| 127 | + * @param array $headers The fields to stream. |
|
| 128 | + * @since 1.0.19 |
|
| 129 | + */ |
|
| 130 | + public function download_json( $stats, $stream, $headers ) { |
|
| 131 | + |
|
| 132 | + $prepared = array(); |
|
| 133 | + |
|
| 134 | + // Loop through |
|
| 135 | + foreach ( $stats as $stat ) { |
|
| 136 | + $prepared[] = $this->prepare_row( $stat, $headers ); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + fwrite( $stream, wp_json_encode( $prepared ) ); |
|
| 140 | + |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Downloads graph as xml |
|
| 145 | + * |
|
| 146 | + * @param array $stats The stats being downloaded. |
|
| 147 | + * @param resource $stream The stream to output to. |
|
| 148 | + * @param array $headers The fields to stream. |
|
| 149 | + * @since 1.0.19 |
|
| 150 | + */ |
|
| 151 | + public function download_xml( $stats, $stream, $headers ) { |
|
| 152 | + |
|
| 153 | + $prepared = array(); |
|
| 154 | + |
|
| 155 | + // Loop through |
|
| 156 | + foreach ( $stats as $stat ) { |
|
| 157 | + $prepared[] = $this->prepare_row( $stat, $headers ); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + $xml = new SimpleXMLElement( '<?xml version="1.0"?><data></data>' ); |
|
| 161 | + $this->convert_array_xml( $prepared, $xml ); |
|
| 162 | + |
|
| 163 | + fwrite( $stream, $xml->asXML() ); |
|
| 164 | + |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Converts stats array to xml |
|
| 169 | + * |
|
| 170 | + * @access public |
|
| 171 | + * @since 1.0.19 |
|
| 172 | + */ |
|
| 173 | + public function convert_array_xml( $data, $xml ) { |
|
| 174 | + |
|
| 175 | + // Loop through |
|
| 176 | + foreach ( $data as $key => $value ) { |
|
| 177 | + |
|
| 178 | + $key = preg_replace( '/[^A-Za-z0-9_\-]/', '', $key ); |
|
| 179 | + |
|
| 180 | + if ( is_array( $value ) ) { |
|
| 181 | + |
|
| 182 | + if ( is_numeric( $key ) ) { |
|
| 183 | + $key = 'item' . $key; //dealing with <0/>..<n/> issues |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + $subnode = $xml->addChild( $key ); |
|
| 187 | + $this->convert_array_xml( $value, $subnode ); |
|
| 188 | + |
|
| 189 | + } else { |
|
| 190 | + $xml->addChild( $key, htmlspecialchars( $value ) ); |
|
| 191 | + } |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - } |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * Prepares a single row for download. |
|
| 198 | - * |
|
| 199 | - * @param stdClass|array $row The row to prepare.. |
|
| 200 | - * @param array $fields The fields to stream. |
|
| 201 | - * @since 1.0.19 |
|
| 202 | - * @return array |
|
| 203 | - */ |
|
| 204 | - public function prepare_row( $row, $fields ) { |
|
| 196 | + /** |
|
| 197 | + * Prepares a single row for download. |
|
| 198 | + * |
|
| 199 | + * @param stdClass|array $row The row to prepare.. |
|
| 200 | + * @param array $fields The fields to stream. |
|
| 201 | + * @since 1.0.19 |
|
| 202 | + * @return array |
|
| 203 | + */ |
|
| 204 | + public function prepare_row( $row, $fields ) { |
|
| 205 | 205 | |
| 206 | - $prepared = array(); |
|
| 207 | - $row = (array) $row; |
|
| 206 | + $prepared = array(); |
|
| 207 | + $row = (array) $row; |
|
| 208 | 208 | |
| 209 | - foreach ( $fields as $field ) { |
|
| 209 | + foreach ( $fields as $field ) { |
|
| 210 | 210 | |
| 211 | - if ( $field === 'total' ) { |
|
| 212 | - $prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES ); |
|
| 213 | - continue; |
|
| 214 | - } |
|
| 211 | + if ( $field === 'total' ) { |
|
| 212 | + $prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES ); |
|
| 213 | + continue; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - if ( $field === 'total_raw' ) { |
|
| 217 | - $prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) ); |
|
| 218 | - continue; |
|
| 219 | - } |
|
| 216 | + if ( $field === 'total_raw' ) { |
|
| 217 | + $prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) ); |
|
| 218 | + continue; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - $prepared[ $field ] = strip_tags( $row[ $field ] ); |
|
| 221 | + $prepared[ $field ] = strip_tags( $row[ $field ] ); |
|
| 222 | 222 | |
| 223 | - } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - return $prepared; |
|
| 226 | - } |
|
| 225 | + return $prepared; |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | 228 | |
| 229 | 229 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * GetPaid_Graph_Downloader Class. |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts |
| 32 | 32 | */ |
| 33 | - public function prepare_handler( $graph ) { |
|
| 33 | + public function prepare_handler($graph) { |
|
| 34 | 34 | |
| 35 | - if ( empty( $this->handler->views[ $graph ] ) ) { |
|
| 36 | - wp_die( esc_html__( 'Invalid Graph', 'invoicing' ), 400 ); |
|
| 35 | + if (empty($this->handler->views[$graph])) { |
|
| 36 | + wp_die(esc_html__('Invalid Graph', 'invoicing'), 400); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - return new $this->handler->views[ $graph ]['class'](); |
|
| 39 | + return new $this->handler->views[$graph]['class'](); |
|
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function prepare_output() { |
| 49 | 49 | |
| 50 | - $output = fopen( 'php://output', 'w' ); |
|
| 50 | + $output = fopen('php://output', 'w'); |
|
| 51 | 51 | |
| 52 | - if ( false === $output ) { |
|
| 53 | - wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
| 52 | + if (false === $output) { |
|
| 53 | + wp_die(esc_html__('Unsupported server', 'invoicing'), 500); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | return $output; |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return string |
| 63 | 63 | */ |
| 64 | - public function prepare_file_type( $graph ) { |
|
| 64 | + public function prepare_file_type($graph) { |
|
| 65 | 65 | |
| 66 | - $file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] ); |
|
| 67 | - $file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) ); |
|
| 66 | + $file_type = empty($_REQUEST['file_type']) ? 'csv' : sanitize_text_field($_REQUEST['file_type']); |
|
| 67 | + $file_name = wpinv_sanitize_key("getpaid-$graph-" . current_time('Y-m-d')); |
|
| 68 | 68 | |
| 69 | - header( "Content-Type:application/$file_type" ); |
|
| 70 | - header( "Content-Disposition:attachment;filename=$file_name.$file_type" ); |
|
| 69 | + header("Content-Type:application/$file_type"); |
|
| 70 | + header("Content-Disposition:attachment;filename=$file_name.$file_type"); |
|
| 71 | 71 | |
| 72 | 72 | return $file_type; |
| 73 | 73 | } |
@@ -76,24 +76,24 @@ discard block |
||
| 76 | 76 | * Handles the actual download. |
| 77 | 77 | * |
| 78 | 78 | */ |
| 79 | - public function download( $graph ) { |
|
| 79 | + public function download($graph) { |
|
| 80 | 80 | global $wpdb; |
| 81 | 81 | |
| 82 | - $handler = $this->prepare_handler( $graph ); |
|
| 82 | + $handler = $this->prepare_handler($graph); |
|
| 83 | 83 | $stream = $this->prepare_output(); |
| 84 | - $stats = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) ); |
|
| 85 | - $headers = array( $handler->field, 'total', 'total_raw' ); |
|
| 86 | - $file_type = $this->prepare_file_type( $graph ); |
|
| 87 | - |
|
| 88 | - if ( 'csv' == $file_type ) { |
|
| 89 | - $this->download_csv( $stats, $stream, $headers ); |
|
| 90 | - } elseif ( 'xml' == $file_type ) { |
|
| 91 | - $this->download_xml( $stats, $stream, $headers ); |
|
| 84 | + $stats = $wpdb->get_results($handler->get_sql($handler->get_range())); |
|
| 85 | + $headers = array($handler->field, 'total', 'total_raw'); |
|
| 86 | + $file_type = $this->prepare_file_type($graph); |
|
| 87 | + |
|
| 88 | + if ('csv' == $file_type) { |
|
| 89 | + $this->download_csv($stats, $stream, $headers); |
|
| 90 | + } elseif ('xml' == $file_type) { |
|
| 91 | + $this->download_xml($stats, $stream, $headers); |
|
| 92 | 92 | } else { |
| 93 | - $this->download_json( $stats, $stream, $headers ); |
|
| 93 | + $this->download_json($stats, $stream, $headers); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - fclose( $stream ); |
|
| 96 | + fclose($stream); |
|
| 97 | 97 | exit; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -105,16 +105,16 @@ discard block |
||
| 105 | 105 | * @param array $headers The fields to stream. |
| 106 | 106 | * @since 1.0.19 |
| 107 | 107 | */ |
| 108 | - public function download_csv( $stats, $stream, $headers ) { |
|
| 108 | + public function download_csv($stats, $stream, $headers) { |
|
| 109 | 109 | |
| 110 | 110 | // Output the csv column headers. |
| 111 | - fputcsv( $stream, $headers ); |
|
| 111 | + fputcsv($stream, $headers); |
|
| 112 | 112 | |
| 113 | 113 | // Loop through |
| 114 | - foreach ( $stats as $stat ) { |
|
| 115 | - $row = array_values( $this->prepare_row( $stat, $headers ) ); |
|
| 116 | - $row = array_map( 'maybe_serialize', $row ); |
|
| 117 | - fputcsv( $stream, $row ); |
|
| 114 | + foreach ($stats as $stat) { |
|
| 115 | + $row = array_values($this->prepare_row($stat, $headers)); |
|
| 116 | + $row = array_map('maybe_serialize', $row); |
|
| 117 | + fputcsv($stream, $row); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | } |
@@ -127,16 +127,16 @@ discard block |
||
| 127 | 127 | * @param array $headers The fields to stream. |
| 128 | 128 | * @since 1.0.19 |
| 129 | 129 | */ |
| 130 | - public function download_json( $stats, $stream, $headers ) { |
|
| 130 | + public function download_json($stats, $stream, $headers) { |
|
| 131 | 131 | |
| 132 | 132 | $prepared = array(); |
| 133 | 133 | |
| 134 | 134 | // Loop through |
| 135 | - foreach ( $stats as $stat ) { |
|
| 136 | - $prepared[] = $this->prepare_row( $stat, $headers ); |
|
| 135 | + foreach ($stats as $stat) { |
|
| 136 | + $prepared[] = $this->prepare_row($stat, $headers); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - fwrite( $stream, wp_json_encode( $prepared ) ); |
|
| 139 | + fwrite($stream, wp_json_encode($prepared)); |
|
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | |
@@ -148,19 +148,19 @@ discard block |
||
| 148 | 148 | * @param array $headers The fields to stream. |
| 149 | 149 | * @since 1.0.19 |
| 150 | 150 | */ |
| 151 | - public function download_xml( $stats, $stream, $headers ) { |
|
| 151 | + public function download_xml($stats, $stream, $headers) { |
|
| 152 | 152 | |
| 153 | 153 | $prepared = array(); |
| 154 | 154 | |
| 155 | 155 | // Loop through |
| 156 | - foreach ( $stats as $stat ) { |
|
| 157 | - $prepared[] = $this->prepare_row( $stat, $headers ); |
|
| 156 | + foreach ($stats as $stat) { |
|
| 157 | + $prepared[] = $this->prepare_row($stat, $headers); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $xml = new SimpleXMLElement( '<?xml version="1.0"?><data></data>' ); |
|
| 161 | - $this->convert_array_xml( $prepared, $xml ); |
|
| 160 | + $xml = new SimpleXMLElement('<?xml version="1.0"?><data></data>'); |
|
| 161 | + $this->convert_array_xml($prepared, $xml); |
|
| 162 | 162 | |
| 163 | - fwrite( $stream, $xml->asXML() ); |
|
| 163 | + fwrite($stream, $xml->asXML()); |
|
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | |
@@ -170,24 +170,24 @@ discard block |
||
| 170 | 170 | * @access public |
| 171 | 171 | * @since 1.0.19 |
| 172 | 172 | */ |
| 173 | - public function convert_array_xml( $data, $xml ) { |
|
| 173 | + public function convert_array_xml($data, $xml) { |
|
| 174 | 174 | |
| 175 | 175 | // Loop through |
| 176 | - foreach ( $data as $key => $value ) { |
|
| 176 | + foreach ($data as $key => $value) { |
|
| 177 | 177 | |
| 178 | - $key = preg_replace( '/[^A-Za-z0-9_\-]/', '', $key ); |
|
| 178 | + $key = preg_replace('/[^A-Za-z0-9_\-]/', '', $key); |
|
| 179 | 179 | |
| 180 | - if ( is_array( $value ) ) { |
|
| 180 | + if (is_array($value)) { |
|
| 181 | 181 | |
| 182 | - if ( is_numeric( $key ) ) { |
|
| 182 | + if (is_numeric($key)) { |
|
| 183 | 183 | $key = 'item' . $key; //dealing with <0/>..<n/> issues |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - $subnode = $xml->addChild( $key ); |
|
| 187 | - $this->convert_array_xml( $value, $subnode ); |
|
| 186 | + $subnode = $xml->addChild($key); |
|
| 187 | + $this->convert_array_xml($value, $subnode); |
|
| 188 | 188 | |
| 189 | 189 | } else { |
| 190 | - $xml->addChild( $key, htmlspecialchars( $value ) ); |
|
| 190 | + $xml->addChild($key, htmlspecialchars($value)); |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
@@ -201,24 +201,24 @@ discard block |
||
| 201 | 201 | * @since 1.0.19 |
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | - public function prepare_row( $row, $fields ) { |
|
| 204 | + public function prepare_row($row, $fields) { |
|
| 205 | 205 | |
| 206 | 206 | $prepared = array(); |
| 207 | 207 | $row = (array) $row; |
| 208 | 208 | |
| 209 | - foreach ( $fields as $field ) { |
|
| 209 | + foreach ($fields as $field) { |
|
| 210 | 210 | |
| 211 | - if ( $field === 'total' ) { |
|
| 212 | - $prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES ); |
|
| 211 | + if ($field === 'total') { |
|
| 212 | + $prepared[$field] = html_entity_decode(strip_tags(wpinv_price($row['total'])), ENT_QUOTES); |
|
| 213 | 213 | continue; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( $field === 'total_raw' ) { |
|
| 217 | - $prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) ); |
|
| 216 | + if ($field === 'total_raw') { |
|
| 217 | + $prepared[$field] = wpinv_round_amount(wpinv_sanitize_amount($row['total'])); |
|
| 218 | 218 | continue; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $prepared[ $field ] = strip_tags( $row[ $field ] ); |
|
| 221 | + $prepared[$field] = strip_tags($row[$field]); |
|
| 222 | 222 | |
| 223 | 223 | } |
| 224 | 224 | |
@@ -42,92 +42,92 @@ discard block |
||
| 42 | 42 | <tr class="wpinv-item wpinv-item-<?php echo esc_attr( $invoice->get_status() ); ?>"> |
| 43 | 43 | <?php |
| 44 | 44 | |
| 45 | - foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
| 45 | + foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
| 46 | 46 | |
| 47 | - $column_id = sanitize_html_class( $column_id ); |
|
| 48 | - $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
| 47 | + $column_id = sanitize_html_class( $column_id ); |
|
| 48 | + $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
| 49 | 49 | |
| 50 | - echo "<td class='" . esc_attr( $column_id . ' ' . $class ) . "'>"; |
|
| 51 | - switch ( $column_id ) { |
|
| 50 | + echo "<td class='" . esc_attr( $column_id . ' ' . $class ) . "'>"; |
|
| 51 | + switch ( $column_id ) { |
|
| 52 | 52 | |
| 53 | - case 'invoice-number': |
|
| 54 | - echo wp_kses_post( wpinv_invoice_link( $invoice ) ); |
|
| 55 | - break; |
|
| 53 | + case 'invoice-number': |
|
| 54 | + echo wp_kses_post( wpinv_invoice_link( $invoice ) ); |
|
| 55 | + break; |
|
| 56 | 56 | |
| 57 | - case 'created-date': |
|
| 58 | - echo esc_html( getpaid_format_date_value( $invoice->get_date_created() ) ); |
|
| 59 | - break; |
|
| 57 | + case 'created-date': |
|
| 58 | + echo esc_html( getpaid_format_date_value( $invoice->get_date_created() ) ); |
|
| 59 | + break; |
|
| 60 | 60 | |
| 61 | - case 'payment-date': |
|
| 62 | - if ( $invoice->needs_payment() ) { |
|
| 63 | - echo '—'; |
|
| 64 | - } else { |
|
| 65 | - echo esc_html( getpaid_format_date_value( $invoice->get_date_completed() ) ); |
|
| 66 | - } |
|
| 61 | + case 'payment-date': |
|
| 62 | + if ( $invoice->needs_payment() ) { |
|
| 63 | + echo '—'; |
|
| 64 | + } else { |
|
| 65 | + echo esc_html( getpaid_format_date_value( $invoice->get_date_completed() ) ); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - break; |
|
| 68 | + break; |
|
| 69 | 69 | |
| 70 | - case 'invoice-status': |
|
| 71 | - echo wp_kses_post( $invoice->get_status_label_html() ); |
|
| 70 | + case 'invoice-status': |
|
| 71 | + echo wp_kses_post( $invoice->get_status_label_html() ); |
|
| 72 | 72 | |
| 73 | - break; |
|
| 73 | + break; |
|
| 74 | 74 | |
| 75 | - case 'invoice-total': |
|
| 76 | - wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); |
|
| 75 | + case 'invoice-total': |
|
| 76 | + wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); |
|
| 77 | 77 | |
| 78 | - break; |
|
| 78 | + break; |
|
| 79 | 79 | |
| 80 | - case 'invoice-actions': |
|
| 81 | - $actions = array( |
|
| 80 | + case 'invoice-actions': |
|
| 81 | + $actions = array( |
|
| 82 | 82 | |
| 83 | - 'pay' => array( |
|
| 84 | - 'url' => $invoice->get_checkout_payment_url(), |
|
| 85 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 86 | - 'class' => 'btn-success', |
|
| 87 | - ), |
|
| 83 | + 'pay' => array( |
|
| 84 | + 'url' => $invoice->get_checkout_payment_url(), |
|
| 85 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 86 | + 'class' => 'btn-success', |
|
| 87 | + ), |
|
| 88 | 88 | |
| 89 | - 'print' => array( |
|
| 90 | - 'url' => $invoice->get_view_url(), |
|
| 91 | - 'name' => __( 'View', 'invoicing' ), |
|
| 92 | - 'class' => 'btn-secondary', |
|
| 93 | - 'attrs' => 'target="_blank"', |
|
| 94 | - ), |
|
| 95 | - ); |
|
| 89 | + 'print' => array( |
|
| 90 | + 'url' => $invoice->get_view_url(), |
|
| 91 | + 'name' => __( 'View', 'invoicing' ), |
|
| 92 | + 'class' => 'btn-secondary', |
|
| 93 | + 'attrs' => 'target="_blank"', |
|
| 94 | + ), |
|
| 95 | + ); |
|
| 96 | 96 | |
| 97 | - if ( ! $invoice->needs_payment() ) { |
|
| 98 | - unset( $actions['pay'] ); |
|
| 99 | - } |
|
| 97 | + if ( ! $invoice->needs_payment() ) { |
|
| 98 | + unset( $actions['pay'] ); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - if ( $invoice->needs_payment() ) { |
|
| 102 | - $actions['delete'] = array( |
|
| 103 | - 'url' => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ), |
|
| 104 | - 'name' => __( 'Delete', 'invoicing' ), |
|
| 105 | - 'class' => 'btn-danger', |
|
| 106 | - ); |
|
| 107 | - } |
|
| 101 | + if ( $invoice->needs_payment() ) { |
|
| 102 | + $actions['delete'] = array( |
|
| 103 | + 'url' => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ), |
|
| 104 | + 'name' => __( 'Delete', 'invoicing' ), |
|
| 105 | + 'class' => 'btn-danger', |
|
| 106 | + ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
| 109 | + $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
| 110 | 110 | |
| 111 | - foreach ( $actions as $key => $action ) { |
|
| 112 | - $class = ! empty( $action['class'] ) ? sanitize_html_class( $action['class'] ) : ''; |
|
| 113 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . esc_attr( $class . ' ' . sanitize_html_class( $key ) ) . '" ' . ( ! empty( $action['attrs'] ) ? esc_html( $action['attrs'] ) : '' ) . '>' . esc_attr( $action['name'] ) . '</a>'; |
|
| 114 | - } |
|
| 111 | + foreach ( $actions as $key => $action ) { |
|
| 112 | + $class = ! empty( $action['class'] ) ? sanitize_html_class( $action['class'] ) : ''; |
|
| 113 | + echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . esc_attr( $class . ' ' . sanitize_html_class( $key ) ) . '" ' . ( ! empty( $action['attrs'] ) ? esc_html( $action['attrs'] ) : '' ) . '>' . esc_attr( $action['name'] ) . '</a>'; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - break; |
|
| 116 | + break; |
|
| 117 | 117 | |
| 118 | - default: |
|
| 119 | - do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
| 120 | - break; |
|
| 118 | + default: |
|
| 119 | + do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
| 120 | + break; |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | - } |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
| 125 | + do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
| 126 | 126 | |
| 127 | - echo '</td>'; |
|
| 127 | + echo '</td>'; |
|
| 128 | 128 | |
| 129 | - endforeach; |
|
| 130 | - ?> |
|
| 129 | + endforeach; |
|
| 130 | + ?> |
|
| 131 | 131 | </tr> |
| 132 | 132 | |
| 133 | 133 | <?php endforeach; ?> |
@@ -141,18 +141,18 @@ discard block |
||
| 141 | 141 | <?php if ( 1 < $invoices->max_num_pages ) : ?> |
| 142 | 142 | <div class="invoicing-Pagination"> |
| 143 | 143 | <?php |
| 144 | - $big = 999999; |
|
| 145 | - |
|
| 146 | - echo wp_kses_post( |
|
| 147 | - paginate_links( |
|
| 148 | - array( |
|
| 149 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 150 | - 'format' => '?paged=%#%', |
|
| 151 | - 'total' => $invoices->max_num_pages, |
|
| 152 | - ) |
|
| 153 | - ) |
|
| 144 | + $big = 999999; |
|
| 145 | + |
|
| 146 | + echo wp_kses_post( |
|
| 147 | + paginate_links( |
|
| 148 | + array( |
|
| 149 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 150 | + 'format' => '?paged=%#%', |
|
| 151 | + 'total' => $invoices->max_num_pages, |
|
| 152 | + ) |
|
| 153 | + ) |
|
| 154 | 154 | ); |
| 155 | - ?> |
|
| 155 | + ?> |
|
| 156 | 156 | </div> |
| 157 | 157 | <?php endif; ?> |
| 158 | 158 | |
@@ -7,13 +7,13 @@ discard block |
||
| 7 | 7 | * @version 1.0.19 |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -defined( 'ABSPATH' ) || exit; |
|
| 10 | +defined('ABSPATH') || exit; |
|
| 11 | 11 | |
| 12 | 12 | // Current page. |
| 13 | -$current_page = empty( $_GET['page'] ) ? 1 : absint( $_GET['page'] ); |
|
| 13 | +$current_page = empty($_GET['page']) ? 1 : absint($_GET['page']); |
|
| 14 | 14 | |
| 15 | 15 | // Fires before displaying user invoices. |
| 16 | -do_action( 'wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type ); |
|
| 16 | +do_action('wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); |
|
| 17 | 17 | |
| 18 | 18 | wpinv_print_errors(); |
| 19 | 19 | |
@@ -21,15 +21,15 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | <div class="table-responsive"> |
| 24 | - <table class="table table-bordered table-hover getpaid-user-invoices <?php echo esc_attr( $post_type ); ?>"> |
|
| 24 | + <table class="table table-bordered table-hover getpaid-user-invoices <?php echo esc_attr($post_type); ?>"> |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | <thead> |
| 28 | 28 | <tr> |
| 29 | 29 | |
| 30 | - <?php foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : ?> |
|
| 31 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo ( ! empty( $column_name['class'] ) ? sanitize_html_class( $column_name['class'] ) : ''); ?> border-bottom-0"> |
|
| 32 | - <span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span> |
|
| 30 | + <?php foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : ?> |
|
| 31 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? sanitize_html_class($column_name['class']) : ''); ?> border-bottom-0"> |
|
| 32 | + <span class="nobr"><?php echo esc_html($column_name['title']); ?></span> |
|
| 33 | 33 | </th> |
| 34 | 34 | <?php endforeach; ?> |
| 35 | 35 | |
@@ -39,43 +39,43 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | <tbody> |
| 42 | - <?php foreach ( $invoices->invoices as $invoice ) : ?> |
|
| 42 | + <?php foreach ($invoices->invoices as $invoice) : ?> |
|
| 43 | 43 | |
| 44 | - <tr class="wpinv-item wpinv-item-<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
| 44 | + <tr class="wpinv-item wpinv-item-<?php echo esc_attr($invoice->get_status()); ?>"> |
|
| 45 | 45 | <?php |
| 46 | 46 | |
| 47 | - foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
| 47 | + foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : |
|
| 48 | 48 | |
| 49 | - $column_id = sanitize_html_class( $column_id ); |
|
| 50 | - $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
| 49 | + $column_id = sanitize_html_class($column_id); |
|
| 50 | + $class = empty($column_name['class']) ? '' : sanitize_html_class($column_name['class']); |
|
| 51 | 51 | |
| 52 | - echo "<td class='" . esc_attr( $column_id . ' ' . $class ) . "'>"; |
|
| 53 | - switch ( $column_id ) { |
|
| 52 | + echo "<td class='" . esc_attr($column_id . ' ' . $class) . "'>"; |
|
| 53 | + switch ($column_id) { |
|
| 54 | 54 | |
| 55 | 55 | case 'invoice-number': |
| 56 | - echo wp_kses_post( wpinv_invoice_link( $invoice ) ); |
|
| 56 | + echo wp_kses_post(wpinv_invoice_link($invoice)); |
|
| 57 | 57 | break; |
| 58 | 58 | |
| 59 | 59 | case 'created-date': |
| 60 | - echo esc_html( getpaid_format_date_value( $invoice->get_date_created() ) ); |
|
| 60 | + echo esc_html(getpaid_format_date_value($invoice->get_date_created())); |
|
| 61 | 61 | break; |
| 62 | 62 | |
| 63 | 63 | case 'payment-date': |
| 64 | - if ( $invoice->needs_payment() ) { |
|
| 64 | + if ($invoice->needs_payment()) { |
|
| 65 | 65 | echo '—'; |
| 66 | 66 | } else { |
| 67 | - echo esc_html( getpaid_format_date_value( $invoice->get_date_completed() ) ); |
|
| 67 | + echo esc_html(getpaid_format_date_value($invoice->get_date_completed())); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | break; |
| 71 | 71 | |
| 72 | 72 | case 'invoice-status': |
| 73 | - echo wp_kses_post( $invoice->get_status_label_html() ); |
|
| 73 | + echo wp_kses_post($invoice->get_status_label_html()); |
|
| 74 | 74 | |
| 75 | 75 | break; |
| 76 | 76 | |
| 77 | 77 | case 'invoice-total': |
| 78 | - wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); |
|
| 78 | + wpinv_the_price($invoice->get_total(), $invoice->get_currency()); |
|
| 79 | 79 | |
| 80 | 80 | break; |
| 81 | 81 | |
@@ -84,47 +84,47 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | 'pay' => array( |
| 86 | 86 | 'url' => $invoice->get_checkout_payment_url(), |
| 87 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 87 | + 'name' => __('Pay Now', 'invoicing'), |
|
| 88 | 88 | 'class' => 'btn-success', |
| 89 | 89 | ), |
| 90 | 90 | |
| 91 | 91 | 'print' => array( |
| 92 | 92 | 'url' => $invoice->get_view_url(), |
| 93 | - 'name' => __( 'View', 'invoicing' ), |
|
| 93 | + 'name' => __('View', 'invoicing'), |
|
| 94 | 94 | 'class' => 'btn-secondary', |
| 95 | 95 | 'attrs' => 'target="_blank"', |
| 96 | 96 | ), |
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | - if ( ! $invoice->needs_payment() ) { |
|
| 100 | - unset( $actions['pay'] ); |
|
| 99 | + if (!$invoice->needs_payment()) { |
|
| 100 | + unset($actions['pay']); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if ( $invoice->needs_payment() ) { |
|
| 103 | + if ($invoice->needs_payment()) { |
|
| 104 | 104 | $actions['delete'] = array( |
| 105 | - 'url' => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ), |
|
| 106 | - 'name' => __( 'Delete', 'invoicing' ), |
|
| 105 | + 'url' => getpaid_get_authenticated_action_url('delete_invoice', add_query_arg('invoice_id', $invoice->get_id())), |
|
| 106 | + 'name' => __('Delete', 'invoicing'), |
|
| 107 | 107 | 'class' => 'btn-danger', |
| 108 | 108 | ); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
| 111 | + $actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice, $post_type); |
|
| 112 | 112 | |
| 113 | - foreach ( $actions as $key => $action ) { |
|
| 114 | - $class = ! empty( $action['class'] ) ? sanitize_html_class( $action['class'] ) : ''; |
|
| 115 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . esc_attr( $class . ' ' . sanitize_html_class( $key ) ) . '" ' . ( ! empty( $action['attrs'] ) ? esc_html( $action['attrs'] ) : '' ) . '>' . esc_attr( $action['name'] ) . '</a>'; |
|
| 113 | + foreach ($actions as $key => $action) { |
|
| 114 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
| 115 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm btn-block ' . esc_attr($class . ' ' . sanitize_html_class($key)) . '" ' . (!empty($action['attrs']) ? esc_html($action['attrs']) : '') . '>' . esc_attr($action['name']) . '</a>'; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | break; |
| 119 | 119 | |
| 120 | 120 | default: |
| 121 | - do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
| 121 | + do_action("wpinv_user_invoices_column_$column_id", $invoice); |
|
| 122 | 122 | break; |
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
| 127 | + do_action("wpinv_user_invoices_column_after_$column_id", $invoice); |
|
| 128 | 128 | |
| 129 | 129 | echo '</td>'; |
| 130 | 130 | |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | </table> |
| 139 | 139 | </div> |
| 140 | 140 | |
| 141 | - <?php do_action( 'wpinv_before_user_invoices_pagination' ); ?> |
|
| 141 | + <?php do_action('wpinv_before_user_invoices_pagination'); ?> |
|
| 142 | 142 | |
| 143 | - <?php if ( 1 < $invoices->max_num_pages ) : ?> |
|
| 143 | + <?php if (1 < $invoices->max_num_pages) : ?> |
|
| 144 | 144 | <div class="invoicing-Pagination"> |
| 145 | 145 | <?php |
| 146 | 146 | $big = 999999; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | echo wp_kses_post( |
| 149 | 149 | paginate_links( |
| 150 | 150 | array( |
| 151 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 151 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
| 152 | 152 | 'format' => '?paged=%#%', |
| 153 | 153 | 'total' => $invoices->max_num_pages, |
| 154 | 154 | ) |
@@ -158,4 +158,4 @@ discard block |
||
| 158 | 158 | </div> |
| 159 | 159 | <?php endif; ?> |
| 160 | 160 | |
| 161 | -<?php do_action( 'wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type ); ?> |
|
| 161 | +<?php do_action('wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); ?> |
|
@@ -8,45 +8,45 @@ discard block |
||
| 8 | 8 | * @var WPInv_Invoice $invoice |
| 9 | 9 | * @var array $columns |
| 10 | 10 | */ |
| 11 | -defined( 'ABSPATH' ) || exit; |
|
| 11 | +defined('ABSPATH') || exit; |
|
| 12 | 12 | |
| 13 | -$meta_data = getpaid_get_invoice_meta( $invoice ); |
|
| 13 | +$meta_data = getpaid_get_invoice_meta($invoice); |
|
| 14 | 14 | |
| 15 | -if ( isset( $meta_data['status'] ) ) { |
|
| 15 | +if (isset($meta_data['status'])) { |
|
| 16 | 16 | $meta_data['status']['value'] = $invoice->get_status_nicename(); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); |
|
| 19 | +do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); |
|
| 20 | 20 | |
| 21 | 21 | ?> |
| 22 | 22 | |
| 23 | 23 | <div id="wpinv-email-details"> |
| 24 | 24 | |
| 25 | 25 | <h3 class="invoice-details-title"> |
| 26 | - <?php echo sprintf( esc_html__( '%s Details', 'invoicing' ), esc_html( ucfirst( $invoice->get_invoice_quote_type() ) ) ); ?> |
|
| 26 | + <?php echo sprintf(esc_html__('%s Details', 'invoicing'), esc_html(ucfirst($invoice->get_invoice_quote_type()))); ?> |
|
| 27 | 27 | </h3> |
| 28 | 28 | |
| 29 | 29 | <table class="table table-bordered table-sm"> |
| 30 | 30 | |
| 31 | - <?php foreach ( $meta_data as $key => $data ) : ?> |
|
| 31 | + <?php foreach ($meta_data as $key => $data) : ?> |
|
| 32 | 32 | |
| 33 | - <?php if ( ! empty( $data['value'] ) ) : ?> |
|
| 33 | + <?php if (!empty($data['value'])) : ?> |
|
| 34 | 34 | |
| 35 | - <?php do_action( "getpaid_before_email_details_$key", $invoice, $data ); ?> |
|
| 35 | + <?php do_action("getpaid_before_email_details_$key", $invoice, $data); ?> |
|
| 36 | 36 | |
| 37 | - <tr class="getpaid-email-details-<?php echo esc_attr( $key ); ?>"> |
|
| 37 | + <tr class="getpaid-email-details-<?php echo esc_attr($key); ?>"> |
|
| 38 | 38 | |
| 39 | 39 | <td class="getpaid-lable-td"> |
| 40 | - <?php echo esc_html( $data['label'] ); ?> |
|
| 40 | + <?php echo esc_html($data['label']); ?> |
|
| 41 | 41 | </td> |
| 42 | 42 | |
| 43 | 43 | <td class="getpaid-value-td"> |
| 44 | - <span class="getpaid-invoice-meta-<?php echo esc_attr( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span> |
|
| 44 | + <span class="getpaid-invoice-meta-<?php echo esc_attr($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span> |
|
| 45 | 45 | </td> |
| 46 | 46 | |
| 47 | 47 | </tr> |
| 48 | 48 | |
| 49 | - <?php do_action( "getpaid_after_email_details_$key", $invoice, $data ); ?> |
|
| 49 | + <?php do_action("getpaid_after_email_details_$key", $invoice, $data); ?> |
|
| 50 | 50 | |
| 51 | 51 | <?php endif; ?> |
| 52 | 52 | |
@@ -56,4 +56,4 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | </div> |
| 58 | 58 | |
| 59 | -<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?> |
|
| 59 | +<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?> |
|
@@ -26,90 +26,90 @@ |
||
| 26 | 26 | |
| 27 | 27 | <?php |
| 28 | 28 | |
| 29 | - // Fires before printing a line item column. |
|
| 30 | - do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice ); |
|
| 29 | + // Fires before printing a line item column. |
|
| 30 | + do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice ); |
|
| 31 | 31 | |
| 32 | - // Item name. |
|
| 33 | - if ( 'name' === $column ) { |
|
| 32 | + // Item name. |
|
| 33 | + if ( 'name' === $column ) { |
|
| 34 | 34 | |
| 35 | - $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
| 35 | + $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
| 36 | 36 | |
| 37 | - if ( $has_featured_image ) { |
|
| 38 | - echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">'; |
|
| 39 | - echo '<div class="getpaid-form-item-image-container mr-2">'; |
|
| 40 | - echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
| 41 | - echo '</div>'; |
|
| 42 | - echo '<div class="getpaid-form-item-name-container">'; |
|
| 43 | - } |
|
| 37 | + if ( $has_featured_image ) { |
|
| 38 | + echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">'; |
|
| 39 | + echo '<div class="getpaid-form-item-image-container mr-2">'; |
|
| 40 | + echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
| 41 | + echo '</div>'; |
|
| 42 | + echo '<div class="getpaid-form-item-name-container">'; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // Display the name. |
|
| 46 | - echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>'; |
|
| 45 | + // Display the name. |
|
| 46 | + echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>'; |
|
| 47 | 47 | |
| 48 | - // And an optional description. |
|
| 49 | - $description = $item->get_description(); |
|
| 48 | + // And an optional description. |
|
| 49 | + $description = $item->get_description(); |
|
| 50 | 50 | |
| 51 | - if ( ! empty( $description ) ) { |
|
| 52 | - echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 53 | - } |
|
| 51 | + if ( ! empty( $description ) ) { |
|
| 52 | + echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // Fires before printing the line item actions. |
|
| 56 | - do_action( 'getpaid_before_invoice_line_item_actions', $item, $invoice ); |
|
| 55 | + // Fires before printing the line item actions. |
|
| 56 | + do_action( 'getpaid_before_invoice_line_item_actions', $item, $invoice ); |
|
| 57 | 57 | |
| 58 | - $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice ); |
|
| 58 | + $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice ); |
|
| 59 | 59 | |
| 60 | - if ( ! empty( $actions ) ) { |
|
| 60 | + if ( ! empty( $actions ) ) { |
|
| 61 | 61 | |
| 62 | - $sanitized = array(); |
|
| 63 | - foreach ( $actions as $key => $item_action ) { |
|
| 64 | - $key = sanitize_html_class( $key ); |
|
| 65 | - $item_action = wp_kses_post( $item_action ); |
|
| 66 | - $sanitized[] = "<span class='$key'>$item_action</span>"; |
|
| 67 | - } |
|
| 62 | + $sanitized = array(); |
|
| 63 | + foreach ( $actions as $key => $item_action ) { |
|
| 64 | + $key = sanitize_html_class( $key ); |
|
| 65 | + $item_action = wp_kses_post( $item_action ); |
|
| 66 | + $sanitized[] = "<span class='$key'>$item_action</span>"; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - echo "<small class='form-text getpaid-line-item-actions'>"; |
|
| 70 | - echo wp_kses_post( implode( ' | ', $sanitized ) ); |
|
| 71 | - echo '</small>'; |
|
| 69 | + echo "<small class='form-text getpaid-line-item-actions'>"; |
|
| 70 | + echo wp_kses_post( implode( ' | ', $sanitized ) ); |
|
| 71 | + echo '</small>'; |
|
| 72 | 72 | |
| 73 | - } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - if ( $has_featured_image ) { |
|
| 76 | - echo '</div>'; |
|
| 77 | - echo '</div>'; |
|
| 78 | - } |
|
| 79 | - } |
|
| 75 | + if ( $has_featured_image ) { |
|
| 76 | + echo '</div>'; |
|
| 77 | + echo '</div>'; |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // Item price. |
|
| 82 | - if ( 'price' === $column ) { |
|
| 81 | + // Item price. |
|
| 82 | + if ( 'price' === $column ) { |
|
| 83 | 83 | |
| 84 | - // Display the item price (or recurring price if this is a renewal invoice) |
|
| 85 | - $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
|
| 86 | - wpinv_the_price( $price, $invoice->get_currency() ); |
|
| 84 | + // Display the item price (or recurring price if this is a renewal invoice) |
|
| 85 | + $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
|
| 86 | + wpinv_the_price( $price, $invoice->get_currency() ); |
|
| 87 | 87 | |
| 88 | - } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - // Tax rate. |
|
| 91 | - if ( 'tax_rate' === $column ) { |
|
| 92 | - echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
| 93 | - } |
|
| 90 | + // Tax rate. |
|
| 91 | + if ( 'tax_rate' === $column ) { |
|
| 92 | + echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - // Item quantity. |
|
| 96 | - if ( 'quantity' === $column ) { |
|
| 97 | - echo (float) $item->get_quantity(); |
|
| 98 | - } |
|
| 95 | + // Item quantity. |
|
| 96 | + if ( 'quantity' === $column ) { |
|
| 97 | + echo (float) $item->get_quantity(); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - // Item sub total. |
|
| 101 | - if ( 'subtotal' === $column ) { |
|
| 102 | - $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
|
| 103 | - wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
| 104 | - } |
|
| 100 | + // Item sub total. |
|
| 101 | + if ( 'subtotal' === $column ) { |
|
| 102 | + $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
|
| 103 | + wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - // Fires when printing a line item column. |
|
| 107 | - do_action( "getpaid_invoice_line_item_$column", $item, $invoice ); |
|
| 106 | + // Fires when printing a line item column. |
|
| 107 | + do_action( "getpaid_invoice_line_item_$column", $item, $invoice ); |
|
| 108 | 108 | |
| 109 | - // Fires after printing a line item column. |
|
| 110 | - do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice ); |
|
| 109 | + // Fires after printing a line item column. |
|
| 110 | + do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice ); |
|
| 111 | 111 | |
| 112 | - ?> |
|
| 112 | + ?> |
|
| 113 | 113 | |
| 114 | 114 | </div> |
| 115 | 115 | |
@@ -10,104 +10,104 @@ |
||
| 10 | 10 | * @var array $columns |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -defined( 'ABSPATH' ) || exit; |
|
| 13 | +defined('ABSPATH') || exit; |
|
| 14 | 14 | |
| 15 | -do_action( 'getpaid_before_invoice_line_item', $invoice, $item ); |
|
| 15 | +do_action('getpaid_before_invoice_line_item', $invoice, $item); |
|
| 16 | 16 | |
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | -<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo esc_attr( $item->get_type() ); ?> border-bottom'> |
|
| 19 | +<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo esc_attr($item->get_type()); ?> border-bottom'> |
|
| 20 | 20 | |
| 21 | 21 | <div class="form-row row align-items-center"> |
| 22 | 22 | |
| 23 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
| 23 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
| 24 | 24 | |
| 25 | - <div class="<?php echo 'name' === $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr( $column ); ?>"> |
|
| 25 | + <div class="<?php echo 'name' === $column ? 'col-12 col-sm-6' : 'col-12 col-sm'; ?> getpaid-invoice-item-<?php echo esc_attr($column); ?>"> |
|
| 26 | 26 | |
| 27 | 27 | <?php |
| 28 | 28 | |
| 29 | 29 | // Fires before printing a line item column. |
| 30 | - do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice ); |
|
| 30 | + do_action("getpaid_invoice_line_item_before_$column", $item, $invoice); |
|
| 31 | 31 | |
| 32 | 32 | // Item name. |
| 33 | - if ( 'name' === $column ) { |
|
| 33 | + if ('name' === $column) { |
|
| 34 | 34 | |
| 35 | - $has_featured_image = has_post_thumbnail( $item->get_id() ); |
|
| 35 | + $has_featured_image = has_post_thumbnail($item->get_id()); |
|
| 36 | 36 | |
| 37 | - if ( $has_featured_image ) { |
|
| 37 | + if ($has_featured_image) { |
|
| 38 | 38 | echo '<div class="d-flex align-items-center getpaid-form-item-has-featured-image">'; |
| 39 | 39 | echo '<div class="getpaid-form-item-image-container mr-2">'; |
| 40 | - echo get_the_post_thumbnail( $item->get_id(), 'thumbnail', array( 'class' => 'getpaid-form-item-image mb-0' ) ); |
|
| 40 | + echo get_the_post_thumbnail($item->get_id(), 'thumbnail', array('class' => 'getpaid-form-item-image mb-0')); |
|
| 41 | 41 | echo '</div>'; |
| 42 | 42 | echo '<div class="getpaid-form-item-name-container">'; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Display the name. |
| 46 | - echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>'; |
|
| 46 | + echo '<div class="mb-1">' . esc_html($item->get_name()) . '</div>'; |
|
| 47 | 47 | |
| 48 | 48 | // And an optional description. |
| 49 | 49 | $description = $item->get_description(); |
| 50 | 50 | |
| 51 | - if ( ! empty( $description ) ) { |
|
| 52 | - echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post( $description ) . '</small>'; |
|
| 51 | + if (!empty($description)) { |
|
| 52 | + echo "<small class='form-text text-muted pr-2 m-0'>" . wp_kses_post($description) . '</small>'; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | // Fires before printing the line item actions. |
| 56 | - do_action( 'getpaid_before_invoice_line_item_actions', $item, $invoice ); |
|
| 56 | + do_action('getpaid_before_invoice_line_item_actions', $item, $invoice); |
|
| 57 | 57 | |
| 58 | - $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice ); |
|
| 58 | + $actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice); |
|
| 59 | 59 | |
| 60 | - if ( ! empty( $actions ) ) { |
|
| 60 | + if (!empty($actions)) { |
|
| 61 | 61 | |
| 62 | - $sanitized = array(); |
|
| 63 | - foreach ( $actions as $key => $item_action ) { |
|
| 64 | - $key = sanitize_html_class( $key ); |
|
| 65 | - $item_action = wp_kses_post( $item_action ); |
|
| 62 | + $sanitized = array(); |
|
| 63 | + foreach ($actions as $key => $item_action) { |
|
| 64 | + $key = sanitize_html_class($key); |
|
| 65 | + $item_action = wp_kses_post($item_action); |
|
| 66 | 66 | $sanitized[] = "<span class='$key'>$item_action</span>"; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | echo "<small class='form-text getpaid-line-item-actions'>"; |
| 70 | - echo wp_kses_post( implode( ' | ', $sanitized ) ); |
|
| 70 | + echo wp_kses_post(implode(' | ', $sanitized)); |
|
| 71 | 71 | echo '</small>'; |
| 72 | 72 | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ( $has_featured_image ) { |
|
| 75 | + if ($has_featured_image) { |
|
| 76 | 76 | echo '</div>'; |
| 77 | 77 | echo '</div>'; |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Item price. |
| 82 | - if ( 'price' === $column ) { |
|
| 82 | + if ('price' === $column) { |
|
| 83 | 83 | |
| 84 | 84 | // Display the item price (or recurring price if this is a renewal invoice) |
| 85 | 85 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
| 86 | - wpinv_the_price( $price, $invoice->get_currency() ); |
|
| 86 | + wpinv_the_price($price, $invoice->get_currency()); |
|
| 87 | 87 | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | // Tax rate. |
| 91 | - if ( 'tax_rate' === $column ) { |
|
| 92 | - echo floatval( round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%'; |
|
| 91 | + if ('tax_rate' === $column) { |
|
| 92 | + echo floatval(round(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%'; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | // Item quantity. |
| 96 | - if ( 'quantity' === $column ) { |
|
| 96 | + if ('quantity' === $column) { |
|
| 97 | 97 | echo (float) $item->get_quantity(); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Item sub total. |
| 101 | - if ( 'subtotal' === $column ) { |
|
| 101 | + if ('subtotal' === $column) { |
|
| 102 | 102 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
| 103 | - wpinv_the_price( $subtotal, $invoice->get_currency() ); |
|
| 103 | + wpinv_the_price($subtotal, $invoice->get_currency()); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // Fires when printing a line item column. |
| 107 | - do_action( "getpaid_invoice_line_item_$column", $item, $invoice ); |
|
| 107 | + do_action("getpaid_invoice_line_item_$column", $item, $invoice); |
|
| 108 | 108 | |
| 109 | 109 | // Fires after printing a line item column. |
| 110 | - do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice ); |
|
| 110 | + do_action("getpaid_invoice_line_item_after_$column", $item, $invoice); |
|
| 111 | 111 | |
| 112 | 112 | ?> |
| 113 | 113 | |
@@ -13,199 +13,199 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class GetPaid_Tax { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Calculates tax for a line item. |
|
| 18 | - * |
|
| 19 | - * @param float $price The price to calc tax on. |
|
| 20 | - * @param array $rates The rates to apply. |
|
| 21 | - * @param boolean $price_includes_tax Whether the passed price has taxes included. |
|
| 22 | - * @return array Array of tax name => tax amount. |
|
| 23 | - */ |
|
| 24 | - public static function calc_tax( $price, $rates, $price_includes_tax = false ) { |
|
| 25 | - |
|
| 26 | - if ( $price_includes_tax ) { |
|
| 27 | - $taxes = self::calc_inclusive_tax( $price, $rates ); |
|
| 28 | - } else { |
|
| 29 | - $taxes = self::calc_exclusive_tax( $price, $rates ); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax ); |
|
| 33 | - |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Calc tax from inclusive price. |
|
| 38 | - * |
|
| 39 | - * @param float $price Price to calculate tax for. |
|
| 40 | - * @param array $rates Array of tax rates. |
|
| 41 | - * @return array |
|
| 42 | - */ |
|
| 43 | - public static function calc_inclusive_tax( $price, $rates ) { |
|
| 44 | - $taxes = array(); |
|
| 45 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 46 | - |
|
| 47 | - // Add tax rates. |
|
| 48 | - $tax_rate = 1 + ( array_sum( $tax_rates ) / 100 ); |
|
| 49 | - |
|
| 50 | - foreach ( $tax_rates as $name => $rate ) { |
|
| 51 | - $the_rate = ( $rate / 100 ) / $tax_rate; |
|
| 52 | - $net_price = $price - ( $the_rate * $price ); |
|
| 53 | - $tax_amount = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price ); |
|
| 54 | - $taxes[ $name ] = $tax_amount; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - // Round all taxes to precision (4DP) before passing them back. |
|
| 58 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 59 | - |
|
| 60 | - return $taxes; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Calc tax from exclusive price. |
|
| 65 | - * |
|
| 66 | - * @param float $price Price to calculate tax for. |
|
| 67 | - * @param array $rates Array of tax rates. |
|
| 68 | - * @return array |
|
| 69 | - */ |
|
| 70 | - public static function calc_exclusive_tax( $price, $rates ) { |
|
| 71 | - $taxes = array(); |
|
| 72 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 73 | - |
|
| 74 | - foreach ( $tax_rates as $name => $rate ) { |
|
| 75 | - |
|
| 76 | - $tax_amount = $price * ( $rate / 100 ); |
|
| 77 | - $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price ); |
|
| 78 | - |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - // Round all taxes to precision (4DP) before passing them back. |
|
| 82 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 83 | - |
|
| 84 | - return $taxes; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Get's an array of all tax rates. |
|
| 89 | - * |
|
| 90 | - * @return array |
|
| 91 | - */ |
|
| 92 | - public static function get_all_tax_rates() { |
|
| 93 | - |
|
| 94 | - $rates = get_option( 'wpinv_tax_rates', array() ); |
|
| 95 | - |
|
| 96 | - return apply_filters( |
|
| 97 | - 'getpaid_get_all_tax_rates', |
|
| 98 | - array_filter( wpinv_parse_list( $rates ) ) |
|
| 99 | - ); |
|
| 100 | - |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Get's an array of default tax rates. |
|
| 105 | - * |
|
| 106 | - * @return array |
|
| 107 | - */ |
|
| 108 | - public static function get_default_tax_rates() { |
|
| 109 | - |
|
| 110 | - return apply_filters( |
|
| 111 | - 'getpaid_get_default_tax_rates', |
|
| 112 | - array( |
|
| 113 | - array( |
|
| 114 | - 'country' => wpinv_get_default_country(), |
|
| 115 | - 'state' => wpinv_get_default_state(), |
|
| 116 | - 'global' => true, |
|
| 117 | - 'rate' => wpinv_get_default_tax_rate(), |
|
| 118 | - 'name' => __( 'Base Tax', 'invoicing' ), |
|
| 119 | - ), |
|
| 120 | - ) |
|
| 121 | - ); |
|
| 122 | - |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Get's an array of all tax rules. |
|
| 127 | - * |
|
| 128 | - * @return array |
|
| 129 | - */ |
|
| 130 | - public static function get_all_tax_rules() { |
|
| 131 | - |
|
| 132 | - $rules = get_option( |
|
| 133 | - 'wpinv_tax_rules', |
|
| 134 | - array( |
|
| 135 | - array( |
|
| 136 | - 'key' => 'physical', |
|
| 137 | - 'label' => __( 'Physical Item', 'invoicing' ), |
|
| 138 | - 'tax_base' => wpinv_get_option( 'tax_base', 'billing' ), |
|
| 139 | - 'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ), |
|
| 140 | - ), |
|
| 141 | - array( |
|
| 142 | - 'key' => 'digital', |
|
| 143 | - 'label' => __( 'Digital Item', 'invoicing' ), |
|
| 144 | - 'tax_base' => wpinv_get_option( 'tax_base', 'billing' ), |
|
| 145 | - 'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ), |
|
| 146 | - ), |
|
| 147 | - ) |
|
| 148 | - ); |
|
| 149 | - |
|
| 150 | - return apply_filters( |
|
| 151 | - 'getpaid_tax_rules', |
|
| 152 | - array_filter( array_values( wpinv_parse_list( $rules ) ) ) |
|
| 153 | - ); |
|
| 154 | - |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Get's an array of tax rates for a given address. |
|
| 159 | - * |
|
| 160 | - * @param string $country |
|
| 161 | - * @param string $state |
|
| 162 | - * @return array |
|
| 163 | - */ |
|
| 164 | - public static function get_address_tax_rates( $country, $state ) { |
|
| 165 | - |
|
| 166 | - $all_tax_rates = self::get_all_tax_rates(); |
|
| 167 | - $matching_rates = array_merge( |
|
| 168 | - wp_list_filter( $all_tax_rates, array( 'country' => $country ) ), |
|
| 169 | - wp_list_filter( $all_tax_rates, array( 'country' => '' ) ) |
|
| 170 | - ); |
|
| 171 | - |
|
| 172 | - foreach ( $matching_rates as $i => $rate ) { |
|
| 173 | - |
|
| 174 | - $states = array_filter( wpinv_clean( explode( ',', strtolower( $rate['state'] ) ) ) ); |
|
| 175 | - if ( empty( $rate['global'] ) && ! in_array( strtolower( $state ), $states ) ) { |
|
| 176 | - unset( $matching_rates[ $i ] ); |
|
| 177 | - } |
|
| 16 | + /** |
|
| 17 | + * Calculates tax for a line item. |
|
| 18 | + * |
|
| 19 | + * @param float $price The price to calc tax on. |
|
| 20 | + * @param array $rates The rates to apply. |
|
| 21 | + * @param boolean $price_includes_tax Whether the passed price has taxes included. |
|
| 22 | + * @return array Array of tax name => tax amount. |
|
| 23 | + */ |
|
| 24 | + public static function calc_tax( $price, $rates, $price_includes_tax = false ) { |
|
| 25 | + |
|
| 26 | + if ( $price_includes_tax ) { |
|
| 27 | + $taxes = self::calc_inclusive_tax( $price, $rates ); |
|
| 28 | + } else { |
|
| 29 | + $taxes = self::calc_exclusive_tax( $price, $rates ); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax ); |
|
| 33 | + |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Calc tax from inclusive price. |
|
| 38 | + * |
|
| 39 | + * @param float $price Price to calculate tax for. |
|
| 40 | + * @param array $rates Array of tax rates. |
|
| 41 | + * @return array |
|
| 42 | + */ |
|
| 43 | + public static function calc_inclusive_tax( $price, $rates ) { |
|
| 44 | + $taxes = array(); |
|
| 45 | + $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 46 | + |
|
| 47 | + // Add tax rates. |
|
| 48 | + $tax_rate = 1 + ( array_sum( $tax_rates ) / 100 ); |
|
| 49 | + |
|
| 50 | + foreach ( $tax_rates as $name => $rate ) { |
|
| 51 | + $the_rate = ( $rate / 100 ) / $tax_rate; |
|
| 52 | + $net_price = $price - ( $the_rate * $price ); |
|
| 53 | + $tax_amount = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price ); |
|
| 54 | + $taxes[ $name ] = $tax_amount; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + // Round all taxes to precision (4DP) before passing them back. |
|
| 58 | + $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 59 | + |
|
| 60 | + return $taxes; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Calc tax from exclusive price. |
|
| 65 | + * |
|
| 66 | + * @param float $price Price to calculate tax for. |
|
| 67 | + * @param array $rates Array of tax rates. |
|
| 68 | + * @return array |
|
| 69 | + */ |
|
| 70 | + public static function calc_exclusive_tax( $price, $rates ) { |
|
| 71 | + $taxes = array(); |
|
| 72 | + $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 73 | + |
|
| 74 | + foreach ( $tax_rates as $name => $rate ) { |
|
| 75 | + |
|
| 76 | + $tax_amount = $price * ( $rate / 100 ); |
|
| 77 | + $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price ); |
|
| 78 | + |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + // Round all taxes to precision (4DP) before passing them back. |
|
| 82 | + $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 83 | + |
|
| 84 | + return $taxes; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Get's an array of all tax rates. |
|
| 89 | + * |
|
| 90 | + * @return array |
|
| 91 | + */ |
|
| 92 | + public static function get_all_tax_rates() { |
|
| 93 | + |
|
| 94 | + $rates = get_option( 'wpinv_tax_rates', array() ); |
|
| 95 | + |
|
| 96 | + return apply_filters( |
|
| 97 | + 'getpaid_get_all_tax_rates', |
|
| 98 | + array_filter( wpinv_parse_list( $rates ) ) |
|
| 99 | + ); |
|
| 100 | + |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Get's an array of default tax rates. |
|
| 105 | + * |
|
| 106 | + * @return array |
|
| 107 | + */ |
|
| 108 | + public static function get_default_tax_rates() { |
|
| 109 | + |
|
| 110 | + return apply_filters( |
|
| 111 | + 'getpaid_get_default_tax_rates', |
|
| 112 | + array( |
|
| 113 | + array( |
|
| 114 | + 'country' => wpinv_get_default_country(), |
|
| 115 | + 'state' => wpinv_get_default_state(), |
|
| 116 | + 'global' => true, |
|
| 117 | + 'rate' => wpinv_get_default_tax_rate(), |
|
| 118 | + 'name' => __( 'Base Tax', 'invoicing' ), |
|
| 119 | + ), |
|
| 120 | + ) |
|
| 121 | + ); |
|
| 122 | + |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Get's an array of all tax rules. |
|
| 127 | + * |
|
| 128 | + * @return array |
|
| 129 | + */ |
|
| 130 | + public static function get_all_tax_rules() { |
|
| 131 | + |
|
| 132 | + $rules = get_option( |
|
| 133 | + 'wpinv_tax_rules', |
|
| 134 | + array( |
|
| 135 | + array( |
|
| 136 | + 'key' => 'physical', |
|
| 137 | + 'label' => __( 'Physical Item', 'invoicing' ), |
|
| 138 | + 'tax_base' => wpinv_get_option( 'tax_base', 'billing' ), |
|
| 139 | + 'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ), |
|
| 140 | + ), |
|
| 141 | + array( |
|
| 142 | + 'key' => 'digital', |
|
| 143 | + 'label' => __( 'Digital Item', 'invoicing' ), |
|
| 144 | + 'tax_base' => wpinv_get_option( 'tax_base', 'billing' ), |
|
| 145 | + 'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ), |
|
| 146 | + ), |
|
| 147 | + ) |
|
| 148 | + ); |
|
| 149 | + |
|
| 150 | + return apply_filters( |
|
| 151 | + 'getpaid_tax_rules', |
|
| 152 | + array_filter( array_values( wpinv_parse_list( $rules ) ) ) |
|
| 153 | + ); |
|
| 154 | + |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Get's an array of tax rates for a given address. |
|
| 159 | + * |
|
| 160 | + * @param string $country |
|
| 161 | + * @param string $state |
|
| 162 | + * @return array |
|
| 163 | + */ |
|
| 164 | + public static function get_address_tax_rates( $country, $state ) { |
|
| 165 | + |
|
| 166 | + $all_tax_rates = self::get_all_tax_rates(); |
|
| 167 | + $matching_rates = array_merge( |
|
| 168 | + wp_list_filter( $all_tax_rates, array( 'country' => $country ) ), |
|
| 169 | + wp_list_filter( $all_tax_rates, array( 'country' => '' ) ) |
|
| 170 | + ); |
|
| 171 | + |
|
| 172 | + foreach ( $matching_rates as $i => $rate ) { |
|
| 173 | + |
|
| 174 | + $states = array_filter( wpinv_clean( explode( ',', strtolower( $rate['state'] ) ) ) ); |
|
| 175 | + if ( empty( $rate['global'] ) && ! in_array( strtolower( $state ), $states ) ) { |
|
| 176 | + unset( $matching_rates[ $i ] ); |
|
| 177 | + } |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state ); |
|
| 181 | - |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Sums a set of taxes to form a single total. Result is rounded to precision. |
|
| 186 | - * |
|
| 187 | - * @param array $taxes Array of taxes. |
|
| 188 | - * @return float |
|
| 189 | - */ |
|
| 190 | - public static function get_tax_total( $taxes ) { |
|
| 191 | - return self::round( array_sum( $taxes ) ); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Round to precision. |
|
| 196 | - * |
|
| 197 | - * Filter example: to return rounding to .5 cents you'd use: |
|
| 198 | - * |
|
| 199 | - * function euro_5cent_rounding( $in ) { |
|
| 200 | - * return round( $in / 5, 2 ) * 5; |
|
| 201 | - * } |
|
| 202 | - * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' ); |
|
| 203 | - * |
|
| 204 | - * @param float|int $in Value to round. |
|
| 205 | - * @return float |
|
| 206 | - */ |
|
| 207 | - public static function round( $in ) { |
|
| 208 | - return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in ); |
|
| 209 | - } |
|
| 180 | + return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state ); |
|
| 181 | + |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Sums a set of taxes to form a single total. Result is rounded to precision. |
|
| 186 | + * |
|
| 187 | + * @param array $taxes Array of taxes. |
|
| 188 | + * @return float |
|
| 189 | + */ |
|
| 190 | + public static function get_tax_total( $taxes ) { |
|
| 191 | + return self::round( array_sum( $taxes ) ); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Round to precision. |
|
| 196 | + * |
|
| 197 | + * Filter example: to return rounding to .5 cents you'd use: |
|
| 198 | + * |
|
| 199 | + * function euro_5cent_rounding( $in ) { |
|
| 200 | + * return round( $in / 5, 2 ) * 5; |
|
| 201 | + * } |
|
| 202 | + * add_filter( 'getpaid_tax_round', 'euro_5cent_rounding' ); |
|
| 203 | + * |
|
| 204 | + * @param float|int $in Value to round. |
|
| 205 | + * @return float |
|
| 206 | + */ |
|
| 207 | + public static function round( $in ) { |
|
| 208 | + return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in ); |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | 211 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Class GetPaid_Tax |
@@ -21,15 +21,15 @@ discard block |
||
| 21 | 21 | * @param boolean $price_includes_tax Whether the passed price has taxes included. |
| 22 | 22 | * @return array Array of tax name => tax amount. |
| 23 | 23 | */ |
| 24 | - public static function calc_tax( $price, $rates, $price_includes_tax = false ) { |
|
| 24 | + public static function calc_tax($price, $rates, $price_includes_tax = false) { |
|
| 25 | 25 | |
| 26 | - if ( $price_includes_tax ) { |
|
| 27 | - $taxes = self::calc_inclusive_tax( $price, $rates ); |
|
| 26 | + if ($price_includes_tax) { |
|
| 27 | + $taxes = self::calc_inclusive_tax($price, $rates); |
|
| 28 | 28 | } else { |
| 29 | - $taxes = self::calc_exclusive_tax( $price, $rates ); |
|
| 29 | + $taxes = self::calc_exclusive_tax($price, $rates); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return apply_filters( 'getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax ); |
|
| 32 | + return apply_filters('getpaid_calc_tax', $taxes, $price, $rates, $price_includes_tax); |
|
| 33 | 33 | |
| 34 | 34 | } |
| 35 | 35 | |
@@ -40,22 +40,22 @@ discard block |
||
| 40 | 40 | * @param array $rates Array of tax rates. |
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | - public static function calc_inclusive_tax( $price, $rates ) { |
|
| 43 | + public static function calc_inclusive_tax($price, $rates) { |
|
| 44 | 44 | $taxes = array(); |
| 45 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 45 | + $tax_rates = wp_list_pluck($rates, 'rate', 'name'); |
|
| 46 | 46 | |
| 47 | 47 | // Add tax rates. |
| 48 | - $tax_rate = 1 + ( array_sum( $tax_rates ) / 100 ); |
|
| 48 | + $tax_rate = 1 + (array_sum($tax_rates) / 100); |
|
| 49 | 49 | |
| 50 | - foreach ( $tax_rates as $name => $rate ) { |
|
| 51 | - $the_rate = ( $rate / 100 ) / $tax_rate; |
|
| 52 | - $net_price = $price - ( $the_rate * $price ); |
|
| 53 | - $tax_amount = apply_filters( 'getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price ); |
|
| 54 | - $taxes[ $name ] = $tax_amount; |
|
| 50 | + foreach ($tax_rates as $name => $rate) { |
|
| 51 | + $the_rate = ($rate / 100) / $tax_rate; |
|
| 52 | + $net_price = $price - ($the_rate * $price); |
|
| 53 | + $tax_amount = apply_filters('getpaid_price_inc_tax_amount', $price - $net_price, $name, $rate, $price); |
|
| 54 | + $taxes[$name] = $tax_amount; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // Round all taxes to precision (4DP) before passing them back. |
| 58 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 58 | + $taxes = array_map(array(__CLASS__, 'round'), $taxes); |
|
| 59 | 59 | |
| 60 | 60 | return $taxes; |
| 61 | 61 | } |
@@ -67,19 +67,19 @@ discard block |
||
| 67 | 67 | * @param array $rates Array of tax rates. |
| 68 | 68 | * @return array |
| 69 | 69 | */ |
| 70 | - public static function calc_exclusive_tax( $price, $rates ) { |
|
| 70 | + public static function calc_exclusive_tax($price, $rates) { |
|
| 71 | 71 | $taxes = array(); |
| 72 | - $tax_rates = wp_list_pluck( $rates, 'rate', 'name' ); |
|
| 72 | + $tax_rates = wp_list_pluck($rates, 'rate', 'name'); |
|
| 73 | 73 | |
| 74 | - foreach ( $tax_rates as $name => $rate ) { |
|
| 74 | + foreach ($tax_rates as $name => $rate) { |
|
| 75 | 75 | |
| 76 | - $tax_amount = $price * ( $rate / 100 ); |
|
| 77 | - $taxes[ $name ] = apply_filters( 'getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price ); |
|
| 76 | + $tax_amount = $price * ($rate / 100); |
|
| 77 | + $taxes[$name] = apply_filters('getpaid_price_ex_tax_amount', $tax_amount, $name, $rate, $price); |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | // Round all taxes to precision (4DP) before passing them back. |
| 82 | - $taxes = array_map( array( __CLASS__, 'round' ), $taxes ); |
|
| 82 | + $taxes = array_map(array(__CLASS__, 'round'), $taxes); |
|
| 83 | 83 | |
| 84 | 84 | return $taxes; |
| 85 | 85 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public static function get_all_tax_rates() { |
| 93 | 93 | |
| 94 | - $rates = get_option( 'wpinv_tax_rates', array() ); |
|
| 94 | + $rates = get_option('wpinv_tax_rates', array()); |
|
| 95 | 95 | |
| 96 | 96 | return apply_filters( |
| 97 | 97 | 'getpaid_get_all_tax_rates', |
| 98 | - array_filter( wpinv_parse_list( $rates ) ) |
|
| 98 | + array_filter(wpinv_parse_list($rates)) |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | 101 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | 'state' => wpinv_get_default_state(), |
| 116 | 116 | 'global' => true, |
| 117 | 117 | 'rate' => wpinv_get_default_tax_rate(), |
| 118 | - 'name' => __( 'Base Tax', 'invoicing' ), |
|
| 118 | + 'name' => __('Base Tax', 'invoicing'), |
|
| 119 | 119 | ), |
| 120 | 120 | ) |
| 121 | 121 | ); |
@@ -134,22 +134,22 @@ discard block |
||
| 134 | 134 | array( |
| 135 | 135 | array( |
| 136 | 136 | 'key' => 'physical', |
| 137 | - 'label' => __( 'Physical Item', 'invoicing' ), |
|
| 138 | - 'tax_base' => wpinv_get_option( 'tax_base', 'billing' ), |
|
| 139 | - 'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ), |
|
| 137 | + 'label' => __('Physical Item', 'invoicing'), |
|
| 138 | + 'tax_base' => wpinv_get_option('tax_base', 'billing'), |
|
| 139 | + 'same_country_rule' => wpinv_get_option('vat_same_country_rule', 'vat_too'), |
|
| 140 | 140 | ), |
| 141 | 141 | array( |
| 142 | 142 | 'key' => 'digital', |
| 143 | - 'label' => __( 'Digital Item', 'invoicing' ), |
|
| 144 | - 'tax_base' => wpinv_get_option( 'tax_base', 'billing' ), |
|
| 145 | - 'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ), |
|
| 143 | + 'label' => __('Digital Item', 'invoicing'), |
|
| 144 | + 'tax_base' => wpinv_get_option('tax_base', 'billing'), |
|
| 145 | + 'same_country_rule' => wpinv_get_option('vat_same_country_rule', 'vat_too'), |
|
| 146 | 146 | ), |
| 147 | 147 | ) |
| 148 | 148 | ); |
| 149 | 149 | |
| 150 | 150 | return apply_filters( |
| 151 | 151 | 'getpaid_tax_rules', |
| 152 | - array_filter( array_values( wpinv_parse_list( $rules ) ) ) |
|
| 152 | + array_filter(array_values(wpinv_parse_list($rules))) |
|
| 153 | 153 | ); |
| 154 | 154 | |
| 155 | 155 | } |
@@ -161,23 +161,23 @@ discard block |
||
| 161 | 161 | * @param string $state |
| 162 | 162 | * @return array |
| 163 | 163 | */ |
| 164 | - public static function get_address_tax_rates( $country, $state ) { |
|
| 164 | + public static function get_address_tax_rates($country, $state) { |
|
| 165 | 165 | |
| 166 | 166 | $all_tax_rates = self::get_all_tax_rates(); |
| 167 | 167 | $matching_rates = array_merge( |
| 168 | - wp_list_filter( $all_tax_rates, array( 'country' => $country ) ), |
|
| 169 | - wp_list_filter( $all_tax_rates, array( 'country' => '' ) ) |
|
| 168 | + wp_list_filter($all_tax_rates, array('country' => $country)), |
|
| 169 | + wp_list_filter($all_tax_rates, array('country' => '')) |
|
| 170 | 170 | ); |
| 171 | 171 | |
| 172 | - foreach ( $matching_rates as $i => $rate ) { |
|
| 172 | + foreach ($matching_rates as $i => $rate) { |
|
| 173 | 173 | |
| 174 | - $states = array_filter( wpinv_clean( explode( ',', strtolower( $rate['state'] ) ) ) ); |
|
| 175 | - if ( empty( $rate['global'] ) && ! in_array( strtolower( $state ), $states ) ) { |
|
| 176 | - unset( $matching_rates[ $i ] ); |
|
| 174 | + $states = array_filter(wpinv_clean(explode(',', strtolower($rate['state'])))); |
|
| 175 | + if (empty($rate['global']) && !in_array(strtolower($state), $states)) { |
|
| 176 | + unset($matching_rates[$i]); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - return apply_filters( 'getpaid_get_address_tax_rates', $matching_rates, $country, $state ); |
|
| 180 | + return apply_filters('getpaid_get_address_tax_rates', $matching_rates, $country, $state); |
|
| 181 | 181 | |
| 182 | 182 | } |
| 183 | 183 | |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | * @param array $taxes Array of taxes. |
| 188 | 188 | * @return float |
| 189 | 189 | */ |
| 190 | - public static function get_tax_total( $taxes ) { |
|
| 191 | - return self::round( array_sum( $taxes ) ); |
|
| 190 | + public static function get_tax_total($taxes) { |
|
| 191 | + return self::round(array_sum($taxes)); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | * @param float|int $in Value to round. |
| 205 | 205 | * @return float |
| 206 | 206 | */ |
| 207 | - public static function round( $in ) { |
|
| 208 | - return apply_filters( 'getpaid_tax_round', round( $in, 4 ), $in ); |
|
| 207 | + public static function round($in) { |
|
| 208 | + return apply_filters('getpaid_tax_round', round($in, 4), $in); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | } |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | |
| 9 | 9 | $dummy_rule = array( |
| 10 | 10 | 'key' => 'TAX_RULE_KEY', |
| 11 | - 'label' => __( 'New Tax Rule', 'invoicing' ), |
|
| 12 | - 'tax_base' => wpinv_get_option( 'tax_base', 'billing' ), |
|
| 11 | + 'label' => __( 'New Tax Rule', 'invoicing' ), |
|
| 12 | + 'tax_base' => wpinv_get_option( 'tax_base', 'billing' ), |
|
| 13 | 13 | 'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ), |
| 14 | 14 | ); |
| 15 | 15 | |
@@ -4,40 +4,40 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | $dummy_rule = array( |
| 10 | 10 | 'key' => 'TAX_RULE_KEY', |
| 11 | - 'label' => __( 'New Tax Rule', 'invoicing' ), |
|
| 12 | - 'tax_base' => wpinv_get_option( 'tax_base', 'billing' ), |
|
| 13 | - 'same_country_rule' => wpinv_get_option( 'vat_same_country_rule', 'vat_too' ), |
|
| 11 | + 'label' => __('New Tax Rule', 'invoicing'), |
|
| 12 | + 'tax_base' => wpinv_get_option('tax_base', 'billing'), |
|
| 13 | + 'same_country_rule' => wpinv_get_option('vat_same_country_rule', 'vat_too'), |
|
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | -wp_nonce_field( 'wpinv_tax_rules', 'wpinv_tax_rules_nonce' ); |
|
| 16 | +wp_nonce_field('wpinv_tax_rules', 'wpinv_tax_rules_nonce'); |
|
| 17 | 17 | |
| 18 | 18 | ?> |
| 19 | 19 | <div class="table-responsive"> |
| 20 | 20 | <table id="wpinv-tax-rules" class="widefat fixed table"> |
| 21 | - <caption><?php echo esc_html_e( 'You can use this section to create or edit your tax rules', 'invoicing' ); ?></caption> |
|
| 21 | + <caption><?php echo esc_html_e('You can use this section to create or edit your tax rules', 'invoicing'); ?></caption> |
|
| 22 | 22 | |
| 23 | 23 | <thead> |
| 24 | 24 | <tr class="table-light"> |
| 25 | 25 | |
| 26 | 26 | <th scope="col" class="border-bottom border-top"> |
| 27 | - <?php esc_html_e( 'Unique Key', 'invoicing' ); ?> |
|
| 27 | + <?php esc_html_e('Unique Key', 'invoicing'); ?> |
|
| 28 | 28 | </th> |
| 29 | 29 | |
| 30 | 30 | <th scope="col" class="border-bottom border-top"> |
| 31 | - <?php esc_html_e( 'Label', 'invoicing' ); ?> |
|
| 31 | + <?php esc_html_e('Label', 'invoicing'); ?> |
|
| 32 | 32 | </th> |
| 33 | 33 | |
| 34 | 34 | <th scope="col" class="border-bottom border-top"> |
| 35 | - <?php esc_html_e( 'Calculate tax based on', 'invoicing' ); ?> |
|
| 35 | + <?php esc_html_e('Calculate tax based on', 'invoicing'); ?> |
|
| 36 | 36 | </th> |
| 37 | 37 | |
| 38 | 38 | <!-- <th scope="col" class="border-bottom border-top"> |
| 39 | - <?php esc_html_e( 'Same country rule', 'invoicing' ); ?> |
|
| 40 | - <?php getpaid_get_help_tip( __( 'What should happen if a customer is from the same country as your business?.', 'invoicing' ), 'position-static', true ); ?> |
|
| 39 | + <?php esc_html_e('Same country rule', 'invoicing'); ?> |
|
| 40 | + <?php getpaid_get_help_tip(__('What should happen if a customer is from the same country as your business?.', 'invoicing'), 'position-static', true); ?> |
|
| 41 | 41 | </th> --> |
| 42 | 42 | |
| 43 | 43 | <th scope="col" class="border-bottom border-top" style="width:32px"> </th> |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | </thead> |
| 47 | 47 | |
| 48 | 48 | <tbody> |
| 49 | - <?php foreach ( GetPaid_Tax::get_all_tax_rules() as $tax_rule ) : ?> |
|
| 50 | - <?php include plugin_dir_path( __FILE__ ) . 'html-tax-rule-edit.php'; ?> |
|
| 49 | + <?php foreach (GetPaid_Tax::get_all_tax_rules() as $tax_rule) : ?> |
|
| 50 | + <?php include plugin_dir_path(__FILE__) . 'html-tax-rule-edit.php'; ?> |
|
| 51 | 51 | <?php endforeach; ?> |
| 52 | 52 | </tbody> |
| 53 | 53 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | <tr class="table-light"> |
| 56 | 56 | <td colspan="4" class="border-top"> |
| 57 | 57 | |
| 58 | - <button type="button" class="button button-secondary wpinv_add_tax_rule" aria-label="<?php esc_attr_e( 'Add Tax Rule', 'invoicing' ); ?>"> |
|
| 59 | - <span><?php esc_html_e( 'Add Tax Rule', 'invoicing' ); ?></span> |
|
| 58 | + <button type="button" class="button button-secondary wpinv_add_tax_rule" aria-label="<?php esc_attr_e('Add Tax Rule', 'invoicing'); ?>"> |
|
| 59 | + <span><?php esc_html_e('Add Tax Rule', 'invoicing'); ?></span> |
|
| 60 | 60 | </button> |
| 61 | 61 | |
| 62 | 62 | </td> |
@@ -67,6 +67,6 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | <script type="text/html" id="tmpl-wpinv-tax-rule-row"> |
| 69 | 69 | <?php $tax_rule = $dummy_rule; ?> |
| 70 | - <?php include plugin_dir_path( __FILE__ ) . 'html-tax-rule-edit.php'; ?> |
|
| 70 | + <?php include plugin_dir_path(__FILE__) . 'html-tax-rule-edit.php'; ?> |
|
| 71 | 71 | </script> |
| 72 | 72 | |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | -defined( 'ABSPATH' ) || exit; |
|
| 7 | +defined('ABSPATH') || exit; |
|
| 8 | 8 | |
| 9 | 9 | ?> |
| 10 | 10 | |
@@ -12,24 +12,24 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | <form method="post" class="text-center card-body"> |
| 14 | 14 | <div class="gp-wizard-payments"> |
| 15 | - <h2 class="gd-settings-title h3 "><?php esc_html_e( 'Gateway Setup', 'invoicing' ); ?></h2> |
|
| 16 | - <p><?php esc_html_e( 'Below are a few gateways that can be setup in a few seconds.', 'invoicing' ); ?> |
|
| 15 | + <h2 class="gd-settings-title h3 "><?php esc_html_e('Gateway Setup', 'invoicing'); ?></h2> |
|
| 16 | + <p><?php esc_html_e('Below are a few gateways that can be setup in a few seconds.', 'invoicing'); ?> |
|
| 17 | 17 | <br> |
| 18 | - <?php esc_html_e( 'We have 20+ Gateways that can be setup later.', 'invoicing' ); ?> |
|
| 18 | + <?php esc_html_e('We have 20+ Gateways that can be setup later.', 'invoicing'); ?> |
|
| 19 | 19 | </p> |
| 20 | 20 | |
| 21 | 21 | <ul class="list-group"> |
| 22 | 22 | |
| 23 | 23 | <li class="list-group-item d-flex justify-content-between align-items-center"> |
| 24 | - <span class="mr-auto"><img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg' ); ?>" class="ml-n2" alt="Stripe"></span> |
|
| 25 | - <?php if ( false === wpinv_get_option( 'stripe_live_connect_account_id' ) ) : ?> |
|
| 24 | + <span class="mr-auto"><img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg'); ?>" class="ml-n2" alt="Stripe"></span> |
|
| 25 | + <?php if (false === wpinv_get_option('stripe_live_connect_account_id')) : ?> |
|
| 26 | 26 | <a href="<?php |
| 27 | - echo esc_url( wp_nonce_url( |
|
| 27 | + echo esc_url(wp_nonce_url( |
|
| 28 | 28 | add_query_arg( |
| 29 | 29 | array( |
| 30 | 30 | 'getpaid-admin-action' => 'connect_gateway', |
| 31 | 31 | 'plugin' => 'stripe', |
| 32 | - 'redirect' => urlencode( add_query_arg( 'step', 'payments' ) ), |
|
| 32 | + 'redirect' => urlencode(add_query_arg('step', 'payments')), |
|
| 33 | 33 | ), |
| 34 | 34 | admin_url() |
| 35 | 35 | ), |
@@ -37,31 +37,31 @@ discard block |
||
| 37 | 37 | 'getpaid-nonce' |
| 38 | 38 | )); |
| 39 | 39 | ?>" |
| 40 | - class="btn btn-sm btn-outline-primary"><?php esc_html_e( 'Connect', 'invoicing' ); ?></a> |
|
| 40 | + class="btn btn-sm btn-outline-primary"><?php esc_html_e('Connect', 'invoicing'); ?></a> |
|
| 41 | 41 | <?php else : ?> |
| 42 | - <span class="btn btn-sm btn-success"><?php esc_html_e( 'Connected', 'invoicing' ); ?></span> |
|
| 42 | + <span class="btn btn-sm btn-success"><?php esc_html_e('Connected', 'invoicing'); ?></span> |
|
| 43 | 43 | <?php endif; ?> |
| 44 | 44 | </li> |
| 45 | 45 | |
| 46 | 46 | <li class="list-group-item"> |
| 47 | 47 | <div class="d-flex justify-content-between align-items-center"> |
| 48 | 48 | <span class="mr-auto"> |
| 49 | - <img src="<?php echo esc_url( WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp' ); ?>" class="" alt="PayPal" height="25"> |
|
| 49 | + <img src="<?php echo esc_url(WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp'); ?>" class="" alt="PayPal" height="25"> |
|
| 50 | 50 | </span> |
| 51 | 51 | <a |
| 52 | 52 | href="#" |
| 53 | 53 | onclick="jQuery('.getpaid-setup-paypal-input').toggleClass('d-none'); return false;" |
| 54 | - class="getpaid-setup-paypal btn btn-sm btn-outline-primary"><?php esc_html_e( 'Set-up', 'invoicing' ); ?></a> |
|
| 54 | + class="getpaid-setup-paypal btn btn-sm btn-outline-primary"><?php esc_html_e('Set-up', 'invoicing'); ?></a> |
|
| 55 | 55 | </div> |
| 56 | 56 | <div class="mt-4 getpaid-setup-paypal-input d-none"> |
| 57 | - <input type="text" placeholder="<?php esc_attr_e( 'PayPal Email', 'invoicing' ); ?>" name="paypal-email" class="form-control" value="<?php echo esc_attr( wpinv_get_option( 'paypal_email' ) ); ?>"> |
|
| 57 | + <input type="text" placeholder="<?php esc_attr_e('PayPal Email', 'invoicing'); ?>" name="paypal-email" class="form-control" value="<?php echo esc_attr(wpinv_get_option('paypal_email')); ?>"> |
|
| 58 | 58 | </div> |
| 59 | 59 | </li> |
| 60 | 60 | |
| 61 | 61 | <li class="list-group-item d-flex justify-content-between align-items-center"> |
| 62 | - <span class="mr-auto"><?php esc_html_e( 'Test Gateway', 'invoicing' ); ?></span> |
|
| 62 | + <span class="mr-auto"><?php esc_html_e('Test Gateway', 'invoicing'); ?></span> |
|
| 63 | 63 | <div class="custom-control custom-switch"> |
| 64 | - <input type="checkbox" name="enable-manual-gateway" class="custom-control-input" id="enable-manual-gateway" <?php checked( wpinv_is_gateway_active( 'manual' ) ); ?>> |
|
| 64 | + <input type="checkbox" name="enable-manual-gateway" class="custom-control-input" id="enable-manual-gateway" <?php checked(wpinv_is_gateway_active('manual')); ?>> |
|
| 65 | 65 | <label class="custom-control-label" for="enable-manual-gateway"></label> |
| 66 | 66 | </div> |
| 67 | 67 | </li> |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | </div> |
| 71 | 71 | |
| 72 | 72 | <p class="gp-setup-actions step text-center mt-4"> |
| 73 | - <input type="submit" class="btn btn-primary" value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" /> |
|
| 73 | + <input type="submit" class="btn btn-primary" value="<?php esc_attr_e('Continue', 'invoicing'); ?>" /> |
|
| 74 | 74 | </p> |
| 75 | 75 | |
| 76 | - <?php getpaid_hidden_field( 'save_step', 1 ); ?> |
|
| 77 | - <?php wp_nonce_field( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); ?> |
|
| 76 | + <?php getpaid_hidden_field('save_step', 1); ?> |
|
| 77 | + <?php wp_nonce_field('getpaid-setup-wizard', 'getpaid-setup-wizard'); ?> |
|
| 78 | 78 | </form> |
| 79 | 79 | </div> |
@@ -38,8 +38,11 @@ |
||
| 38 | 38 | )); |
| 39 | 39 | ?>" |
| 40 | 40 | class="btn btn-sm btn-outline-primary"><?php esc_html_e( 'Connect', 'invoicing' ); ?></a> |
| 41 | - <?php else : ?> |
|
| 42 | - <span class="btn btn-sm btn-success"><?php esc_html_e( 'Connected', 'invoicing' ); ?></span> |
|
| 41 | + <?php else { |
|
| 42 | + : ?> |
|
| 43 | + <span class="btn btn-sm btn-success"><?php esc_html_e( 'Connected', 'invoicing' ); |
|
| 44 | +} |
|
| 45 | +?></span> |
|
| 43 | 46 | <?php endif; ?> |
| 44 | 47 | </li> |
| 45 | 48 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
| 36 | 36 | |
| 37 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 38 | - return 'manage_options'; |
|
| 39 | - }; |
|
| 37 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 38 | + return 'manage_options'; |
|
| 39 | + }; |
|
| 40 | 40 | |
| 41 | - return $capalibilty; |
|
| 41 | + return $capalibilty; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | // Prepare user values. |
| 63 | 63 | $prefix = preg_replace( '/\s+/', '', $prefix ); |
| 64 | 64 | $prefix = empty( $prefix ) ? $email : $prefix; |
| 65 | - $args = array( |
|
| 66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
| 67 | - 'user_pass' => wp_generate_password(), |
|
| 68 | - 'user_email' => $email, |
|
| 65 | + $args = array( |
|
| 66 | + 'user_login' => wpinv_generate_user_name( $prefix ), |
|
| 67 | + 'user_pass' => wp_generate_password(), |
|
| 68 | + 'user_email' => $email, |
|
| 69 | 69 | 'role' => 'subscriber', |
| 70 | 70 | ); |
| 71 | 71 | |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | function wpinv_generate_user_name( $prefix = '' ) { |
| 83 | 83 | |
| 84 | 84 | // If prefix is an email, retrieve the part before the email. |
| 85 | - $prefix = strtok( $prefix, '@' ); |
|
| 85 | + $prefix = strtok( $prefix, '@' ); |
|
| 86 | 86 | $prefix = trim( $prefix, '.' ); |
| 87 | 87 | |
| 88 | - // Sanitize the username. |
|
| 89 | - $prefix = sanitize_user( $prefix, true ); |
|
| 88 | + // Sanitize the username. |
|
| 89 | + $prefix = sanitize_user( $prefix, true ); |
|
| 90 | 90 | |
| 91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 94 | - } |
|
| 91 | + $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 92 | + if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 93 | + $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | $username = $prefix; |
| 97 | 97 | $postfix = 2; |
@@ -220,43 +220,43 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | foreach ( getpaid_user_address_fields() as $key => $label ) { |
| 222 | 222 | |
| 223 | - // Display the country. |
|
| 224 | - if ( 'country' == $key ) { |
|
| 225 | - |
|
| 226 | - aui()->select( |
|
| 227 | - array( |
|
| 228 | - 'options' => wpinv_get_country_list(), |
|
| 229 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 230 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
| 231 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
| 232 | - 'placeholder' => $label, |
|
| 233 | - 'label' => wp_kses_post( $label ), |
|
| 234 | - 'label_type' => 'vertical', |
|
| 235 | - 'class' => 'getpaid-address-field', |
|
| 223 | + // Display the country. |
|
| 224 | + if ( 'country' == $key ) { |
|
| 225 | + |
|
| 226 | + aui()->select( |
|
| 227 | + array( |
|
| 228 | + 'options' => wpinv_get_country_list(), |
|
| 229 | + 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 230 | + 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
| 231 | + 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
| 232 | + 'placeholder' => $label, |
|
| 233 | + 'label' => wp_kses_post( $label ), |
|
| 234 | + 'label_type' => 'vertical', |
|
| 235 | + 'class' => 'getpaid-address-field', |
|
| 236 | 236 | ), |
| 237 | 237 | true |
| 238 | - ); |
|
| 239 | - |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - // Display the state. |
|
| 243 | - elseif ( 'state' == $key ) { |
|
| 244 | - |
|
| 245 | - getpaid_get_states_select_markup( |
|
| 246 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
| 247 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
| 248 | - $label, |
|
| 249 | - $label, |
|
| 250 | - '', |
|
| 251 | - false, |
|
| 252 | - '', |
|
| 253 | - 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 238 | + ); |
|
| 239 | + |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + // Display the state. |
|
| 243 | + elseif ( 'state' == $key ) { |
|
| 244 | + |
|
| 245 | + getpaid_get_states_select_markup( |
|
| 246 | + getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
| 247 | + getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
| 248 | + $label, |
|
| 249 | + $label, |
|
| 250 | + '', |
|
| 251 | + false, |
|
| 252 | + '', |
|
| 253 | + 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 254 | 254 | true |
| 255 | - ); |
|
| 255 | + ); |
|
| 256 | 256 | |
| 257 | 257 | } else { |
| 258 | 258 | |
| 259 | - aui()->input( |
|
| 259 | + aui()->input( |
|
| 260 | 260 | array( |
| 261 | 261 | 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
| 262 | 262 | 'id' => 'wpinv-' . sanitize_html_class( $key ), |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | 'class' => 'getpaid-address-field', |
| 269 | 269 | ), |
| 270 | 270 | true |
| 271 | - ); |
|
| 271 | + ); |
|
| 272 | 272 | |
| 273 | 273 | } |
| 274 | 274 | } |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | function getpaid_allowed_html() { |
| 408 | 408 | $allowed_html = wp_kses_allowed_html( 'post' ); |
| 409 | 409 | |
| 410 | - // form fields |
|
| 410 | + // form fields |
|
| 411 | 411 | $allowed_html['form'] = array( |
| 412 | 412 | 'action' => true, |
| 413 | 413 | 'accept' => true, |
@@ -419,12 +419,12 @@ discard block |
||
| 419 | 419 | ); |
| 420 | 420 | |
| 421 | 421 | // - input |
| 422 | - $allowed_html['input'] = array( |
|
| 423 | - 'class' => array(), |
|
| 424 | - 'id' => array(), |
|
| 425 | - 'name' => array(), |
|
| 426 | - 'value' => array(), |
|
| 427 | - 'type' => array(), |
|
| 422 | + $allowed_html['input'] = array( |
|
| 423 | + 'class' => array(), |
|
| 424 | + 'id' => array(), |
|
| 425 | + 'name' => array(), |
|
| 426 | + 'value' => array(), |
|
| 427 | + 'type' => array(), |
|
| 428 | 428 | 'placeholder' => array(), |
| 429 | 429 | 'autocomplete' => array(), |
| 430 | 430 | 'autofocus' => array(), |
@@ -438,33 +438,33 @@ discard block |
||
| 438 | 438 | 'max' => array(), |
| 439 | 439 | 'step' => array(), |
| 440 | 440 | 'size' => array(), |
| 441 | - ); |
|
| 441 | + ); |
|
| 442 | 442 | |
| 443 | 443 | // - input |
| 444 | - $allowed_html['textarea'] = array( |
|
| 445 | - 'class' => array(), |
|
| 446 | - 'id' => array(), |
|
| 447 | - 'name' => array(), |
|
| 448 | - 'value' => array(), |
|
| 449 | - ); |
|
| 450 | - |
|
| 451 | - // select |
|
| 452 | - $allowed_html['select'] = array( |
|
| 453 | - 'class' => array(), |
|
| 454 | - 'id' => array(), |
|
| 455 | - 'name' => array(), |
|
| 444 | + $allowed_html['textarea'] = array( |
|
| 445 | + 'class' => array(), |
|
| 446 | + 'id' => array(), |
|
| 447 | + 'name' => array(), |
|
| 448 | + 'value' => array(), |
|
| 449 | + ); |
|
| 450 | + |
|
| 451 | + // select |
|
| 452 | + $allowed_html['select'] = array( |
|
| 453 | + 'class' => array(), |
|
| 454 | + 'id' => array(), |
|
| 455 | + 'name' => array(), |
|
| 456 | 456 | 'autocomplete' => array(), |
| 457 | 457 | 'multiple' => array(), |
| 458 | - ); |
|
| 458 | + ); |
|
| 459 | 459 | |
| 460 | - // select options |
|
| 461 | - $allowed_html['option'] = array( |
|
| 462 | - 'selected' => array(), |
|
| 460 | + // select options |
|
| 461 | + $allowed_html['option'] = array( |
|
| 462 | + 'selected' => array(), |
|
| 463 | 463 | 'disabled' => array(), |
| 464 | 464 | 'value' => array(), |
| 465 | - ); |
|
| 465 | + ); |
|
| 466 | 466 | |
| 467 | - return $allowed_html; |
|
| 467 | + return $allowed_html; |
|
| 468 | 468 | |
| 469 | 469 | } |
| 470 | 470 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package GetPaid |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -defined( 'ABSPATH' ) || exit; |
|
| 9 | +defined('ABSPATH') || exit; |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * Generates a users select dropdown. |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | * @param array $args |
| 17 | 17 | * @see wp_dropdown_users |
| 18 | 18 | */ |
| 19 | -function wpinv_dropdown_users( $args = '' ) { |
|
| 19 | +function wpinv_dropdown_users($args = '') { |
|
| 20 | 20 | |
| 21 | - if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) { |
|
| 21 | + if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) { |
|
| 22 | 22 | $args['show'] = 'display_name_with_login'; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - return wp_dropdown_users( $args ); |
|
| 25 | + return wp_dropdown_users($args); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | * @return string capability to check against |
| 33 | 33 | * @param string $capalibilty Optional. The alternative capability to check against. |
| 34 | 34 | */ |
| 35 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
| 35 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
| 36 | 36 | |
| 37 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 37 | + if (current_user_can('manage_options')) { |
|
| 38 | 38 | return 'manage_options'; |
| 39 | 39 | }; |
| 40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @return bool |
| 49 | 49 | */ |
| 50 | 50 | function wpinv_current_user_can_manage_invoicing() { |
| 51 | - return current_user_can( wpinv_get_capability() ); |
|
| 51 | + return current_user_can(wpinv_get_capability()); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -57,19 +57,19 @@ discard block |
||
| 57 | 57 | * @since 1.0.19 |
| 58 | 58 | * @return int|WP_Error |
| 59 | 59 | */ |
| 60 | -function wpinv_create_user( $email, $prefix = '' ) { |
|
| 60 | +function wpinv_create_user($email, $prefix = '') { |
|
| 61 | 61 | |
| 62 | 62 | // Prepare user values. |
| 63 | - $prefix = preg_replace( '/\s+/', '', $prefix ); |
|
| 64 | - $prefix = empty( $prefix ) ? $email : $prefix; |
|
| 65 | - $args = array( |
|
| 66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
| 63 | + $prefix = preg_replace('/\s+/', '', $prefix); |
|
| 64 | + $prefix = empty($prefix) ? $email : $prefix; |
|
| 65 | + $args = array( |
|
| 66 | + 'user_login' => wpinv_generate_user_name($prefix), |
|
| 67 | 67 | 'user_pass' => wp_generate_password(), |
| 68 | 68 | 'user_email' => $email, |
| 69 | 69 | 'role' => 'subscriber', |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | - return wp_insert_user( $args ); |
|
| 72 | + return wp_insert_user($args); |
|
| 73 | 73 | |
| 74 | 74 | } |
| 75 | 75 | |
@@ -79,26 +79,26 @@ discard block |
||
| 79 | 79 | * @since 1.0.19 |
| 80 | 80 | * @return bool|WP_User |
| 81 | 81 | */ |
| 82 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
| 82 | +function wpinv_generate_user_name($prefix = '') { |
|
| 83 | 83 | |
| 84 | 84 | // If prefix is an email, retrieve the part before the email. |
| 85 | - $prefix = strtok( $prefix, '@' ); |
|
| 86 | - $prefix = trim( $prefix, '.' ); |
|
| 85 | + $prefix = strtok($prefix, '@'); |
|
| 86 | + $prefix = trim($prefix, '.'); |
|
| 87 | 87 | |
| 88 | 88 | // Sanitize the username. |
| 89 | - $prefix = sanitize_user( $prefix, true ); |
|
| 89 | + $prefix = sanitize_user($prefix, true); |
|
| 90 | 90 | |
| 91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
| 92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
| 93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
| 91 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
| 92 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
| 93 | + $prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $username = $prefix; |
| 97 | 97 | $postfix = 2; |
| 98 | 98 | |
| 99 | - while ( username_exists( $username ) ) { |
|
| 99 | + while (username_exists($username)) { |
|
| 100 | 100 | $username = "{$prefix}{$postfix}"; |
| 101 | - $postfix ++; |
|
| 101 | + $postfix++; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | return $username; |
@@ -115,31 +115,31 @@ discard block |
||
| 115 | 115 | $tabs = array( |
| 116 | 116 | |
| 117 | 117 | 'gp-invoices' => array( |
| 118 | - 'label' => __( 'Invoices', 'invoicing' ), // Name of the tab. |
|
| 118 | + 'label' => __('Invoices', 'invoicing'), // Name of the tab. |
|
| 119 | 119 | 'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead. |
| 120 | 120 | 'icon' => 'fas fa-file-invoice', // Shown on some profile plugins. |
| 121 | 121 | ), |
| 122 | 122 | |
| 123 | 123 | 'gp-subscriptions' => array( |
| 124 | - 'label' => __( 'Subscriptions', 'invoicing' ), |
|
| 124 | + 'label' => __('Subscriptions', 'invoicing'), |
|
| 125 | 125 | 'content' => '[wpinv_subscriptions]', |
| 126 | 126 | 'icon' => 'fas fa-redo', |
| 127 | 127 | ), |
| 128 | 128 | |
| 129 | 129 | 'gp-edit-address' => array( |
| 130 | - 'label' => __( 'Billing Address', 'invoicing' ), |
|
| 130 | + 'label' => __('Billing Address', 'invoicing'), |
|
| 131 | 131 | 'callback' => 'getpaid_display_address_edit_tab', |
| 132 | 132 | 'icon' => 'fas fa-credit-card', |
| 133 | 133 | ), |
| 134 | 134 | |
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | - $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs ); |
|
| 137 | + $tabs = apply_filters('getpaid_user_content_tabs', $tabs); |
|
| 138 | 138 | |
| 139 | 139 | // Make sure address editing is last on the list. |
| 140 | - if ( isset( $tabs['gp-edit-address'] ) ) { |
|
| 140 | + if (isset($tabs['gp-edit-address'])) { |
|
| 141 | 141 | $address = $tabs['gp-edit-address']; |
| 142 | - unset( $tabs['gp-edit-address'] ); |
|
| 142 | + unset($tabs['gp-edit-address']); |
|
| 143 | 143 | $tabs['gp-edit-address'] = $address; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -153,19 +153,19 @@ discard block |
||
| 153 | 153 | * @param array $tab |
| 154 | 154 | * @return array |
| 155 | 155 | */ |
| 156 | -function getpaid_prepare_user_content_tab( $tab ) { |
|
| 156 | +function getpaid_prepare_user_content_tab($tab) { |
|
| 157 | 157 | |
| 158 | - if ( ! empty( $tab['callback'] ) ) { |
|
| 159 | - return call_user_func( $tab['callback'] ); |
|
| 158 | + if (!empty($tab['callback'])) { |
|
| 159 | + return call_user_func($tab['callback']); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( ! empty( $tab['content'] ) ) { |
|
| 163 | - return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) ); |
|
| 162 | + if (!empty($tab['content'])) { |
|
| 163 | + return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content'])))))))); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | $notice = aui()->alert( |
| 167 | 167 | array( |
| 168 | - 'content' => __( 'This tab has no content or content callback.', 'invoicing' ), |
|
| 168 | + 'content' => __('This tab has no content or content callback.', 'invoicing'), |
|
| 169 | 169 | 'type' => 'error', |
| 170 | 170 | ) |
| 171 | 171 | ); |
@@ -181,14 +181,14 @@ discard block |
||
| 181 | 181 | * @param string $default |
| 182 | 182 | * @return array |
| 183 | 183 | */ |
| 184 | -function getpaid_get_tab_url( $tab, $default ) { |
|
| 184 | +function getpaid_get_tab_url($tab, $default) { |
|
| 185 | 185 | global $getpaid_tab_url; |
| 186 | 186 | |
| 187 | - if ( empty( $getpaid_tab_url ) ) { |
|
| 187 | + if (empty($getpaid_tab_url)) { |
|
| 188 | 188 | return $default; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - return sprintf( $getpaid_tab_url, $tab ); |
|
| 191 | + return sprintf($getpaid_tab_url, $tab); |
|
| 192 | 192 | |
| 193 | 193 | } |
| 194 | 194 | |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function getpaid_display_address_edit_tab() { |
| 202 | 202 | |
| 203 | - if ( 0 === get_current_user_id() ) { |
|
| 203 | + if (0 === get_current_user_id()) { |
|
| 204 | 204 | return '<div class="bsui">' . aui()->alert( |
| 205 | 205 | array( |
| 206 | 206 | 'type' => 'error', |
| 207 | - 'content' => __( 'Your must be logged in to view this section', 'invoicing' ), |
|
| 207 | + 'content' => __('Your must be logged in to view this section', 'invoicing'), |
|
| 208 | 208 | 'dismissible' => false, |
| 209 | 209 | ) |
| 210 | 210 | ) . '</div>'; |
@@ -218,19 +218,19 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | <?php |
| 220 | 220 | |
| 221 | - foreach ( getpaid_user_address_fields() as $key => $label ) { |
|
| 221 | + foreach (getpaid_user_address_fields() as $key => $label) { |
|
| 222 | 222 | |
| 223 | 223 | // Display the country. |
| 224 | - if ( 'country' == $key ) { |
|
| 224 | + if ('country' == $key) { |
|
| 225 | 225 | |
| 226 | 226 | aui()->select( |
| 227 | 227 | array( |
| 228 | 228 | 'options' => wpinv_get_country_list(), |
| 229 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 230 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
| 231 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
| 229 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
| 230 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
| 231 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
| 232 | 232 | 'placeholder' => $label, |
| 233 | - 'label' => wp_kses_post( $label ), |
|
| 233 | + 'label' => wp_kses_post($label), |
|
| 234 | 234 | 'label_type' => 'vertical', |
| 235 | 235 | 'class' => 'getpaid-address-field', |
| 236 | 236 | ), |
@@ -240,17 +240,17 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | // Display the state. |
| 243 | - elseif ( 'state' == $key ) { |
|
| 243 | + elseif ('state' == $key) { |
|
| 244 | 244 | |
| 245 | 245 | getpaid_get_states_select_markup( |
| 246 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
| 247 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
| 246 | + getpaid_get_user_address_field(get_current_user_id(), 'country'), |
|
| 247 | + getpaid_get_user_address_field(get_current_user_id(), 'state'), |
|
| 248 | 248 | $label, |
| 249 | 249 | $label, |
| 250 | 250 | '', |
| 251 | 251 | false, |
| 252 | 252 | '', |
| 253 | - 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 253 | + 'getpaid_address[' . esc_attr($key) . ']', |
|
| 254 | 254 | true |
| 255 | 255 | ); |
| 256 | 256 | |
@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | aui()->input( |
| 260 | 260 | array( |
| 261 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
| 262 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
| 261 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
| 262 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
| 263 | 263 | 'placeholder' => $label, |
| 264 | - 'label' => wp_kses_post( $label ), |
|
| 264 | + 'label' => wp_kses_post($label), |
|
| 265 | 265 | 'label_type' => 'vertical', |
| 266 | 266 | 'type' => 'text', |
| 267 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
| 267 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
| 268 | 268 | 'class' => 'getpaid-address-field', |
| 269 | 269 | ), |
| 270 | 270 | true |
@@ -278,32 +278,32 @@ discard block |
||
| 278 | 278 | 'name' => 'getpaid_address[email_cc]', |
| 279 | 279 | 'id' => 'wpinv-email_cc', |
| 280 | 280 | 'placeholder' => '[email protected], [email protected]', |
| 281 | - 'label' => __( 'Other email addresses', 'invoicing' ), |
|
| 281 | + 'label' => __('Other email addresses', 'invoicing'), |
|
| 282 | 282 | 'label_type' => 'vertical', |
| 283 | 283 | 'type' => 'text', |
| 284 | - 'value' => sanitize_text_field( get_user_meta( get_current_user_id(), '_wpinv_email_cc', true ) ), |
|
| 284 | + 'value' => sanitize_text_field(get_user_meta(get_current_user_id(), '_wpinv_email_cc', true)), |
|
| 285 | 285 | 'class' => 'getpaid-address-field', |
| 286 | - 'help_text' => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ), |
|
| 286 | + 'help_text' => __('Optionally provide other email addresses where we should send payment notifications', 'invoicing'), |
|
| 287 | 287 | ), |
| 288 | 288 | true |
| 289 | 289 | ); |
| 290 | 290 | |
| 291 | - do_action( 'getpaid_display_address_edit_tab' ); |
|
| 291 | + do_action('getpaid_display_address_edit_tab'); |
|
| 292 | 292 | |
| 293 | 293 | aui()->input( |
| 294 | 294 | array( |
| 295 | 295 | 'name' => 'getpaid_profile_edit_submit_button', |
| 296 | 296 | 'id' => 'getpaid_profile_edit_submit_button', |
| 297 | - 'value' => __( 'Save Address', 'invoicing' ), |
|
| 298 | - 'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ), |
|
| 297 | + 'value' => __('Save Address', 'invoicing'), |
|
| 298 | + 'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'), |
|
| 299 | 299 | 'type' => 'submit', |
| 300 | 300 | 'class' => 'btn btn-primary btn-block submit-button', |
| 301 | 301 | ), |
| 302 | 302 | true |
| 303 | 303 | ); |
| 304 | 304 | |
| 305 | - wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 306 | - getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' ); |
|
| 305 | + wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); |
|
| 306 | + getpaid_hidden_field('getpaid-action', 'edit_billing_details'); |
|
| 307 | 307 | ?> |
| 308 | 308 | |
| 309 | 309 | </form> |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | return ob_get_clean(); |
| 315 | 315 | } |
| 316 | -add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' ); |
|
| 316 | +add_shortcode('getpaid_edit_address', 'getpaid_display_address_edit_tab'); |
|
| 317 | 317 | |
| 318 | 318 | /** |
| 319 | 319 | * Saves the billing address edit tab. |
@@ -321,30 +321,30 @@ discard block |
||
| 321 | 321 | * @since 2.1.4 |
| 322 | 322 | * @param array $data |
| 323 | 323 | */ |
| 324 | -function getpaid_save_address_edit_tab( $data ) { |
|
| 324 | +function getpaid_save_address_edit_tab($data) { |
|
| 325 | 325 | |
| 326 | - if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) { |
|
| 326 | + if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) { |
|
| 327 | 327 | return; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | $data = $data['getpaid_address']; |
| 331 | 331 | $user_id = get_current_user_id(); |
| 332 | 332 | |
| 333 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
| 333 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
| 334 | 334 | |
| 335 | - if ( isset( $data[ $field ] ) ) { |
|
| 336 | - $value = sanitize_text_field( $data[ $field ] ); |
|
| 337 | - update_user_meta( $user_id, '_wpinv_' . $field, $value ); |
|
| 335 | + if (isset($data[$field])) { |
|
| 336 | + $value = sanitize_text_field($data[$field]); |
|
| 337 | + update_user_meta($user_id, '_wpinv_' . $field, $value); |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - if ( isset( $data['email_cc'] ) ) { |
|
| 342 | - update_user_meta( $user_id, '_wpinv_email_cc', sanitize_text_field( $data['email_cc'] ) ); |
|
| 341 | + if (isset($data['email_cc'])) { |
|
| 342 | + update_user_meta($user_id, '_wpinv_email_cc', sanitize_text_field($data['email_cc'])); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | - wpinv_set_error( 'address_updated' ); |
|
| 345 | + wpinv_set_error('address_updated'); |
|
| 346 | 346 | } |
| 347 | -add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' ); |
|
| 347 | +add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab'); |
|
| 348 | 348 | |
| 349 | 349 | |
| 350 | 350 | /* |
@@ -362,27 +362,27 @@ discard block |
||
| 362 | 362 | * @param array $tabs |
| 363 | 363 | * @return array |
| 364 | 364 | */ |
| 365 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
| 365 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
| 366 | 366 | |
| 367 | 367 | // Abort if the integration is inactive. |
| 368 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
| 368 | + if (!getpaid_is_userswp_integration_active()) { |
|
| 369 | 369 | return $tabs; |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - $new_tabs = array(); |
|
| 372 | + $new_tabs = array(); |
|
| 373 | 373 | |
| 374 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
| 374 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
| 375 | 375 | |
| 376 | - $new_tabs[ $slug ] = array( |
|
| 376 | + $new_tabs[$slug] = array( |
|
| 377 | 377 | 'title' => $tab['label'], |
| 378 | 378 | 'icon' => $tab['icon'], |
| 379 | 379 | ); |
| 380 | 380 | |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - return array_merge( $tabs, $new_tabs ); |
|
| 383 | + return array_merge($tabs, $new_tabs); |
|
| 384 | 384 | } |
| 385 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
| 385 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
| 386 | 386 | |
| 387 | 387 | /** |
| 388 | 388 | * Display our UsersWP account tabs. |
@@ -391,21 +391,21 @@ discard block |
||
| 391 | 391 | * @param array $tabs |
| 392 | 392 | * @return array |
| 393 | 393 | */ |
| 394 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
| 394 | +function getpaid_display_userswp_account_tabs($tab) { |
|
| 395 | 395 | global $getpaid_tab_url; |
| 396 | 396 | |
| 397 | 397 | $our_tabs = getpaid_get_user_content_tabs(); |
| 398 | 398 | |
| 399 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
| 400 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
| 401 | - echo wp_kses( getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ), getpaid_allowed_html() ); |
|
| 399 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
| 400 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
| 401 | + echo wp_kses(getpaid_prepare_user_content_tab($our_tabs[$tab]), getpaid_allowed_html()); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | } |
| 405 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
| 405 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
| 406 | 406 | |
| 407 | 407 | function getpaid_allowed_html() { |
| 408 | - $allowed_html = wp_kses_allowed_html( 'post' ); |
|
| 408 | + $allowed_html = wp_kses_allowed_html('post'); |
|
| 409 | 409 | |
| 410 | 410 | // form fields |
| 411 | 411 | $allowed_html['form'] = array( |
@@ -476,17 +476,17 @@ discard block |
||
| 476 | 476 | * @param string $tab Current tab. |
| 477 | 477 | * @return string Title. |
| 478 | 478 | */ |
| 479 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
| 479 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
| 480 | 480 | |
| 481 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
| 481 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
| 482 | 482 | |
| 483 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
| 484 | - return $our_tabs[ $tab ]['label']; |
|
| 483 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
| 484 | + return $our_tabs[$tab]['label']; |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | return $title; |
| 488 | 488 | } |
| 489 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
| 489 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
| 490 | 490 | |
| 491 | 491 | /** |
| 492 | 492 | * Registers the UsersWP integration settings. |
@@ -495,26 +495,26 @@ discard block |
||
| 495 | 495 | * @param array $settings An array of integration settings. |
| 496 | 496 | * @return array |
| 497 | 497 | */ |
| 498 | -function getpaid_register_userswp_settings( $settings ) { |
|
| 498 | +function getpaid_register_userswp_settings($settings) { |
|
| 499 | 499 | |
| 500 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
| 500 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
| 501 | 501 | |
| 502 | 502 | $settings[] = array( |
| 503 | 503 | |
| 504 | 504 | 'id' => 'userswp', |
| 505 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
| 505 | + 'label' => __('UsersWP', 'invoicing'), |
|
| 506 | 506 | 'settings' => array( |
| 507 | 507 | |
| 508 | 508 | 'userswp_settings' => array( |
| 509 | 509 | 'id' => 'userswp_settings', |
| 510 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
| 510 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
| 511 | 511 | 'type' => 'header', |
| 512 | 512 | ), |
| 513 | 513 | |
| 514 | 514 | 'enable_userswp' => array( |
| 515 | 515 | 'id' => 'enable_userswp', |
| 516 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
| 517 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
| 516 | + 'name' => __('Enable Integration', 'invoicing'), |
|
| 517 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
| 518 | 518 | 'type' => 'checkbox', |
| 519 | 519 | 'std' => 1, |
| 520 | 520 | ), |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | return $settings; |
| 529 | 529 | } |
| 530 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
| 530 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
| 531 | 531 | |
| 532 | 532 | /** |
| 533 | 533 | * Ovewrites the invoices history page to UsersWP. |
@@ -535,18 +535,18 @@ discard block |
||
| 535 | 535 | * @since 2.3.1 |
| 536 | 536 | * @return bool |
| 537 | 537 | */ |
| 538 | -function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) { |
|
| 538 | +function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) { |
|
| 539 | 539 | |
| 540 | 540 | $our_tabs = getpaid_get_user_content_tabs(); |
| 541 | 541 | $tab = "gp-{$post_type}s"; |
| 542 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
| 543 | - return add_query_arg( 'type', $tab, uwp_get_account_page_url() ); |
|
| 542 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
| 543 | + return add_query_arg('type', $tab, uwp_get_account_page_url()); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | return $url; |
| 547 | 547 | |
| 548 | 548 | } |
| 549 | -add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 ); |
|
| 549 | +add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2); |
|
| 550 | 550 | |
| 551 | 551 | /** |
| 552 | 552 | * Checks if the integration is enabled. |
@@ -555,8 +555,8 @@ discard block |
||
| 555 | 555 | * @return bool |
| 556 | 556 | */ |
| 557 | 557 | function getpaid_is_userswp_integration_active() { |
| 558 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
| 559 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
| 558 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
| 559 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | /* |
@@ -574,26 +574,26 @@ discard block |
||
| 574 | 574 | * @param array $settings An array of integration settings. |
| 575 | 575 | * @return array |
| 576 | 576 | */ |
| 577 | -function getpaid_register_buddypress_settings( $settings ) { |
|
| 577 | +function getpaid_register_buddypress_settings($settings) { |
|
| 578 | 578 | |
| 579 | - if ( class_exists( 'BuddyPress' ) ) { |
|
| 579 | + if (class_exists('BuddyPress')) { |
|
| 580 | 580 | |
| 581 | 581 | $settings[] = array( |
| 582 | 582 | |
| 583 | 583 | 'id' => 'buddypress', |
| 584 | - 'label' => __( 'BuddyPress', 'invoicing' ), |
|
| 584 | + 'label' => __('BuddyPress', 'invoicing'), |
|
| 585 | 585 | 'settings' => array( |
| 586 | 586 | |
| 587 | 587 | 'buddypress_settings' => array( |
| 588 | 588 | 'id' => 'buddypress_settings', |
| 589 | - 'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>', |
|
| 589 | + 'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>', |
|
| 590 | 590 | 'type' => 'header', |
| 591 | 591 | ), |
| 592 | 592 | |
| 593 | 593 | 'enable_buddypress' => array( |
| 594 | 594 | 'id' => 'enable_buddypress', |
| 595 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
| 596 | - 'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ), |
|
| 595 | + 'name' => __('Enable Integration', 'invoicing'), |
|
| 596 | + 'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'), |
|
| 597 | 597 | 'type' => 'checkbox', |
| 598 | 598 | 'std' => 1, |
| 599 | 599 | ), |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | |
| 607 | 607 | return $settings; |
| 608 | 608 | } |
| 609 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' ); |
|
| 609 | +add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings'); |
|
| 610 | 610 | |
| 611 | 611 | /** |
| 612 | 612 | * Checks if the integration is enabled. |
@@ -615,8 +615,8 @@ discard block |
||
| 615 | 615 | * @return bool |
| 616 | 616 | */ |
| 617 | 617 | function getpaid_is_buddypress_integration_active() { |
| 618 | - $enabled = wpinv_get_option( 'enable_buddypress', 1 ); |
|
| 619 | - return class_exists( 'BuddyPress' ) && ! empty( $enabled ); |
|
| 618 | + $enabled = wpinv_get_option('enable_buddypress', 1); |
|
| 619 | + return class_exists('BuddyPress') && !empty($enabled); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | /** |
@@ -627,13 +627,13 @@ discard block |
||
| 627 | 627 | */ |
| 628 | 628 | function getpaid_setup_buddypress_integration() { |
| 629 | 629 | |
| 630 | - if ( getpaid_is_buddypress_integration_active() ) { |
|
| 630 | + if (getpaid_is_buddypress_integration_active()) { |
|
| 631 | 631 | require_once WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php'; |
| 632 | 632 | buddypress()->getpaid = new BP_GetPaid_Component(); |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | } |
| 636 | -add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' ); |
|
| 636 | +add_action('bp_setup_components', 'getpaid_setup_buddypress_integration'); |
|
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * Checks if a given user has purchased a given item. |
@@ -642,10 +642,10 @@ discard block |
||
| 642 | 642 | * @param int $item_id The item id. |
| 643 | 643 | * @return int The IDs of users who purchased the item. |
| 644 | 644 | */ |
| 645 | -function getpaid_user_ids_who_purchased_item( $item_id ) { |
|
| 645 | +function getpaid_user_ids_who_purchased_item($item_id) { |
|
| 646 | 646 | global $wpdb; |
| 647 | 647 | |
| 648 | - if ( empty( $item_id ) ) { |
|
| 648 | + if (empty($item_id)) { |
|
| 649 | 649 | return false; |
| 650 | 650 | } |
| 651 | 651 | |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | ) |
| 659 | 659 | ); |
| 660 | 660 | |
| 661 | - return wp_parse_id_list( $ids ); |
|
| 661 | + return wp_parse_id_list($ids); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | /** |
@@ -667,10 +667,10 @@ discard block |
||
| 667 | 667 | * @since 2.6.17 |
| 668 | 668 | * @param int $user_id The user id. |
| 669 | 669 | */ |
| 670 | -function getpaid_has_user_purchased_item( $user_id, $item_id ) { |
|
| 670 | +function getpaid_has_user_purchased_item($user_id, $item_id) { |
|
| 671 | 671 | global $wpdb; |
| 672 | 672 | |
| 673 | - if ( empty( $user_id ) ) { |
|
| 673 | + if (empty($user_id)) { |
|
| 674 | 674 | return false; |
| 675 | 675 | } |
| 676 | 676 | |
@@ -685,5 +685,5 @@ discard block |
||
| 685 | 685 | ) |
| 686 | 686 | ); |
| 687 | 687 | |
| 688 | - return ! empty( $count ); |
|
| 688 | + return !empty($count); |
|
| 689 | 689 | } |
@@ -1,32 +1,32 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | - // Is the request set up correctly? |
|
| 4 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 5 | - return aui()->alert( |
|
| 6 | - array( |
|
| 7 | - 'type' => 'warning', |
|
| 8 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
| 9 | - ) |
|
| 10 | - ); |
|
| 11 | - wp_die( esc_html__( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - // Payment form or button? |
|
| 15 | - if ( ! empty( $_GET['form'] ) ) { |
|
| 16 | - |
|
| 17 | - $shortcode = sprintf( |
|
| 18 | - '[getpaid form=%s]', |
|
| 19 | - (int) $_GET['form'] |
|
| 20 | - ); |
|
| 21 | - |
|
| 22 | - } else { |
|
| 23 | - |
|
| 24 | - $shortcode = sprintf( |
|
| 25 | - '[getpaid item=%s]', |
|
| 26 | - esc_attr( urldecode( $_GET['item'] ) ) |
|
| 27 | - ); |
|
| 28 | - |
|
| 29 | - } |
|
| 3 | + // Is the request set up correctly? |
|
| 4 | + if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 5 | + return aui()->alert( |
|
| 6 | + array( |
|
| 7 | + 'type' => 'warning', |
|
| 8 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
| 9 | + ) |
|
| 10 | + ); |
|
| 11 | + wp_die( esc_html__( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + // Payment form or button? |
|
| 15 | + if ( ! empty( $_GET['form'] ) ) { |
|
| 16 | + |
|
| 17 | + $shortcode = sprintf( |
|
| 18 | + '[getpaid form=%s]', |
|
| 19 | + (int) $_GET['form'] |
|
| 20 | + ); |
|
| 21 | + |
|
| 22 | + } else { |
|
| 23 | + |
|
| 24 | + $shortcode = sprintf( |
|
| 25 | + '[getpaid item=%s]', |
|
| 26 | + esc_attr( urldecode( $_GET['item'] ) ) |
|
| 27 | + ); |
|
| 28 | + |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | 31 | ?> |
| 32 | 32 | |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | <title><?php echo esc_html( get_bloginfo( 'name' ) ); ?></title> |
| 46 | 46 | <?php |
| 47 | - wp_enqueue_scripts(); |
|
| 48 | - wp_print_styles(); |
|
| 49 | - wp_print_head_scripts(); |
|
| 50 | - wp_custom_css_cb(); |
|
| 51 | - wpinv_get_template( 'frontend-head.php' ); |
|
| 52 | - wp_site_icon(); |
|
| 53 | - ?> |
|
| 47 | + wp_enqueue_scripts(); |
|
| 48 | + wp_print_styles(); |
|
| 49 | + wp_print_head_scripts(); |
|
| 50 | + wp_custom_css_cb(); |
|
| 51 | + wpinv_get_template( 'frontend-head.php' ); |
|
| 52 | + wp_site_icon(); |
|
| 53 | + ?> |
|
| 54 | 54 | |
| 55 | 55 | <style type="text/css"> |
| 56 | 56 | .body{ |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | <body class="body page-template-default page"> |
| 85 | 85 | <div id="getpaid-form-embed" class="container my-5 page type-page status-publish hentry post post-content"> |
| 86 | 86 | <?php |
| 87 | - do_action( 'getpaid_payment_form_embed_top' ); |
|
| 88 | - echo do_shortcode( $shortcode ); |
|
| 89 | - do_action( 'getpaid_payment_form_embed_bottom' ); |
|
| 90 | - wpinv_get_template( 'frontend-footer.php' ); |
|
| 91 | - ?> |
|
| 87 | + do_action( 'getpaid_payment_form_embed_top' ); |
|
| 88 | + echo do_shortcode( $shortcode ); |
|
| 89 | + do_action( 'getpaid_payment_form_embed_bottom' ); |
|
| 90 | + wpinv_get_template( 'frontend-footer.php' ); |
|
| 91 | + ?> |
|
| 92 | 92 | </div> |
| 93 | 93 | <?php wp_footer(); ?> |
| 94 | 94 | </body> |
@@ -1,18 +1,18 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Is the request set up correctly? |
| 4 | - if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) { |
|
| 4 | + if (empty($_GET['form']) && empty($_GET['item'])) { |
|
| 5 | 5 | return aui()->alert( |
| 6 | 6 | array( |
| 7 | 7 | 'type' => 'warning', |
| 8 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
| 8 | + 'content' => __('No payment form or item selected', 'invoicing'), |
|
| 9 | 9 | ) |
| 10 | 10 | ); |
| 11 | - wp_die( esc_html__( 'No payment form or item selected', 'invoicing' ), 400 ); |
|
| 11 | + wp_die(esc_html__('No payment form or item selected', 'invoicing'), 400); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Payment form or button? |
| 15 | - if ( ! empty( $_GET['form'] ) ) { |
|
| 15 | + if (!empty($_GET['form'])) { |
|
| 16 | 16 | |
| 17 | 17 | $shortcode = sprintf( |
| 18 | 18 | '[getpaid form=%s]', |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | $shortcode = sprintf( |
| 25 | 25 | '[getpaid item=%s]', |
| 26 | - esc_attr( urldecode( $_GET['item'] ) ) |
|
| 26 | + esc_attr(urldecode($_GET['item'])) |
|
| 27 | 27 | ); |
| 28 | 28 | |
| 29 | 29 | } |
@@ -35,20 +35,20 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | <head> |
| 37 | 37 | |
| 38 | - <meta charset="<?php bloginfo( 'charset' ); ?>"> |
|
| 38 | + <meta charset="<?php bloginfo('charset'); ?>"> |
|
| 39 | 39 | <meta name="viewport" content="width=device-width, initial-scale=1.0" > |
| 40 | 40 | |
| 41 | 41 | <meta name="robots" content="noindex,nofollow"> |
| 42 | 42 | |
| 43 | 43 | <link rel="profile" href="https://gmpg.org/xfn/11"> |
| 44 | 44 | |
| 45 | - <title><?php echo esc_html( get_bloginfo( 'name' ) ); ?></title> |
|
| 45 | + <title><?php echo esc_html(get_bloginfo('name')); ?></title> |
|
| 46 | 46 | <?php |
| 47 | 47 | wp_enqueue_scripts(); |
| 48 | 48 | wp_print_styles(); |
| 49 | 49 | wp_print_head_scripts(); |
| 50 | 50 | wp_custom_css_cb(); |
| 51 | - wpinv_get_template( 'frontend-head.php' ); |
|
| 51 | + wpinv_get_template('frontend-head.php'); |
|
| 52 | 52 | wp_site_icon(); |
| 53 | 53 | ?> |
| 54 | 54 | |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | <body class="body page-template-default page"> |
| 85 | 85 | <div id="getpaid-form-embed" class="container my-5 page type-page status-publish hentry post post-content"> |
| 86 | 86 | <?php |
| 87 | - do_action( 'getpaid_payment_form_embed_top' ); |
|
| 88 | - echo do_shortcode( $shortcode ); |
|
| 89 | - do_action( 'getpaid_payment_form_embed_bottom' ); |
|
| 90 | - wpinv_get_template( 'frontend-footer.php' ); |
|
| 87 | + do_action('getpaid_payment_form_embed_top'); |
|
| 88 | + echo do_shortcode($shortcode); |
|
| 89 | + do_action('getpaid_payment_form_embed_bottom'); |
|
| 90 | + wpinv_get_template('frontend-footer.php'); |
|
| 91 | 91 | ?> |
| 92 | 92 | </div> |
| 93 | 93 | <?php wp_footer(); ?> |