@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | - exit; |
|
| 7 | + exit; |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -12,112 +12,112 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | abstract class WPInv_Session { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Customer ID. |
|
| 17 | - * |
|
| 18 | - * @var int $_customer_id Customer ID. |
|
| 19 | - */ |
|
| 20 | - protected $_customer_id; |
|
| 15 | + /** |
|
| 16 | + * Customer ID. |
|
| 17 | + * |
|
| 18 | + * @var int $_customer_id Customer ID. |
|
| 19 | + */ |
|
| 20 | + protected $_customer_id; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Session Data. |
|
| 24 | - * |
|
| 25 | - * @var array $_data Data array. |
|
| 26 | - */ |
|
| 27 | - protected $_data = array(); |
|
| 22 | + /** |
|
| 23 | + * Session Data. |
|
| 24 | + * |
|
| 25 | + * @var array $_data Data array. |
|
| 26 | + */ |
|
| 27 | + protected $_data = array(); |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Dirty when the session needs saving. |
|
| 31 | - * |
|
| 32 | - * @var bool $_dirty When something changes |
|
| 33 | - */ |
|
| 34 | - protected $_dirty = false; |
|
| 29 | + /** |
|
| 30 | + * Dirty when the session needs saving. |
|
| 31 | + * |
|
| 32 | + * @var bool $_dirty When something changes |
|
| 33 | + */ |
|
| 34 | + protected $_dirty = false; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Init hooks and session data. Extended by child classes. |
|
| 38 | - * |
|
| 39 | - * @since 3.3.0 |
|
| 40 | - */ |
|
| 41 | - public function init() {} |
|
| 36 | + /** |
|
| 37 | + * Init hooks and session data. Extended by child classes. |
|
| 38 | + * |
|
| 39 | + * @since 3.3.0 |
|
| 40 | + */ |
|
| 41 | + public function init() {} |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Cleanup session data. Extended by child classes. |
|
| 45 | - */ |
|
| 46 | - public function cleanup_sessions() {} |
|
| 43 | + /** |
|
| 44 | + * Cleanup session data. Extended by child classes. |
|
| 45 | + */ |
|
| 46 | + public function cleanup_sessions() {} |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Magic get method. |
|
| 50 | - * |
|
| 51 | - * @param mixed $key Key to get. |
|
| 52 | - * @return mixed |
|
| 53 | - */ |
|
| 54 | - public function __get( $key ) { |
|
| 55 | - return $this->get( $key ); |
|
| 56 | - } |
|
| 48 | + /** |
|
| 49 | + * Magic get method. |
|
| 50 | + * |
|
| 51 | + * @param mixed $key Key to get. |
|
| 52 | + * @return mixed |
|
| 53 | + */ |
|
| 54 | + public function __get( $key ) { |
|
| 55 | + return $this->get( $key ); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Magic set method. |
|
| 60 | - * |
|
| 61 | - * @param mixed $key Key to set. |
|
| 62 | - * @param mixed $value Value to set. |
|
| 63 | - */ |
|
| 64 | - public function __set( $key, $value ) { |
|
| 65 | - $this->set( $key, $value ); |
|
| 66 | - } |
|
| 58 | + /** |
|
| 59 | + * Magic set method. |
|
| 60 | + * |
|
| 61 | + * @param mixed $key Key to set. |
|
| 62 | + * @param mixed $value Value to set. |
|
| 63 | + */ |
|
| 64 | + public function __set( $key, $value ) { |
|
| 65 | + $this->set( $key, $value ); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * Magic isset method. |
|
| 70 | - * |
|
| 71 | - * @param mixed $key Key to check. |
|
| 72 | - * @return bool |
|
| 73 | - */ |
|
| 74 | - public function __isset( $key ) { |
|
| 75 | - return isset( $this->_data[ sanitize_title( $key ) ] ); |
|
| 76 | - } |
|
| 68 | + /** |
|
| 69 | + * Magic isset method. |
|
| 70 | + * |
|
| 71 | + * @param mixed $key Key to check. |
|
| 72 | + * @return bool |
|
| 73 | + */ |
|
| 74 | + public function __isset( $key ) { |
|
| 75 | + return isset( $this->_data[ sanitize_title( $key ) ] ); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Magic unset method. |
|
| 80 | - * |
|
| 81 | - * @param mixed $key Key to unset. |
|
| 82 | - */ |
|
| 83 | - public function __unset( $key ) { |
|
| 84 | - if ( isset( $this->_data[ $key ] ) ) { |
|
| 85 | - unset( $this->_data[ $key ] ); |
|
| 86 | - $this->_dirty = true; |
|
| 87 | - } |
|
| 88 | - } |
|
| 78 | + /** |
|
| 79 | + * Magic unset method. |
|
| 80 | + * |
|
| 81 | + * @param mixed $key Key to unset. |
|
| 82 | + */ |
|
| 83 | + public function __unset( $key ) { |
|
| 84 | + if ( isset( $this->_data[ $key ] ) ) { |
|
| 85 | + unset( $this->_data[ $key ] ); |
|
| 86 | + $this->_dirty = true; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Get a session variable. |
|
| 92 | - * |
|
| 93 | - * @param string $key Key to get. |
|
| 94 | - * @param mixed $default used if the session variable isn't set. |
|
| 95 | - * @return array|string value of session variable |
|
| 96 | - */ |
|
| 97 | - public function get( $key, $default = null ) { |
|
| 98 | - $key = sanitize_key( $key ); |
|
| 99 | - return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default; |
|
| 100 | - } |
|
| 90 | + /** |
|
| 91 | + * Get a session variable. |
|
| 92 | + * |
|
| 93 | + * @param string $key Key to get. |
|
| 94 | + * @param mixed $default used if the session variable isn't set. |
|
| 95 | + * @return array|string value of session variable |
|
| 96 | + */ |
|
| 97 | + public function get( $key, $default = null ) { |
|
| 98 | + $key = sanitize_key( $key ); |
|
| 99 | + return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Set a session variable. |
|
| 104 | - * |
|
| 105 | - * @param string $key Key to set. |
|
| 106 | - * @param mixed $value Value to set. |
|
| 107 | - */ |
|
| 108 | - public function set( $key, $value ) { |
|
| 109 | - if ( $value !== $this->get( $key ) ) { |
|
| 110 | - $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
|
| 111 | - $this->_dirty = true; |
|
| 112 | - } |
|
| 113 | - } |
|
| 102 | + /** |
|
| 103 | + * Set a session variable. |
|
| 104 | + * |
|
| 105 | + * @param string $key Key to set. |
|
| 106 | + * @param mixed $value Value to set. |
|
| 107 | + */ |
|
| 108 | + public function set( $key, $value ) { |
|
| 109 | + if ( $value !== $this->get( $key ) ) { |
|
| 110 | + $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
|
| 111 | + $this->_dirty = true; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - /** |
|
| 116 | - * Get customer ID. |
|
| 117 | - * |
|
| 118 | - * @return int |
|
| 119 | - */ |
|
| 120 | - public function get_customer_id() { |
|
| 121 | - return $this->_customer_id; |
|
| 122 | - } |
|
| 115 | + /** |
|
| 116 | + * Get customer ID. |
|
| 117 | + * |
|
| 118 | + * @return int |
|
| 119 | + */ |
|
| 120 | + public function get_customer_id() { |
|
| 121 | + return $this->_customer_id; |
|
| 122 | + } |
|
| 123 | 123 | } |
@@ -1355,10 +1355,10 @@ |
||
| 1355 | 1355 | $data['cart_details'][$key]['price'] = wpinv_round_amount( $item_total ); |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | - $total = $data['subtotal'] - $data['discount'] + $data['tax']; |
|
| 1359 | - if ( $total < 0 ) { |
|
| 1360 | - $total = 0; |
|
| 1361 | - } |
|
| 1358 | + $total = $data['subtotal'] - $data['discount'] + $data['tax']; |
|
| 1359 | + if ( $total < 0 ) { |
|
| 1360 | + $total = 0; |
|
| 1361 | + } |
|
| 1362 | 1362 | |
| 1363 | 1363 | $data['subtotal'] = wpinv_round_amount( $cart_subtotal ); |
| 1364 | 1364 | $data['discount'] = wpinv_round_amount( $cart_discount ); |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | function wpinv_get_payment_key( $invoice_id = 0 ) { |
| 672 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 672 | + $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 673 | 673 | return $invoice->get_key(); |
| 674 | 674 | } |
| 675 | 675 | |
@@ -919,7 +919,7 @@ discard block |
||
| 919 | 919 | return false; |
| 920 | 920 | } |
| 921 | 921 | $invoice = wpinv_get_invoice_cart(); |
| 922 | - if ( empty( $invoice ) ) { |
|
| 922 | + if ( empty( $invoice ) ) { |
|
| 923 | 923 | return false; |
| 924 | 924 | } |
| 925 | 925 | |
@@ -1216,20 +1216,20 @@ discard block |
||
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | function wpinv_checkout_get_cc_info() { |
| 1219 | - $cc_info = array(); |
|
| 1220 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 1221 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 1222 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 1223 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 1224 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 1225 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 1226 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 1227 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 1228 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 1229 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 1230 | - |
|
| 1231 | - // Return cc info |
|
| 1232 | - return $cc_info; |
|
| 1219 | + $cc_info = array(); |
|
| 1220 | + $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 1221 | + $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 1222 | + $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 1223 | + $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 1224 | + $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 1225 | + $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 1226 | + $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 1227 | + $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 1228 | + $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 1229 | + $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 1230 | + |
|
| 1231 | + // Return cc info |
|
| 1232 | + return $cc_info; |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
@@ -1436,7 +1436,7 @@ discard block |
||
| 1436 | 1436 | $required_fields = wpinv_checkout_required_fields(); |
| 1437 | 1437 | |
| 1438 | 1438 | // Loop through required fields and show error messages |
| 1439 | - if ( !empty( $required_fields ) ) { |
|
| 1439 | + if ( !empty( $required_fields ) ) { |
|
| 1440 | 1440 | foreach ( $required_fields as $field_name => $value ) { |
| 1441 | 1441 | if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
| 1442 | 1442 | wpinv_set_error( $value['error_id'], $value['error_message'] ); |
@@ -1539,7 +1539,7 @@ discard block |
||
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | function wpinv_get_checkout_session() { |
| 1542 | - global $wpi_session; |
|
| 1542 | + global $wpi_session; |
|
| 1543 | 1543 | |
| 1544 | 1544 | return $wpi_session->get( 'wpinv_checkout' ); |
| 1545 | 1545 | } |
@@ -1620,7 +1620,7 @@ discard block |
||
| 1620 | 1620 | $response['data']['taxf'] = $invoice->get_tax( true ); |
| 1621 | 1621 | $response['data']['total'] = $invoice->get_total(); |
| 1622 | 1622 | $response['data']['totalf'] = $invoice->get_total( true ); |
| 1623 | - $response['data']['free'] = $invoice->is_free() && ( ! ( (float) $response['data']['total'] > 0 ) || $invoice->is_free_trial() ) ? true : false; |
|
| 1623 | + $response['data']['free'] = $invoice->is_free() && ( ! ( (float) $response['data']['total'] > 0 ) || $invoice->is_free_trial() ) ? true : false; |
|
| 1624 | 1624 | |
| 1625 | 1625 | wp_send_json( $response ); |
| 1626 | 1626 | } |
@@ -1905,57 +1905,57 @@ discard block |
||
| 1905 | 1905 | } |
| 1906 | 1906 | |
| 1907 | 1907 | function wpinv_get_invoice_id_by_key( $key ) { |
| 1908 | - global $wpdb; |
|
| 1908 | + global $wpdb; |
|
| 1909 | 1909 | |
| 1910 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1910 | + $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1911 | 1911 | |
| 1912 | - if ( $invoice_id != NULL ) |
|
| 1913 | - return $invoice_id; |
|
| 1912 | + if ( $invoice_id != NULL ) |
|
| 1913 | + return $invoice_id; |
|
| 1914 | 1914 | |
| 1915 | - return 0; |
|
| 1915 | + return 0; |
|
| 1916 | 1916 | } |
| 1917 | 1917 | |
| 1918 | 1918 | function wpinv_can_view_receipt( $invoice_key = '' ) { |
| 1919 | - $return = false; |
|
| 1919 | + $return = false; |
|
| 1920 | 1920 | |
| 1921 | - if ( empty( $invoice_key ) ) { |
|
| 1922 | - return $return; |
|
| 1923 | - } |
|
| 1921 | + if ( empty( $invoice_key ) ) { |
|
| 1922 | + return $return; |
|
| 1923 | + } |
|
| 1924 | 1924 | |
| 1925 | - global $wpinv_receipt_args; |
|
| 1925 | + global $wpinv_receipt_args; |
|
| 1926 | 1926 | |
| 1927 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 1928 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
| 1929 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 1930 | - } |
|
| 1927 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 1928 | + if ( isset( $_GET['invoice-id'] ) ) { |
|
| 1929 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 1930 | + } |
|
| 1931 | 1931 | |
| 1932 | - if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
| 1933 | - return $return; |
|
| 1934 | - } |
|
| 1932 | + if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
| 1933 | + return $return; |
|
| 1934 | + } |
|
| 1935 | 1935 | |
| 1936 | - $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
| 1937 | - if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
| 1938 | - return $return; |
|
| 1939 | - } |
|
| 1936 | + $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
| 1937 | + if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
| 1938 | + return $return; |
|
| 1939 | + } |
|
| 1940 | 1940 | |
| 1941 | - if ( is_user_logged_in() ) { |
|
| 1942 | - if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
| 1943 | - $return = true; |
|
| 1944 | - } |
|
| 1945 | - } |
|
| 1941 | + if ( is_user_logged_in() ) { |
|
| 1942 | + if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
| 1943 | + $return = true; |
|
| 1944 | + } |
|
| 1945 | + } |
|
| 1946 | 1946 | |
| 1947 | - $session = wpinv_get_checkout_session(); |
|
| 1948 | - if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
| 1949 | - $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
| 1947 | + $session = wpinv_get_checkout_session(); |
|
| 1948 | + if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
| 1949 | + $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
| 1950 | 1950 | |
| 1951 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 1952 | - $return = $return && $check_key === $invoice_key; |
|
| 1953 | - } else { |
|
| 1954 | - $return = $check_key === $invoice_key; |
|
| 1955 | - } |
|
| 1956 | - } |
|
| 1951 | + if ( wpinv_require_login_to_checkout() ) { |
|
| 1952 | + $return = $return && $check_key === $invoice_key; |
|
| 1953 | + } else { |
|
| 1954 | + $return = $check_key === $invoice_key; |
|
| 1955 | + } |
|
| 1956 | + } |
|
| 1957 | 1957 | |
| 1958 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 1958 | + return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | 1961 | function wpinv_pay_for_invoice() { |
@@ -2263,14 +2263,14 @@ discard block |
||
| 2263 | 2263 | |
| 2264 | 2264 | if ( isset( $_GET['invoice_key'] ) || is_singular( 'wpi_invoice' ) || is_singular( 'wpi_quote' ) ) { |
| 2265 | 2265 | $invoice_key = isset( $_GET['invoice_key'] ) ? urldecode($_GET['invoice_key']) : ''; |
| 2266 | - global $post; |
|
| 2266 | + global $post; |
|
| 2267 | 2267 | |
| 2268 | 2268 | if(!empty($invoice_key)){ |
| 2269 | - $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 2269 | + $invoice_id = wpinv_get_invoice_id_by_key($invoice_key); |
|
| 2270 | 2270 | } else if(!empty( $post ) && ($post->post_type == 'wpi_invoice' || $post->post_type == 'wpi_quote')) { |
| 2271 | - $invoice_id = $post->ID; |
|
| 2271 | + $invoice_id = $post->ID; |
|
| 2272 | 2272 | } else { |
| 2273 | - return; |
|
| 2273 | + return; |
|
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | 2276 | $invoice = new WPInv_Invoice($invoice_id); |
@@ -2279,17 +2279,17 @@ discard block |
||
| 2279 | 2279 | return; |
| 2280 | 2280 | } |
| 2281 | 2281 | |
| 2282 | - if ( is_user_logged_in() ) { |
|
| 2283 | - if ( (int)$invoice->get_user_id() === get_current_user_id() ) { |
|
| 2284 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2285 | - } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2286 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2287 | - } |
|
| 2288 | - } else { |
|
| 2289 | - if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2290 | - update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2291 | - } |
|
| 2292 | - } |
|
| 2282 | + if ( is_user_logged_in() ) { |
|
| 2283 | + if ( (int)$invoice->get_user_id() === get_current_user_id() ) { |
|
| 2284 | + update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2285 | + } else if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2286 | + update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2287 | + } |
|
| 2288 | + } else { |
|
| 2289 | + if ( !wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) { |
|
| 2290 | + update_post_meta($invoice_id,'_wpinv_is_viewed', 1); |
|
| 2291 | + } |
|
| 2292 | + } |
|
| 2293 | 2293 | } |
| 2294 | 2294 | |
| 2295 | 2295 | } |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' ); |
| 30 | 30 | add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' ); |
| 31 | 31 | |
| 32 | - remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
|
| 32 | + remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal'); |
|
| 33 | 33 | } |
| 34 | 34 | add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 ); |
| 35 | 35 | |
@@ -12,124 +12,124 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class WPInv_Session_Handler extends WPInv_Session { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Cookie name used for the session. |
|
| 17 | - * |
|
| 18 | - * @var string cookie name |
|
| 19 | - */ |
|
| 20 | - protected $_cookie; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Stores session expiry. |
|
| 24 | - * |
|
| 25 | - * @var int session due to expire timestamp |
|
| 26 | - */ |
|
| 27 | - protected $_session_expiring; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Stores session due to expire timestamp. |
|
| 31 | - * |
|
| 32 | - * @var string session expiration timestamp |
|
| 33 | - */ |
|
| 34 | - protected $_session_expiration; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * True when the cookie exists. |
|
| 38 | - * |
|
| 39 | - * @var bool Based on whether a cookie exists. |
|
| 40 | - */ |
|
| 41 | - protected $_has_cookie = false; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Table name for session data. |
|
| 45 | - * |
|
| 46 | - * @var string Custom session table name |
|
| 47 | - */ |
|
| 48 | - protected $_table; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Constructor for the session class. |
|
| 52 | - */ |
|
| 53 | - public function __construct() { |
|
| 54 | - |
|
| 55 | - $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH ); |
|
| 15 | + /** |
|
| 16 | + * Cookie name used for the session. |
|
| 17 | + * |
|
| 18 | + * @var string cookie name |
|
| 19 | + */ |
|
| 20 | + protected $_cookie; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Stores session expiry. |
|
| 24 | + * |
|
| 25 | + * @var int session due to expire timestamp |
|
| 26 | + */ |
|
| 27 | + protected $_session_expiring; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Stores session due to expire timestamp. |
|
| 31 | + * |
|
| 32 | + * @var string session expiration timestamp |
|
| 33 | + */ |
|
| 34 | + protected $_session_expiration; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * True when the cookie exists. |
|
| 38 | + * |
|
| 39 | + * @var bool Based on whether a cookie exists. |
|
| 40 | + */ |
|
| 41 | + protected $_has_cookie = false; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Table name for session data. |
|
| 45 | + * |
|
| 46 | + * @var string Custom session table name |
|
| 47 | + */ |
|
| 48 | + protected $_table; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Constructor for the session class. |
|
| 52 | + */ |
|
| 53 | + public function __construct() { |
|
| 54 | + |
|
| 55 | + $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH ); |
|
| 56 | 56 | add_action( 'init', array( $this, 'init' ), -1 ); |
| 57 | - add_action( 'wp_logout', array( $this, 'destroy_session' ) ); |
|
| 58 | - add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 ); |
|
| 59 | - add_action( 'shutdown', array( $this, 'save_data' ), 20 ); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Init hooks and session data. |
|
| 64 | - * |
|
| 65 | - * @since 3.3.0 |
|
| 66 | - */ |
|
| 67 | - public function init() { |
|
| 68 | - $this->init_session_cookie(); |
|
| 69 | - |
|
| 70 | - if ( ! is_user_logged_in() ) { |
|
| 71 | - add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) ); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Setup cookie and customer ID. |
|
| 77 | - * |
|
| 78 | - * @since 3.6.0 |
|
| 79 | - */ |
|
| 80 | - public function init_session_cookie() { |
|
| 81 | - $cookie = $this->get_session_cookie(); |
|
| 82 | - |
|
| 83 | - if ( $cookie ) { |
|
| 84 | - $this->_customer_id = $cookie[0]; |
|
| 85 | - $this->_session_expiration = $cookie[1]; |
|
| 86 | - $this->_session_expiring = $cookie[2]; |
|
| 87 | - $this->_has_cookie = true; |
|
| 88 | - $this->_data = $this->get_session_data(); |
|
| 89 | - |
|
| 90 | - // If the user logs in, update session. |
|
| 91 | - if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) { |
|
| 92 | - $this->_customer_id = get_current_user_id(); |
|
| 93 | - $this->_dirty = true; |
|
| 94 | - $this->save_data(); |
|
| 95 | - $this->set_customer_session_cookie( true ); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - // Update session if its close to expiring. |
|
| 99 | - if ( time() > $this->_session_expiring ) { |
|
| 100 | - $this->set_session_expiration(); |
|
| 101 | - $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); |
|
| 102 | - } |
|
| 103 | - } else { |
|
| 104 | - $this->set_session_expiration(); |
|
| 105 | - $this->_customer_id = $this->generate_customer_id(); |
|
| 106 | - $this->_data = $this->get_session_data(); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Sets the session cookie on-demand (usually after adding an item to the cart). |
|
| 112 | - * |
|
| 113 | - * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set. |
|
| 114 | - * |
|
| 115 | - * Warning: Cookies will only be set if this is called before the headers are sent. |
|
| 116 | - * |
|
| 117 | - * @param bool $set Should the session cookie be set. |
|
| 118 | - */ |
|
| 119 | - public function set_customer_session_cookie( $set ) { |
|
| 120 | - if ( $set ) { |
|
| 121 | - $to_hash = $this->_customer_id . '|' . $this->_session_expiration; |
|
| 122 | - $cookie_hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
| 123 | - $cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash; |
|
| 124 | - $this->_has_cookie = true; |
|
| 125 | - |
|
| 126 | - if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) { |
|
| 127 | - $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true ); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){ |
|
| 57 | + add_action( 'wp_logout', array( $this, 'destroy_session' ) ); |
|
| 58 | + add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 ); |
|
| 59 | + add_action( 'shutdown', array( $this, 'save_data' ), 20 ); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Init hooks and session data. |
|
| 64 | + * |
|
| 65 | + * @since 3.3.0 |
|
| 66 | + */ |
|
| 67 | + public function init() { |
|
| 68 | + $this->init_session_cookie(); |
|
| 69 | + |
|
| 70 | + if ( ! is_user_logged_in() ) { |
|
| 71 | + add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) ); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Setup cookie and customer ID. |
|
| 77 | + * |
|
| 78 | + * @since 3.6.0 |
|
| 79 | + */ |
|
| 80 | + public function init_session_cookie() { |
|
| 81 | + $cookie = $this->get_session_cookie(); |
|
| 82 | + |
|
| 83 | + if ( $cookie ) { |
|
| 84 | + $this->_customer_id = $cookie[0]; |
|
| 85 | + $this->_session_expiration = $cookie[1]; |
|
| 86 | + $this->_session_expiring = $cookie[2]; |
|
| 87 | + $this->_has_cookie = true; |
|
| 88 | + $this->_data = $this->get_session_data(); |
|
| 89 | + |
|
| 90 | + // If the user logs in, update session. |
|
| 91 | + if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) { |
|
| 92 | + $this->_customer_id = get_current_user_id(); |
|
| 93 | + $this->_dirty = true; |
|
| 94 | + $this->save_data(); |
|
| 95 | + $this->set_customer_session_cookie( true ); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + // Update session if its close to expiring. |
|
| 99 | + if ( time() > $this->_session_expiring ) { |
|
| 100 | + $this->set_session_expiration(); |
|
| 101 | + $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); |
|
| 102 | + } |
|
| 103 | + } else { |
|
| 104 | + $this->set_session_expiration(); |
|
| 105 | + $this->_customer_id = $this->generate_customer_id(); |
|
| 106 | + $this->_data = $this->get_session_data(); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Sets the session cookie on-demand (usually after adding an item to the cart). |
|
| 112 | + * |
|
| 113 | + * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set. |
|
| 114 | + * |
|
| 115 | + * Warning: Cookies will only be set if this is called before the headers are sent. |
|
| 116 | + * |
|
| 117 | + * @param bool $set Should the session cookie be set. |
|
| 118 | + */ |
|
| 119 | + public function set_customer_session_cookie( $set ) { |
|
| 120 | + if ( $set ) { |
|
| 121 | + $to_hash = $this->_customer_id . '|' . $this->_session_expiration; |
|
| 122 | + $cookie_hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
| 123 | + $cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash; |
|
| 124 | + $this->_has_cookie = true; |
|
| 125 | + |
|
| 126 | + if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) { |
|
| 127 | + $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true ); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){ |
|
| 133 | 133 | if ( ! headers_sent() ) { |
| 134 | 134 | setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) ); |
| 135 | 135 | } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
@@ -138,96 +138,96 @@ discard block |
||
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Should the session cookie be secure? |
|
| 143 | - * |
|
| 144 | - * @since 3.6.0 |
|
| 145 | - * @return bool |
|
| 146 | - */ |
|
| 147 | - protected function use_secure_cookie() { |
|
| 141 | + /** |
|
| 142 | + * Should the session cookie be secure? |
|
| 143 | + * |
|
| 144 | + * @since 3.6.0 |
|
| 145 | + * @return bool |
|
| 146 | + */ |
|
| 147 | + protected function use_secure_cookie() { |
|
| 148 | 148 | $is_https = false !== strstr( get_option( 'home' ), 'https:' ); |
| 149 | - return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() ); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Return true if the current user has an active session, i.e. a cookie to retrieve values. |
|
| 154 | - * |
|
| 155 | - * @return bool |
|
| 156 | - */ |
|
| 157 | - public function has_session() { |
|
| 158 | - return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Set session expiration. |
|
| 163 | - */ |
|
| 164 | - public function set_session_expiration() { |
|
| 165 | - $this->_session_expiring = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours. |
|
| 166 | - $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours. |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * Generate a unique customer ID for guests, or return user ID if logged in. |
|
| 171 | - * |
|
| 172 | - * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID. |
|
| 173 | - * |
|
| 174 | - * @return string |
|
| 175 | - */ |
|
| 176 | - public function generate_customer_id() { |
|
| 177 | - $customer_id = ''; |
|
| 178 | - |
|
| 179 | - if ( is_user_logged_in() ) { |
|
| 180 | - $customer_id = get_current_user_id(); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - if ( empty( $customer_id ) ) { |
|
| 149 | + return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() ); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Return true if the current user has an active session, i.e. a cookie to retrieve values. |
|
| 154 | + * |
|
| 155 | + * @return bool |
|
| 156 | + */ |
|
| 157 | + public function has_session() { |
|
| 158 | + return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Set session expiration. |
|
| 163 | + */ |
|
| 164 | + public function set_session_expiration() { |
|
| 165 | + $this->_session_expiring = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours. |
|
| 166 | + $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours. |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * Generate a unique customer ID for guests, or return user ID if logged in. |
|
| 171 | + * |
|
| 172 | + * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID. |
|
| 173 | + * |
|
| 174 | + * @return string |
|
| 175 | + */ |
|
| 176 | + public function generate_customer_id() { |
|
| 177 | + $customer_id = ''; |
|
| 178 | + |
|
| 179 | + if ( is_user_logged_in() ) { |
|
| 180 | + $customer_id = get_current_user_id(); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + if ( empty( $customer_id ) ) { |
|
| 184 | 184 | $customer_id = wp_create_nonce('wpinv-session-customer-id'); |
| 185 | - } |
|
| 186 | - |
|
| 187 | - return $customer_id; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Get the session cookie, if set. Otherwise return false. |
|
| 192 | - * |
|
| 193 | - * Session cookies without a customer ID are invalid. |
|
| 194 | - * |
|
| 195 | - * @return bool|array |
|
| 196 | - */ |
|
| 197 | - public function get_session_cookie() { |
|
| 198 | - $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine. |
|
| 199 | - |
|
| 200 | - if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { |
|
| 201 | - return false; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); |
|
| 205 | - |
|
| 206 | - if ( empty( $customer_id ) ) { |
|
| 207 | - return false; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - // Validate hash. |
|
| 211 | - $to_hash = $customer_id . '|' . $session_expiration; |
|
| 212 | - $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
| 213 | - |
|
| 214 | - if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { |
|
| 215 | - return false; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * Get session data. |
|
| 223 | - * |
|
| 224 | - * @return array |
|
| 225 | - */ |
|
| 226 | - public function get_session_data() { |
|
| 227 | - return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array(); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - public function generate_key($customer_id){ |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + return $customer_id; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Get the session cookie, if set. Otherwise return false. |
|
| 192 | + * |
|
| 193 | + * Session cookies without a customer ID are invalid. |
|
| 194 | + * |
|
| 195 | + * @return bool|array |
|
| 196 | + */ |
|
| 197 | + public function get_session_cookie() { |
|
| 198 | + $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine. |
|
| 199 | + |
|
| 200 | + if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { |
|
| 201 | + return false; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); |
|
| 205 | + |
|
| 206 | + if ( empty( $customer_id ) ) { |
|
| 207 | + return false; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + // Validate hash. |
|
| 211 | + $to_hash = $customer_id . '|' . $session_expiration; |
|
| 212 | + $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
| 213 | + |
|
| 214 | + if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { |
|
| 215 | + return false; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * Get session data. |
|
| 223 | + * |
|
| 224 | + * @return array |
|
| 225 | + */ |
|
| 226 | + public function get_session_data() { |
|
| 227 | + return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array(); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + public function generate_key($customer_id){ |
|
| 231 | 231 | if(!$customer_id){ |
| 232 | 232 | return; |
| 233 | 233 | } |
@@ -235,62 +235,62 @@ discard block |
||
| 235 | 235 | return 'wpi_trans_'.$customer_id; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Save data. |
|
| 240 | - */ |
|
| 241 | - public function save_data() { |
|
| 242 | - // Dirty if something changed - prevents saving nothing new. |
|
| 243 | - if ( $this->_dirty && $this->has_session() ) { |
|
| 238 | + /** |
|
| 239 | + * Save data. |
|
| 240 | + */ |
|
| 241 | + public function save_data() { |
|
| 242 | + // Dirty if something changed - prevents saving nothing new. |
|
| 243 | + if ( $this->_dirty && $this->has_session() ) { |
|
| 244 | 244 | |
| 245 | 245 | set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration); |
| 246 | 246 | |
| 247 | - $this->_dirty = false; |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * Destroy all session data. |
|
| 253 | - */ |
|
| 254 | - public function destroy_session() { |
|
| 255 | - $this->delete_session( $this->_customer_id ); |
|
| 256 | - $this->forget_session(); |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * Forget all session data without destroying it. |
|
| 261 | - */ |
|
| 262 | - public function forget_session() { |
|
| 263 | - $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true ); |
|
| 264 | - |
|
| 265 | - wpinv_empty_cart(); |
|
| 266 | - |
|
| 267 | - $this->_data = array(); |
|
| 268 | - $this->_dirty = false; |
|
| 269 | - $this->_customer_id = $this->generate_customer_id(); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * When a user is logged out, ensure they have a unique nonce by using the customer/session ID. |
|
| 274 | - * |
|
| 275 | - * @param int $uid User ID. |
|
| 276 | - * @return string |
|
| 277 | - */ |
|
| 278 | - public function nonce_user_logged_out( $uid ) { |
|
| 279 | - return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * Returns the session. |
|
| 284 | - * |
|
| 285 | - * @param string $customer_id Customer ID. |
|
| 286 | - * @param mixed $default Default session value. |
|
| 287 | - * @return string|array |
|
| 288 | - */ |
|
| 289 | - public function get_session( $customer_id, $default = false ) { |
|
| 290 | - |
|
| 291 | - if ( defined( 'WP_SETUP_CONFIG' ) ) { |
|
| 292 | - return array(); |
|
| 293 | - } |
|
| 247 | + $this->_dirty = false; |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * Destroy all session data. |
|
| 253 | + */ |
|
| 254 | + public function destroy_session() { |
|
| 255 | + $this->delete_session( $this->_customer_id ); |
|
| 256 | + $this->forget_session(); |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * Forget all session data without destroying it. |
|
| 261 | + */ |
|
| 262 | + public function forget_session() { |
|
| 263 | + $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true ); |
|
| 264 | + |
|
| 265 | + wpinv_empty_cart(); |
|
| 266 | + |
|
| 267 | + $this->_data = array(); |
|
| 268 | + $this->_dirty = false; |
|
| 269 | + $this->_customer_id = $this->generate_customer_id(); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * When a user is logged out, ensure they have a unique nonce by using the customer/session ID. |
|
| 274 | + * |
|
| 275 | + * @param int $uid User ID. |
|
| 276 | + * @return string |
|
| 277 | + */ |
|
| 278 | + public function nonce_user_logged_out( $uid ) { |
|
| 279 | + return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * Returns the session. |
|
| 284 | + * |
|
| 285 | + * @param string $customer_id Customer ID. |
|
| 286 | + * @param mixed $default Default session value. |
|
| 287 | + * @return string|array |
|
| 288 | + */ |
|
| 289 | + public function get_session( $customer_id, $default = false ) { |
|
| 290 | + |
|
| 291 | + if ( defined( 'WP_SETUP_CONFIG' ) ) { |
|
| 292 | + return array(); |
|
| 293 | + } |
|
| 294 | 294 | |
| 295 | 295 | if ( !is_user_logged_in() ) { |
| 296 | 296 | if(!wp_verify_nonce( $customer_id, 'wpinv-session-customer-id' )){ |
@@ -305,32 +305,32 @@ discard block |
||
| 305 | 305 | $value = $default; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - return maybe_unserialize( $value ); |
|
| 309 | - } |
|
| 308 | + return maybe_unserialize( $value ); |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - /** |
|
| 312 | - * Delete the session from the cache and database. |
|
| 313 | - * |
|
| 314 | - * @param int $customer_id Customer ID. |
|
| 315 | - */ |
|
| 316 | - public function delete_session( $customer_id ) { |
|
| 311 | + /** |
|
| 312 | + * Delete the session from the cache and database. |
|
| 313 | + * |
|
| 314 | + * @param int $customer_id Customer ID. |
|
| 315 | + */ |
|
| 316 | + public function delete_session( $customer_id ) { |
|
| 317 | 317 | |
| 318 | 318 | $key = $this->generate_key($customer_id); |
| 319 | 319 | |
| 320 | - delete_transient($key); |
|
| 321 | - } |
|
| 320 | + delete_transient($key); |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - /** |
|
| 324 | - * Update the session expiry timestamp. |
|
| 325 | - * |
|
| 326 | - * @param string $customer_id Customer ID. |
|
| 327 | - * @param int $timestamp Timestamp to expire the cookie. |
|
| 328 | - */ |
|
| 329 | - public function update_session_timestamp( $customer_id, $timestamp ) { |
|
| 323 | + /** |
|
| 324 | + * Update the session expiry timestamp. |
|
| 325 | + * |
|
| 326 | + * @param string $customer_id Customer ID. |
|
| 327 | + * @param int $timestamp Timestamp to expire the cookie. |
|
| 328 | + */ |
|
| 329 | + public function update_session_timestamp( $customer_id, $timestamp ) { |
|
| 330 | 330 | |
| 331 | 331 | set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp); |
| 332 | 332 | |
| 333 | - } |
|
| 333 | + } |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | global $wpi_session; |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | - exit; |
|
| 9 | + exit; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -15,71 +15,71 @@ discard block |
||
| 15 | 15 | class WPInv_Admin_Addons extends Ayecode_Addons { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Get the extensions page tabs. |
|
| 20 | - * |
|
| 21 | - * @return array of tabs. |
|
| 22 | - */ |
|
| 23 | - public function get_tabs(){ |
|
| 24 | - $tabs = array( |
|
| 25 | - 'addons' => __("Addons", "invoicing"), |
|
| 18 | + /** |
|
| 19 | + * Get the extensions page tabs. |
|
| 20 | + * |
|
| 21 | + * @return array of tabs. |
|
| 22 | + */ |
|
| 23 | + public function get_tabs(){ |
|
| 24 | + $tabs = array( |
|
| 25 | + 'addons' => __("Addons", "invoicing"), |
|
| 26 | 26 | 'gateways' => __("Payment Gateways", "invoicing"), |
| 27 | 27 | 'recommended_plugins' => __("Recommended plugins", "invoicing"), |
| 28 | 28 | 'membership' => __("Membership", "invoicing"), |
| 29 | - ); |
|
| 30 | - |
|
| 31 | - return $tabs; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Get section content for the addons screen. |
|
| 36 | - * |
|
| 37 | - * @param string $section_id |
|
| 38 | - * |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - public function get_section_data( $section_id ) { |
|
| 42 | - $section = self::get_tab( $section_id ); |
|
| 43 | - $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
| 44 | - $section_data = new stdClass(); |
|
| 45 | - |
|
| 46 | - if($section_id=='recommended_plugins'){ |
|
| 47 | - $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
| 48 | - } |
|
| 49 | - elseif ( ! empty( $section ) ) { |
|
| 50 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
| 51 | - //if ( 1==1) { |
|
| 52 | - |
|
| 53 | - $query_args = array( 'category' => $section_id, 'number' => 100); |
|
| 54 | - $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
| 55 | - |
|
| 56 | - $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
| 57 | - |
|
| 58 | - if ( ! is_wp_error( $raw_section ) ) { |
|
| 59 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
| 60 | - |
|
| 61 | - if ( ! empty( $section_data->products ) ) { |
|
| 62 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - $products = isset($section_data->products) ? $section_data->products : ''; |
|
| 69 | - |
|
| 70 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * Outputs a button. |
|
| 75 | - *ccc |
|
| 76 | - * @param string $url |
|
| 77 | - * @param string $text |
|
| 78 | - * @param string $theme |
|
| 79 | - * @param string $plugin |
|
| 80 | - */ |
|
| 81 | - public function output_button( $addon ) { |
|
| 82 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 29 | + ); |
|
| 30 | + |
|
| 31 | + return $tabs; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Get section content for the addons screen. |
|
| 36 | + * |
|
| 37 | + * @param string $section_id |
|
| 38 | + * |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + public function get_section_data( $section_id ) { |
|
| 42 | + $section = self::get_tab( $section_id ); |
|
| 43 | + $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
| 44 | + $section_data = new stdClass(); |
|
| 45 | + |
|
| 46 | + if($section_id=='recommended_plugins'){ |
|
| 47 | + $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
| 48 | + } |
|
| 49 | + elseif ( ! empty( $section ) ) { |
|
| 50 | + if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
| 51 | + //if ( 1==1) { |
|
| 52 | + |
|
| 53 | + $query_args = array( 'category' => $section_id, 'number' => 100); |
|
| 54 | + $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
| 55 | + |
|
| 56 | + $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
| 57 | + |
|
| 58 | + if ( ! is_wp_error( $raw_section ) ) { |
|
| 59 | + $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
| 60 | + |
|
| 61 | + if ( ! empty( $section_data->products ) ) { |
|
| 62 | + set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + $products = isset($section_data->products) ? $section_data->products : ''; |
|
| 69 | + |
|
| 70 | + return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * Outputs a button. |
|
| 75 | + *ccc |
|
| 76 | + * @param string $url |
|
| 77 | + * @param string $text |
|
| 78 | + * @param string $theme |
|
| 79 | + * @param string $plugin |
|
| 80 | + */ |
|
| 81 | + public function output_button( $addon ) { |
|
| 82 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 83 | 83 | // $button_text = __('Free','invoicing'); |
| 84 | 84 | // $licensing = false; |
| 85 | 85 | // $installed = false; |
@@ -91,123 +91,123 @@ discard block |
||
| 91 | 91 | // $install_status = 'get'; |
| 92 | 92 | // $onclick = ''; |
| 93 | 93 | |
| 94 | - $wp_org_themes = array('supreme-directory','directory-starter'); |
|
| 95 | - |
|
| 96 | - $button_args = array( |
|
| 97 | - 'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab, |
|
| 98 | - 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
| 99 | - 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
| 100 | - 'button_text' => __('Free','invoicing'), |
|
| 101 | - 'price_text' => __('Free','invoicing'), |
|
| 102 | - 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
| 103 | - 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
| 104 | - 'class' => 'button-primary', |
|
| 105 | - 'install_status' => 'get', |
|
| 106 | - 'installed' => false, |
|
| 107 | - 'price' => '', |
|
| 108 | - 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
| 109 | - 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
| 110 | - 'onclick' => '', |
|
| 111 | - 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
| 112 | - 'active' => false, |
|
| 113 | - 'file' => '', |
|
| 114 | - 'update_url' => '', |
|
| 115 | - ); |
|
| 116 | - |
|
| 117 | - if( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
| 118 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 119 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 120 | - $status = self::install_plugin_install_status($addon); |
|
| 121 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 122 | - if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
| 123 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 124 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 125 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 126 | - $button_args['installed'] = self::is_theme_installed($addon); |
|
| 127 | - if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
| 128 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 129 | - } |
|
| 130 | - }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
| 131 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 132 | - $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
| 133 | - $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
| 134 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // set price |
|
| 138 | - if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
| 139 | - if(is_object($addon->pricing)){ |
|
| 140 | - $prices = (Array)$addon->pricing; |
|
| 141 | - $button_args['price'] = reset($prices); |
|
| 142 | - }elseif(isset($addon->pricing)){ |
|
| 143 | - $button_args['price'] = $addon->pricing; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // set price text |
|
| 148 | - if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
| 149 | - $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - // set if installed |
|
| 154 | - if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
| 155 | - $button_args['installed'] = true; |
|
| 156 | - } |
|
| 94 | + $wp_org_themes = array('supreme-directory','directory-starter'); |
|
| 95 | + |
|
| 96 | + $button_args = array( |
|
| 97 | + 'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab, |
|
| 98 | + 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
| 99 | + 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
| 100 | + 'button_text' => __('Free','invoicing'), |
|
| 101 | + 'price_text' => __('Free','invoicing'), |
|
| 102 | + 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
| 103 | + 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
| 104 | + 'class' => 'button-primary', |
|
| 105 | + 'install_status' => 'get', |
|
| 106 | + 'installed' => false, |
|
| 107 | + 'price' => '', |
|
| 108 | + 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
| 109 | + 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
| 110 | + 'onclick' => '', |
|
| 111 | + 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
| 112 | + 'active' => false, |
|
| 113 | + 'file' => '', |
|
| 114 | + 'update_url' => '', |
|
| 115 | + ); |
|
| 116 | + |
|
| 117 | + if( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
| 118 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 119 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 120 | + $status = self::install_plugin_install_status($addon); |
|
| 121 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 122 | + if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
| 123 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 124 | + }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
| 125 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
| 126 | + $button_args['installed'] = self::is_theme_installed($addon); |
|
| 127 | + if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
| 128 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
| 129 | + } |
|
| 130 | + }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
| 131 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
| 132 | + $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
| 133 | + $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
| 134 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // set price |
|
| 138 | + if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
| 139 | + if(is_object($addon->pricing)){ |
|
| 140 | + $prices = (Array)$addon->pricing; |
|
| 141 | + $button_args['price'] = reset($prices); |
|
| 142 | + }elseif(isset($addon->pricing)){ |
|
| 143 | + $button_args['price'] = $addon->pricing; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // set price text |
|
| 148 | + if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
| 149 | + $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + // set if installed |
|
| 154 | + if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
| 155 | + $button_args['installed'] = true; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | 158 | // print_r($button_args); |
| 159 | - // set if active |
|
| 160 | - if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
| 161 | - if($button_args['type'] != 'themes'){ |
|
| 162 | - $button_args['active'] = is_plugin_active($button_args['file']); |
|
| 163 | - }else{ |
|
| 164 | - $button_args['active'] = self::is_theme_active($addon); |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // set button text and class |
|
| 169 | - if($button_args['active']){ |
|
| 170 | - $button_args['button_text'] = __('Active','invoicing'); |
|
| 171 | - $button_args['class'] = ' button-secondary disabled '; |
|
| 172 | - }elseif($button_args['installed']){ |
|
| 173 | - $button_args['button_text'] = __('Activate','invoicing'); |
|
| 174 | - |
|
| 175 | - if($button_args['type'] != 'themes'){ |
|
| 176 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 177 | - $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
| 178 | - }else{ |
|
| 179 | - $button_args['url'] = '#'; |
|
| 180 | - } |
|
| 181 | - }else{ |
|
| 182 | - if ( current_user_can( 'switch_themes' ) ) { |
|
| 183 | - $button_args['url'] = self::get_theme_activation_url($addon); |
|
| 184 | - }else{ |
|
| 185 | - $button_args['url'] = '#'; |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - }else{ |
|
| 190 | - if($button_args['type'] == 'recommended_plugins'){ |
|
| 191 | - $button_args['button_text'] = __('Install','invoicing'); |
|
| 192 | - }else{ |
|
| 193 | - $button_args['button_text'] = __('Get it','invoicing'); |
|
| 194 | - |
|
| 195 | - /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
| 159 | + // set if active |
|
| 160 | + if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
| 161 | + if($button_args['type'] != 'themes'){ |
|
| 162 | + $button_args['active'] = is_plugin_active($button_args['file']); |
|
| 163 | + }else{ |
|
| 164 | + $button_args['active'] = self::is_theme_active($addon); |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // set button text and class |
|
| 169 | + if($button_args['active']){ |
|
| 170 | + $button_args['button_text'] = __('Active','invoicing'); |
|
| 171 | + $button_args['class'] = ' button-secondary disabled '; |
|
| 172 | + }elseif($button_args['installed']){ |
|
| 173 | + $button_args['button_text'] = __('Activate','invoicing'); |
|
| 174 | + |
|
| 175 | + if($button_args['type'] != 'themes'){ |
|
| 176 | + if ( current_user_can( 'manage_options' ) ) { |
|
| 177 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
| 178 | + }else{ |
|
| 179 | + $button_args['url'] = '#'; |
|
| 180 | + } |
|
| 181 | + }else{ |
|
| 182 | + if ( current_user_can( 'switch_themes' ) ) { |
|
| 183 | + $button_args['url'] = self::get_theme_activation_url($addon); |
|
| 184 | + }else{ |
|
| 185 | + $button_args['url'] = '#'; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + }else{ |
|
| 190 | + if($button_args['type'] == 'recommended_plugins'){ |
|
| 191 | + $button_args['button_text'] = __('Install','invoicing'); |
|
| 192 | + }else{ |
|
| 193 | + $button_args['button_text'] = __('Get it','invoicing'); |
|
| 194 | + |
|
| 195 | + /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
| 196 | 196 | $button_args['button_text'] = __('Install','invoicing'); |
| 197 | 197 | $button_args['url'] = self::get_theme_install_url($button_args['slug']); |
| 198 | 198 | $button_args['onclick'] = 'gd_set_button_installing(this);'; |
| 199 | 199 | }*/ |
| 200 | 200 | |
| 201 | - } |
|
| 202 | - } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | |
| 205 | - // filter the button arguments |
|
| 206 | - $button_args = apply_filters('edd_api_button_args',$button_args); |
|
| 205 | + // filter the button arguments |
|
| 206 | + $button_args = apply_filters('edd_api_button_args',$button_args); |
|
| 207 | 207 | // print_r($button_args); |
| 208 | - // set price text |
|
| 209 | - if(isset($button_args['price_text'])){ |
|
| 210 | - ?> |
|
| 208 | + // set price text |
|
| 209 | + if(isset($button_args['price_text'])){ |
|
| 210 | + ?> |
|
| 211 | 211 | <a |
| 212 | 212 | target="_blank" |
| 213 | 213 | class="addons-price-text" |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | <?php echo esc_html( $button_args['price_text'] ); ?> |
| 216 | 216 | </a> |
| 217 | 217 | <?php |
| 218 | - } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | 220 | |
| 221 | - $target = ''; |
|
| 222 | - if ( ! empty( $button_args['url'] ) ) { |
|
| 223 | - $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
| 224 | - } |
|
| 221 | + $target = ''; |
|
| 222 | + if ( ! empty( $button_args['url'] ) ) { |
|
| 223 | + $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - ?> |
|
| 226 | + ?> |
|
| 227 | 227 | <a |
| 228 | 228 | data-licence="<?php echo esc_attr($button_args['license']);?>" |
| 229 | 229 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>" |
@@ -246,28 +246,28 @@ discard block |
||
| 246 | 246 | <?php |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - } |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * Handles output of the addons page in admin. |
|
| 254 | - */ |
|
| 255 | - public function output() { |
|
| 256 | - $tabs = self::get_tabs(); |
|
| 257 | - $sections = self::get_sections(); |
|
| 258 | - $theme = wp_get_theme(); |
|
| 259 | - $section_keys = array_keys( $sections ); |
|
| 260 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
| 261 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 262 | - include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * A list of recommended wp.org plugins. |
|
| 267 | - * @return array |
|
| 268 | - */ |
|
| 269 | - public function get_recommend_wp_plugins(){ |
|
| 270 | - $plugins = array( |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * Handles output of the addons page in admin. |
|
| 254 | + */ |
|
| 255 | + public function output() { |
|
| 256 | + $tabs = self::get_tabs(); |
|
| 257 | + $sections = self::get_sections(); |
|
| 258 | + $theme = wp_get_theme(); |
|
| 259 | + $section_keys = array_keys( $sections ); |
|
| 260 | + $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
| 261 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
| 262 | + include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * A list of recommended wp.org plugins. |
|
| 267 | + * @return array |
|
| 268 | + */ |
|
| 269 | + public function get_recommend_wp_plugins(){ |
|
| 270 | + $plugins = array( |
|
| 271 | 271 | 'invoicing-quotes' => array( |
| 272 | 272 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
| 273 | 273 | 'slug' => 'invoicing-quotes', |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | 'name' => 'UsersWP', |
| 287 | 287 | 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'), |
| 288 | 288 | ), |
| 289 | - ); |
|
| 289 | + ); |
|
| 290 | 290 | |
| 291 | - return $plugins; |
|
| 292 | - } |
|
| 291 | + return $plugins; |
|
| 292 | + } |
|
| 293 | 293 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | * |
| 5 | 5 | */ |
| 6 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | - exit; |
|
| 7 | + exit; |
|
| 8 | 8 | } |
| 9 | 9 | add_ThickBox(); |
| 10 | 10 | ?> |
@@ -14,18 +14,18 @@ discard block |
||
| 14 | 14 | <?php if ( $tabs ){ ?> |
| 15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
| 16 | 16 | <?php |
| 17 | - foreach ( $tabs as $name => $label ) { |
|
| 18 | - echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
| 19 | - } |
|
| 20 | - do_action( 'wpi_addons_tabs' ); |
|
| 21 | - ?> |
|
| 17 | + foreach ( $tabs as $name => $label ) { |
|
| 18 | + echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
| 19 | + } |
|
| 20 | + do_action( 'wpi_addons_tabs' ); |
|
| 21 | + ?> |
|
| 22 | 22 | </nav> |
| 23 | 23 | |
| 24 | 24 | <?php |
| 25 | 25 | |
| 26 | - if($current_tab == 'membership'){ |
|
| 26 | + if($current_tab == 'membership'){ |
|
| 27 | 27 | |
| 28 | - ?> |
|
| 28 | + ?> |
|
| 29 | 29 | |
| 30 | 30 | <div class="wpi-membership-tab-conatiner"> |
| 31 | 31 | <div class="membership-content"> |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | <h2><?php _e("Have a membership key?","invoicing");?></h2> |
| 37 | 37 | <p> |
| 38 | 38 | <?php |
| 39 | - $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1'); |
|
| 40 | - echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351)); |
|
| 41 | - ?> |
|
| 39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1'); |
|
| 40 | + echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351)); |
|
| 41 | + ?> |
|
| 42 | 42 | </p> |
| 43 | 43 | <?php }?> |
| 44 | 44 | |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | <div class="feature-list"> |
| 49 | 49 | <ul> |
| 50 | 50 | <?php |
| 51 | - $addon_obj = new WPInv_Admin_Addons(); |
|
| 52 | - if ($addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
| 53 | - foreach ( $addons as $addon ) { |
|
| 54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - ?> |
|
| 51 | + $addon_obj = new WPInv_Admin_Addons(); |
|
| 52 | + if ($addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
| 53 | + foreach ( $addons as $addon ) { |
|
| 54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + ?> |
|
| 58 | 58 | </ul> |
| 59 | 59 | |
| 60 | 60 | <div class="feature-cta"> |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | <h3><?php _e("Included Gateways:","invoicing");?></h3> |
| 66 | 66 | <ul> |
| 67 | 67 | <?php |
| 68 | - if ($addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
| 69 | - foreach ( $addons as $addon ) { |
|
| 70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - ?> |
|
| 68 | + if ($addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
| 69 | + foreach ( $addons as $addon ) { |
|
| 70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + ?> |
|
| 74 | 74 | </ul> |
| 75 | 75 | </div> |
| 76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | <div class="testimonial-content"> |
| 82 | 82 | <div class="t-image"> |
| 83 | 83 | <?php |
| 84 | - echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > '; |
|
| 85 | - ?> |
|
| 84 | + echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > '; |
|
| 85 | + ?> |
|
| 86 | 86 | </div> |
| 87 | 87 | <div class="t-content"> |
| 88 | 88 | <p> |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | <div class="testimonial-content"> |
| 102 | 102 | <div class="t-image"> |
| 103 | 103 | <?php |
| 104 | - echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > '; |
|
| 105 | - ?> |
|
| 104 | + echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > '; |
|
| 105 | + ?> |
|
| 106 | 106 | </div> |
| 107 | 107 | <div class="t-content"> |
| 108 | 108 | <p> |
@@ -126,20 +126,20 @@ discard block |
||
| 126 | 126 | </div> |
| 127 | 127 | </div> |
| 128 | 128 | <?php |
| 129 | - }else{ |
|
| 130 | - $installed_plugins = get_plugins(); |
|
| 129 | + }else{ |
|
| 130 | + $installed_plugins = get_plugins(); |
|
| 131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
| 132 | - if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
| 133 | - ?> |
|
| 132 | + if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
| 133 | + ?> |
|
| 134 | 134 | <ul class="wpi-products"><?php foreach ( $addons as $addon ) : |
| 135 | 135 | if(965==$addon->info->id){continue;}// don't show quote add on |
| 136 | - ?><li class="wpi-product"> |
|
| 136 | + ?><li class="wpi-product"> |
|
| 137 | 137 | <div class="wpi-product-title"> |
| 138 | 138 | <h3><?php |
| 139 | - if ( ! empty( $addon->info->excerpt) ){ |
|
| 140 | - echo wpi_help_tip( $addon->info->excerpt ); |
|
| 141 | - } |
|
| 142 | - echo esc_html( $addon->info->title ); ?></h3> |
|
| 139 | + if ( ! empty( $addon->info->excerpt) ){ |
|
| 140 | + echo wpi_help_tip( $addon->info->excerpt ); |
|
| 141 | + } |
|
| 142 | + echo esc_html( $addon->info->title ); ?></h3> |
|
| 143 | 143 | </div> |
| 144 | 144 | |
| 145 | 145 | <span class="wpi-product-image"> |
@@ -147,27 +147,27 @@ discard block |
||
| 147 | 147 | <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
| 148 | 148 | <?php endif; |
| 149 | 149 | |
| 150 | - if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){ |
|
| 151 | - echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
| 152 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
| 153 | - echo '</a>'; |
|
| 154 | - }elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){ |
|
| 155 | - if(defined('WP_EASY_UPDATES_ACTIVE')){ |
|
| 156 | - $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com&TB_iframe=true'); |
|
| 157 | - }else{ |
|
| 158 | - // if installed show activation link |
|
| 159 | - if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
|
| 160 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
| 161 | - }else{ |
|
| 162 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - echo '<a href="'.$url.'" class="thickbox">'; |
|
| 166 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
| 167 | - echo '</a>'; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - ?> |
|
| 150 | + if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){ |
|
| 151 | + echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
| 152 | + echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
| 153 | + echo '</a>'; |
|
| 154 | + }elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){ |
|
| 155 | + if(defined('WP_EASY_UPDATES_ACTIVE')){ |
|
| 156 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com&TB_iframe=true'); |
|
| 157 | + }else{ |
|
| 158 | + // if installed show activation link |
|
| 159 | + if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
|
| 160 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
| 161 | + }else{ |
|
| 162 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + echo '<a href="'.$url.'" class="thickbox">'; |
|
| 166 | + echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
| 167 | + echo '</a>'; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + ?> |
|
| 171 | 171 | |
| 172 | 172 | </span> |
| 173 | 173 | |
@@ -175,15 +175,15 @@ discard block |
||
| 175 | 175 | <span class="wpi-product-button"> |
| 176 | 176 | <?php |
| 177 | 177 | $addon_obj->output_button( $addon ); |
| 178 | - ?> |
|
| 178 | + ?> |
|
| 179 | 179 | </span> |
| 180 | 180 | |
| 181 | 181 | <span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul> |
| 182 | 182 | <?php endif; |
| 183 | - } |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - } |
|
| 186 | - ?> |
|
| 185 | + } |
|
| 186 | + ?> |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | <div class="clearfix" ></div> |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | <input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button> |
| 203 | 203 | <br> |
| 204 | 204 | <?php |
| 205 | - echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' ); |
|
| 206 | - ?> |
|
| 205 | + echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' ); |
|
| 206 | + ?> |
|
| 207 | 207 | </span> |
| 208 | 208 | </div> |
| 209 | 209 | |
@@ -46,25 +46,25 @@ |
||
| 46 | 46 | parent::__construct( $options ); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * The Super block output function. |
|
| 51 | - * |
|
| 52 | - * @param array $args |
|
| 53 | - * @param array $widget_args |
|
| 54 | - * @param string $content |
|
| 55 | - * |
|
| 56 | - * @return mixed|string|bool |
|
| 57 | - */ |
|
| 49 | + /** |
|
| 50 | + * The Super block output function. |
|
| 51 | + * |
|
| 52 | + * @param array $args |
|
| 53 | + * @param array $widget_args |
|
| 54 | + * @param string $content |
|
| 55 | + * |
|
| 56 | + * @return mixed|string|bool |
|
| 57 | + */ |
|
| 58 | 58 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 59 | 59 | |
| 60 | - ob_start(); |
|
| 60 | + ob_start(); |
|
| 61 | 61 | |
| 62 | - do_action( 'wpinv_before_user_invoice_history' ); |
|
| 63 | - wpinv_get_template_part( 'wpinv-invoice-history' ); |
|
| 64 | - do_action( 'wpinv_after_user_invoice_history' ); |
|
| 62 | + do_action( 'wpinv_before_user_invoice_history' ); |
|
| 63 | + wpinv_get_template_part( 'wpinv-invoice-history' ); |
|
| 64 | + do_action( 'wpinv_after_user_invoice_history' ); |
|
| 65 | 65 | |
| 66 | - $output = ob_get_clean(); |
|
| 67 | - return trim($output); |
|
| 66 | + $output = ob_get_clean(); |
|
| 67 | + return trim($output); |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
@@ -44,22 +44,22 @@ |
||
| 44 | 44 | parent::__construct( $options ); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * The Super block output function. |
|
| 49 | - * |
|
| 50 | - * @param array $args |
|
| 51 | - * @param array $widget_args |
|
| 52 | - * @param string $content |
|
| 53 | - * |
|
| 54 | - * @return mixed|string|bool |
|
| 55 | - */ |
|
| 47 | + /** |
|
| 48 | + * The Super block output function. |
|
| 49 | + * |
|
| 50 | + * @param array $args |
|
| 51 | + * @param array $widget_args |
|
| 52 | + * @param string $content |
|
| 53 | + * |
|
| 54 | + * @return mixed|string|bool |
|
| 55 | + */ |
|
| 56 | 56 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
| 57 | 57 | |
| 58 | - ob_start(); |
|
| 58 | + ob_start(); |
|
| 59 | 59 | |
| 60 | - wpinv_print_errors(); |
|
| 60 | + wpinv_print_errors(); |
|
| 61 | 61 | |
| 62 | - return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
|
| 62 | + return '<div class="wpinv">' . ob_get_clean() . '</div>'; |
|
| 63 | 63 | |
| 64 | 64 | } |
| 65 | 65 | |